cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping Queries

Former Member
0 Kudos

Hi All,

I have the following mapping requirements in the message mapping but I am not getting how to implement these requirements

1.The Source field is Source while the target field is target,the mapping logic should be like,if(target field starts with the CR) then the output should be mapped with the constant 005 else the output should be mapped with the constant 022.

How can i implement it?

2.The source Idoc segment name and the field in the segment are segment and field respectively,the target field is target.

Now,the mapping requirement is like,create only segment when the field of the segment is populated.How can I implement it?

3.The source field is source, the target field is target,now the mapping logic should be like this,if(the source starts with AA)then remove AA else source should be mapped to the target as it is.How can I implement it?

Thanks in advance

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

U want to suppress target field if source filed value starts with "AA" and if not then pass source value as it is?? if yes then see the blow mapping(infact this has already been stated in earlier replies):

source->

Startswith-> Not ->Ifwithoutelse -> target (source -> then)

Constant (AA)->

Note: map source filed in "then" condition

Thanks

Amit

Former Member
0 Kudos

Hi Amit,

Thanks for the reply.

U want to suppress target field if source filed value starts with "AA" and if not then pass source value as it is??

The mapping logic should be like this

If the input value is comming as AA01234,then the AA should be suppressed and 01234 should be passed else means,the values is not having AA at the start,then it should be passed as it is.

How can I implement this logic?

Thanks in advance

Former Member
0 Kudos

Hi Supriya,

Thanks for the reply.

The mapping logic should be like this

If the input value is comming as AA01234,then the AA should be suppressed and 01234 should be passed else means,the values is not having AA at the start,then it should be passed as it is.

How can I implement this logic?

Thanks in advance

Former Member
0 Kudos

Hi,

In that case:

source->

Startswith-> If thenelse -> target ((source->UDF -> then) and source-> else))

Constant (AA)->

UDF wil be:

Execution type will be: Single value

Input will var1 type string.

int a=var1.length();

String a1 = var1.substring(2,a);

return a1;

Thanks

Amit

Answers (7)

Answers (7)

Former Member
0 Kudos

Hi Shweta,

Source -->UDF -->

where should the output of UDF be given?

The output of the UDF is given to the then part of ifThenElse function (that is upper part).

Source-> Substring(0,2)--


> equalS -


> ifThenElse -


> Target

Constant AA-----> Source --->

Here where should the source output in Constant AA-----> Source ---> be given?

Source Constant[AA] is given to equalS 2nd input, and only Source is given as input to the else part of ifThenElse(lower part)

3.What should be given to the Then and Else of IfThenElse?

Already answered.

-Supriya.

Edited by: Supriya Sawant on Sep 17, 2010 11:48 AM

Former Member
0 Kudos

Hi Shweta,

You have to use UDF in this case.

The UDF would be :

Pass the incoming value as input to UDF, say it is A.

int x = A.length();

String B = A.substring(2,x);

return B;

The actual mapping would be:

Source -->UDF -->

Source-> Substring(0,2)--


> equalS -


> ifThenElse -


> Target

Constant [AA]-----> Source --->

-Supriya.

Former Member
0 Kudos

Hi Supriya,

Thanks for the reply.

Source -->UDF -->

Source---> Substring(0,2)----------------------> equalS ----> ifThenElse ----> Target
Constant AA-----> Source --->

Here the substring output and the constant AA should be the input to the equalsS and the output of the equals should be given to the If of the IfThenElse.

I have a few queries

1.

Source -->UDF -->

where should the output of UDF be given?

2.

Source---> Substring(0,2)----------------------> equalS ----> ifThenElse ----> Target
Constant AA-----> Source --->

Here where should the source output in Constant AA-----> Source ---> be given?

3.What should be given to the Then and Else of IfThenElse?

Thanks in advance

Edited by: Shweta Kullkarni on Sep 17, 2010 11:40 AM

Former Member
0 Kudos

Hi,

i think u havent read the reply properly:

1) source->UDF output needs to be given under "then" condition

2) source under "else" condition.

Suggestion: instead of using substring function use the standard available function "startsWith".

Thanks

Amit

Former Member
0 Kudos

Hi Shweta,

Map the output of 'not' function to if part of ifWithoutElse and constant[] to else part.

-Supriya.

former_member208856
Active Contributor
0 Kudos

