cancel
Showing results for 
Search instead for 
Did you mean: 

Message mapping problem

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Shubhankar !

Try the mapWithDefault function to get a "0" value when input value does not exists.

Regards,

Matias.

justin_santhanam
Active Contributor
0 Kudos

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.

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi,

Try the same but using 'SplitByValue' on BETRG and KSCHL before using them.

Former Member
0 Kudos

Hi Yaghya,

Thanks for your suggestion. When I am checking queue, KSCHL has tree value

R1

R2

R1

But BETRG has two values

015

050

So I am getting one less that is main the problem.

How can I create same number of values for KSCHL and BETRG?

Thanks in advance.

Regards,

Shubhankar

Former Member
0 Kudos

Shubhankar,

How about writing small UDF...where just pass all KSCHL and BETRG. It would be easy to handle in UDF once you have all data there...set context level at "E1EDP01"

Nilesh

Former Member
0 Kudos

Do you not get a SUPPRESS value now in BETRG along with 015 and 050?

This counts as a valueless element.

Former Member
0 Kudos

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

Former Member
0 Kudos

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