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

regarding read statement

Former Member
0 Likes
759

any one please help me to write a read statement for the following requirement.....

for example in an internal table we are having 10 records if first record is blank we should read from second record and if first record is not blank we should read it from first record.....

Thanks in advance..........

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
738

Hi Do Like this :

READ TABLE ITAB INDEX 1 INTO workarea1 .

READ TABLE ITAB INDEX 2 INTO workarea2 .

IF NOT workarea1 IS INITIAL .

PROCESS workarea1 .

ELSE.

PROCESS workarea2 .

ENDIF .

Please inform if there is some other req .

Hope this Helps .

Praveen

6 REPLIES 6
Read only

former_member386202
Active Contributor
0 Likes
738

Hi,

No need to use read statement , loop on that internal table into work area

then check if work arear is initail or not.

Regards,

Prashant

Read only

Former Member
0 Likes
738


read table itab into watab index 1.
if watab is initial.
read table itab into watab index 2.
endif.

Read only

naimesh_patel
Active Contributor
0 Likes
738

You can do it with LOOP and CONTINUE combination

Loop at itab.
if itab-field1 is intial.
  continue.
else.
*  access data of itab.
exit.
endif.
endloop.

Regards,

Naimesh Patel

Read only

Former Member
0 Likes
738

loop at it into wa.

if wa is initial.

sy-index = s_index + 1.

read table it into wa sy-index s_index.

endif.

endloop.

Read only

Former Member
0 Likes
739

Hi Do Like this :

READ TABLE ITAB INDEX 1 INTO workarea1 .

READ TABLE ITAB INDEX 2 INTO workarea2 .

IF NOT workarea1 IS INITIAL .

PROCESS workarea1 .

ELSE.

PROCESS workarea2 .

ENDIF .

Please inform if there is some other req .

Hope this Helps .

Praveen

Read only

Former Member
0 Likes
738

U can loop at the internal table instead of using read statement......or still if u want to use read statement and want to consider first two records...then read by using index 1 and if it is blank then use index 2.

Regards,

Arun.