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
Saturday, October 18, 2008
Subscribe to:
Post Comments (Atom)
Archives
-
▼
2008
(139)
-
▼
October
(139)
- free download book on abap reporting on all modules
- Submit ABAP report with SQL traces
- SAP ABAP Commonly Asked Questions I
- Difference Between LIS, Reports, Abap Query
- SAP Some ABAP/4 Query header line variable
- SAP ABAP Quick Viewer
- SAP ABAP Proxy communication
- SAP ABAP/4 Program: Describe Select-Options
- SAP ABAP/4 Program: Output Table Fields to a List
- SAP ABAP/4 Program: Outstanding PO Report
- SAP ABAP/4 Program:Un/Lock all users in a client
- SAP ABAP/4 Program: Output Table Fields to a List
- SAP ABAP Program: Output of Date Format
- free download book on abap programming Tutorial
- SAP ABAP Programming Language
- free download BC-ABA pdf book SAP ABAP prog
- BC-ABA pdf free download SAP ABAP prog
- SAP ABAP Sample Test Questions on Programming
- SAP ABAP Programming Documentation
- SAP ABAP free download abap programming pdf book
- SAP ABAP The Employee Example - step by step example
- SAP Finding the user-exits of a SAP transaction code
- SAP A comparison between enhancement techniques
- SAP Toolbar Control Object
- SAP HTML Viewer Control
- Add Button to ALV Toolbar with REUSE_ALV_LIST_DISPLAY
- Interview Question on BAPI, RFC, ABAP Objects, Tables
- OBJECTS Tutorials PDF Free downloads
- Objective Questions
- MODEL PROGRAMS ON EVERY TOPIC
- sd tables structure
- Tables structure
- purchasing tables structures
- fico tables structure
- Project Systems tables structure
- Production Planning tables structures
- PM Tables
- system tables
- Classic pdf free download
- SAP ABAP List Viewer ALV
- SAP ABAP CONSTANTS
- SAP ABAP CONDENSE
- faqs SAP ABAP Interview Tips, Questions and Answers
- SAP ABAP interview questions
- SAP Answers to some ABAP Interview Questions
- SAP ABAP Interview Questions
- What types of tables can be created in the ABAP Di...
- More SAP ABAP Interview Faq's
- What types of objects can be created in the ABAP D...
- What is the difference between Pooled tables and C...
- What is the difference between Database tables and...
- What are the different types of Views? ABAP
- What is Table Maintenance Generator? ABAP
- Real Time SAP ABAP Internal Tables
- Real Time BDC & LSMW
- performance tuning
- ABAP TAW12 3/3 ABAP Workbench Concepts
- ABAP TAW12 2/3 ABAP Workbench Concepts
- ABAP TAW12 1/3 ABAP Workbench Concepts
- ABAP TAW10 2/2 ABAP Workbench Fundamental
- SAP ABAP TAW10 1/2 ABAP Workbench Fundamentals
- SAP ABAP Creating Extract Dataset
- all interview questions sap abap faqs
- SAP free download abap
- Important SAP ABAP FAQs
- ABAP FAQs
- FAQ In ABAP
- SAP ABAP Dialog Programming
- Will there always be an implicit commit in an RFC?
- Validating table fields in SAP ABAP
- SAP ABAP The difference between field groups and i...
- SAP ABAP Unicode check error fix
- SAP ABAP Creating a screen for grid display
- SAP ABAP Migrating test programs from ECC 4.6 to 6.0
- SAP ABAP Creating a field exit for a data element
- SAP ABAO Methods for uploading SAP data
- SAP ABAP Error when reading XML files
- SAP ABAP A parameter with no record available
- ABAP Adobe Document Services ADS
- Dictionary
- What is this new transaction 'n' all about?
- What does ABAP stand for?
- What does R/3 stands for ?
- How are RANGES different from SELECT-OPTIONS?
- How to convert a date to internal or external format?
- How do I download data in my internal table in a C...
- How can I get the IP address of the system program...
- How can I download my internal table into an Excel...
- How can I read an Excel file from presentation ser...
- How can I convert numerals into the corresponding ...
- I am using a SELECT query on a database table. Sin...
- Where are the long texts of a document stored and ...
- How do I create a long text for a document?
- How do I display / add the Terms and Conditions to...
- How to convert from one currency value to other?
- How to change the deadline of the workitem program...
- In SAP ABAP How to calculate last date of the month?
- How to do the EXCISE ANNEXURE10 report?
- SAP ABAP Class ALV
- SAP ABAP ALV Articles
-
▼
October
(139)
No comments:
Post a Comment