cancel
Showing results for 
Search instead for 
Did you mean: 

Using an intermediate variable while mapping

Former Member
0 Kudos

Hi helpers!

I'm still learning and I wonder how can I do the next:

I have one source file that has two types of lines, one header and 'n' normal lines. There is an field in the header with information I need in every normal line of the target file.

I imagine that there is a way to record the value in that field into a variable so I can access to it for every target line.

Hope I've explained myself. Thankyou!.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

HI,

If i am getting you correctly , you want to map a value from the header of the source to the target field on the details (normal) lines.

I think this can be achieved through a normal mapping to .

just map the value in the source header to the target field.

so the target field will extract the value from the header source field whenever the line occurs.

Thanks

Nikhil

Former Member
0 Kudos

Doing that I get a mapping error. That was the first thing I thought.

I think it's because the LINE_I (details) section is linked 1on1 with the LINE_I sections of the source and the data I want to get is in LINE_H (header) section of the source file.

Thanks.

bhavesh_kantilal
Active Contributor
0 Kudos

hi,

can you give us your source and destination strucutur , so that it would help us understand your requirements better.

Regards,

Bhavesh

Former Member
0 Kudos

Of course, I hope this works:

Source:

RECORD

--LINE_H (1 ocurrence)

-


DATE (The field I want)

--LINE_I (n ocurrences)

Target:

RECORD

--LINE_I (n ocurrences)

-


DATE_EXEC (The field where I want in every line the DATE value)

moorthy
Active Contributor
0 Kudos

Hi,

Just you need to set the value for Date field in the Global Variables ( SP14) /Global Containers. And in the line item level, you need to get that value.

This blog explains in detail-

/people/michal.krawczyk2/blog/2005/03/04/globalcontainer--in-graphical-mapping-xi

Hope this helps

Thanks,

Moorthy

Former Member
0 Kudos

Hi,

You can adopt one of the logics below

1) store it in a global variable and use it in mapping (as suggested by others)

2) store it ina global container (in a simple user-defined mapping) and use it in item level mapping

3) use the standard node function useOneAsMany..which doesnt require any java mapping. But this is resource intensive.

praveen

Former Member
0 Kudos

Sirupa,

Could you tell us how we can use "useOneAsMany"?

For this to be used, the source date has to be in the same context as the target date right?

We would have to change the context of the date field in the source, in order to use this. How do we do that?

Regards,

Smitha.

Former Member
0 Kudos

Hi Smitha,

Assume the following

Source:

RECORD

--LINE_H (1 ocurrence)

-


DATE (The field I want)

--LINE_I (n ocurrences)

-


FLD_I (1 occurrence)

Target:

RECORD

--LINE_I (n ocurrences)

-


DATE_EXEC (1 occrrence)

-


FLD_I (1 occrrence)

/Record/LINE_I = /Record/LINE_I/FLD_I[context=Record]

/Record/LINE_I/DATE_EXEC = useOneAsMany(

/Record/LINE_H/DATE ,

/Record/LINE_I/FLD_I[context=Record] ,

/Record/LINE_I/FLD_I)

/Record/LINE_I/FLD_I = /Record/LINE_I/FLD_I

Check whether this works out. I dint test it yet.

Its possible using useOneAsMany.

praveen

Former Member
0 Kudos

Sirupa,

I tried the useOneAsMany node function and it works perfectly for this scenario.

It worked without the context change also.

Regards,

Smitha

bhavesh_kantilal
Active Contributor
0 Kudos

hi,

you can use global variables if you are on SP14 or above.

Just save the value in the global variable and then use it in your mapping for other fields.

Refer this blog on the same,

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

If you are not on SP14, you can use the CONCAT function available in the standard functions-- TEXT functions and concat this value with the value of other fields also,

Refer top this link for standard functions in XI,

http://help.sap.com/saphelp_nw04/helpdata/en/2c/2d8c4024d26e1de10000000a1550b0/content.htm

Regards,

Bhavesh

Former Member
0 Kudos

Ok, I now how to create a variable now but, how do I initialice it with the value of a field? May I write something about the payload?

Sorry, I'm not really proud of my Java. Thanks!

moorthy
Active Contributor
0 Kudos

Hi,

There is a concept of Global Container. You can use this for this reason.

http://help.sap.com/saphelp_nw2004s/helpdata/en/ae/d03341771b4c0de10000000a1550b0/frameset.htm

http://help.sap.com/saphelp_nw2004s/helpdata/en/ae/d03341771b4c0de10000000a1550b0/frameset.htm

And you can write small java user defined to achieve this without using Global Container.

Hope this helps.

Regards,

Moorthy