Get top level refID in planned production orders explosion tab

Hello,

I have created a new field in between Number and reference type in the below screenshot and I am trying to display the topLevel reference itemId. 

In order to achieve it, I am trying to get the top level refId. Please see the below screenshot for better understanding.

I tried with the following steps,

Created a new field in the table ReqTrans -> Created a display method with the following code to get the ToplevelRefID

public static display PoolId displayPool(ReqTrans _this)
    {
        PoolId           poolId;
        ReqPO            reqPO;

        switch (_this.RefType)
        {
            case ReqRefType::BOMLine :
            case ReqRefType::BOMPlannedOrder :
               
                poolId = ReqPO::find(_this.PlanVersion,_this.RefId).ItemId;

                break;
       
                   default:
        }
        return poolId;
    }

I have used switch case cos I have other scenarios also dont mind that.

Please help me to achieve this.

Thanks

  • ReqTransCov has that relation between issue and receipt ReqTans. \Data Dictionary\Tables\ReqTrans\Methods\selectCov
    Something like this, ReqTrans::findRecId(reqTransChild.selectCov().IssueRecId).RefId; // reqTransChild is your current reqTrans
  • In reply to Kranthi:

    Hello Kranthi,

    Thaks for your reply. I modified the code as you said but I am getting the same,

        public static display PoolId displayPool(ReqTrans _this)
        {
            PoolId           poolId;
            ReqPO            reqPO;
                  
            switch (_this.RefType)
            {
    
                case ReqRefType::BOMLine :
                case ReqRefType::BOMPlannedOrder :
                   
                    //poolId = ReqPO::find(_this.PlanVersion,ProdTable::findTopLevelRef_this.RefId).ProdId).ItemId;
                    poolId = ReqPO::find(_this.PlanVersion,ReqTrans::findRecId(_this.selectCov().IssueRecId).RefId).ItemId;
          
    
                    break;
                   
                default:
            }
            return poolId;

    I am not getting the topmost level . Instead of getting the top reference. Please see the following image for your better understanding,

    In the above image on choosing the cube Timer, I am getting 0750 instead I should get 10101.

    Thanks

  • In reply to Wekey:

    It didn't found any such existing method that gives you the information of the top Ref id. You may have to traverse back to that ref Id. But that may greatly impact the performance. What is the form name that you are trying to add this field?
  • In reply to Kranthi:

    I have added the field in the same form in pegging section.
  • In reply to Wekey:

    You are modifying the ReqTransExplosion form right?
    if you simply want to display in the grid what ever is displayed on the top section, then you can do a simple trick
    Declare a global variable in class declaration of the form and write a display on form methods to return that variable.
    In the execute Query method of the data source assign a value to that variable.

    Example:
    InventTransRefId refid; // this is in class declaration
    In the ReqTransCaller.executeQuery() method do the assignment,
    refid = reqTransFind.RefId;
    Write a display method to return this variable (refid) use that method for the newly added control.

  • In reply to Kranthi:

    Thank you so much. It worked

    I want to implement the same in AX7 as well you got any Idea on that?
  • In reply to Wekey:

    I don't have the environment to check right now.
Related
Recommended