cancel
Showing results for 
Search instead for 
Did you mean: 

logic for grouping of items

Former Member
0 Kudos

Hi,

Here is my scenario. This is my input file.

I- header and J - are items. My requirement in target side is

I will have to group the items as below as separate messages:

I'm able to split the messages but not able to group with the related items

IYD01DOLL0000110000660000001557357820H

J201110192011101928USD  ABCD    9999AFVR000007686000000000000000000000000     

J0000000000000000       8000        000000180000000000000000000000000   IND

J0000000000000000       9000        000007488000000000000000000000000   GMM  

IYD01DOLL0000110000660000001557357820H 

J201110192011101928USD  ABCD    99AA3709000012804000000000000000000000000            

J0000000000000000       8000        000011480000000000000000000000000   CHDIND     

J0000000000000000       8000        000000060000000000000000000000000   CHDIND    

J0000000000000000       9000        000000100000000000000000000000000   CHDIND   

IYD01DOLL0000110000660000001557357820H   

J201110192011101928USD  ABCD    99AA3709000012804000000000000000000000000            

J0000000000000000       8000        000011480000000000000000000000000   CHDIND        

J0000000000000000       9000        000000060000000000000000000000000   CHDIND    

J0000000000000000       8000        000000100000000000000000000000000   CHDIND          

J0000000000000000       9000        000000100000000000000000000000000   CHDIND     

Thanks.

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi Pothana,

I have also faced the similar requirement. For this case we have to read source line by line and within the mapping we can use udfs to group and split. So you have to generate a separate target message for every Header. If this is the case

After FCC at sender side, ur source would be like

<Data>IYD01DOLL0000110000660000001557357820H</Data>

<Data>J201110192011101928USD  ABCD    9999AFVR000007686000000000000000000000000</Data>

<Data>J0000000000000000       8000        000000180000000000000000000000000   IND</Data>

<Data>J0000000000000000       9000        000007488000000000000000000000000   GMM</Data>

Since you have generate multiple messages, change the occurrences of the target message in the signature tab.

UDF to extract header values

UDF to extract the items and maintain the context

The above udf will group the items with respect to header, then use substring functions to extract the values from the row and map to suitable target elements.

Regards,

Malini

Former Member
0 Kudos

Hi Pothana,

If I have correctly understood your requirement, you can use the CopyValue function in Graphical Mapping to achieve what you are looking for.

Following is a link to refer about Copyvalue:

http://help.sap.com/saphelp_nw04/helpdata/en/26/d22366565be0449d7b3cc26b1bab10/content.htm

As for grouping the items together, you can use the SortbyKey function using one key element to sort all other elements in the message:

Refer more about SortbyKey:

http://help.sap.com/saphelp_nw04/helpdata/en/43/c4cdfc334824478090739c04c4a249/content.htm

Thanks & Regards,

Tejas Bisen

Former Member
0 Kudos

Hi Pothana,

Please clear the key values for the grouping. Just like Sep Gong said, if "ABCD","8000","9000" are the key values and could keep the sequence like "ABCD" is the first item line, then read all the file in FCC and split the items based on every "ABCD" or some other key values. for the header line. just use useOneAsMany function.

Regards,

K. Song

Former Member
0 Kudos

Hi

I see some values such as "ABCD","8000","9000" in the Items.

They are fixed values? If yes, i think you can split the items based on this field.

gagandeep_batra
Active Contributor
0 Kudos

Hi Pothana,

this type of scenario i have also face,

what you can do is just read the whole file row by row using fcc and the using UDF you need to  create the target message,

in udf you read all row in an array a[] and do like that

for(int i= 0; i<var1.length;i++)

{

if(a[i].substring(0,1).equals("I"))  // read first character l

{

result.addValue(a[i]); // add header

i++;

while(a[i].substring(0,1).equals("J"))

{

result.addValue(a[i]);

i++;

}

result.addValue(ResultList.CC);

i--;  ///because i increase more

}

check below blog that may also help

http://scn.sap.com/community/pi-and-soa-middleware/blog/2013/04/19/yes-it-is-possible-to-dynamically...

http://scn.sap.com/community/pi-and-soa-middleware/blog/2013/03/28/step-by-step-use-of-fccrd-based-o...

Regards

Gagan