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

FI Info for Internal Orders aka Project Expense Report



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



Joined: 01 Sep 2007
Posts: 1636

PostPosted: Sat Apr 12, 2008 11:13 am    Post subject: FI Info for Internal Orders aka Project Expense Report Reply with quote

The report displays information about internal orders. It has two parts: one for reporting data based on document information in BSIS and BSEG, and one for reporting data based on purchasing order information. The user selects which report to run with the appropriate radio button. For PO data, this report simply prepares and submits a set of parameters to the Outstanding Purchase Order report. For document information, this report prepares and lists the appropriate information from BSIS and BSEG.

Report By Document Data: The report looks up data in BSIS and BSEG that meets the user's selection criteria, and lists the data (one line per BSIS entry). Purchase order and cost object data resides in BSEG; the rest of the data resides in BSIS.

Report By PO Data: The report looks up purchase order information by referencing BSIS, and then referencing BSEG. It then keeps a list of purchase orders po_doc, which is passed on to the Outstanding Order report to limit its selection, and a list of (Purchase Order, Item Number) pairs (fields ebeln and ebelp in BSEG). In addition, it keeps a list of (Purchase Order, Internal Order) pairs (fields BSEG-ebeln and BSIS-aufnr), so that the Outstanding PO report can quickly look up the internal order numbers without another database call. These two lists are kept in the select-options po_itemp and po_aufnr. It was convenient to do it this way, because select-options are easy to pass on using submit...with. The limitation is that, in pur_itemp, ebelp must always be less than ebeln, and in po_order, aufnr must always be less than ebeln, otherwise an error will occur when passing the parameters. If this happens, and the program needs to be modified, then the info will have to be passed using an internal table exported to memory in this report (using export) and then imported in the Outstanding PO report (using import). The Outstanding PO report report behaves slightly different when called from this report. Namely:
  • the compare parameter is set to 'A' (an arbitrary value), which is a flag indicating that the report was called by this report, and to process as described here
  • After looking up records for PO documents, limited by the PO numbers in the po_doc selection criteria passed to it, the report makes a further check on each line item, listing only those items found in the PO/Item pairs list po_itemp
  • the report lists items with IR < GR, or GR = IR = 0 (rather than IR <> GR)
  • the report's output list contains an additional field Internal Order, which is looked up in the PO/Internal Order pairs list po_order that is passed to it

For further details, see documentation in the Outstanding PO report.

Project Expense Report

Code:
*&---------------------------------------------------------------------*
*& Report  ZPRJEXP2                                                    *
*& Author: Matt Wong, SNI Taiwan, Aug 1998                             *
*&                                                                     *
*& Report for displaying expense data for internal orders/projects.    *
*& PO_ITEMP contains PO/item pairs to be passed onto the Outstanding PO*
*& report, since we may only want to access certain items of a PO (not *
*& all items).                                                         *
*& Using a select-option to do this makes it easier to pass the info to*
*& the report                                                          *
*&                                                                     *
*& PO_AUFNR is also for passing data between programs. It passes       *
*& PO/Internal Order number pairs                                      *
*&---------------------------------------------------------------------*

REPORT  ZPRJEXP2  LINE-SIZE 250 LINE-COUNT 65 NO STANDARD PAGE HEADING.
TABLES: BSIS, BSEG.
PARAMETERS: COMPANY LIKE BSIS-BUKRS OBLIGATORY,
            BYDOC RADIOBUTTON GROUP REPT,
            BYPO  RADIOBUTTON GROUP REPT.
SELECT-OPTIONS: ORDER FOR BSIS-AUFNR OBLIGATORY NO-EXTENSION,
            POSTDATE FOR SY-DATUM NO-EXTENSION,
            YEAR FOR BSIS-GJAHR NO-DISPLAY,
            PO_DOC FOR BSEG-EBELN NO-DISPLAY,
            PO_ITEMP FOR BSEG-EBELN NO-DISPLAY, "PO/item pair
            PO_AUFNR FOR BSIS-AUFNR NO-DISPLAY.

