Registration

Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
http://scn.sap.com
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata
 REPORT ZRGBPTR_PLANNED_VS_ACTUAL_V2
LINE-SIZE 295
NO STANDARD PAGE HEADING
MESSAGE-ID ZDEV.
.
* DESCRIPTION : This Report is to check the progress of *
* orders on that resource and also planned *
* orders on that resource. *
*======================================================================*
* CHANGE HISTORY LOG *
*----------------------------------------------------------------------*
* MOD. NO.| DATE | NAME | CORRECTION NUMBER | CHANGE REFERENCE #*
*----------------------------------------------------------------------*
* DESCRIPTION:Incorporated the changes for above TPR, To Restrict the *
* resource to be appeared twice in the same week *
*----------------------------------------------------------------------*
* DESCRIPTION:Incorporated the changes for above TPR, *
* extended the displayed area for the quantity and fiscal values up to *
* 8 digits to avoid the display of star when the value is bigger than *
* 6digits *
*----------------------------------------------------------------------*
* DESCRIPTION:Incorporated the changes for incident IM1749436 & *
* Displayed the Planned Order Number in the Report *
*----------------------------------------------------------------------*
* DESCRIPTION: Incorporated the changes for Printing and Downloading *
* the report output. Changes have been made to the *
* logic for KG conversion. The following fields have been *
* included on the selection screen--> *
* Production Scheduler *
* Selection Profile Status *
* Order Satus (With option for Exclusion) *
* And the corresponding logic *
*----------------------------------------------------------------------*
************************************************************************
* PROGRAM ID : /EUR/RGBPTN_PLANNED_VS_ACTUAL *
* PROGRAM TITLE : planned versus Actual Order Report *
* DEVELOPMENT ID : GDEVWR0001401 *
* CHANGE REQUEST NUMBER: RD2K902050 *
* DESCRIPTION : This Report is to check the progress of *
* orders on that resource and also planned *
* orders on that resource. *
* GLOBAL DATA DECLARATIONS *
*======================================================================*
* CHANGE HISTORY LOG: Write the Change History Log In Main Program *
* *
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Include /EUR/RGBPTN_PLANVSACT_TOP *
*&---------------------------------------------------------------------*
***************************************************************
* DATA DECLARATIONS
***************************************************************
*------------- Tables -----------------------------------------*
TABLES : CRHD, MARA, T134, T001W, T001K, AFKO, PLAF.
*--------------------constants--------------------------------*
CONSTANTS: C_X TYPE C VALUE 'X', "CheckValue
C_A TYPE C VALUE 'A', "WrkCenterType
C_101 TYPE BWART VALUE '101', "Mvmt Type 101
C_102 TYPE BWART VALUE '102', "Mvmt Type 102
C_KGM TYPE MEINS VALUE 'KG', "KG
C_NA(4) TYPE C VALUE 'N/A', "NotApplicable
C_DATE TYPE SY-DATUM VALUE '20031103', "Default Date
C_NULL(3) TYPE C VALUE '***', "NullValues
C_BT(2) TYPE C VALUE 'BT', "Between
C_BR1(3) TYPE C VALUE 'BR1', "Memory-ID
C_PAF(3) TYPE C VALUE 'PAF', "Memory-ID
C_TCODE(4) TYPE C VALUE 'COR3', "TranasCode
C_TCODE1(4) TYPE C VALUE 'MD13', "TranasCode
C_0 TYPE C VALUE '0',
C_1 TYPE C VALUE '1', "wkdy 1-Mon
C_2 TYPE C VALUE '2', "wkday 2-Tue
C_3 TYPE C VALUE '3', "wkday 3-Wed
C_4 TYPE C VALUE '4', "wkday 4-Thu
C_5 TYPE C VALUE '5', "wkday 5-Fri
C_6 TYPE C VALUE '6', "wkday 6-Sat
C_7 TYPE C VALUE '7', "wkday 7-Sun
C_MAIN(4) TYPE C VALUE 'MAIN', "PF Status
C_ORD(3) TYPE C VALUE 'ORD', "Order Unit
C_KG(6) TYPE C VALUE 'KGUNIT', "KG unit
C_FISC(4) TYPE C VALUE 'FISC', "Fiscal values
C_DET(3) TYPE C VALUE 'DET', "Detail
C_SUMM(4) TYPE C VALUE 'SUMM', "Summary
C_EXIT(4) TYPE C VALUE 'EXIT', "Exit
C_CANC(4) TYPE C VALUE 'CANC', "Cancel
C_LIST TYPE SYPLIST VALUE 'PLAN VS ACT' ,
C_156 TYPE SY-LINSZ VALUE '156',
*-----------------------BEGIN OF MOD-004-------------------------*
C_55 TYPE PRI_PARAMS-LINCT VALUE '55',
C_PRINT(3) TYPE C VALUE 'PRT',
C_DOWNLOAD(8) TYPE C VALUE 'DOWNLOAD',
C_LOCL(4) TYPE C VALUE 'LOCL',
C_SPACE TYPE C VALUE ' ',
C_PS_FILEPATH TYPE RLGRAP-FILENAME
VALUE 'C:\TEMP\PLANNED_VS_SAVED.PDF',
C_295 TYPE SY-LINSZ VALUE '295',
C_I TYPE C VALUE 'I' , "Include
C_EQ(2) TYPE C VALUE 'EQ',
C_40 TYPE AUFTYP VALUE 40,
C_100(3) TYPE C VALUE '100'.
*-----------------------END OF MOD-004---------------------------*
 
*------------- flag variables---------------------------------*
DATA: FLG_MATSEL(1) TYPE C, "flag for Material Selection
FLG_ORDSEL(1) TYPE C. "flag for order selection
* flg_stat(1) TYPE c, "flag for status
* flg_ind TYPE i,
* flg_print TYPE c VALUE ' '.
*------------- variables---------------------------------*
DATA: V_WAERS TYPE WAERS, "Currency Key
V_TEXT1 TYPE NAME1, "Name Of the Palnt
V_TEXT3(60) TYPE C, "Report Header String
V_MONDAY TYPE SY-DATUM, "Default Mon Date
V_SUNDAY TYPE SY-DATUM, "Default Sun Date
V_FMDAY TYPE SY-DATUM, "Variable To Hold Date
V_RTEXT TYPE CR_KTEXT. "Resource Description
RANGES: I_AUFNR_RANGE FOR AUFK-AUFNR.
 
*-----------------Type Definitions---------------------------*
TYPES: DIFFTYPE TYPE P DECIMALS 3,
DISPTYPE TYPE P DECIMALS 0.
*-------------------- Types ----------------------------------*
TYPES: BEGIN OF TYP_S_OBJNR,
AUFNR TYPE AUFNR,
* aufpl TYPE co_aufpl,
* aplfl TYPE plnfolge,
* plnfl TYPE plnfolge,
OBJNR TYPE J_OBJNR,
END OF TYP_S_OBJNR,
TYP_TS_AUFNR_OBJNR TYPE SORTED TABLE OF TYP_S_OBJNR
WITH NON-UNIQUE KEY AUFNR OBJNR,
TYP_TS_OBJNR TYPE SORTED TABLE OF TYP_S_OBJNR.
 
* Type for Materials Selection.
TYPES: BEGIN OF TY_MARA,
MATNR TYPE MATNR, "Material Number
MTART TYPE MTART, "Material Type
MEINS TYPE MEINS, "Unit of Measure
END OF TY_MARA.
*Types for Material Description
TYPES: BEGIN OF TY_MATDESC,
MATNR TYPE MATNR, "Material Number
MAKTX TYPE MAKTX, "Material Description
END OF TY_MATDESC.
*Type for Orders Selection
TYPES: BEGIN OF TY_CAUFV,
AUFNR TYPE CAUFV-AUFNR, "Order Number
OBJNR TYPE CAUFV-OBJNR, "Object Number
GLTRP TYPE CAUFV-GLTRP, "Basic Finish Date
GSTRP TYPE CAUFV-GSTRP, "Basic Start Date
GAMNG TYPE CAUFV-GAMNG, "Total Order Quantity
GMEIN TYPE CAUFV-GMEIN, "Unit of Measure
PLNBEZ TYPE CAUFV-PLNBEZ, "Material Number
AUFPL TYPE CAUFV-AUFPL, "Routing Number
END OF TY_CAUFV.
** Types for all phases of orders
TYPES: BEGIN OF TY_AFVV_AFVC,
AUFPL TYPE CO_AUFPL, "Routing Number
VORNR TYPE VORNR, "Operation Number
ARBID TYPE CR_OBJID, "Objid Of Resource
END OF TY_AFVV_AFVC.
** Types for Work Center Details
TYPES: BEGIN OF TY_CRHD,
OBJID TYPE CR_OBJID, "Objid Of Resource
ARBPL TYPE ARBPL, "WorkCenter
END OF TY_CRHD.
**Types for material document segment
TYPES: BEGIN OF TY_MSEG,
MBLNR TYPE MBLNR, "Document Number
MJAHR TYPE MJAHR, "Document Year
ZEILE TYPE MBLPO, "Counter
BWART TYPE BWART, "Movement Type
MATNR TYPE MATNR, "Material Number
AUFNR TYPE AUFNR, "Process Order Number
MENGE TYPE MENGE_D, "Quantity
MEINS TYPE MEINS, "UOM "MOD-003+
END OF TY_MSEG.
**Types for system Status
TYPES: BEGIN OF TY_TJ02T,
TXT04 TYPE J_TXT04, "Individual Status Of an Object
END OF TY_TJ02T.
**Types for Planned Orders.
TYPES: BEGIN OF TY_PLAF,
MATNR TYPE MATNR, "Material Number
PLNUM TYPE PLNUM, "Planned Order Number
VERID TYPE VERID, "Production Version
GSMNG TYPE GSMNG, "Total Planned Order Quantity
PEDTR TYPE PEDTR, "Order Finish Date
PERTR TYPE PERTR, "Planned Opening date
MEINS TYPE MEINS, " Unit of measure
END OF TY_PLAF.
**Types for Material Valuation
TYPES: BEGIN OF TY_PRICE,
MATNR TYPE MATNR, "MaterialNumber
STPRS TYPE STPRS, "Standard Price
PEINH TYPE PEINH, "Price Unit.
END OF TY_PRICE.
**Types For Production Versions
TYPES: BEGIN OF TY_MKAL,
MATNR TYPE MATNR, "MaterialNumber
MDV01 TYPE MDV01, "Production Line.
END OF TY_MKAL.
TYPES: BEGIN OF TY_STATUS_TMP,
STAT TYPE J_STATUS, "stat,
EXCL TYPE FLG_SEL,
END OF TY_STATUS_TMP.
TYPES: BEGIN OF TY_STAT,
SY_STAT TYPE J_STATUS, "stat,
END OF TY_STAT.
** Types for Final Orders
TYPES: BEGIN OF TY_FINALORD,
WDATE TYPE SYDATUM, "Week date
ARBPL TYPE ARBPL, "Resource /Work Center
MATNR TYPE MATNR, "material Number
AUFNR TYPE AUFNR, "process order Number
SPWOC TYPE SCAL-WEEK, "week day/period to analyze
MTART TYPE MTART, "Material Type
MAKTX TYPE MAKTX, "Material Description
GSTRP TYPE DATS, "Basic start date
GLTRP TYPE DATS, "Basic End Date
GAMNG TYPE DISPTYPE, "Planned quantity
MENGE TYPE DISPTYPE, "Actual Quantity
DIFF TYPE DISPTYPE, "Difference
MEINS TYPE MEINS, "Unit Of Mesaure
ZPLAN TYPE DISPTYPE, "KG planned qty
ZACT TYPE DISPTYPE, "KG actual qty
ZDIFF TYPE DISPTYPE, "KG diff
ZMEINS TYPE MEINS, "KG uom
FPLAN TYPE DISPTYPE, "Fiscal Planned Qty
FACT TYPE DISPTYPE, "Fiscal Actual Qty
FDIFF TYPE DISPTYPE, "Fiscal Difference
FCURR TYPE WAERS, "Fiscal Currency
WKDAY TYPE WEEK_DAY, "Week day
END OF TY_FINALORD.
** Types For Getting the week names.
TYPES: BEGIN OF TY_WKDAY,
WKDAY TYPE WEEK_DAY, "WeekDay
END OF TY_WKDAY.
** Types for week day material uom details,
TYPES: BEGIN OF TY_WEEK1,
SPWOC TYPE SPWOC, "Week
WKDAY TYPE WEEK_DAY, "Week Day
ARBPL TYPE ARBPL, "Resource
MATNR TYPE MATNR, "Material No
MEINS TYPE MEINS, "UOM
END OF TY_WEEK1.
* Types for week day resource uom details
TYPES: BEGIN OF TY_WEEK2,
SPWOC TYPE SPWOC, "Week
WKDAY TYPE WEEK_DAY, "Week Day
ARBPL TYPE ARBPL, "Resource
MEINS TYPE MEINS, "UOM
END OF TY_WEEK2.
* Types for week day uom details
TYPES: BEGIN OF TY_WEEK3,
SPWOC TYPE SPWOC, "Week
WKDAY TYPE WEEK_DAY, "Week Day
MEINS TYPE MEINS, "UOM
END OF TY_WEEK3.
TYPES: BEGIN OF TY_ORDER_STATUS,
AUFNR TYPE AUFNR,
ASTNR TYPE AUFASTNR,
END OF TY_ORDER_STATUS.
* Types for Weekly Report Details
TYPES: BEGIN OF TY_WEEKLY,
SPWOC TYPE SCAL-WEEK, "Week
ARBPL TYPE ARBPL, "Resource
MATNR TYPE MATNR, "Material Number
AUFNR TYPE AUFNR, "Order Number
MTART TYPE MTART, "Material Type
MAKTX TYPE MAKTX, "Material Description
MON_PLAN TYPE DISPTYPE, "Mon Planned Qty
MON_ACT TYPE DISPTYPE, "Mon Actual Qty
MON_DIFF TYPE DISPTYPE, "Mon Diff Qty
MON_PERC TYPE DISPTYPE, "Mon Perc
TUE_PLAN TYPE DISPTYPE, "Tue Planned
TUE_ACT TYPE DISPTYPE, "Tue Actual
TUE_DIFF TYPE DISPTYPE, "Tue Diff
TUE_PERC TYPE DISPTYPE, "Tue Percentage
WED_PLAN TYPE DISPTYPE, "Wed Planned
WED_ACT TYPE DISPTYPE, "Wed actual
WED_DIFF TYPE DISPTYPE, "Wed Diff
WED_PERC TYPE DISPTYPE, "Wed Perc
THU_PLAN TYPE DISPTYPE, "Thu Planned
THU_ACT TYPE DISPTYPE, "Thu actual
THU_DIFF TYPE DISPTYPE, "Thu Diff
THU_PERC TYPE DISPTYPE, "Thu Perc
FRI_PLAN TYPE DISPTYPE, "Fri Planned
FRI_ACT TYPE DISPTYPE, "Fri Actual
FRI_DIFF TYPE DISPTYPE, "Fri diff
FRI_PERC TYPE DISPTYPE, "Fri Perc
SAT_PLAN TYPE DISPTYPE, "Sat Planned
SAT_ACT TYPE DISPTYPE, "Sat Actual
SAT_DIFF TYPE DISPTYPE, "Sat Diff
SAT_PERC TYPE DISPTYPE, "Sat Perc
SUN_PLAN TYPE DISPTYPE, "Sun Plan
SUN_ACT TYPE DISPTYPE, "Sun Actual
SUN_DIFF TYPE DISPTYPE, "Sun Diff
SUN_PERC TYPE DISPTYPE, "Sun perc
TOT_PLAN TYPE DISPTYPE, "Tot planned
TOT_ACT TYPE DISPTYPE, "Total Actual
TOT_DIFF TYPE DISPTYPE, "Total Diff
TOT_PERC TYPE DISPTYPE, "Total Perc
MEINS TYPE MEINS, "UOM
WAERS TYPE WAERS, "Currency Key
END OF TY_WEEKLY.
 
*-------------------- Internal Tables ------------------------*
**Internal table for material Selection.
DATA: I_MARA TYPE STANDARD TABLE OF TY_MARA
INITIAL SIZE 0 WITH HEADER LINE.
**Internal table for Order Selection.
DATA: I_CAUFV TYPE STANDARD TABLE OF TY_CAUFV
INITIAL SIZE 0 WITH HEADER LINE.
**Internal table for all phases of data.
DATA: I_AFVV_AFVC TYPE STANDARD TABLE OF TY_AFVV_AFVC
INITIAL SIZE 0 WITH HEADER LINE.
**Internal table for order header data.
*DATA: i_tj02t TYPE STANDARD TABLE OF ty_tj02t
* INITIAL SIZE 0 WITH HEADER LINE.
**Internal table for planned Orders.
DATA: I_PLAF TYPE STANDARD TABLE OF TY_PLAF
INITIAL SIZE 0 WITH HEADER LINE.
**Internal Table Declaration for Production Versions of Material
DATA: I_MKAL TYPE STANDARD TABLE OF TY_MKAL
INITIAL SIZE 0 WITH HEADER LINE.
**Internal Table Declaation for final orders.
DATA: I_FINALORD TYPE STANDARD TABLE OF TY_FINALORD
INITIAL SIZE 0 WITH HEADER LINE.
**Internal Table Declartion for Work Center Details
DATA: I_CRHD TYPE STANDARD TABLE OF TY_CRHD
INITIAL SIZE 0 WITH HEADER LINE.
**Internal Table Declartion for Material document segemnt
DATA: I_MSEG TYPE STANDARD TABLE OF TY_MSEG
INITIAL SIZE 0 WITH HEADER LINE.
**Internal Table Declartion for WeekNames
DATA: I_WKDAY TYPE STANDARD TABLE OF TY_WKDAY
INITIAL SIZE 0 WITH HEADER LINE.
** Internal table to populate Week day resource material UOM details.
DATA: I_WEEK1 TYPE STANDARD TABLE OF TY_WEEK1
INITIAL SIZE 0 WITH HEADER LINE.
** internal table to populate week day resource uom details
DATA: I_WEEK2 TYPE STANDARD TABLE OF TY_WEEK2
INITIAL SIZE 0 WITH HEADER LINE.
**internal table to populate wekday uom Details.
DATA: I_WEEK3 TYPE STANDARD TABLE OF TY_WEEK3
INITIAL SIZE 0 WITH HEADER LINE.
**Internal Table Declaration for weekly report .
DATA: I_WEEKLY TYPE STANDARD TABLE OF TY_WEEKLY
INITIAL SIZE 0 WITH HEADER LINE.
**Internal Table Declaration for weekly report .
DATA: I_TEMP_WEEKLY TYPE STANDARD TABLE OF TY_WEEKLY
INITIAL SIZE 0 WITH HEADER LINE.
*DATA: i_stat TYPE STANDARD TABLE OF ty_stat INITIAL SIZE 0.
DATA: I_STATUS_HDR_TAB
TYPE STANDARD TABLE OF TY_STATUS_TMP
INITIAL SIZE 0
WITH HEADER LINE.
*DATA: i_order_stat TYPE STANDARD TABLE OF ty_order_status
* INITIAL SIZE 0.
**Work Area Declarations
DATA: REC_FINALORD TYPE TY_FINALORD,
REC_WEEKLY TYPE TY_WEEKLY,
REC_TEMP_WEEKLY TYPE TY_WEEKLY,
V_VALID TYPE C,
REC_OUT_PARAMS TYPE PRI_PARAMS.
* v_objid TYPE objec.
 
 
 
 
************************************************************************
* PROGRAM ID : /EUR/RGBPTN_PLANNED_VS_ACTUAL *
* PROGRAM TITLE : planned versus Actual Order Report *
* DEVELOPMENT ID : GDEVWR0001401 *
* CHANGE REQUEST NUMBER: RD2K902050 *
* DESCRIPTION : This Report is to check the progress of *
* orders on that resource and also planned *
* orders on that resource. *
* SELECTION SCREEN *
*======================================================================*
* CHANGE HISTORY LOG: Write the Change History Log In Main Program *
* *
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Include /EUR/RGBPTN_PLANVSACT_SEL *
*&---------------------------------------------------------------------*
************************************************************************
* SELECTION SCREEN
************************************************************************
*------------------Selection Criteria.---------------------------------*
DATA: V_FEVOR TYPE MARC-FEVOR.
SELECTION-SCREEN BEGIN OF BLOCK A WITH FRAME TITLE TEXT-001.
PARAMETERS: P_WERKS TYPE WERKS_D MEMORY ID WRK OBLIGATORY. "Plant
SELECT-OPTIONS: S_WCTR FOR CRHD-ARBPL MEMORY ID AGR
MATCHCODE OBJECT CRAM, "Resource
S_PRSCH FOR V_FEVOR MEMORY ID PRS,
S_DATE FOR SY-DATUM OBLIGATORY NO-EXTENSION .
PARAMETERS: P_NOW(4) TYPE N .
SELECT-OPTIONS: S_MTYPE FOR T134-MTART MEMORY ID MTA, "Material Type
S_MATNO FOR MARA-MATNR MEMORY ID MAT. "Material Number
SELECTION-SCREEN END OF BLOCK A.
*SELECT-OPTIONS: s_orstat FOR v_dummy
* MATCHCODE OBJECT /eur/rgbpte_ordstat.
*"Order Status
*----------------------BEGIN OF MOD-004-------------------------*
SELECTION-SCREEN BEGIN OF BLOCK D WITH FRAME TITLE TEXT-102.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN:
COMMENT 1(20) TEXT-101 FOR FIELD P_SYST1 MODIF ID FAU,
POSITION 33 .
PARAMETERS:
P_SYST1 TYPE J_TXT04 MODIF ID FAU,
P_SYSH1 TYPE J_STATUS NO-DISPLAY.
SELECTION-SCREEN:
POSITION 39 .
PARAMETERS:
CB_EXCL1 TYPE EXCL MODIF ID FAU.
SELECTION-SCREEN:
COMMENT 42(5) TEXT-099 FOR FIELD CB_EXCL1 MODIF ID FAU,
COMMENT 52(3) TEXT-100 FOR FIELD P_SYST2 MODIF ID FAU,
POSITION 58 .
PARAMETERS:
P_SYST2 TYPE J_TXT04 MODIF ID FAU,
P_SYSH2 TYPE J_STATUS NO-DISPLAY.
SELECTION-SCREEN:
POSITION 64 .
PARAMETERS:
CB_EXCL2 TYPE EXCL MODIF ID FAU.
SELECTION-SCREEN:
COMMENT 67(5) TEXT-099 FOR FIELD CB_EXCL2 MODIF ID FAU.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK D.
*----------------------END OF MOD-004--------------------------------*
*------------------ Display Options.---------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK B WITH FRAME TITLE TEXT-002.
PARAMETERS: CB_COLOR AS CHECKBOX DEFAULT C_X. "Colours
PARAMETERS: CB_PLAN AS CHECKBOX. "Planned Orders
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: RB_QUAN RADIOBUTTON GROUP GR2. "Quantities
SELECTION-SCREEN POSITION 15.
SELECTION-SCREEN COMMENT 15(20) TEXT-023 FOR FIELD RB_QUAN.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE .
SELECTION-SCREEN POSITION 5.
PARAMETERS: RB_ORD RADIOBUTTON GROUP GRP1. "Order Quantities
SELECTION-SCREEN COMMENT 10(14) TEXT-017 FOR FIELD RB_ORD.
PARAMETERS: RB_KGM RADIOBUTTON GROUP GRP1. "KG Quantities
SELECTION-SCREEN POSITION 30.
SELECTION-SCREEN COMMENT 30(20) TEXT-018 FOR FIELD RB_KGM.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: RB_FVAL RADIOBUTTON GROUP GR2. "Fiscal Values
SELECTION-SCREEN POSITION 15.
SELECTION-SCREEN COMMENT 15(20) TEXT-024 FOR FIELD RB_FVAL.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK B.
*-----------Report Type-----------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK C WITH FRAME TITLE TEXT-003.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: RB_WEEK RADIOBUTTON GROUP GR3. "Weekly Report
SELECTION-SCREEN POSITION 15.
SELECTION-SCREEN COMMENT 15(20) TEXT-021 FOR FIELD RB_WEEK.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE .
SELECTION-SCREEN POSITION 5.
PARAMETERS: RB_DET RADIOBUTTON GROUP GR4. "Summary Report
SELECTION-SCREEN COMMENT 10(10) TEXT-019 FOR FIELD RB_DET.
PARAMETERS: RB_SUM RADIOBUTTON GROUP GR4.
SELECTION-SCREEN POSITION 30.
SELECTION-SCREEN COMMENT 35(20) TEXT-020 FOR FIELD RB_SUM.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: RB_DAILY RADIOBUTTON GROUP GR3. "Daily Report
SELECTION-SCREEN POSITION 15.
SELECTION-SCREEN COMMENT 15(20) TEXT-022 FOR FIELD RB_DAILY.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK C.
 
** Top inlcude for Global Data Declarations
* INCLUDE /eur/rgbptn_planvsact_top.
** Top Include for Selection Screen
* INCLUDE /eur/rgbptn_planvsact_sel.
*------------- INITIALIZATION --------------------------------*
INITIALIZATION.
PERFORM FILL_DATES.
*------------- AT SELECTION-SCREEN ---------------------------*
AT SELECTION-SCREEN ON P_WERKS.
PERFORM VALIDATE_PLANT.
AT SELECTION-SCREEN ON S_WCTR.
IF NOT S_WCTR[] IS INITIAL.
PERFORM VALIDATE_WORKCENTER.
ENDIF.
AT SELECTION-SCREEN ON P_NOW.
PERFORM VALIDATE_WEEKS.
AT SELECTION-SCREEN ON S_MTYPE.
IF NOT S_MTYPE[] IS INITIAL.
PERFORM VALIDATE_MATERIAL_TYPE.
ENDIF.
AT SELECTION-SCREEN ON S_MATNO.
IF NOT S_MATNO[] IS INITIAL.
PERFORM VALIDATE_MATNO.
ENDIF.
AT SELECTION-SCREEN .
*----------------------BEGIN OF MOD-004-----------------------*
* Validate the Order Status
IF NOT P_SYST1 IS INITIAL.
PERFORM VALIDATE_ORDER_STATUS1.
ENDIF.
IF NOT P_SYST2 IS INITIAL.
PERFORM VALIDATE_ORDER_STATUS2.
ENDIF.
*----------------------END OF MOD-004-------------------------*
PERFORM DATE_VALIDATIONS.
IF NOT S_MTYPE[] IS INITIAL AND NOT S_MATNO[] IS INITIAL.
PERFORM VALIDATE_MATNR_MTART.
ENDIF.
*------------- START OF SELECTION ------------------------------------*
START-OF-SELECTION.
*----------------Set the GUI status -----------------------------------*
* The option for print and download has been added to the
* PF-STATUS c_main as a part of MOD-004
SET PF-STATUS C_MAIN.
PERFORM SELECT_MATERIALS.
*-------------------------BEGIN OF MOD-004-----------------------------*
* Check if there has been atleast one status text enetred on the
* Selection screen
IF NOT P_SYST1 IS INITIAL
OR NOT P_SYST2 IS INITIAL.
* Status Table
* Fill the status table with the system status corresponding to the
* Status texts entered by the user and the checkbox(Exclusion) status
PERFORM FILL_STATUS_TABLE
TABLES I_STATUS_HDR_TAB " Status Table
USING P_SYST1 " System Text1
CB_EXCL1 " Exclusion status for
" system text1
P_SYST2 " System Text2
CB_EXCL2. " Exclusion Status for
" system text2
ENDIF.
*-------------------------END OF MOD-004-------------------------------*
*------------ACTUAL ORDERS DATA RETRIEVAL-----------------------------*
*--------------------------BEGIN OF MOD-004----------------------------*
* PERFORM select_status.
* Select the Orders and filter them as per the Order status
* and the corresponding checkbox status in the status table
PERFORM CHECK_STATUS TABLES I_STATUS_HDR_TAB " Status Table
I_AUFNR_RANGE. " Useful range
" of Order Nos.
*---------------------------END OF MOD-004-----------------------------*
PERFORM SELECT_ACTUAL_ORDERS.
PERFORM SELECT_WORKCENTER_DETAILS.
PERFORM SELECT_DOCUMENT_SEGMENT_INFO. "From MSEG TABLE
PERFORM SELECT_FINALACTUAL_ORDERS.
*----------PLANNED ORDERS DATA RETRIEVAL-------------------------------*
IF CB_PLAN = C_X.
PERFORM SELECT_PLANNED_ORDERS.
PERFORM SELECT_PRODUCTION_VERSIONS. "Data from MKAL.
PERFORM SELECT_FINALPLANNED_ORDERS.
ENDIF.
IF I_FINALORD[] IS INITIAL.
MESSAGE S040. "No Orders found for Selection Criteria
LEAVE LIST-PROCESSING.
ENDIF.
*-------------------END OF SELECTION-----------------------------------*
END-OF-SELECTION.
* Report Header displayed only once based on client feedback
PERFORM DISPLAY_REPORT_HEADER.
IF RB_WEEK = C_X.
PERFORM MERGE_DATA.
PERFORM DISPLAY_WEEKLY_REPORT_MAIN.
PERFORM DISPLAY_REPORT_FOOTER.
ELSEIF RB_DAILY = C_X.
PERFORM DISPLAY_DAILY_REPORT.
PERFORM DISPLAY_REPORT_FOOTER.
ENDIF.
 
