Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

IF CONDITION IN SMARTFORM.

Former Member
0 Kudos

Hello all,

Just facing a small problem in smart form.

The code goes as follows ::

PLANT: &GRLABEL-WERKS&

/* Codes works fine. Displayed correctly.

/: IF &GRLABEL-WERKS& = '01'

  • Inside IF

/: ELSE

  • Outside IF

/: Endif

The problem is in if condition. Its going in else part even if first condition is satisfied.

Is ht ere any problem in hte code or anything?? I am not getting a way out.

Please help me.

10 REPLIES 10

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Just a guess here, is GRLABEL-WERKS supposed to be 4 characters. Try changing the following line of code.



/: IF &GRLABEL-WERKS& = '0001'

Regards,

Rich Heilman

0 Kudos

Yes it is 4 characters but ht eproblem still persists.

0 Kudos

Are you saying that it goes into both ends of the IF statement? What I mean is, it executes code on both sides of the ELSE? Is this correct?

Regards,

Rich Heilman

0 Kudos

see like if grlabel is "6001" (assume)

it should print Inside If else it should print Outside IF.

But wat is happening in my case is it is printing both .

Inside IF and

Outside If.

hopw this clarifies hte picture.

0 Kudos

Please post your complete code, anything that has to do with this IF statement and the fields that it prints.

Regards,

Rich Heilman

0 Kudos

/:PROTECT

  • WBS ELEMENT: &W_GRLABEL-PS_PSP_PNR&

  • PLANT: &W_GRLABEL-WERKS& //

/: IF &W_GRLABEL-WERKS& = '6001'

  • INSIDE IF

/: ELSE

  • OUTSIDE IF

/: ENDIF

/: ENDPROTECT

THE Code goes as above.

All the values are populated properly and are checked.

The values are passed from the ABAP Code to smartform using a structure.

All is fine but the IF is not working.

It should either execute "If or else" but in my case its executing both.

If one condition is satisfied, it should not go in the else part but its going.

0 Kudos

Hi Sachin,

1) Try debugging the script part and see if the logical condition is TRUE or not.

2) Try with a different IF statement like this:

/: IF &W_GRLABEL-WERKS& > 0.

  • Greater than Zero

/: ELSEIF &W_GRLABEL-WERKS& = 0.

  • Equal to Zero

/: ENDIF.

Note:- This is to just check whether the IF flow is correct. Once you can do this correctly, then the modification of the same is easy.

Cheers,

Sam.

Former Member
0 Kudos

have u debugged the code?

Former Member
0 Kudos

Hi,

You can use Alternate node to put in your IF condition.

There you can put condition GRLABEL-WERKS = '01' and use true and false node to take care of your if and Else text.

Regards,

Gagan

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

If you want to write the output based on if condition,then you can use condition in text element.

Otherwise,if you want to do some manipulations in code based on the value,then you can do as follows

Declare a variable(say V) in Global definition-Global data.

v type grlabel-werks.

Create a program line and store the value in a variable.

Declare v as output parameter and grlabel as input parameter.

Inside the program line,write your code as

v = grlabel-werks.

Then if you want to manipulate something,write your coding in that program line as below.

if v = '01'

..manipulations

else.

...

endif.