cancel
Showing results for 
Search instead for 
Did you mean: 

BPC Transformation conditional mapping

former_member221145
Participant
0 Kudos
724

Hi Experts,

I have a conditional mapping which I am trying to acheive in the transformation file (BPC 11.1 NW)

IF(0PCOMPANY <> *STR() Then 0PCOMPANY ; IF(0CUSTOMER <> *STR() Then 0CUSTOMER; IF(0VENDOR <> *STR() Then 0VENDOR; *STR(I_NONE))))

Can I use <> operator in the IF condition of Transformation file?

I tried with concatenation

INTERCO=*IF(0PCOMPANY+0CUSTOMER+0VENDOR=*STR() then *STR(I_NONE); ..can't proceed from here.

Thanks,
Rohit

Accepted Solutions (1)

Accepted Solutions (1)

former_member186338
Active Contributor
0 Kudos

May be the following will work in transformation:

INTERCO=*IF(0PCOMPANY+0CUSTOMER+0VENDOR=*STR() then *STR(I_NONE); 0PCOMPANY+0CUSTOMER=*STR() then 0VENDOR; 0PCOMPANY=*STR() then 0CUSTOMER; 0PCOMPANY

former_member221145
Participant
0 Kudos

Brilliant! Thanks Vadim this is the logic which I started to think but couldn't proceed from then Else ..INTERCO=*IF(0PCOMPANY+0CUSTOMER+0VENDOR=*STR() then *STR(I_NONE); ..can't proceed from here.

I am yet to test this and will keep you posted.

Thanks,

Rohit

Answers (3)

Answers (3)

N1kh1l
Active Contributor

rohit.padala

<> is not supported in Transformation file. You can try a workaround. I think you are trying to check if 0PCOMPANY is not blank then 0PCOMPANY else if 0CUSTOMER is not blank then 0CUSTOMER and so on. If your starting character/digit of COMPANY, CUSTOMER and VENDOR is consistent you can try below.
INTERCO=*IF(0PCOMPANY+0CUSTOMER=0PCOMPANY THEN 0PCOMPANY;0PCOMPANY(1:1)=*STR(C);0PCOMPANY;0CUSTOMER+0VENDOR=0CUSTOMER THEN 0CUSTOMER;0CUSTOMER(1:1)=*STR(P) THEN 0CUSTOMER;0PCOMPANY+0CUSTOMER+0VENDOR=0VENDOR THEN 0VENDOR;*STR(I_NONE))

0PCOMPANY(1:1)=*STR(C) Replace C with starting character of your COMPANY
0CUSTOMER(1:1)=*STR(P) Replace P with starting character of your CUSTOMER Unfortunately if starting characters are not consistent then you will need a routine (UJD_ROUTINE) for this.Hope it helps you.

Please upvote/accept if this helps

Nikhil

former_member186338
Active Contributor
0 Kudos

sorry, but it will not work:

*IF(0PCOMPANY+0CUSTOMER=0PCOMPANY THEN 0PCOMPANY;...

if 0PCOMPANY and 0CUSTOMER are empty then condition is true! Empty 0PCOMPANY will generate error

N1kh1l
Active Contributor
0 Kudos

vadim.kalinin,

Thanks Vadim, you are right. I overlooked that scenario.

Nikhil

former_member221145
Participant
0 Kudos

Brilliant! Thanks Vadim this is the logic which I started to think but couldn't proceed from then Else ..INTERCO=*IF(0PCOMPANY+0CUSTOMER+0VENDOR=*STR() then *STR(I_NONE); ..can't proceed from here.

I am yet to test this and will keep you posted.

Thanks,

Rohit

former_member186338
Active Contributor
0 Kudos

UJD_ROUTINE is not required

INTERCO=0PCOMPANY+*STR(_)+0CUSTOMER+*STR(_)+0VENDOR

And in conversion file you can use javascript to parse the line and check conditions.

P.S.

In conversion test:

IF %external% = "__" then "I_NONE"

IF %external% start with "__" then vendor part

IF %external% start with "_" then customer part

Else pcompany part

P.P.S

sample how to get customer part in js:

var external="1234_34lmlm5_678";
alert(external.slice(external.indexOf("_")+1,external.lastIndexOf("_")));

result is 34lmlm5

vendor part:

alert(external.slice(external.lastIndexOf("_")+1));

pcompany part:

alert(external.slice(0,external.indexOf("_")));

full logic:

alert(external=="__" ? "I_NONE" : (external.slice(0,2)=="__" ? external.slice(external.lastIndexOf("_")+1) : (external.slice(0,1)=="_" ? external.slice(external.indexOf("_")+1,external.lastIndexOf("_")) : external.slice(0,external.indexOf("_")))));

not very complex!

Line in conversion file:

js:%external%=="__" ? "I_NONE" : (%external%.slice(0,2)=="__" ? %external%.slice(%external%.lastIndexOf("_")+1) : (%external%.slice(0,1)=="_" ? %external%.slice(%external%.indexOf("_")+1,%external%.lastIndexOf("_")) : %external%.slice(0,%external%.indexOf("_"))))
former_member186338
Active Contributor
0 Kudos

Sorry, but read help on IF function syntax:

*If(Condition1 then Action1;Condition2 then Action2;Default Action)

only single IF!