Maximo Open Forum

 View Only
  • 1.  How to remove one children object xml on Response?

    Posted 03-07-2023 12:58

    Good day everyone!

    I have the xml structure below:

    <QuerySHIPMENTAPIResponse>
             <SHIPMENTAPISet>
                <SHIPMENT>
                   <ENTERBY></ENTERBY>
                   <FROMSITEID></FROMSITEID>
                   <INVUSENUM></INVUSENUM>
                   <ORGID></ORGID>
                   <SHIPDATE>2023-03-07T12:05:34-05:00</SHIPDATE>
                   <SHIPMENTNUM>99590</SHIPMENTNUM>
                   <SHIPTO/>
                   <SITEID></SITEID>
    
                   <SHIPMENTLINE>
                        <SHIPMENTLINENUM>1</SHIPMENTLINENUM>
                        <CUSTOMFLAG>1</CUSTOMFLAG>
                   </SHIPMENTLINE>
    
                   <SHIPMENTLINE>
                         <SHIPMENTLINENUM>2</SHIPMENTLINENUM>
                         <CUSTOMFLAG>0</CUSTOMFLAG>
                   </SHIPMENTLINE>
                </SHIPMENT>
               
             </SHIPMENTAPISet>
          </QuerySHIPMENTAPIResponse>
    

    I have a requirement wherein I need to remove the shipmentline 1 if I met the condition (customflag = 1). I tried using removeChildren on the integration automation script but it also removes shipmentline 2. 

    Is there a way to remove only the first child xml object? I also tried using processing rules but I am not sure if I set it up incorrectly or it is not working because the Object Structure is Query only.

    Any inputs are appreciated, thank you!


    #Customizations
    #Integrations
    #Inventory

    ------------------------------
    KM Cornista
    ------------------------------


  • 2.  RE: How to remove one children object xml on Response?

    Posted 03-07-2023 19:11
    Use the structure data class api in user exit auto script.
    Do it like this-
    1. Navigate to Shipment line 1- getchildrendata() : this will returns list of child elements. Loop into the required shipment line number.
    2. Set the shipment line as a current data- setascurrent(<shipment line="" element="" from="" step="" 1="">)
    3. Use removecurrentdata() method to remove the element and set parent element as current element.


    ---------------------------------
    Biplab Choudhury
    BPD Zenith Australia
    ---------------------------------





  • 3.  RE: How to remove one children object xml on Response?

    Posted 03-08-2023 10:16

    If you're going to skip a record, the most efficient place to do it is with an OSOUT object structure and use the skipMbo because that will prevent serialization of the data. 

    https://ibm-maximo-dev.github.io/maximo-autoscript-documentation/integration/osevents



    ------------------------------
    Steven Shull
    IBM
    ------------------------------



  • 4.  RE: How to remove one children object xml on Response?

    Posted 03-09-2023 08:42
    Edited by KM Cornista 03-09-2023 12:06

    Hey Biplab,

    It seems that removecurrentdata only removes a single element and not the whole shipmentline object. I need the whole object removed/skipped and not a single field only.

    Hey Steven,

    I tried your approach but it seems that nothing is happening. This is the code snippet:

    def skipMbo(ctx):
        if ctx.getMboName() == "SHIPMENT":
            shipLineSet = ctx.getMbo().getMboSet("SHIPMENTLINE")
            if not shipLineSet.isEmpty():
                shipLineObj = shipLineSet.moveFirst()
                if shipLineObj.getDouble("CUSTRECQTY") == shipLineObj.getDouble("SHIPPEDQTY"):
                    ctx.skipMbo()

    However I have another script on QUERY Enterprise Service on USEREXIT.OUT.BEFORE that sets the "CUSTRECQTY" field. So perhaps the OSOUT script is being triggered last? What is the order of execution of these types of scripts? I'd like this efficient approach but I would like to understand how they take precedence to each other.

    Best regards,



    ------------------------------
    KM Cornista
    ------------------------------



  • 5.  RE: How to remove one children object xml on Response?

    Posted 03-10-2023 10:08

    You said your goal was to remove individual shipment lines. In that case you would want to check that your mbo is SHIPMENTLINE (if ctx.getMboName()=="SHIPMENTLINE"). This method fires for every MBO, including the children objects.

    OSOUT would run before the USEREXIT. I would move the logic where you're setting CUSTRECQTY to the overrideValues(ctx) in OSOUT. 



    ------------------------------
    Steven Shull
    IBM
    ------------------------------



  • 6.  RE: How to remove one children object xml on Response?

    Posted 03-10-2023 12:39
    Edited by KM Cornista 03-10-2023 12:39

    Hi Steven,

    I put the setting of CUSTRECQTY to overrideValues and it worked. But the skipMbo function still wont work on my end. Here is the updated code per your advise:

    def skipMbo(ctx):
        if ctx.getMboName() == "SHIPMENTLINE":
            if ctx.getMbo().getDouble("CUSTRECQTY") == ctx.getMbo().getDouble("SHIPPEDQTY"):
                ctx.skipMbo()

    I even tried just equating the CUSTRECQTY condition to a value to test and still not being triggered. Anything else I'm missing here? 



    ------------------------------
    KM Cornista
    ------------------------------



  • 7.  RE: How to remove one children object xml on Response?

    Posted 03-20-2023 08:12

    Hi KM,

    Your script syntax looks correct, what I am suspecting the compare IF condition is getting evaluated to False. 

    Please check the same script by using a simple condition only to verify the Skipping of MBO is working fine. 



    ------------------------------
    Subhransu Sekhar Sahoo
    Tata Consultancy Services
    ------------------------------



  • 8.  RE: How to remove one children object xml on Response?

    Posted 03-21-2023 04:17

    Hello Subhransu,

    So it seems that skipMbo() logic is being triggered first before the overrideValues() function because I tried a simple condition like you suggested and it is being evaluated. Any way to set the values on my CUSTRECQTY then get evaluated on skipMbo() function? Or do I need a new approach if I want it to be like this?



    ------------------------------
    KM Cornista
    IBM
    ------------------------------