cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping issue

Former Member
0 Kudos

Hi all,

I'm working on following mapping scenario.

Source

-


Name Occurrences Type

E1EDKA1 0..99 Node

-PARVW 0..1 String

-IHREZ 0..1 String

Target

-


HEADER 0..unbounded Node

-REFERNCE 0..1 String

PARVW can have values..AG,WE,LF, not necessarily in the same sequence. When PARVW = LF, I wanna copy the corresponding IHREZ value to field REFERENCE in target structure . Note that IHREZ is an optional field, it may not be present for all partner functions. I created a advanced function with the following code.

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

if (parvw<i>.equals("LF"))

result.addValue(ihrez<i>);

But this function is generating the following o/p queue

Input

-


PARVW IHREZ

AG <blank>

LF 12324

WE <blank>

Output

-


SUPPRESS

12324

SUPPRESS

Since the first element in the queue is SUPPRESS, there is no element REFERENCE getting created.

Any help is highly appreciated.

Thanks in advance

Praveen

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi Praveen,

You need not have use any userdefined function, please use the following mapping (text preview).

mapping for HEADER :

/root_target/HEADER =removeContexts(ifWithoutElse(and(stringEquals( /root_source/E1EDKA1/PARVW =, const()), exists(/root_source/E1EDKA1/ IHREZ=)), /root_source/E1EDKA1/IHREZ =))

mapping for REFERNCE :

/root_target /HEADER/ REFERNCE=SplitByValue( removeContexts(ifWithoutElse(and(stringEquals( /root_source/E1EDKA1/PARVW =, const()), exists(/root_source/E1EDKA1/ IHREZ=)), /root_source/E1EDKA1/IHREZ =)))

Regards,

KNS Kumar.

Former Member
0 Kudos

Hi all,

Thanks for your inputs. I solved it using the following advanced user defined function.

  • Cache entire Queue

String[] a = new String[100];

int i,j ;

j = 0;

for(i=0; i<parvw.length; i++)

if (! parvw<i>.equals(ResultList.CC) &&

! parvw<i>.equals(ResultList.SUPPRESS) )

a[j++] = parvw<i>;

for(i=0; i<a.length; i++)

if (a<i> != null && a<i>.equals("LF"))

result.addValue(ihrez<i>);

Kumar, I tried your solution..it works too..

Points for a few and thanks for the rest

praveen

Former Member
0 Kudos

Hi Praveen,

Go thru the link

http://help.sap.com/saphelp_nw04/helpdata/en/63/308c4024d26e1de10000000a1550b0/content.htm

Thanks and Regards

Vishal Kumar

stefan_grube
Active Contributor
0 Kudos

Hi Praveen,

use the node function <i>RemoveContexts</i> after your function.

But I do not see way you use a user defined function, you can do this with an equalS - if construction.

Regards

Stefan

MichalKrawczyk
Active Contributor
0 Kudos

Hi,

what about:

String empty = " ";

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

if (parvw.equals("LF"))

{

result.addValue(ihrez);

}

else

{

result.addValue(empty);

}

can you try this as I have no access to the XI right now

Regards,

michal

MichalKrawczyk
Active Contributor
0 Kudos

or you can try:

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

if (parvw.equals("LF"))

{

result.addValue(ihrez);

}

else

{

result.addSuppress();

}

Regards,

michal

Former Member
0 Kudos

Hi Michal,

Thanks for ur inputs.

If result.addValue() doesnt get called in case of AG and WE the SUPPRESS getting added to the o/p queue by default.

Additional result.addSuppress is not of use.

praven

MichalKrawczyk
Active Contributor
0 Kudos

Hi,

have a look at the createIf function

prepared as user advanced function:

http://help.sap.com/saphelp_nw04/helpdata/en/7d/028c4057d5701de10000000a1550b0/content.htm

Regards,

michal