on 03-12-2007 2:22 PM
HI,
im having problems with my if then else condition.
What i want to have. (ORDERS IDOC)
IF E1EDKA1-PARVW = WE and
E1EDKA1-LIFNR = "XX" then CONSTANT ("true")
else Constant ("false").
If i use only one E1EDKA1 segment ... it works.
If i use many E1EDKA1 segments and use if without else ... it works.
But i cant get it with if then else. I will allways get the else value.
any ideas ?
Gordon
Message was edited by:
Gordon Breuer
Hi
i think u can do it with graphical mapping.
whatever u have done is correct. just change the context.
try this.
PARVW(context=<b>E1EDKA1</b>)
equals
Constant(WE)
<b>and</b>
LIFNR(context=<b>E1EDKA1</b>)
equals
Constant(XX)
the <b>and</b> operator goes into the IF
Then is filled with constant (true)
Else is filled with constant (false)
& output goes to target field.
Map E1EDKA1 properly.
Thanks,
Maheshwari.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Maheshwari. : no ...same result. have you tested it ?
you dont have to test with E1EDKA1 WE only. Most orders have PARVW AG, RE, LF and many more.
@Chilla. Your UDF is not complete. The "(" and ")" is missing and it´s only working if i have only one E1EDKA1 segment with PARVW "WE".
try the following test.
E1EDKA1 - AG (LIFNR Field is not available)
E1EDKA1 - WE (LIFNR is available with xx)
but ... this way seems to be the right one, lets go and complete this issue together.
Thanks you,
chilla !
HI
full details as already said.
PARVW = WE and LIFNR = xx
but note that E1EDKA1 segment could be exists more than once.
Example
E1EDKA1-PARVW = AG
E1EDKa1-LIFNR = is not existing / visible
E1EDKA1-PARVW = WE
E1EDKa1-LIFNR = xx
E1EDKA1-PARVW = LF
E1EDKa1-LIFNR = 4711
false: if LIFNR is not filled with xx and PARVW = WE
true: if one of the E1EDKA1 is filled with LIFNR = xx and PARVW = WE.
right ?
HI,
<b>In your example data only one true and two false right?</b>
try the below UDF
-
use parvw - removecontext -- UDF -- split byvalue --target node
-
use lifnr -- remove context --- /
while creating UDF ---Input parvw,lifnr , select the queue option for User defined function
for (int i =0;i < parvw.length;i++){
if parvw(i).equals("WE") && lifnr(i).equals("xx"){
result.addValue("true");
}else
{
result.addValue("false");
}
}
Note the "true" and "false" are not equal to boolean values do not compare.
Regards
Chilla
reward points...
Message was edited by:
Chandra Sekhar Chilla
Gordon,
wirte UDF with input two strings 1.PARVW 2.LIFNR. use context or queue in UDF to pass all entries to UDF.
UDF.
for(int i=0; i<PARVW.length;i++)
{
if((PARVW(i).equals("WE")) and ((LIFNR(i).equals("XX")));
reusltlist.addValue("true");
else
reusltlist.addValue("false");
}
Message was edited by:
Sreeram Reddy
HI,
No need , i just modified my UDF see above ,Use WE not AG
Also given the correct graphic.
plz clarify the target node occur and its parent node occur
if parent of target node is more 0.. ubound or >0.. then map with the left side parent to right side parent or empty constant with right side parent.
Sure it will work
<b>---- use parvw - removecontext -- UDF -- split byvalue --target node
-
use lifnr -- remove context --- /</b>
Regards
Chilla
<i>reward points if it is helpful..</i>
HI,
Plz
map side parent node to targt parent node OR empty constant to taget node
no context change parvw -remove context- UDF-- splitbyvalue - taget node
no context change lifnr -- removecontext /
try with WE not AG.
<b>Please give graphic of your mapping and UDF code</b>
Regards
Chilla
Message was edited by:
Chandra Sekhar Chilla
what do you mean by "map side parent node to targt parent node OR empty constant to taget node" ?
grafikcode:
parvw -rmvcon-udf(param1) - splitbyvalue(each)-ORGID
lifnr-mapwdflt-rmvcon-udf(param2)
udf:
for(int i=0; i<parvw.length;i++){
if (parvw(i).equals("WE") && lifnr(i).equals("xx")){
result.addValue("true");
}else{
result.addValue("false");
}
}
but UDF has errors!
ERROR:
.java:1136: cannot resolve symbol symbol : method parvw (int) location: class com.sap.xi.tf.ORDERS05_2_ORDERS05_ if (parvw(i).equals("WE") && lifnr(i).equals("xx")){ ^
and the same with lifnr !
damn ... great Job guy´s. Its working now.
Here my final UDF... maybe someone needs this,too.
{
for(int i=0; i<parvw.length;i++)
{
if (parvw(i).equals("WE") && lifnr(i).equals("xx"))
{
result.addValue("true");
}
}
result.addValue("false");
}
points rewarded to both of you!
Gordon
Message was edited by:
Gordon Breuer
HI,
The same only i have given.use WE.
Regards
Chilla
<b>remember points rewarded if it is helpful..</b>
<b>SDN/BPX is a community that lives for and from its users. Which means when asking a question, you also assume the responsibility to assign the points. Its recommended that you assign 6 or 10 points once to the answer/person that helped you the most. Assign 2 points to everyone that contributed something
https://www.sdn.sap.com/irj/sdn/wiki?path=/display/home/rulesofEngagement</b>
Ok.. i got it.
try this one.
add if-then-else before checking equals condition of LIFNR
PARVW(context=E1EDKA1)
equals
Constant(WE)
and
<b>if</b> LIFNR -> <b>exists </b><b>then</b> LIFNR
<b>else</b> constat(blank)
equals
Constant(XX)
the and operator goes into the IF
Then is filled with constant (true)
Else is filled with constant (false)
& output goes to target field.
This shd work now
Thanks,
Maheshwari.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Gordon,
take LIFNR as input....... use mapwithdefault func.......in mapwithdefault, use default value as space(' ')......take its output and compare with "XX".....then you can use if then else........
Thanks,
Rajeev Gupta
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
we can solve this in the following ways
--parvw - change context to its parent node which is having 0..unbound / 0..999 more
and use your if else/if elsewithout -- splitbyvalue-- target node
OR
--parvw - (change context to its parent node which is having 0..unbound / 0..999 more or root) instead use removecontext --
and use your if else/if elsewithout -- splitbyvalue --target node
Second solution
use same as above , instead above ifelse/ifwithoutelse write UDF with queue option
but before UDF removecontext and after UDF use splitbyvalue..
<b>right side parent node which is having 0.. unbound or 0..more should be mapped with empty constant</b>
Please let me know the result..
Regards
Chilla..
Hi,
see below
parvw -- remove context -- UDF \ splitbyvalue -- target node
lifnr -- remove context -- above UDF /
For UDF --use input two string arrays : select queue option
implement you logic
for(int i =0;i < parvw.length;i++) {
write code here .. because i am not having full scope of your rquirement
}
regards
chilla.
Hi Gordon,
see both PARVW and LIFNR will have E1EDKA1 as context by default....so dont worry about context......
PARVW->Mapwithdefault->equalS(compare with WE)->
LIFNR ->Mapwithdefault->equalS(compare with XX) ->AND->Ifthenelse->creatif->Target Node above your constant target field
PARVW->Mapwithdefault->equalS(compare with WE)->
LIFNR ->Mapwithdefault->equalS(compare with XX) ->AND->Ifthenelse->splitbyvalue->Constant target field.
Thanks,
Rajeev Gupta
HI,
try the below UDF
-
use parvw - removecontext -- UDF -- split byvalue --target node
-
use lifnr -- remove context --- /
while creating UDF ---Input parvw,lifnr , select the queue option for User defined function
for (int i =0;i < parvw.length;i++){
if parvw<i>.equals("WE") && lifnr<i>.equals("xx"){
result.addValue("true");
}else
{
result.addValue("false");
}
}
Note the "true" and "false" are not equal to boolean values do not compare.
Regards
Chilla
<i>reward points...</i>
you need use and operator
IF E1EDKA1-PARVW = WE and operator E1EDKA1-LIFNR = "XX" then assign for true for IF part false assingto Else part
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi. Open your Message mapping and in the test tab give the necessary test values. Come back to design tab. Now right click on the if then else step and choose the option "display queue". This will show the input and output for the particular step.
You can debug with this tool easily
Regards,
Jai Shankar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.