Skip to Content
0
Former Member
Dec 02, 2004 at 11:29 AM

Mapping XML to Flat File if XML Tag is not always there

45 Views

Hello,

As I need to map from an IDOC into a flat file with fixed length using the graphical mapping, I face the problem that in IDOCs fields are not always filled. For a single field I can use the “exist” function and insert an empty string. In XI 2.0 this was not necessary and the system did that automatically now you have to put an “IF” around to see if that field exists or not and depending on the outcome use the field value or an empty string. My problem gets worse if you have to qualify the source record by a field in the same node. When you map into the flat structure you have to use the remove context function. I got it to work but doing that for a lot of fields sucks. Following is my graphical mapping:

Structure:

<SEG1>

<SEG2>

<LAND1>EN</LAND1>

<LOG>1</LOG>

</SEG2>

<SEG2>

<LOG>2</LOG>

</SEG2>

<SEG2>

<LAND1>EN</LAND1>

<LOG>3</LOG>

</SEG2>

</SEG1>

/ns0:SEG1/ITEM/ LAND1_0006=if ([]Constant ([value=DEE]) , equalsS ([]Constant ([value=]) , if ([]if([] if([] /HRMD_A06/IDOC/E1PLOGI/E1PITYP/E1P0006/LAND1 , exists([] /HRMD_A06/IDOC/E1PLOGI/E1PITYP/E1P0006/LAND1 ) , Constant ([value=])) , equalsS ([]/HRMD_A06/IDOC/ E1PLOGI/E1PITYP/E1P0006/ SUBTY , Constant ([value=1])) , Constant ([value=])) , exists ([]/HRMD_A06/IDOC/ E1PLOGI/E1PITYP/E1P0006) , Constant([value=]))) , /HRMD_A06/IDOC/E1PLOGI /E1PITYP/E1P0006/LAND1 )

Is there a java function or other method to create an empty source tag of <LAND1/> in my case. Any java code is appreciated. I can do the same in XSLT without any issue but the idea is to use the graphical mapping.

Thanks

Stefan