Tips and Tricks for the ABAP® Programming Language
YPROD001 – Drilled down report for a selected material
For a given plant name it first display the material names available in the plant. You can then drill down for any material of this plant.
ABAP™-Source-Code
You can copy and paste the source code directly into the ABAP™-Workbench.
REPORT YPROD001 LINE-SIZE 250. "20010411, Release 1.0 * ********************** HEADER ************** * * Copyright (c) 1999 by xxxx xxx, 44318 Anywhere, http://xxxxx * or: Copyright (c) 1999 by X.X. from X. * * You can use or modify this report for your own work as long * as you don't try to sell or republish it. * In no event will the author be liable for indirect, special, * Incidental, or consequental damages (if any) arising out of * the use of this report. *//////////////////////////////////////////////////////////////////////* * Append your coding here ... *----------------------------------------------------------------------- * PROGRAM SPECIFICATION *---------------------------------------------------------------------- * Programmer Name : Kannan K * * * Report Title : Drilled down report for a selected material * * * Description : for a given plant name it first display the * material names available in the plant.you * can * click(hotspot) any material,you will be * displayed the list of production order * details(as secondary list) for the selected * material, with the push buttons where you * can * see the related purchase order or material * document or details of production order or * status of production order by clicking any * one of the push button. * *----------------------------------------------------------------------- INCLUDE <LIST>. TABLES:MSEG,MARD,AUFK,AFKO,AFPO,EKKO,EKPO,JEST,TJ02T. DATA F(30) TYPE C. SELECT-OPTIONS:PLANT FOR MARD-WERKS OBLIGATORY DEFAULT 'PL10'. START-OF-SELECTION. SET PF-STATUS 'BASIC'. *SET TITLEBAR 'BASIC'. FORMAT COLOR 6 INVERSE ON. WRITE: /3 'PLANT', 15 'MATERIAL'. FORMAT COLOR OFF INVERSE OFF. ULINE. SELECT * FROM MARD WHERE WERKS IN PLANT. FORMAT HOTSPOT ON. WRITE: /3 MARD-WERKS, 15 MARD-MATNR. HIDE:MARD-WERKS,MARD-MATNR. FORMAT HOTSPOT OFF. ENDSELECT. ULINE. END-OF-SELECTION. TOP-OF-PAGE. WRITE: 'LIST OF MATERIAL IN PLANT: ',MARD-WERKS. *HIDE:MARD-WERKS. ULINE. TOP-OF-PAGE DURING LINE-SELECTION. CASE SY-PFKEY. WHEN 'SCREEN1'. WRITE: 'DETAILS OF PRODUCTION ORDER FOR :',MARD-MATNR. *HIDE:MARD-MATNR. ULINE. FORMAT COLOR 6 INVERSE ON. WRITE: /1'ORD.NO', 20 'ORD.TYPE',40 'QUANTITY'.ULINE. FORMAT COLOR OFF INVERSE OFF. WHEN 'STATUS'. WRITE: 'STATUS OF PROD.ORD.NO : ',AFKO-AUFNR. ULINE. FORMAT COLOR 5 INVERSE ON. WRITE: /3 'STATUS',20 'DESCRIPTION'. FORMAT COLOR OFF INVERSE OFF.ULINE. WHEN 'SCREEN2'. WRITE:'DETAILS OF PRODUCTION ORDER: ',AFKO-AUFNR. ULINE. WHEN 'SCREEN3'. FORMAT COLOR 5 INVERSE ON. WRITE: 'DETAILS OF MATERIAL DOCUMENT FOR :',MARD-MATNR. ULINE.FORMAT COLOR OFF INVERSE OFF. WHEN 'SCREEN4'. WRITE: 'DETAILS OF MATERIAL DOCUMENT : ',MSEG-MBLNR. ULINE. WHEN 'NIT 5'. WRITE: 'DETAILS OF PURCHASE ORDER FOR : ',MARD-MATNR. ULINE. WHEN 'SCREEN 6'. WRITE: 'DETAILS OF PURCHASE ORDER : ',EKKO-EBELN. HIDE:EKKO-EBELN. ULINE. ENDCASE. AT USER-COMMAND. CASE SY-UCOMM. WHEN 'SEL1'. SET PF-STATUS 'SCREEN1'. *SET TITLEBAR 'SCREEN1'. SY-LSIND = 1. WINDOW STARTING AT 15 2 ENDING AT 80 15. SELECT * FROM AFPO WHERE DWERK = MARD-WERKS AND MATNR = MARD-MATNR. SELECT * FROM AFKO WHERE AUFNR = AFPO-AUFNR. * FORMAT HOTSPOT ON. WRITE: 1 AFKO-AUFNR COLOR 5 HOTSPOT ON. * FORMAT HOTSPOT OFF. WRITE: 20 AFPO-DAUAT, 40 AFKO-GAMNG LEFT-JUSTIFIED. HIDE: AFKO-AUFNR,AFPO-AUFNR,AFPO-DAUAT,AFKO-GAMNG. HIDE:AFPO-DWERK,AFPO-MATNR, MARD-WERKS,MARD-MATNR. SKIP. ENDSELECT. ENDSELECT. *IF SY-SUBRC NE 0.MESSAGE A235.ENDIF. IF SY-SUBRC NE 0. SKIP 3. FORMAT COLOR 5 INVERSE ON. ULINE AT /13(35). WRITE:/13 SY-VLINE,15 'PRODUCTION ORDER DOES NOT EXIST.', 47 SY-VLINE. ULINE AT /13(35). FORMAT COLOR OFF INVERSE OFF. ENDIF. WHEN 'DTLS'. SET PF-STATUS 'SCREEN2'. WINDOW STARTING AT 15 2 ENDING AT 80 15. GET CURSOR FIELD F. IF F = 'AFKO-AUFNR'. SELECT * FROM AFKO WHERE AUFNR = AFPO-AUFNR. FORMAT COLOR 5 INVERSE ON. WRITE: /1 'MATERIAL', 20 AFKO-PLNBEZ COLOR COL_TOTAL.SKIP. WRITE: /1 'QUANTITY', 20 AFKO-GAMNG LEFT-JUSTIFIED COLOR COL_TOTAL. SKIP. WRITE: /1 'MRP CONT', 20 AFKO-DISPO COLOR COL_TOTAL.SKIP. WRITE: /1 'PLANNER GRP',20 AFKO-PLGRP COLOR COL_TOTAL.SKIP. WRITE: /1 'ORD.START DT', 20 AFKO-GSTRP COLOR COL_TOTAL.SKIP. WRITE: /1 'ORD.FIN.DT',20 AFKO-GLTRP COLOR COL_TOTAL.SKIP. WRITE:/1 'INSP.LOT.NO',20 AFKO-PRUEFLOS COLOR COL_TOTAL.SKIP. WRITE: /1 'RESERVATION',20 AFKO-RSNUM COLOR COL_TOTAL.SKIP. WRITE: /1 'BOM STATUS',20 AFKO-STLST COLOR COL_TOTAL. FORMAT COLOR OFF INVERSE OFF. *HIDE:AFPO-AUFNR,AFKO-PLNBEZ,AFKO-GAMNG,AFKO-GSTRP,AFKO-AUFNR. ENDSELECT. ENDIF. WHEN 'STAT'. SET PF-STATUS 'STATUS'. WINDOW STARTING AT 15 2 ENDING AT 80 15. SELECT * FROM AUFK WHERE AUFNR = AFKO-AUFNR. SELECT * FROM JEST WHERE OBJNR = AUFK-OBJNR. SELECT * FROM TJ02T WHERE ISTAT = JEST-STAT AND SPRAS = 'E'. WRITE: /3 TJ02T-TXT04,20 TJ02T-TXT30. HIDE:TJ02T-TXT04,TJ02T-TXT30,AUFK-AUFNR,AFKO-AUFNR. ENDSELECT. ENDSELECT. ENDSELECT. ULINE. WHEN 'TRAN'. CALL TRANSACTION 'ZK44'. WHEN 'SEL2'. SET PF-STATUS 'SCREEN3'. WINDOW STARTING AT 15 2 ENDING AT 80 15. SY-LSIND = 1. FORMAT COLOR 5 INVERSE ON. WRITE: /1 'PLANT', 10 'PROD.ORD.NO',25 'MAT.DOC.NO'.ULINE. FORMAT COLOR OFF INVERSE OFF. SELECT * FROM MSEG WHERE WERKS = MARD-WERKS AND MATNR = MARD-MATNR. WRITE: /1 MSEG-WERKS,10 MSEG-AUFNR,40 MSEG-EBELN. FORMAT HOTSPOT ON. WRITE: 25 MSEG-MBLNR. FORMAT HOTSPOT OFF. HIDE:MSEG-WERKS,MSEG-AUFNR,MSEG-MBLNR,MSEG-EBELN. SKIP. ENDSELECT. IF SY-SUBRC NE 0. SKIP 3. FORMAT COLOR 6 INVERSE ON. ULINE AT /13(35). WRITE: /13 SY-VLINE,15'MATERIAL DOC. DOES NOT EXIST',47 SY-VLINE. ULINE AT /13(35). FORMAT COLOR OFF INVERSE OFF. ENDIF. WHEN 'DET'. SET PF-STATUS 'SCREEN4'. WINDOW STARTING AT 15 2 ENDING AT 80 15 . GET CURSOR FIELD F. IF F = 'MSEG-MBLNR'. FORMAT COLOR 5 INVERSE ON. WRITE: /1 'MATERIAL',15 'PUR.ORD.NO',30 'PROD.ORD.NO', 45 'MOV.TYPE',55 'QUANTITY'. FORMAT COLOR OFF INVERSE OFF. ULINE. SELECT * FROM MSEG WHERE MBLNR = MSEG-MBLNR. WRITE: /1 MSEG-MATNR,15 MSEG-EBELN,30 MSEG-AUFNR, 45 MSEG-BWART ,55 MSEG-MENGE LEFT-JUSTIFIED. SKIP. ENDSELECT. ULINE. WRITE:/1 'STOR.LOC ', 20 MSEG-LGORT COLOR COL_TOTAL.SKIP. WRITE:/1 'RESERVATION', 20 MSEG-RSNUM COLOR COL_TOTAL.SKIP. WRITE: /1 'G/L ACCOUNT',20 MSEG-SAKTO COLOR COL_TOTAL. SKIP. ENDIF. WHEN 'TR2'. CALL TRANSACTION 'MB02'. WHEN 'SEL3'. SET PF-STATUS 'NIT 5'. *SET TITLEBAR 'NIT5'. WINDOW STARTING AT 15 2 ENDING AT 80 15. SY-LSIND = 1. WRITE: /5 'PUR.ORD.NO',20 'DOC.TYPE',35 'CREATED ON',48 'CREATED BY'. ULINE. SELECT * FROM EKPO WHERE WERKS = MARD-WERKS AND MATNR = MARD-MATNR. SELECT * FROM EKKO WHERE EBELN = EKPO-EBELN. FORMAT COLOR 5 INVERSE ON. FORMAT HOTSPOT ON. WRITE: 5 EKKO-EBELN. FORMAT HOTSPOT OFF. WRITE: 20 EKKO-BSART,35 EKKO-AEDAT,48 EKKO-ERNAM. HIDE: EKPO-MENGE,EKKO-EBELN,EKKO-BSART,EKPO-MATNR, EKPO-WERKS,MARD-WERKS,MARD-MATNR. FORMAT COLOR OFF INVERSE OFF. SKIP. ENDSELECT. ENDSELECT. IF SY-SUBRC NE 0. SKIP 3. ULINE AT /13(35). FORMAT COLOR 6 INVERSE ON. WRITE: /13 SY-VLINE,15 'PURCHASE ORDER DOES NOT EXIST', 47 SY-VLINE. FORMAT COLOR OFF INVERSE OFF. ULINE AT /13(35). ENDIF. WHEN 'DE'. SET PF-STATUS 'SCREEN 6'. WINDOW STARTING AT 15 2 ENDING AT 80 15. GET CURSOR FIELD F. IF F = 'EKKO-EBELN'. FORMAT COLOR 6 INVERSE ON. WRITE: /1 'ITEM',15 'MATERIAL',25 'QUANTITY',40 'STO.LOC', 50 'MAT.TYPE'. FORMAT COLOR OFF INVERSE OFF. ULINE. SELECT * FROM EKPO WHERE EBELN = EKKO-EBELN. WRITE: /1 EKPO-EBELP,15 EKPO-MATNR,25 EKPO-MENGE LEFT-JUSTIFIED, 40 EKPO-LGORT,50 EKPO-MTART. HIDE:EKPO-EBELN,EKPO-EBELP,EKPO-MATNR,EKPO-MENGE,EKPO-LGORT, MARD-MATNR,MARD-WERKS. SKIP. ENDSELECT. ULINE. WRITE: /1 'PURCH.ORGANISATION',25 EKKO-EKORG COLOR COL_TOTAL. SKIP. WRITE: /1 'PURCHASING GROUP',25 EKKO-EKGRP COLOR COL_TOTAL. SKIP. WRITE: /1 'QUOTATION NO', 25 EKKO-ANGNR COLOR COL_TOTAL.SKIP. WRITE: /1 'CUSTOMER', 25 EKKO-KUNNR COLOR COL_TOTAL.SKIP. WRITE: /1 'ORDER VALUE',25 EKPO-NETWR LEFT-JUSTIFIED COLOR COL_TOTAL. SKIP. WRITE: /1 'P.R.NUMBER',25 EKPO-BANFN COLOR COL_TOTAL. SKIP. ENDIF. WHEN 'TR1'. CALL TRANSACTION 'ME22'. ENDCASE.