cancel
Showing results for 
Search instead for 
Did you mean: 

Graphical Mapping Help

Former Member
0 Kudos

Hi

I am trying to sort idoc segments based on values like below. I have written XSLT before which just broken after applying SPs. i need a break fix immediately before SAP look into the SP issue.

Now i am leaning towards graphical map. Please help with this

Sample Structure

<E1EDL37>
<EX1DV>0000000000101</EX1DV>
<VHILM>RFID_CASE</VHILM>
.......
</E1EDL37>
<E1EDL37>
<EX1DV>0000000000102</EX1DV>
<VHILM>RFID_CASE</VHILM>
.......
</E1EDL37>
<E1EDL37>
<EX1DV>0000000000103</EX1DV>
<VHILM>RFID_CASE</VHILM>
.......
</E1EDL37>
<E1EDL37>
<EX1DV>0000000000104</EX1DV>
<VHILM>RFID_CASE</VHILM>
.......
</E1EDL37>
<E1EDL37>
<EX1DV>0000000000201</EX1DV>
<VHILM>RFID_CASE</VHILM>
.......
</E1EDL37>
<E1EDL37>
<EX1DV>0000000000202</EX1DV>
<VHILM>RFID_CASE</VHILM>
.......
</E1EDL37>
<E1EDL37>
<EX1DV>0000000000203</EX1DV>
<VHILM>RFID_CASE</VHILM>
.......
</E1EDL37>
<E1EDL37>
<EX1DV>0000000000204</EX1DV>
<VHILM>RFID_CASE</VHILM>
.......
</E1EDL37>
<E1EDL37>
<EXIDV>0000000000200</EXIDV>
<VHILM>RFID_PALL</VHILM>
<E1EDL44>
<EXIDV>0000000000201</EXIDV>
<EXIDV>0000000000202</EXIDV>
<EXIDV>0000000000203</EXIDV>
<EXIDV>0000000000204</EXIDV>
.......
</E1EDL37>
<E1EDL37>
<EXIDV>0000000000100</EXIDV>
<VHILM>RFID_PALL</VHILM>
<E1EDL44>
<EXIDV>0000000000101</EXIDV>
<EXIDV>0000000000102</EXIDV>
<EXIDV>0000000000103</EXIDV>
<EXIDV>0000000000104</EXIDV>
.......
</E1EDL37>

Here is the output i am looking for

<E1EDL37>
<EXIDV>0000000000100</EXIDV>
<VHILM>RFID_PALL</VHILM>
<E1EDL44>
<EXIDV>0000000000101</EXIDV>
<EXIDV>0000000000102</EXIDV>
<EXIDV>0000000000103</EXIDV>
<EXIDV>0000000000104</EXIDV>
</E1EDL37>
<E1EDL37>
<EX1DV>0000000000101</EX1DV>
<VHILM>RFID_CASE</VHILM>
.......
</E1EDL37>
<E1EDL37>
<EX1DV>0000000000102</EX1DV>
<VHILM>RFID_CASE</VHILM>
.......
</E1EDL37>
<E1EDL37>
<EX1DV>0000000000103</EX1DV>
<VHILM>RFID_CASE</VHILM>
.......
</E1EDL37>
<E1EDL37>
<EX1DV>0000000000104</EX1DV>
<VHILM>RFID_CASE</VHILM>
.......
</E1EDL37>

<E1EDL37>
<EXIDV>0000000000200</EXIDV>
<VHILM>RFID_PALL</VHILM>
<E1EDL44>
<EXIDV>0000000000201</EXIDV>
<EXIDV>0000000000202</EXIDV>
<EXIDV>0000000000203</EXIDV>
<EXIDV>0000000000204</EXIDV>
.......
</E1EDL37>
<E1EDL37>
<EX1DV>0000000000201</EX1DV>
<VHILM>RFID_CASE</VHILM>
.......
</E1EDL37>
<E1EDL37>
<EX1DV>0000000000202</EX1DV>
<VHILM>RFID_CASE</VHILM>
.......
</E1EDL37>
<E1EDL37>
<EX1DV>0000000000203</EX1DV>
<VHILM>RFID_CASE</VHILM>
.......
</E1EDL37>
<E1EDL37>
<EX1DV>0000000000204</EX1DV>
<VHILM>RFID_CASE</VHILM>
.......
</E1EDL37>

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

sorry for the delayed reply. Let me reiterate the source occurrences

E1EDL37 --- 1..unbounded

---EXIDV --- 0..1

