‎2010 May 26 4:17 PM
Hi All,
Iam using transformations for reading the data from XML to Internal tables. Everything is working fine.
Here my question is, If some tags are missing in the XML file, program is giving error 'TAG XXX is missing'.
I dont want to get this error, if any tag is missing program should take the blank value instead of raising the error.
Please help. thanks.
Regards,
Sreedhar
‎2010 May 26 4:32 PM
You need to set the tag as conditional in your transformation template.
‎2010 May 27 6:42 AM
Please let me know how to make tags as conditional in transformations...
‎2010 May 27 2:16 PM
You can find the syntax for all of the conditional operators in the help files for transformations, but here's an example:
<tt:cond frq="?">
<NODE>
<tt:value ref="NODE"/>
</NODE>
</tt:cond>
‎2010 May 27 2:33 PM
Hi,
I have done the changes using the condition..but its working if we have the condition for only one Node..if we put the condition for more Nodes its giving error. I have put the below condition.
<tt:s-cond check="not-initial($ref.copy)">
<COPYINDICATOR>
<tt:value ref="$ref.copy"/>
</COPYINDICATOR>
</tt:s-cond>
if i use the condition only for any of one node its working..if i write the code like below
<!-- CopyIndicator -->
<tt:s-cond check="not-initial($ref.copy)">
<COPYINDICATOR>
<tt:value ref="$ref.copy"/>
</COPYINDICATOR>
</tt:s-cond>
<!-- LineCountNumeric -->
<tt:s-cond check="not-initial($ref.lcn)">
<LCN>
<tt:value ref="$ref.lcn"/>
</LCN>
</tt:s-cond>
its giving me error saying that some Element is missing..but actually that element is present in XML. Please advice
‎2010 May 27 2:48 PM
Unfortunately, I don't have any idea how your XML is formed. Keep in mind that 's-' is for serialization while you are deserializing, and if you need to initiate a loop process, you need to use 'tt:group'.
‎2010 May 27 2:52 PM
Hi,
My transformation is as below... Please let me know you mail ID so that i will send XML format
<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates" template="temp">
<tt:root name="ROOT"/>
<tt:template name="temp">
<tt:loop ref="ROOT">
<!-- Read Header Details -->
<DESPATCHADVICE>
<!-- Profile ID -->
<PROFILEID>
<tt:value ref="$ref.profile"/>
</PROFILEID>
<!-- BOL Number -->
<tt:s-cond check="not-initial($ref.bol)">
<BOLID>
<tt:value ref="$ref.bol"/>
</BOLID>
</tt:s-cond>
<!-- CopyIndicator -->
<tt:s-cond check="not-initial($ref.copy)">
<COPYINDICATOR>
<tt:value ref="$ref.copy"/>
</COPYINDICATOR>
</tt:s-cond>
<!-- LineCountNumeric -->
<tt:s-cond check="not-initial($ref.lcn)">
<LCN>
<tt:value ref="$ref.lcn"/>
</LCN>
</tt:s-cond>
<!-- GrossWeightMeasure -->
<tt:s-cond check="not-initial($ref.gwm)">
<GWM>
<tt:value ref="$ref.gwm"/>
</GWM>
</tt:s-cond>
<!-- Pro Number -->
<tt:s-cond check="not-initial($ref.pro)">
<PROID>
<tt:value ref="$ref.pro"/>
</PROID>
</tt:s-cond>
<!-- DespatchAdviceTypeCode -->
<tt:s-cond check="not-initial($ref.dac)">
<DAC>
<tt:value ref="$ref.dac"/>
</DAC>
</tt:s-cond>
<!-- Reading Trailer Number and Scac code -->
<DOCUMENT_CONF>
<!-- Trailer Number -->
<tt:s-cond check="not-initial($ref.trailer)">
<TRAILERID>
<tt:value ref="$ref.trailer"/>
</TRAILERID>
</tt:s-cond>
<!-- SCAC Code -->
<tt:s-cond check="not-initial($ref.scac)">
<SCACCODE>
<tt:value ref="$ref.scac"/>
</SCACCODE>
</tt:s-cond>
</DOCUMENT_CONF>
<!-- Reading PO Details -->
<tt:loop name="details" ref="$ref.details">
<DESPATCH_CONF>
<!-- PO Number -->
<tt:s-cond check="not-initial($details.po)">
<PO_CONF>
<tt:value ref="$details.po"/>
</PO_CONF>
</tt:s-cond>
<!-- Item Number -->
<tt:s-cond check="not-initial($details.item)">
<ITEMID_CONF>
<tt:value ref="$details.item"/>
</ITEMID_CONF>
</tt:s-cond>
<!--Reading Material Details -->
<SHIPMENT_CONF>
<!--Material Details -->
<tt:s-cond check="not-initial($details.matnr)">
<MATERAIL>
<tt:value ref="$details.matnr"/>
</MATERAIL>
</tt:s-cond>
<!--Quantity -->
<tt:s-cond check="not-initial($details.tiq)">
<TIQ>
<tt:value ref="$details.tiq"/>
</TIQ>
</tt:s-cond>
<!--Packing Slip -->
<tt:s-cond check="not-initial($details.packing)">
<PACKINGSLIP>
<tt:value ref="$details.packing"/>
</PACKINGSLIP>
</tt:s-cond>
<!--Reading Serial Number Details -->
<tt:loop name="serial" ref="$ref.serial">
<THU_CONF>
<!--Serial Number -->
<tt:s-cond check="not-initial($serial.sernr)">
<SERNR>
<tt:value ref="$serial.sernr"/>
</SERNR>
</tt:s-cond>
</THU_CONF>
</tt:loop>
</SHIPMENT_CONF>
</DESPATCH_CONF>
</tt:loop>
</DESPATCHADVICE>
</tt:loop>
</tt:template>
</tt:transform>
We are reading the data from XML..Please suggest.. Please let me know how to use <tt:group>
Edited by: Sreedhar841 on May 27, 2010 4:09 PM
‎2010 May 26 6:42 PM
Hi,
How you reading data from XML to internal table.
If you are reading it throught DATASET then try and to increse number of lines and you will able to read all tabs.
Ex- READ DATASET FNAME INTO TEXT2 LENGTH 500.
Ashutosh