Saturday, 11 July 2015

AX2012 R3 CU8 : X++ code to get resource requirements for production routes

Hi Friends,
The below X++ code, can be used to get the resource type and the resource ID defined on the production routes for a production order. Thanks to the methods available on ProdRoute table out of the box which makes this easy.

Below is the job simulating the code:

To quickly reuse the code here it is:

static void Job45(Args _args)
    ProdRoute                       prodRoute;
    RecId                           recId;
    WrkCtrId                        wrkCtrGrpId;
    ProdId                          prodId = "W000170";
    WrkCtrActivityRequirementType   relationShipType;
    WrkCtrActivityRequirement       wrkCtrActivityRequirement;

    while select prodRoute
        where prodRoute.ProdId == prodId
        recId = prodRoute.activityRequirementSet().RecId;

        select WrkCtrActivityRequirement
            where WrkCtrActivityRequirement.ActivityRequirementSet == recid;
        wrkCtrGrpId =  WrkCtrActivityRequirement.requirementEdit();
        relationShipType = WrkCtrActivityRequirement.RelationshipType;
        info(strFmt("%1, %2",relationShipType,wrkCtrGrpId));

Have a great day.