cancel
Showing results for 
Search instead for 
Did you mean: 

Summarize amount in mapping

Former Member
0 Kudos

Hi

I am using standard idoc INVOIC02. I need summarized amount of menge where partn = north and south at the target. The structure is something like this.

E1EDP01

--MENGE

--E1EDP05

--PARTN

Please advice.

Regards

Monika

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos


MENGE..>removeContext...>\
                     ....UDF....Target field
PARTN.....>removeContext..>/

UDF.Choose context while creating the UDF


int sum=0;

for(int i=0;i<PARTN.length;i++)
{
if(PARTN<i>.equals("north")||PARTN<i>.equals("south")
{
int a = Integer.parseInt(MENGE<i>);
sum = sum +a;
}
}
String res = String.valueOf(sum);
result.addValue(res)

Answers (3)

Answers (3)

Former Member
0 Kudos

In the above structure there is no PATNR field under E1EDP01 segment

also Do you want sum of PATNR =north and PATNR =south separately?

Former Member
0 Kudos

Hi Kubra

I want the sum separately. Can you please provide more clarity on your solution.

Regards

Monika

sunil_singh13
Active Contributor
0 Kudos

Hi Monika,

Logic given by Luic will work, no need to write any UDF. As SAP standard function are capable of achieving your requirment.

But you have to make sure that you have taken the proper context of the fields.

Thanks,

Sunil Singh

Former Member
0 Kudos

>> I want the sum separately. Can you please provide more clarity on your solution.

Hint: If you want to sum separately then you have to duplicate the target node which contains the sum. I think it is possible without using any udf try the solution which I have give to you in my earlier reply.

Former Member
0 Kudos

First of all filter the menge based on partn by if conditon then use the remove context in the output of if conditon and then use SUM function from statistic.

e.g.

if (partn = north or south) then (MENGE) --- removeContext - SUM- Target.

--Sarvesh

Former Member
0 Kudos

Hi Sarvesh

It is working without the udf also. However i am not getting the result based on the filter say suppose "NORTH". It is giving me the grand total of all the menge irrespective of PARTN.

Regards

Monika

Former Member
0 Kudos

> It is working without the udf also. However i am not getting the result based on the filter say suppose "NORTH". It is giving me the grand total of all the menge irrespective of PARTN.

Since you want two results in one field (one for north and another for south) therefore first you duplicate the target node in which menge is present then use the below logic in each mapping.

if (PARTN = NORTH ) then (MENGE) --- RemoveContext --- SUM--- Target1.

if (PARTN = SOUTH) then (MENGE) --- RemoveContext --- SUM--- Target2.(Duplicate MENGE)

Othewise let me know your exact requirement.

Regards,

Sarvesh

Former Member
0 Kudos

Hi Sarvesh

Please refer to standard idoc INVOIC02. It has a segment e1edp01 which contains a field MENGE. It also contains another segment E1EDPA1 which contains a field PARTN. Now i want the sum of menge for PARTN = NORTH and SOUTH sepately. However even after hndling context i get sum of all values as PARTN lies in the context of MENGE.

Regards

Monika

Former Member
0 Kudos

Can you send your target structure and indicate in which field you want the sum of North and in which of South.

Former Member
0 Kudos

<INVOIC02>

<MANDT>050</MANDT>

<DOCNUM>0000000057208371</DOCNUM>

<E1EDK01>

<CURCY>USD</CURCY>

<WKURS>1.00000</WKURS>

</E1EDK01>

<E1EDP01>

<POSEX>00001</POSEX>

<ACTION>001</ACTION>

<PSTYP>0</PSTYP>

<MENGE>50.000</MENGE>

<MENEE>PC</MENEE>

<EDPA1>

<PARVW>ZS</PARVW>

<LIFNR>0004000073</LIFNR>

<NAME1>ZEICHMAN MANUFACTURING INC.</NAME1>

<STRAS>5985 CLAY AVENUE SW</STRAS>

<ORT01>Grand Rapids</ORT01>

<PSTLZ>49548</PSTLZ>

<LAND1>US</LAND1>

<REGIO>MI</REGIO>

<EDPA1>

</E1EDP01>

<E1EDP01>

<POSEX>00002</POSEX>

<ACTION>001</ACTION>

<PSTYP>0</PSTYP>

<MENGE>40.000</MENGE>

<MENEE>PC</MENEE>

<Z1EDPA1></Z1EDPA1>

</E1EDP01>

<E1EDP01>

<POSEX>00003</POSEX>

<ACTION>001</ACTION>

<PSTYP>0</PSTYP>

<MENGE>90.000</MENGE>

<MENEE>PC</MENEE>

<EDPA1>

<PARVW>ZS</PARVW>

<LIFNR>0004000073</LIFNR>

<NAME1>ZEICHMAN MANUFACTURING INC.</NAME1>

<STRAS>5985 CLAY AVENUE SW</STRAS>

<ORT01>Grand Rapids</ORT01>

<PSTLZ>49548</PSTLZ>

<LAND1>US</LAND1>

<REGIO>MI</REGIO>

<EDPA1>

</E1EDP01>

<INVOIC02>

Former Member
0 Kudos

Hi Monika

in your structure is not the element PATNR.

Well in case exist you can use standar functions.



PATRN ---- Equal$ ("South") 
PATRN ---- Equal$ ("North") .......Or ......ifwithoutElse
................................................................Sum(MENGE)-------->Target

Former Member
0 Kudos

Hi

I am sorry i forgot to include PARTN. It exist below PARWN

Regards

Monika