‎2009 Dec 08 4:20 AM
Hi,
The scenario is, I have some 5 to 6 values in my internal table itab.
now in, if statement, i wanted to check whether any of these values are present. if present then I have to proceed.
if status_old ... <itab-value>.
if sy-subrc = 0.
contiune.
endif.
endif.
is it possible to check dynamically using if statement.
regards,
Mani
‎2009 Dec 08 4:38 AM
Hi;
you should mention what want to check whether data row wise or column wise.
If its row wise then you wrote is correct.
If its column wise then you can achieve it by using field symbol like
ASSIGN us_file_input TO <lfs_input>. ASSIGN gs_header TO <lfs_record>.
*---Find the Value of 1st row only
DO 16 TIMES.
ASSIGN COMPONENT lv_cnt OF STRUCTURE <lfs_input> TO <lfs_field>.
IF sy-subrc EQ 0 AND NOT
<lfs_field> IS INITIAL.
IF lv_cnt LT 5.
ASSIGN COMPONENT lv_cnt OF STRUCTURE <lfs_record> TO <lfs_hfield>.
IF sy-subrc EQ 0 AND
<lfs_field> NE <lfs_hfield>.
For the rest, there is good example in sap online help by presssing F1 on the key work ASSIGN COMPONENT.
Regards
Shashi
‎2009 Dec 08 4:24 AM
You Should press F1 on IF and try to understand its use.
There is no need of sy-subrc check.
Use SAP Help to solve these types of issues.
‎2009 Dec 08 4:31 AM
Hi,
According to your scenario you need to pick one value from 5 to 6 values of internal table.
No need to use if statement.
Try this
Loop at itab where field = value.
Do you processing here.
endloop.
Regards
Shriraam
‎2009 Dec 08 4:40 AM
Hi,
You can also use READ statement to check for a particular value...
Eg:
Read table <itab> into <wa> where variable = <value>.
If sy-subrc = 0.
Your Processing
Endif.
--
Prateek
‎2009 Dec 08 4:38 AM
Hi;
you should mention what want to check whether data row wise or column wise.
If its row wise then you wrote is correct.
If its column wise then you can achieve it by using field symbol like
ASSIGN us_file_input TO <lfs_input>. ASSIGN gs_header TO <lfs_record>.
*---Find the Value of 1st row only
DO 16 TIMES.
ASSIGN COMPONENT lv_cnt OF STRUCTURE <lfs_input> TO <lfs_field>.
IF sy-subrc EQ 0 AND NOT
<lfs_field> IS INITIAL.
IF lv_cnt LT 5.
ASSIGN COMPONENT lv_cnt OF STRUCTURE <lfs_record> TO <lfs_hfield>.
IF sy-subrc EQ 0 AND
<lfs_field> NE <lfs_hfield>.
For the rest, there is good example in sap online help by presssing F1 on the key work ASSIGN COMPONENT.
Regards
Shashi
‎2009 Dec 08 4:40 AM
Hi,
try like this . for example
loop at it_final into wa_final.
if ( wa_final-bwart eq '303' or wa_final-bwart eq '313' ).
if sy-subrc = 0.
contiune.
endif.
endif.
endloop.