For All Entries Performance

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

*&---------------------------------------------------------------------* *& Report ZFAEI * *& Steven Buttiglieri * *&---------------------------------------------------------------------* *& Click here for the results from

this program document times * *& * *&---------------------------------------------------------------------* REPORT ZFAEI MESSAGE-ID ZZ NO STANDARD PAGE HEADING LINE-COUNT 58 LINE-SIZE 170. TABLES: AUFK, COSP, BKPF. DATA: BEGIN OF T_AUFK OCCURS 200. INCLUDE STRUCTURE AUFK. DATA: END OF T_AUFK. DATA: BEGIN OF T_COSP OCCURS 200, * include structure cosp. LEDNR LIKE COSP-LEDNR, OBJNR LIKE COSP-OBJNR, GJAHR LIKE COSP-GJAHR, WRTTP LIKE COSP-WRTTP, VERSN LIKE COSP-VERSN, KSTAR LIKE COSP-KSTAR, WTG001 LIKE COSP-WTG001, WTG002 LIKE COSP-WTG002, WTG003 LIKE COSP-WTG003, WTG004 LIKE COSP-WTG004, WTG005 LIKE COSP-WTG005, WTG006 LIKE COSP-WTG006, WTG007 LIKE COSP-WTG007, WTG008 LIKE COSP-WTG008, WTG009 LIKE COSP-WTG009, WTG010 LIKE COSP-WTG010, WTG011 LIKE COSP-WTG011, WTG012 LIKE COSP-WTG012, WTG013 LIKE COSP-WTG013, WTG014 LIKE COSP-WTG014, WTG015 LIKE COSP-WTG015, WTG016 LIKE COSP-WTG016, END OF T_COSP. DATA: W_GJAHR LIKE BKPF-GJAHR. DATA: TIME1 TYPE I, TIME2 TYPE I, TIME3 TYPE I. SELECT-OPTIONS: P_AUFNR FOR AUFK-AUFNR MATCHCODE OBJECT ORDE DEFAULT '2000000' TO '4999999'. SELECT-OPTIONS: S_PRCTR FOR AUFK-PRCTR " Profit Center MATCHCODE OBJECT PRCT. SELECT-OPTIONS: S_KSTAR FOR AUFK-KSTAR. " Cost Elem INITIALIZATION. * initializing the cost element selections * Note: Must keep the leading 0's on the Cost Element #'s, because * that's how they're stored in the database, and they won't be selected * correctly otherwise MOVE: 'I' TO S_KSTAR-SIGN, 'BT' TO S_KSTAR-OPTION, '0000400000' TO S_KSTAR-LOW,

'0000499999' TO S_KSTAR-HIGH. APPEND S_KSTAR. MOVE: 'I' TO S_KSTAR-SIGN, 'BT' TO S_KSTAR-OPTION, '0000600000' TO S_KSTAR-LOW, '0000600499' TO S_KSTAR-HIGH. APPEND S_KSTAR. MOVE: 'I' TO S_KSTAR-SIGN, 'BT' TO S_KSTAR-OPTION, '0000600600' TO S_KSTAR-LOW, '0000699999' TO S_KSTAR-HIGH. APPEND S_KSTAR. MOVE: 'I' TO S_KSTAR-SIGN, 'BT' TO S_KSTAR-OPTION, '0000800000' TO S_KSTAR-LOW, '0000899999' TO S_KSTAR-HIGH. APPEND S_KSTAR. START-OF-SELECTION. CALL FUNCTION 'FI_PERIOD_DETERMINE' EXPORTING I_BUKRS = 'CUR' I_BUDAT = SY-DATUM I_MONAT = '00' I_GJAHR = '0000' IMPORTING E_GJAHR = W_GJAHR. CLEAR T_AUFK. REFRESH T_AUFK. SELECT AUFNR KTEXT KSTAR OBJNR PRCTR USER8 FROM AUFK INTO CORRESPONDING FIELDS OF TABLE T_AUFK WHERE AUFNR IN P_AUFNR AND PRCTR IN S_PRCTR. IF T_AUFK[] IS INITIAL. EXIT. ENDIF. CLEAR T_COSP. REFRESH T_COSP. * Select COSP COSS costs; too many records in t_aufk to use * For All Entries In GET RUN TIME FIELD TIME1. SELECT LEDNR OBJNR GJAHR WRTTP VERSN KSTAR WTG001 WTG002 WTG003 WTG004 WTG005 WTG006 WTG007 WTG008 WTG009 WTG010 WTG011 WTG012 WTG013 WTG014 WTG015 WTG016 FROM COSP INTO TABLE T_COSP FOR ALL ENTRIES IN T_AUFK WHERE LEDNR EQ '00' AND OBJNR = T_AUFK-OBJNR AND GJAHR LE W_GJAHR AND WRTTP EQ '04' AND VERSN = '000' AND KSTAR IN S_KSTAR. GET RUN TIME FIELD TIME2. TIME3 = TIME2 - TIME1. DESCRIBE TABLE T_COSP LINES SY-TFILL. WRITE : / 'For all entries in time: ', TIME3. WRITE : / 'For all entries in rows: ', SY-TFILL.

CLEAR T_COSP. REFRESH T_COSP. CLEAR: TIME1, TIME2, TIME3. GET RUN TIME FIELD TIME1. * selecting COSP COSS costs to avoid repeat database hits. LOOP AT T_AUFK. SELECT LEDNR OBJNR GJAHR WRTTP VERSN KSTAR WTG001 WTG002 WTG003 WTG004 WTG005 WTG006 WTG007 WTG008 WTG009 WTG010 WTG011 WTG012 WTG013 WTG014 WTG015 WTG016 FROM COSP APPENDING TABLE T_COSP " primary costs * for all entries in t_aufk WHERE LEDNR EQ '00' AND OBJNR = T_AUFK-OBJNR AND GJAHR LE W_GJAHR AND WRTTP EQ '04' AND VERSN = '000' AND KSTAR IN S_KSTAR. ENDLOOP. GET RUN TIME FIELD TIME2. TIME3 = TIME2 - TIME1. DESCRIBE TABLE T_COSP LINES SY-TFILL. WRITE : / 'Loop on itab time: ', TIME3. WRITE : / 'Loop on itab rows: ', SY-TFILL. WRITE : / 'Program completed successfully.'. Results:

You might also like