05-24-2006 11:00 AM
Hi Guys,
I am using IF statements in my sapscript , but am getting an error -- "AND, OR or end of condition expected" . I have pasted my code below. Any suggestions in this regard would be helpful.
/: IF ( &BSEG-BELNR& EQ &BKPF-BELNR& )
/: IF ( &BSEG-KOART& = 'D' )
/: IF ( &BKPF-BLART& = 'KR' )
M3 ,,&BKPF-BELNR&,,&BKPF-XBLNR&,,&BKPF-BLDAT&,,&BSEG-SGTXT(25)&
= ,,&BSEG-DMBTR&,,&BKPF-HWAER&
/: IF STRLEN(&BSEG-SGTXT&) GT 25
M3 ,,,,,,,,&BSEG-SGTXT+25&
/: ENDIF
/: PERFORM CAL_TOTAL IN PROGRAM ZFR_PYTADV1
/: USING &BSEG-DMBTR&
/: CHANGING &W_TOTAL&
/: ENDPERFORM
/: ELSEIF ( &BKPF-BLART& = 'RE' )
M3 ,,&BKPF-BELNR&,,&BKPF-XBLNR&,,&BKPF-BLDAT&,,&BSEG-SGTXT(25)&
= ,,&BSEG-DMBTR&,,&BKPF-HWAER&
/: IF STRLEN( &BSEG-SGTXT& ) GT 25
M3 ,,,,,,,,&BSEG-SGTXT+25&
/: ENDIF
/: PERFORM CAL_TOTAL IN PROGRAM ZFR_PYTADV1
/: USING &BSEG-DMBTR&
/: CHANGING &W_TOTAL&
/: ENDPERFORM
/: ENDIF
/: ENDIF
/: ENDIF
regards
Nishant
05-24-2006 11:02 AM
hi nishant,
u have to write
/: IF ( &BSEG-BELNR& EQ &BKPF-BELNR& )
or ( &BSEG-KOART& = 'D' )
or ( &BKPF-BLART& = 'KR' ).
-
-
/: endif.
hope this helps,
priya.
05-24-2006 11:02 AM
hi nishant,
u have to write
/: IF ( &BSEG-BELNR& EQ &BKPF-BELNR& )
or ( &BSEG-KOART& = 'D' )
or ( &BKPF-BLART& = 'KR' ).
-
-
/: endif.
hope this helps,
priya.
05-24-2006 11:06 AM
Hi Priya,
I want both the first and second IF statements to be fulfilled before control goes on to 3rd IF statement.
I tried using AND statements i:e:
IF ( &BSEG-BELNR& EQ &BKPF-BELNR& ) AND
( &BSEG-KOART& = 'D' )
But its not working...
Regards
Nishant
05-24-2006 11:26 AM
Hi Nishant,
it is because of <b>Brackets</b> it is giving that error.you should have to write the separate code inorder to avoid the Brackets.
i did it at my end.
it is not giving any errors..
/: IF A = 10 .
/: IF A = 'D' .
/: IF A = 'KR' .
/:
/: IF A GT 25.
/: ENDIF
/: ELSEIF A = 2
/: IF A GT 25.
/: ENDIF.
/: ENDIF.
/: ENDIF.
/: ENDIF
Regards
vijay
05-24-2006 11:27 AM
hi nishant,
try
/: IF ( &BSEG-BELNR& EQ &BKPF-BELNR& )
and ( &BSEG-KOART& = 'D' )
and ( &BKPF-BLART& = 'KR' )
M3 ,,&BKPF-BELNR&,,&BKPF-XBLNR&,,&BKPF-BLDAT&,,&BSEG-SGTXT(25)&
= ,,&BSEG-DMBTR&,,&BKPF-HWAER&
/: ENDIF.
/: IF STRLEN(&BSEG-SGTXT&) GT 25
M3 ,,,,,,,,&BSEG-SGTXT+25&
/: ENDIF
HOPE THIS HELPS,
PRIYA.
05-24-2006 11:33 AM
Thanks Vijay and Hymavathi,
removing braces solved my problem.
regards
Nishant
Ps: i have awarded points to helpful ansers.
05-24-2006 11:04 AM
HI NIshant,
I thinkk you are missing a period at the end of each if statement. Try putting a '.' at the end of each statement.
Regards,
Ravi
05-24-2006 11:05 AM
Period Missing at the end of If Statement and in most of the places of your code. Remove <b>BRACES</b>
05-24-2006 11:17 AM
Hi Santosh,
I tried placing periods at the end of IF statements. I dont think periods are required in Sapscripts.
Regards
Nishant
05-24-2006 11:06 AM
Hi ,
Use <b>OR</b> condition in between ur if statements...
It may help u..
Cheers,
Simha.
05-24-2006 11:20 AM
try changing this statement with paranthesis:
/: IF ( STRLEN( &BSEG-SGTXT& ) GT 25 )
By the way, are you sure you can use the strlen function in sap script directly?
Instead caluculate the strlen in the driver program itself and use that variable in the script.
Regards,
Ravi
05-24-2006 11:22 AM
periods are not required in scripts
as u r not using and or OR and they are separate if stetements,
just remove the braces ( ) in every expression and try
05-24-2006 11:36 AM
hi
how about calling perform in ur script
and put all ur conditions there itself..
thanksss........
05-24-2006 12:05 PM
Hi Nishant,
u cannot use simultaneous IF conditions in sapscritp...u need to use AND ...dunno y ur command using AND is not working..just try out a few things like debugging the script n checking the values that these variables are getting at runtime so that u get to know wat exactly the problem is..
Regards
Bikash