08-05-2008 2:58 PM
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.
08-05-2008 3:04 PM
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.
08-05-2008 3:03 PM
08-05-2008 3:04 PM
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.
08-05-2008 3:08 PM
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.
08-05-2008 3:11 PM
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