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.

4 comments:

  1. hi

    how to update resource or wrkctrgrpid for proudction order

    ReplyDelete
  2. Nice post...I look forward to reading more, and getting a more active part in the talks here, whilst picking up some knowledge as well..

    Pass Box manufacturers

    ReplyDelete
  3. Madam, we are integrating production module(Job Registration ) with 3 'rd party software , they need Prodroute along with wrkctrid, some records are not fetching in below SQL Query as routeoprefid is blank .

    please let me know the right table to join and the get wrkctrid in Sql Query .


    FROM PRODROUTE AS T JOIN PRODTABLE AS T7 ON T.PRODID=T7.PRODID JOIN
    ROUTEOPR AS T1 ON T.ROUTEOPRREFRECID=T1.RECID join
    inventtable as nT1 oN t7.ITEMID=Nt1.ITEMID aNd nT1.DATAAREAID=t1.DATAAREAID JOIN
    WRKCTRROUTEOPRACTIVITY AS T2 ON T1.RECID=T2.ROUTEOPR JOIN
    WRKCTRACTIVITYREQUIREMENTSET AS T3 ON T3.ACTIVITY=T2.ACTIVITY JOIN
    WRKCTRACTIVITYREQUIREMENT T4 ON T4.ACTIVITYREQUIREMENTSET=T3.RECID JOIN
    WRKCTRACTIVITYRESOURCEREQUIREMENT AS T5 ON T5.ACTIVITYREQUIREMENT=T4.RECID JOIN
    WRKCTRTABLE AS T6 ON T6.WRKCTRID=T5.WRKCTRID


    ReplyDelete