locked
Idoc to be not sent if condition is true RRS feed

  • Question

  • Hi,

    I have input xml which looks like below : 

            <Delivery>
                <BatchN>SAP16716</BatchN>
                   ...............other elements go here
                 <Location></Location>

            </Delivery>

    The above xml is the debatched message which then is mapped to an IDOC schema finally send the IDOC to SAP system.

    The above xml can have multiple Delivery records. So whichever Delivery record has below condition met then that IDOC shouldnt be sent to SAP. 

    My scenario is if in the above xml file if BatchN contains SAPand Location is blank then i need not to send the IDOC to SAP system. Idoc is the DELVRY05 idoc. If Location value exists then all elements are mapped  across IDOC and sent to sap if not in above condition then that IDOC not to be sent to SAP. 

    Ex :if there are 3 Delivery Records and in one of the record BatchN starts with SAP and Location is BLANK/NULL then this this record mapped to IDOC should not be sent to SAP.

    Can anyone please advise? Thank you. 

     
    Thursday, November 3, 2016 11:36 PM

Answers

  • Hi Yashod,

    One way to handle this is:

    1) Count the number of Delivery records using xpath.

    Example: count(/*[local-name()='Root']/*[local-name()='Delivery'])

    2) Initiate a loop.

    3) Inside loop using xpath check for the value of both BatchN and Location for the looped iteration.

    For BatchN you can make use of String.Contains method and for Location use String.IsNullOrEmpty method.

    4) Have a bool variable (let say it 'boolCallSAP' with initial value set to 'True') and in the loop if the above condition meets set it to False.

    5) Exit the loop once you iterate through all the Delivery records.

    6) Based on the bool variable value make the decision of calling SAP or not.


    Rachit Sikroria (Microsoft Azure MVP)

    Friday, November 4, 2016 2:43 AM
  • Hi Rachit,

    Is this in orchestration? I'm not using Orchestration here its message based application, so how can i achieve this scenario in mapper? 

    Hold on! 

    You will have to use an orchestration. The correct and best way to handle this is with an Orchestration.

    There is nothing wrong using Orchestrations, don't worry about 'performance'.

    In case of mapper, you will be able to handle the creation of destination node based on the condition which you wish to apply but you won't be able to make the routing decision. 


    Rachit Sikroria (Microsoft Azure MVP)

    • Marked as answer by Lathaa Friday, February 2, 2018 3:19 PM
    Friday, November 4, 2016 1:08 PM

All replies

  • Hi Yashod,

    One way to handle this is:

    1) Count the number of Delivery records using xpath.

    Example: count(/*[local-name()='Root']/*[local-name()='Delivery'])

    2) Initiate a loop.

    3) Inside loop using xpath check for the value of both BatchN and Location for the looped iteration.

    For BatchN you can make use of String.Contains method and for Location use String.IsNullOrEmpty method.

    4) Have a bool variable (let say it 'boolCallSAP' with initial value set to 'True') and in the loop if the above condition meets set it to False.

    5) Exit the loop once you iterate through all the Delivery records.

    6) Based on the bool variable value make the decision of calling SAP or not.


    Rachit Sikroria (Microsoft Azure MVP)

    Friday, November 4, 2016 2:43 AM
  • Hi Rachit,

    Is this in orchestration? I'm not using Orchestration here its message based application, so how can i achieve this scenario in mapper? 

    Friday, November 4, 2016 9:23 AM
  • Hi Yashod,

    In the messaging based scenario you will have to play with the promoted proerties..promote the property using the property schema and map the nodes in the data in the incoming message to these property fields..that way when the messages are debatched, the properties will be promoted based on the data in these messages.

    Now in the cases of valid data that matches your condition, apply necessary filters using these promoted properties..this will make sure that only valid messages are routed to the destination.

    Note: There is no contains  predicate  in the filters so conatains willnot work in that case...you have two options

    1) Make the routing opn some other field or

    2) Use the orchestration to route the message to the necessary destinations

    Regards


    Mandar Dharmadhikari



    Friday, November 4, 2016 10:12 AM
  • Hi Rachit,

    Is this in orchestration? I'm not using Orchestration here its message based application, so how can i achieve this scenario in mapper? 

    Hold on! 

    You will have to use an orchestration. The correct and best way to handle this is with an Orchestration.

    There is nothing wrong using Orchestrations, don't worry about 'performance'.

    In case of mapper, you will be able to handle the creation of destination node based on the condition which you wish to apply but you won't be able to make the routing decision. 


    Rachit Sikroria (Microsoft Azure MVP)

    • Marked as answer by Lathaa Friday, February 2, 2018 3:19 PM
    Friday, November 4, 2016 1:08 PM