AnsweredAssumed Answered

Conditionally map a value -- or drop elements without sub-elements

Question asked by mrelzer on Jul 24, 2017
Latest reply on Jan 12, 2018 by daniel.santana

I'm creating an IDOC from a database query. Some records have a piece of data (a serial number) and some do not. In the IDOC format it is built as such:

<E1EDL24 SEGMENT="1">

   ...

    <E1EDL11 SEGMENT="1">
      <SERNR>XXX</SERNR>
   </E1EDL11>

</E1EDL24>

 

I have that working in Boomi correctly. However, when there are no serial numbers, I end up getting:

<E1EDL24 SEGMENT="1">

   ...

    <E1EDL11 SEGMENT="1" />
</E1EDL24>

 

This ends up throwing an IDOC parse failure (pointed at the empty E1EDL11).

 

What I believe I need to do is prevent the E1EDL11 segment from populating (at all) when there are no serial numbers. I think I could possibly block the "SEGMENT" value conditionally, but I'm using a Line Item Increment function on (which honestly may not be the right thing to do -- but that's another problem I need to work out) -- and can't figure out how I could conditionally map that value... or how to tell the system to not include E1EDL11 when there are no children SERNRs.

 

UPDATE:

I have tentatively made this work by first mapping to my IDOC format without the SEGMENT set. Then throwing in a decision shape which checks the XML (IDOC) profile for the serial number. If true, send it through another map to add just that one value. So the first map doesn't add E1EDL11 if there is no serial number (because I'm not setting SEGMENT), then the second map adds the line counter to SEGMENT-- which is only run if there is a SERNR available.

 

I have to believe there is a better way than this -- but I've at least got something that tentatively gets me past this hurdle.

Outcomes