*-------------------TOP OF PAGE--------------------------------------*
* TOP-OF-PAGE event commented out based on client feedback.
* TOP-OF-PAGE
* PERFORM display_report_header.
*-------AT LINE SELECTION---------------------------------------------*
AT LINE-SELECTION.
IF RB_WEEK = C_X.
PERFORM DISPLAY_FLOW USING REC_WEEKLY-AUFNR.
ELSE.
PERFORM DISPLAY_FLOW USING REC_FINALORD-AUFNR.
ENDIF.
*------------AT USER COMMAND------------------------------------------*
AT USER-COMMAND.
CASE SY-UCOMM.
WHEN C_EXIT OR C_CANC. "Exit or Cancel
LEAVE LIST-PROCESSING.
WHEN C_ORD. "Order UoM
CLEAR: RB_KGM, RB_FVAL.
RB_ORD = C_X. RB_QUAN = C_X.
SY-LINSZ = C_295. "#EC *
PERFORM DISPLAY_REPORT_HEADER.
IF RB_WEEK = C_X.
PERFORM MERGE_DATA.
*--------------------------BEGIN OF MOD-004---------------------------*
PERFORM DISPLAY_WEEKLY_REPORT_MAIN.
*---------------------------END OF MOD-004----------------------------*
PERFORM DISPLAY_REPORT_FOOTER.
ELSE.
PERFORM DISPLAY_DAILY_REPORT.
PERFORM DISPLAY_REPORT_FOOTER.
ENDIF.
WHEN C_KG. "KG UoM
CLEAR: RB_ORD, RB_FVAL.
RB_KGM = C_X. RB_QUAN = C_X.
SY-LINSZ = C_295. "#EC *
PERFORM DISPLAY_REPORT_HEADER.
IF RB_WEEK = C_X.
PERFORM MERGE_DATA.
PERFORM CONVERT_UNIT_TO_KG.
*--------------------------BEGIN OF MOD-004---------------------------*
PERFORM DISPLAY_WEEKLY_REPORT_MAIN.
*---------------------------END OF MOD-004----------------------------*
PERFORM DISPLAY_REPORT_FOOTER.
ELSE.
*--------------------------BEGIN OF MOD-004---------------------------*
PERFORM CONVERT_UNIT_TO_KG.
*---------------------------END OF MOD-004----------------------------*
PERFORM DISPLAY_DAILY_REPORT.
PERFORM DISPLAY_REPORT_FOOTER.
ENDIF.
WHEN C_FISC. "Fiscal Values
CLEAR: RB_QUAN.
RB_FVAL = C_X.
SY-LINSZ = C_295. "#EC *
PERFORM DISPLAY_REPORT_HEADER.
IF RB_WEEK = C_X.
PERFORM MERGE_DATA.
*--------------------------BEGIN OF MOD-004---------------------------*
PERFORM DISPLAY_WEEKLY_REPORT_MAIN.
*---------------------------END OF MOD-004----------------------------*
PERFORM DISPLAY_REPORT_FOOTER.
ELSE.
PERFORM DISPLAY_DAILY_REPORT.
PERFORM DISPLAY_REPORT_FOOTER.
ENDIF.
WHEN C_DET. "Details
CLEAR : RB_SUM.
SY-LINSZ = C_295. "#EC *
IF RB_WEEK = C_X.
RB_DET = C_X.
PERFORM DISPLAY_REPORT_HEADER.
*--------------------------BEGIN OF MOD-004---------------------------*
PERFORM DISPLAY_WEEKLY_REPORT_MAIN.
*---------------------------END OF MOD-004----------------------------*
PERFORM DISPLAY_REPORT_FOOTER.
ELSE.
MESSAGE I045. "This Button works only for weekly report
ENDIF.
WHEN C_SUMM. "Summary
CLEAR: RB_DET.
SY-LINSZ = C_295. "#EC *
IF RB_WEEK = C_X.
RB_SUM = C_X.
PERFORM DISPLAY_REPORT_HEADER.
*--------------------------BEGIN OF MOD-004---------------------------*
PERFORM DISPLAY_WEEKLY_REPORT_MAIN.
*---------------------------END OF MOD-004----------------------------*
PERFORM DISPLAY_REPORT_FOOTER.
ELSE.
MESSAGE I045. "This Button works only for weekly report
ENDIF.
*--------------------------BEGIN OF MOD-004---------------------------*
* When the formatted print button is pressed
WHEN C_PRINT. "'PRT'
* Change the line size to get the output one page wide
SY-LINSZ = C_156. "#EC *
* Get the parameters for print
PERFORM GET_PRINT_PARAM CHANGING REC_OUT_PARAMS
V_VALID.
IF NOT V_VALID IS INITIAL.
PERFORM PRINT_ON USING REC_OUT_PARAMS
V_VALID.
* Display the Report Header
PERFORM DISPLAY_REPORT_HEADER.
* Display the Weekly Report
IF RB_WEEK = C_X.
PERFORM MERGE_DATA.
PERFORM DISPLAY_WEEKLY_REPORT.
PERFORM DISPLAY_REPORT_FOOTER.
* Display the daily Report
ELSEIF RB_DAILY = C_X.
PERFORM DISPLAY_DAILY_REPORT.
PERFORM DISPLAY_REPORT_FOOTER.
ENDIF.
ENDIF.
PERFORM PRINT_OFF.
* Whem the Download Button is pressed
WHEN C_DOWNLOAD. "'DOWNLOAD'
* Change the line size to get the output one page wide
SY-LINSZ = C_156. "#EC *
* Create a spool request to be passed on to the program 'RSTXPDFT4'
* to download the list as PDF
PERFORM CREATE_SPOOL.
* Download the list as PDF
PERFORM DOWNLOAD_TO_PDF.
* Delete the spool request created
PERFORM DELETE_SPOOL.
*---------------------------END OF MOD-004----------------------------*
ENDCASE.
 
**Include for Performs.
* INCLUDE /eur/rgbptn_planvsact_f01.
 
 
 
 
 
 
 
 
 
************************************************************************
* PROGRAM ID : /EUR/RGBPTN_PLANNED_VS_ACTUAL *
* PROGRAM TITLE : planned versus Actual Order Report *
* DEVELOPMENT ID : GDEVWR0001401 *
* CHANGE REQUEST NUMBER: RD2K902050 *
* DESCRIPTION : This Report is to check the progress of *
* orders on that resource and also planned *
* orders on that resource. *
* SUBROUTINES *
*======================================================================*
* CHANGE HISTORY LOG: Write the Change History Log In Main Program *
* *
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Include /EUR/RGTPTN_PLANVSACT_F01 *
*&---------------------------------------------------------------------*
 
*&---------------------------------------------------------------------*
*& FORM FILL_DATES
*&---------------------------------------------------------------------*
* Subroutine to fill default dates.
*----------------------------------------------------------------------*
FORM FILL_DATES .
DATA: L_DAYOFWEEK(1) TYPE C, "aux. day of week
L_AUXDATE TYPE DATS. "var to hold auxilary date.
CALL FUNCTION 'DATE_COMPUTE_DAY'
EXPORTING
DATE = SY-DATUM
IMPORTING
DAY = L_DAYOFWEEK.
L_AUXDATE = SY-DATUM + 1 - L_DAYOFWEEK.
S_DATE-LOW = L_AUXDATE.
S_DATE-HIGH = S_DATE-LOW + 6.
S_DATE-OPTION = C_BT.
S_DATE-SIGN = C_I.
APPEND S_DATE.
ENDFORM. " fill_dates
*&---------------------------------------------------------------------*
*& FORM VALIDATE_PLANT
*&---------------------------------------------------------------------*
* subroutine to validate_plant
*----------------------------------------------------------------------*
FORM VALIDATE_PLANT.
SELECT SINGLE NAME1 BWKEY
FROM T001W
INTO (V_TEXT1 , T001W-BWKEY)
WHERE WERKS = P_WERKS.
IF SY-SUBRC NE 0.
MESSAGE E001 WITH P_WERKS. "Enter a valid Plant
ELSE.
* Do Authority Check
* AUTHORITY-CHECK OBJECT 'C_AFKO_AWK'
* ID 'WERKS' FIELD P_WERKS
* ID 'AUFART' FIELD 'DUMMY'.
* IF SY-SUBRC <> 0.
* MESSAGE E035 WITH P_WERKS.
* "Authorization failed for displaying Process Orders in Plant
* ENDIF.
SELECT SINGLE BUKRS
FROM T001K
INTO T001K-BUKRS
WHERE BWKEY = T001W-BWKEY.
IF SY-SUBRC <> 0 OR T001K-BUKRS IS INITIAL.
MESSAGE E009 WITH T001W-BWKEY.
"No Company Code found for Valuation Area
ENDIF.
SELECT SINGLE WAERS
FROM T001
INTO V_WAERS
WHERE BUKRS = T001K-BUKRS.
IF SY-SUBRC <> 0 OR V_WAERS IS INITIAL.
MESSAGE E010 WITH T001K-BUKRS. "No Currency found for Company Code
ENDIF.
ENDIF.
ENDFORM. " Validate_plant
*&---------------------------------------------------------------------*
*& FORM VALIDATE_WORKCENTER
*&---------------------------------------------------------------------*
* subroutine to validate work center
*----------------------------------------------------------------------*
FORM VALIDATE_WORKCENTER.
SELECT ARBPL
UP TO 1 ROWS
FROM CRHD
INTO CRHD-ARBPL
WHERE ARBPL IN S_WCTR.
ENDSELECT.
IF SY-SUBRC <> 0.
MESSAGE E038. "Entered Resource is Invalid
ENDIF.
ENDFORM. " validate_workcenter
*&---------------------------------------------------------------------*
*& FORM VALIDATE_WEEKS
*&---------------------------------------------------------------------*
* subroutine to validate Number of weeks.
*----------------------------------------------------------------------*
FORM VALIDATE_WEEKS .
IF NOT S_DATE-LOW IS INITIAL
AND NOT S_DATE-HIGH IS INITIAL
AND NOT P_NOW IS INITIAL.
MESSAGE E043. "No Of Weeks Cannot be Entered
"As Date Range is Filled
ENDIF.
ENDFORM. " validate_weeks
*&---------------------------------------------------------------------*
*& FORM VALIDATE_MATERIAL_TYPE
*&---------------------------------------------------------------------*
* subroutine to validate material type
*----------------------------------------------------------------------*
FORM VALIDATE_MATERIAL_TYPE .
SELECT MTART
UP TO 1 ROWS
FROM T134
INTO T134-MTART
WHERE MTART IN S_MTYPE.
ENDSELECT.
IF SY-SUBRC <> 0.
MESSAGE E011. "Entered Material Type(s) is invalid
ENDIF.
ENDFORM. " validate_material_type
*&---------------------------------------------------------------------*
*& FORM VALIDATE_MATNO
*&---------------------------------------------------------------------*
* subroutine to validate material Number
*----------------------------------------------------------------------*
FORM VALIDATE_MATNO .
SELECT MATNR
UP TO 1 ROWS
FROM MARA
INTO MARA-MATNR
WHERE MATNR IN S_MATNO.
ENDSELECT.
IF SY-SUBRC <> 0.
MESSAGE E015. "Entered Material(s) is invalid
ENDIF.
ENDFORM. " validate_matno
 
*---------------------------BEGIN OF MOD-004---------------------------*
*&---------------------------------------------------------------------*
*& FORM VALIDATE_ORDER_STATUS
*&---------------------------------------------------------------------*
* subroutine to validate order status
*----------------------------------------------------------------------*
FORM VALIDATE_ORDER_STATUS1 .
* Declarations for local variables
DATA: L_V_SYST1 TYPE STRING,
L_V_TXT04 TYPE J_TXT04. "#EC *
L_V_SYST1 = P_SYST1.
* Function Module to convert the order status text
* to Upper case
CALL FUNCTION 'AIPC_CONVERT_TO_UPPERCASE'
EXPORTING
I_INPUT = L_V_SYST1 " Order text (Any Case)
I_LANGU = SY-LANGU " Language
IMPORTING
E_OUTPUT = L_V_SYST1. " Order text (Upper Case)
P_SYST1 = L_V_SYST1.
* Check if the text appears in tj02t (System status texts)
SELECT SINGLE TXT04 " System status text
INTO L_V_TXT04 "#EC *
FROM TJ02T " Table: System status texts
WHERE SPRAS = SY-LANGU
AND TXT04 = P_SYST1. " System Status
IF SY-SUBRC NE C_0.
* Entered Order Status is Invalid
MESSAGE E039.
ENDIF.
ENDFORM. " validate_order_status
*--------------------------END OF MOD-004------------------------------*
*&---------------------------------------------------------------------*
*& FORM DATE_VALIDATIONS
*&---------------------------------------------------------------------*
* subroutine for date validations
*----------------------------------------------------------------------*
FORM DATE_VALIDATIONS .
IF S_DATE-HIGH IS INITIAL AND
P_NOW IS INITIAL.
REFRESH S_DATE.
S_DATE-HIGH = S_DATE-LOW + 6.
S_DATE-SIGN = C_I.
S_DATE-OPTION = C_BT.
APPEND S_DATE.
MESSAGE W044. "Date Range is Defaulted to 1 week
ELSE.
IF S_DATE-HIGH IS INITIAL AND
NOT P_NOW IS INITIAL.
REFRESH S_DATE.
S_DATE-HIGH = S_DATE-LOW + ( 7 * P_NOW ) - 1.
S_DATE-SIGN = C_I.
S_DATE-OPTION = C_BT.
APPEND S_DATE.
ENDIF.
ENDIF.
ENDFORM. " DATE_VALIDATIONS
*&---------------------------------------------------------------------*
*& FORM VALIDTAE_MATNR_MTART
*&---------------------------------------------------------------------*
* subroutine to validate material number and material type
*----------------------------------------------------------------------*
FORM VALIDATE_MATNR_MTART .
SELECT MTART UP TO 1 ROWS
FROM MARA
INTO MARA-MTART
WHERE MATNR IN S_MATNO
AND MTART IN S_MTYPE.
ENDSELECT.
IF SY-SUBRC <> 0.
MESSAGE E033. "Invalid Material for the Material type
ENDIF.
ENDFORM. " validate_matnr_mtart
*&---------------------------------------------------------------------*
*& FORM SELECT_MATERIALS
*&---------------------------------------------------------------------*
* subroutine to select materials
*----------------------------------------------------------------------*
FORM SELECT_MATERIALS .
CLEAR FLG_MATSEL.
SELECT MATNR
MTART
MEINS
FROM MARA
INTO TABLE I_MARA
WHERE MATNR IN S_MATNO
AND MTART IN S_MTYPE.
* Sy-subrc will not fail here. Validations have been done before
IF SY-SUBRC = 0.
FLG_MATSEL = C_X.
SORT I_MARA BY MATNR.
ENDIF.
ENDFORM. " select_materials
*&---------------------------------------------------------------------*
*& FORM SELECT_ACTUAL_ORDERS
*&---------------------------------------------------------------------*
* subroutine to select actual orders
*----------------------------------------------------------------------*
FORM SELECT_ACTUAL_ORDERS .
REFRESH: I_CAUFV, I_AFVV_AFVC.
CLEAR: I_CAUFV, I_AFVV_AFVC.
IF FLG_MATSEL IS INITIAL.
SELECT AUFNR
OBJNR
GLTRP
GSTRP
GAMNG
GMEIN
PLNBEZ
AUFPL
FROM CAUFV
INTO TABLE I_CAUFV
*--------------BEGIN OF MOD-004-------------*
WHERE AUFNR IN I_AUFNR_RANGE
*---------------END OF MOD-004--------------*
AND WERKS = P_WERKS
AND GSTRP IN S_DATE
*--------------BEGIN OF MOD-004-------------*
AND FEVOR IN S_PRSCH.
*---------------END OF MOD-004--------------*
ELSE.
SELECT AUFNR
OBJNR
GLTRP
GSTRP
GAMNG
GMEIN
PLNBEZ
AUFPL
INTO TABLE I_CAUFV
FROM CAUFV
FOR ALL ENTRIES IN I_MARA
*--------------BEGIN OF MOD-004-------------*
WHERE AUFNR IN I_AUFNR_RANGE
*---------------END OF MOD-004--------------*
AND PLNBEZ = I_MARA-MATNR
AND WERKS = P_WERKS
AND GSTRP IN S_DATE
*--------------BEGIN OF MOD-004-------------*
AND FEVOR IN S_PRSCH.
*---------------END OF MOD-004--------------*
ENDIF.
IF SY-SUBRC = 0.
SORT I_CAUFV BY AUFNR.
ENDIF.
IF NOT I_CAUFV[] IS INITIAL.
SELECT AFVC~AUFPL
AFVC~VORNR
AFVC~ARBID
INTO TABLE I_AFVV_AFVC
FROM AFVC JOIN AFVV
ON AFVC~AUFPL = AFVV~AUFPL
FOR ALL ENTRIES IN I_CAUFV
WHERE AFVC~AUFPL = I_CAUFV-AUFPL
AND AFVC~PHFLG = C_X.
IF SY-SUBRC = 0.
SORT I_AFVV_AFVC BY AUFPL ASCENDING VORNR DESCENDING.
ENDIF.
ENDIF.
ENDFORM. " select_actual_orders
 
*-----------------------BEGIN OF MOD-004------------------------------*
**&---------------------------------------------------------------------
*
**& FORM SELECT_STATUS
**&---------------------------------------------------------------------
*
** subroutine to retrieve System status texts from table TJ02T
**----------------------------------------------------------------------
*
*FORM select_status .
* REFRESH i_tj02t.
* CLEAR i_tj02t.
*
* IF NOT s_orstat[] IS INITIAL.
* SELECT txt04
* FROM tj02t INTO TABLE i_tj02t
* WHERE spras = sy-langu
* AND txt04 IN s_orstat.
*
* IF sy-subrc = 0.
* SORT i_tj02t BY txt04.
* DELETE ADJACENT DUPLICATES FROM i_tj02t COMPARING txt04.
* ENDIF.
* ENDIF.
*ENDFORM. " select_status
*------------------------END OF MOD-004-------------------------------*
 
*&---------------------------------------------------------------------*
*& FORM SELECT_WORKCENTER_DETAILS
*&---------------------------------------------------------------------*
* subroutine to get work center details
*----------------------------------------------------------------------*
FORM SELECT_WORKCENTER_DETAILS .
SELECT OBJID
ARBPL
FROM CRHD
INTO TABLE I_CRHD
WHERE OBJTY = C_A
AND WERKS = P_WERKS
AND ARBPL IN S_WCTR.
IF SY-SUBRC = 0.
SORT I_CRHD BY OBJID.
ENDIF.
ENDFORM. " select_workcenter_details
*&---------------------------------------------------------------------*
*& FORM SELECT_DOCUMENT_SEGMENT_INFO *
*&---------------------------------------------------------------------*
* Subroutine to get the document segment information for a material *
*----------------------------------------------------------------------*
FORM SELECT_DOCUMENT_SEGMENT_INFO .
CHECK NOT I_CAUFV[] IS INITIAL.
SELECT MBLNR
MJAHR
ZEILE
BWART
MATNR
AUFNR
MENGE
MEINS "MOD-003++
FROM MSEG
INTO TABLE I_MSEG
FOR ALL ENTRIES IN I_CAUFV
WHERE BWART IN (C_101 , C_102)
AND MATNR = I_CAUFV-PLNBEZ
AND AUFNR = I_CAUFV-AUFNR.
IF SY-SUBRC = 0.
SORT I_MSEG BY MATNR AUFNR.
ENDIF.
ENDFORM. " select_document_segment_info
*&---------------------------------------------------------------------*
*& FORM SELECT_FINALACTUAL_ORDERS
*&---------------------------------------------------------------------*
* Subroutine to get the final actual orders
*----------------------------------------------------------------------*
FORM SELECT_FINALACTUAL_ORDERS .
DATA: L_BASEQTY TYPE GAMNG,
L_PRICE TYPE STPRS,
L_UOM TYPE MEINS. "MOD-003++
LOOP AT I_CAUFV.
* IF NOT i_tj02t[] IS INITIAL.
** CLEAR flg_stat.
** PERFORM get_status_info USING i_caufv-objnr l_stext.
** LOOP AT i_tj02t.
** IF l_stext NS i_tj02t-txt04.
** flg_stat = c_x.
** EXIT.
** ENDIF.
** ENDLOOP.
** IF flg_stat = c_x.
** CONTINUE.
** ENDIF.
* ENDIF.
 
CLEAR FLG_ORDSEL.
LOOP AT I_AFVV_AFVC WHERE AUFPL = I_CAUFV-AUFPL.
READ TABLE I_CRHD WITH KEY OBJID = I_AFVV_AFVC-ARBID
BINARY SEARCH.
IF SY-SUBRC = 0.
FLG_ORDSEL = C_X.
EXIT.
ENDIF.
ENDLOOP.
IF FLG_ORDSEL IS INITIAL.
CONTINUE.
ENDIF.
*---Move the required data into internal table i_finalord
CLEAR I_FINALORD.
MOVE: I_CRHD-ARBPL TO I_FINALORD-ARBPL, "RESOURCE
I_CAUFV-PLNBEZ TO I_FINALORD-MATNR, "Material Number
I_CAUFV-GSTRP TO I_FINALORD-GSTRP, "Basic start date
I_CAUFV-GLTRP TO I_FINALORD-GLTRP, "Basic End date
I_CAUFV-GLTRP TO I_FINALORD-WDATE, " Activity Date
I_CAUFV-AUFNR TO I_FINALORD-AUFNR, "Process Order No
I_CAUFV-GAMNG TO I_FINALORD-GAMNG, "Planned Quantity
I_CAUFV-GMEIN TO I_FINALORD-MEINS, "Unit of measure
C_KGM TO I_FINALORD-ZMEINS,"KG Conversion
V_WAERS TO I_FINALORD-FCURR. "Currency
*----Get the Material Description
PERFORM GET_MATDESC USING I_FINALORD-MATNR
CHANGING I_FINALORD-MAKTX.
*----Get the Dayname
PERFORM GET_DAYNAME USING I_FINALORD-GLTRP
CHANGING I_FINALORD-WKDAY."Week Day
*----Get the Week
PERFORM GET_WEEK USING I_FINALORD-GLTRP
CHANGING I_FINALORD-SPWOC."Week
*---Get the ACTUAL Quantity(menge) from mseg.
CLEAR L_UOM. "MOD-003++
* PERFORM get_actual_qauntites. "MOD-003--
PERFORM GET_ACTUAL_QAUNTITES CHANGING L_UOM. "MOD-003++
**BEGIN OF MOD-003
IF L_UOM <> SPACE AND
I_FINALORD-MEINS <> L_UOM.
PERFORM CONVERT_QUANTITY USING I_FINALORD-MATNR
L_UOM
I_FINALORD-MENGE
I_FINALORD-MEINS
CHANGING I_FINALORD-MENGE.
ENDIF.
** END OF MOD-003
*---Quantitity Conversions: Convert Actual quantity.
PERFORM CONVERT_QUANTITY USING I_FINALORD-MATNR
I_FINALORD-MEINS
I_FINALORD-MENGE
I_FINALORD-ZMEINS
CHANGING I_FINALORD-ZACT.
*---Qunatitiy conversions: Convert Planned Quantity.
PERFORM CONVERT_QUANTITY USING I_FINALORD-MATNR
I_FINALORD-MEINS
I_FINALORD-GAMNG
I_FINALORD-ZMEINS
CHANGING I_FINALORD-ZPLAN.
*----Calculate the costs---------------------------*
READ TABLE I_MARA WITH KEY MATNR = I_FINALORD-MATNR BINARY SEARCH.
IF SY-SUBRC = 0.
*---Get the Material Description-------------------*
MOVE I_MARA-MTART TO I_FINALORD-MTART.
*----Get the Price
CLEAR L_PRICE.
PERFORM GET_PRICE USING I_FINALORD-MATNR
P_WERKS
CHANGING L_PRICE.
*---Qunatitiy conversions: Convert Planned Quantity.
CLEAR L_BASEQTY.
PERFORM CONVERT_QUANTITY USING I_FINALORD-MATNR
I_FINALORD-MEINS
I_FINALORD-GAMNG
I_MARA-MEINS
CHANGING L_BASEQTY.
I_FINALORD-FPLAN = L_BASEQTY * L_PRICE.
CLEAR L_BASEQTY.
*---Qunatitiy conversions: Convert Actual Quantity.
PERFORM CONVERT_QUANTITY USING I_FINALORD-MATNR
I_FINALORD-MEINS
I_FINALORD-MENGE
I_MARA-MEINS
CHANGING L_BASEQTY.
I_FINALORD-FACT = L_BASEQTY * L_PRICE.
ENDIF.
*---Calculate the differences
PERFORM CALCULATE_DIFFERENCES.
APPEND I_FINALORD.
ENDLOOP.
*--Sort the Internal table i_finalord By wdate reosource matno and aufnr
SORT I_FINALORD BY WDATE ARBPL MATNR AUFNR.
ENDFORM. " select_finalactual_orders
 
*-----------------------BEGIN OF MOD-004---------------------------*
**&---------------------------------------------------------------------
**& Form GET_STATUS_INFO
**&---------------------------------------------------------------------
*
** Subroutine to retrieve the status information
**----------------------------------------------------------------------
*
** -->P_I_CAUFV_OBJID text
** -->P_L_STEXT text
**----------------------------------------------------------------------
*
*FORM get_status_info USING p_i_caufv_objid
* p_l_stext.
*
* DATA: l_text(4) TYPE c,
* l_stsma TYPE j_stsma,
* l_i_status TYPE STANDARD TABLE OF jstat WITH HEADER LINE.
*
* REFRESH l_i_status.
* CLEAR: p_l_stext.
*
**--Read Object Status
* CALL FUNCTION 'STATUS_READ'
* EXPORTING
* objnr = p_i_caufv_objid
* only_active = c_x
* IMPORTING
* stsma = l_stsma
* TABLES
* status = l_i_status.
*
* LOOP AT l_i_status.
**--Status number conversion
* CALL FUNCTION 'STATUS_NUMBER_CONVERSION'
* EXPORTING
* language = sy-langu
* status_number = l_i_status-stat
* stsma = l_stsma
* IMPORTING
* txt04 = l_text.
*
* CONCATENATE p_l_stext l_text INTO p_l_stext.
* ENDLOOP.
*
*ENDFORM. " GET_STATUS_INFO
*---------------------END OF MOD-004------------------------------*
 
