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: 

SAP Script - problem accessing a variable from the program

Former Member
0 Kudos

Hello Friends,

I try to access a variable in SAP Script.

For ex.

IF &Y_VAR& EQ 'X'.

When the control goes here, during debuging, it simple omits the whole condition, including else part.

It's really a strange thing. Could any one suggest what is wrong here.

Senthil

7 REPLIES 7

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Is this variable define in the global section of the print program? Can you please post the code from the sapscript for the IF statement along with the format.

Regards,

Rich Heilman

0 Kudos

Hi,

The code is

IF &Y_FLAG& EQ 'X'.

INCLUDE '0510011256' OBJECT VBBK ID '0001'

ELSE.

INCLUDE ...

ENDIF.

This code is in the Address window, and when debugging Y_FLAG holds the value X, but it simple skips the process. Y_FLAG is declared globally in the program.

Thank for your time.

Senthil

0 Kudos

Hi,

Make sure that y_flag is of Char 1 (or) .

Try it as

IF &Y_FLAG& = 'X'

.

<i>Hope This Info Helps YOU.</i>

Regards,

Lakshmi

Former Member
0 Kudos

chk if u have declared Y_VAR within a subroutine..if yes, then declare it globally...

0 Kudos

As Bikash suggested might be variable not declared globally in the print program.

You do check(syntax check) at text element level.

Hope this helps.

Thanks and regards,

vamshi tallada

Former Member
0 Kudos

define the variable globally in the print program or

use CALL FUNCTION 'SET_TEXTSYMBOL'

EXPORTING

NAME = NAME

VALUE = VALUE.

if the variable is not globally defined.

For E.g

PERFORM SET_TEXTSYMBOL USING 'ITEM_FT' ITEM_FT

FORM SET_TEXTSYMBOL USING NAME VALUE.

CALL FUNCTION 'SET_TEXTSYMBOL'

EXPORTING

NAME = NAME

VALUE = VALUE.

ENDFORM. " SET_TEXTSYMBOL

and in the SAP Script use &ITEM_FT& variable.

Former Member
0 Kudos

This looks more like an activation issue even though you are seeing the code in debugging, you may be executing the older version of it. Activate all and then start your test from the begining.