SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Список ордеров



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> CO
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1636

PostPosted: Thu Sep 20, 2007 1:06 pm    Post subject: Список ордеров Reply with quote

Code:

*&---------------------------------------------------------------------*
*& Report  ZFAEI                                                       *
*& Steven Buttiglieri                                                  *
*&---------------------------------------------------------------------*
*&                                                                     *
*&---------------------------------------------------------------------*

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.'.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> CO All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.