‎2006 Jun 13 12:15 AM
Hi people,
I don't have more choice to take out the selects from this loop. Now the question is if I insert the data of a select in a internal table when the loop is running like this:
LOOP AT t_regup INTO wa_regup .
SELECT usnam cpudt belnr stblg
FROM bkpf INTO CORRESPONDING FIELDS OF table t_bkpf1
WHERE belnr = wa_regup-belnr
AND bukrs = wa_regup-bukrs.
SELECT znme1 lifnr laufd laufi zbukr hbkid
waers zaldt
hktid vblnr chect zland rzawe uzawe voidr
FROM payr INTO CORRESPONDING FIELDS OF table t_payr1
WHERE hbkid = wa_regup-hbkid
AND hktid = wa_regup-hktid
AND zbukr = wa_regup-zbukr
AND voidr = ''.
the lines are inserted line by line, so I don't need to use an append?, because I try to not use the 'ENDSELECT.' statement.
Thanks for the help.
‎2006 Jun 13 12:21 AM
Replace INTO with APPENDING in both the SELECT Statements. Otherwise, the itabs might be overwritten with each loop pass.
Regards,
Suresh Datti
‎2006 Jun 13 12:23 AM
hi structure ur SELECT as follows for better performance..
IF NOT t_regup IS INITIAL.
SELECT usnam cpudt belnr stblg FROM bkpf INTO CORRESPONDING FIELDS OF table t_bkpf1
FOR ALL ENTRIES IN t_regup
WHERE belnr = t_regup -belnr AND
bukrs = t_regup -bukrs.
ENDIF.
IF NOT t_regup IS INITIAL.
SELECT znme1 lifnr laufd laufi zbukr hbkid waers zaldt hktid vblnr chect zland rzawe uzawe voidr FROM payr INTO CORRESPONDING FIELDS OF table t_payr1
FOR ALL ENTRIES IN t_regup
WHERE hbkid = t_regup -hbkid AND
hktid = t_regup -hktid AND
zbukr = t_regup -zbukr AND voidr = ''.
ENDIF.
Cheers,
Abdul Hakim
‎2006 Jun 13 12:24 AM
Carlos,
There is no need to use an APPEND in your case. As you are populating an internal table in your select.
SELECT....ENDSELECT is like a loop and you have to use APPEND to add record to an internal table.
Hope this is what you have asked.
Thanks,
‎2006 Jun 13 12:24 AM
So, if I replace the into by the append I don't need to use ENDSELECT statement right?
‎2006 Jun 13 12:25 AM
‎2006 Jun 13 12:25 AM
Yes...if you replace into with appending there is no need to use endselect.
Thanks,
‎2006 Jun 13 12:27 AM
hi
you could use my above logic to fetch the data from the tables in one shot and keep it in two internal tables and later you can loop thru the two tables based on the key fields and append it to the final table.this will improve ur performance a lot.if you place SELECT query in between LOOP and ENDLOOP it will affect your performance.
Plz check the performance tuning of ABAP programs under the knowledge pool portal http://help.sap.com
Cheers,
Abdul Hakim
‎2006 Jun 13 4:17 AM
Before you make any changes, we should know your requirements. The code snippet you have shwon us will overwrite your internal table for each loop pass. That may be what you want if you are processing each line of t_regup individually; however, if you want to get all of your data up front and process it outside of the loop, then you need to do the FOR ALL ENTRIES as suggested by Abdul.
Rob
Message was edited by: Rob Burbank