This report displays information for outstanding purchase orders. The report has two parts: one is the standard report, and the other is called from the Project Expense report. Note that both reports output GL Account, cost center, and cost object information (from table EKKN) as a single value on the output line. Actually, each line may have several cost centers and cost object to which the invoices were allocated; however, the user only wanted one (any one) to be listed.
Standard Report: The standard report lists info (limited by selection criteria) for purchase order items whose GR and IR are not equal. The report first accesses the header table EKKO, limited by purchasing group and purchase order. It then accesses EKPO, limited by PO item and material selection criteria. An internal table sums keeps subtotals of the related GR/IR quantities and values, read from EKBE, for the given PO and item. In the fill_sums routine, the subtotals are grouped by Credit/Debit indicator (EKBE-SHKZG), account assignment (EKBE-ZEKKN), and PO Doc Category (EKBE-BEWTP). These subtotals are then processed by the fill_outtab routine, which makes the GR/IR totals and compares them. If they are unequal, data is looked up further from EKKN, and the item is output.
Report Called from Project Expense Report: The report called from the Project Expense Report is the same as the standard report except that:
the compare variable is set to value 'A'.
records are outputted if GR < IR, or if both GR and IR are zero
selection criteria is based on the data in the po_itemp select-options list. This list is filled when the report is called
project number is output (project number is looked up in the po_aufnr select-options list which is filled when the report is called)
subtotals are not outputted
Outstanding PO Report
*&---------------------------------------------------------------------*
*& Outstanding POs *
*& *
*& ekbe has GR/IR records. If there is account assignment (ekpo-knttp *
*& is not blank), then ekkn will also have records related to the ekbe *
*& records. First check ekbe to see if GR/IR are unequal. If they are, *
*& list them and show related info. *
*& *
*& The ekkn table may contain several records with different G/L Accts *
*& Cost Centers, and/or Cost Objects. This report selects one record *
*& at random and uses it to get this data. Thus the *
*& report's output is somewhat misleading, as the G/L, Cctr, and CObj *
*& are listed as a single value rather than several values. A better *
*& implementation would list this info in sub-records (e.g. drill-down)*
*&---------------------------------------------------------------------*
REPORT ZGRIROPO LINE-SIZE 250 LINE-COUNT 65 NO STANDARD PAGE HEADING.
TABLES: EKBE, EKPO, EKKO, EKKN, BSIS.
PARAMETERS: COMPARE TYPE C NO-DISPLAY.
SELECT-OPTIONS:
PO_DOC FOR EKPO-EBELN, "Purchase order
PO_ITEM FOR EKPO-EBELP,"Purchase order item
PUR_GRP FOR EKKO-EKGRP,"Purchasing Group
MAT_NR FOR EKPO-MATNR, "material #
SEL_ACCT FOR EKPO-KNTTP, "account assignment category
POSTDAT FOR SY-DATUM NO-DISPLAY, "posting date
"transfer of params from project expense report
PO_ITEMP FOR EKPO-EBELN NO-DISPLAY, "PO/item pair
PO_AUFNR FOR BSIS-AUFNR NO-DISPLAY. "PO/order pair
DATA:
LN TYPE I, "subtotal for cost objects
TOTAL LIKE EKBE-DMBTR,
OLDSAKTO LIKE EKKN-SAKTO,
OLDKOSTL LIKE EKKN-KOSTL,
OLDKSTRG LIKE EKKN-KSTRG,
DO_SUBTOTAL TYPE C,
WROTE_SUBT TYPE C,
BEGIN OF COBJ_SUBTOTAL,
MENGE LIKE EKBE-MENGE,
GR LIKE EKBE-MENGE,
IR LIKE EKBE-MENGE,
ESTGRVAL LIKE EKBE-DMBTR,
IRVAL LIKE EKBE-DMBTR,
OUT LIKE EKBE-MENGE,
ESTOUTVAL LIKE EKBE-DMBTR,
END OF COBJ_SUBTOTAL,
BEGIN OF TOTALS.
INCLUDE STRUCTURE COBJ_SUBTOTAL.
DATA:END OF TOTALS,
EKKOEBELN LIKE EKKO-EBELN, "for ekko data
BEGIN OF MYEKPO, "for ekpo data
EBELN LIKE EKPO-EBELN,
EBELP LIKE EKPO-EBELP,
MENGE LIKE EKPO-MENGE,
NETPR LIKE EKPO-NETPR,
KNTTP LIKE EKPO-KNTTP,
TXZ01 LIKE EKPO-TXZ01,
END OF MYEKPO,
BEGIN OF MYEKKN,
* zekkn like ekkn-zekkn,
MENGE LIKE EKKN-MENGE,
VPROZ LIKE EKKN-VPROZ,
SAKTO LIKE EKKN-SAKTO,
KOSTL LIKE EKKN-KOSTL,
KSTRG LIKE EKKN-KSTRG,
END OF MYEKKN,
BEGIN OF SUMS OCCURS 20, "totals for gr and ir
ZEKKN LIKE EKBE-ZEKKN, "Acct assignment serial
BEWTP LIKE EKBE-BEWTP, "PO Doc category
MENGE LIKE EKBE-MENGE, "GR/IR Quantity
DMBTR LIKE EKBE-DMBTR, "GR Value
SHKZG LIKE EKBE-SHKZG, "Debt/Credit indicator
END OF SUMS,
BEGIN OF OUTTAB OCCURS 1000, "output list
EBELN LIKE EKPO-EBELN, "PO Doc
EBELP LIKE EKPO-EBELP, "PO item
ZEKKN LIKE EKKN-ZEKKN, "account serial #
SAKTO LIKE EKKN-SAKTO, "G/L acct
KOSTL LIKE EKKN-KOSTL, "cost center
KSTRG LIKE EKKN-KSTRG, "cost object
MENGE LIKE EKPO-MENGE, "Quantity (total)
TXZ01 LIKE EKPO-TXZ01, "short text
GR LIKE EKPO-MENGE, "GR Quantity
ESTGRVAL LIKE EKBE-DMBTR,
GRVAL LIKE EKBE-DMBTR, "GR Value
IR LIKE EKPO-MENGE, "IR Quantity
IRVAL LIKE EKBE-DMBTR, "IR Value
OUT LIKE EKPO-MENGE, "Outstanding IR quantity
OUTVAL LIKE EKPO-BRTWR, "Outstanding IR value
ESTOUTVAL LIKE EKPO-BRTWR, "Estimated Outstanding IR Value
END OF OUTTAB.
AT SELECTION-SCREEN.
IF PUR_GRP IS INITIAL AND PO_DOC IS INITIAL.
MESSAGE E007(ZS).
ENDIF.
START-OF-SELECTION.
* should do authorization checking here **
SELECT EBELN FROM EKKO "select POs from pur grp and po doc
INTO EKKOEBELN
WHERE LOEKZ = ' ' AND "not to be deleted
EKGRP IN PUR_GRP AND "criteria
EBELN IN PO_DOC
ORDER BY EBELN.
* should do authorization checking here **
SELECT EBELN EBELP MENGE NETPR KNTTP TXZ01
FROM EKPO "select POs from material criteria
INTO MYEKPO
WHERE LOEKZ = ' ' AND "not to be deleted
KNTTP IN SEL_ACCT AND
EBELN = EKKOEBELN AND
EBELP IN PO_ITEM AND
MATNR IN MAT_NR
ORDER BY EBELN EBELP.
IF COMPARE = 'A'. "only use PO/item pairs passed from proj exp
LOOP AT PO_ITEMP
WHERE HIGH = MYEKPO-EBELN AND LOW = MYEKPO-EBELP.
ENDLOOP.
CHECK SY-SUBRC = 0. "PO/item pair was listed
ENDIF.
* should do authorization checking here **
PERFORM FILL_SUMS.
PERFORM FILL_OUTTAB. "fill info for output
CLEAR OUTTAB.
ENDSELECT.
ENDSELECT.
PERFORM WRITE_OUTTAB.
*---------------------------------------------------------------------*
* FORM FILL_SUMS *
*---------------------------------------------------------------------*
FORM FILL_SUMS. "fill sums table with GR/IR data from ekbe
CLEAR SUMS. CLEAR SUMS[].
SELECT ZEKKN BEWTP MENGE DMBTR SHKZG FROM EKBE INTO SUMS
WHERE EBELN = MYEKPO-EBELN AND EBELP = MYEKPO-EBELP.
CHECK SUMS-SHKZG <> ' '.
IF SUMS-SHKZG = 'H'. "negative value
SUMS-MENGE = - SUMS-MENGE.
SUMS-DMBTR = - SUMS-DMBTR.
ENDIF.
SUMS-SHKZG = ' '.
COLLECT SUMS.
ENDSELECT.
ENDFORM.
*---------------------------------------------------------------------*
* FORM FILL_OUTTAB *
*---------------------------------------------------------------------*
FORM FILL_OUTTAB.
* preconditions: myekpo is set at current PO and item
* sums has gr/ir totals, by zekkn sub-index
CLEAR OUTTAB.
LOOP AT SUMS.
IF SUMS-BEWTP = 'E'. "goods receipt
OUTTAB-GR = OUTTAB-GR + SUMS-MENGE.
OUTTAB-GRVAL = OUTTAB-GRVAL + SUMS-DMBTR.
ELSEIF SUMS-BEWTP = 'R'. "invoice receipt
OUTTAB-IR = OUTTAB-IR + SUMS-MENGE.
OUTTAB-IRVAL = OUTTAB-IRVAL + SUMS-DMBTR.
ELSE.
* perform write_bewtp_unhandled.
ENDIF.
ENDLOOP.
IF COMPARE = SPACE.
CHECK OUTTAB-GR <> OUTTAB-IR. "if gr/ir is equal, stop processing
ELSE. "COMPARE = 'A'.
CHECK ( OUTTAB-IR < OUTTAB-GR OR
( OUTTAB-GR = 0 AND OUTTAB-IR = 0 ) ).
ENDIF.
OUTTAB-EBELN = MYEKPO-EBELN.
OUTTAB-EBELP = MYEKPO-EBELP.
OUTTAB-MENGE = MYEKPO-MENGE.
OUTTAB-TXZ01 = MYEKPO-TXZ01.
OUTTAB-OUT = OUTTAB-GR - OUTTAB-IR.
OUTTAB-OUTVAL = OUTTAB-GRVAL - OUTTAB-IRVAL.
OUTTAB-ESTGRVAL = OUTTAB-GR * MYEKPO-NETPR.
OUTTAB-ESTOUTVAL = OUTTAB-ESTGRVAL - OUTTAB-IRVAL.
IF MYEKPO-KNTTP <> ' '. "account assignment: need to use ekkn
IF EKPO-VRTKZ = '2'. "multiple account distributed by percentage
WRITE: / 'This program does not handle accounts distributed',
'by percentage. Pls check manually (PO number',
EKPO-EBELN, ')'.
EXIT.
ENDIF.
* Fill in random info from ekkn.
SELECT SINGLE MENGE VPROZ SAKTO KOSTL KSTRG FROM EKKN
INTO MYEKKN WHERE
EBELN = MYEKPO-EBELN AND EBELP = MYEKPO-EBELP.
OUTTAB-SAKTO = MYEKKN-SAKTO.
OUTTAB-KOSTL = MYEKKN-KOSTL.
OUTTAB-KSTRG = MYEKKN-KSTRG.
APPEND OUTTAB. CLEAR OUTTAB.
ENDIF. "account assignment
ENDFORM.
*---------------------------------------------------------------------*
* FORM WRITE_OUTTAB *
*---------------------------------------------------------------------*
FORM WRITE_OUTTAB.
DESCRIBE TABLE OUTTAB LINES LN.
IF LN = 0.
WRITE: / 'No records found.'.
EXIT.
ENDIF.
SORT OUTTAB BY SAKTO KOSTL KSTRG.
LOOP AT OUTTAB.
IF ( NOT OLDSAKTO IS INITIAL ) AND OUTTAB-SAKTO <> OLDSAKTO AND
WROTE_SUBT = SPACE.
DO_SUBTOTAL = 'X'.
ENDIF.
OLDSAKTO = OUTTAB-SAKTO.
IF ( NOT OLDKOSTL IS INITIAL ) AND OUTTAB-KOSTL <> OLDKOSTL AND
WROTE_SUBT = SPACE.
DO_SUBTOTAL = 'X'.
ENDIF.
IF ( NOT OLDKSTRG IS INITIAL ) AND OLDKSTRG <> OUTTAB-KSTRG.
DO_SUBTOTAL = 'X'.
ENDIF.
OLDKSTRG = OUTTAB-KSTRG.
WROTE_SUBT = SPACE.
IF DO_SUBTOTAL = 'X'.
PERFORM WRITE_COBJ_SUBTOTAL.
CLEAR COBJ_SUBTOTAL.
DO_SUBTOTAL = SPACE.
ENDIF.
ADD-CORRESPONDING OUTTAB TO COBJ_SUBTOTAL.
ADD-CORRESPONDING OUTTAB TO TOTALS.
IF OUTTAB-OUT < 0.
FORMAT COLOR COL_NEGATIVE.
ENDIF.
WRITE: /
OUTTAB-EBELN UNDER TEXT-004, "PO doc
OUTTAB-EBELP UNDER TEXT-005, "PO item
OUTTAB-SAKTO UNDER TEXT-006, "G/L Acct
OUTTAB-KOSTL UNDER TEXT-007, "Cost Center
OUTTAB-KSTRG UNDER TEXT-008, "Cost Object
(13) OUTTAB-MENGE UNDER TEXT-009, "Quantity
(13) OUTTAB-GR UNDER TEXT-010, "GR quantity
(13) OUTTAB-IR UNDER TEXT-011, "IR quantity
(13) OUTTAB-ESTGRVAL UNDER TEXT-017, "Estimated GR Value
* (13) outtab-grval under text-012, "GR Val
(13) OUTTAB-IRVAL UNDER TEXT-013, "IR Value
(13) OUTTAB-OUT UNDER TEXT-014, "Outstandng IR qty
(13) OUTTAB-ESTOUTVAL UNDER TEXT-018, "Estimated Out IR Value
* (13) outtab-outval under text-015. "Outstandng IRval
OUTTAB-TXZ01 UNDER TEXT-019.
IF COMPARE = 'A'.
LOOP AT PO_AUFNR WHERE HIGH = OUTTAB-EBELN.
WRITE: PO_AUFNR-LOW UNDER TEXT-020.
ENDLOOP.
ENDIF.
FORMAT COLOR OFF.
ENDLOOP.
PERFORM WRITE_COBJ_SUBTOTAL.
PERFORM WRITE_TOTALS.
ENDFORM.
*---------------------------------------------------------------------*
* FORM WRITE_HEADERS *
*---------------------------------------------------------------------*
FORM WRITE_HEADERS.
FORMAT COLOR COL_HEADING.
WRITE: / TEXT-004, "PO
12 TEXT-005, "Item
18 TEXT-006, "G/L
29 TEXT-007, "Cost Center
40 TEXT-008, "Cost Object
49 TEXT-009, "Tot Qty
57 TEXT-010, "GR Qty
71 TEXT-011, "IR Qty
85 TEXT-017, "Est GR Value
* 85 text-012, "GR Val
99 TEXT-013, "IR Val
113 TEXT-014, "Outstanding IR Qty
* 127 text-015. "Outstanding IR Val
127 TEXT-018, "Est Out IR Val
141 TEXT-019. "short text
IF COMPARE = 'A'.
WRITE: 183 TEXT-020. "project
ENDIF.
WRITE: / SY-ULINE.
FORMAT COLOR OFF.
ENDFORM.
TOP-OF-PAGE.
WRITE: SY-DATUM, SY-REPID, '/', SY-UNAME.
IF COMPARE = 'A'. "called from proj exp. report
READ TABLE POSTDAT INDEX 1.
WRITE: 85 'Project Expenditure Tracking Report (By PO Number)'.
WRITE: 'Posting date'.
IF POSTDAT-HIGH IS INITIAL.
WRITE: ':', POSTDAT-LOW.
ELSE.
WRITE: 'Between', POSTDAT-LOW, 'and', POSTDAT-HIGH.
ENDIF.
ELSE.
WRITE: 110 'Outstanding Purchase Order'.
ENDIF.
WRITE: 240 'Page:', 248(2) SY-PAGNO, / SY-ULINE.
PERFORM WRITE_HEADERS.
*&---------------------------------------------------------------------*
*& Form WRITE_COBJ_SUBTOTAL
*&---------------------------------------------------------------------*
FORM WRITE_COBJ_SUBTOTAL.
IF COMPARE = ' '.
WRITE: / SY-ULINE.
WRITE: / 'Subtotal' UNDER TEXT-008,
(13) COBJ_SUBTOTAL-MENGE UNDER TEXT-009, "Quantity
(13) COBJ_SUBTOTAL-GR UNDER TEXT-010, "GR quantity
(13) COBJ_SUBTOTAL-IR UNDER TEXT-011, "IR quantity
(13) COBJ_SUBTOTAL-ESTGRVAL UNDER TEXT-017, "Estimated GR Value
(13) COBJ_SUBTOTAL-IRVAL UNDER TEXT-013, "IR Value
(13) COBJ_SUBTOTAL-OUT UNDER TEXT-014, "Outstandng IR qty
(13) COBJ_SUBTOTAL-ESTOUTVAL UNDER TEXT-018. "Estimated Out IRva
SKIP 1.
WROTE_SUBT = 'X'.
ENDIF.
ENDFORM. " WRITE_COBJ_SUBTOTAL
*&---------------------------------------------------------------------*
*& Form WRITE_TOTALS
*&---------------------------------------------------------------------*
FORM WRITE_TOTALS.
WRITE: / SY-ULINE.
WRITE: / 'Total:' UNDER TEXT-008,
(13) TOTALS-MENGE UNDER TEXT-009, "Quantity
(13) TOTALS-GR UNDER TEXT-010, "GR quantity
(13) TOTALS-IR UNDER TEXT-011, "IR quantity
(13) TOTALS-ESTGRVAL UNDER TEXT-017, "Estimated GR Value
(13) TOTALS-IRVAL UNDER TEXT-013, "IR Value
(13) TOTALS-OUT UNDER TEXT-014, "Outstandng IR qty
(13) TOTALS-ESTOUTVAL UNDER TEXT-018. "Estimated Out IRva
ENDFORM. " WRITE_TOTALS
Friday, November 23, 2007
ABAP/4 Program: Outstanding PO Report
Labels:
Outstanding PO Report
Subscribe to:
Post Comments (Atom)
Blog Archive
-
▼
2007
(952)
-
▼
November
(716)
- SAP Paper Documents
- SAP Repository
- SAP R/3 Implementation and Maintenance Tips
- ABAP/4 programming language overview
- The interactive eLearning system for ABAP™
- Helpful System Administration ABAPS
- free download abap programmin pdf book
- examples of real time objects in sap abap(1)
- examples of real time objects in sap abap
- work flow example2
- Workflow tips
- Miscellaneous sap abap faq
- BDC , LSMW, Conversions faq in abap
- Sap Scripts & Smart forms faqs in abap
- performance tuning in abap faqs
- Real Time BDC & LSMW faqs
- Real Time ABAP Internal Tables faqs
- Real Time ABAP Reports faqs
- Real Time questions ..in sap ABAP
- SAP ABAP FAQ (Technical)
- ABAP and Unicode
- ABAP and JavaScript
- ABAP Objects
- ABAP Database Access
- Running ABAP Programs
- ABAP User Dialogs
- The ABAP Programming Language
- Creating and Changing ABAP Programs
- Overview of the Components of Application Programs
- Introduction to ABAP
- ABAP Programming Documentation
- FREE DOWNLOAD ALE, EDI & IDOCS
- Conversion of IDOCs to XML.pdf
- FREE DOWNLOAD IDOC Interface Technology
- FREE DOWNLOAD EDI, IDOC Interface
- FREE DOWNLOAD IDOC BOOK
- FREE DOWNLOAD LSMW - Idoc Inbound Processing
- FREE DOWNLOAD SAP ABAP Idoc Interface
- FREE DOWNLOAD Java for SAP
- FREE DOWNLOAD Java for ABAP Programmers
- FREE DOWNLOAD Java and BAPI technology for EP
- free download Building Web Services with Java and ...
- free download Enable SAP with the power of Javascript
- FREE DOWNLOAD ABAP Training Simulator
- FREE DOWNLOAD SAP Accounting Training Simulators
- free download SAPScripts Made Easy
- CONDENSE
- CONSTANTS
- ABAP Quick Viewer
- sap abap XXL (EXtended Export of Lists)
- Some ABAP/4 Query header line variable
- Understanding SAP Query
- ABAP/4 Query
- ABAP/4 Query Hints and Tips
- SAP Website Links Exchange for ABAP, Basis or Cons...
- sap abap Program for Generate IDoc
- sap abap program for Reads an existing Idoc and di...
- List of ABAP Function modules
- sap abap FTP programming
- sap abap program for Issuing an Unix Command from ...
- sap abap program for RFC call to get Server List
- sap abap program for A SAP Pop-out Calculator
- sap ABAP program for Timers and Auto-refresh
- sap abap program for WS_EXECUTE to called External...
- sap abap programming Execute DOS Command from ABAP...
- To execute a dos command from ABAP
- sap abap program for Make your SAPGUI Disappear an...
- sap abap program for Using Function Modules F4_FIL...
- abp program for How to Restrict the Select Options
- sap abap program for Take Values from Selection-Sc...
- sap abap program for Change Text Into Password
- sap abap program for Function Module for Encryptio...
- sap abap program for FM VRM_SET_VALUE To List Box
- sap abap program for Value Request For Parameter
- sap abap program for Pop a Message to specific SAP...
- ABAP Pop-out box for user confirmation
- sap ABAP program for POP-UP Window
- sap abap program Sample XML Source Code For SAP
- sap abap XML file to word document through SAP
- sap abap program for How to Write Web Reports in SAP
- sap abap conversion Program to Test Line Selection...
- sap abap program for String Handling in ABAP - Rem...
- sap abap program for Split String into two parts a...
- sap abap conversion Program For Printing Prime Number
- sap abap program for How can I get Ascii value of ...
- sap abap program for Figure to Words for India but...
- sap abap conversion program for Print Number Value...
- sap abap conversion program for Insert a special T...
- sap abap program for String Handling in ABAP - Rem...
- sap abap program for Split String into two parts a...
- sap abap conversion Program For Printing Prime Number
- sap abap program for How can I get Ascii value of ...
- sap abap program for Figure to Words for India but...
- sap abap conversion program for Print Number Value...
- sap abap conversion program for Insert a special T...
- sap abap program for Convert SAP Spool List to HTML
- sap program for Convert Month to Word in ABAP
- ABAP function to convert Number to Words
- sap abap program for How to Create Tree Control
- sap abap A sample Tree Programming
-
▼
November
(716)
No comments:
Post a Comment