DATA:
      BSEG_FIELDS LIKE RSFS_STRUC OCCURS 10 WITH HEADER LINE,
      BEGIN OF MYBSEG,
        EBELN LIKE BSEG-EBELN,
        EBELP LIKE BSEG-EBELP,
        KSTRG LIKE BSEG-KSTRG,
      END OF MYBSEG,
      LASTAUFNR LIKE BSIS-AUFNR,
      AUFNRSUBTOTAL LIKE BSIS-DMBTR,
      TOTAL LIKE BSIS-DMBTR.

AT SELECTION-SCREEN ON POSTDATE.
  CLEAR YEAR. REFRESH YEAR.
  IF NOT POSTDATE-LOW IS INITIAL.
    YEAR-SIGN = 'I'.
    YEAR-OPTION = 'EQ'.
    YEAR-LOW = POSTDATE-LOW(4).
    IF NOT POSTDATE-HIGH IS INITIAL AND
       ( POSTDATE-LOW(4) <> POSTDATE-HIGH(4) ) .
      MESSAGE E003(ZS).
    ENDIF.
    APPEND YEAR.
  ENDIF.

INITIALIZATION.
  BSEG_FIELDS = 'ebeln'. APPEND BSEG_FIELDS.
  BSEG_FIELDS = 'ebelp'. APPEND BSEG_FIELDS.
  BSEG_FIELDS = 'kstrg'. APPEND BSEG_FIELDS.
  REFRESH PO_DOC.
  PO_DOC-SIGN = 'I'.
  PO_DOC-OPTION = 'EQ'.
  REFRESH PO_ITEMP.

TOP-OF-PAGE.
  WRITE: SY-DATUM.
  WRITE: 85 'Project Expenditure Tracing Report (by Document),'.
  WRITE: 'Posting date'.
  IF POSTDATE-HIGH IS INITIAL.
    WRITE: POSTDATE-LOW.
  ELSE.
    WRITE: 'Between', POSTDATE-LOW, 'and', POSTDATE-HIGH.
  ENDIF.
  WRITE:   240 'Page:', 248(2) SY-PAGNO, / SY-ULINE.

START-OF-SELECTION.
* should do authorization checking here **
  SELECT * FROM BSIS WHERE
         BUKRS = COMPANY AND
         GJAHR IN YEAR AND
         AUFNR IN ORDER AND
         BUDAT IN POSTDATE
       ORDER BY AUFNR BELNR.
    IF BYPO = ' ' AND LASTAUFNR <> BSIS-AUFNR.
      PERFORM WRITE_ORDER_HEADER.
    ENDIF.
    LASTAUFNR = BSIS-AUFNR.
* should do authorization checking here **
    SELECT SINGLE (BSEG_FIELDS) FROM BSEG INTO MYBSEG WHERE
           BUKRS = COMPANY AND
           BELNR = BSIS-BELNR AND
           GJAHR = BSIS-GJAHR AND
           BUZEI = BSIS-BUZEI.
    IF BYPO = 'X'. "output by PO doc: report zgmpo-05
      LOOP AT PO_AUFNR WHERE HIGH = MYBSEG-EBELN AND LOW = BSIS-AUFNR.
      ENDLOOP.
      IF SY-SUBRC = 4. "no entry already exists
        PO_AUFNR-HIGH = MYBSEG-EBELN.
        PO_AUFNR-LOW = BSIS-AUFNR.
        APPEND PO_AUFNR.
      ENDIF.
      IF MYBSEG-EBELN <> SPACE.
        PERFORM ADD_PO_ITEM.
      ENDIF.
    ELSE. "output by document
      IF BSIS-SHKZG = 'H'.
      ELSE.
        BSIS-DMBTR = - BSIS-DMBTR.
      ENDIF.
      PERFORM WRITE_OUTPUT.
      TOTAL = TOTAL + BSIS-DMBTR.
      AUFNRSUBTOTAL = AUFNRSUBTOTAL + BSIS-DMBTR.
    ENDIF.
  ENDSELECT.
  IF BYPO = 'X'.
    SUBMIT ZGMPO-05 WITH COMPARE = 'A'
           WITH PO_ITEMP IN PO_ITEMP
           WITH PO_DOC IN PO_DOC
           WITH POSTDAT IN POSTDATE
           WITH PO_AUFNR IN PO_AUFNR AND RETURN.
  ELSE.
    PERFORM WRITE_AUFNRSUBTOTAL.
    PERFORM WRITE_TOTAL.
  ENDIF.
