on 06-03-2014 3:36 PM
I tried to generate mulitple target notes based on count (10) of tdlines on each item level
E1EDP01>E1EDPT1>E1EDPT2>TDLINE
Using the following udf
int count = Integer.parseInt(segcount[0]);
for (int i=0; i<count; i= i+10)
{
result.addValue("");
}
I have two E1EDPT1>E1EDPT2>TDLINE(with 5 tdlines) segments on source on each E1EDPO1 segments . Expecting two Notes segments on each item level on target
But I am getting all four Notes in first item level only
mapping .(TDlinecontext set to E!ETPT1) .I tried and changed to E1DP01 then i got only one segment on each item
TDLine>count>udf.>removecontext>Notes
Thanks for your help
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mahesh,
Keep your original context and add this to the end of your UDF after the for loop:
result.addContextChange();
Regards,
Ryan Crosby
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In first E1EDP01 ,there are two E1EDPT1 >E1EDPT2 with one 5 TD lines and other E1EDPT1 >E1EDPT2 has one TDline . So I am expecting in first item level two notes and similar way in EDP01 expecting two Notes .If you look at the incoming dispaly queue for udf 5 CC 1 are first item TDlines count and 5 CC 1 are second t item TDlines count .each line item there should be atleast two Notes .
firs item created 5 notes and 2nd item level created one note . For TDline count of 1 to 10 ,one note in target is requried .So If we have 5, one note ,15 two notes ,21 three notes like that for each E1EDPT1. with the following getting each item only one Note . Expecting two in each item
for(int i = 0; i < count.length; i++)
{
int num = Integer.parseInt(count[i]);
for(int j = 0; j < num; j = j+10)
{
result.addValue("");
}
result.addContextChange();
}
Hi Mahesh,
Ok, now I see what you are meaning... you are talking about the total count of notes so that's using integer division... change to the following code:
for(int i = 0; i < count.length; i++)
{
int num = (Integer.parseInt(count[i]) / 10) + 1;
for(int j = 0; j < num; j++)
{
result.addValue("");
}
if(i < count.length - 1)
result.addContextChange();
}
Regards,
Ryan Crosby
Message was edited by: Ryan Crosby
It is not the question of always need 2 per item. for each E1EDPT1 generate based on the no of tdlines
The structure
E1EDPT1
TDID 0..99
E1EDPT2 0.999999999999
TDLINE
E1EDPT2
TDLINE for every 10 TDlines one note in taget 1st line item
E1EDPT2
TDLINE
E1EDPT2
TDLINE
E1EDPT1
TDID 0..99
E1EDPT2 0.999999999999
TDLINE
E1EDPT2
TDLINE for every 10 TDlines one note in taget 1st line item
E1EDPT2
TDLINE
E1EDPT2
TDLINE
2)E1EDP01 2nd line item
E1EDPT1
TDID 0..99
E1EDPT2 0.999999999999
TDLINE
E1EDPT2
TDLINE for every 10 TDlines one note in taget 2nd line item
E1EDPT2
TDLINE
E1EDPT2
TDLINE
E1EDPT1
TDID 0..99
E1EDPT2 0.999999999999
TDLINE
E1EDPT2
TDLINE for every 10 TDlines one note in taget 2nd line item
E1EDPT2
TDLINE
E1EDPT2
TDLINE
So we need divide all TDlines of E1EDPT2/10 under each E1EDPT1
Hi,
The code I have given that mentioned integer division would already do this if you have your source context setup correctly. There is no way for me to tell where the necessary context changes would need to be placed without seeing sample source and expected target xml however.
Regards,
Ryan Crosby
Thank you Ryan for looking in to this .I set up context change for TDLine to E1EDPT1
,I tried with E1EDP01 context also .Still i got the same result. 1st E1EDP01 item > 2nd E1EDPT2 tdlines moved to 2nd item level. Not sure if i am not doing something not correct.
tdline-count -remove context-udf-notes
Thanks
Hi,
I tried this out using this target structure:
I mapped Item and Notes like this (TDLINE was set to E1EDP01 context and my UDF was all values of a context):
I used this code since it was all values of a context:
for(int i = 0; i < count.length; i++)
{
int num = (Integer.parseInt(count[i] / 10) + 1;
for(int j = 0; j < num; j++)
{
result.addValue("");
}
}
This was the XML result that I got when I had 11 TDLINE values for each E1EDP01 segment:
<?xml version="1.0" encoding="UTF-8"?>
<Item><Notes></Notes><Notes></Notes></Item>
<Item><Notes></Notes><Notes></Notes></Item>
Based on what you have described of 1 Notes node per 10 TDLINES that UDF should be working fine. The only question is whether you were using all values of a context or queue and what your full target structure looks like.
Regards,
Ryan Crosby
Hi Ryan,
Context change set to E1EDP01 for TDline. Attached test data with two E1EDPT1 segments E1EDPT2-one TDline in line item( E1EDP01). Similary in 2nd E1EDP01 also two E1EDPT1 segments E1EDPT2-one TDline . There is only one Notes structure in each line item created . Expecting two since we have two E1EDPT1 in each E1EDP01. Set all values of context The issue is with the count I guess. We need to count under each z1edpt1 based on no of tdlines and create strucutre. changed the context to E1EDPT1 added removed context but created all 4 notes in first item only
Thank you ryan for your help. This could be final issue. when there is no E1EDPT1 present in any of the line items getting that exception
com.sap.aii.mappingtool.tf7.FunctionException: Function formatByExample: Queues do not have the same number of values] in class com.sap.aii.mappingtool.flib7.NodeFunctions method formatByEx
Thanks again
<E1EDP01 SEGMENT="1">
<POSEX>00010</POSEX>
<ACTION>001</ACTION>
<PSTYP>0</PSTYP>
<MENGE>4.000</MENGE>
<MENEE>EA</MENEE>
<BMNG2>4.000</BMNG2>
<PMENE>EA</PMENE>
<VPREI>12.39</VPREI>
<PEINH>1</PEINH>
<NETWR>49.56</NETWR>
<MATKL>078XX</MATKL>
<BPUMN>1</BPUMN>
<BPUMZ>1</BPUMZ>
<WERKS>2400</WERKS>
<Z1KONV2 SEGMENT="1">
<KNUMV>1000022683</KNUMV>
<KPOSN>000010</KPOSN>
<KBETR> 12.39</KBETR>
</Z1KONV2>
<Z1EKET2 SEGMENT="1">
<SLFDT>20120702</SLFDT>
<LPEIN>1</LPEIN>
<ETENR>0001</ETENR>
</Z1EKET2>
<Z1EKPO2 SEGMENT="1">
<KNTTP>F</KNTTP>
<PSTYP>0</PSTYP>
<AFNAM>Stores</AFNAM>
<EFFWR> 53.82</EFFWR>
<REPOS>X</REPOS>
<WEBRE>X</WEBRE>
<WEPOS>X</WEPOS>
<ZZDIRECT>Taxable</ZZDIRECT>
<XERSY>X</XERSY>
</Z1EKPO2>
<Z1EKKN2 SEGMENT="1">
<SAKTO>0000620102</SAKTO>
<PS_PSP_PNR>00000000</PS_PSP_PNR>
<AUFNR>000010015832</AUFNR>
<VPROZ> 0.0</VPROZ>
<WEMPF>test</WEMPF>
<ABLAD>Jude</ABLAD>
<MENGE> 4.000</MENGE>
</Z1EKKN2>
<E1EDP20 SEGMENT="1">
<WMENG>4.000</WMENG>
<AMENG>0.000</AMENG>
<EDATU>20130702</EDATU>
</E1EDP20>
<E1EDP19 SEGMENT="1">
<QUALF>001</QUALF>
<KTEXT>4MUX5 - test</KTEXT>
</E1EDP19>
</E1EDP01>
Hi Ryan,
Sorry to come again with the same issue. Attached source xml with two edpt1 segments each 3 tdlines in each line items . Modifled code to tdline count/2(for testing). So for each edpt1 expecting two notes in target . So total for each line item I am getting only two in each line item target .Expecting four in each line item
<E1EDP01 SEGMENT="1">
<E1EDPT1 SEGMENT="1">
<TDID>G1</TDID>
<TSSPRAS>E</TSSPRAS>
<TSSPRAS_ISO>EN</TSSPRAS_ISO>
<E1EDPT2 SEGMENT="1">
<TDLINE>1ST LINE ITEM </TDLINE>
<TDFORMAT>*</TDFORMAT>
</E1EDPT2>
<E1EDPT2 SEGMENT="1">
<TDLINE>1ST LINE ITEM </TDLINE>
<TDFORMAT>/</TDFORMAT>
</E1EDPT2>
<E1EDPT2 SEGMENT="1">
<TDLINE>1ST LINE ITEM </TDLINE>
<TDFORMAT>/</TDFORMAT>
</E1EDPT2>
</E1EDPT1>
<E1EDPT1 SEGMENT="1">
<TDID>G2</TDID>
<TSSPRAS>E</TSSPRAS>
<TSSPRAS_ISO>EN</TSSPRAS_ISO>
<E1EDPT2 SEGMENT="1">
<TDLINE>1ST LINE ITEM </TDLINE>
<TDFORMAT>*</TDFORMAT>
</E1EDPT2>
<E1EDPT2 SEGMENT="1">
<TDLINE>1ST LINE ITEM </TDLINE>
<TDFORMAT>*</TDFORMAT>
</E1EDPT2>
<E1EDPT2 SEGMENT="1">
<TDLINE>1ST LINE ITEM </TDLINE>
<TDFORMAT>*</TDFORMAT>
</E1EDPT2>
</E1EDPT1>
</E1EDP01>
<E1EDP01 SEGMENT="1">
<E1EDPT1 SEGMENT="1">
<TDID>G3</TDID>
<TSSPRAS>E</TSSPRAS>
<TSSPRAS_ISO>EN</TSSPRAS_ISO>
<E1EDPT2 SEGMENT="1">
<TDLINE>2ND LINE ITEM</TDLINE>
<TDFORMAT>*</TDFORMAT>
</E1EDPT2>
<E1EDPT2 SEGMENT="1">
<TDLINE>2ND LINE ITEM</TDLINE>
<TDFORMAT>/</TDFORMAT>
</E1EDPT2>
<E1EDPT2 SEGMENT="1">
<TDLINE>2ND LINE ITEM</TDLINE>
<TDFORMAT>/</TDFORMAT>
</E1EDPT2>
</E1EDPT1>
<E1EDPT1 SEGMENT="1">
<TDID>G4</TDID>
<TSSPRAS>E</TSSPRAS>
<TSSPRAS_ISO>EN</TSSPRAS_ISO>
<E1EDPT2 SEGMENT="1">
<TDLINE>2ND LINE ITEM</TDLINE>
<TDFORMAT>*</TDFORMAT>
</E1EDPT2>
<E1EDPT2 SEGMENT="1">
<TDLINE>2ND LINE ITEM</TDLINE>
<TDFORMAT>*</TDFORMAT>
</E1EDPT2>
<E1EDPT2 SEGMENT="1">
<TDLINE>2ND LINE ITEM</TDLINE>
<TDFORMAT>*</TDFORMAT>
</E1EDPT2>
<E1EDPT2 SEGMENT="1">
<TDLINE>2ND LINE ITEM</TDLINE>
<TDFORMAT>*</TDFORMAT>
</E1EDPT2>
</E1EDPT1>
</E1EDP01>
Thank you
Hi Mahesh,
It looks like a result of how the system manages the queue when using the ifWithouElse that it suppresses many values because the length of each context has to match. If we move the UDF to the spot after the ifWithoutElse then it solves the queue suppression problem:
Regards,
Ryan Crosby
Message was edited by: Ryan Crosby
Hi Mahesh,
You'll need to double check the contexts and code then... I got a total of 4 & then 5 on the second line item for the same mapping. Based on your example from the 10 before it would be 2 notes nodes for a count of 3 and 3 for a count of 4 (the num + 1 part in the code).
Regards,
Ryan Crosby
Hi. Can you put your XML Source and the XML expected ?
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.