*&---------------------------------------------------------------------*
*& FORM SELECT_PLANNED_ORDERS.
*&---------------------------------------------------------------------*
* Subroutine for selecting planned orders
*----------------------------------------------------------------------*
FORM SELECT_PLANNED_ORDERS.
** Check for the matsel flag
** If it is initial retrieve the records
** From plaf based on plant and start date
** Else Retrieve the records from plaf based
** Material Number and plant and stat date
IF FLG_MATSEL IS INITIAL.
SELECT MATNR
* aufnr "Mod-003--
PLNUM "Mod-003++
VERID
GSMNG
PEDTR
PERTR
MEINS
FROM PLAF
INTO TABLE I_PLAF
WHERE PLWRK = P_WERKS
AND PERTR IN S_DATE.
ELSE.
SELECT MATNR
* aufnr "Mod-003--
PLNUM "Mod-003++
VERID
GSMNG
PEDTR
PERTR
MEINS
INTO TABLE I_PLAF
FROM PLAF
FOR ALL ENTRIES IN I_MARA
WHERE MATNR = I_MARA-MATNR
AND PLWRK = P_WERKS
AND PERTR IN S_DATE.
ENDIF.
IF SY-SUBRC = 0.
SORT I_PLAF BY MATNR VERID.
ENDIF.
ENDFORM. " select_planned_orders
*&---------------------------------------------------------------------*
*& FORM SELECT_PRODUCTION_VERSIONS
*&---------------------------------------------------------------------*
* subroutine to select production versions
*----------------------------------------------------------------------*
FORM SELECT_PRODUCTION_VERSIONS .
**Check the internal table i_plaf
CHECK NOT I_PLAF[] IS INITIAL.
**If it is not initial Select the records from
**mkal(Production Vesrions)
SELECT MATNR
MDV01
INTO TABLE I_MKAL
FROM MKAL
FOR ALL ENTRIES IN I_PLAF
WHERE MATNR = I_PLAF-MATNR
AND WERKS = P_WERKS
AND VERID = I_PLAF-VERID
AND MDV01 IN S_WCTR[].
IF SY-SUBRC = 0.
SORT I_MKAL BY MATNR.
ENDIF.
ENDFORM. " select_production_versions
*&---------------------------------------------------------------------*
*& Form SELECT_FINALPLANNED_ORDERS
*&---------------------------------------------------------------------*
* subroutine to select final planned orders
*----------------------------------------------------------------------*
FORM SELECT_FINALPLANNED_ORDERS .
DATA: L_BASEQTY TYPE GAMNG,
L_PRICE TYPE STPRS.
 
LOOP AT I_PLAF.
READ TABLE I_MKAL WITH KEY MATNR = I_PLAF-MATNR BINARY SEARCH.
IF SY-SUBRC = 0.
CLEAR I_FINALORD.
**Move the corresponding records from i_plaf to i_finalord
MOVE: I_PLAF-MATNR TO I_FINALORD-MATNR,
I_PLAF-PLNUM TO I_FINALORD-AUFNR,
I_PLAF-PEDTR TO I_FINALORD-GLTRP,
I_PLAF-PERTR TO I_FINALORD-GSTRP,
I_PLAF-PEDTR TO I_FINALORD-WDATE,
I_PLAF-GSMNG TO I_FINALORD-GAMNG,
I_PLAF-MEINS TO I_FINALORD-MEINS,
C_KGM TO I_FINALORD-ZMEINS,
V_WAERS TO I_FINALORD-FCURR.
IF I_MKAL-MDV01 = SPACE.
MOVE: TEXT-092 TO I_FINALORD-ARBPL.
ELSE.
MOVE: I_MKAL-MDV01 TO I_FINALORD-ARBPL.
ENDIF.
*----Get the Material Description
PERFORM GET_MATDESC USING I_FINALORD-MATNR
CHANGING I_FINALORD-MAKTX."material desc
*----Get the Day Name
PERFORM GET_DAYNAME USING I_FINALORD-GLTRP
CHANGING I_FINALORD-WKDAY."Week Day
*----Get the Week
PERFORM GET_WEEK USING I_FINALORD-GLTRP
CHANGING I_FINALORD-SPWOC."Week
*---Qunatitiy conversions: Convert Planned Quantity
PERFORM CONVERT_QUANTITY USING I_FINALORD-MATNR
I_FINALORD-MEINS
I_FINALORD-GAMNG
I_FINALORD-ZMEINS
CHANGING I_FINALORD-ZPLAN.
*----Calculate the costs
READ TABLE I_MARA WITH KEY MATNR = I_FINALORD-MATNR BINARY SEARCH.
IF SY-SUBRC = 0.
MOVE I_MARA-MTART TO I_FINALORD-MTART.
CLEAR L_PRICE.
PERFORM GET_PRICE USING I_FINALORD-MATNR
P_WERKS
CHANGING L_PRICE.
CLEAR L_BASEQTY.
PERFORM CONVERT_QUANTITY USING I_FINALORD-MATNR
I_FINALORD-MEINS
I_FINALORD-GAMNG
I_MARA-MEINS
CHANGING L_BASEQTY.
I_FINALORD-FPLAN = L_BASEQTY * L_PRICE.
CLEAR L_BASEQTY.
ENDIF.
*----Calculate the differences
PERFORM CALCULATE_DIFFERENCES.
APPEND I_FINALORD.
ENDIF.
ENDLOOP.
SORT I_FINALORD BY WDATE ARBPL MATNR AUFNR.
ENDFORM. " SELECT_FINALPLANNED_ORDERS
*&---------------------------------------------------------------------*
*& Form get_week
*&---------------------------------------------------------------------*
* Subroutine to get week from date
*----------------------------------------------------------------------*
* -->P_I_FINALORD_GLTRP text
* <--P_I_FINALORD_SPWOC text
*----------------------------------------------------------------------*
FORM GET_WEEK USING P_I_FINALORD_GLTRP
CHANGING P_I_FINALORD_SPWOC.
*---Function Module to Get the Week based on date.
CALL FUNCTION 'DATE_GET_WEEK'
EXPORTING
DATE = P_I_FINALORD_GLTRP
IMPORTING
WEEK = P_I_FINALORD_SPWOC.
ENDFORM. " get_week
*&---------------------------------------------------------------------*
*& FORM GET_ACTUAL_QUANTITES
*&---------------------------------------------------------------------*
* Subroutine to get the actual quantities from mseg.
*----------------------------------------------------------------------*
FORM GET_ACTUAL_QAUNTITES
CHANGING FP_L_UOM. "AS
LOOP AT I_MSEG WHERE AUFNR = I_CAUFV-AUFNR
AND MATNR = I_CAUFV-PLNBEZ.
FP_L_UOM = I_MSEG-MEINS. "AS
IF I_MSEG-BWART = C_101.
I_FINALORD-MENGE = I_FINALORD-MENGE + I_MSEG-MENGE.
ELSE.
I_FINALORD-MENGE = I_FINALORD-MENGE - I_MSEG-MENGE.
ENDIF.
ENDLOOP.
ENDFORM. " get_actual_qauntites
*&---------------------------------------------------------------------*
*& FORM CALCULATE_DIFFERENCES
*&---------------------------------------------------------------------*
* Subroutine for calculating the differences
*----------------------------------------------------------------------*
FORM CALCULATE_DIFFERENCES .
I_FINALORD-DIFF = ABS( I_FINALORD-GAMNG - I_FINALORD-MENGE ).
I_FINALORD-ZDIFF = ABS( I_FINALORD-ZPLAN - I_FINALORD-ZACT ).
I_FINALORD-FDIFF = ABS( I_FINALORD-FPLAN - I_FINALORD-FACT ).
ENDFORM. " CALCULATE_DIFFERENCES
*&---------------------------------------------------------------------*
*& FORM CONVERT_QUANTITY
*&---------------------------------------------------------------------*
* Subroutine for quantity conversions
*----------------------------------------------------------------------*
* -->P_I_FINALORD_MATNR text
* -->P_I_FINALORD_MEINS text
* -->P_I_FINALORD_MENGE text
* <--P_I_FINALORD_ZACT text
*----------------------------------------------------------------------*
FORM CONVERT_QUANTITY USING P_I_MATNR
P_I_SR_MEINS
P_I_SR_MENGE
P_I_TG_MEINS
CHANGING P_I_TG_MENGE.
DATA: L_IN_QTY TYPE BSTMG,
L_OUT_QTY TYPE BSTMG.
MOVE: P_I_SR_MENGE TO L_IN_QTY.
**Function Module to Convert Material Unit from One Unit to another
CALL FUNCTION 'MD_CONVERT_MATERIAL_UNIT'
EXPORTING
I_MATNR = P_I_MATNR
I_IN_ME = P_I_SR_MEINS
I_OUT_ME = P_I_TG_MEINS
I_MENGE = L_IN_QTY
IMPORTING
E_MENGE = L_OUT_QTY
EXCEPTIONS
ERROR_IN_APPLICATION = 1
ERROR = 2
OTHERS = 3.
IF SY-SUBRC = 0.
MOVE L_OUT_QTY TO P_I_TG_MENGE.
ELSE.
CLEAR P_I_TG_MENGE.
ENDIF.
ENDFORM. " convert_quantity
*&---------------------------------------------------------------------*
*& FORM GET_PRICE
*&---------------------------------------------------------------------*
* Subroutine to get the price
*----------------------------------------------------------------------*
* -->P_V_MATNR text
* -->P_V_WERKS text
* <--P_V_PRICE text
*----------------------------------------------------------------------*
FORM GET_PRICE USING P_V_MATNR
P_V_WERKS
CHANGING P_V_PRICE.
STATICS I_PRICE TYPE STANDARD TABLE OF TY_PRICE
INITIAL SIZE 0 WITH HEADER LINE.
CLEAR: I_PRICE, P_V_PRICE.
READ TABLE I_PRICE WITH KEY MATNR = P_V_MATNR.
IF SY-SUBRC <> 0.
SELECT MATNR
STPRS
PEINH
UP TO 1 ROWS
FROM MBEW
INTO I_PRICE
WHERE MATNR = P_V_MATNR
AND BWKEY = P_V_WERKS.
ENDSELECT.
IF SY-SUBRC = 0.
APPEND I_PRICE.
ENDIF.
ENDIF.
IF I_PRICE-PEINH <> 0.
P_V_PRICE = I_PRICE-STPRS / I_PRICE-PEINH.
ENDIF.
ENDFORM. " get_price
*&---------------------------------------------------------------------*
*& FORM MERGE_DATA *
*&---------------------------------------------------------------------*
* Subroutine to merge weekly data into final internal table i_week *
*----------------------------------------------------------------------*
FORM MERGE_DATA .
DATA: L_WKDAY_NUM TYPE CIND,
L_PLANNED TYPE DISPTYPE,
L_ACTUAL TYPE DISPTYPE,
L_DIFF TYPE DISPTYPE,
L_PERC TYPE P DECIMALS 0 .
**For weekly report Consolidate data from i_finalord into internal
**tables i_weekly
REFRESH: I_WEEKLY.
LOOP AT I_FINALORD.
CLEAR I_WEEKLY.
MOVE: I_FINALORD-SPWOC TO I_WEEKLY-SPWOC,
I_FINALORD-ARBPL TO I_WEEKLY-ARBPL,
I_FINALORD-MATNR TO I_WEEKLY-MATNR,
I_FINALORD-AUFNR TO I_WEEKLY-AUFNR,
I_FINALORD-MTART TO I_WEEKLY-MTART,
I_FINALORD-MAKTX TO I_WEEKLY-MAKTX.
IF RB_QUAN = C_X.
IF RB_ORD = C_X .
MOVE: I_FINALORD-GAMNG TO L_PLANNED,
I_FINALORD-MENGE TO L_ACTUAL,
I_FINALORD-DIFF TO L_DIFF,
I_FINALORD-MEINS TO I_WEEKLY-MEINS.
PERFORM FILL_IWEEK1.
PERFORM FILL_IWEEK2.
PERFORM FILL_IWEEK3.
ELSE.
MOVE: I_FINALORD-ZPLAN TO L_PLANNED,
I_FINALORD-ZACT TO L_ACTUAL,
I_FINALORD-ZDIFF TO L_DIFF,
I_FINALORD-ZMEINS TO I_WEEKLY-MEINS.
ENDIF.
ELSE.
MOVE: I_FINALORD-FPLAN TO L_PLANNED,
I_FINALORD-FACT TO L_ACTUAL,
I_FINALORD-FDIFF TO L_DIFF,
I_FINALORD-FCURR TO I_WEEKLY-WAERS.
ENDIF.
PERFORM CALCULATE_PERCENTAGE USING L_PLANNED
L_DIFF
CHANGING L_PERC.
CLEAR L_WKDAY_NUM.
CALL FUNCTION 'DATE_COMPUTE_DAY'
EXPORTING
DATE = I_FINALORD-WDATE
IMPORTING
DAY = L_WKDAY_NUM.
 
CASE L_WKDAY_NUM.
WHEN C_1.
MOVE : L_PLANNED TO I_WEEKLY-MON_PLAN,
L_ACTUAL TO I_WEEKLY-MON_ACT,
L_DIFF TO I_WEEKLY-MON_DIFF,
L_PERC TO I_WEEKLY-MON_PERC.
WHEN C_2.
MOVE: L_PLANNED TO I_WEEKLY-TUE_PLAN,
L_ACTUAL TO I_WEEKLY-TUE_ACT,
L_DIFF TO I_WEEKLY-TUE_DIFF,
L_PERC TO I_WEEKLY-TUE_PERC.
WHEN C_3.
MOVE: L_PLANNED TO I_WEEKLY-WED_PLAN,
L_ACTUAL TO I_WEEKLY-WED_ACT,
L_DIFF TO I_WEEKLY-WED_DIFF,
L_PERC TO I_WEEKLY-WED_PERC.
WHEN C_4.
MOVE: L_PLANNED TO I_WEEKLY-THU_PLAN,
L_ACTUAL TO I_WEEKLY-THU_ACT,
L_DIFF TO I_WEEKLY-THU_DIFF,
L_PERC TO I_WEEKLY-THU_PERC.
WHEN C_5.
MOVE: L_PLANNED TO I_WEEKLY-FRI_PLAN,
L_ACTUAL TO I_WEEKLY-FRI_ACT,
L_DIFF TO I_WEEKLY-FRI_DIFF,
L_PERC TO I_WEEKLY-FRI_PERC.
WHEN C_6.
MOVE: L_PLANNED TO I_WEEKLY-SAT_PLAN,
L_ACTUAL TO I_WEEKLY-SAT_ACT,
L_DIFF TO I_WEEKLY-SAT_DIFF,
L_PERC TO I_WEEKLY-SAT_PERC.
WHEN C_7.
MOVE: L_PLANNED TO I_WEEKLY-SUN_PLAN,
L_ACTUAL TO I_WEEKLY-SUN_ACT,
L_DIFF TO I_WEEKLY-SUN_DIFF,
L_PERC TO I_WEEKLY-SUN_PERC.
ENDCASE.
MOVE: L_PLANNED TO I_WEEKLY-TOT_PLAN,
L_ACTUAL TO I_WEEKLY-TOT_ACT,
L_DIFF TO I_WEEKLY-TOT_DIFF,
L_PERC TO I_WEEKLY-TOT_PERC.
APPEND I_WEEKLY.
ENDLOOP.
ENDFORM. " merge_data
*&---------------------------------------------------------------------*
*& FORM FILL_IWEEK1 *
*&---------------------------------------------------------------------*
* Subroutine to fill the i_week1 internal table
*----------------------------------------------------------------------*
FORM FILL_IWEEK1.
**Consolidate Data into Internal table i_week1 based on
**week,weekday,resource and material Number, consolidating at material
**level
READ TABLE I_WEEK1 WITH KEY SPWOC = I_FINALORD-SPWOC
WKDAY = I_FINALORD-WKDAY
ARBPL = I_FINALORD-ARBPL
MATNR = I_FINALORD-MATNR.
IF SY-SUBRC = 0.
IF I_WEEK1-MEINS <> C_NULL.
IF I_WEEK1-MEINS <> I_FINALORD-MEINS.
I_WEEK1-MEINS = C_NULL.
MODIFY I_WEEK1 INDEX SY-TABIX TRANSPORTING MEINS.
ENDIF.
ENDIF.
ELSE.
CLEAR I_WEEK1.
MOVE: I_FINALORD-SPWOC TO I_WEEK1-SPWOC,
I_FINALORD-WKDAY TO I_WEEK1-WKDAY,
I_FINALORD-ARBPL TO I_WEEK1-ARBPL,
I_FINALORD-MATNR TO I_WEEK1-MATNR,
I_FINALORD-MEINS TO I_WEEK1-MEINS.
APPEND I_WEEK1.
ENDIF.
ENDFORM. " fill_iweek1
*&---------------------------------------------------------------------*
*& FORM FILL_IWEEK2
*&---------------------------------------------------------------------*
* Subroutine to fill the internal table i_week2 based on week,day,res
*----------------------------------------------------------------------*
FORM FILL_IWEEK2.
**Consolidate Data into Internal table i_week2 based on
**week,weekday,resource consolidating at resource level
READ TABLE I_WEEK2 WITH KEY SPWOC = I_FINALORD-SPWOC
WKDAY = I_FINALORD-WKDAY
ARBPL = I_FINALORD-ARBPL.
IF SY-SUBRC = 0.
IF I_WEEK2-MEINS <> C_NULL.
IF I_WEEK2-MEINS <> I_FINALORD-MEINS.
I_WEEK2-MEINS = C_NULL.
MODIFY I_WEEK2 INDEX SY-TABIX TRANSPORTING MEINS.
ENDIF.
ENDIF.
ELSE.
CLEAR I_WEEK2.
MOVE: I_FINALORD-SPWOC TO I_WEEK2-SPWOC,
I_FINALORD-WKDAY TO I_WEEK2-WKDAY,
I_FINALORD-ARBPL TO I_WEEK2-ARBPL,
I_FINALORD-MEINS TO I_WEEK2-MEINS.
APPEND I_WEEK2.
ENDIF.
ENDFORM. " fill_iweek2
*&---------------------------------------------------------------------*
*& FORM FILL_IWEEK3
*&---------------------------------------------------------------------*
* Subroutine to fill the internal table i_week3 based on week,day,res
*--------------------------------------------------------------------*
FORM FILL_IWEEK3.
**Consolidate Data into Internal table i_week3 based on
**week,weekday consolidating at weeklevel
READ TABLE I_WEEK3 WITH KEY SPWOC = I_FINALORD-SPWOC
WKDAY = I_FINALORD-WKDAY.
IF SY-SUBRC = 0.
IF I_WEEK3-MEINS <> C_NULL.
IF I_WEEK3-MEINS <> I_FINALORD-MEINS.
I_WEEK3-MEINS = C_NULL.
MODIFY I_WEEK3 INDEX SY-TABIX TRANSPORTING MEINS.
ENDIF.
ENDIF.
ELSE.
CLEAR : I_WEEK3.
MOVE: I_FINALORD-SPWOC TO I_WEEK3-SPWOC,
I_FINALORD-WKDAY TO I_WEEK3-WKDAY,
I_FINALORD-MEINS TO I_WEEK3-MEINS.
APPEND I_WEEK3.
ENDIF.
ENDFORM. " fill_iweek3
 
*-------------------------BEGIN OF MOD-004-----------------------------*
*&---------------------------------------------------------------------*
*& Form display_weekly_report
*&---------------------------------------------------------------------*
* Subrotuine to display weekly report
*----------------------------------------------------------------------*
FORM DISPLAY_WEEKLY_REPORT.
DATA: L_DATE TYPE SYDATUM.
L_DATE = C_DATE.
DO 7 TIMES.
PERFORM GET_WEEK_NAMES USING L_DATE
CHANGING I_WKDAY-WKDAY .
L_DATE = L_DATE + C_1.
ENDDO.
** Begin of Mod-001
SORT I_WEEKLY BY SPWOC ARBPL MATNR. "Mod-001.
** End of Mod-001
LOOP AT I_WEEKLY.
CLEAR REC_WEEKLY.
MOVE I_WEEKLY TO REC_WEEKLY.
AT NEW SPWOC.
PERFORM DISPLAY_WEEK_HEADER.
ENDAT.
** At new workcenter display the workcenter header
AT NEW ARBPL.
PERFORM WRKCENTER_HEADER1.
ENDAT.
** At new Material display the material Header
AT NEW MATNR.
PERFORM MATERIAL_HEADER.
ENDAT.
MOVE REC_WEEKLY TO REC_TEMP_WEEKLY.
APPEND REC_TEMP_WEEKLY TO I_TEMP_WEEKLY.
**Check for the Detail level Report or Summary Level Report
**If it is a Detail Level Report display the materials and
**Corresponding orders
IF RB_DET = C_X.
IF CB_COLOR = C_X.
FORMAT COLOR COL_NORMAL INTENSIFIED OFF.
ENDIF.
* Show the weekly orders under the material No and on the
* Days of the week (Mon to Thu)
PERFORM SHOW_WEEKLY_ORDERS1.
ENDIF.
**if it is summary level report Show only the material numbers
AT END OF MATNR.
SUM.
** check whether to display the quantities and order units
IF RB_QUAN = C_X AND RB_ORD = C_X.
PERFORM CHECK_UOM_WEEK_RES_MAT1.
ENDIF.
* Calculate the Percentage for Material Total
* From Mon to thu
PERFORM CALCULATE_WK_PERC1.
IF CB_COLOR = C_X.
FORMAT COLOR COL_TOTAL INTENSIFIED ON.
ENDIF.
* Display the Material total From Mon to Thu
PERFORM DISPLAY_WK_TOT1 USING TEXT-088.
ENDAT.
AT END OF ARBPL.
SUM.
** check whether to display the quantities and order units
IF RB_QUAN = C_X AND RB_ORD = C_X.
PERFORM CHECK_UOM_WEEK_RES1.
ENDIF.
* Calculate Perscentage for the Respurce total
* Form Mon to Thu
PERFORM CALCULATE_WK_PERC1.
IF CB_COLOR = C_X.
FORMAT COLOR COL_KEY INTENSIFIED OFF.
ENDIF.
* Display Report Total from Mon to Thu
PERFORM DISPLAY_WK_TOT1 USING TEXT-089.
* Display the weekly report of the same week
* from Friday to Total
PERFORM DISPLAY_WEEKLY_REPORT_NEXT.
ENDAT.
AT END OF SPWOC.
SUM.
** check whether to display the quantities and order units
IF RB_QUAN = C_X AND RB_ORD = C_X.
PERFORM CHECK_UOM_WEEK1.
ENDIF.
* Calculate the percentage difference for
* the Week total for the week from Mon to thu
PERFORM CALCULATE_WK_PERC1.
* Display header for the week total (From Mon to thu)
V_FMDAY = V_MONDAY.
IF CB_COLOR = C_X.
FORMAT COLOR COL_POSITIVE INTENSIFIED OFF.
ENDIF.
WRITE: TEXT-091.
ULINE (156).
IF CB_COLOR = C_X.
FORMAT COLOR COL_HEADING INTENSIFIED ON.
ENDIF.
WRITE : /(14) '', SY-VLINE.
WRITE:(10) TEXT-050,(13) V_FMDAY,50 SY-VLINE.
V_FMDAY = V_FMDAY + 1.
WRITE:(10) TEXT-051,(13) V_FMDAY,84 SY-VLINE.
V_FMDAY = V_FMDAY + 1.
WRITE:(10) TEXT-052,(13) V_FMDAY,118 SY-VLINE.
V_FMDAY = V_FMDAY + 1.
WRITE:(10) TEXT-053,(13) V_FMDAY,152 SY-VLINE, 156 SY-VLINE.
V_FMDAY = V_FMDAY + 1.
ULINE (156).
WRITE : /(14) ''.
DO 4 TIMES.
WRITE: SY-VLINE,(31) TEXT-068.
ENDDO.
IF RB_QUAN = C_X.
WRITE: SY-VLINE NO-GAP, (4) TEXT-070.
ELSE.
WRITE : SY-VLINE NO-GAP ,(4) TEXT-087.
ENDIF.
WRITE: 156 SY-VLINE.
ULINE (156).
IF CB_COLOR = C_X.
FORMAT COLOR COL_POSITIVE INTENSIFIED OFF.
ENDIF.
* Display week total from Mon to thu
PERFORM DISPLAY_WK_TOT1 USING ' '.
* Display header for the week total From Fri to tot
IF CB_COLOR = C_X.
FORMAT COLOR COL_HEADING INTENSIFIED ON.
ENDIF.
WRITE : /(14) '', SY-VLINE.
WRITE:(10) TEXT-054,(13) V_FMDAY,50 SY-VLINE.
V_FMDAY = V_FMDAY + 1.
WRITE:(10) TEXT-055,(13) V_FMDAY,84 SY-VLINE.
V_FMDAY = V_FMDAY + 1.
WRITE:(10) TEXT-056,(13) V_FMDAY,118 SY-VLINE.
WRITE:(10) TEXT-057, 152 SY-VLINE, 156 SY-VLINE.
ULINE (156).
WRITE : /(14) ''.
DO 4 TIMES.
WRITE: SY-VLINE,(31) TEXT-068.
ENDDO.
IF RB_QUAN = C_X.
WRITE: SY-VLINE NO-GAP, (4) TEXT-070.
ELSE.
WRITE : SY-VLINE NO-GAP ,(4) TEXT-087.
ENDIF.
WRITE: 156 SY-VLINE.
ULINE (156).
IF CB_COLOR = C_X.
FORMAT COLOR COL_POSITIVE INTENSIFIED OFF.
ENDIF.
* Display week total from Fri to Tot
PERFORM DISPLAY_WK_TOT2 USING C_SPACE.
ENDAT.
ENDLOOP.
ENDFORM. " display_report
*----------------------END OF MOD-004-------------------*
 
 
*&---------------------------------------------------------------------*
*& Form display_report_header
*&---------------------------------------------------------------------*
* Sub routine to display Report Header
*----------------------------------------------------------------------*
FORM DISPLAY_REPORT_HEADER.
DATA: L_TEXT1(20) TYPE C,
L_TEXT2(20) TYPE C,
L_TEXT3(40) TYPE C.
**Report Header Details Depending on daily report or weekly Report
FORMAT COLOR COL_BACKGROUND.
* CALL FUNCTION '/NESGLB/X_PRINT_REPORT_HEADER'
* EXPORTING
* prog_id = sy-cprog
* prog_title = sy-title
* sysid = sy-sysid
* first_call = ' '
* print_header = c_x.
**If weekly report.
IF RB_WEEK = C_X.
WRITE: TEXT-030,
15 S_DATE-LOW,
28(10) TEXT-031,
35 S_DATE-HIGH,
50 P_WERKS,
60 V_TEXT1.
ELSE.
WRITE : TEXT-071,
50 P_WERKS,
60 V_TEXT1.
ENDIF.
SKIP.
IF RB_WEEK = C_X.
CLEAR: L_TEXT1,
L_TEXT2,
L_TEXT3.
IF RB_ORD = C_X.
L_TEXT1 = TEXT-032.
ELSE.
L_TEXT1 = TEXT-033.
ENDIF.
**if the quantities is checked
IF RB_QUAN = C_X.
L_TEXT2 = TEXT-034.
ELSE.
L_TEXT2 = TEXT-035.
ENDIF.
IF RB_DET = C_X.
L_TEXT3 = TEXT-036.
ELSE.
L_TEXT3 = TEXT-037.
ENDIF.
CONCATENATE L_TEXT1 TEXT-038
L_TEXT2 TEXT-038
L_TEXT3 INTO V_TEXT3
SEPARATED BY SPACE.
WRITE : V_TEXT3.
IF CB_COLOR = C_X.
WRITE: 45 TEXT-039,
(16) TEXT-040 COLOR COL_POSITIVE INTENSIFIED OFF,
(16) TEXT-041 COLOR COL_KEY INTENSIFIED OFF,
(16) TEXT-042 COLOR COL_GROUP INTENSIFIED OFF,
(16) TEXT-043 COLOR COL_TOTAL INTENSIFIED ON,
(16) TEXT-044 COLOR COL_NORMAL INTENSIFIED OFF.
ENDIF.
**begin of mod-002
* ULINE (245).
ULINE (156).
**end of mod-002
**If the Report To be displayed is daily report
ELSEIF RB_DAILY = C_X.
CLEAR: L_TEXT1,
L_TEXT2,
L_TEXT3.
IF RB_ORD = C_X.
L_TEXT1 = TEXT-032.
ELSE.
L_TEXT1 = TEXT-033.
ENDIF.
IF RB_QUAN = C_X.
L_TEXT2 = TEXT-034.
ELSE.
L_TEXT2 = TEXT-035.
ENDIF.
CONCATENATE L_TEXT1 TEXT-038
L_TEXT2 INTO V_TEXT3
SEPARATED BY SPACE.
WRITE : V_TEXT3.
IF CB_COLOR = C_X.
WRITE: 45 TEXT-039,
(16) TEXT-045 COLOR COL_POSITIVE INTENSIFIED OFF,
(16) TEXT-041 COLOR COL_KEY INTENSIFIED OFF,
(16) TEXT-042 COLOR COL_GROUP INTENSIFIED OFF,
(16) TEXT-043 COLOR COL_TOTAL INTENSIFIED ON,
(16) TEXT-044 COLOR COL_NORMAL INTENSIFIED OFF.
ENDIF.
ULINE /(150).
ENDIF.
ENDFORM. " display_report_header
*&---------------------------------------------------------------------*
*& FORM DISPLAY_WEEK_HEADER
*&---------------------------------------------------------------------*
* Subroutine To display the weekly header
*----------------------------------------------------------------------*
FORM DISPLAY_WEEK_HEADER .
**Make the firstday and lastday as Monday and sunday respectively
CALL FUNCTION 'WEEK_GET_FIRST_DAY'
EXPORTING
WEEK = REC_WEEKLY-SPWOC
IMPORTING
DATE = V_MONDAY
EXCEPTIONS
WEEK_INVALID = 1
OTHERS = 2.
IF SY-SUBRC <> C_0.
CLEAR V_MONDAY.
ENDIF.
 
