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: 

Reports

Former Member
0 Kudos

This is lalitha .

1. I jhave got run time error in my pro n not able to solve it .

This is the select statement .

IF T_HOLD-CMGST = 'B' OR

T_HOLD-CMGST = 'C' .

T_HOLD-CMGST = 'YES' .

FLAG = 'X' .

ENDIF .

I HAVE DEFINED FLAG AS

DATA: FLAG TYPE F .

''FLAG = 'X' .is an error .flag is defined in float ,but the value is given in 'x' .

I dont know how to give the value for flag .

2 . Please explain me what is a flag?

3. why do define it in a program .

With regards.

lalitha .

5 REPLIES 5

rodrigo_paisante3
Active Contributor
0 Kudos

Hi,

if you want to mark something, ry to use TYPE C.

DATA flag TYPE C.

It will works.

Flag is a point to verify, you mark that point and then check with an if.

Regards

Former Member
0 Kudos

A flag is basically a yes/no indicator. When you give it the value 'X', it means "yes". When the value is blank, it means "no". It needs to be defined as type C (for character). Type F is for floating point numbers. Or you can simply define it like this:

DATA flag(1).

This will create a 1-character field. I hope this helps.

- April King

Former Member
0 Kudos

To expand a little on April's explanation, a "flag" is an indicator as to the state of something - it will depend on your local requirement as to how it is used. For example, in answer to your question, you could code a test as follows:

data:
  l_flag        type f.  "float

case sy-uname.
  when 'BATCH'  "if current user is batch...
    or 'BATCHJOB'. "or batchjob   
    l_flag = 1.
  when 'FRED'.
    l_flag = 2.
endif.
....
if l_flag is initial.  "not set to anything
  message i398(00) with 'Unauthorised access' space space space.
endif.

For "boolean" tests, then the more common approach is to have a char 1 field (like sap_bool for example) that you have a value of "X" or space in, for example:

data:
  l_flag        type sap_bool.  "char 1
case sy-uname.
  when 'BATCH'  "if current user is batch...
    or 'BATCHJOB'. "or batchjob   
    l_flag = 'X'
  when 'FRED'.
    l_flag = 'X'.
endif.
....
if l_flag is initial.  "not set to anything
  message i398(00) with 'Unauthorised access' space space space.
endif.

Jonathan

Former Member
0 Kudos

declaration of flag is wrong.

DATA: FLAG TYPE C.

This will work out..Please reward

Regards

former_member235056
Active Contributor
0 Kudos

Dear friend,

Do this,

DATA: FLAG TYPE C.

IF T_HOLD-CMGST = 'B' OR

T_HOLD-CMGST = 'C' .

T_HOLD-CMGST = 'YES' .

FLAG = 'X' .

ENDIF .

Regards,

Ameet