‎2008 Jan 04 11:09 AM
Hi all
In the below code you can see am using two LOOP AT statements.So its taking a long time to execute how can i use only one loop condition and get my desired output.Please help.
Vijay
SELECT * FROM s023 INTO
CORRESPONDING FIELDS OF TABLE IT_s023 WHERE
WERKS = P_WERKS AND
SPTAG IN P_SPTAG .
SELECT * FROM S026 INTO CORRESPONDING FIELDS OF TABLE
IT_S026 WHERE WERKS = P_WERKS AND
SPTAG IN p_sptag .
LOOP AT IT_S026.
IT_REPORT-ENMNG = IT_S026-ENMNG .
IT_REPORT-SPTAG = IT_S026-SPTAG .
IT_REPORT-MATNR = IT_S026-MATNR .
ENDLOOP.
LOOP AT IT_S023.
ADD IT_s023-WEMNG TO Z.
IT_REPORT-WEMNG = IT_S023-WEMNG.
APPEND IT_REPORT.
ENDLOOP.
‎2008 Jan 04 11:19 AM
Hi Vijay
I guess inside the loop for s026 , you can read the table it_s023 with the primary keys.The only component i can see missing in the key would be DISPO ...i dont know how much this would afftect the read.
Thanks and Regards
Shivika
‎2008 Jan 04 11:38 AM
Hi vijay,
First u will declare an internal table.In that internal table we have place both the table fileds i.e so23,so26 fileds.
After that we have to inner join and then loop the data.I will send some sample data check it once ok..
data: begin of itab occurs 0,
so23 fileds,so23 fileds
end of itab.
parameters: p_werks like werks,
p_sptag like sptab.
select *
from sp03 as a
inner join sp06 as b
on awerks = bwerks
into corresponding fileds of table itab
where werks eq p_werks
and sptag eq p_aptag.
WE HAVE TO USE THE "ON" CONDITIONS LIKE THIS THERE MUST BE A COMMON FILED FOR BOTH TABLES THE COMMON FILED WE MENTION THERE OK..
loop at itab.
code
endloop.
Award points if helpful.
Kiran Kumar.G
Have a Nice Day..
‎2008 Jan 04 12:06 PM
Hi VIJAY,
Follow this one i hope it will work.. any syntax errors will come on read statement just change the statement according that.
SELECT * FROM s023 INTO
CORRESPONDING FIELDS OF TABLE IT_s023 WHERE
WERKS = P_WERKS AND
SPTAG IN P_SPTAG .
SELECT * FROM S026 INTO CORRESPONDING FIELDS OF TABLE
IT_S026 WHERE WERKS = P_WERKS AND
SPTAG IN p_sptag .
LOOP AT IT_S026.
IT_REPORT-ENMNG = IT_S026-ENMNG .
IT_REPORT-SPTAG = IT_S026-SPTAG .
IT_REPORT-MATNR = IT_S026-MATNR .
Read table IT_S023 WITH KEY WERKS = IT_S026-WERKS
AND SPTAG = IT_SO26-SPTAG
ADD IT_s023-WEMNG TO Z.
IT_REPORT-WEMNG = IT_S023-WEMNG.
APPEND IT_REPORT.
ENDLOOP.
‎2008 Jan 04 10:26 PM
AND wont be there in READ statement when you use WITH KEY statement.
Above abapers have provided very good information, please reward them and close the tag if you satisfy with their answers.
Regards,
Satya