‎2009 Dec 21 5:42 AM
hello all,
i am writting this code .....first select is working fine for me as i am getting 5 entires in table itab which i am expecting...
but for second when i loop itab itab then at that time i should get one record in table itab2 out of second select query........
but as i can see while debugging i am getting that entry at third time when i am in loop.....but it again i think it overwrites with next enter and making itab2 entry as 0 at the end.....
what might be problem.
even i write append itab2.
clear itab2.
same error i am getting...(here CDPOS is cluster table..is this because of this??)..pease help
selection-screen:begin of block test with frame title new.
select-options: s_ddate for vbak-vdatu.
selection-screen:end of block test.
select avbeln avdatu bnetpr bnetwr b~matnr into corresponding fields of table itab
from vbak as a inner join vbap as b on avbeln = bvbeln where
b~matnr = 'AUP-501'
and a~vdatu in s_ddate.
LOOP AT ITAB.
select * from CDPOS into table itab2 where
OBJECTID = ITAB-VBELN AND
TABNAME = 'VBAP' AND
FNAME = 'NETPR'.
ENDLOOP.
‎2009 Dec 21 5:49 AM
Hi,
You are completely into wrong performance..
as per your query
selection-screen:begin of block test with frame title new.
select-options: s_ddate for vbak-vdatu.
selection-screen:end of block test.
select avbeln avdatu bnetpr bnetwr b~matnr into corresponding fields of table itab
from vbak as a inner join vbap as b on avbeln = bvbeln where
b~matnr = 'AUP-501'
and a~vdatu in s_ddate.
LOOP AT ITAB.
select * from CDPOS into table itab2 where
OBJECTID = ITAB-VBELN AND
TABNAME = 'VBAP' AND
FNAME = 'NETPR'.
ENDLOOP.
The second query is inside loop and its moving data into itab2 for every record in internnale table ITAB and
finally itab2 contains the last records of ITAB data if CDPOs has the data for itab-vbeln(last records).
To over come you need to write the select as beloew
select * from CDPOS APPENDING table itab2 where
OBJECTID = ITAB-VBELN AND
TABNAME = 'VBAP' AND
FNAME = 'NETPR'.
But I suggest you to write for all entries
select <the filed you need> from CDPOS
into table itab2
for all entries in itab
where OBJECTID = ITAB-VBELN AND
TABNAME = 'VBAP' AND FNAME = 'NETPR'.
Then
loop at ITAB.
Read table itab2 with key vbeln = itab-vbeln binary search.
If sy-subrc = 0.
<Write your code, functions etc>.
endif.
endloop.
regards,
Nazeer
‎2009 Dec 21 5:49 AM
Hi,
You are completely into wrong performance..
as per your query
selection-screen:begin of block test with frame title new.
select-options: s_ddate for vbak-vdatu.
selection-screen:end of block test.
select avbeln avdatu bnetpr bnetwr b~matnr into corresponding fields of table itab
from vbak as a inner join vbap as b on avbeln = bvbeln where
b~matnr = 'AUP-501'
and a~vdatu in s_ddate.
LOOP AT ITAB.
select * from CDPOS into table itab2 where
OBJECTID = ITAB-VBELN AND
TABNAME = 'VBAP' AND
FNAME = 'NETPR'.
ENDLOOP.
The second query is inside loop and its moving data into itab2 for every record in internnale table ITAB and
finally itab2 contains the last records of ITAB data if CDPOs has the data for itab-vbeln(last records).
To over come you need to write the select as beloew
select * from CDPOS APPENDING table itab2 where
OBJECTID = ITAB-VBELN AND
TABNAME = 'VBAP' AND
FNAME = 'NETPR'.
But I suggest you to write for all entries
select <the filed you need> from CDPOS
into table itab2
for all entries in itab
where OBJECTID = ITAB-VBELN AND
TABNAME = 'VBAP' AND FNAME = 'NETPR'.
Then
loop at ITAB.
Read table itab2 with key vbeln = itab-vbeln binary search.
If sy-subrc = 0.
<Write your code, functions etc>.
endif.
endloop.
regards,
Nazeer
‎2009 Dec 21 5:50 AM
Hello
Try this:
LOOP AT ITAB.
select * from CDPOS APPENDING table itab2 where " <- add APPENDING
OBJECTID = ITAB-VBELN AND
TABNAME = 'VBAP' AND
FNAME = 'NETPR'.
ENDLOOP.
‎2009 Dec 21 5:51 AM
Hi
Just do like this
select * from cdpos into table itab2 for all entries in itab
where objectid = itab-vbeln and
tabname = 'VBAP' and
fname = 'NETPR'.
Regards,
Ramesh.
‎2009 Dec 21 5:53 AM
‎2009 Dec 21 5:53 AM
hi,
instead of using the select statement inside the loop,try to use the select statement using FOR ALL ENTRIES in ITAB1.
Data type of the fields in the where condition needs to be same as that of CDPOS table variable.