>

> 1.The Source field is Source while the target field is target,the mapping logic should be like,if(target field starts with the CR) then the output should be mapped with the constant 005 else the output should be mapped with the constant 022.

> How can i implement it?

>

For this you can use SUBSTRING Function

IF WITH ELSE Source --> Substring (0,2)

--> Equals

CONSTANT(CR)

--> Then CONSTANT(005) --> Target

ELSE CONSTANTt (022) --> Target

>

> 2.The source Idoc segment name and the field in the segment are segment and field respectively,the target field is target.

> Now,the mapping requirement is like,create only segment when the field of the segment is populated.How can I implement it?

>

>

USE EXISTS Function in this case

SOURCE --> EXISTS --> TARGET (it will create target only, when source exists).

>

> 3.The source field is source, the target field is target,now the mapping logic should be like this,if(the source starts with AA)then remove AA else source should be mapped to the target as it is.How can I implement it?

>

>

Use same SUBSTRING (0,2)

IF SUBSTRING (0,2) -->

EQUALS

-->

CONSTANT (AA)

--> Then SUBSTRINT (3,10) --> Target

Former Member
0 Kudos

Hi Shweta,

2. filed ---> createIf ---> target

Do I need to implement it like Source field->createif->target field?

Yes.

Source ---> subString(0,1) ---> equalS -


> not ->ifWithoutElse-> target

ConstantAA] constant[ -


>

Do I need to use the ConstantAA value in the else condition of the If then else condition?

Firstly, it is not ifThenElse function, it is ifWithoutElse.

For the second input of ifWithoutElse, use contsant[].

And output of sbString function and Constant[AA] should be used for equalS function.

-Supriya.

Former Member
0 Kudos

Hi Supriya,

Thanks for the reply.

Firstly, it is not ifThenElse function, it is ifWithoutElse.
For the second input of ifWithoutElse, use contsant[].
And output of sbString function and ConstantAA should be used for equalS function.

What do I need to put infor Then in the If condition?

Thanks in advance

former_member209575
Contributor
0 Kudos

Hi,

1.The Source field is Source while the target field is target,the mapping logic should be like,if(target field starts with the CR) then the output should be mapped with the constant 005 else the output should be mapped with the constant 022.

How can i implement it?

Can u provide some more clarity

2.The source Idoc segment name and the field in the segment are segment and field respectively,the target field is target.

Now,the mapping requirement is like,create only segment when the field of the segment is populated.How can I implement it?

U can check whether fields are emtpy using a small UDF and if not empty return TRUE and ucan pass this to node function "createif"

3.The source field is source, the target field is target,now the mapping logic should be like this,if(the source starts with AA)then remove AA else source should be mapped to the target as it is.How can I implement it?

you need the following UDF (ExecutionType: All Values of a Context) for the node ROW:

boolean flag = true;

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

if (var1<i>.startsWith("AA")) {

flag = false;

}

}

if (flag) {

result.addValue("");

} else {

result.addSuppress();

}

Then create the following mapping: Field --> UDF --> removeContext --> ROW

Regards

Pradeep P N

Former Member
0 Kudos

Hi Shweta,

Try the below mappings:

1.Source ->subString(0,1)-> fixValues ---> target

In the fixValues table, put the values as if CR is there then 005, otherwise default value is 022.

2. filed ---> createIf ---> target

3. Source ---> subString(0,1) ---> equalS -


> not ->ifWithoutElse-> target

Constant[AA] constant[] -


>

-Supriya.

Former Member
0 Kudos

Hi Supriya,

Thanks for the reply.

2. filed ---> createIf ---> target

Do I need to implement it like Source field->createif->target field?

3. Source ---> subString(0,1) ---> equalS -----> not --->ifWithoutElse---> target

ConstantAA] constant[ ---->

Do I need to use the ConstantAA value in the else condition of the If then else condition?

Thanks in advance

rajasekhar_reddy14
Active Contributor
0 Kudos

Hi Swetha,

first read help documentation about standards function, understand celarly, practice your self...

http://help.sap.com/saphelp_nwpi71/helpdata/EN/43/c4cdfc334824478090739c04c4a249/content.htm

Starts with function available to check if field starts withh AA ,then you can implemet logic..the requirement what you have posted very simple..

Regards,

raj