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: 

Problem with READ TABLE with INDEX and TRANSPORTING

manoj_goyal2
Participant
0 Kudos

Hi Guys,

I am using READ TABLE statemen to read internal table li_spfli.

READ TABLE li_spfli INDEX 2 TRANSPORTING carrid

write li_spfli-carrid.

The above READ statement does not return the CARRID of row 2 and it is returning the CARRID of last row.

But if i use below statment.

READ TABLE li_spfli INDEX 2.

if sy-subrc eq 0.

write: li_spfli-carrid.

endif

I want to use transporting to improve the performance. Kindly suggest what to do.

Thanks,

mini

3 REPLIES 3

Former Member
0 Kudos

Hi,

Try this,

DATA: sflight_tab TYPE SORTED TABLE OF sflight

WITH UNIQUE KEY carrid connid fldate,

sflight_wa LIKE LINE OF sflight_tab.

DATA subrc TYPE sy-subrc.

SELECT *

FROM sflight

INTO TABLE sflight_tab

WHERE carrid = 'LH'.

subrc = sy-subrc.

WHILE subrc = 0.

sflight_wa-seatsocc = 0.

READ TABLE sflight_tab

INDEX sy-index

INTO sflight_wa COMPARING seatsocc

TRANSPORTING carrid

connid

fldate

seatsocc.

CASE sy-subrc.

WHEN 0.

WRITE: / sflight_wa-carrid, sflight_wa-connid,

sflight_wa-fldate, sflight_wa-seatsocc COLOR = 6.

subrc = sy-subrc.

WHEN 2.

WRITE: / sflight_wa-carrid, sflight_wa-connid,

sflight_wa-fldate, sflight_wa-seatsocc COLOR = 5.

subrc = 0.

WHEN 4 OR 8.

EXIT.

ENDCASE.

ENDWHILE.

Pls Check the following SAP Help link,

http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb35f8358411d1829f0000e829fbfe/content.htm

Regards,

Ruthra

0 Kudos

The statement READ TABLE is used to extract one record only and put it in a Work Area or in the header of the internal table (I believe this is your case).

Use LOOP statement instead.

LOOP at li_spfli.
  write:
     li_spfli-carrid.
ENDLOOP.

Regards.

Former Member
0 Kudos

Hi

I do not find any problem with that statment. However as you mention, you are not getting the desired result, if you want more optimized solution, you can use

field-symbols: <fs> type any.

READ TABLE li_spfli INDEX 2 assigning <fs>.

write <fs>-carrid.

If you want to change any field value, you can just give <fs>-field_name = value.

This will modify the content in the internal table. You dont have to give modify statement.

Regards

Navneet