*&---------------------------------------------------------------------*
*&      Form  WRITE_OUTPUT
*&---------------------------------------------------------------------*
FORM WRITE_OUTPUT.
  WRITE: / BSIS-BELNR UNDER TEXT-001,  "Document
           BSIS-BUDAT UNDER TEXT-002,  "Posting Date
           BSIS-KOSTL UNDER TEXT-003,  "Cost Center
           BSIS-SGTXT UNDER TEXT-004,  "Description
           BSIS-DMBTR UNDER TEXT-005,  "Amount
         MYBSEG-KSTRG UNDER TEXT-006,  "Cost Object
         MYBSEG-EBELN UNDER TEXT-007.  "PO Number
ENDFORM.                               " WRITE_OUTPUT

*&---------------------------------------------------------------------*
*&      Form  WRITE_COL_HEADERS
*&---------------------------------------------------------------------*
FORM  WRITE_COL_HEADERS.
  WRITE: / TEXT-001,                   "Document
        16 TEXT-002,                   "Posting Date
        28 TEXT-003,                   "Cost Center
        36 TEXT-004,                   "Description
        87 TEXT-005,                   "Amount
       107 TEXT-006,                   "Cost Object
       123 TEXT-007.                   "PO Number
ENDFORM.
*&---------------------------------------------------------------------*
*&      Form  WRITE_TOTAL
*&---------------------------------------------------------------------*
FORM WRITE_TOTAL.
  WRITE: / SY-ULINE.
  WRITE: / 'Total:' UNDER TEXT-004, TOTAL UNDER TEXT-005.
ENDFORM.                               " WRITE_TOTAL
*&---------------------------------------------------------------------*
*&      Form  ADD_PO_ITEM
*&---------------------------------------------------------------------*
FORM ADD_PO_ITEM.
  LOOP AT PO_DOC WHERE LOW = MYBSEG-EBELN.
  ENDLOOP.
  IF SY-SUBRC = 4.                     "entry does not already exist
    PO_DOC-LOW = MYBSEG-EBELN.
    APPEND PO_DOC.
  ENDIF.

* add po/item pair to list. PO goes into high, item into low
  LOOP AT PO_ITEMP WHERE HIGH = MYBSEG-EBELN AND LOW = MYBSEG-EBELP.
  ENDLOOP.
  IF SY-SUBRC = 4. "entry does not already exist
    PO_ITEMP-HIGH = MYBSEG-EBELN.
    PO_ITEMP-LOW = MYBSEG-EBELP.
    APPEND PO_ITEMP.
  ENDIF.
ENDFORM.                               " ADD_PO_ITEM
*&---------------------------------------------------------------------*
*&      Form  WRITE_ORDER_HEADER
*&---------------------------------------------------------------------*
FORM WRITE_ORDER_HEADER.
  IF NOT AUFNRSUBTOTAL IS INITIAL.
    PERFORM WRITE_AUFNRSUBTOTAL.
  ENDIF.

  SKIP 1.
  WRITE: / 'Project No:', BSIS-AUFNR.
  WRITE: / SY-ULINE.
  PERFORM WRITE_COL_HEADERS.
ENDFORM.                    " WRITE_ORDER_HEADER

*&---------------------------------------------------------------------*
*&      Form  WRITE_AUFNRSUBTOTAL
*&---------------------------------------------------------------------*
FORM WRITE_AUFNRSUBTOTAL.
  WRITE: / SY-ULINE.
 WRITE: / 'Project Total:' UNDER TEXT-004, AUFNRSUBTOTAL UNDER TEXT-005.
  AUFNRSUBTOTAL = 0.
ENDFORM.                    " WRITE_AUFNRSUBTOTAL
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 -> ММ 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.