cancel
Showing results for 
Search instead for 
Did you mean: 

Split mapping

Former Member
0 Kudos
72

hi all ,

i am trying to do a advanced user defined java mapping:

my source structure is

<header>

sap order no

customer No

name

address

city

state

zipcode

<lineItem>

lineitemid

codevalue

make

model

my target structure is

<Msg 1>

sap order no

cutomer No

flag1

flag2

flag3

flag4

flag5

here, in the source the header occurs only once, the line item occurs multiple times. one to five times. all i am trying to do is this particular element "code value" . i have to count the no of occuerences of this node, save the value at each occurence and split each value. example the 1st occurenece can have A , 2nd occurence can have B third occurence can again be A. so let say the values are A B and A. i have to count the occurences, store the value at each occurence and split the value. so that i can map 1st time occurence (A) to flag 1, (B) to flag 2 and (A) to flag 3 and so on...

can somebody please provide me any suggestions???

Accepted Solutions (1)

Accepted Solutions (1)

stefan_grube
Active Contributor
0 Kudos

When I undtood correct, you want:

flag1 = codevalue(occurrence 1)

flag2 = codevalue(occurrence 2)

and so on.

You can do this with following advanced function (<b>not</b> caching the queue) with two parameters:

  int index = Integer.parseInt(b[0]);
  if (a.length > index)
     result.addValue(a[index]);
  else
    result.addValue("");

Use it like this:

codevalue(context=oneLevelUp) 
                               YourFunction - flag_n
                constant(n-1) /

It works as well with standard functions, but I needed 13 object for one target element, maybe another guy has a better solution

Hope that helps,

Stefan

Former Member
0 Kudos

Thanks all for your suggestions..

Stefan...

I am very comfortable with standard fns rather than java as i am not a java person..

i was trying the mapping in std msg mapping but of no use..i would appreciate if you can give me an idea of doing the mapping with std fns...

Pls advice

Thanks

Harika

stefan_grube
Active Contributor
0 Kudos

When you want to do this with standard functions, you have first to consider, that the occurrance of lineitem is between 0 and 5, so when we want to check for flag4, we have to assure, that the occurrance is greater 3. We do this with the statistic function count. If the check fails, we take an empty constant for flag4.

For the check, if the 4th value is here, we choose the static function index, which counts the elements in a context. This function comes with SP12/13.

For flag4 we have:


    lineitem - index 
                      equalA 
          Constant(4)/        ifWithoutElse 
                              /              
codevalue(context=upOneLevel)/                                                                                
lineitem - count           
                                      greater - if - flag4
                          Constant(3)/          /      
                                               /
                                    Constant()/

As promised there are 13 objects

If this does not work for you, let me have the XML that you use for testing.

Stefan

Former Member
0 Kudos

Hello stefan,

I tried your suggestion and it worked!!!Thanks a million.

Also can i have your personal e-mail id ?

Thanks a lot again

Harika

Former Member
0 Kudos

Great Job...Congratulations...

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Harika,

U can do split mapping of ur scenario by using RB_Split during ur interface determination, or by using packaging.(search for 'blog on packaging' in sdn).

cheers,

Prashanth

former_member91687
Active Contributor
0 Kudos

Hi Harika,

Have a look at these links:

/people/prasad.ulagappan2/blog/2005/06/29/java-mapping-part-i

http://help.sap.com/saphelp_nw04/helpdata/en/f8/2857cbc374da48993c8eb7d3c8c87a/content.htm

Hope these help.

Cheers,

Chandra

bhavesh_kantilal
Active Contributor
0 Kudos

Hi Harika,

If you are using Graphical Mapping, then in SP14 a new feature called GLOBAL VARIABLES has been added. You can save all these values into a gloabl variable and access them later whenever you want. As you told specifically that the occurence is only between 1 and 5, I think this problem can be solved using GLOBAL VARIABLES.

For more on Global Variables and how to use them in SP14, check this blog out,

/people/sap.user72/blog/2005/10/01/xi-new-features-in-sp14

Else, you can always go for JAVA MAPPING and XSLT mapping wherein the values can be stored in a array and accessed later. Check out these links for the same,

http://help.sap.com/saphelp_nw04/helpdata/en/14/80243b4a66ae0ce10000000a11402f/frameset.htm

http://help.sap.com/saphelp_nw04/helpdata/en/14/80243b4a66ae0ce10000000a11402f/frameset.htm

Hope this helps,

Regards,

Bhavesh