cancel
Showing results for 
Search instead for 
Did you mean: 

IF Else condition

Former Member
0 Kudos

Hi Every one,

Hello every one

i have requirement in mapping where i have to map E1EDP02/ZEILE when QUALF= 001 to the target feild LineItemno if E1EDP19/IDTNR = "FREIGHT CHARGES" (when QUAL="002") or else the target feild has to be mapped to E1EDP26/BETRG (when QUAL="003").

I know the above requirement can be easyly achived using If else condidtion.

But the complexity in the above requirement is usually there will be more than five E1EDP19-IDTNR = (when QUAL="002")coming from the source side. The feild E1EDP02/ZEILE when QUALF= 001 should be mapped to the LineItemno even if one of the source field E1EDP19/IDTNR = "FREIGHT CHARGES" (when QUAL="002"). It is not mandatory that all of the source field: E1EDP19/IDTNR = "FREIGHT CHARGES" (when QUAL="002"). the result to the if condition should be true even if one source E1EDP19/IDTNR is equal to "FREIGHT CHARGES" (when QUAL="002").

Can any one please tell me how i can achive the above requirement.

Regards

FYI: I have alredy posted this question erlier in the morning; but one of our friend locked it saying i have double posted it. but that was the first time i have posted the question. Please dont lock it again because its an urgent requirement.

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member184681
Active Contributor
0 Kudos

Dear Swetha Reddy,

Now, same thing is already posted three times:

First one already answered by two people

Second one that I already locked

Third one here in this thread

I do understand that this is an urgent requirement (just as most of them here in SCN, anyway), but this is not a reason yet to ignore the rules of the SCN. If you are not sure if a thread was posted successfully for some reason, first go to your profile and to "Activity" tab page, where you can find your own, most recent threads.

Regards,

Greg

Former Member
0 Kudos

Sorry about the mistake Greg and thanks for info. I am new to sap/scn.

I will keep that in mind from now and follow rules of engagement.

Thanks again for all your help.

rajasekhar_reddy14
Active Contributor
0 Kudos

I dont see any complexity in this requirement, attach sample data.

Former Member
0 Kudos

Hi Raja,

The complexity in the above scenario is the field E1EDP19-IDTNR = (when QUAL="002") comes more that 1 time in the source Idoc.

for example if there are five  E1EDP19-IDTNR = (when QUAL="002") comin from source Idoc and only one E1EDP19/IDTNR = "FREIGHT CHARGES" (when QUAL="002") and the remaining are equal to other, then if condition is passing to else since there is one true and four falses in the condition.

My requirement is even if one E1EDP19/IDTNR = "FREIGHT CHARGES" (when QUAL="002") is there from source side then IF condition should get true and passed to THEN rather than passing it to ELSE.

Hope i made myself clear.

Thanks for help

rajasekhar_reddy14
Active Contributor
0 Kudos

use if then function(without else) first check Qualifier = 002 using equals - text function and map this to if then function,map IDTNR to then.

Former Member
0 Kudos

Hi Raja,

I am not getting it right, can you please explain it a bit clearly.

My requirement is

i have to map E1EDP02/ZEILE when QUALF= 001 to the target feild LineItemno if E1EDP19/IDTNR = "FREIGHT CHARGES" (when QUAL="002") or else the target feild has to be mapped to E1EDP26/BETRG (when QUAL="003").

rajasekhar_reddy14
Active Contributor
0 Kudos

which IDoc are you using ORDERS05?

Former Member
0 Kudos

INVOIC.INVOIC01

Former Member
0 Kudos

Hi Swetha,

You are better off righting a small UDF, I am attaching a small code here below:

(Please note that this code is for representative purposes only and may have some syntax errors)

if (E1EDP19Qualf = 002)

{

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

    {

        if (E1EDP19IDTNR[i].equals("FREIGHT CHARGES"))

        { flag = 1;}

        }   

}

if (flag == 1)

{

    if(E1EDP02QUALF == 001)

    {result.addValue(E1EDP02ZEILE)}

    else

    {

    result.addValue(E1EDP26BETRG);

    }

}

Also, as per this code if you would need the same index of ZEILE or BETRG as IDTNR then you would need another variable like Flag to store the index value of "i" where IDTNR equals "FREIGHT CHARGES".

Please let me know in case you need more assistance with the code.

