2011 Oct 04 5:45 PM
Hello Friends,
I have searched before posting thread, couldnt find anything.
I am creating an XML file using Call Transformation. My internal table has 3 date fields and some other fields. For some records I dont have values for the date fields. In that case my XML file is giving the date value as 0000-00-00 since I declared it as Date type. This value 0000-00-00 is not accepted by the middle ware as the valid date. I can not change it as String type as per the suggestion.
In that case I am advised to skip printing the date field tag if it doesnt have value.
Is there any way to skip the date field if it is empty. Any Suggestions please ?.
Thanks
Lakshmi.
2011 Oct 08 4:00 PM
Hi SwarnaLakshmi,
As Carlosrv said, there is the option initial_components = 'suppress', that works for components of ABAP structured data objects. I think people don't succeed in using it in small tests if the initial data object attached to the root is an elementary data object. I answered more in depth here -> .
Sandra
2011 Oct 04 7:21 PM
Hi,
I had exactly the same problem before. When you call a transformation there is an option called initial_components. According to SAP if you use initial_components = 'SUPRESS' the empty fields should not being generated on the XML.
Now, this didn't work for me and I have seen some people with the same problem. Here is how I solved this (maybe not the best way but it worked):
First: My fields are all CHAR in my table
Second: In the transformation, you can use conditional transformation to not display a tag if field is empty, here a piece of my transformation (I am using simple transformations):
<tt:root name="ROOT"/>
...
...
<tt:cond s-check="not-initial(ref('ROOT.L1_NM')) or not-initial(ref('ROOT.L2_NM'))">
<TRNMTR_NM>
<tt:cond s-check="not-initial(ref('ROOT.L1_NM'))">
<l1_nm>
<tt:value ref="ROOT.L1_NM"/>
</l1_nm>
</tt:cond>
<tt:cond s-check="not-initial(ref('ROOT.L2_NM'))">
<l2_nm>
<tt:value ref="ROOT.L2_NM"/>
</l2_nm>
</tt:cond>
</TRNMTR_NM>
</tt:cond>As you can see, I first check if the fields have values.
Hope it helps
Edited by: carlosrv on Oct 4, 2011 8:22 PM
2011 Oct 04 9:41 PM
Hi Carlos,
Thanks much for the reply. Greatly appreciated.
I have implemented the same condition checking for my date type fields but still getting empty tags like this
<date/>. So I am still checking how to discard these empty tags from my XML file.
Thanks
Swarna
2011 Oct 04 9:55 PM
Using conditional checks should avoid empty tags:
<tt:cond s-check="not-initial(ref('ROOT.L1_NM'))">You can post a portion of your definition so I can give you a hint.
Regards,
2011 Oct 04 10:50 PM
Hi Carlos,
Here is my data tag.
<date1>
<tt:s-cond check = "not-initial(date1)">
<tt:value ref="$ROOT1.date1"/>
</tt:s-cond>
</date1>
It would be helpful if you could Suggest something.
Thanks
Swarna.
2011 Oct 05 10:53 PM
Try this:
<tt:cond s-check="not-initial(ref('$ROOT1.DATE1'))">
<date1>
<tt:value ref="$ROOT1.date1"/>
</date1>
</tt:cond>
if it doesn't work try removing the dollar sign from the condition:
<tt:cond s-check="not-initial(ref('ROOT1.DATE1'))">
2011 Oct 08 4:00 PM
Hi SwarnaLakshmi,
As Carlosrv said, there is the option initial_components = 'suppress', that works for components of ABAP structured data objects. I think people don't succeed in using it in small tests if the initial data object attached to the root is an elementary data object. I answered more in depth here -> .
Sandra
2011 Oct 15 12:44 AM
Thanks Sandra and Carlos. Now I am able discard the Empty tags.
Appreciated
Swarna