Extract Production Order with
status DLV - I0012 and TECO - I0045
* If DLV - I0012 it must be CNF - I0009
* Those with this status rejected DLT - I0013 DLFL - I0076
* Jobs with both status and no settlement will be display
REPORT ZXXXX NO STANDARD PAGE HEADING LINE-SIZE 150
LINE-COUNT 65(2) MESSAGE-ID Z1.
TABLES:
AFKO,
"Order header data PP orders
AFVC,
"Operation within an order
JEST,
"Object status
TJ02T,
"System status texts
AFPO,
"Order item
AFRU,
"Order completion confirmations
CRHD,
"Work Center Header
AUAK,
"Document Header for Settlement
AUAS.
"Settlement Document: Totals Segment
SELECT-OPTIONS: S_GSBER FOR AFPO-GSBER,
S_AUFNR FOR AFPO-AUFNR,
S_MATNR FOR AFKO-STLBEZ,
S_STAT FOR JEST-STAT DEFAULT 'I0012',
S_GSTRP FOR AFKO-GSTRP,
S_DISPO FOR AFKO-DISPO.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN BEGIN OF BLOCK BLK WITH FRAME TITLE TEXT-001.
SELECTION-SCREEN END OF BLOCK BLK.
DATA: X_STATUS(1),
X_CNF(1),
X_DLV(1),
W_STAT,
W_FLAG,
W_NEW,
W_STATUS(15),
OP_STATUS(15),
JOB_STATUS(15),
W_OBJNR(14),
W_PRODQTY LIKE AFPO-WEMNG.
FIELD-GROUPS: HEADER.
SELECT * FROM AFKO WHERE
DISPO IN S_DISPO
ORDER BY AUFNR.
CHECK S_MATNR.
CHECK S_GSTRP.
CONCATENATE 'OR' AFKO-AUFNR INTO W_OBJNR.
CLEAR AUAK.
SELECT SINGLE * FROM AUAK WHERE OBJNR = W_OBJNR.
* For checking
* write:/ 'objnr ', w_objnr, auak-perbz, sy-subrc.
IF AUAK-PERBZ = 'FUL' OR AUAK-PERBZ = 'GES'.
CONTINUE. ENDIF.
CLEAR: W_STAT, W_STATUS, W_FLAG, X_STATUS, X_DLV, X_CNF.
SELECT * FROM JEST WHERE
OBJNR = W_OBJNR AND
INACT = SPACE
ORDER BY OBJNR STAT.
IF JEST-STAT = 'I0013' OR
JEST-STAT = 'I0076'.
X_STATUS = 'X'.
ENDIF.
IF JEST-STAT = 'I0009'.
X_CNF = 'X'.
ENDIF.
IF JEST-STAT = 'I0012'.
X_DLV = 'X'.
ENDIF.
CHECK S_STAT.
PERFORM SUB_STATUS.
ENDSELECT.
IF X_DLV = 'X'. "DLV but final confirm CNF
IF X_CNF <> 'X'.
CONTINUE. ENDIF.
ENDIF.
IF X_STATUS = 'X'.
CONTINUE. ENDIF.
IF W_STATUS = SPACE.
CONTINUE. ENDIF.
SELECT SINGLE * FROM AFPO WHERE AUFNR = AFKO-AUFNR.
CHECK S_GSBER.
CHECK S_AUFNR.
MOVE W_STATUS TO JOB_STATUS.
CLEAR: W_NEW.
SELECT * FROM AFVC WHERE AUFPL = AFKO-AUFPL.
CLEAR: W_STATUS, W_FLAG.
SELECT * FROM JEST WHERE
OBJNR
= AFVC-OBJNR AND
INACT = SPACE.
PERFORM SUB_STATUS.
ENDSELECT.
CLEAR W_PRODQTY.
SELECT * FROM AFRU WHERE RUECK = AFVC-RUECK AND
STOKZ NE 'X' AND
STZHL EQ '0'.
W_PRODQTY = W_PRODQTY + AFRU-LMNGA.
ENDSELECT.
SELECT SINGLE * FROM CRHD WHERE OBJID = AFVC-ARBID.
IF JOB_STATUS = 'TECO'.
CHECK W_PRODQTY <> 0
AND
AFPO-WEMNG <> 0.
ENDIF.
IF W_NEW IS INITIAL.
W_STAT = '*'.
WRITE: /002 AFPO-GSBER,
008 AFKO-AUFNR,
020 AFPO-MATNR,
040 AFKO-GSTRP,
052 AFKO-GLTRP,
064 JOB_STATUS,
081 CRHD-ARBPL,
090 AFVC-VORNR,
"Oper
097(10) W_STATUS,
109(12) W_PRODQTY,
"Confirm Qty
123(12) AFKO-GAMNG,
"Order Qty
137(12) AFPO-WEMNG.
"Received Qty
ELSE.
WRITE: /081 AFVC-VORNR,
087 CRHD-ARBPL,
097(10) W_STATUS,
137(12) W_PRODQTY.
ENDIF.
ENDSELECT.
ENDSELECT.
FORM SUB_STATUS.
IF JEST-STAT = 'I0009'.
W_STAT = 'O'.
CONCATENATE 'CNF' W_STATUS INTO W_STATUS
SEPARATED BY SPACE.
ELSEIF JEST-STAT = 'I0010'.
W_STAT = 'O'.
CONCATENATE 'PCNF' W_STATUS INTO W_STATUS
SEPARATED BY SPACE.
ELSEIF JEST-STAT = 'I0012'.
W_STAT = 'X'.
CONCATENATE 'DLV' W_STATUS INTO W_STATUS
SEPARATED BY SPACE.
ELSEIF JEST-STAT = 'I0013'.
W_STAT = 'X'.
CONCATENATE 'DLT' W_STATUS INTO W_STATUS
SEPARATED BY SPACE.
ELSEIF JEST-STAT = 'I0045'.
W_STAT = 'X'.
CONCATENATE 'TECO' W_STATUS INTO W_STATUS
SEPARATED BY SPACE.
ELSEIF JEST-STAT = 'I0051'.
CONCATENATE 'MILE' W_STATUS INTO W_STATUS
SEPARATED BY SPACE.
ELSEIF JEST-STAT = 'I0074'.
W_STAT = 'O'.
CONCATENATE 'PDLV' W_STATUS INTO W_STATUS
SEPARATED BY SPACE.
ELSEIF JEST-STAT = 'I0076'.
W_STAT = 'O'.
CONCATENATE 'DLFL' W_STATUS INTO W_STATUS
SEPARATED BY SPACE.
ENDIF.
* For checking
* write:/ 'w_status ', w_status, caufv-aufnr.
ENDFORM.
TOP-OF-PAGE.
WRITE:/ SY-DATUM,SY-UZEIT,
120 'Page', SY-PAGNO.
WRITE: / SY-REPID,
58 'O R D E R D E
T A I L S'.
SKIP.
WRITE: / 'MRP Controller -', AFKO-DISPO.
SKIP.
ULINE.
WRITE: /002 'Plant',
008 'Order
No',
020 'Material',
040 'Order
Start',
052 'Order
End',
064 'Status',
081 'Work
Ctr',
090 'Op',
097 'Op
Status',
109 '
Confirm Qty',
123 '
Order Qty',
137 'Received
Qty'.
ULINE.
SKIP.
INITIALIZATION.
S_STAT-LOW = 'I0045'.
APPEND S_STAT.
More Function Module
Functions / SAP
Script / ALV
Tables
Database Table
ABAP Books List
ABAP/4 Certification,
Programming, Smartforms, Sapscripts and Object Oriented Programming Books
Smart Forms
SAP Smartforms
ABAP Menu:
ABAP Example Hints
and Tips
Return to Index:-
SAP ABAP/4 Programming,
Basis Administration, Configuration Hints and Tips
(c) www.gotothings.com All material on this site is Copyright.
Every effort is made to ensure the content integrity.
Information used on this site is at your own risk.
All product names are trademarks of their respective
companies. The site www.gotothings.com is in no way affiliated with
SAP AG.
Any unauthorised copying or mirroring is prohibited.
|