Application Development and Automation 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: 
Read only

Query regarding if statement

Former Member
0 Likes
707

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
684

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

5 REPLIES 5
Read only

Former Member
0 Likes
684

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.

Read only

Former Member
0 Likes
684

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

Read only

0 Likes
684

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

Read only

Former Member
0 Likes
685

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

Read only

p604431
Active Participant
0 Likes
684

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.