cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping Sum of E1EDP05 BERTG in Lineitem to Target

sivag_s
Explorer
0 Kudos

Hello,

I am doing Graphical mapping from Invoice IDOC to EDI file. Please help me in fixing the following issues I am facing.

1. Under line item (E1EDP01), segment E1EDP05 occurs multiple times. I need to sum all BERTG in E1EDP05 and map it to corresponding line item in the Target. In above scenario we should also consider sign (+ or - ) in ALCKZ while summing.

2. I need to Map Order number in Header to all the line items.

Regards,

Sivaganesh S.

Accepted Solutions (0)

Answers (2)

Answers (2)

RaghuVamseedhar
Active Contributor
0 Kudos

Siva,

1) Please adjust/remove context of input field and use this UDF.


public void udf_sum(String[] var1, ResultList out, Container container) throws StreamTransformationException {

    float sum = 0;

    for (String string : var1) {

        if (string.endsWith("-")) {

            string = string.replace("-", "");

            sum = sum - Integer.parseInt(string);

        } else {

            sum = sum + Integer.parseInt(string);

        }

    }

    out.addValue(sum + "");

}

2) Please use copyValue.

Snavi
Active Participant
0 Kudos

you can concat ALCKZ + BETRG and then SUM function for your first requirement (refer screenshot)

context of ALCKZ and BETRG is set to EIEDP01

the 'lines' in the target structure mapped from E1EDP01 (i.e number of lines)

order can be directly mapped from POSNR

In my example I used 2 lines (E1EDP01) each with 3 E1EDP05 segments


and the result I get after mapping execution is 2 lines with unit price added

sivag_s
Explorer
0 Kudos

Hi Navdeep Singh,

Thanks for your reply. Regarding 1st point its working fine. I am using same technique for KRATE field, which contains negative sign in it (26.00-). In this case, I used SUM method directly to KRATE, but I am getting exception.

So I used Endswith, Replace and Concatenate function to bring the - sign in front (-26). But - sign is concatenating for both positive and negative values. Please find the below mapping I used.

Please advice me how to map directly without replace function in else part or please tell me is there any other technique to bring - sign before number. Thank you.

Regards,

Sivaganesh S.

Snavi
Active Participant
0 Kudos

Hi,

you can use the UDF

if ( var.charAt(var.length()-1) == '-')

{

     var = '-' + var.substring(0,var.length()-1);

}

return var;

var is the variable you need to paas which has value suffix with '-' sign

former_member190293
Active Contributor
0 Kudos

Hi, Sivag!

You could try something like this (assuming changing contexts for your case accordingly).

Regards, Evgeniy.