V_SUNDAY = V_MONDAY + C_6.
IF V_MONDAY < S_DATE-LOW.
V_MONDAY = S_DATE-LOW.
ENDIF.
IF V_SUNDAY > S_DATE-HIGH.
V_SUNDAY = S_DATE-HIGH.
ENDIF.
SKIP 1.
IF CB_COLOR = C_X.
FORMAT COLOR COL_POSITIVE INTENSIFIED OFF.
ENDIF.
**begin of mod-002
* ULINE (245).
ULINE (295).
**end of mod-002
 
 
WRITE: / TEXT-046,
25 REC_WEEKLY-SPWOC,
40 TEXT-047,
46 V_MONDAY,
60 TEXT-048,
65 V_SUNDAY,
**begin of mod-002
* 245 sy-vline.
295 SY-VLINE.
* ULINE (245).
ULINE (295).
**end of mod-002
ENDFORM. " display_week_header
 
*&---------------------------------------------------------------------*
*& FORM MATERIAL_HEADER
*&---------------------------------------------------------------------*
* Subroutine To display Material Header
*----------------------------------------------------------------------*
FORM MATERIAL_HEADER .
DATA: L_MAKTX TYPE MAKTX.
* Get the material Description for the Material No.
PERFORM GET_MATDESC USING REC_WEEKLY-MATNR CHANGING L_MAKTX.
* Display the Material Header
IF CB_COLOR = C_X.
FORMAT COLOR COL_GROUP INTENSIFIED OFF.
ENDIF.
WRITE :/1 REC_WEEKLY-MATNR, 40 REC_WEEKLY-MTART, 47 L_MAKTX,
**begin of mod-002
* WRITE: 245 sy-vline.
* ULINE (245).
295 SY-VLINE.
ULINE (295).
**end of mod-002
 
ENDFORM. " material_Header
*&---------------------------------------------------------------------*
*& FORM DISPLAY_DAILY_REPORT
*&---------------------------------------------------------------------*
* subroutine to disply daily report
*----------------------------------------------------------------------*
FORM DISPLAY_DAILY_REPORT.
DATA: L_UOM_DAY TYPE MEINS,
L_UOM_RES TYPE MEINS,
L_UOM_MAT TYPE MEINS,
L_PERC TYPE DISPTYPE.
LOOP AT I_FINALORD.
CLEAR: REC_FINALORD, L_PERC.
** Move the Records into WorkArea
MOVE I_FINALORD TO REC_FINALORD.
** At start of New Date, Display day header
** and Get the UOM into l_uom_day
AT NEW WDATE.
PERFORM DISPLAY_DAY_HEADER.
L_UOM_DAY = REC_FINALORD-MEINS.
ENDAT.
** At start of New Resource Display the Resource Header
** and get the UOM into l_uom_res
AT NEW ARBPL.
PERFORM DISPLAY_RESOURCE_HEADER.
L_UOM_RES = REC_FINALORD-MEINS.
ENDAT.
AT NEW MATNR.
**At start of New Material Display the material Header
**and get the UOM into l_uom_mat.
PERFORM DISPLAY_MATERIAL_HEADER.
L_UOM_MAT = REC_FINALORD-MEINS.
PERFORM DISPLAY_ORDER_HEADER.
ENDAT.
IF CB_COLOR = C_X.
FORMAT COLOR COL_NORMAL INTENSIFIED OFF.
ENDIF.
PERFORM WRITE_VLINES_DAILY.
**Check for the OrderUnit,Quantities and compare whether all the UOMs
** are matching on particular day and calculate the Corresponding
**percentages and Display the Orders for the planned ,actual and fiscal
**respectively
IF RB_QUAN = C_X.
IF RB_ORD = C_X.
IF REC_FINALORD-MEINS <> L_UOM_MAT.
CLEAR L_UOM_MAT.
ENDIF.
IF REC_FINALORD-MEINS <> L_UOM_RES.
CLEAR L_UOM_RES.
ENDIF.
IF REC_FINALORD-MEINS <> L_UOM_DAY.
CLEAR L_UOM_DAY.
ENDIF.
PERFORM CALCULATE_PERCENTAGE USING REC_FINALORD-GAMNG
REC_FINALORD-DIFF
CHANGING L_PERC.
PERFORM WRITE_ORDERS_DAILY USING REC_FINALORD-AUFNR
REC_FINALORD-GAMNG
REC_FINALORD-MENGE
REC_FINALORD-DIFF
L_PERC
REC_FINALORD-MEINS.
ELSE.
PERFORM CALCULATE_PERCENTAGE USING REC_FINALORD-ZPLAN
REC_FINALORD-ZDIFF
CHANGING L_PERC.
PERFORM WRITE_ORDERS_DAILY USING REC_FINALORD-AUFNR
REC_FINALORD-ZPLAN
REC_FINALORD-ZACT
REC_FINALORD-ZDIFF
L_PERC
REC_FINALORD-ZMEINS.
ENDIF.
ELSE.
PERFORM CALCULATE_PERCENTAGE USING REC_FINALORD-FPLAN
REC_FINALORD-FDIFF
CHANGING L_PERC.
PERFORM WRITE_ORDERS_DAILY USING REC_FINALORD-AUFNR
REC_FINALORD-FPLAN
REC_FINALORD-FACT
REC_FINALORD-FDIFF
L_PERC
REC_FINALORD-FCURR.
ENDIF.
** AT the End of matnr arbpl and wdate calculate the Totals for the day
**if all the UOM s are matching else display the Totals with ***
AT END OF MATNR.
SUM.
ULINE /1(109).
IF CB_COLOR = C_X.
FORMAT COLOR COL_TOTAL INTENSIFIED ON.
ENDIF.
PERFORM DISPLAY_TOTALS USING L_UOM_MAT TEXT-088 .
ENDAT.
AT END OF ARBPL.
SUM.
ULINE /1(109).
IF CB_COLOR = C_X.
FORMAT COLOR COL_KEY INTENSIFIED OFF.
ENDIF.
PERFORM DISPLAY_TOTALS USING L_UOM_RES TEXT-089.
ENDAT.
AT END OF WDATE.
SUM.
ULINE /1(109).
IF CB_COLOR = C_X.
FORMAT COLOR COL_POSITIVE INTENSIFIED OFF.
ENDIF.
PERFORM DISPLAY_TOTALS USING L_UOM_DAY TEXT-090.
ULINE /1(109).
ENDAT.
ENDLOOP.
ENDFORM. " display_daily_report
*&---------------------------------------------------------------------*
*& FORM DISPLAY_DAY_HEADER
*&---------------------------------------------------------------------*
* Subroutine to Display Day Header
*----------------------------------------------------------------------*
FORM DISPLAY_DAY_HEADER.
IF CB_COLOR = C_X.
FORMAT COLOR COL_POSITIVE INTENSIFIED OFF.
ENDIF.
ULINE /1(109).
WRITE: /1 SY-VLINE,
2 TEXT-072,
8 REC_FINALORD-WDATE,
19 REC_FINALORD-WKDAY,
109 SY-VLINE.
ENDFORM. " display_day_header
*&---------------------------------------------------------------------*
*& FORM DISPLAY_RESOURCE_HEADER
*&---------------------------------------------------------------------*
* Subroutine to display Resource Header
*----------------------------------------------------------------------*
FORM DISPLAY_RESOURCE_HEADER .
CLEAR: V_RTEXT.
IF CB_COLOR = C_X.
FORMAT COLOR COL_KEY INTENSIFIED OFF .
ENDIF.
ULINE /1(109).
WRITE: /1 SY-VLINE,
2 TEXT-073,
14 REC_FINALORD-ARBPL.
PERFORM GET_RESDESC USING REC_FINALORD-ARBPL
P_WERKS
CHANGING V_RTEXT.
WRITE: 30 V_RTEXT,
109 SY-VLINE.
ENDFORM. " display_resource_header
*&---------------------------------------------------------------------*
*& FORM DISPLAY_MATERIAL_HEADER
*&---------------------------------------------------------------------*
* Subroutine to Display Material Header
*----------------------------------------------------------------------*
FORM DISPLAY_MATERIAL_HEADER.
IF CB_COLOR = C_X.
FORMAT COLOR COL_GROUP INTENSIFIED OFF.
ENDIF.
ULINE /1(109).
WRITE: /1 SY-VLINE,
2 TEXT-074,
14 REC_FINALORD-MATNR,
35 REC_FINALORD-MAKTX,
77 REC_FINALORD-MTART,
109 SY-VLINE.
ULINE /1(109).
ENDFORM. " display_material_header
*&---------------------------------------------------------------------*
*& FORM GET_DAYNAME
*&---------------------------------------------------------------------*
* Subroutine to get the day names
*----------------------------------------------------------------------*
* -->P_I_FINALORD_WDATE text
* <--P_I_FINALORD_WKDAY text
*----------------------------------------------------------------------*
FORM GET_DAYNAME USING P_I_FINALORD_WDATE
CHANGING P_I_FINALORD_WKDAY.
CALL FUNCTION 'DATE_TO_DAY'
EXPORTING
DATE = P_I_FINALORD_WDATE
IMPORTING
WEEKDAY = P_I_FINALORD_WKDAY.
ENDFORM. " get_dayname
*&---------------------------------------------------------------------*
*& FORM DISPLAY_ORDER_HEADER
*&---------------------------------------------------------------------*
* Subroutine to display Order Header
*----------------------------------------------------------------------*
FORM DISPLAY_ORDER_HEADER .
DATA: L_TEXT1(25) TYPE C,
L_TEXT2(25) TYPE C,
L_TEXT3(25) TYPE C.
IF CB_COLOR = C_X.
FORMAT COLOR COL_HEADING INTENSIFIED ON.
ENDIF.
IF RB_QUAN = C_X.
WRITE: /1 SY-VLINE,
TEXT-076,
19 SY-VLINE,
TEXT-077,
38 SY-VLINE,
TEXT-078,
59 SY-VLINE,
TEXT-079,
82 SY-VLINE,
TEXT-081,
103 SY-VLINE,
TEXT-082,
109 SY-VLINE.
ELSE.
CONCATENATE TEXT-083 V_WAERS INTO L_TEXT1 SEPARATED BY SPACE.
CONCATENATE TEXT-084 V_WAERS INTO L_TEXT2 SEPARATED BY SPACE.
CONCATENATE TEXT-085 V_WAERS INTO L_TEXT3 SEPARATED BY SPACE.
WRITE: / SY-VLINE,
TEXT-076,
19 SY-VLINE,
L_TEXT1,
38 SY-VLINE,
L_TEXT2,
59 SY-VLINE,
L_TEXT3,
82 SY-VLINE,
TEXT-081,
103 SY-VLINE,
TEXT-087,
109 SY-VLINE.
ENDIF.
ULINE /1(109).
ENDFORM. " display_order_header
*&---------------------------------------------------------------------*
*& FORM DISPLAY_TOTALS
*&---------------------------------------------------------------------*
* Subroutine to Display Daily Totals
*----------------------------------------------------------------------*
* -->P_i_UOM text
* -->P_i_MAT text
*----------------------------------------------------------------------*
FORM DISPLAY_TOTALS USING P_I_UOM
P_I_MAT.
DATA: L_PERC TYPE DISPTYPE.
PERFORM WRITE_VLINES_DAILY.
IF RB_QUAN = C_X.
IF RB_ORD = C_X.
IF NOT P_I_UOM IS INITIAL.
CLEAR L_PERC.
PERFORM CALCULATE_PERCENTAGE USING I_FINALORD-GAMNG
I_FINALORD-DIFF
CHANGING L_PERC.
PERFORM WRITE_ORDERS_DAILY USING P_I_MAT
I_FINALORD-GAMNG
I_FINALORD-MENGE
I_FINALORD-DIFF
L_PERC
P_I_UOM.
ELSE.
PERFORM WRITE_ORDERS_DAILY USING P_I_MAT
C_NULL
C_NULL
C_NULL
C_NA
C_NULL.
ENDIF.
ELSE.
CLEAR L_PERC.
PERFORM CALCULATE_PERCENTAGE USING I_FINALORD-ZPLAN
I_FINALORD-ZDIFF
CHANGING L_PERC.
PERFORM WRITE_ORDERS_DAILY USING P_I_MAT
I_FINALORD-ZPLAN
I_FINALORD-ZACT
I_FINALORD-ZDIFF
L_PERC
REC_FINALORD-ZMEINS.
ENDIF.
ELSE.
CLEAR L_PERC.
PERFORM CALCULATE_PERCENTAGE USING I_FINALORD-FPLAN
I_FINALORD-FDIFF
CHANGING L_PERC.
PERFORM WRITE_ORDERS_DAILY USING P_I_MAT
I_FINALORD-FPLAN
I_FINALORD-FACT
I_FINALORD-FDIFF
L_PERC
REC_FINALORD-FCURR.
ENDIF.
ENDFORM. " display_totals
*&---------------------------------------------------------------------*
*& FORM CALCULATE_PERCENTAGE
*&---------------------------------------------------------------------*
* Subroutine To calculate Percentages
*----------------------------------------------------------------------*
* -->P_L_PLANNED text
* -->P_L_DIFF text
* <--P_L_PERC text
*----------------------------------------------------------------------*
FORM CALCULATE_PERCENTAGE USING P_L_PLANNED
P_L_DIFF
CHANGING P_L_PERC.
IF P_L_PLANNED IS INITIAL.
CLEAR P_L_PERC.
ELSE.
P_L_PERC = ( 1 - ( P_L_DIFF / P_L_PLANNED ) ) * C_100.
ENDIF.
ENDFORM. " calculate_percentage
*&---------------------------------------------------------------------*
*& FORM WRITE_VLINES_DAILY
*&---------------------------------------------------------------------*
* Subroutine to write vlines
*----------------------------------------------------------------------*
FORM WRITE_VLINES_DAILY .
WRITE: /1 SY-VLINE,
19 SY-VLINE,
38 SY-VLINE,
59 SY-VLINE,
82 SY-VLINE,
103 SY-VLINE,
109 SY-VLINE.
ENDFORM. " write_vlines_daily
*&---------------------------------------------------------------------*
*& FORM WRITE_ORDERS_DAILY
*&---------------------------------------------------------------------*
* Subroutine to write daily orders
*----------------------------------------------------------------------*
* -->P_I_AUFNR text
* -->P_I_PLANNED text
* -->P_I_ACTUAL text
* -->P_I_DIFF text
* -->P_I_PERC text
* -->P_I_UOM text
*----------------------------------------------------------------------*
FORM WRITE_ORDERS_DAILY USING P_I_AUFNR
P_I_PLANNED
P_I_ACTUAL
P_I_DIFF
P_I_PERC
P_I_UOM.
WRITE: 2 P_I_AUFNR.
* HIDE: P_I_AUFNR.
WRITE: 21 P_I_PLANNED,
39 P_I_ACTUAL,
62 P_I_DIFF,
85 P_I_PERC,
104 P_I_UOM.
ENDFORM. " write_orders_daily
*&---------------------------------------------------------------------*
*& FORM GET_MATDESC
*&---------------------------------------------------------------------*
* Subroutine to get the material Descriptions
*----------------------------------------------------------------------*
* -->P_I_MATNR text
* <--P_I_MAKTX text
*----------------------------------------------------------------------*
FORM GET_MATDESC USING P_I_MATNR
CHANGING P_I_MAKTX.
STATICS: ST_I_MATDESC TYPE STANDARD TABLE OF TY_MATDESC
INITIAL SIZE 0 WITH HEADER LINE.
CLEAR ST_I_MATDESC.
READ TABLE ST_I_MATDESC WITH KEY MATNR = P_I_MATNR.
IF SY-SUBRC <> 0.
SELECT SINGLE MATNR MAKTX
INTO ST_I_MATDESC
FROM MAKT
WHERE MATNR = P_I_MATNR
AND SPRAS = SY-LANGU.
IF SY-SUBRC = 0.
APPEND ST_I_MATDESC.
ENDIF.
ENDIF.
P_I_MAKTX = ST_I_MATDESC-MAKTX.
ENDFORM. " get_matdesc
*&---------------------------------------------------------------------*
*& FORM SHOW_WEEKLY_ORDERS1
*&---------------------------------------------------------------------*
* Subroutine for Displaying weekly orders From Monday To Thursday
*----------------------------------------------------------------------*
FORM SHOW_WEEKLY_ORDERS1.
WRITE: /(14) REC_WEEKLY-AUFNR.
HIDE REC_WEEKLY-AUFNR.
WRITE: SY-VLINE,
**begin of mod-002
* (6) rec_weekly-mon_plan NO-SIGN,
* (6) rec_weekly-mon_act NO-SIGN,
* (6) rec_weekly-mon_diff NO-SIGN,
* (4) rec_weekly-mon_perc NO-SIGN,
* sy-vline,
* (6) rec_weekly-tue_plan NO-SIGN,
* (6) rec_weekly-tue_act NO-SIGN,
* (6) rec_weekly-tue_diff NO-SIGN,
* (4) rec_weekly-tue_perc NO-SIGN,
* sy-vline,
* (6) rec_weekly-wed_plan NO-SIGN,
* (6) rec_weekly-wed_act NO-SIGN,
* (6) rec_weekly-wed_diff NO-SIGN,
* (4) rec_weekly-wed_perc NO-SIGN,
* sy-vline,
* (6) rec_weekly-thu_plan NO-SIGN,
* (6) rec_weekly-thu_act NO-SIGN,
* (6) rec_weekly-thu_diff NO-SIGN,
* (4) rec_weekly-thu_perc NO-SIGN,
* sy-vline,
* (6) rec_weekly-fri_plan NO-SIGN,
* (6) rec_weekly-fri_act NO-SIGN,
* (6) rec_weekly-fri_diff NO-SIGN,
* (4) rec_weekly-fri_perc NO-SIGN,
* sy-vline,
* (6) rec_weekly-sat_plan NO-SIGN,
* (6) rec_weekly-sat_act NO-SIGN,
* (6) rec_weekly-sat_diff NO-SIGN,
* (4) rec_weekly-sat_perc NO-SIGN,
* sy-vline,
* (6) rec_weekly-sun_plan NO-SIGN,
* (6) rec_weekly-sun_act NO-SIGN,
* (6) rec_weekly-sun_diff NO-SIGN,
* (4) rec_weekly-sun_perc NO-SIGN,
* sy-vline,
* (6) rec_weekly-tot_plan NO-SIGN,
* (6) rec_weekly-tot_act NO-SIGN,
* (6) rec_weekly-tot_diff NO-SIGN,
* (4) rec_weekly-tot_perc NO-SIGN,
* sy-vline.
*
 
