12-11-2013 1:25 PM
hie this is my first report in abap so can u assit me please.
Below is a report that i have developed but i have 3 problems
1)Firstly the completed column is not displaying the output though that grand total is appearing.
2)The report is taking ages to display can anyone give me ideas on how to make it faster by changing the code?
3)Have i managed to use the select options key word correctly?
REPORT Z_REPORT_ORDER_NOTIFY_1.
*&---------------------------------------------------------------------*
*& Report ZPM_ORDERSTATS
*& A management report to monitor the Work orders that are entered in SAP,
*& if at any stage people are not working management can use this to follow-up.
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
*tables to be used
tables:qmel,aufk.
*these parametes will work for filtering
PARAMETERS: startdat LIKE aufk-erdat OBLIGATORY,
enddate LIKE aufk-erdat OBLIGATORY,
plant LIKE aufk-werks OBLIGATORy.
SELECT-OPTIons ordtype for aufk-auart.
*data declarations being declared
data : Notifications type i VALUE 0.
data : Created type i VALUE 0.
data : Not_Created type i VALUE 0.
data : Released type i VALUE 0.
data : Completed type i VALUE 0.
data : Closed type i VALUE 0.
data : notifycount type i VALUE 0.
data : ordercount type i VALUE 0.
data : ntcount type i VALUE 0.
data : recount type i VALUE 0.
data : recomplete type i value 0.
data : closedcount type i value 0.
*structure of the internal table
types: begin of lty_qmel,
aufnr type aufk-aufnr,
phas0 TYPE aufk-phas0,
phas1 TYPE aufk-phas1,
phas2 TYPE aufk-phas2,
phas3 TYPE aufk-phas3,
end of lty_qmel.
types: begin of lty_CRTX,
OBJTY type CRTX-OBJTY,
OBJID TYPE CRTX-OBJID,
KTEXT TYPE CRTX-KTEXT,
end of lty_CRTX.
*The objects to be used
data lt_qmel type table of lty_qmel.
DATA lty_CRTX TYPE TABLE OF lty_CRTX.
SELECT DISTINCT M1~OBJTY M1~OBJID M1~KTEXT
FROM CRTX AS M1 INNER JOIN CRHD AS M2 ON M1~OBJTY = M2~OBJTY AND M1~OBJID = M2~OBJID
INTO TABLE lty_CRTX WHERE M2~WERKS EQ plant
.
IF sy-subrc EQ 0.
FIELD-SYMBOLS <fs> TYPE lty_CRTX.
LOOP AT lty_CRTX ASSIGNING <fs>.
clear Notifications.
clear Created.
clear Not_created.
clear Released.
clear Completed.
clear Closed.
SELECT COUNT( * )
FROM qmel
INTO notifications
where
ARBPLWERK = plant
AND CROBJTY EQ <fs>-OBJTY AND ARBPL EQ <fs>-OBJID.
SELECT distinct M1~aufnr M2~phas0 m2~phas1 m2~phas2 m2~phas3
FROM qmel AS M1 INNER JOIN aufk
AS M2 on m1~aufnr = m2~aufnr
INTO TABLE lt_qmel
where
ARBPLWERK = plant
AND CROBJTY EQ <fs>-OBJTY AND ARBPL EQ <fs>-OBJID AND QMNUM NE ''.
IF Lt_qmel[] IS not INITIAL.
SELECT COUNT( * )
FROM aufk
INTO created
FOR ALL ENTRIES IN lt_qmel
WHERE AUFNR = lt_qmel-AUFNR AND
PHAS0 = 'X'
AND erdat >= startdat
and erdat <= enddate
AND werks = plant
AND auart IN ordtype.
SELECT COUNT( * )
FROM aufk
INTO Not_created
FOR ALL ENTRIES IN lt_qmel
WHERE AUFNR = lt_qmel-AUFNR AND
PHAS0 <> 'X' AND
erdat >= startdat
and erdat <= enddate
AND werks = plant
AND auart IN ordtype.
SELECT COUNT( * )
FROM aufk
INTO Released
FOR ALL ENTRIES IN lt_qmel
WHERE AUFNR = lt_qmel-AUFNR AND
PHAS1 = 'X' AND
erdat >= startdat
and erdat <= enddate
AND werks = plant
AND auart IN ordtype.
SELECT COUNT( * )
FROM aufk
INTO Completed
FOR ALL ENTRIES IN lt_qmel
WHERE AUFNR = lt_qmel-AUFNR AND
PHAS2 = 'X' AND
erdat >= startdat
and erdat <= enddate
AND werks = plant
AND auart IN ordtype.
SELECT COUNT( * )
FROM aufk
INTO Closed
FOR ALL ENTRIES IN lt_qmel
WHERE AUFNR = lt_qmel-AUFNR AND
PHAS3 = 'X' AND
erdat >= startdat
and erdat <= enddate
AND werks = plant
AND auart IN ordtype.
notifycount = notifycount + notifications.
ordercount = ordercount + Created.
ntcount = ntcount + Not_created.
recount = recount + Released.
recomplete = recomplete + Completed.
closedcount = closedcount + Closed.
endif.
WRITE: /01 <fs>-KTEXT,
41 notifications,
56 created,
70 Not_created,
80 Released,
99 Completed,
105 Closed.
CLEAR lt_qmel.
ENDLOOP.
ENDIF.
WRITE: /01'GRAND TOTAL ', notifycount,' ',ordercount,'',ntcount,'',recount,recomplete,closedcount.
TOP-OF-PAGE.
FORMAT COLOR 4.
SKIP.
WRITE:/01 'MAINTENANCE ORDER STATICS REPORT ', 70 sy-datum USING EDIT MASK
'__/__/____', '/', sy-uname, '/', sy-repid, 162 ' ' .
WRITE:/01 'PLANT : ', plant, 162 ' '.
WRITE:/01 'PERIOD : ', startdat, ' to ', enddate, 162 ' '.
WRITE:/162 ' '.
SKIP.
WRITE: /01 'Description',
41 'Notifications',
61 'Created',
70 'Not Created',
83 'Released',
97 'Completed',
110 'Closed'.
please help
12-11-2013 1:33 PM
Hello Bryan,
You should never select data in a loop.
Best way would be fill buffer tables before the loop with all entries you need and catch them with read table.
to get the count in your special case it maybe would be faster to buffer all relevant entries from table "aufk" and count them manually in your program.
Next performance Killer is a select with a "<>" or "NE" statement. Better use " = space" instead of "<> 'X' " if you only have X and space inthis field.
12-11-2013 1:41 PM
Hi -
1. Do not write SELECT statment inside the LOOP and ENDLOOP. Instead, Use FOR ALL ENTRIES.
2. Try to pass as much key fields to where condition
3. First take data to internal table for each SELECT from database tables
4. You can do manipulation / calculation on the internal tables after having the data.
Hope it helps.
Let us know, if you face any further help.
Regards,
Atul Mohanty
12-13-2013 8:38 AM
thank you so much guys i have found material on perfomance when accesing data
so im still going thru it
will post if i have challenges