‎2007 Jul 10 2:01 PM
when i am executing this code, it takes a lot of time. even though i hav checked temp[] whether it is initial. But do i need to check ltap[] because the data has been collected from temp to ltap.Also temp has data and since no record matches the for all entries fetches all the data from ltak.
IF NOT lt_temp[] IS INITIAL.
LOOP AT lt_temp INTO ls_temp.
COLLECT ls_temp INTO lt_ltap.
ENDLOOP.
FREE lt_temp.
SELECT lgnum "Warehouse Number
tanum "Transfer order number
FROM ltak
INTO TABLE lt_ltak1
FOR ALL ENTRIES IN lt_ltap
WHERE lgnum EQ lt_ltap-lgnum
AND tanum EQ lt_ltap-tanum
AND trart EQ 'A'
OR trart EQ 'X'.
‎2007 Jul 10 2:17 PM
After the FREE statement, try:
SORT lt_ltap by lgnum tanum.
DELETE ADJACENT DUPLICATES FROM lt_ltap comparing lgnum tanum.
Then do the SELECT.
Rob
‎2007 Jul 10 2:17 PM
After the FREE statement, try:
SORT lt_ltap by lgnum tanum.
DELETE ADJACENT DUPLICATES FROM lt_ltap comparing lgnum tanum.
Then do the SELECT.
Rob
‎2007 Jul 10 2:30 PM
it has been sorted afterwards.
do i need to check table ltap for initial since the select query doesnt match any condition and all the data from table ltak is being extracted which is taking a lot of time
‎2007 Jul 10 2:34 PM
You need to sort it before.
If there is data in the original table, there will be data in the final table.
Rob
‎2007 Jul 10 2:49 PM
but isnt it a rule that when u do for all entries for any table, that table has to be checked whether it is initial or not.
‎2007 Jul 10 3:08 PM
You have to know that there is data in the table. You checked the original table, so when you move data into the work table, there must be data there as well.
Rob
‎2007 Jul 10 3:20 PM
Hi,
From the look of your code it seems that your internal table is being built from LTAP (Transfer Order Item) , and then you are reading LTAK (TO Header), could you do a JOIN between LTAP and LTAK?
‎2007 Jul 11 11:08 AM
don'tdo like looping , collocting , free ..etc .
just write 2 select queries using FOR ALL ENTRIES it will take care of it see. i am using the sy-subrc .
*Select FOR ALL ENTRIES command
SELECT bukrs belnr gjahr bldat monat budat xblnr awtyp awkey
UP TO 100 ROWS
FROM bkpf
INTO TABLE it_bkpf.<b>IF sy-subrc EQ 0.</b>
* The FOR ALL ENTRIES comand only retrieves data which matches
* entries within a particular internal table.
SELECT bukrs belnr gjahr buzei mwskz umsks prctr hkont xauto koart
dmbtr mwart hwbas aufnr projk shkzg kokrs
FROM bseg
INTO TABLE it_bseg
FOR ALL ENTRIES IN it_bkpf
WHERE bukrs EQ it_bkpf-bukrs AND
belnr EQ it_bkpf-belnr AND
gjahr EQ it_bkpf-gjahr.<b>ENDIF.</b>
reward points if it is usefull ...
Girish
‎2007 Jul 12 3:55 PM
Besides all other points already mentioned here: Please keep in mind that the "FOR ALL ENTRIES IN" statement translates to the database as:
WHERE TANUM = '111123454566' OR
TANUM = '111123454567' OR
TANUM = '111123454568' OR
.....
This makes only sense if your internal table lt_ltap contains just a handful of records. You can even get a runtime error as the length of the SQL statement created is limited (depending on the DB)
Of course I don't know what your program is supposed to do, but it might be smarter to check only against LGNUM (which are most likely just a few records) and do the checking for the TANUM in memory.
Regards
Frank
‎2007 Jul 13 8:50 PM
Frank - I think this is is a problem for RANGES, not FOR ALL ENTRIES (at least in a DB2 or Oracle environment). I created a table with 500K entries and used it with FOR ALL ENTRIES and it didn't dump. I think the SAP kernel is better at translating FOR ALL ENTRIES for the database than it is for RANGES.
Rob
‎2007 Jul 16 9:52 AM
Hi Rob,
that's quite amazing. I once created an itab with just 8K entries and the FOR ALL ENTRIES statement dumped on me - and this was a DB2 on a z390.
Is the max length of an SQL statement a system setting ?
Regards
Frank
‎2007 Jul 30 3:37 PM
‎2007 Jul 16 1:16 PM
As this is a code sample, make sure that your ENDIF is after the select.
We have all assumed that the problem is with the select, BUT the problem may be with the COLLECT. Have the definition of the LT_LTAP table consist only of the fields lgnum, tanum and an interger field. This way you eliminate your duplicates, quickly.
MattG.
‎2007 Jul 17 9:06 AM
Hi,
Here collect statements takes very much time. So remove this and use any other technique to get your desired result instead of collect.
Reward points if useful,
Aleem.
‎2007 Jul 31 9:47 AM
First of all, please use the <b>Code</b> button when you paste code. It makes it much easier to read.
I think your problem is in your select statement.
SELECT lgnum "Warehouse Number
tanum "Transfer order number
FROM ltak
INTO TABLE lt_ltak1
FOR ALL ENTRIES IN lt_ltap
WHERE lgnum EQ lt_ltap-lgnum
AND tanum EQ lt_ltap-tanum
AND trart EQ 'A'
OR trart EQ 'X'.Should be changed to
SELECT lgnum "Warehouse Number
tanum "Transfer order number
FROM ltak
INTO TABLE lt_ltak1
FOR ALL ENTRIES IN lt_ltap
WHERE lgnum EQ lt_ltap-lgnum AND
tanum EQ lt_ltap-tanum AND
( trart EQ 'A'
OR trart EQ 'X' ).I always write ANDs at the right side and ORs at the left side of WHERE clauses to remind me that ORs start a new clause, while ANDs are a continuation of an existing clause - adding additional constraints.
Message was edited by Kjetil Kilhavn:
But then again, I could of course be wrong. Perhaps you intend to select all entries where TRART = 'X' irrespective of the LGNUM and TANUM values. I don't think so, but if you do this on purpose you must expect poor performance since TRART is not an indexed field.