(8) REC_WEEKLY-MON_PLAN NO-SIGN LEFT-JUSTIFIED,
(8) REC_WEEKLY-MON_ACT NO-SIGN LEFT-JUSTIFIED,
(8) REC_WEEKLY-MON_DIFF NO-SIGN LEFT-JUSTIFIED,
(4) REC_WEEKLY-MON_PERC NO-SIGN LEFT-JUSTIFIED,
SY-VLINE,
(8) REC_WEEKLY-TUE_PLAN NO-SIGN LEFT-JUSTIFIED,
(8) REC_WEEKLY-TUE_ACT NO-SIGN LEFT-JUSTIFIED,
(8) REC_WEEKLY-TUE_DIFF NO-SIGN LEFT-JUSTIFIED,
(4) REC_WEEKLY-TUE_PERC NO-SIGN LEFT-JUSTIFIED,
SY-VLINE,
(8) REC_WEEKLY-WED_PLAN NO-SIGN LEFT-JUSTIFIED,
(8) REC_WEEKLY-WED_ACT NO-SIGN LEFT-JUSTIFIED,
(8) REC_WEEKLY-WED_DIFF NO-SIGN LEFT-JUSTIFIED,
(4) REC_WEEKLY-WED_PERC NO-SIGN LEFT-JUSTIFIED,
SY-VLINE,
(8) REC_WEEKLY-THU_PLAN NO-SIGN LEFT-JUSTIFIED,
(8) REC_WEEKLY-THU_ACT NO-SIGN LEFT-JUSTIFIED,
(8) REC_WEEKLY-THU_DIFF NO-SIGN LEFT-JUSTIFIED,
(4) REC_WEEKLY-THU_PERC NO-SIGN LEFT-JUSTIFIED,
SY-VLINE.
*------------------------BEGIN OF MOD-004-----------------------*
* MOVE rec_weekly TO rec_temp_weekly.
*
* APPEND rec_temp_weekly TO i_temp_weekly.
* (8) rec_weekly-fri_plan NO-SIGN left-justified,
* (8) rec_weekly-fri_act NO-SIGN left-justified,
* (8) rec_weekly-fri_diff NO-SIGN left-justified,
* (4) rec_weekly-fri_perc NO-SIGN left-justified,
* sy-vline,
* (8) rec_weekly-sat_plan NO-SIGN left-justified,
* (8) rec_weekly-sat_act NO-SIGN left-justified,
* (8) rec_weekly-sat_diff NO-SIGN left-justified,
* (4) rec_weekly-sat_perc NO-SIGN left-justified,
* sy-vline,
* (8) rec_weekly-sun_plan NO-SIGN left-justified,
* (8) rec_weekly-sun_act NO-SIGN left-justified,
* (8) rec_weekly-sun_diff NO-SIGN left-justified,
* (4) rec_weekly-sun_perc NO-SIGN left-justified,
* sy-vline,
* (8) rec_weekly-tot_plan NO-SIGN left-justified,
* (8) rec_weekly-tot_act NO-SIGN left-justified,
* (8) rec_weekly-tot_diff NO-SIGN left-justified,
* (4) rec_weekly-tot_perc NO-SIGN left-justified,
* sy-vline.
** end of mod-002.
IF RB_QUAN = C_X.
**begin of mod-002.
* WRITE: (3) rec_weekly-meins, 245 sy-vline.
* ELSE.
* WRITE: (3) rec_weekly-waers, 245 sy-vline.
* ENDIF.
* ULINE (245).
WRITE: (3) REC_WEEKLY-MEINS, 156 SY-VLINE.
ELSE.
WRITE: (3) REC_WEEKLY-WAERS, 156 SY-VLINE.
ENDIF.
ULINE (156).
**end of mod-002
ENDFORM. " show_weekly_orders
*&---------------------------------------------------------------------*
*& FORM GET_WEEK_NAMES
*&---------------------------------------------------------------------*
* Subroutine to get the week names
*----------------------------------------------------------------------*
FORM GET_WEEK_NAMES USING P_I_DATE
CHANGING P_I_WKDAY_WKDAY.
CALL FUNCTION 'DATE_TO_DAY'
EXPORTING
DATE = P_I_DATE
IMPORTING
WEEKDAY = P_I_WKDAY_WKDAY.
APPEND I_WKDAY.
ENDFORM. " get_week_names
*&---------------------------------------------------------------------*
*& Form check_uom_week_res_mat1
*&---------------------------------------------------------------------*
* Subroutine To check UOM for summing at material Level
* For the week from Monday to Thursday
*----------------------------------------------------------------------*
FORM CHECK_UOM_WEEK_RES_MAT1.
READ TABLE I_WKDAY INDEX C_1.
READ TABLE I_WEEK1 WITH KEY SPWOC = I_WEEKLY-SPWOC
WKDAY = I_WKDAY-WKDAY
ARBPL = I_WEEKLY-ARBPL
MATNR = I_WEEKLY-MATNR.
IF SY-SUBRC <> C_0 OR I_WEEK1-MEINS = C_NULL.
CLEAR: I_WEEKLY-MON_PLAN,
I_WEEKLY-MON_ACT,
I_WEEKLY-MON_DIFF,
I_WEEKLY-MON_PERC.
ENDIF.
READ TABLE I_WKDAY INDEX C_2.
READ TABLE I_WEEK1 WITH KEY SPWOC = I_WEEKLY-SPWOC
WKDAY = I_WKDAY-WKDAY
ARBPL = I_WEEKLY-ARBPL
MATNR = I_WEEKLY-MATNR.
IF SY-SUBRC <> C_0 OR I_WEEK1-MEINS = C_NULL.
CLEAR: I_WEEKLY-TUE_PLAN,
I_WEEKLY-TUE_ACT,
I_WEEKLY-TUE_DIFF,
I_WEEKLY-TUE_PERC.
ENDIF.
READ TABLE I_WKDAY INDEX C_3.
READ TABLE I_WEEK1 WITH KEY SPWOC = I_WEEKLY-SPWOC
WKDAY = I_WKDAY-WKDAY
ARBPL = I_WEEKLY-ARBPL
MATNR = I_WEEKLY-MATNR.
IF SY-SUBRC <> C_0 OR I_WEEK1-MEINS = C_NULL.
CLEAR: I_WEEKLY-WED_PLAN,
I_WEEKLY-WED_ACT,
I_WEEKLY-WED_DIFF,
I_WEEKLY-WED_PERC.
ENDIF.
READ TABLE I_WKDAY INDEX C_4.
READ TABLE I_WEEK1 WITH KEY SPWOC = I_WEEKLY-SPWOC
WKDAY = I_WKDAY-WKDAY
ARBPL = I_WEEKLY-ARBPL
MATNR = I_WEEKLY-MATNR.
IF SY-SUBRC <> C_0 OR I_WEEK1-MEINS = C_NULL.
CLEAR: I_WEEKLY-THU_PLAN,
I_WEEKLY-THU_ACT,
I_WEEKLY-THU_DIFF,
I_WEEKLY-THU_PERC.
ENDIF.
*--------------------BEGIN OF MOD-004----------------------*
* READ TABLE i_wkday INDEX 5.
* READ TABLE i_week1 WITH KEY spwoc = i_weekly-spwoc
* wkday = i_wkday-wkday
* arbpl = i_weekly-arbpl
* matnr = i_weekly-matnr.
*
* IF sy-subrc <> 0 OR i_week1-meins = c_null.
* CLEAR: i_weekly-fri_plan,
* i_weekly-fri_act,
* i_weekly-fri_diff,
* i_weekly-fri_perc.
* ENDIF.
*
* READ TABLE i_wkday INDEX 6.
* READ TABLE i_week1 WITH KEY spwoc = i_weekly-spwoc
* wkday = i_wkday-wkday
* arbpl = i_weekly-arbpl
* matnr = i_weekly-matnr.
*
* IF sy-subrc <> 0 OR i_week1-meins = c_null.
* CLEAR: i_weekly-sat_plan,
* i_weekly-sat_act,
* i_weekly-sat_diff,
* i_weekly-sat_perc.
* ENDIF.
*
* READ TABLE i_wkday INDEX 7.
* READ TABLE i_week1 WITH KEY spwoc = i_weekly-spwoc
* wkday = i_wkday-wkday
* arbpl = i_weekly-arbpl
* matnr = i_weekly-matnr.
*
* IF sy-subrc <> 0 OR i_week1-meins = c_null.
* CLEAR: i_weekly-sun_plan,
* i_weekly-sun_act,
* i_weekly-sun_diff,
* i_weekly-sun_perc.
* ENDIF.
*
* LOOP AT i_week1 WHERE spwoc = i_weekly-spwoc AND
* arbpl = i_weekly-arbpl AND
* matnr = i_weekly-matnr.
* IF i_week1-meins = c_null.
* CLEAR: i_weekly-tot_plan,
* i_weekly-tot_act,
* i_weekly-tot_diff,
* i_weekly-tot_perc.
* EXIT.
* ELSE.
* IF sy-tabix = 1.
* l_meins = i_week1-meins.
* ELSE.
* IF i_week1-meins <> l_meins.
* CLEAR: i_weekly-tot_plan,
* i_weekly-tot_act,
* i_weekly-tot_diff,
* i_weekly-tot_perc.
* EXIT.
* ENDIF.
* ENDIF.
* ENDIF.
* ENDLOOP.
*-------------------------END OF MOD-004----------------------------*
ENDFORM. " check_uom_week_res_mat
*&---------------------------------------------------------------------*
*& Form check_uom_week_res1
*&---------------------------------------------------------------------*
* Checking the UOM for summation at resource Level
* For the week from Monday to Thursday
*----------------------------------------------------------------------*
FORM CHECK_UOM_WEEK_RES1 .
READ TABLE I_WKDAY INDEX C_1.
READ TABLE I_WEEK2 WITH KEY SPWOC = I_WEEKLY-SPWOC
WKDAY = I_WKDAY-WKDAY
ARBPL = I_WEEKLY-ARBPL.
IF SY-SUBRC <> C_0 OR I_WEEK2-MEINS = C_NULL.
CLEAR: I_WEEKLY-MON_PLAN,
I_WEEKLY-MON_ACT,
I_WEEKLY-MON_DIFF,
I_WEEKLY-MON_PERC.
ENDIF.
READ TABLE I_WKDAY INDEX C_2.
READ TABLE I_WEEK2 WITH KEY SPWOC = I_WEEKLY-SPWOC
WKDAY = I_WKDAY-WKDAY
ARBPL = I_WEEKLY-ARBPL.
IF SY-SUBRC <> C_0 OR I_WEEK2-MEINS = C_NULL.
CLEAR: I_WEEKLY-TUE_PLAN,
I_WEEKLY-TUE_ACT,
I_WEEKLY-TUE_DIFF,
I_WEEKLY-TUE_PERC.
ENDIF.
READ TABLE I_WKDAY INDEX C_3.
READ TABLE I_WEEK2 WITH KEY SPWOC = I_WEEKLY-SPWOC
WKDAY = I_WKDAY-WKDAY
ARBPL = I_WEEKLY-ARBPL.
IF SY-SUBRC <> C_0 OR I_WEEK2-MEINS = C_NULL.
CLEAR: I_WEEKLY-WED_PLAN,
I_WEEKLY-WED_ACT,
I_WEEKLY-WED_DIFF,
I_WEEKLY-WED_PERC.
ENDIF.
READ TABLE I_WKDAY INDEX C_4.
READ TABLE I_WEEK2 WITH KEY SPWOC = I_WEEKLY-SPWOC
WKDAY = I_WKDAY-WKDAY
ARBPL = I_WEEKLY-ARBPL.
IF SY-SUBRC <> C_0 OR I_WEEK2-MEINS = C_NULL.
CLEAR: I_WEEKLY-THU_PLAN,
I_WEEKLY-THU_ACT,
I_WEEKLY-THU_DIFF,
I_WEEKLY-THU_PERC.
ENDIF.
*-----------------------BEGIN OF MOD-004---------------------*
* READ TABLE i_wkday INDEX 5.
* READ TABLE i_week2 WITH KEY spwoc = i_weekly-spwoc
* wkday = i_wkday-wkday
* arbpl = i_weekly-arbpl.
* IF sy-subrc <> 0 OR i_week2-meins = c_null.
* CLEAR: i_weekly-fri_plan,
* i_weekly-fri_act,
* i_weekly-fri_diff,
* i_weekly-fri_perc.
* ENDIF.
*
* READ TABLE i_wkday INDEX 6.
* READ TABLE i_week2 WITH KEY spwoc = i_weekly-spwoc
* wkday = i_wkday-wkday
* arbpl = i_weekly-arbpl.
* IF sy-subrc <> 0 OR i_week2-meins = c_null.
* CLEAR: i_weekly-sat_plan,
* i_weekly-sat_act,
* i_weekly-sat_diff,
* i_weekly-sat_perc.
* ENDIF.
*
* READ TABLE i_wkday INDEX 7.
* READ TABLE i_week2 WITH KEY spwoc = i_weekly-spwoc
* wkday = i_wkday-wkday
* arbpl = i_weekly-arbpl.
* IF sy-subrc <> 0 OR i_week2-meins = c_null.
* CLEAR: i_weekly-sun_plan,
* i_weekly-sun_act,
* i_weekly-sun_diff,
* i_weekly-sun_perc.
* ENDIF.
*
* LOOP AT i_week2 WHERE spwoc = i_weekly-spwoc AND
* arbpl = i_weekly-arbpl.
* IF i_week2-meins = c_null.
* CLEAR: i_weekly-tot_plan,
* i_weekly-tot_act,
* i_weekly-tot_diff,
* i_weekly-tot_perc.
* EXIT.
* ELSE.
* IF sy-tabix = 1.
* l_meins = i_week2-meins.
* ELSE.
* IF i_week2-meins <> l_meins.
* CLEAR: i_weekly-tot_plan,
* i_weekly-tot_act,
* i_weekly-tot_diff,
* i_weekly-tot_perc.
* EXIT.
* ENDIF.
* ENDIF.
* ENDIF.
* ENDLOOP.
*------------------------END OF MOD-004------------------------*
ENDFORM. " check_uom_week_res
 
*&---------------------------------------------------------------------*
*& Form check_uom_week1
*&---------------------------------------------------------------------*
* Checking the UOM for summation at week Level
* For the week from Monday to Thursday
*----------------------------------------------------------------------*
FORM CHECK_UOM_WEEK1 .
READ TABLE I_WKDAY INDEX C_1.
READ TABLE I_WEEK3 WITH KEY SPWOC = I_WEEKLY-SPWOC
WKDAY = I_WKDAY-WKDAY.
IF SY-SUBRC <> C_0 OR I_WEEK3-MEINS = C_NULL.
CLEAR: I_WEEKLY-MON_PLAN,
I_WEEKLY-MON_ACT,
I_WEEKLY-MON_DIFF,
I_WEEKLY-MON_PERC.
ENDIF.
READ TABLE I_WKDAY INDEX C_2.
READ TABLE I_WEEK3 WITH KEY SPWOC = I_WEEKLY-SPWOC
WKDAY = I_WKDAY-WKDAY.
IF SY-SUBRC <> C_0 OR I_WEEK3-MEINS = C_NULL.
CLEAR: I_WEEKLY-TUE_PLAN,
I_WEEKLY-TUE_ACT,
I_WEEKLY-TUE_DIFF,
I_WEEKLY-TUE_PERC.
ENDIF.
READ TABLE I_WKDAY INDEX C_3.
READ TABLE I_WEEK3 WITH KEY SPWOC = I_WEEKLY-SPWOC
WKDAY = I_WKDAY-WKDAY.
IF SY-SUBRC <> C_0 OR I_WEEK3-MEINS = C_NULL.
CLEAR: I_WEEKLY-WED_PLAN,
I_WEEKLY-WED_ACT,
I_WEEKLY-WED_DIFF,
I_WEEKLY-WED_PERC.
ENDIF.
READ TABLE I_WKDAY INDEX C_4.
READ TABLE I_WEEK3 WITH KEY SPWOC = I_WEEKLY-SPWOC
WKDAY = I_WKDAY-WKDAY.
IF SY-SUBRC <> C_0 OR I_WEEK3-MEINS = C_NULL.
CLEAR: I_WEEKLY-THU_PLAN,
I_WEEKLY-THU_ACT,
I_WEEKLY-THU_DIFF,
I_WEEKLY-THU_PERC.
ENDIF.
*-----------------------BEGIN OF MOD-004-----------------------*
* READ TABLE i_wkday INDEX 5.
* READ TABLE i_week3 WITH KEY spwoc = i_weekly-spwoc
* wkday = i_wkday-wkday.
*
* IF sy-subrc <> 0 OR i_week3-meins = c_null.
* CLEAR: i_weekly-fri_plan,
* i_weekly-fri_act,
* i_weekly-fri_diff,
* i_weekly-fri_perc.
* ENDIF.
*
* READ TABLE i_wkday INDEX 6.
* READ TABLE i_week3 WITH KEY spwoc = i_weekly-spwoc
* wkday = i_wkday-wkday.
*
* IF sy-subrc <> 0 OR i_week3-meins = c_null.
* CLEAR: i_weekly-sat_plan,
* i_weekly-sat_act,
* i_weekly-sat_diff,
* i_weekly-sat_perc.
* ENDIF.
*
* READ TABLE i_wkday INDEX 7.
* READ TABLE i_week3 WITH KEY spwoc = i_weekly-spwoc
* wkday = i_wkday-wkday.
*
* IF sy-subrc <> 0 OR i_week3-meins = c_null.
* CLEAR: i_weekly-sun_plan,
* i_weekly-sun_act,
* i_weekly-sun_diff,
* i_weekly-sun_perc.
* ENDIF.
*
* LOOP AT i_week3 WHERE spwoc = i_weekly-spwoc.
* IF i_week3-meins = c_null.
* CLEAR: i_weekly-tot_plan,
* i_weekly-tot_act,
* i_weekly-tot_diff,
* i_weekly-tot_perc.
* EXIT.
* ELSE.
* IF sy-tabix = 1.
* l_meins = i_week3-meins.
* ELSE.
* IF i_week3-meins <> l_meins.
* CLEAR: i_weekly-tot_plan,
* i_weekly-tot_act,
* i_weekly-tot_diff,
* i_weekly-tot_perc.
* EXIT.
* ENDIF.
* ENDIF.
* ENDIF.
* ENDLOOP.
*------------------------END OF MOD-004------------------------------*
ENDFORM. " check_uom_week
*&---------------------------------------------------------------------*
*& FORM DISPLAY_WK_TOT1
*&---------------------------------------------------------------------*
* Subroutine to display the week day Totals
* for the week from Monday to thursday
*----------------------------------------------------------------------*
** Begin of Mod-001
FORM DISPLAY_WK_TOT1 USING P_I_TEXT.
WRITE: /(14) P_I_TEXT,
SY-VLINE,
* (6) i_weekly-mon_plan NO-SIGN,
* (6) i_weekly-mon_act NO-SIGN,
* (6) i_weekly-mon_diff NO-SIGN,
* (4) i_weekly-mon_perc NO-SIGN,
* sy-vline,
* (6) i_weekly-tue_plan NO-SIGN,
* (6) i_weekly-tue_act NO-SIGN,
* (6) i_weekly-tue_diff NO-SIGN,
* (4) i_weekly-tue_perc NO-SIGN,
* sy-vline,
* (6) i_weekly-wed_plan NO-SIGN,
* (6) i_weekly-wed_act NO-SIGN,
* (6) i_weekly-wed_diff NO-SIGN,
* (4) i_weekly-wed_perc NO-SIGN,
* sy-vline,
* (6) i_weekly-thu_plan NO-SIGN,
* (6) i_weekly-thu_act NO-SIGN,
* (6) i_weekly-thu_diff NO-SIGN,
* (4) i_weekly-thu_perc NO-SIGN,
* sy-vline,
* (6) i_weekly-fri_plan NO-SIGN,
* (6) i_weekly-fri_act NO-SIGN,
* (6) i_weekly-fri_diff NO-SIGN,
* (4) i_weekly-fri_perc NO-SIGN,
* sy-vline,
* (6) i_weekly-sat_plan NO-SIGN,
* (6) i_weekly-sat_act NO-SIGN,
* (6) i_weekly-sat_diff NO-SIGN,
* (4) i_weekly-sat_perc NO-SIGN,
* sy-vline,
* (6) i_weekly-sun_plan NO-SIGN,
* (6) i_weekly-sun_act NO-SIGN,
* (6) i_weekly-sun_diff NO-SIGN,
* (4) i_weekly-sun_perc NO-SIGN,
* sy-vline,
* (6) i_weekly-tot_plan NO-SIGN,
* (6) i_weekly-tot_act NO-SIGN,
* (6) i_weekly-tot_diff NO-SIGN,
* (4) i_weekly-tot_perc NO-SIGN,
* sy-vline.
* IF rb_fval = c_x.
* WRITE: (3) rec_weekly-waers.
* ENDIF.
* WRITE: 245 sy-vline.
* ULINE (245).
*
(8) I_WEEKLY-MON_PLAN NO-SIGN LEFT-JUSTIFIED,
(8) I_WEEKLY-MON_ACT NO-SIGN LEFT-JUSTIFIED,
(8) I_WEEKLY-MON_DIFF NO-SIGN LEFT-JUSTIFIED,
(4) I_WEEKLY-MON_PERC NO-SIGN LEFT-JUSTIFIED,
SY-VLINE,
(8) I_WEEKLY-TUE_PLAN NO-SIGN LEFT-JUSTIFIED,
(8) I_WEEKLY-TUE_ACT NO-SIGN LEFT-JUSTIFIED,
(8) I_WEEKLY-TUE_DIFF NO-SIGN LEFT-JUSTIFIED,
(4) I_WEEKLY-TUE_PERC NO-SIGN LEFT-JUSTIFIED,
SY-VLINE,
(8) I_WEEKLY-WED_PLAN NO-SIGN LEFT-JUSTIFIED,
(8) I_WEEKLY-WED_ACT NO-SIGN LEFT-JUSTIFIED,
(8) I_WEEKLY-WED_DIFF NO-SIGN LEFT-JUSTIFIED,
(4) I_WEEKLY-WED_PERC NO-SIGN LEFT-JUSTIFIED,
SY-VLINE,
(8) I_WEEKLY-THU_PLAN NO-SIGN LEFT-JUSTIFIED,
(8) I_WEEKLY-THU_ACT NO-SIGN LEFT-JUSTIFIED,
(8) I_WEEKLY-THU_DIFF NO-SIGN LEFT-JUSTIFIED,
(4) I_WEEKLY-THU_PERC NO-SIGN LEFT-JUSTIFIED,
SY-VLINE.
*--------------------------BEGIN OF MOD-004-------------------------*
* (8) i_weekly-fri_plan NO-SIGN LEFT-JUSTIFIED,
* (8) i_weekly-fri_act NO-SIGN LEFT-JUSTIFIED,
* (8) i_weekly-fri_diff NO-SIGN LEFT-JUSTIFIED,
* (4) i_weekly-fri_perc NO-SIGN LEFT-JUSTIFIED,
* sy-vline,
* (8) i_weekly-sat_plan NO-SIGN LEFT-JUSTIFIED,
* (8) i_weekly-sat_act NO-SIGN LEFT-JUSTIFIED,
* (8) i_weekly-sat_diff NO-SIGN LEFT-JUSTIFIED,
* (4) i_weekly-sat_perc NO-SIGN LEFT-JUSTIFIED,
* sy-vline,
* (8) i_weekly-sun_plan NO-SIGN LEFT-JUSTIFIED,
* (8) i_weekly-sun_act NO-SIGN LEFT-JUSTIFIED,
* (8) i_weekly-sun_diff NO-SIGN LEFT-JUSTIFIED,
* (4) i_weekly-sun_perc NO-SIGN LEFT-JUSTIFIED,
* sy-vline,
* (8) i_weekly-tot_plan NO-SIGN LEFT-JUSTIFIED,
* (8) i_weekly-tot_act NO-SIGN LEFT-JUSTIFIED,
* (8) i_weekly-tot_diff NO-SIGN LEFT-JUSTIFIED,
* (4) i_weekly-tot_perc NO-SIGN LEFT-JUSTIFIED,
* sy-vline.
*--------------------------END OF MOD-004---------------------------*
IF RB_FVAL = C_X.
WRITE: (3) REC_WEEKLY-WAERS.
ENDIF.
WRITE: 156 SY-VLINE.
ULINE (156).
 
*** End of Mod-001
ENDFORM. " display_wk_tot.
*&---------------------------------------------------------------------*
*& FORM CALCULATE_WK_PERC1
*&---------------------------------------------------------------------*
* Subroutine to Calculate Week Percentages
* For the week from Monday to Thursday
*----------------------------------------------------------------------*
FORM CALCULATE_WK_PERC1.
PERFORM CALCULATE_PERCENTAGE USING I_WEEKLY-MON_PLAN
I_WEEKLY-MON_DIFF
CHANGING I_WEEKLY-MON_PERC.
PERFORM CALCULATE_PERCENTAGE USING I_WEEKLY-TUE_PLAN
I_WEEKLY-TUE_DIFF
CHANGING I_WEEKLY-TUE_PERC.
PERFORM CALCULATE_PERCENTAGE USING I_WEEKLY-WED_PLAN
I_WEEKLY-WED_DIFF
CHANGING I_WEEKLY-WED_PERC.
PERFORM CALCULATE_PERCENTAGE USING I_WEEKLY-THU_PLAN
I_WEEKLY-THU_DIFF
CHANGING I_WEEKLY-THU_PERC.
*------------------------BEGIN OF MOD-004------------------------------*
* PERFORM calculate_percentage USING i_weekly-fri_plan
* i_weekly-fri_diff
* CHANGING i_weekly-fri_perc.
*
* PERFORM calculate_percentage USING i_weekly-sat_plan
* i_weekly-sat_diff
* CHANGING i_weekly-sat_perc.
*
* PERFORM calculate_percentage USING i_weekly-sun_plan
* i_weekly-sun_diff
* CHANGING i_weekly-sun_perc.
*
* PERFORM calculate_percentage USING i_weekly-tot_plan
* i_weekly-tot_diff
* CHANGING i_weekly-tot_perc.
*------------------------END OF MOD-004------------------------------*
ENDFORM. " calculate_wk_prec
*&---------------------------------------------------------------------*
*& FORM GET_RESDESC
*&---------------------------------------------------------------------*
* subroutine to get the Resource Description
*----------------------------------------------------------------------*
* -->P_i_WERKS text
* -->P_i_WEEKLY_ARBPL text
* <--P_i_RTEXT text
*----------------------------------------------------------------------*
FORM GET_RESDESC USING P_I_ARBPL
P_I_WERKS
CHANGING P_I_RTEXT.
CALL FUNCTION 'CR_WORKSTATION_CHECK'
EXPORTING
ARBPL = P_I_ARBPL
WERKS = P_I_WERKS
IMPORTING
KTEXT = P_I_RTEXT
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MOVE: P_I_ARBPL TO P_I_RTEXT.
ENDIF.
ENDFORM. " get_resdesc
*&---------------------------------------------------------------------*
*& FORM DISPLAY_FLOW
*&---------------------------------------------------------------------*
* Subroutine for to displaying the COR3 transaction based on order No
*----------------------------------------------------------------------*
* -->P_I_WEEKLY_AUFNR text
*----------------------------------------------------------------------*
FORM DISPLAY_FLOW USING P_I_WEEKLY-AUFNR.
IF NOT P_I_WEEKLY-AUFNR IS INITIAL.
**********MOD-003*********************************
SELECT SINGLE AUFNR
FROM AFKO
INTO AFKO-AUFNR
WHERE AUFNR = P_I_WEEKLY-AUFNR.
IF SY-SUBRC = 0.
SET PARAMETER ID C_BR1 FIELD P_I_WEEKLY-AUFNR.
CALL TRANSACTION C_TCODE AND SKIP FIRST SCREEN.
ELSE.
SELECT SINGLE PLNUM
FROM PLAF
INTO PLAF-PLNUM
WHERE PLNUM = P_I_WEEKLY-AUFNR.
IF SY-SUBRC = 0.
SET PARAMETER ID C_PAF FIELD P_I_WEEKLY-AUFNR.
CALL TRANSACTION C_TCODE1 AND SKIP FIRST SCREEN.
ENDIF.
ENDIF.
************mod-003*************************************
ENDIF.
ENDFORM. " display_flow
*&---------------------------------------------------------------------*
*& FORM DISPLAY_REPORT_FOOTER
*&---------------------------------------------------------------------*
* Subroutine to display the report footer
*----------------------------------------------------------------------*
FORM DISPLAY_REPORT_FOOTER .
FORMAT COLOR COL_BACKGROUND.
* CALL FUNCTION '/NESGLB/X_PRINT_REPORT_FOOTER'
* EXPORTING
* linsz = sy-linsz
* linct = sy-linct
* linno = sy-linno.
ENDFORM. " display_report_footer
 
*&---------------------------------------------------------------------*
*& FORM WRKCENTER_HEADER1.
*&---------------------------------------------------------------------*
* Subroutine to display work center Header for days
* from Monday to Thursday
*----------------------------------------------------------------------*
FORM WRKCENTER_HEADER1.
**Make the Default day/ as monday of the week.
CLEAR: V_RTEXT.
CALL FUNCTION 'WEEK_GET_FIRST_DAY'
EXPORTING
WEEK = I_WEEKLY-SPWOC
IMPORTING
DATE = V_MONDAY
EXCEPTIONS
WEEK_INVALID = 1
OTHERS = 2.
IF SY-SUBRC <> C_0.
CLEAR V_MONDAY.
ENDIF.
V_FMDAY = V_MONDAY.
IF CB_COLOR = C_X.
FORMAT COLOR COL_KEY INTENSIFIED OFF.
ENDIF.
WRITE: / TEXT-049,
12 REC_WEEKLY-ARBPL.
**Get the Work Center Description .
PERFORM GET_RESDESC USING REC_WEEKLY-ARBPL
P_WERKS
CHANGING V_RTEXT.
WRITE: 24 V_RTEXT,
**begin of mod-002
* 245 sy-vline.
156 SY-VLINE.
**end of mod-002
 
IF CB_COLOR = C_X.
FORMAT COLOR COL_HEADING INTENSIFIED ON.
ENDIF.
** begin of mod-002
* WRITE : /(14) ' ' , sy-vline.
** WRITE:(8) text-050,(13) v_fmday,44 sy-vline. v_fmday = v_fmday +
*1.
** WRITE:(10) text-051,(13) v_fmday,72 sy-vline. v_fmday = v_fmday +
*1.
** WRITE:(10) text-052,(13) v_fmday,295 sy-vline. v_fmday = v_fmday +
*1.
** WRITE:(10) text-053,(13) v_fmday,128 sy-vline. v_fmday = v_fmday +
*1.
** WRITE:(10) text-054,(13) v_fmday,156 sy-vline. v_fmday = v_fmday +
*1.
** WRITE:(10) text-055,(13) v_fmday,184 sy-vline. v_fmday = v_fmday +
*1.
** WRITE:(10) text-056,(13) v_fmday,212 sy-vline.
**
* WRITE:(26) text-057, 240 sy-vline, (3) '', 245 sy-vline.
*WRITE:(31) text-057, 288 sy-vline, (3) '', 295 sy-vline.
ULINE (156).
WRITE : /(14) ' ', SY-VLINE .
WRITE:(10) TEXT-050,(13) V_FMDAY,50 SY-VLINE. V_FMDAY = V_FMDAY + 1.
"46
WRITE:(10) TEXT-051,(13) V_FMDAY,84 SY-VLINE. V_FMDAY = V_FMDAY + 1.
"76
WRITE:(10) TEXT-052,(13) V_FMDAY,118 SY-VLINE. V_FMDAY = V_FMDAY + 1.
"106
WRITE:(10) TEXT-053,(13) V_FMDAY,152 SY-VLINE, 156 SY-VLINE.
"136
V_FMDAY = V_FMDAY + 1.
*-------------------------BEGIN OF MOD-004----------------------------*
** WRITE:(10) text-054,(13) v_fmday,186 sy-vline. v_fmday = v_fmday +
*1.
** WRITE:(10) text-055,(13) v_fmday,220 sy-vline. v_fmday = v_fmday +
*1.
** WRITE:(10) text-056,(13) v_fmday,254 sy-vline.
** WRITE:(31) text-057, 288 sy-vline, (3) '', 295 sy-vline.
*--------------------------END OF MOD-004-----------------------------*
ULINE (156).
WRITE : / TEXT-058.
**end of mod-002
 
DO 4 TIMES.
WRITE: SY-VLINE,(31) TEXT-068.
ENDDO.
IF RB_QUAN = C_X.
WRITE: SY-VLINE NO-GAP, (4) TEXT-070.
ELSE.
WRITE : SY-VLINE NO-GAP ,(4) TEXT-087.
ENDIF.
**begin of mod-002
* WRITE: 245 sy-vline.
* ULINE (245).
WRITE: 156 SY-VLINE.
ULINE (156).
**end of mod-002
ENDFORM. " Wrkcenter_Header
 
 
*------------------------BEGIN OF MOD-004------------------------*
FORM WRKCENTER_HEADER2.
**Make the Default day/ as monday of the week.
CLEAR: V_RTEXT.
V_FMDAY = V_MONDAY + C_4.
IF CB_COLOR = C_X.
FORMAT COLOR COL_KEY INTENSIFIED OFF.
ENDIF.
WRITE: / TEXT-049,
12 REC_WEEKLY-ARBPL.
**Get the Work Center Description .
PERFORM GET_RESDESC USING REC_WEEKLY-ARBPL
P_WERKS
CHANGING V_RTEXT.
WRITE: 24 V_RTEXT,
**begin of mod-002
* 245 sy-vline.
156 SY-VLINE.
**end of mod-002
 
