on 07-21-2011 11:34 PM
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>
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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();
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
78 | |
10 | |
7 | |
6 | |
6 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.