cancel
Showing results for 
Search instead for 
Did you mean: 

How to write conditions in Script Text Elements

Former Member
0 Kudos

Hello,

Very Good Morning!

Script forms :

How can I write conditions in Text Elements.

For ex :

If Land1(Country) = German

tbl_ord-ean11 = vbap-pmatn.

Elseif Land1(Country) NE German

tbl_ord-ean11 = vbap-MATNR

....I mean...The label should not appear if the country is other than 'Germany'

in the script form.

How can I write this logic in the Text element....Any suggestions will be apprecaited.

Regards,

Kittu

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Hello everybody,

Thank you for your response!

The information provided was helpful!

Points Rewarded!

Regards,

Kittu

Former Member
0 Kudos

IF..ELSE..ENDIF can be used within the layout set to control the flow of logic. It is same as the corresponding ABAP command but with only one difference that no full stops are used here.

Example :

/: IF &VBRK-VKORG(2)& EQ u2018HGu2019

/: DEFINE &PREFIX& = u2018Mr.u2019

/: ELSE

/: DEFINE &PREFIX& = u2018Mrs.u2019

/: ENDIF

/ &PREFIX&

Conditional Text: IF

You can use the IF control command to specify that text lines should be printed only when certain conditions are met. If the logical expression contained within the IF command is true, then the text lines enclosed by the IF... ENDIF command pair are printed. Otherwise they are ignored.

Syntax:

/: IF condition

:

:

/: ENDIF

The logical expression can use the following comparison operators:

= EQ equal to

< LT less than

> GT greater than

<= LE less than or equal to

>= GE greater than or equal to

<> NE not equal to

The following logical operators can be used to combine conditions:

u2022 NOT

u2022 AND

u2022 OR

Evaluation of both the individual logical expressions and of the combinations of expressions is performed strictly from left to right. There are no precedence rules. Bracketed expressions are not supported.

The comparison is always performed on literal values, that is, the symbols are formatted as character strings before they are compared. This is particularly significant in the case of program symbols, because the formatting of these may depend on various parameters. For example, the formatted form of a currency field employs a variable number of decimal places and a variable u2018decimal pointu2019 symbol (a period or a comma) depending on the applicable currency key.

You can extend the IF command with the ELSE command to allow text lines to be specified that you want to print in case the condition is false. If the condition is true, the text lines enclosed by the IF and ELSE commands are formatted; otherwise the text lines enclosed by the ELSE and ENDIF commands are formatted.

Syntax:

/: IF condition

:

/: ELSE

:

/: ENDIF

The ELSEIF command allows you to specify multiple cases.

Syntax:

/: IF condition

:

/: ELSEIF condition

:

/: ELSE

:

/: ENDIF

You can use any number of ELSEIF commands within one compound IF.. ENDIF control command. The use of an ELSE command is then optional.

o You must not extend a condition over more than one line. Both the IF or ELSEIF command and the attached condition must be completely contained within a single line.

o You can nest IF commands.

o You must terminate an IF command with an ENDIF command. If you forget this, there will be no more output following the IF command if the condition is false.

o If a syntax error occurs in the interpretation of this command, then the command is not executed. This may have an unexpected effect on the subsequent text output. For example, if the IF statement is incorrect, then all following ELSEIF and ELSE commands will be ignored, since the opening IF command is u2018missingu2019. This will cause all the text lines attached to the ELSEIF and ELSE commands to be printed.

REWARD IF HELPFUL

Former Member
0 Kudos

Hi,

We can use the statement IF and ENDIF -

/: IF &NEXTPAGE& = 0

p1 define &lastpage& := 'X'

  • &'GRAND TOTAL :'W_TOTAL&

  • &'TOTAL : 'TOTAL&

/: ENDIF

We can use PERFORM and ENDPERFORM and make caluclations and pass this to the variable of script.

Remember that all the values are stored as char format ie NO integers floats etc are allowed.

before passing, assign it to char type variable and then condense the char variable then pass this to script variable.

The variable doesnt hold any value then the label should not be displayed then we do like this-

&'GRAND TOTAL :'W_TOTAL&

here we need to put the label insde the & and & symbols. then if this w_total is initial then the label is not displayed.

After Apostrophie(') dont keep any space.

if we keep

'GRAND TOTAL :' &W_TOTAL&

Here eventhough the w_total is intitial then

GRAND TOTAL label is displayed.

Ex-

If &Land1(Country) & = 'German'

define &tbl_ord-ean11& = &vbap-pmatn&.

Else.

&Land1(Country)& NE 'German'

define &tbl_ord-ean11& = &vbap-MATNR&

&'COUNTRY'land1&. -


here the label is not printed

ENDIF.

Reward if Helpful.

Regards

Chandralekha

Former Member
0 Kudos

Hi,

Good morning.

In script we can check conditions using IF and IF ELSE. But you cann't assign values or transfer value from one variable to other. If any that assignment is necessary do that using perform in scripts by writing code in program.

Hope this will help you.

Regards,

Aswini.

bpawanchand
Active Contributor
0 Kudos

HI

You can use the IF control command to specify that text lines should be printed only when certain conditions are met. If the logical expression contained within the IF command is true, then the text lines enclosed by the IF... ENDIF command pair are printed. Otherwise they are ignored.

Syntax:

/: IF condition

:

:

/: ENDIF

for e;x

/E <NAme of the text element>

/: IF condition

:

/: ELSEIF condition

:

/: ELSE

:

/: ENDIF

Regards

Pavan