IF CB_COLOR = C_X.
FORMAT COLOR COL_HEADING INTENSIFIED ON.
ENDIF.
** begin of mod-002
* WRITE : /(14) ' ' , sy-vline.
** WRITE:(8) text-050,(13) v_fmday,44 sy-vline. v_fmday = v_fmday +
*1.
** WRITE:(10) text-051,(13) v_fmday,72 sy-vline. v_fmday = v_fmday +
*1.
** WRITE:(10) text-052,(13) v_fmday,295 sy-vline. v_fmday = v_fmday +
*1.
** WRITE:(10) text-053,(13) v_fmday,128 sy-vline. v_fmday = v_fmday +
*1.
** WRITE:(10) text-054,(13) v_fmday,156 sy-vline. v_fmday = v_fmday +
*1.
** WRITE:(10) text-055,(13) v_fmday,184 sy-vline. v_fmday = v_fmday +
*1.
** WRITE:(10) text-056,(13) v_fmday,212 sy-vline.
**
* WRITE:(26) text-057, 240 sy-vline, (3) '', 245 sy-vline.
*WRITE:(31) text-057, 288 sy-vline, (3) '', 295 sy-vline.
ULINE (156).
WRITE : /(14) ' ', SY-VLINE .
* WRITE:(8) text-050,(13) v_fmday,50 sy-vline. v_fmday = v_fmday + 1
*.
* WRITE:(10) text-051,(13) v_fmday,84 sy-vline. v_fmday = v_fmday + 1
*.
* WRITE:(10) text-052,(13) v_fmday,118 sy-vline. v_fmday = v_fmday + 1
*.
* WRITE:(10) text-053,(13) v_fmday,152 sy-vline. v_fmday = v_fmday + 1
*.
WRITE:(10) TEXT-054,(13) V_FMDAY,50 SY-VLINE. V_FMDAY = V_FMDAY + 1.
WRITE:(10) TEXT-055,(13) V_FMDAY,84 SY-VLINE. V_FMDAY = V_FMDAY + 1.
WRITE:(10) TEXT-056,(13) V_FMDAY,118 SY-VLINE.
WRITE:(10) TEXT-057, 152 SY-VLINE, (3) '', 156 SY-VLINE.
ULINE (156).
WRITE : / TEXT-058.
**end of mod-002
 
DO 4 TIMES.
WRITE: SY-VLINE,(31) TEXT-068.
ENDDO.
IF RB_QUAN = C_X.
WRITE: SY-VLINE NO-GAP, (4) TEXT-070.
ELSE.
WRITE : SY-VLINE NO-GAP ,(4) TEXT-087.
ENDIF.
**begin of mod-002
* WRITE: 245 sy-vline.
* ULINE (245).
WRITE: 156 SY-VLINE.
ULINE (156).
**end of mod-002
ENDFORM. " Wrkcenter_Header
 
 
*&---------------------------------------------------------------------*
*& Form display_weekly_report_next
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DISPLAY_WEEKLY_REPORT_NEXT .
SORT I_TEMP_WEEKLY BY SPWOC ARBPL MATNR.
LOOP AT I_TEMP_WEEKLY.
CLEAR REC_WEEKLY.
MOVE I_TEMP_WEEKLY TO REC_WEEKLY.
** At new workcenter display the workcenter header
AT NEW ARBPL.
PERFORM WRKCENTER_HEADER2.
ENDAT.
** At new Material display the material Header
AT NEW MATNR.
PERFORM MATERIAL_HEADER.
ENDAT.
**Check for the Detail level Report or Summary Level Report
**If it is a Detail Level Report display the materials and
**Corresponding orders
IF RB_DET = C_X.
IF CB_COLOR = C_X.
FORMAT COLOR COL_NORMAL INTENSIFIED OFF.
ENDIF.
PERFORM SHOW_WEEKLY_ORDERS2.
ENDIF.
**if it is summary level report Show only the material numbers
AT END OF MATNR.
SUM.
** check whether to display the quantities and order units
IF RB_QUAN = C_X AND RB_ORD = C_X.
PERFORM CHECK_UOM_WEEK_RES_MAT2.
ENDIF.
* Calculate the percentage difference for
* the material total for the week from Fri to tot
PERFORM CALCULATE_WK_PERC2.
IF CB_COLOR = C_X.
FORMAT COLOR COL_TOTAL INTENSIFIED ON.
ENDIF.
* Display the material total for the week from Fri to tot
PERFORM DISPLAY_WK_TOT2 USING TEXT-088.
ENDAT.
AT END OF ARBPL.
SUM.
** check whether to display the quantities and order units
IF RB_QUAN = C_X AND RB_ORD = C_X.
PERFORM CHECK_UOM_WEEK_RES2.
ENDIF.
* Calculate the percentage difference for
* the Resource total for the week from Fri to tot
PERFORM CALCULATE_WK_PERC2.
IF CB_COLOR = C_X.
FORMAT COLOR COL_KEY INTENSIFIED OFF.
ENDIF.
* Display the Resource total for the week from Fri to tot
PERFORM DISPLAY_WK_TOT2 USING TEXT-089.
ENDAT.
AT END OF SPWOC.
SUM.
** check whether to display the quantities and order units
IF RB_QUAN = C_X AND RB_ORD = C_X.
PERFORM CHECK_UOM_WEEK2.
ENDIF.
* Calculate the percentage difference for
* the Week total for the week from Fri to tot
PERFORM CALCULATE_WK_PERC2.
* IF cb_color = c_x.
* FORMAT COLOR COL_POSITIVE INTENSIFIED OFF.
* ENDIF.
** PERFORM display_wk_tot2 USING text-091.
SKIP 1.
ENDAT.
ENDLOOP.
CLEAR: REC_TEMP_WEEKLY,
I_TEMP_WEEKLY.
REFRESH: I_TEMP_WEEKLY.
ENDFORM. " display_weekly_report_next
 
 
 
*&---------------------------------------------------------------------*
*& Form show_weekly_orders2
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM SHOW_WEEKLY_ORDERS2 .
WRITE: /(14) REC_WEEKLY-AUFNR.
WRITE: SY-VLINE,
* (8) rec_weekly-mon_plan NO-SIGN LEFT-JUSTIFIED,
* (8) rec_weekly-mon_act NO-SIGN LEFT-JUSTIFIED,
* (8) rec_weekly-mon_diff NO-SIGN LEFT-JUSTIFIED,
* (4) rec_weekly-mon_perc NO-SIGN LEFT-JUSTIFIED,
* sy-vline,
* (8) rec_weekly-tue_plan NO-SIGN LEFT-JUSTIFIED,
* (8) rec_weekly-tue_act NO-SIGN LEFT-JUSTIFIED,
* (8) rec_weekly-tue_diff NO-SIGN LEFT-JUSTIFIED,
* (4) rec_weekly-tue_perc NO-SIGN LEFT-JUSTIFIED,
* sy-vline,
* (8) rec_weekly-wed_plan NO-SIGN LEFT-JUSTIFIED,
* (8) rec_weekly-wed_act NO-SIGN LEFT-JUSTIFIED,
* (8) rec_weekly-wed_diff NO-SIGN LEFT-JUSTIFIED,
* (4) rec_weekly-wed_perc NO-SIGN LEFT-JUSTIFIED,
* sy-vline,
* (8) rec_weekly-thu_plan NO-SIGN LEFT-JUSTIFIED,
* (8) rec_weekly-thu_act NO-SIGN LEFT-JUSTIFIED,
* (8) rec_weekly-thu_diff NO-SIGN LEFT-JUSTIFIED,
* (4) rec_weekly-thu_perc NO-SIGN LEFT-JUSTIFIED,
* sy-vline.
(8) REC_WEEKLY-FRI_PLAN NO-SIGN LEFT-JUSTIFIED,
(8) REC_WEEKLY-FRI_ACT NO-SIGN LEFT-JUSTIFIED,
(8) REC_WEEKLY-FRI_DIFF NO-SIGN LEFT-JUSTIFIED,
(4) REC_WEEKLY-FRI_PERC NO-SIGN LEFT-JUSTIFIED,
SY-VLINE,
(8) REC_WEEKLY-SAT_PLAN NO-SIGN LEFT-JUSTIFIED,
(8) REC_WEEKLY-SAT_ACT NO-SIGN LEFT-JUSTIFIED,
(8) REC_WEEKLY-SAT_DIFF NO-SIGN LEFT-JUSTIFIED,
(4) REC_WEEKLY-SAT_PERC NO-SIGN LEFT-JUSTIFIED,
SY-VLINE,
(8) REC_WEEKLY-SUN_PLAN NO-SIGN LEFT-JUSTIFIED,
(8) REC_WEEKLY-SUN_ACT NO-SIGN LEFT-JUSTIFIED,
(8) REC_WEEKLY-SUN_DIFF NO-SIGN LEFT-JUSTIFIED,
(4) REC_WEEKLY-SUN_PERC NO-SIGN LEFT-JUSTIFIED,
SY-VLINE,
(8) REC_WEEKLY-TOT_PLAN NO-SIGN LEFT-JUSTIFIED,
(8) REC_WEEKLY-TOT_ACT NO-SIGN LEFT-JUSTIFIED,
(8) REC_WEEKLY-TOT_DIFF NO-SIGN LEFT-JUSTIFIED,
(4) REC_WEEKLY-TOT_PERC NO-SIGN LEFT-JUSTIFIED,
SY-VLINE.
** end of mod-002.
IF RB_QUAN = C_X.
**begin of mod-002.
* WRITE: (3) rec_weekly-meins, 245 sy-vline.
* ELSE.
* WRITE: (3) rec_weekly-waers, 245 sy-vline.
* ENDIF.
* ULINE (245).
WRITE: (3) REC_WEEKLY-MEINS, 156 SY-VLINE.
ELSE.
WRITE: (3) REC_WEEKLY-WAERS, 156 SY-VLINE.
ENDIF.
ULINE (156).
ENDFORM. " show_weekly_orders2
 
 
*&---------------------------------------------------------------------*
*& Form check_uom_week_res_mat2
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CHECK_UOM_WEEK_RES_MAT2 .
DATA L_MEINS TYPE MEINS.
READ TABLE I_WKDAY INDEX C_5.
READ TABLE I_WEEK1 WITH KEY SPWOC = I_TEMP_WEEKLY-SPWOC
WKDAY = I_WKDAY-WKDAY
ARBPL = I_TEMP_WEEKLY-ARBPL
MATNR = I_TEMP_WEEKLY-MATNR.
IF SY-SUBRC <> C_0 OR I_WEEK1-MEINS = C_NULL.
CLEAR: I_TEMP_WEEKLY-FRI_PLAN,
I_TEMP_WEEKLY-FRI_ACT,
I_TEMP_WEEKLY-FRI_DIFF,
I_TEMP_WEEKLY-FRI_PERC.
ENDIF.
READ TABLE I_WKDAY INDEX C_6.
READ TABLE I_WEEK1 WITH KEY SPWOC = I_TEMP_WEEKLY-SPWOC
WKDAY = I_WKDAY-WKDAY
ARBPL = I_TEMP_WEEKLY-ARBPL
MATNR = I_TEMP_WEEKLY-MATNR.
IF SY-SUBRC <> C_0 OR I_WEEK1-MEINS = C_NULL.
CLEAR: I_TEMP_WEEKLY-SAT_PLAN,
I_TEMP_WEEKLY-SAT_ACT,
I_TEMP_WEEKLY-SAT_DIFF,
I_TEMP_WEEKLY-SAT_PERC.
ENDIF.
READ TABLE I_WKDAY INDEX C_7.
READ TABLE I_WEEK1 WITH KEY SPWOC = I_TEMP_WEEKLY-SPWOC
WKDAY = I_WKDAY-WKDAY
ARBPL = I_TEMP_WEEKLY-ARBPL
MATNR = I_TEMP_WEEKLY-MATNR.
IF SY-SUBRC <> C_0 OR I_WEEK1-MEINS = C_NULL.
CLEAR: I_TEMP_WEEKLY-SUN_PLAN,
I_TEMP_WEEKLY-SUN_ACT,
I_TEMP_WEEKLY-SUN_DIFF,
I_TEMP_WEEKLY-SUN_PERC.
ENDIF.
LOOP AT I_WEEK1 WHERE SPWOC = I_TEMP_WEEKLY-SPWOC AND
ARBPL = I_TEMP_WEEKLY-ARBPL AND
MATNR = I_TEMP_WEEKLY-MATNR.
IF I_WEEK1-MEINS = C_NULL.
CLEAR: I_TEMP_WEEKLY-TOT_PLAN,
I_TEMP_WEEKLY-TOT_ACT,
I_TEMP_WEEKLY-TOT_DIFF,
I_TEMP_WEEKLY-TOT_PERC.
EXIT.
ELSE.
IF SY-TABIX = C_1.
L_MEINS = I_WEEK1-MEINS.
ELSE.
IF I_WEEK1-MEINS <> L_MEINS.
CLEAR: I_TEMP_WEEKLY-TOT_PLAN,
I_TEMP_WEEKLY-TOT_ACT,
I_TEMP_WEEKLY-TOT_DIFF,
I_TEMP_WEEKLY-TOT_PERC.
EXIT.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM. " check_uom_week_res_mat2
 
 
*&---------------------------------------------------------------------*
*& Form calculate_wk_perc2
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CALCULATE_WK_PERC2 .
PERFORM CALCULATE_PERCENTAGE USING I_TEMP_WEEKLY-FRI_PLAN
I_TEMP_WEEKLY-FRI_DIFF
CHANGING I_TEMP_WEEKLY-FRI_PERC.
PERFORM CALCULATE_PERCENTAGE USING I_TEMP_WEEKLY-SAT_PLAN
I_TEMP_WEEKLY-SAT_DIFF
CHANGING I_TEMP_WEEKLY-SAT_PERC.
PERFORM CALCULATE_PERCENTAGE USING I_TEMP_WEEKLY-SUN_PLAN
I_TEMP_WEEKLY-SUN_DIFF
CHANGING I_TEMP_WEEKLY-SUN_PERC.
PERFORM CALCULATE_PERCENTAGE USING I_TEMP_WEEKLY-TOT_PLAN
I_TEMP_WEEKLY-TOT_DIFF
CHANGING I_TEMP_WEEKLY-TOT_PERC.
ENDFORM. " calculate_wk_perc2
 
 
*&---------------------------------------------------------------------*
*& Form check_uom_week_res2
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CHECK_UOM_WEEK_RES2 .
DATA L_MEINS TYPE MEINS.
READ TABLE I_WKDAY INDEX C_5.
READ TABLE I_WEEK2 WITH KEY SPWOC = I_WEEKLY-SPWOC
WKDAY = I_WKDAY-WKDAY
ARBPL = I_WEEKLY-ARBPL.
IF SY-SUBRC <> C_0 OR I_WEEK2-MEINS = C_NULL.
CLEAR: I_WEEKLY-FRI_PLAN,
I_WEEKLY-FRI_ACT,
I_WEEKLY-FRI_DIFF,
I_WEEKLY-FRI_PERC.
ENDIF.
READ TABLE I_WKDAY INDEX C_6.
READ TABLE I_WEEK2 WITH KEY SPWOC = I_WEEKLY-SPWOC
WKDAY = I_WKDAY-WKDAY
ARBPL = I_WEEKLY-ARBPL.
IF SY-SUBRC <> C_0 OR I_WEEK2-MEINS = C_NULL.
CLEAR: I_WEEKLY-SAT_PLAN,
I_WEEKLY-SAT_ACT,
I_WEEKLY-SAT_DIFF,
I_WEEKLY-SAT_PERC.
ENDIF.
READ TABLE I_WKDAY INDEX C_7.
READ TABLE I_WEEK2 WITH KEY SPWOC = I_WEEKLY-SPWOC
WKDAY = I_WKDAY-WKDAY
ARBPL = I_WEEKLY-ARBPL.
IF SY-SUBRC <> C_0 OR I_WEEK2-MEINS = C_NULL.
CLEAR: I_WEEKLY-SUN_PLAN,
I_WEEKLY-SUN_ACT,
I_WEEKLY-SUN_DIFF,
I_WEEKLY-SUN_PERC.
ENDIF.
LOOP AT I_WEEK2 WHERE SPWOC = I_WEEKLY-SPWOC AND
ARBPL = I_WEEKLY-ARBPL.
IF I_WEEK2-MEINS = C_NULL.
CLEAR: I_WEEKLY-TOT_PLAN,
I_WEEKLY-TOT_ACT,
I_WEEKLY-TOT_DIFF,
I_WEEKLY-TOT_PERC.
EXIT.
ELSE.
IF SY-TABIX = C_1.
L_MEINS = I_WEEK2-MEINS.
ELSE.
IF I_WEEK2-MEINS <> L_MEINS.
CLEAR: I_WEEKLY-TOT_PLAN,
I_WEEKLY-TOT_ACT,
I_WEEKLY-TOT_DIFF,
I_WEEKLY-TOT_PERC.
EXIT.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM. " check_uom_week_res2
 
 
*&---------------------------------------------------------------------*
*& Form check_uom_week2
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CHECK_UOM_WEEK2 .
DATA L_MEINS TYPE MEINS.
READ TABLE I_WKDAY INDEX C_5.
READ TABLE I_WEEK3 WITH KEY SPWOC = I_WEEKLY-SPWOC
WKDAY = I_WKDAY-WKDAY.
IF SY-SUBRC <> C_0 OR I_WEEK3-MEINS = C_NULL.
CLEAR: I_WEEKLY-FRI_PLAN,
I_WEEKLY-FRI_ACT,
I_WEEKLY-FRI_DIFF,
I_WEEKLY-FRI_PERC.
ENDIF.
READ TABLE I_WKDAY INDEX C_6.
READ TABLE I_WEEK3 WITH KEY SPWOC = I_WEEKLY-SPWOC
WKDAY = I_WKDAY-WKDAY.
IF SY-SUBRC <> C_0 OR I_WEEK3-MEINS = C_NULL.
CLEAR: I_WEEKLY-SAT_PLAN,
I_WEEKLY-SAT_ACT,
I_WEEKLY-SAT_DIFF,
I_WEEKLY-SAT_PERC.
ENDIF.
READ TABLE I_WKDAY INDEX C_7.
READ TABLE I_WEEK3 WITH KEY SPWOC = I_WEEKLY-SPWOC
WKDAY = I_WKDAY-WKDAY.
IF SY-SUBRC <> C_0 OR I_WEEK3-MEINS = C_NULL.
CLEAR: I_WEEKLY-SUN_PLAN,
I_WEEKLY-SUN_ACT,
I_WEEKLY-SUN_DIFF,
I_WEEKLY-SUN_PERC.
ENDIF.
LOOP AT I_WEEK3 WHERE SPWOC = I_WEEKLY-SPWOC.
IF I_WEEK3-MEINS = C_NULL.
CLEAR: I_WEEKLY-TOT_PLAN,
I_WEEKLY-TOT_ACT,
I_WEEKLY-TOT_DIFF,
I_WEEKLY-TOT_PERC.
EXIT.
ELSE.
IF SY-TABIX = C_1.
L_MEINS = I_WEEK3-MEINS.
ELSE.
IF I_WEEK3-MEINS <> L_MEINS.
CLEAR: I_WEEKLY-TOT_PLAN,
I_WEEKLY-TOT_ACT,
I_WEEKLY-TOT_DIFF,
I_WEEKLY-TOT_PERC.
EXIT.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM. " check_uom_week2
 
 
*&---------------------------------------------------------------------*
*& Form display_wk_tot2
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_TEXT_088 text
*----------------------------------------------------------------------*
FORM DISPLAY_WK_TOT2 USING P_I_TEXT.
WRITE: /(14) P_I_TEXT,
SY-VLINE,
(8) I_WEEKLY-FRI_PLAN NO-SIGN LEFT-JUSTIFIED,
(8) I_WEEKLY-FRI_ACT NO-SIGN LEFT-JUSTIFIED,
(8) I_WEEKLY-FRI_DIFF NO-SIGN LEFT-JUSTIFIED,
(4) I_WEEKLY-FRI_PERC NO-SIGN LEFT-JUSTIFIED,
SY-VLINE,
(8) I_WEEKLY-SAT_PLAN NO-SIGN LEFT-JUSTIFIED,
(8) I_WEEKLY-SAT_ACT NO-SIGN LEFT-JUSTIFIED,
(8) I_WEEKLY-SAT_DIFF NO-SIGN LEFT-JUSTIFIED,
(4) I_WEEKLY-SAT_PERC NO-SIGN LEFT-JUSTIFIED,
SY-VLINE,
(8) I_WEEKLY-SUN_PLAN NO-SIGN LEFT-JUSTIFIED,
(8) I_WEEKLY-SUN_ACT NO-SIGN LEFT-JUSTIFIED,
(8) I_WEEKLY-SUN_DIFF NO-SIGN LEFT-JUSTIFIED,
(4) I_WEEKLY-SUN_PERC NO-SIGN LEFT-JUSTIFIED,
SY-VLINE,
(8) I_WEEKLY-TOT_PLAN NO-SIGN LEFT-JUSTIFIED,
(8) I_WEEKLY-TOT_ACT NO-SIGN LEFT-JUSTIFIED,
(8) I_WEEKLY-TOT_DIFF NO-SIGN LEFT-JUSTIFIED,
(4) I_WEEKLY-TOT_PERC NO-SIGN LEFT-JUSTIFIED,
SY-VLINE.
IF RB_FVAL = C_X.
WRITE: (3) REC_WEEKLY-WAERS.
ENDIF.
WRITE: 156 SY-VLINE.
ULINE (156).
ENDFORM. " display_wk_tot2
 
 
 
*&---------------------------------------------------------------------*
*& Form get_parameters_for_print
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
*FORM get_parameters_for_print CHANGING fp_out_params TYPE pri_params
* fp_valid TYPE c.
*
* DATA : l_arc_params TYPE arc_params,
* l_wa_DDPRTLIST type DDPRTLIST.
*
** CALL FUNCTION 'DDIF_OBJECT_PRINT_VARIANT'
** EXPORTING
** paramname = 'SAPMEDINFO'
** tables
** objlist = l_wa_DDPRTLIST.
** EXCEPTIONS
** NOT_FOUND = 1
** OTHERS = 2
** .
** IF sy-subrc <> 0.
*** MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*** WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
** ENDIF.
*
*
* CALL FUNCTION 'GET_PRINT_PARAMETERS'
* EXPORTING
* copies = p_cop
* destination = p_print
** EXPIRATION = C_NUM1_UNKNOWN
* immediately = cb_imp
** layout = 'X_58_170'
* line_count = c_55
* line_size = sy-linsz
* list_name = c_list
** LIST_TEXT = C_CHAR_UNKNOWN
** MODE = ' '
* no_dialog = c_x
* report = sy-repid
* user = sy-uname
* IMPORTING
* out_archive_parameters = l_arc_params
* out_parameters = fp_out_params
* valid = fp_valid
* EXCEPTIONS
* archive_info_not_found = 1
* invalid_print_params = 2
* invalid_archive_params = 3
* OTHERS = 4.
* IF sy-subrc <> c_0.
* CASE sy-subrc.
* WHEN c_1.
* MESSAGE e073. " Archive information not found
* WHEN c_2.
* MESSAGE e074. " Invalid print parameters
* WHEN c_3.
* MESSAGE e075. " Invalid archive parameters
* ENDCASE.
* ENDIF.
*
*ENDFORM. " get_parameters_for_print
 
 
*&---------------------------------------------------------------------*
*& Form print_on
*&---------------------------------------------------------------------*
* Start the print by writing ABAP list to spool
*----------------------------------------------------------------------*
* -->FP_REC_OUT_PARAMS -- Print parameters
* -->FP_V_VALID -- Validity Indicator
*----------------------------------------------------------------------*
FORM PRINT_ON USING FP_REC_OUT_PARAMS TYPE PRI_PARAMS
" Print parameters
FP_V_VALID TYPE C. " Validity Indicator
IF NOT FP_V_VALID IS INITIAL.
* Write ABAP List to Spool
NEW-PAGE PRINT ON NEW-SECTION
PARAMETERS FP_REC_OUT_PARAMS " Print Parameters
NO DIALOG. " No dialog needed
ENDIF.
ENDFORM. " print_on
 
*&---------------------------------------------------------------------*
*& Form print_off
*&---------------------------------------------------------------------*
* Terminate the Print
*----------------------------------------------------------------------*
FORM PRINT_OFF .
NEW-PAGE PRINT OFF.
ENDFORM. " print_off
 
*&---------------------------------------------------------------------*
*& Form convert_unit_to_kg
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CONVERT_UNIT_TO_KG .
LOOP AT I_WEEKLY INTO REC_WEEKLY.
PERFORM CONVERT_TO_KG CHANGING: REC_WEEKLY-MON_PLAN,
REC_WEEKLY-MON_ACT,
REC_WEEKLY-MON_DIFF,
REC_WEEKLY-MON_PERC.
PERFORM CONVERT_TO_KG CHANGING: REC_WEEKLY-TUE_PLAN,
REC_WEEKLY-TUE_ACT,
REC_WEEKLY-TUE_DIFF,
REC_WEEKLY-TUE_PERC.
PERFORM CONVERT_TO_KG CHANGING: REC_WEEKLY-WED_PLAN,
REC_WEEKLY-WED_ACT,
REC_WEEKLY-WED_DIFF,
REC_WEEKLY-WED_PERC.
PERFORM CONVERT_TO_KG CHANGING: REC_WEEKLY-THU_PLAN,
REC_WEEKLY-THU_ACT,
REC_WEEKLY-THU_DIFF,
REC_WEEKLY-THU_PERC.
PERFORM CONVERT_TO_KG CHANGING: REC_WEEKLY-FRI_PLAN,
REC_WEEKLY-FRI_ACT,
REC_WEEKLY-FRI_DIFF,
REC_WEEKLY-FRI_PERC.
PERFORM CONVERT_TO_KG CHANGING: REC_WEEKLY-SAT_PLAN,
REC_WEEKLY-SAT_ACT,
REC_WEEKLY-SAT_DIFF,
REC_WEEKLY-SAT_PERC.
PERFORM CONVERT_TO_KG CHANGING: REC_WEEKLY-SUN_PLAN,
REC_WEEKLY-SUN_ACT,
REC_WEEKLY-SUN_DIFF,
REC_WEEKLY-SUN_PERC.
PERFORM CONVERT_TO_KG CHANGING: REC_WEEKLY-TOT_PLAN,
REC_WEEKLY-TOT_ACT,
REC_WEEKLY-TOT_DIFF,
REC_WEEKLY-TOT_PERC.
MODIFY I_WEEKLY FROM REC_WEEKLY.
ENDLOOP.
ENDFORM. " convert_unit_to_kg
 
 
*&---------------------------------------------------------------------*
*& Form convert_to_kg
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* <--P_REC_WEEKLY_TOT_PLAN text
* <--P_REC_WEEKLY_TOT_ACT text
* <--P_REC_WEEKLY_TOT_DIFF text
* <--P_REC_WEEKLY_TOT_PERC text
*----------------------------------------------------------------------*
FORM CONVERT_TO_KG CHANGING FP_V_AMNT TYPE DISPTYPE.
DATA: L_V_AMNT TYPE EKPO-MENGE,
L_V_INIT_AMNT TYPE EKPO-MENGE.
* SELECT SINGLE gewei
* INTO l_unit
* FROM mara
* WHERE matnr = rec_weekly-matnr.
L_V_INIT_AMNT = FP_V_AMNT.
CALL FUNCTION 'MD_CONVERT_MATERIAL_UNIT'
EXPORTING
I_MATNR = REC_WEEKLY-MATNR
I_IN_ME = REC_WEEKLY-MEINS
I_OUT_ME = 'KG'
I_MENGE = L_V_INIT_AMNT
IMPORTING
E_MENGE = L_V_AMNT
EXCEPTIONS
ERROR_IN_APPLICATION = 1
ERROR = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
 
