2007 Oct 10 6:32 PM
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 .
2007 Oct 10 6:39 PM
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
2007 Oct 10 7:52 PM
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
2007 Oct 10 11:07 PM
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
2007 Oct 11 6:23 AM
declaration of flag is wrong.
DATA: FLAG TYPE C.
This will work out..Please reward
Regards
2007 Oct 11 12:30 PM
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