‎2006 Mar 23 8:41 AM
Hello experts,
I am currently having trouble inserting my IF statement in the main window of a form. what I want to do is
IF mseg-bwart is NOT equal to '631' then it would do the code below. if it is EQUAL to 631, then it would not do the code below. I have tried using nested if but it always fails. Any help would be appreciated. Many thanks guys and take care!
/: IF &MKPF-TCODE2& NE 'MB01' AND &MKPF-TCODE2& NE 'MIGO_GR'
I1 ,,&MSEG-WEMPF&
/: ELSE
I1 ,,&MSEG-EBELN&
/: ENDIF
‎2006 Mar 23 8:54 AM
Hi Viray,
try using Case..
sorry for the previous one..
/: CASE &MSEG-BWART&
/: WHEN '631'.
/: WHEN OTHERS.
/ : IF &MKPF-TCODE2& NE 'MB01' AND &MKPF-TCODE2& NE 'MIGO_GR'I1 ,,&MSEG-WEMPF&
/: ELSE
I1 ,,&MSEG-EBELN&
/: ENDIF
/: ENDCASEregards
satesh
Message was edited by: Satesh R
Message was edited by: Satesh R
‎2006 Mar 23 8:45 AM
Hi,
please send the code where it is not working.
So that we can help u out in this regard.this code is not suffient.
Regards,
Sreevani
‎2006 Mar 23 8:50 AM
/: IF &MSEG-BWART& NE '631' AND &MKPF-TCODE2& NE 'MB01' AND &MKPF-TCODE2& NE 'MIGO_GR'
I1 ,,&MSEG-WEMPF&
/: ELSEIF &MSEG-BWART& NE '631'
I1 ,,&MSEG-EBELN&
/: ENDIF
‎2006 Mar 23 8:54 AM
1ST CHECK THAT IN DRIVER PROGRAM ALL THE VALUE OF MSEG TABLE IS FETCH...
IN DRIVER PROGRAM...
SEELCT * FROM MSEG WHERE CONDN.
/:IF &MSEG-BWART& = '631'
DO THIS
:ELSE
DO THIS
:ENDIF
Message was edited by: kishan negi
‎2006 Mar 23 8:54 AM
Hi Viray,
try using Case..
sorry for the previous one..
/: CASE &MSEG-BWART&
/: WHEN '631'.
/: WHEN OTHERS.
/ : IF &MKPF-TCODE2& NE 'MB01' AND &MKPF-TCODE2& NE 'MIGO_GR'I1 ,,&MSEG-WEMPF&
/: ELSE
I1 ,,&MSEG-EBELN&
/: ENDIF
/: ENDCASEregards
satesh
Message was edited by: Satesh R
Message was edited by: Satesh R
‎2006 Mar 23 8:59 AM
try doing this.
IF mseg-bwart is NOT equal to '631' then it would do the code below. if it is EQUAL to 631, then it would not do the code below
/: IF &mseg-bwart& NE 631 .
/: IF &MKPF-TCODE2& NE 'MB01' AND &MKPF-TCODE2& NE 'MIGO_GR'
I1 ,,&MSEG-WEMPF&
/: ELSE
I1 ,,&MSEG-EBELN&
/: ENDIF
/:ENDIF
What i want to say that sometime i had observe if you give the neagtive condition along with AND and all , it behaves very differently , i would advices you to break your IF with a single condition followed by other and try to see the results.
I think that will wrk.
Cheers
Sunny
Rewrd points, if found helpful
‎2006 Mar 23 9:06 AM
Hello Viraylab,
First and foremost is all the variables that u are using should be available in sapscript. If they are then u can us the following..
/: CASE &MSEG-BWART&
/: WHEN '631'.
/: IF &MKPF-TCODE2& NE 'MB01' AND &MKPF-TCODE2&
NE 'MIGO_GR'
I1 ,,&MSEG-WEMPF&
/: ELSE
I1 ,,&MSEG-EBELN&
/: ENDIF
/: WHEN OTHERS
/: ENDCASE
Try using debugger to find out exact reason if it is still skipping the code.
‎2006 Mar 23 9:12 AM
I don't think you can use nested IFs in SAPScript.
You may have to repeat some of the code and use a bigger IF statement to include all the conditions.
‎2006 Mar 23 10:59 AM
hi,
this is always a problem in scripts,
the best way is to set a flag inside the code.and use that flag here that is the best way.
regards,
Sasi
‎2006 Mar 23 11:01 AM
try to use this
/: IF &MSEG-BWART& NE '631' AND &MKPF-TCODE2& NE 'MB01' AND &MKPF-TCODE2& NE 'MIGO_GR'
I1 ,,&MSEG-WEMPF&/:
ELSE
I1 ,,&MSEG-EBELN&/: ENDIF
endif