* CALL FUNCTION 'CF_UT_UNIT_CONVERSION'
* EXPORTING
* matnr_imp = rec_weekly-matnr
* meins_imp = l_unit
* unit_new_imp = 'KG'
* unit_old_imp = rec_weekly-meins
* value_old_imp = l_v_init_amnt
* IMPORTING
* value_new_exp = l_v_amnt
* EXCEPTIONS
* overflow = 1
* OTHERS = 2.
* IF sy-subrc <> 0.
** MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
** WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
* ENDIF.
FP_V_AMNT = L_V_AMNT.
ENDFORM. " convert_to_kg
 
 
*&---------------------------------------------------------------------*
*& Form validate_order_status2
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM VALIDATE_ORDER_STATUS2 .
* Local Data Declarations
DATA: L_V_TXT04 TYPE J_TXT04, "#EC *
L_V_SYST2 TYPE STRING.
L_V_SYST2 = P_SYST2.
* Function Mudule to convert the System staus text
* to Upper Case
CALL FUNCTION 'AIPC_CONVERT_TO_UPPERCASE'
EXPORTING
I_INPUT = L_V_SYST2 " System Status Text (Any Case)
I_LANGU = SY-LANGU " language
IMPORTING
E_OUTPUT = L_V_SYST2. " System Status Text (Upper Case)
P_SYST2 = L_V_SYST2.
* Check if the System Status Text is present in
* tj02t (System status texts)
SELECT SINGLE TXT04 " System Status Text
INTO L_V_TXT04
FROM TJ02T " Table: System status texts
WHERE SPRAS = SY-LANGU "#EC *
AND TXT04 = P_SYST2.
IF SY-SUBRC NE C_0.
* Entered Order Status is Invalid
MESSAGE E039.
ENDIF.
ENDFORM. " validate_order_status2
 
 
*&---------------------------------------------------------------------*
*& Form fill_status_table
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_I_STATUS_HDR_TAB text
* -->P_P_SYST1 text
* -->P_P_EXCL1 text
* -->P_P_SYST2 text
*----------------------------------------------------------------------*
FORM FILL_STATUS_TABLE TABLES FP_I_STATUS_HDR_TAB " Status Table
STRUCTURE I_STATUS_HDR_TAB
USING FP_V_SYST1 TYPE J_TXT04 " System Text1
FP_V_EXCL1 TYPE EXCL " Excusion status
" for system text1
FP_V_SYST2 TYPE J_TXT04 " System Text2
FP_V_EXCL2 TYPE EXCL." Exclusion Status
" for system text2
* Local Data Declarations
DATA: L_WA_STATUS_TMP TYPE TY_STATUS_TMP. " System Status
" Table
CLEAR: FP_I_STATUS_HDR_TAB,
L_WA_STATUS_TMP.
REFRESH FP_I_STATUS_HDR_TAB.
* Select the system status code form the status texts
* into the status table along with the checkbox(exclusion) status
IF NOT FP_V_SYST1 IS INITIAL.
CALL FUNCTION 'STATUS_TEXT_CONVERSION'
EXPORTING
LANGUAGE = SY-LANGU
TXT04 = FP_V_SYST1 " status text1
IMPORTING
STATUS_NUMBER = L_WA_STATUS_TMP-STAT " Status code1
EXCEPTIONS
INSUFFICIENT_INPUT = 1
NOT_FOUND = 2
OBJECT_NOT_FOUND = 3
WRONG_MODE = 4
OTHERS = 5.
IF SY-SUBRC EQ C_0.
L_WA_STATUS_TMP-EXCL = FP_V_EXCL1.
COLLECT L_WA_STATUS_TMP INTO FP_I_STATUS_HDR_TAB.
ELSE.
CASE SY-SUBRC.
WHEN C_1.
* Neither STSMA nor OBJNR Filled (MODE = 'E')
MESSAGE E077.
WHEN C_2.
* Status Not Found
MESSAGE E078.
WHEN C_3.
* Status Object not Found for OBJNR (MODE='E')
MESSAGE E079.
WHEN C_4.
* Incorrect Mode
MESSAGE E080.
WHEN OTHERS.
* An Unknown Error Has Occured
MESSAGE E081.
ENDCASE.
ENDIF.
ENDIF.
IF NOT FP_V_SYST2 IS INITIAL.
CALL FUNCTION 'STATUS_TEXT_CONVERSION'
EXPORTING
LANGUAGE = SY-LANGU
TXT04 = FP_V_SYST2 " status text2
IMPORTING
STATUS_NUMBER = L_WA_STATUS_TMP-STAT " status code2
EXCEPTIONS
INSUFFICIENT_INPUT = 1
NOT_FOUND = 2
OBJECT_NOT_FOUND = 3
WRONG_MODE = 4
OTHERS = 5.
IF SY-SUBRC EQ C_0.
L_WA_STATUS_TMP-EXCL = FP_V_EXCL2.
COLLECT L_WA_STATUS_TMP INTO FP_I_STATUS_HDR_TAB.
ELSE.
CASE SY-SUBRC.
WHEN C_1.
* Neither STSMA nor OBJNR Filled (MODE = 'E')
MESSAGE E077.
WHEN C_2.
* Status Not Found
MESSAGE E078.
WHEN C_3.
* Status Object not Found for OBJNR (MODE='E')
MESSAGE E079.
WHEN C_4.
* Incorrect Mode
MESSAGE E080.
WHEN OTHERS.
* An Unknown Error Has Occured
MESSAGE E081.
ENDCASE.
ENDIF.
ENDIF.
ENDFORM. " fill_status_table
 
 
*&---------------------------------------------------------------------*
*& Form check_status
*&---------------------------------------------------------------------*
* To select the useful range of Order Nos.
*----------------------------------------------------------------------*
* --> fp_i_status_hdr_tab Status Table
* --> fp_i_aufnr_range Useful range Of Order Nos.
*----------------------------------------------------------------------*
FORM CHECK_STATUS TABLES FP_I_STATUS_HDR_TAB " Status Table
STRUCTURE I_STATUS_HDR_TAB
FP_I_AUFNR_RANGE " Useful Range of
" Order Nos.
STRUCTURE I_AUFNR_RANGE.
* Local Data Declarations
DATA: L_I_LTS_OBJNR TYPE TYP_TS_AUFNR_OBJNR. " internal table
" to store order Nos.
FIELD-SYMBOLS: <F1> TYPE TYP_S_OBJNR. " Field symbol for
" order Nos.
CHECK NOT FP_I_STATUS_HDR_TAB[] IS INITIAL.
* Select all the order Nos. of the Order type
* (autyp) = 40(Process orders)
SELECT AUFNR OBJNR FROM AUFK
INTO TABLE L_I_LTS_OBJNR[]
WHERE AUTYP = C_40.
* To filter the selected orders on the basis of
* the status table
PERFORM REDUCE_ORDERS
TABLES FP_I_STATUS_HDR_TAB " Status table
CHANGING L_I_LTS_OBJNR[]. " Table of Order Nos.
* Fill the final range table for the order Nos.
* and the corresponding details
REFRESH FP_I_AUFNR_RANGE[].
FP_I_AUFNR_RANGE-SIGN = C_I.
FP_I_AUFNR_RANGE-OPTION = C_EQ.
CLEAR FP_I_AUFNR_RANGE-LOW.
CLEAR FP_I_AUFNR_RANGE-HIGH.
LOOP AT L_I_LTS_OBJNR[] ASSIGNING <F1>.
FP_I_AUFNR_RANGE-LOW = <F1>-AUFNR.
APPEND FP_I_AUFNR_RANGE.
ENDLOOP.
* no order found
IF SY-SUBRC <> C_0.
APPEND FP_I_AUFNR_RANGE.
ENDIF.
* Free the internal table used
FREE: L_I_LTS_OBJNR[].
ENDFORM. " check_status
 
 
*&---------------------------------------------------------------------*
*& Form reduce_orders
*&---------------------------------------------------------------------*
* To reduce the available range of object nos to useful ones
*----------------------------------------------------------------------*
* --> fp_i_status_tab1 Status table
* --> fp_i_cts_objnr table of Object Nos.
*----------------------------------------------------------------------*
FORM REDUCE_ORDERS
TABLES FP_I_STATUS_TAB1 STRUCTURE I_STATUS_HDR_TAB
" Status Table
CHANGING FP_I_CTS_OBJNR TYPE TYP_TS_OBJNR. " Table of Object Nos.
DATA: L_I_OBJNR_TAB
TYPE STANDARD TABLE OF JSTO_PRE " Order No.
INITIAL SIZE 0
WITH HEADER LINE.
FIELD-SYMBOLS: <F1> TYPE TYP_S_OBJNR. " Field Symbol for
" Order Nos.
CHECK NOT FP_I_STATUS_TAB1[] IS INITIAL.
* Fill the order table
LOOP AT FP_I_CTS_OBJNR[] ASSIGNING <F1>.
L_I_OBJNR_TAB-OBJNR = <F1>-OBJNR.
APPEND L_I_OBJNR_TAB.
ENDLOOP.
CALL FUNCTION 'STATUS_PRE_READ'
TABLES
JSTO_PRE_TAB = L_I_OBJNR_TAB.
* Flag to indicate that objects have been deleted.
DATA OBJECTS_DELETED.
* Filter the order Nos on the basis of status
PERFORM REDUCE_OBJNR_BY_STATUS
TABLES L_I_OBJNR_TAB " Order Nos table
FP_I_STATUS_TAB1 " Status Table
CHANGING OBJECTS_DELETED. " Flag of deletion
* If certain order nos have been deleted
IF OBJECTS_DELETED = C_X.
* If all the order nos have been deleted
* refresh the final order nos table
IF L_I_OBJNR_TAB[] IS INITIAL.
REFRESH FP_I_CTS_OBJNR[].
ELSE.
SORT L_I_OBJNR_TAB BY OBJNR.
* Filter the final table for order nos on the basis of
* the filtered order Nos. I.e the final order table should
* have only those orders that have been selected on the basis of
* the orders entered by the user on the selection screen
LOOP AT FP_I_CTS_OBJNR[] ASSIGNING <F1>.
READ TABLE L_I_OBJNR_TAB
WITH KEY OBJNR = <F1>-OBJNR
BINARY SEARCH.
* If the order no is not found in the filtered order nos table
* delete the record form the final table.
IF SY-SUBRC <> C_0.
DELETE FP_I_CTS_OBJNR[].
ENDIF.
ENDLOOP.
ENDIF.
ENDIF.
ENDFORM. " REDUCE_AUFNR_OBJNR_BY_STATUS
 
*&---------------------------------------------------------------------*
*& Form reduce_objnr_by_status
*&---------------------------------------------------------------------*
* To reduce the order nos by matching their stauts to the one(s)
* entered on the selection screen by the user
*----------------------------------------------------------------------*
* -->fP_i_OBJNR_TAB Object Nos.
* -->fP_i_STATUS_TAB2 Status table
* <--fP_v_OBJECTS_DELETED Indicator that objects have been
* delected
*----------------------------------------------------------------------*
FORM REDUCE_OBJNR_BY_STATUS
TABLES FP_I_OBJNR_TAB STRUCTURE OBJNR_TAB " Object Nos.
FP_I_STATUS_TAB2 STRUCTURE I_STATUS_HDR_TAB " StatusTable
CHANGING FP_V_OBJECTS_DELETED. " Indicator that objects have
" been deleted
* local data Declarations
DATA: L_V_OBJNR_CNT TYPE SYDBCNT, " database count of objects
L_I_OBJNR_TAB TYPE STANDARD TABLE OF JSTO_PRE INITIAL SIZE 0,
" Table for object Nos.
L_DBCNT TYPE SY-DBCNT. " db count of deleted objects
CLEAR FP_V_OBJECTS_DELETED.
* If there are existing order Nos.
CHECK NOT FP_I_OBJNR_TAB[] IS INITIAL.
DESCRIBE TABLE FP_I_OBJNR_TAB LINES L_V_OBJNR_CNT.
* Chect the orders nos for each status entered
* On the selection screen by the user
LOOP AT FP_I_STATUS_TAB2.
IF FP_I_OBJNR_TAB[] IS INITIAL.
EXIT.
* If there are existing order Nos.
ELSE.
L_I_OBJNR_TAB[] = FP_I_OBJNR_TAB[].
* Alle Objektnummern, bei denen der geforderte Status (nicht) sitzt,
* werden aus der Tabelle OBJNR_TAB gelöscht.
CALL FUNCTION 'STATUS_CHECK_MULTI'
EXPORTING
STATUS = FP_I_STATUS_TAB2-STAT " Status
FLG_EXCLUDE = FP_I_STATUS_TAB2-EXCL " Exclustion Status
TABLES
OBJECTS = L_I_OBJNR_TAB. " Filtered Order Nos.
ENDIF.
FP_I_OBJNR_TAB[] = L_I_OBJNR_TAB[].
ENDLOOP.
* Change the indicator for deletion if at all there
* has been deletion of objects
DESCRIBE TABLE FP_I_OBJNR_TAB LINES L_DBCNT.
* If the no of orders in the original order table
* is not same as the no of orders in the final order table
* then there has been deletion of orders.
IF L_DBCNT <> L_V_OBJNR_CNT.
FP_V_OBJECTS_DELETED = C_X.
ENDIF.
ENDFORM. " reduce_objnr_by_status
 
*----------------------------END OF MOD-004---------------------*
 
 
*&---------------------------------------------------------------------*
*& Form create_spool
*&---------------------------------------------------------------------*
* Create a spool request to be passed on to the program 'RSTXPDFT4' *
* that would download the list as a .pdf file
*----------------------------------------------------------------------*
FORM CREATE_SPOOL .
* Get the print parameters
PERFORM GET_PARAMETERS_FOR_PRINT CHANGING REC_OUT_PARAMS
" Print parameters
V_VALID. " Validity inidator
IF NOT V_VALID IS INITIAL.
PERFORM PRINT_ON USING REC_OUT_PARAMS
V_VALID.
* Report layput the way it should appear on the .pdf file
PERFORM DISPLAY_REPORT_HEADER.
* If weekly report is needed
IF RB_WEEK = C_X.
PERFORM MERGE_DATA.
PERFORM DISPLAY_WEEKLY_REPORT.
PERFORM DISPLAY_REPORT_FOOTER.
* If daily report is needed
ELSEIF RB_DAILY = C_X.
PERFORM DISPLAY_DAILY_REPORT.
PERFORM DISPLAY_REPORT_FOOTER.
ENDIF.
ENDIF.
PERFORM PRINT_OFF.
* Display error msg if the spool request is not created
IF SY-SPONO IS INITIAL.
* Error While Downloading The List Into a .pdf File
MESSAGE E090.
ENDIF.
ENDFORM. " create_spool
 
 
*&---------------------------------------------------------------------*
*& Form get_parameters_for_print
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* <--P_REC_OUT_PARAMS text
* <--P_V_VALID text
*----------------------------------------------------------------------*
FORM GET_PARAMETERS_FOR_PRINT CHANGING FP_OUT_PARAMS TYPE PRI_PARAMS
FP_VALID TYPE C.
* DATA: l_arc_params TYPE arc_params.
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
DESTINATION = C_LOCL "'LOCL'
* immediately = 'X'
* layout = 'X_58_170'
LINE_COUNT = C_55
LINE_SIZE = SY-LINSZ
LIST_NAME = C_LIST
NO_DIALOG = C_X
REPORT = SY-REPID
USER = SY-UNAME
IMPORTING
* out_archive_parameters = l_arc_params
OUT_PARAMETERS = FP_OUT_PARAMS
VALID = FP_VALID
EXCEPTIONS
ARCHIVE_INFO_NOT_FOUND = 1
INVALID_PRINT_PARAMS = 2
INVALID_ARCHIVE_PARAMS = 3
OTHERS = 4.
IF SY-SUBRC <> C_0.
CASE SY-SUBRC.
WHEN C_1.
MESSAGE E073. " Archive information not found
WHEN C_2.
MESSAGE E074. " Invalid print parameters
WHEN C_3.
MESSAGE E075. " Invalid archive parameters
ENDCASE.
ENDIF.
ENDFORM. " get_parameters_for_print
 
 
*&---------------------------------------------------------------------*
*& Form download_to_pdf
*&---------------------------------------------------------------------*
* Download the List as a .pdf file at the specified path on the
* Presentation Server
*----------------------------------------------------------------------*
FORM DOWNLOAD_TO_PDF .
* Submit to the program 'RSTXPDFT4', the spool Number.
* If the download checkbox is ticked and the file path given,
* The progarm peforms the download to a .pdf file. The file path
* may be changed by the user as a popup asking for the same appears
* while execution. The pop up allows navigation.
IF NOT SY-SPONO IS INITIAL.
* Converting SAPscript (OTF) or ABAP List Spool Job to PDF
SUBMIT RSTXPDFT4
WITH SPOOLNO = SY-SPONO " Spool Number
WITH P_FILE = C_PS_FILEPATH " File path
WITH DOWNLOAD = C_X " Checkbox for download ticked
AND RETURN EXPORTING LIST TO MEMORY. " To avoid the output screen
* Free the memory held by the output screen of 'RSTXPDFT4'
* in the previous submit to the program
CALL FUNCTION 'LIST_FREE_MEMORY'.
* MESSAGE s091.
ENDIF.
ENDFORM. " download_to_pdf
 
 
*&---------------------------------------------------------------------*
*& Form delete_spool
*&---------------------------------------------------------------------*
* Delete the spool request created for downloading the list
*----------------------------------------------------------------------*
FORM DELETE_SPOOL .
DATA: L_V_SPONO TYPE TSP01_SP0R-RQID_CHAR,
L_V_STAT TYPE SY-SUBRC.
L_V_SPONO = SY-SPONO.
* Delete the spool request created for downloading the list
IF NOT L_V_SPONO IS INITIAL.
CALL FUNCTION 'RSPO_R_RDELETE_SPOOLREQ'
EXPORTING
SPOOLID = L_V_SPONO " Spool request No.
IMPORTING
STATUS = L_V_STAT. " Status of deletion
* If the spool request was not deleted
IF NOT L_V_STAT IS INITIAL.
* Error while downloading
MESSAGE E092.
ENDIF.
ENDIF.
ENDFORM. " delete_spool
 
 
*&---------------------------------------------------------------------*
*& Form display_weekly_report_main
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DISPLAY_WEEKLY_REPORT_MAIN .
DATA: L_DATE TYPE SYDATUM.
L_DATE = C_DATE.
DO 7 TIMES.
PERFORM GET_WEEK_NAMES USING L_DATE
CHANGING I_WKDAY-WKDAY .
L_DATE = L_DATE + 1.
ENDDO.
** Begin of Mod-001
SORT I_WEEKLY BY SPWOC ARBPL MATNR. "Mod-001.
** End of Mod-001
LOOP AT I_WEEKLY.
CLEAR REC_WEEKLY.
MOVE I_WEEKLY TO REC_WEEKLY.
AT NEW SPWOC.
PERFORM DISPLAY_WEEK_HEADER.
ENDAT.
** At new workcenter display the workcenter header
AT NEW ARBPL.
PERFORM WRKCENTER_HEADER.
ENDAT.
** At new Material display the material Header
AT NEW MATNR.
PERFORM MATERIAL_HEADER.
ENDAT.
**Check for the Detail level Report or Summary Level Report
**If it is a Detail Level Report display the materials and
**Corresponding orders
IF RB_DET = C_X.
IF CB_COLOR = C_X.
FORMAT COLOR COL_NORMAL INTENSIFIED OFF.
ENDIF.
PERFORM SHOW_WEEKLY_ORDERS.
ENDIF.
**if it is summary level report Show only the material numbers
AT END OF MATNR.
SUM.
** check whether to display the quantities and order units
IF RB_QUAN = C_X AND RB_ORD = C_X.
PERFORM CHECK_UOM_WEEK_RES_MAT.
ENDIF.
PERFORM CALCULATE_WK_PERC.
IF CB_COLOR = C_X.
FORMAT COLOR COL_TOTAL INTENSIFIED ON.
ENDIF.
PERFORM DISPLAY_WK_TOT USING TEXT-088.
ENDAT.
AT END OF ARBPL.
SUM.
** check whether to display the quantities and order units
IF RB_QUAN = C_X AND RB_ORD = C_X.
PERFORM CHECK_UOM_WEEK_RES.
ENDIF.
PERFORM CALCULATE_WK_PERC.
IF CB_COLOR = C_X.
FORMAT COLOR COL_KEY INTENSIFIED OFF.
ENDIF.
PERFORM DISPLAY_WK_TOT USING TEXT-089.
ENDAT.
AT END OF SPWOC.
SUM.
** check whether to display the quantities and order units
IF RB_QUAN = C_X AND RB_ORD = C_X.
PERFORM CHECK_UOM_WEEK.
ENDIF.
PERFORM CALCULATE_WK_PERC.
IF CB_COLOR = C_X.
FORMAT COLOR COL_POSITIVE INTENSIFIED OFF.
ENDIF.
PERFORM DISPLAY_WK_TOT USING TEXT-091.
SKIP 1.
ENDAT.
ENDLOOP.
ENDFORM. " display_weekly_report_main
 
 
*&---------------------------------------------------------------------*
*& Form calculate_wk_perc
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CALCULATE_WK_PERC .
PERFORM CALCULATE_PERCENTAGE USING I_WEEKLY-MON_PLAN
I_WEEKLY-MON_DIFF
CHANGING I_WEEKLY-MON_PERC.
PERFORM CALCULATE_PERCENTAGE USING I_WEEKLY-TUE_PLAN
I_WEEKLY-TUE_DIFF
CHANGING I_WEEKLY-TUE_PERC.
PERFORM CALCULATE_PERCENTAGE USING I_WEEKLY-WED_PLAN
I_WEEKLY-WED_DIFF
CHANGING I_WEEKLY-WED_PERC.
PERFORM CALCULATE_PERCENTAGE USING I_WEEKLY-THU_PLAN
I_WEEKLY-THU_DIFF
CHANGING I_WEEKLY-THU_PERC.
PERFORM CALCULATE_PERCENTAGE USING I_WEEKLY-FRI_PLAN
I_WEEKLY-FRI_DIFF
CHANGING I_WEEKLY-FRI_PERC.
PERFORM CALCULATE_PERCENTAGE USING I_WEEKLY-SAT_PLAN
I_WEEKLY-SAT_DIFF
CHANGING I_WEEKLY-SAT_PERC.
PERFORM CALCULATE_PERCENTAGE USING I_WEEKLY-SUN_PLAN
I_WEEKLY-SUN_DIFF
CHANGING I_WEEKLY-SUN_PERC.
PERFORM CALCULATE_PERCENTAGE USING I_WEEKLY-TOT_PLAN
I_WEEKLY-TOT_DIFF
CHANGING I_WEEKLY-TOT_PERC.
 
ENDFORM. " calculate_wk_perc
 
 
*&---------------------------------------------------------------------*
*& Form wrkcenter_header
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM WRKCENTER_HEADER .
CLEAR: V_RTEXT.
CALL FUNCTION 'WEEK_GET_FIRST_DAY'
EXPORTING
WEEK = I_WEEKLY-SPWOC
IMPORTING
DATE = V_MONDAY
EXCEPTIONS
WEEK_INVALID = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
CLEAR V_MONDAY.
ENDIF.
V_FMDAY = V_MONDAY.
IF CB_COLOR = C_X.
FORMAT COLOR COL_KEY INTENSIFIED OFF.
ENDIF.
WRITE: / TEXT-049,
12 REC_WEEKLY-ARBPL.
**Get the Work Center Description .
PERFORM GET_RESDESC USING REC_WEEKLY-ARBPL
P_WERKS
CHANGING V_RTEXT.
WRITE: 24 V_RTEXT,
**begin of mod-002
* 245 sy-vline.
295 SY-VLINE.
**end of mod-002
 
IF CB_COLOR = C_X.
FORMAT COLOR COL_HEADING INTENSIFIED ON.
ENDIF.
** begin of mod-002
* WRITE : /(14) ' ' , sy-vline.
** WRITE:(8) text-050,(13) v_fmday,44 sy-vline. v_fmday = v_fmday +
*1.
** WRITE:(10) text-051,(13) v_fmday,72 sy-vline. v_fmday = v_fmday +
*1.
** WRITE:(10) text-052,(13) v_fmday,100 sy-vline. v_fmday = v_fmday +
*1.
** WRITE:(10) text-053,(13) v_fmday,128 sy-vline. v_fmday = v_fmday +
*1.
** WRITE:(10) text-054,(13) v_fmday,156 sy-vline. v_fmday = v_fmday +
*1.
** WRITE:(10) text-055,(13) v_fmday,184 sy-vline. v_fmday = v_fmday +
*1.
** WRITE:(10) text-056,(13) v_fmday,212 sy-vline.
**
* WRITE:(26) text-057, 240 sy-vline, (3) '', 245 sy-vline.
*WRITE:(31) text-057, 288 sy-vline, (3) '', 295 sy-vline.
 
WRITE : /(14) ' ' , SY-VLINE.
WRITE:(8) TEXT-050,(13) V_FMDAY,50 SY-VLINE. V_FMDAY = V_FMDAY + 1.
WRITE:(10) TEXT-051,(13) V_FMDAY,84 SY-VLINE. V_FMDAY = V_FMDAY + 1.
WRITE:(10) TEXT-052,(13) V_FMDAY,118 SY-VLINE. V_FMDAY = V_FMDAY + 1.
WRITE:(10) TEXT-053,(13) V_FMDAY,152 SY-VLINE. V_FMDAY = V_FMDAY + 1.
WRITE:(10) TEXT-054,(13) V_FMDAY,186 SY-VLINE. V_FMDAY = V_FMDAY + 1.
WRITE:(10) TEXT-055,(13) V_FMDAY,220 SY-VLINE. V_FMDAY = V_FMDAY + 1.
WRITE:(10) TEXT-056,(13) V_FMDAY,254 SY-VLINE.
WRITE:(31) TEXT-057, 288 SY-VLINE, (3) '', 295 SY-VLINE.
WRITE : / TEXT-058.
**end of mod-002
 
DO 8 TIMES.
WRITE: SY-VLINE,(31) TEXT-068.
ENDDO.
IF RB_QUAN = C_X.
WRITE: SY-VLINE NO-GAP, (4) TEXT-070.
ELSE.
WRITE : SY-VLINE NO-GAP ,(4) TEXT-087.
ENDIF.
**begin of mod-002
* WRITE: 245 sy-vline.
* ULINE (245).
WRITE: 295 SY-VLINE.
ULINE (295).
**end of mod-002
ENDFORM. " wrkcenter_header
 
 
*&---------------------------------------------------------------------*
*& Form show_weekly_orders
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM SHOW_WEEKLY_ORDERS .
WRITE: /(14) REC_WEEKLY-AUFNR.
HIDE REC_WEEKLY-AUFNR.
WRITE: SY-VLINE,
**begin of mod-002
* (6) rec_weekly-mon_plan NO-SIGN,
* (6) rec_weekly-mon_act NO-SIGN,
* (6) rec_weekly-mon_diff NO-SIGN,
* (4) rec_weekly-mon_perc NO-SIGN,
* sy-vline,
* (6) rec_weekly-tue_plan NO-SIGN,
* (6) rec_weekly-tue_act NO-SIGN,
* (6) rec_weekly-tue_diff NO-SIGN,
* (4) rec_weekly-tue_perc NO-SIGN,
* sy-vline,
* (6) rec_weekly-wed_plan NO-SIGN,
* (6) rec_weekly-wed_act NO-SIGN,
* (6) rec_weekly-wed_diff NO-SIGN,
* (4) rec_weekly-wed_perc NO-SIGN,
* sy-vline,
* (6) rec_weekly-thu_plan NO-SIGN,
* (6) rec_weekly-thu_act NO-SIGN,
* (6) rec_weekly-thu_diff NO-SIGN,
* (4) rec_weekly-thu_perc NO-SIGN,
* sy-vline,
* (6) rec_weekly-fri_plan NO-SIGN,
* (6) rec_weekly-fri_act NO-SIGN,
* (6) rec_weekly-fri_diff NO-SIGN,
* (4) rec_weekly-fri_perc NO-SIGN,
* sy-vline,
* (6) rec_weekly-sat_plan NO-SIGN,
* (6) rec_weekly-sat_act NO-SIGN,
* (6) rec_weekly-sat_diff NO-SIGN,
* (4) rec_weekly-sat_perc NO-SIGN,
* sy-vline,
* (6) rec_weekly-sun_plan NO-SIGN,
* (6) rec_weekly-sun_act NO-SIGN,
* (6) rec_weekly-sun_diff NO-SIGN,
* (4) rec_weekly-sun_perc NO-SIGN,
* sy-vline,
* (6) rec_weekly-tot_plan NO-SIGN,
* (6) rec_weekly-tot_act NO-SIGN,
* (6) rec_weekly-tot_diff NO-SIGN,
* (4) rec_weekly-tot_perc NO-SIGN,
* sy-vline.
*
 