---VHILM --- 0..1

---E1EDL44 --- 1..unbounded

-


EXIDV --- 1.1

I stressed only the one's important for sorting logic. But i have several other segments with many number of fields to catch up. If there is an easy way doing it by not concentrating on each field for the logic that really saves time

I am going to work on both suggestions. And let u know the results

markangelo_dihiansan
Active Contributor
0 Kudos

Hello,

This can be done using graphical mapping and without udf. See mapping below:

Legend: rc = removeContext, sBV = splitByValue :EV = eachValue :VC = ValueChanged, mWd = mapWithDefault

fBe = formatByExample

For E1EDL37


E1EDL37 -> E1EDL37

For EX1DV


EX1DV -> rC -> sort:ascending -> sBV:EV -> EX1DV

For VHILM


EX1DV -> rC -> sortByKey:ascending -> sBV:EV -> VHILM
VHILM -> rC -> /

Now for the fun part

For E1EDL44


                      EX1DV -> UseOneAsMany (2,3) -> rC -> sortByKey:ascending -----> fBE -> equalsS: -> not -> ifWithoutElse (output of fBE is mapped to then) -> E1EDL44
EXIDV(setContextTo E1EDL37) -> mWd: -> /                                                / Constant: /
                      EX1DV -> UseOneAsMany (2,3) -> rC -> sort:ascending -> sBV:VC -> /
EXIDV(setContextTo E1EDL37) -> mWd: -> /

For EXIDV


                          EX1DV -> UseOneAsMany (2,3) -> rC -> sortByKey:ascending -----> fBE -> equalsS: -> not -> ifWithoutElse (output of fBE is mapped to then) -> sBV:EV -> EXIDV
EXIDV(setContextTo E1EDL37) -> mWd: -> /                                                / Constant: /
                      EX1DV -> UseOneAsMany (2,3) -> rC -> sort:ascending -> sBV:VC -> /
EXIDV(setContextTo E1EDL37) -> mWd: -> /

Hope this helps,

Mark

Former Member
0 Kudos

Mark

I am little confused on E1EDL44 segment mapping. Could u please elaborate. useOneAsMany starts with 3 inputs. I am not seeing here.

markangelo_dihiansan
Active Contributor
0 Kudos

Hello,

The (2,3) means that the input for the second is the same as the third.

Regards,

Mark

Former Member
0 Kudos

Hi Chilly,

As per my understanding ur source and target structure is as

E1EDL37 --- 1..unbounded

---EXIDV --- 0..1

---VHILM --- 0..1

---E1EDL44 --- 1..1

-


EXIDV --- 0..unbounded

We can achive this requirement by using sort and sortByKey function

E1EDL37 --- E1EDL37

E1EDL44 --- E1EDL44

Logic for E1EDL37-EXIDV

E1EDL37-EXIDV ---> RemoveContext ---> sort ---> splitByValue ---> EXIDV

E1EDL37-EXIDV --- RemoveContext ---> SortByKey (2nd Input, VHILM --- RemoveContext) --- VHILM

Logic for E1EDL44-EXIDV

We need to write the UDF to sync the contextChange. there will be 3 input to UDF

1st Input.

E1EDL37-EXIDV ---> useOneAsMany (2nd and 3rd input, E1EDL44-EX1DV) --- removeContext --- sort --- splitByBValue (ValueChange) --- collapseContext --- removeContext --- UDF 1stInput

2nd Input

E1EDL37-EXIDV ---> useOneAsMany (2nd and 3rd input, E1EDL44-EX1DV) --- removeContext --- sort --- concat (2nd Input) --- UDF 2nd Input

concat 2nd Input

E1EDL37-EXIDV ---> useOneAsMany (2nd and 3rd input, E1EDL44-EX1DV) --- removeContext --- sortByKey (2nd Input, E1EDL44-EXIDV --- removeContext) --- concat 2ndInput

3rd Input.

E1EDL37-EXIDV ---> useOneAsMany (2nd and 3rd input, E1EDL44-EX1DV) --- removeContext --- sortByKey (2nd Input, E1EDL44-EXIDV --- removeContext)

public void formatByExample(String[] var1, ResultList result, String[] var2, String[] var3, Container container) throws StreamTransformationException{

for(int i=0;i<var1.length;i++)

{

for(int j=0;j<var2.length;j++)

{

if(var2[j].startsWith(var1<i>))

{

result.addValue(var3[j]);

}

}

result.addContextChange();

}

}