Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Optional XML fields in Simple transformations (ST)

JackGraus
Active Contributor
0 Likes
3,346

Hi, I am using Simple Transformation (ST) to convert an XML file into ABAP data. In my XML file some XML tags are optional: sometimes they are available in the file, sometimes they are not. I can not find out how to define a ST for this.

Either the XML fields are in the ST definition and then these field should also be in the XML file or

the XML fields are not in the ST definition and then these fields are not allowed in the XML.

Regards jack

1 ACCEPTED SOLUTION
Read only

JackGraus
Active Contributor
1,630

Hi Jack, please find some sample coding below that will solve your issue:

<tt:cond check="not-initial(ref('E1EDL20.INCO1'))">
  <INCO1 tt:value-ref="E1EDL20.INCO1"/>
</tt:cond>

With the simple transformation tt cond statment you can make an XML tag optional. In below example during deserialisation xml tag <INCO1> will be skipped when not availabke in the xml and SAP data E1EDL20.INCO1 will not be filled by the transformation.

Regards. Please give points when usefull !

2 REPLIES 2
Read only

JackGraus
Active Contributor
1,631

Hi Jack, please find some sample coding below that will solve your issue:

<tt:cond check="not-initial(ref('E1EDL20.INCO1'))">
  <INCO1 tt:value-ref="E1EDL20.INCO1"/>
</tt:cond>

With the simple transformation tt cond statment you can make an XML tag optional. In below example during deserialisation xml tag <INCO1> will be skipped when not availabke in the xml and SAP data E1EDL20.INCO1 will not be filled by the transformation.

Regards. Please give points when usefull !

Read only

0 Likes
1,630

Hi J. Graus,

i have similar requirement (using multiple XML's) to update deep structures in abap.

ST logic would be as below:

i tried above given code but no luck.

please advise.

Thanks in advance.

Regards,

Buddha