(8) REC_WEEKLY-MON_PLAN NO-SIGN LEFT-JUSTIFIED,
(8) REC_WEEKLY-MON_ACT NO-SIGN LEFT-JUSTIFIED,
(8) REC_WEEKLY-MON_DIFF NO-SIGN LEFT-JUSTIFIED,
(4) REC_WEEKLY-MON_PERC NO-SIGN LEFT-JUSTIFIED,
SY-VLINE,
(8) REC_WEEKLY-TUE_PLAN NO-SIGN LEFT-JUSTIFIED,
(8) REC_WEEKLY-TUE_ACT NO-SIGN LEFT-JUSTIFIED,
(8) REC_WEEKLY-TUE_DIFF NO-SIGN LEFT-JUSTIFIED,
(4) REC_WEEKLY-TUE_PERC NO-SIGN LEFT-JUSTIFIED,
SY-VLINE,
(8) REC_WEEKLY-WED_PLAN NO-SIGN LEFT-JUSTIFIED,
(8) REC_WEEKLY-WED_ACT NO-SIGN LEFT-JUSTIFIED,
(8) REC_WEEKLY-WED_DIFF NO-SIGN LEFT-JUSTIFIED,
(4) REC_WEEKLY-WED_PERC NO-SIGN LEFT-JUSTIFIED,
SY-VLINE,
(8) REC_WEEKLY-THU_PLAN NO-SIGN LEFT-JUSTIFIED,
(8) REC_WEEKLY-THU_ACT NO-SIGN LEFT-JUSTIFIED,
(8) REC_WEEKLY-THU_DIFF NO-SIGN LEFT-JUSTIFIED,
(4) REC_WEEKLY-THU_PERC NO-SIGN LEFT-JUSTIFIED,
SY-VLINE,
(8) REC_WEEKLY-FRI_PLAN NO-SIGN LEFT-JUSTIFIED,
(8) REC_WEEKLY-FRI_ACT NO-SIGN LEFT-JUSTIFIED,
(8) REC_WEEKLY-FRI_DIFF NO-SIGN LEFT-JUSTIFIED,
(4) REC_WEEKLY-FRI_PERC NO-SIGN LEFT-JUSTIFIED,
SY-VLINE,
(8) REC_WEEKLY-SAT_PLAN NO-SIGN LEFT-JUSTIFIED,
(8) REC_WEEKLY-SAT_ACT NO-SIGN LEFT-JUSTIFIED,
(8) REC_WEEKLY-SAT_DIFF NO-SIGN LEFT-JUSTIFIED,
(4) REC_WEEKLY-SAT_PERC NO-SIGN LEFT-JUSTIFIED,
SY-VLINE,
(8) REC_WEEKLY-SUN_PLAN NO-SIGN LEFT-JUSTIFIED,
(8) REC_WEEKLY-SUN_ACT NO-SIGN LEFT-JUSTIFIED,
(8) REC_WEEKLY-SUN_DIFF NO-SIGN LEFT-JUSTIFIED,
(4) REC_WEEKLY-SUN_PERC NO-SIGN LEFT-JUSTIFIED,
SY-VLINE,
(8) REC_WEEKLY-TOT_PLAN NO-SIGN LEFT-JUSTIFIED,
(8) REC_WEEKLY-TOT_ACT NO-SIGN LEFT-JUSTIFIED,
(8) REC_WEEKLY-TOT_DIFF NO-SIGN LEFT-JUSTIFIED,
(4) REC_WEEKLY-TOT_PERC NO-SIGN LEFT-JUSTIFIED,
SY-VLINE.
** end of mod-002.
IF RB_QUAN = C_X.
**begin of mod-002.
* WRITE: (3) rec_weekly-meins, 245 sy-vline.
* ELSE.
* WRITE: (3) rec_weekly-waers, 245 sy-vline.
* ENDIF.
* ULINE (245).
WRITE: (3) REC_WEEKLY-MEINS, 295 SY-VLINE.
ELSE.
WRITE: (3) REC_WEEKLY-WAERS, 295 SY-VLINE.
ENDIF.
ULINE (295).
ENDFORM. " show_weekly_orders
 
 
*&---------------------------------------------------------------------*
*& Form display_wk_tot
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_TEXT_088 text
*----------------------------------------------------------------------*
FORM DISPLAY_WK_TOT USING P_I_TEXT.
WRITE: /(14) P_I_TEXT,
SY-VLINE,
* (6) i_weekly-mon_plan NO-SIGN,
* (6) i_weekly-mon_act NO-SIGN,
* (6) i_weekly-mon_diff NO-SIGN,
* (4) i_weekly-mon_perc NO-SIGN,
* sy-vline,
* (6) i_weekly-tue_plan NO-SIGN,
* (6) i_weekly-tue_act NO-SIGN,
* (6) i_weekly-tue_diff NO-SIGN,
* (4) i_weekly-tue_perc NO-SIGN,
* sy-vline,
* (6) i_weekly-wed_plan NO-SIGN,
* (6) i_weekly-wed_act NO-SIGN,
* (6) i_weekly-wed_diff NO-SIGN,
* (4) i_weekly-wed_perc NO-SIGN,
* sy-vline,
* (6) i_weekly-thu_plan NO-SIGN,
* (6) i_weekly-thu_act NO-SIGN,
* (6) i_weekly-thu_diff NO-SIGN,
* (4) i_weekly-thu_perc NO-SIGN,
* sy-vline,
* (6) i_weekly-fri_plan NO-SIGN,
* (6) i_weekly-fri_act NO-SIGN,
* (6) i_weekly-fri_diff NO-SIGN,
* (4) i_weekly-fri_perc NO-SIGN,
* sy-vline,
* (6) i_weekly-sat_plan NO-SIGN,
* (6) i_weekly-sat_act NO-SIGN,
* (6) i_weekly-sat_diff NO-SIGN,
* (4) i_weekly-sat_perc NO-SIGN,
* sy-vline,
* (6) i_weekly-sun_plan NO-SIGN,
* (6) i_weekly-sun_act NO-SIGN,
* (6) i_weekly-sun_diff NO-SIGN,
* (4) i_weekly-sun_perc NO-SIGN,
* sy-vline,
* (6) i_weekly-tot_plan NO-SIGN,
* (6) i_weekly-tot_act NO-SIGN,
* (6) i_weekly-tot_diff NO-SIGN,
* (4) i_weekly-tot_perc NO-SIGN,
* sy-vline.
* IF rb_fval = c_x.
* WRITE: (3) rec_weekly-waers.
* ENDIF.
* WRITE: 245 sy-vline.
* ULINE (245).
*
(8) I_WEEKLY-MON_PLAN NO-SIGN LEFT-JUSTIFIED,
(8) I_WEEKLY-MON_ACT NO-SIGN LEFT-JUSTIFIED,
(8) I_WEEKLY-MON_DIFF NO-SIGN LEFT-JUSTIFIED,
(4) I_WEEKLY-MON_PERC NO-SIGN LEFT-JUSTIFIED,
SY-VLINE,
(8) I_WEEKLY-TUE_PLAN NO-SIGN LEFT-JUSTIFIED,
(8) I_WEEKLY-TUE_ACT NO-SIGN LEFT-JUSTIFIED,
(8) I_WEEKLY-TUE_DIFF NO-SIGN LEFT-JUSTIFIED,
(4) I_WEEKLY-TUE_PERC NO-SIGN LEFT-JUSTIFIED,
SY-VLINE,
(8) I_WEEKLY-WED_PLAN NO-SIGN LEFT-JUSTIFIED,
(8) I_WEEKLY-WED_ACT NO-SIGN LEFT-JUSTIFIED,
(8) I_WEEKLY-WED_DIFF NO-SIGN LEFT-JUSTIFIED,
(4) I_WEEKLY-WED_PERC NO-SIGN LEFT-JUSTIFIED,
SY-VLINE,
(8) I_WEEKLY-THU_PLAN NO-SIGN LEFT-JUSTIFIED,
(8) I_WEEKLY-THU_ACT NO-SIGN LEFT-JUSTIFIED,
(8) I_WEEKLY-THU_DIFF NO-SIGN LEFT-JUSTIFIED,
(4) I_WEEKLY-THU_PERC NO-SIGN LEFT-JUSTIFIED,
SY-VLINE,
(8) I_WEEKLY-FRI_PLAN NO-SIGN LEFT-JUSTIFIED,
(8) I_WEEKLY-FRI_ACT NO-SIGN LEFT-JUSTIFIED,
(8) I_WEEKLY-FRI_DIFF NO-SIGN LEFT-JUSTIFIED,
(4) I_WEEKLY-FRI_PERC NO-SIGN LEFT-JUSTIFIED,
SY-VLINE,
(8) I_WEEKLY-SAT_PLAN NO-SIGN LEFT-JUSTIFIED,
(8) I_WEEKLY-SAT_ACT NO-SIGN LEFT-JUSTIFIED,
(8) I_WEEKLY-SAT_DIFF NO-SIGN LEFT-JUSTIFIED,
(4) I_WEEKLY-SAT_PERC NO-SIGN LEFT-JUSTIFIED,
SY-VLINE,
(8) I_WEEKLY-SUN_PLAN NO-SIGN LEFT-JUSTIFIED,
(8) I_WEEKLY-SUN_ACT NO-SIGN LEFT-JUSTIFIED,
(8) I_WEEKLY-SUN_DIFF NO-SIGN LEFT-JUSTIFIED,
(4) I_WEEKLY-SUN_PERC NO-SIGN LEFT-JUSTIFIED,
SY-VLINE,
(8) I_WEEKLY-TOT_PLAN NO-SIGN LEFT-JUSTIFIED,
(8) I_WEEKLY-TOT_ACT NO-SIGN LEFT-JUSTIFIED,
(8) I_WEEKLY-TOT_DIFF NO-SIGN LEFT-JUSTIFIED,
(4) I_WEEKLY-TOT_PERC NO-SIGN LEFT-JUSTIFIED,
SY-VLINE.
IF RB_FVAL = C_X.
WRITE: (3) REC_WEEKLY-WAERS.
ENDIF.
WRITE: 295 SY-VLINE.
ULINE (295).
 
*** End of Mod-001
ENDFORM. " display_wk_tot.
 
 
*&---------------------------------------------------------------------*
*& Form check_uom_week
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CHECK_UOM_WEEK .
DATA L_MEINS TYPE MEINS.
READ TABLE I_WKDAY INDEX 1.
READ TABLE I_WEEK3 WITH KEY SPWOC = I_WEEKLY-SPWOC
WKDAY = I_WKDAY-WKDAY.
IF SY-SUBRC <> 0 OR I_WEEK3-MEINS = C_NULL.
CLEAR: I_WEEKLY-MON_PLAN,
I_WEEKLY-MON_ACT,
I_WEEKLY-MON_DIFF,
I_WEEKLY-MON_PERC.
ENDIF.
READ TABLE I_WKDAY INDEX 2.
READ TABLE I_WEEK3 WITH KEY SPWOC = I_WEEKLY-SPWOC
WKDAY = I_WKDAY-WKDAY.
IF SY-SUBRC <> 0 OR I_WEEK3-MEINS = C_NULL.
CLEAR: I_WEEKLY-TUE_PLAN,
I_WEEKLY-TUE_ACT,
I_WEEKLY-TUE_DIFF,
I_WEEKLY-TUE_PERC.
ENDIF.
READ TABLE I_WKDAY INDEX 3.
READ TABLE I_WEEK3 WITH KEY SPWOC = I_WEEKLY-SPWOC
WKDAY = I_WKDAY-WKDAY.
IF SY-SUBRC <> 0 OR I_WEEK3-MEINS = C_NULL.
CLEAR: I_WEEKLY-WED_PLAN,
I_WEEKLY-WED_ACT,
I_WEEKLY-WED_DIFF,
I_WEEKLY-WED_PERC.
ENDIF.
READ TABLE I_WKDAY INDEX 4.
READ TABLE I_WEEK3 WITH KEY SPWOC = I_WEEKLY-SPWOC
WKDAY = I_WKDAY-WKDAY.
IF SY-SUBRC <> 0 OR I_WEEK3-MEINS = C_NULL.
CLEAR: I_WEEKLY-THU_PLAN,
I_WEEKLY-THU_ACT,
I_WEEKLY-THU_DIFF,
I_WEEKLY-THU_PERC.
ENDIF.
READ TABLE I_WKDAY INDEX 5.
READ TABLE I_WEEK3 WITH KEY SPWOC = I_WEEKLY-SPWOC
WKDAY = I_WKDAY-WKDAY.
IF SY-SUBRC <> 0 OR I_WEEK3-MEINS = C_NULL.
CLEAR: I_WEEKLY-FRI_PLAN,
I_WEEKLY-FRI_ACT,
I_WEEKLY-FRI_DIFF,
I_WEEKLY-FRI_PERC.
ENDIF.
READ TABLE I_WKDAY INDEX 6.
READ TABLE I_WEEK3 WITH KEY SPWOC = I_WEEKLY-SPWOC
WKDAY = I_WKDAY-WKDAY.
IF SY-SUBRC <> 0 OR I_WEEK3-MEINS = C_NULL.
CLEAR: I_WEEKLY-SAT_PLAN,
I_WEEKLY-SAT_ACT,
I_WEEKLY-SAT_DIFF,
I_WEEKLY-SAT_PERC.
ENDIF.
READ TABLE I_WKDAY INDEX 7.
READ TABLE I_WEEK3 WITH KEY SPWOC = I_WEEKLY-SPWOC
WKDAY = I_WKDAY-WKDAY.
IF SY-SUBRC <> 0 OR I_WEEK3-MEINS = C_NULL.
CLEAR: I_WEEKLY-SUN_PLAN,
I_WEEKLY-SUN_ACT,
I_WEEKLY-SUN_DIFF,
I_WEEKLY-SUN_PERC.
ENDIF.
LOOP AT I_WEEK3 WHERE SPWOC = I_WEEKLY-SPWOC.
IF I_WEEK3-MEINS = C_NULL.
CLEAR: I_WEEKLY-TOT_PLAN,
I_WEEKLY-TOT_ACT,
I_WEEKLY-TOT_DIFF,
I_WEEKLY-TOT_PERC.
EXIT.
ELSE.
IF SY-TABIX = 1.
L_MEINS = I_WEEK3-MEINS.
ELSE.
IF I_WEEK3-MEINS <> L_MEINS.
CLEAR: I_WEEKLY-TOT_PLAN,
I_WEEKLY-TOT_ACT,
I_WEEKLY-TOT_DIFF,
I_WEEKLY-TOT_PERC.
EXIT.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM. " check_uom_week
*&---------------------------------------------------------------------*
*& Form check_uom_week_res
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CHECK_UOM_WEEK_RES .
DATA L_MEINS TYPE MEINS.
READ TABLE I_WKDAY INDEX 1.
READ TABLE I_WEEK2 WITH KEY SPWOC = I_WEEKLY-SPWOC
WKDAY = I_WKDAY-WKDAY
ARBPL = I_WEEKLY-ARBPL.
IF SY-SUBRC <> 0 OR I_WEEK2-MEINS = C_NULL.
CLEAR: I_WEEKLY-MON_PLAN,
I_WEEKLY-MON_ACT,
I_WEEKLY-MON_DIFF,
I_WEEKLY-MON_PERC.
ENDIF.
READ TABLE I_WKDAY INDEX 2.
READ TABLE I_WEEK2 WITH KEY SPWOC = I_WEEKLY-SPWOC
WKDAY = I_WKDAY-WKDAY
ARBPL = I_WEEKLY-ARBPL.
IF SY-SUBRC <> 0 OR I_WEEK2-MEINS = C_NULL.
CLEAR: I_WEEKLY-TUE_PLAN,
I_WEEKLY-TUE_ACT,
I_WEEKLY-TUE_DIFF,
I_WEEKLY-TUE_PERC.
ENDIF.
READ TABLE I_WKDAY INDEX 3.
READ TABLE I_WEEK2 WITH KEY SPWOC = I_WEEKLY-SPWOC
WKDAY = I_WKDAY-WKDAY
ARBPL = I_WEEKLY-ARBPL.
IF SY-SUBRC <> 0 OR I_WEEK2-MEINS = C_NULL.
CLEAR: I_WEEKLY-WED_PLAN,
I_WEEKLY-WED_ACT,
I_WEEKLY-WED_DIFF,
I_WEEKLY-WED_PERC.
ENDIF.
READ TABLE I_WKDAY INDEX 4.
READ TABLE I_WEEK2 WITH KEY SPWOC = I_WEEKLY-SPWOC
WKDAY = I_WKDAY-WKDAY
ARBPL = I_WEEKLY-ARBPL.
IF SY-SUBRC <> 0 OR I_WEEK2-MEINS = C_NULL.
CLEAR: I_WEEKLY-THU_PLAN,
I_WEEKLY-THU_ACT,
I_WEEKLY-THU_DIFF,
I_WEEKLY-THU_PERC.
ENDIF.
READ TABLE I_WKDAY INDEX 5.
READ TABLE I_WEEK2 WITH KEY SPWOC = I_WEEKLY-SPWOC
WKDAY = I_WKDAY-WKDAY
ARBPL = I_WEEKLY-ARBPL.
IF SY-SUBRC <> 0 OR I_WEEK2-MEINS = C_NULL.
CLEAR: I_WEEKLY-FRI_PLAN,
I_WEEKLY-FRI_ACT,
I_WEEKLY-FRI_DIFF,
I_WEEKLY-FRI_PERC.
ENDIF.
READ TABLE I_WKDAY INDEX 6.
READ TABLE I_WEEK2 WITH KEY SPWOC = I_WEEKLY-SPWOC
WKDAY = I_WKDAY-WKDAY
ARBPL = I_WEEKLY-ARBPL.
IF SY-SUBRC <> 0 OR I_WEEK2-MEINS = C_NULL.
CLEAR: I_WEEKLY-SAT_PLAN,
I_WEEKLY-SAT_ACT,
I_WEEKLY-SAT_DIFF,
I_WEEKLY-SAT_PERC.
ENDIF.
READ TABLE I_WKDAY INDEX 7.
READ TABLE I_WEEK2 WITH KEY SPWOC = I_WEEKLY-SPWOC
WKDAY = I_WKDAY-WKDAY
ARBPL = I_WEEKLY-ARBPL.
IF SY-SUBRC <> 0 OR I_WEEK2-MEINS = C_NULL.
CLEAR: I_WEEKLY-SUN_PLAN,
I_WEEKLY-SUN_ACT,
I_WEEKLY-SUN_DIFF,
I_WEEKLY-SUN_PERC.
ENDIF.
LOOP AT I_WEEK2 WHERE SPWOC = I_WEEKLY-SPWOC AND
ARBPL = I_WEEKLY-ARBPL.
IF I_WEEK2-MEINS = C_NULL.
CLEAR: I_WEEKLY-TOT_PLAN,
I_WEEKLY-TOT_ACT,
I_WEEKLY-TOT_DIFF,
I_WEEKLY-TOT_PERC.
EXIT.
ELSE.
IF SY-TABIX = 1.
L_MEINS = I_WEEK2-MEINS.
ELSE.
IF I_WEEK2-MEINS <> L_MEINS.
CLEAR: I_WEEKLY-TOT_PLAN,
I_WEEKLY-TOT_ACT,
I_WEEKLY-TOT_DIFF,
I_WEEKLY-TOT_PERC.
EXIT.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM. " check_uom_week_res
 
*&---------------------------------------------------------------------*
*& Form check_uom_week_res_mat
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CHECK_UOM_WEEK_RES_MAT.
DATA L_MEINS TYPE MEINS.
READ TABLE I_WKDAY INDEX 1.
READ TABLE I_WEEK1 WITH KEY SPWOC = I_WEEKLY-SPWOC
WKDAY = I_WKDAY-WKDAY
ARBPL = I_WEEKLY-ARBPL
MATNR = I_WEEKLY-MATNR.
IF SY-SUBRC <> 0 OR I_WEEK1-MEINS = C_NULL.
CLEAR: I_WEEKLY-MON_PLAN,
I_WEEKLY-MON_ACT,
I_WEEKLY-MON_DIFF,
I_WEEKLY-MON_PERC.
ENDIF.
READ TABLE I_WKDAY INDEX 2.
READ TABLE I_WEEK1 WITH KEY SPWOC = I_WEEKLY-SPWOC
WKDAY = I_WKDAY-WKDAY
ARBPL = I_WEEKLY-ARBPL
MATNR = I_WEEKLY-MATNR.
IF SY-SUBRC <> 0 OR I_WEEK1-MEINS = C_NULL.
CLEAR: I_WEEKLY-TUE_PLAN,
I_WEEKLY-TUE_ACT,
I_WEEKLY-TUE_DIFF,
I_WEEKLY-TUE_PERC.
ENDIF.
READ TABLE I_WKDAY INDEX 3.
READ TABLE I_WEEK1 WITH KEY SPWOC = I_WEEKLY-SPWOC
WKDAY = I_WKDAY-WKDAY
ARBPL = I_WEEKLY-ARBPL
MATNR = I_WEEKLY-MATNR.
IF SY-SUBRC <> 0 OR I_WEEK1-MEINS = C_NULL.
CLEAR: I_WEEKLY-WED_PLAN,
I_WEEKLY-WED_ACT,
I_WEEKLY-WED_DIFF,
I_WEEKLY-WED_PERC.
ENDIF.
READ TABLE I_WKDAY INDEX 4.
READ TABLE I_WEEK1 WITH KEY SPWOC = I_WEEKLY-SPWOC
WKDAY = I_WKDAY-WKDAY
ARBPL = I_WEEKLY-ARBPL
MATNR = I_WEEKLY-MATNR.
IF SY-SUBRC <> 0 OR I_WEEK1-MEINS = C_NULL.
CLEAR: I_WEEKLY-THU_PLAN,
I_WEEKLY-THU_ACT,
I_WEEKLY-THU_DIFF,
I_WEEKLY-THU_PERC.
ENDIF.
READ TABLE I_WKDAY INDEX 5.
READ TABLE I_WEEK1 WITH KEY SPWOC = I_WEEKLY-SPWOC
WKDAY = I_WKDAY-WKDAY
ARBPL = I_WEEKLY-ARBPL
MATNR = I_WEEKLY-MATNR.
IF SY-SUBRC <> 0 OR I_WEEK1-MEINS = C_NULL.
CLEAR: I_WEEKLY-FRI_PLAN,
I_WEEKLY-FRI_ACT,
I_WEEKLY-FRI_DIFF,
I_WEEKLY-FRI_PERC.
ENDIF.
READ TABLE I_WKDAY INDEX 6.
READ TABLE I_WEEK1 WITH KEY SPWOC = I_WEEKLY-SPWOC
WKDAY = I_WKDAY-WKDAY
ARBPL = I_WEEKLY-ARBPL
MATNR = I_WEEKLY-MATNR.
IF SY-SUBRC <> 0 OR I_WEEK1-MEINS = C_NULL.
CLEAR: I_WEEKLY-SAT_PLAN,
I_WEEKLY-SAT_ACT,
I_WEEKLY-SAT_DIFF,
I_WEEKLY-SAT_PERC.
ENDIF.
READ TABLE I_WKDAY INDEX 7.
READ TABLE I_WEEK1 WITH KEY SPWOC = I_WEEKLY-SPWOC
WKDAY = I_WKDAY-WKDAY
ARBPL = I_WEEKLY-ARBPL
MATNR = I_WEEKLY-MATNR.
IF SY-SUBRC <> 0 OR I_WEEK1-MEINS = C_NULL.
CLEAR: I_WEEKLY-SUN_PLAN,
I_WEEKLY-SUN_ACT,
I_WEEKLY-SUN_DIFF,
I_WEEKLY-SUN_PERC.
ENDIF.
LOOP AT I_WEEK1 WHERE SPWOC = I_WEEKLY-SPWOC AND
ARBPL = I_WEEKLY-ARBPL AND
MATNR = I_WEEKLY-MATNR.
IF I_WEEK1-MEINS = C_NULL.
CLEAR: I_WEEKLY-TOT_PLAN,
I_WEEKLY-TOT_ACT,
I_WEEKLY-TOT_DIFF,
I_WEEKLY-TOT_PERC.
EXIT.
ELSE.
IF SY-TABIX = 1.
L_MEINS = I_WEEK1-MEINS.
ELSE.
IF I_WEEK1-MEINS <> L_MEINS.
CLEAR: I_WEEKLY-TOT_PLAN,
I_WEEKLY-TOT_ACT,
I_WEEKLY-TOT_DIFF,
I_WEEKLY-TOT_PERC.
EXIT.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM. " check_uom_week_res_mat
 
 
 
*&---------------------------------------------------------------------*
*& Form get_print_param
*&---------------------------------------------------------------------*
* Get the print parameters
*----------------------------------------------------------------------*
* <--fP_REC_OUT_PARAMS -- Print parameters
* <--fP_V_VALID -- Validity indicator
*----------------------------------------------------------------------*
FORM GET_PRINT_PARAM CHANGING FP_OUT_PARAMS TYPE PRI_PARAMS
" Print parameters
FP_VALID TYPE C. " Validity indicator
 
* DATA : l_arc_params TYPE arc_params.
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
* copies = p_cop
DESTINATION = C_LOCL "'LOCL'
* EXPIRATION = C_NUM1_UNKNOWN
* immediately = 'X'
* layout = 'X_58_170'
LINE_COUNT = C_55
LINE_SIZE = SY-LINSZ
LIST_NAME = C_LIST
* LIST_TEXT = C_CHAR_UNKNOWN
* MODE = ' '
NO_DIALOG = C_SPACE "' '
REPORT = SY-REPID
USER = SY-UNAME
IMPORTING
* out_archive_parameters = l_arc_params
OUT_PARAMETERS = FP_OUT_PARAMS
VALID = FP_VALID
EXCEPTIONS
ARCHIVE_INFO_NOT_FOUND = 1
INVALID_PRINT_PARAMS = 2
INVALID_ARCHIVE_PARAMS = 3
OTHERS = 4.
IF SY-SUBRC <> C_0.
CASE SY-SUBRC.
WHEN C_1.
MESSAGE E073. " Archive information not found
WHEN C_2.
MESSAGE E074. " Invalid print parameters
WHEN C_3.
MESSAGE E075. " Invalid archive parameters
ENDCASE.
ENDIF.
ENDFORM. " get_print_param
*Text elements
*----------------------------------------------------------
* 017 Order Quantities
* 018 KGM Quantities
* 019 Detail Report
* 020 Summary Report
* 021 Weekly Report
* 022 Daily Report
* 023 Quantities
* 024 Fiscal Values
* 030 Weekly Report
* 032 Order Quantities
 
*Selection texts
*----------------------------------------------------------
* CB_COLOR Display Color Legend
* CB_EXCL1 Exclude 1
* CB_EXCL2 Exclude 2
* CB_PLAN Planned Orders
* P_NOW Number of weeks
* P_SYST1 System 1
* P_SYST2 System 2
* P_WERKS Plant
* RB_DAILY Daily Report
* RB_DET Detail
* RB_FVAL Fiscal Values
* RB_KGM KGM Conversion
* RB_ORD Orders Unit
* RB_QUAN Quantities
* RB_SUM Summary
* RB_WEEK Weekly Report
* S_DATE Date to define first week
* S_MATNO Material
* S_MTYPE Material Type
* S_PRSCH Order Status Contains
* S_WCTR Work Center
 
*Messages
*----------------------------------------------------------
*
* Message class: ZDEV
*001 Please enter a correct Sales Organization !!
*009
*010
*011
*015
*033
*035
*038
*039
*040
*043
*044
*045
*073 Invalid combination of Sales Organization and Distribution Channel
*074
*075
*077
*078
*079
*080
*081
*090
*092
  • No labels