‎2008 Jul 30 6:54 AM
Hello Friends,
I am Debugging one report and I want to know the meaning of following Query, That what this querri is doing and what result will come, Please guide me as soon as possible.........
SELECT abudat bmatnr bwerks cmtart SUM( b~menge ) AS xmenge
INTO (budat, matnr, werks, mtart, menge)
FROM ( ( mkpf AS a INNER JOIN mseg AS b ON amblnr = bmblnr )
INNER JOIN mara AS c ON bmatnr = cmatnr )
WHERE a~budat IN p_budat
AND b~bwart = '101'
AND ( blgort = 'FGSL' )"OR blgort = 'JWSL' OR b~lgort = 'SCRL' )
AND a~mjahr = mjahr
GROUP BY abudat bmatnr bwerks cmtart
ORDER BY abudat bmatnr bwerks cmtart.
itab-budat = budat.
itab-matnr = matnr.
itab-werks = werks.
itab-mtart = mtart.
itab-menge = menge.
APPEND itab.
CLEAR: itab, budat, matnr, werks, mtart, menge.
ENDSELECT.
‎2008 Jul 30 7:02 AM
Hi Shelly,
This query is an Inner join among 3 table MARA,MKPF and MSEG on field MKPF -budat MSEG-matnr MSEG-werks MARA-mtart.
And sums up on field MESG-menge.
After that Where condition,GROUP BY and ORDER BY are self explanetory.
Finaly the required fields are taken into internal table itab, which is an INTERNAL TABLE with header line so have same name for work area and internal table.
Finaly the buffer is cleared with CLEAR keyword.
Since you are Anlysing it, let me tell you
1. Using iNNER JOIN among 3 tables leads to major performance ISSUE
and
2. Using of Internal table with header line is OBSOLATE in SAP.
Regards,
Anirban
‎2008 Jul 30 7:02 AM
Hi Shelly,
This query is an Inner join among 3 table MARA,MKPF and MSEG on field MKPF -budat MSEG-matnr MSEG-werks MARA-mtart.
And sums up on field MESG-menge.
After that Where condition,GROUP BY and ORDER BY are self explanetory.
Finaly the required fields are taken into internal table itab, which is an INTERNAL TABLE with header line so have same name for work area and internal table.
Finaly the buffer is cleared with CLEAR keyword.
Since you are Anlysing it, let me tell you
1. Using iNNER JOIN among 3 tables leads to major performance ISSUE
and
2. Using of Internal table with header line is OBSOLATE in SAP.
Regards,
Anirban
‎2008 Jul 30 7:29 AM
Dear Sir,
Can You please guide me how can I write it in efficient way...
Warm Regards
Shelly Malik
‎2008 Jul 30 7:30 AM
Dear sir,
Can you please guide me how can I write it in effecient way????
‎2008 Jul 30 7:31 AM
Dear Sir,
Can You please guide me how can I write it in efficient way...
Warm Regards
Shelly Malik
‎2008 Jul 30 7:35 AM
Hi shelly,
1.Instead of use Inner join use FOR ALL ENTRIES. For detail concept check
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3a1f358411d1829f0000e829fbfe/content.htm
and
2. Use Internal table without header line for your code.
All the best,
Anirban
‎2008 Jul 30 8:00 AM
Hi Shelly,
Please check this link
[JOINS vs. FOR ALL ENTRIES - Which Performs Better?|https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/6050] [original link is broken] [original link is broken] [original link is broken];
Best regards,
raam
‎2008 Jul 30 7:07 AM
Hi Friend,
This select query actually storing total goods receipts (101) quantity (menge) against all material (matnr) within specified date (budat) and storage location (lgort) shoule be FGSL/JWSL/SCRL, material document year (MJHAR) should be provdie value mjhar, in internal table itab.
Note: this select query consume a lot of memory area.
Hope it will help you.
Regards
Krishnendu
‎2008 Jul 30 7:53 AM
Hi Friend,
Ohh! i will guide you to write in efficeien way:
1. SELECT data from MKPF, MSEG and MARA using inner join into an internal table. Where condition will be like as it is.
You can not use SUM(MENGE) use only MENGE
2. Use group by, order by with those clause on that internal table.
3. Loop that internal table and use AT END OF BUDAT. SUM. END AT it will sum as required. Within that AT END AT pass values to an work are like itab. APPEND itab.
Check the work are before appending, if you are not getting all value, pass to and local work area before AT.
\[removed by moderator\]
Regards
Krishnendu
Edited by: Jan Stallkamp on Jul 30, 2008 4:24 PM