cancel
Showing results for 
Search instead for 
Did you mean: 

Problem when using IF and ENDIF in SAPScript

Former Member
0 Kudos

Hi everyone,

I'm still new at using sapscript. I want to use IF....ENDIF but i confused how to use it in my sapscript. Here is the logic that i get from my functional designer :

IF t8jvb03-ceind = 'C' THEN

<E>JIBCL_N /* Element JIBCL_N */

&t8jvb11-jibcl& &t8jv11-cltext&

IF t8jvb11-jibsa <> '99999' THEN

<E>JIBSA_N

&t8jvb11-jibsa& &t8jvb11-satext&

ENDIF

<E>COBJT_E

&t8jvb11-cotype& &t8jvb11-cobject& &t8jvb11-fcmamt& &t8jvb11-fydamt& &t8jvb11-fidamt&

<E>JIBCL_E

Total: &t8jvb11-jibcl& &t8jvb11-cltext& &t8jvb11-fcmamt& &t8jvb11-fydamt& &t8jvb11-fidamt&

ELSEIF t8jvb03-ceind = 'O' THEN

IF t8jvb11-jibsa <> '99999' THEN

<E>JIBCL_N

&t8jvb11-jibcl& &t8jv11-cltext&

<E>JIBSA_N

&t8jvb11-jibsa& &t8jvb11-satext& &t8jvb11-fcmamt& &t8jvb11-fydamt& &t8jvb11-fidamt&

ENDIF

<E>JIBCL_E

Total : : &t8jvb11-jibcl& &t8jvb11-cltext& &t8jvb11-fcmamt& &t8jvb11-fydamt& &t8jvb11-fidamt&

ELSEIF t8jvb03-ceind = 'W' THEN

......

When i activate this logic, it's said that there is double element written(example JIBCL_N in IF t8jvb03-ceind = 'C' and in ELSEIF t8jvb03-ceind = 'O' THEN). Is this ok ? or is there any better way to do this ? For your information i copy the form from standard form ''JV_IN_EXP_JIB". Thank you.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi

have to use the commands before the lines as below

/: IF t8jvb03-ceind = 'C' THEN

/E JIBCL_N /* Element JIBCL_N */

/ &t8jvb11-jibcl& &t8jv11-cltext&

/: IF t8jvb11-jibsa <> '99999' THEN

/E JIBSA_N

/ &t8jvb11-jibsa& &t8jvb11-satext&

/: ENDIF

/E COBJT_E

/ &t8jvb11-cotype& &t8jvb11-cobject& &t8jvb11-fcmamt& &t8jvb11-fydamt&

= &t8jvb11-fidamt&

/E JIBCL_E

/ Total: &t8jvb11-jibcl& &t8jvb11-cltext& &t8jvb11-fcmamt& &t8jvb11-fydamt&

= &t8jvb11-fidamt&

/: ELSEIF t8jvb03-ceind = 'O' THEN

/: IF t8jvb11-jibsa <> '99999' THEN

/E JIBCL_N

/ &t8jvb11-jibcl& &t8jv11-cltext&

/E JIBSA_N

/ &t8jvb11-jibsa& &t8jvb11-satext& &t8jvb11-fcmamt& &t8jvb11-fydamt&

= &t8jvb11-fidamt&

/: ENDIF

/E JIBCL_E

/ Total : : &t8jvb11-jibcl& &t8jvb11-cltext& &t8jvb11-fcmamt& &t8jvb11-fydamt& = &t8jvb11-fidamt&

/: ELSEIF t8jvb03-ceind = 'W' THEN

Regards

Anji

Former Member
0 Kudos

Hi Anji,

It's ok to write same element more than one (example JIBCL_N) ? Because i have try this before i put question to forum and when i activate this form, i have information message that there is element that created more than one. Thank you.

Regards,

Satria

Former Member
0 Kudos

no need to put the elements in the conditioon block...

define only one element... and the data that you want to print put it in the conditional block...

so when you call your element SAPScript will print the data based on the current condition