Former Member
0 Kudos

Hi VJ,

Thanks for the help, there is a small change in requirement.

Can you please give me a code to write UDF.

The requirement is like this;

for example if there are five  E1EDP19-IDTNR = (when QUAL="002") comin from source Idoc and only one E1EDP19/IDTNR = "FREIGHT CHARGES" (when QUAL="002") and the remaining are equal to other, then if condition is passing to else since there is one true and four falses in the condition.

My requirement is even if one E1EDP19/IDTNR = "FREIGHT CHARGES" (when QUAL="002") is there from source side then IF condition should get true.

Just give me code to make the condition true if altleast one  E1EDP19/IDTNR = "FREIGHT CHARGES" (when QUAL="002"), and it should return false if there is no  E1EDP19/IDTNR = "FREIGHT CHARGES" (when QUAL="002") at all from source side.

Former Member
0 Kudos

Hi Swetha,

Please find below the code:

Assumptions:

1. The UDF assumes that you will have same number of values for IDTNR, ZEILE and BETRG

2. All the 6 inputs are context changed to E1EDP01 and the UDFs output type is queue.

int flag = 0;    // No IDTNR equals to FREIGHT CHARGES

int index = 0;

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

{

if (E1EDP19Qualf[i].equals("002"))

{

    if (IDTNR[i].equals("FREIGHT CHARGES"))

    {

        flag = 1;

        index = i;        // in case you want ZEILE or BETRG at the same index

    }

        }        // end of if (E1EDP19Qualf[i].equals("002"))

}                // end of for loop

if (flag == 1)

{

for (int j = 0; j < IDTNR.length ; j++){

    if(E1EDP02Qualf[j].equals("001"))

        result.addValue(ZEILE[j]);

}

}

else

{

for (int j = 0; j < IDTNR.length ; j++){

    if(E1EDP26Qualf[j].equals("003"))

        result.addValue(BETRG[j]);

}

}

Best luck,

Varun

Former Member
0 Kudos

Hi Varun,

Sorry for confusing you; i thing i am not clear in explaining you my requirement.

let me explain it clearly, My interface is Idoc(Invoice)to File

I usually have this field E1EDP19/IDTNR (when QUAL="002") with multiple occurances from source side. for example it is occuring 5 times. I will have atleast one value of one of the five feilds equal to FREIGHT CHARGES.

I want the condition to be true if atleast one occurance of E1EDP19/IDTNR (when QUAL="002")= FREIGHT CHARGES. and the condition should be false if none of the five occurances of the E1EDP19/IDTNR (when QUAL="002")= FREIGHT CHARGES.

If it is true then i have one requirement to map then and if it is false i will map to Else using If Then Else function.

Please tell me if i can achive the above using Graphical mapping or give me a Code for UDF.

Regards

Former Member
0 Kudos

Hi Everyone,

Can any one help me with below requirement please,

My interface is Idoc(Invoice)to File 

I usually have this field E1EDP19/IDTNR (when QUAL="002") with multiple occurances from source side. for example it is occuring 5 times. I will have atleast one value of one of the five feilds equal to FREIGHT CHARGES.

I want the condition to be true if atleast one occurance of E1EDP19/IDTNR (when QUAL="002")= FREIGHT CHARGES. and the condition should be false if none of the five occurances of the E1EDP19/IDTNR (when QUAL="002")= FREIGHT CHARGES.

If it is true then i have one requirement to map then and if it is false i will map to Else using If Then Else function.

Please tell me if i can achive the above using Graphical mapping or give me a Code for UDF.

Regards

Former Member
0 Kudos

Hi Shweta,

If we look closely, the UDF code that I have give does the following:

a) it checks (for all the occurrences) if E1EDP19 - QUALF is 002; if yes then it checks whether IDTNR equals "FREIGHT CHARGES" or not. If any one occurrence of IDTNR has the value as "FREIGHT CHARGES" then it sets the flag as 001. I think this is what you want?

If you want to also cover the case where you can have multiple IDTNR equalling FREIGHT CHARGES then instead of flag = 1, you can use flag = flag + 1 and then in the IF condition, you can change the condition to: "if (flag > 0)" and then run the for loop for the numbers of times as flag is occurring.

In case you need to discuss the issue at length, kindly give me you email id and I'll drop you an email.

Best regards,

V J