07-29-2007 1:44 PM
Hi,
Please help me out in generation of the below report with coding.
<b>A report, which displays the information about outstanding purchase orders.</b>
you can send your views to 'muraly.g@gmail.com'.
Thanks in advance.
-Muraly.
07-29-2007 2:50 PM
Hi muraly,
the information is stored in table EKES. Use SE16.
Regards,
Clemens
07-29-2007 3:17 PM
Outstanding PO's
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 < loekz =" '" loekz =" '" ebeln =" EKKOEBELN" compare =" 'A'." high =" MYEKPO-EBELN" low =" MYEKPO-EBELP." subrc =" 0." ebeln =" MYEKPO-EBELN" ebelp =" MYEKPO-EBELP."> ' '.
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 < gr =" 0" ir =" 0" ebeln =" MYEKPO-EBELN." ebelp =" MYEKPO-EBELP." menge =" MYEKPO-MENGE." txz01 =" MYEKPO-TXZ01." out =" OUTTAB-GR" outval =" OUTTAB-GRVAL" estgrval =" OUTTAB-GR" estoutval =" OUTTAB-ESTGRVAL"> ' '. "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