* ABAP/4 Report: Normal production order printing/two options
* By:lake
* Date:2002-10-22
***********************************************
* Amendments:
* Modify Person:
* Date Modified:
***********************************************
Report ypp012
No standard page heading
Message-id y001
Line-size "A4 width of the paper
Line-count 60 (3). "The length of each sheet of paper
Initialization.
Tables:afko, "Order header data pp order, AUFPL
Afpo, "Order items
AFVV, "db of number/date/value in operation"
AFVC, "Order of operations, Aufpl,arbid
RESB, "Reservation/related Requirements"
Makt, "Product description
CRHD, "Work Center table header, Arbid
Crtx. "Work center or Production resource/tool text
* Internal Table 1 Definition: Connection Two transparent table: AFKO,AFPO;
* Put the data associated with each production order
Data:begin of I_TAB1 occurs 0,
Dwerk like Afpo-dwerk, "factory
Matnr like Afpo-matnr, "item number
Charg like Afpo-charg, "batch
Aufnr like AFPO-AUFNR, "order number
Dispo like AFKO-DISPO, "MRP Controller
Ftrmi like Afko-ftrmi, "actual release date
Gltri like Afko-gltri, "actual End date
GLTRP like AFKO-GLTRP, "Basic finish date
Gamng like Afko-gamng, "number of plans
Gmein like Afko-gmein, "basic unit of measure
Plnnr like Afko-plnnr, "task List Group code
Plnal like Afko-plnal, "group counter
AUFPL like AFKO-AUFPL, "route number of the operation in the order
Stlal like Afko-stlal, "optional BOM
End of I_TAB1.
* Internal table 2 definition: Connection three tables: AFVV,AFVC,CRHD
* Production order--〉 by operation number, work center, (Job Center description)
* Plan number, production start date, production finish date
Data:begin of i_tab2 occurs 0,
AUFPL like AFVV-AUFPL, "route number of the operation in the order
Aplzl like Afvv-aplzl, "counter
Mgvrg like AFVV-MGVRG, "number of operations
Ssavd like AFVV-SSAVD, "latest scheduled start: execution
Ssedd like Afvv-ssedd, "latest Scheduled completion: execution
Arbid like Afvc-arbid, "object ID of the resource
Vornr like Afvc-vornr, "operation number
End of I_TAB2.
* For the internal table of the item, connect two transparent tables: RESB,MAKTX.
Data:begin of i_tab3 occurs 0,
Aufnr like RESB-AUFNR, "order number
AUFPL like RESB-AUFPL, "route number of the operation in the order
Aplzl like Resb-aplzl, "counter
Matnr like Resb-matnr, "item number
Bdmng like RESB-BDMNG, "demand
Meins like Resb-meins, "basic unit of measure
Maktx like MAKT-MAKTX, "material description
End of I_TAB3.
* Work center related data, connect two tables: Crhd,crtx.
Data:begin of I_TAB4 occurs 0,
ARBPL like CRHD-ARBPL, "work center
ObjID like Crhd-objid, "object ID of the resource
Ktext like Crtx-ktext, "short description
End of I_TAB4.
* Generate selection screen, get query condition input interface
Select-options s_1 for Afpo-dwerk "factory
Obligatory "parameter: set to Required fields
No intervals "Parameters: Single input box
No-extension "parameter: does not produce an extension icon
Default ' PL01 '. "Define default values
Select-options s_2 for AFKO-DISPO "MRP Controller
Obligatory "parameter: set to Required fields
No intervals "Parameters: Single input box
No-extension "parameter: does not produce an extension icon
Default ' 001 '. "Define default values
Select-options S_3 for AFKO-AUFNR. The production order
Select-options s_4 for Afpo-matnr "Product code
No intervals "Parameters: Single input box
No-extension. "Parameter: does not produce an extension icon
Select-options s_5 for Sy-datum "time range
Obligatory. "Parameter: Set to Required
Selection-screen begin of Block Rad1
With frame title text-001.
Parameters p_main RadioButton Group GR1. The production order
Parameters p_detail RadioButton Group GR1. "Production order operations, item details
Selection-screen end of Block Rad1.
* Determine if the order number and date range are both empty, and if yes, terminate the program run
* Because of the potential for large amounts of data access, resource problems arise.
At Selection-screen.
If S_3 = "and S_4 are initial and s_5 is initial.
Message e007.
endif.
Start-of-selection.
Perform get_data. "Get the data, the main process
If P_main = ' X '. "If the production order is output only
Perform output_data_m.
Else. "If the output details
Perform output_data. "Calling subroutine: output data detail
endif.
Top-of-page.
Perform pagetitle. "Call Header subroutine
If P_main = ' X '. "If the production order is output only
Perform output_tablehead_m. "Output Header
Else. "If the output details
Perform output_tablehead. "Calling subroutine: Displaying the header portion of the table
endif.
End-of-page.
Perform endpage. "Call Footer subroutine
*&---------------------------------------------------------------------*
*& Form PageTitle
*&---------------------------------------------------------------------*
* Output Header sub-program
*----------------------------------------------------------------------*
*-P1 text
* <--P2 text
*----------------------------------------------------------------------*
Form PageTitle.
Write:/3 ' qg/zn22.15.03-03-a ', 38 ' Zhongnan Aluminum Alloy Wheel Co., Ltd. ',
80 ' factory: ', S_1-low.
Write:/46 ' production order ', 80 ' No-gap, (4) Sy-pagno no-gap, ' page ' No-gap.
EndForm. "Show sub-programs for headers
*&---------------------------------------------------------------------*
*& Form EndPage
*&---------------------------------------------------------------------*
* Output Footer Sub-Program
*----------------------------------------------------------------------*
*-P1 text
* <--P2 text
*----------------------------------------------------------------------*
Form EndPage.
Uline.
Write:/3 ' Description: Key operations of the work center of the internal machine production planning detailed platoon ',
' Production according to ' process scheduling schedule ' requirements. '.
Write:/3 ' approved: ', 23 ' Audit: ', 43 ' planner: ', 63 ' Print Date: ', Sy-datum.
EndForm. "Show the footer of the sub-program
*&---------------------------------------------------------------------*
*& Form Get_data
*&---------------------------------------------------------------------*
* Get Data Sub-program
*----------------------------------------------------------------------*
*-P1 text
* <--P2 text
*----------------------------------------------------------------------*
Form Get_data.
* According to the input conditions, the data about the order is placed in the internal table I_TAB1
* Generate the data required for the header, connect two tables: Afko,afpo.
Select Afpo~dwerk Afpo~matnr afpo~charg
AFKO~AUFNR Afko~dispo Afko~ftrmi Afko~gltri
AFKO~GAMNG Afko~gmein Afko~plnnr afko~plnal
AFKO~AUFPL Afko~plnbez Afko~stlal AFKO~GLTRP
into corresponding fields of table I_TAB1
From Afko inner join Afpo on AFKO~AUFNR = Afpo~aufnr
where Afpo~dwerk in S_1 "factory
and Afko~dispo in S_2 "MRP Controller
and AFKO~AUFNR in S_3 "order number
and Afpo~matnr in S_4 "Product code
and Afko~ftrmi in S_5. "Time
* To determine if there is a qualifying order, no record on the error exit.
If SY-SUBRC <> 0.
Message e001.
endif.
* Connect two transparent tables: AFVV,AFVC; According to the route number of the internal table 1
* Put qualifying records into internal tables: I_TAB2; mainly process data
Select AFVV~AUFPL Afvv~aplzl afvv~mgvrg afvv~ssavd afvv~ssedd
Afvc~arbid Afvc~vornr
into corresponding fields of table I_TAB2
From AFVV INNER JOIN AFVC
On AFVV~AUFPL = AFVC~AUFPL and Afvv~aplzl = Afvc~aplzl
For all entries in I_TAB1
where AFVV~AUFPL = I_TAB1-AUFPL. "Conditions for the process in the internal table 1
Sort i_tab2 by AUFPL Aplzl. "Sort the I_TAB2
* Connecting two transparent tables: Resb,makt; According to the route number and counter of the internal table 2
* Put qualifying records in internal table: I_TAB3; mainly material data
Select Resb~aufnr Resb~matnr resb~bdmng resb~meins
RESB~AUFPL Resb~aplzl Resb~stlal Resb~vornr
Makt~maktx
into corresponding fields of table I_TAB3
From Resb INNER JOIN Makt
On resb~matnr = Makt~matnr
For all entries in I_TAB2
where RESB~AUFPL = I_TAB2-AUFPL
and Resb~aplzl = I_tab2-aplzl.
* Junction two transparent table: CRHD,CRTX; object ID of resource based on internal table 2
* Put qualifying records into internal tables: I_TAB4; data for work centers
Select CRHD~ARBPL Crhd~objid crtx~ktext
into corresponding fields of table I_TAB4
From CRHD INNER JOIN CRTX
On Crhd~objid = Crtx~objid
For all entries in I_TAB2
where Crhd~objid = I_tab2-arbid.
EndForm. The main program
*&---------------------------------------------------------------------*
*& Form Output_tablehead
*&---------------------------------------------------------------------*
* Output list Header
*----------------------------------------------------------------------*
*-P1 text
* <--P2 text
*----------------------------------------------------------------------*
Form Output_tablehead.
Write:/3 ' Product Code: ', i_tab1-matnr,31 ' status: ', i_tab1-charg,41
' Quantity: ', i_tab1-gamng left-justified decimals 0,
59 ' units: ', I_tab1-gmein,
' Production order number: ', I_tab1-aufnr.
Write:/3 ' Order start date: ', i_tab1-ftrmi,31
' Order completion date: ', i_tab1-gltri,70
' Route: ', I_tab1-plnnr, ' _ ', i_tab1-plnal.
Uline AT/2 (92).
Write:/2 sy-vline,
3 ' operation number ' color col_heading,
Ten Sy-vline,
11 ' work center ' color col_heading,
Sy-vline,
21 ' work center description ' Color col_heading,
Sy-vline,
46 ' plan number ' color col_heading,
Sy-vline,
60 ' production start date ' color col_heading,
Sy-vline,
78 ' Production finish date ' color col_heading,
Sy-vline.
Uline AT/2 (92).
EndForm. The Show Schedule header section
*&---------------------------------------------------------------------*
*& Form Output_data
*&---------------------------------------------------------------------*
* Output Work center detail data
*----------------------------------------------------------------------*
*-P1 text
* <--P2 text
*----------------------------------------------------------------------*
Form Output_data.
Sort I_tab1 by Aufnr. "Sort by order number I_TAB1
Loop at I_TAB1.
* The optional BOM is "DE"