on 08-12-2007 12:40 PM
I am doing ORDERS05 to XML file mapping. In the output filed "Amount" which is doing sum of all BETRG field in E1EDP05 where KSCHL field is R1 or R2.
Input file looks like:
<E1EDP01>
.
.
<E1EDP05>
<KSCHL>R1</KSCHL>
<BETRG>005</BETRG>
</E1EDP05>
<E1EDP05>
<KSCHL>R2</KSCHL>
<BETRG>015</BETRG>
</E1EDP05>
<E1EDP05>
<KSCHL>R2</KSCHL>
<BETRG>050</BETRG>
</E1EDP05>
<E1EDP05>
<KSCHL>R50</KSCHL>
<BETRG>015</BETRG>
</E1EDP05>
.
</E1EDP01>
<E1EDP01>
.
.
<E1EDP05>
<KSCHL>R1</KSCHL>
<BETRG>005</BETRG>
</E1EDP05>
<E1EDP05>
<KSCHL>R2</KSCHL>
</E1EDP05>
<E1EDP05>
<KSCHL>R2</KSCHL>
<BETRG>050</BETRG>
</E1EDP05>
<E1EDP05>
<KSCHL>R50</KSCHL>
<BETRG>015</BETRG>
</E1EDP05>
</E1EDP01>
As you can in the input file one of the E1EDP05 segment does not contain BETRG field but KSCHL is R2.
I am using graphical mapping.
Amount=add(
sum(ifWithoutElse([keepss=false]stringEquals(ORDERS05/IDOC/E1EDP01/E1EDP05/KSCHL=, const([value=R1])), ORDERS05/IDOC/E1EDP01/E1EDP05/BETRG=)),
sum(ifWithoutElse([keepss=false]stringEquals(ORDERS05/IDOC/E1EDP01/E1EDP05/KSCHL=, const([value=R2])), ORDERS05/IDOC/E1EDP01/E1EDP05/BETRG=)))
KSCHL and BETRG both context pointing to Idoc.
But I am not getting correct result when BETRG is missing.
When all values are present then it is not a problem.
Could you please suggest?
Thanks
Shubhankar
Hi Shubhankar !
Try the mapWithDefault function to get a "0" value when input value does not exists.
Regards,
Matias.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Shubhankar,
Try this . Use ur same logic, but do this small part before SUM.
-
If True----
BETRG
BETRG(Change Conext to IDOC) ->Exists-->If -
>SUM
-
If False----
Constant[0]
Best regards,
raj.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Raj,
If I understood you correctly then it should be
sum(ifWithoutElse([keepss=false]stringEquals(ORDERS05/IDOC/E1EDP01/E1EDP05/KSCHL=, const([value=R1])), <b>iF(ORDERS05/IDOC/E1EDP01/E1EDP05/BETRG=, exists(ORDERS05/IDOC/E1EDP01/E1EDP05/BETRG=), const([value=0])))),</b>
Bold portion I have changed it .
I have below values
R1 no value populated (BETRG tag is not coming)
R2 015
R1 050
R1 005
R2 015
R1 no value populated (BETRG tag is not coming)
But I am getting 100 istead of 085
In the display queue in0(that is R1) is 35 and in1(that is R2) is 65.
Please suggest something.
Thanks
Shubhankar
Hi Yaghya,
It is working when I am doing with single data. When context level for these two fileds is poiting to their parent segment(E1EDP05) and using removecontext after if condition.
But when I have multiple idocs it is not working properly. I am getting all totals to my first record and 0 for other records.
Please give some more suggestion.
Thanks
Shubhankar
Hi All,
Thanks for your valuable suggestion. I have created one UDF.
It is taking two argument and cache is queue.
1st Arg : KSCHL(context to Idoc)
2nd Arg: BETRG-->collapseContexts
My UDF:
//write your code here
int x=0;
for(int j=0;j<b.length;j++)
{
if (!b[j].equals(result.CC))
{
if(!c[x].equals(""))
result.addValue(c[x]);
else
result.addValue("0");
x++;
}
else
result.addContextChange();
}
My UDF is creating context for each idoc and also populating 0 when BETRG has suppress value.
After that result of UDF function is passing to if condition.
May be It is not very good solution but atleast it si working .
Thanks
Shubhankar
User | Count |
---|---|
87 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.