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: 

internal table

Former Member
0 Kudos

SELECT * FROM mara UP TO 1 ROWS

INTO CORRESPONDING FIELDS OF TABLE itab

WHERE matnr IN s_matnr AND ersda IN s_date.

READ TABLE itab INDEX 1 .

IF sy-subrc EQ 0 .

SELECT SINGLE * FROM makt WHERE matnr EQ itab-matnr .

ENDIF .

select * from mast into table w_mast

for all entries in itab where matnr = itab-matnr.

loop at w_mast.

SELECT * FROM stpo APPENDING TABLE w_stpo

WHERE stlnr = w_mast-stlnr.

READ TABLE w_stpo index 1 .(I need help here , bcoz internal table has more than one content)so i cant use read

ENDLOOP.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

select under a loop statement in not a good idea regarding performance.

anyways you can do sumthing like:


data:
  count    type i,
  w_lines type i.
loop at w_mast.

SELECT * FROM stpo APPENDING TABLE w_stpo
WHERE stlnr = w_mast-stlnr.

describe table w_stpo lines w_lines.

do w_lines time.

READ TABLE w_stpo index count .
count = count + 1.
enddo.
ENDLOOP.

With luck,

Pritam.

4 REPLIES 4

Former Member
0 Kudos

Use a loop if you want to read the whole table

Former Member
0 Kudos

select under a loop statement in not a good idea regarding performance.

anyways you can do sumthing like:


data:
  count    type i,
  w_lines type i.
loop at w_mast.

SELECT * FROM stpo APPENDING TABLE w_stpo
WHERE stlnr = w_mast-stlnr.

describe table w_stpo lines w_lines.

do w_lines time.

READ TABLE w_stpo index count .
count = count + 1.
enddo.
ENDLOOP.

With luck,

Pritam.

former_member188685
Active Contributor
0 Kudos
if not w_mast is initial.
  SELECT * FROM stpo APPENDING TABLE w_stpo
 for all entries in w_mast
  WHERE stlnr = w_mast-stlnr.
endif.
 loop at w_mast.

loop at  w_stpo where matnr = w_mast-matnr.


ENDLOOP.

Endloop.

Former Member
0 Kudos

Hi,

Change the read table statment to,

Read table <internal table> into <workarea> index 1.

Read table is used to read the contents of itab inside a loop. The read table is used with binary search option and the itab1 should be sorted before using read table.

for more info:

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

Reading records with keys

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

Reading lines with Index

http://help.sap.com/saphelp_47x200/helpdata/en/fc/eb3730358411d1829f0000e829fbfe/content.htm

Regards,

Harish