Skip to end of metadata
Go to start of metadata
Error rendering macro 'code': Invalid value specified for parameter 'com.atlassian.confluence.ext.code.render.InvalidValueException'
*&---------------------------------------------------------------------*
* Report: : ZPROCESSORD
* AUTHOR : Aveek Ghose *
* SUPPLIER : *
*======================================================================*
* CHANGE HISTORY LOG *
*----------------------------------------------------------------------*
* MOD. NO.| DATE | NAME | CORRECTION NUMBER | CHANGE REFERENCE #*
*----------------------------------------------------------------------*
* MOD-001 |DD/MM/YYYY| XXXXXX | XXXXXXXXXX | XXXXXXXXX *
* DESCRIPTION: *
*----------------------------------------------------------------------*
* MOD-002 |DD/MM/YYYY| XXXXXX | XXXXXXXXXX | XXXXXXXXX *
* DESCRIPTION: *
*----------------------------------------------------------------------*
****** Top Include for Declarations
* include ZPROCESSORDTOP.
*&---------------------------------------------------------------------*
*& Include ZPROCESSORDTOP
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Include ZPROCESSORDTOP
*&---------------------------------------------------------------------*
REPORT ZPROCESSORD LINE-SIZE 125 MESSAGE-ID ZDEV.
DATA : WA_AFKO TYPE AFKO, " Order header data PP orders
WA_CSSL TYPE CSSL. " Cost Center / Activity Type
*--------------------Ranges -----------------------------------------*
TYPES: BEGIN OF ty_r_bwart,
SIGN TYPE CHAR1,
OPTION TYPE CHAR2,
LOW TYPE BWART,
HIGH TYPE BWART,
END OF TY_R_BWART.
DATA: I_R_BWART TYPE STANDARD TABLE OF TY_R_BWART INITIAL SIZE 0,
WA_BWART TYPE TY_R_BWART.
TYPES : TY_STPRS TYPE P LENGTH 8 DECIMALS 2,                "MOD-101
* ty_stprs TYPE p LENGTH 8 DECIMALS 3, "MOD-101
TY_STPRS1 TYPE P LENGTH 8 DECIMALS 2,                       "MOD-101
TY_MENGE TYPE P LENGTH 8 DECIMALS 6,                        "MOD-101
TY_VGWRT(9) TYPE P DECIMALS 3.                              "MOD-101
*------------------Constants Declaration-----------------------------*
CONSTANTS:
C_X TYPE CHAR1 VALUE 'X', " Constant X
C_OBJTYP TYPE CR_OBJTY VALUE 'A', " Object Type
C_TXT_DLV TYPE CHAR4 VALUE 'DLV', " Order Status Delivered
C_TXT_CNF TYPE CHAR4 VALUE 'CNF', " Order status confirmed
C_BACK TYPE SYUCOMM VALUE 'BACK'," Back
C_TRDE TYPE SYUCOMM VALUE 'TRDE'," Order Details
C_TRPI TYPE SYUCOMM VALUE 'TRPI'," Choose
C_TRSL TYPE SYUCOMM VALUE 'TRSL'," Choose
C_SUMS TYPE SYUCOMM VALUE 'SUMS'," Summary Report
C_QTY TYPE SYUCOMM VALUE 'QTY', " Quantities
C_FISC TYPE SYUCOMM VALUE 'FISC'," Fiscal Values
C_KGM TYPE SYUCOMM VALUE 'KGM', " KGM
C_ORDU TYPE SYUCOMM VALUE 'ORDU'," Order UOM
C_ZERO TYPE SYUCOMM VALUE 'ZERO'," Zero Loss
C_STD TYPE SYUCOMM VALUE 'STD', " Non Zero Loss
C_SIGN TYPE CHAR1 VALUE 'I', " Range Sign
C_OPTION TYPE CHAR2 VALUE 'EQ', " Range Option
C_MOVM_LOW_261 TYPE BWART VALUE '261', " Range-low value OF movement
C_MOVM_LOW_262 TYPE BWART VALUE '262', " Range-low value OF movement
C_MOVM_LOW_531 TYPE BWART VALUE '531', " Range-low value OF movement
C_MOVM_LOW_532 TYPE BWART VALUE '532', " Range-low value OF movement
C_TLEVEL_2 TYPE CHAR2 VALUE '02', " Tree level
C_PLUS TYPE CHAR15 VALUE 'SYM_PLUS_FOLDER',
C_MINUS TYPE CHAR16 VALUE 'SYM_MINUS_FOLDER',
C_TEXT1 TYPE CHAR14 VALUE 'NODELIST-TEXT1',
C_TREP TYPE SYUCOMM VALUE 'TREP'," Expand subtree
C_TRCM TYPE SYUCOMM VALUE 'TRCM'," Collapse subtree
C_EXIT TYPE SYUCOMM VALUE '&F15', "Exit
C_101 TYPE BWART VALUE '101', "Movement type
C_102 TYPE BWART VALUE '102', "Movement type
C_TECO TYPE CHAR4 VALUE 'TECO',
C_S TYPE SHKZG VALUE 'S', "Debit/Credit Indicator
C_0 TYPE CHAR1 VALUE '0',
C_100 TYPE INT4 VALUE 100,
C_PERC TYPE CHAR1 VALUE '%',
C_BRAC TYPE CHAR1 VALUE ')',
*" BEGIN OF MOD-101
C_ZEROVAL TYPE TY_VGWRT VALUE '0.000',
C_DETL TYPE SYUCOMM VALUE 'DETL'," Detail Report
C_PHAS TYPE SYUCOMM VALUE 'PHAS'," Phase Report
C_TLEVEL_3 TYPE CHAR2 VALUE '03', " Tree level
C_TLEVEL_4 TYPE CHAR2 VALUE '04', " Tree level
C_40 TYPE INT4 VALUE 40,
C_1 TYPE INT4 VALUE 1,
C_2 TYPE INT4 VALUE 2,
C_3 TYPE INT4 VALUE 3,
C_4 TYPE INT4 VALUE 4,
C_5 TYPE INT4 VALUE 5,
C_6 TYPE INT4 VALUE 6,
C_8 TYPE INT4 VALUE 8,
C_10 TYPE INT4 VALUE 10,
C_12 TYPE INT4 VALUE 12,
C_14 TYPE INT4 VALUE 14,
C_18 TYPE INT4 VALUE 18,
C_20 TYPE INT4 VALUE 20,
C_22 TYPE INT4 VALUE 22,
C_24 TYPE INT4 VALUE 24,
C_25 TYPE INT4 VALUE 25,
C_26 TYPE INT4 VALUE 26,
C_30 TYPE INT4 VALUE 30,
C_33 TYPE INT4 VALUE 33,
C_35 TYPE INT4 VALUE 35,
C_37 TYPE INT4 VALUE 37,
C_42 TYPE INT4 VALUE 42,
C_45 TYPE INT4 VALUE 45,
C_1_1 TYPE CHAR3 VALUE '1_1',
C_2_1 TYPE CHAR3 VALUE '2_1',
C_2_2 TYPE CHAR3 VALUE '2_2',
C_3_1 TYPE CHAR3 VALUE '3_1',
C_3_2 TYPE CHAR3 VALUE '3_2',
C_3_3 TYPE CHAR3 VALUE '3_3',
C_3_4 TYPE CHAR3 VALUE '3_4',
C_4_1 TYPE CHAR3 VALUE '4_1',
C_4_2 TYPE CHAR3 VALUE '4_2',
C_5_1 TYPE CHAR3 VALUE '5_1',
C_5_2 TYPE CHAR3 VALUE '5_2',
C_6_1 TYPE CHAR3 VALUE '6_1',
C_6_2 TYPE CHAR3 VALUE '6_2',
* c_1_1 TYPE char3 VALUE '1_1',
* c_1 TYPE int4 VALUE 1,
* c_40 TYPE int4 VALUE 40,
* c_2_1 TYPE char3 VALUE '2_1',
* c_3_1 TYPE char3 VALUE '3_1',
* c_2 TYPE int4 VALUE 2,
* c_22 TYPE int4 VALUE 22,
* c_15 TYPE int4 VALUE 15,
* c_25 TYPE int4 VALUE 25,
* c_20 TYPE int4 VALUE 20,
* c_3 TYPE int4 VALUE 3,
* c_4 TYPE int4 VALUE 4,
* c_2_2 TYPE char3 VALUE '2_2',
* c_3_3 TYPE char3 VALUE '3_3',
* c_3_4 TYPE char3 VALUE '3_4',
* c_6_1 TYPE char3 VALUE '6_1',
* c_3_2 TYPE char3 VALUE '3_2',
* C_35 TYPE int4 VALUE 32,
* C_36 TYPE int4 VALUE 36,
* c_4_1 TYPE char3 VALUE '4_1',
* c_18 TYPE int4 VALUE 18,
* c_30 TYPE int4 VALUE 30,
* c_35_1 TYPE int4 VALUE 35,
* c_6 TYPE int4 VALUE 6,
* c_19 TYPE int4 VALUE 19,
* c_29 TYPE int4 VALUE 29,
* c_21 TYPE int4 VALUE 21,
* c_12 TYPE int4 VALUE 12,
* c_33 TYPE int4 VALUE 30, "33,
* c_37 TYPE int4 VALUE 37,
* c_10 TYPE int4 VALUE 10,
* c_42 TYPE int4 VALUE 42,
* c_3_5 TYPE char3 VALUE '3_5',
* c_45 TYPE int4 VALUE 45,
* c_44 TYPE int4 VALUE 44,
* c_3_6 TYPE char3 VALUE '3_6',
* c_26 TYPE int4 VALUE 26,
* c_5 TYPE int4 VALUE 5,
*"END OF MOD-101
C_M TYPE CHAR1 VALUE 'M',
C_Y TYPE CHAR1 VALUE 'Y',
C_HYP TYPE CHAR1 VALUE '-',
C_A TYPE CHAR1 VALUE 'A', "Object type
C_000 TYPE VERSN VALUE '000', "Version
C_PROG TYPE SYCPROG VALUE '/EUR/RGBPTR_PRO_ORDER_VARIANCE'.
*------------------Data Declaration----------------------------------*
DATA:
V_WAERS TYPE WAERS, " Currency Key
V_UOM TYPE CHAR5,
V_MSEHI TYPE MSEHI VALUE 'SGL',
V_WERKS TYPE WERKS_D,                                       "#EC NEEDED
V_OUTPUT_TEXT(60) TYPE C,
V_PLANT_EFFIC(3) TYPE N,
V_DUMMY(4) TYPE C, " Dummy variable for Ord. Status
FLG_COLOR(1) TYPE C,
***Begin of MOD-001
V_UCOMM TYPE SYUCOMM,
V_UCOMM1 TYPE SYUCOMM,
V_STAT1 TYPE J_ISTAT,
V_STAT2 TYPE J_ISTAT,
V_CONV_RC TYPE CHAR1,
V_REP TYPE SYUCOMM,
V_OLDF TYPE CHAR3,
V_NEWF TYPE CHAR3,
V_PRS TYPE TY_STPRS1,
****End of MOD-001
****mod-03.
V_MEINS TYPE MSEHI. "to store c_kgm value.
****mod-03.
*------------------ Types Declaration -------------------------------*
TYPES:
* Type for Work Center Header
BEGIN OF TY_CRHD,
OBJID TYPE CR_OBJID, " Object ID of the resource
ARBPL TYPE ARBPL, " Work center
VGWTS TYPE VORGSCHL, " Std. Value Key "MOD-101
END OF TY_CRHD,
* Type for Cost Center Master Data
BEGIN OF TY_CSKS,
KOKRS TYPE KOKRS, " Controlling Area
KOSTL TYPE KOSTL, " Cost Center
END OF TY_CSKS,
* Type for Assignment of Work Center to Cost Center
BEGIN OF TY_CRCO,
OBJTY TYPE CR_OBJTY,
OBJID TYPE CR_OBJID,
KOKRS TYPE KOKRS,
KOSTL TYPE KOSTL,
LSTAR TYPE LSTAR,                                           "MOD-101
END OF TY_CRCO,
* Type for process order with order status text
BEGIN OF TY_ORDER_STATUS_TEXT,
AUFNR TYPE AUFNR,
STTXT(100) TYPE C,
END OF TY_ORDER_STATUS_TEXT,
* Type for Order status texts
BEGIN OF TY_TJ02T,
ISTAT TYPE J_ISTAT, " Status number " MOD-101+
TXT04 TYPE J_TXT04,
END OF TY_TJ02T,
* Type for plant Materials
BEGIN OF TY_MARC,
MATNR TYPE MATNR,
WERKS TYPE WERKS_D,
KAUSF TYPE KAUSF,
END OF TY_MARC,
*" BEGIN OF MOD-101
* Type for Orders
BEGIN OF TY_ORDERS,
AUFNR TYPE AUFNR, " Order Number
WERKS TYPE WERKS_D, " Plant
KOKRS TYPE KOKRS, " Controlling Area
OBJNR TYPE J_OBJNR, " Object number
GLTRP TYPE SYDATUM, " Date
GSTRP TYPE CO_GSTRP, " Basic start Date
RSNUM TYPE RSNUM, " Reservation number
GAMNG TYPE GAMNG, " Total order quantity
GMEIN TYPE MEINS, " order uom
PLNBEZ TYPE MATNR, " Material Number
PLNTY TYPE PLNTY, " Task list type
PLNNR TYPE PLNNR, " Key for task list group
PLNAL TYPE PLNAL, " Group counter
STLST TYPE STLST, " BOM Status
STLTY TYPE STLTY, " BOM category
STLNR TYPE STNUM, " Bill of material
SDATV TYPE DATUV, " Valid-From Date
STLAL TYPE STALT, " Alternative BOM
STLAN TYPE STLAN, " BOM Usage
AUFPL TYPE CO_AUFPL, " Routing no for operations in order
ZAEHL TYPE CIM_COUNT, " Internal counter
RUECK TYPE CO_RUECK, " Confirmation number of operation
AUART TYPE AUFART, " Order Type
** Begin of change on 31-05-2005
AUFLD TYPE CO_AUFLD,
" Date of BOM Explosion/Routing Transfer
** End of change on 31-05-2005
CAPID TYPE CAPID, " BOM Application
MENGE TYPE MENGE_D, " Quantity
ERFMG TYPE ERFMG, " Quantity
LMNGA TYPE RU_LMNGA, " Yield currently to be confirmed
MAKTX TYPE MAKTX, " Material Description
BMENG TYPE BASMN, " Base Quantity
BMEIN TYPE BASME, " Base unit of measure for BOM
KAUSF TYPE KAUSF, " Component scrap in percent
* Qty in base UoM
BLMNGA TYPE RU_LMNGA, " Yield currently to be confirmed
BMENGE TYPE MENGE_D, " GR Quantity
BGAMNG TYPE GAMNG, " Total Order Qty
BBMENG TYPE BASMN, " Base Quantity in Base UoM
* UoM
GRUOM TYPE MEINS, " gr uom
CFUOM TYPE MEINS, " conf uom
BSUOM TYPE MEINS, " base uom
GEWEI TYPE GEWEI, " weight uom
NTGEW TYPE NTGEW,
DEL,
END OF TY_ORDERS,
* Type for BOM Appln
BEGIN OF TY_BOMAPP,
WERKS TYPE WERKS_D, " Plant
AUART TYPE AUFART, " Order Type
CAPID TYPE CAPID, " BOM Appln
END OF TY_BOMAPP,
* Type for Operation within an order
BEGIN OF TY_AFVC,
AUFPL TYPE CO_AUFPL,
APLZL TYPE CO_APLZL,
LTXA1 TYPE LTXA1,
PLNKN TYPE PLNKN,
PLNTY TYPE PLNTY,
PLNNR TYPE PLNNR,
ZAEHL TYPE CIM_COUNT,
VORNR TYPE VORNR,
STEUS TYPE STEUS,
ARBID TYPE CR_OBJID,
RUECK TYPE CO_RUECK,
PHFLG TYPE PHFLG,
SUMNR TYPE SUMKNTNR,
VGWTS TYPE VORGSCHL,
LAR01 TYPE LSTAR,
LAR02 TYPE LSTAR,
LAR03 TYPE LSTAR,
LAR04 TYPE LSTAR,
LAR05 TYPE LSTAR,
LAR06 TYPE LSTAR,
AUFNR TYPE AUFNR,
LMNGA TYPE LMNGA,
CFUOM TYPE MEINS,
GMEIN TYPE MEINS,
END OF TY_AFVC,
* Type for quantities/dates/values in the operations
BEGIN OF TY_AFVV,
AUFPL TYPE CO_AUFPL, " Routing number of operations in the order
APLZL TYPE CO_APLZL, " General counter for order
MEINH TYPE VORME, " Activity unit of measure
BMSCH TYPE BMSCH, " Base Quantity
UMREN TYPE CP_UMREN,
UMREZ TYPE CP_UMREZ,
VGE01 TYPE VGWRTEH, " Unit of measure for the standard value
VGW01 TYPE VGWRT, " Standard value
VGE02 TYPE VGWRTEH, " Unit of measure for the standard value
VGW02 TYPE VGWRT, " Standard value
VGE03 TYPE VGWRTEH, " Unit of measure for the standard value
VGW03 TYPE VGWRT, " Standard value
VGE04 TYPE VGWRTEH, " Unit of measure for the standard value
VGW04 TYPE VGWRT, " Standard value
VGE05 TYPE VGWRTEH, " Unit of measure for the standard value
VGW05 TYPE VGWRT, " Standard value
VGE06 TYPE VGWRTEH, " Unit of measure for the standard value
VGW06 TYPE VGWRT, " Standard value
MGVRG TYPE MGVRG, " Operation Quantity
LMNGA TYPE LMNGA, " Total Yield Confirmed
GMNGA TYPE GMNGA, " Yield Confirmed in order UoM
ISM01 TYPE CO_RUMNG, " Previously confirmed activity
ISM02 TYPE CO_RUMNG, " Previously confirmed activity
ISM03 TYPE CO_RUMNG, " Previously confirmed activity
ISM04 TYPE CO_RUMNG, " Previously confirmed activity
ISM05 TYPE CO_RUMNG, " Previously confirmed activity
ISM06 TYPE CO_RUMNG, " Previously confirmed activity
SSAVD TYPE SSAVD, " Latest scheduled start: Execution (date)
GAMNG TYPE GAMNG,
BBMSCH TYPE BMSCH,
PRDUOM TYPE MEINS,
BSUOM TYPE VORME,
END OF TY_AFVV,
* Type for Document Segment: Material
BEGIN OF TY_MSEG,
AUFNR TYPE AUFNR,
AUFPL TYPE CO_AUFPL,
APLZL TYPE CO_APLZL,
MATNR TYPE MATNR,
MBLNR TYPE MBLNR,
MJAHR TYPE MJAHR,
ZEILE TYPE MBLPO,
BWART TYPE BWART,
WERKS TYPE WERKS_D,
LGORT TYPE LGORT_D,
CHARG TYPE CHARG_D,
MENGE TYPE MENGE_D,
MEINS TYPE MEINS,
ERFMG TYPE ERFMG,
ERFME TYPE ERFME,
RSNUM TYPE RSNUM,
RSPOS TYPE RSPOS,
RSART TYPE RSART,
BMENGE TYPE MENGE_D,
BMEINS TYPE MEINS,
GEWEI TYPE GEWEI,
NTGEW TYPE NTGEW,
END OF TY_MSEG,
* Type for Document Segment: Material - Sum of Qtys
BEGIN OF TY_MSEG_SUM,
AUFNR TYPE AUFNR,
AUFPL TYPE CO_AUFPL,
APLZL TYPE CO_APLZL,
MATNR TYPE MATNR,
MEINS TYPE MEINS,
ERFMG TYPE ERFMG,
ERFMG1 TYPE ERFMG,
ERFMG2 TYPE ERFMG,
ERFMG5 TYPE ERFMG,
ERFME TYPE ERFME,
BMENGE TYPE MENGE_D,
BMENGE1 TYPE MENGE_D,
BMENGE2 TYPE MENGE_D,
BMENGE5 TYPE MENGE_D,
BMEINS TYPE MEINS,
GEWEI TYPE GEWEI,
BWART TYPE BWART,                                           "23-06-2005
END OF TY_MSEG_SUM,
* Type for Order completion confirmations
BEGIN OF TY_AFRU,
AUFNR TYPE AUFNR,
RUECK TYPE CO_RUECK,
GMNGA TYPE RU_GMNGA,
LMNGA TYPE RU_LMNGA,
GMEIN TYPE MEINS,
MEINH TYPE RU_VORME,
MEILR TYPE MEILR,
STOKZ TYPE CO_STOKZ,
RUECK_MST TYPE CO_RUECK,
AUFPL TYPE CO_AUFPL,
APLZL TYPE CO_APLZL,
END OF TY_AFRU,
* Type for Reservation/dependent requirements
BEGIN OF TY_RESB,
RSNUM TYPE RSNUM,
RSPOS TYPE RSPOS,
RSART TYPE RSART,
XLOEK TYPE XLOEK,
MATNR TYPE MATNR,
WERKS TYPE WERKS_D,
BDMNG TYPE BDMNG,
MEINS TYPE MEINS,
SHKZG TYPE SHKZG,
AUFNR TYPE AUFNR,
DUMPS TYPE DUMPS,
AUFPL TYPE CO_AUFPL,
VORNR TYPE VORNR,
APLZL TYPE CO_APLZL,
POSTP TYPE POSTP,
KZKUP TYPE KZKUP,
RGEKZ TYPE RGEKZ,
AUSCH TYPE CS_E_AUSCH,
STLTY TYPE STLTY,
STLNR TYPE STNUM,
STLKN TYPE STLKN,
STPOZ TYPE CIM_COUNT,
BWART TYPE BWART, "Neel 30/06/2005
BBDMNG TYPE BDMNG,
BMEINS TYPE MEINS,
FLAGP TYPE CHAR1,                                           " MOD-GT1+
END OF TY_RESB,
* Individual materials for production order.
BEGIN OF TY_ORDMATS,
AUFNR TYPE AUFNR, " Order number
AUFPL TYPE CO_AUFPL,
APLZL TYPE CO_APLZL,
MATNR TYPE MATNR, " Component material
MTART TYPE MTART, " material type
STUFE TYPE HISTU,
*>>NEEL 4/6/2005
WEGXX TYPE CS_E_VWEGX,
TTIDX TYPE TTIDX,
VWEGX TYPE WEGXX,
*<<NEEL 4/6/2005
OJTXB TYPE OJTXB, " parent object text
OJTXP TYPE OJTXP, " object text
MENGE TYPE MENGE_D, " component qty
MENGES TYPE MENGE_D, " component qty with scrap
MENGEZ TYPE MENGE_D, " component qty with zero loss
MEINS TYPE MEINS, " component uom
XMENG TYPE CS_E_XBMNG, " BoM Base Qty (Next Level)
XMENGS TYPE CS_E_XBMNG, " BoM Base Qty (Next Level) w scrap
XMENGZ TYPE CS_E_XBMNG, " BoM Base Qty (Next Level) w zero loss
XMEIN TYPE CS_E_XBMEN, " BoM Base UoM (Next Level)
MNGLG TYPE CS_E_MNGLG, " Calc. Comp. Qty in Base UoM
MNGLGS TYPE CS_E_MNGLG, " Calc.Comp.Qty in Base UoM w scrap
MNGLGZ TYPE CS_E_MNGLG,
" Calc.Comp.Qty in Base UoM w zero loss
MMEIN TYPE MEINS, " base UoM
STPRS TYPE STPRS, " std price
PEINH TYPE PEINH, " price unit
POSTP TYPE POSTP, " Item category ( BOM )
MSIGN TYPE CS_E_MSIGN, " +/- sign
RGEKZ TYPE RGEKZ, " back flush indicator
AUSCH TYPE CS_E_AUSCH, " component scrap
KAUSF TYPE CS_E_KAUSF, " component scrap %
* yyzero TYPE /glb/rgtpt_yyzero, " Zero loss conversion factor
BOM TYPE CHAR1,
BOMD TYPE CHAR1,
BYPROD TYPE CHAR1, " by product indicator
STLTY TYPE STLTY,
STLNR TYPE STNUM,
STLKN TYPE STLKN,
STPOZ TYPE CIM_COUNT,
END OF TY_ORDMATS,
* Type for Material Production unit
BEGIN OF TY_MARC1,
MATNR TYPE MATNR,
WERKS TYPE WERKS_D,
FRTME TYPE FRTME,
END OF TY_MARC1,
* Type for Material Production unit
BEGIN OF TY_MARA,
MATNR TYPE MATNR,
MTART TYPE MTART,
MEINS TYPE MEINS,
GEWEI TYPE GEWEI,
NTGEW TYPE NTGEW,
END OF TY_MARA,
* Type for parameter ID
BEGIN OF TY_PARAM,
VGWTS TYPE VORGSCHL,
PAR01 TYPE PARAMID,
PAR02 TYPE PARAMID,
PAR03 TYPE PARAMID,
PAR04 TYPE PARAMID,
PAR05 TYPE PARAMID,
PAR06 TYPE PARAMID,
END OF TY_PARAM,
* Type for keyword for parameter ID
BEGIN OF TY_PARAM_KEY,
PARID TYPE PARAMID,
TXTLG TYPE PARALTXT,
END OF TY_PARAM_KEY,
BEGIN OF TY_MBEW1,
MATNR TYPE MATNR,
BWKEY TYPE BWKEY,
STPRS TYPE STPRS,
PEINH TYPE PEINH,
END OF TY_MBEW1,
BEGIN OF TY_HIER_ORDER,
AUFNR TYPE AUFNR, " Order number
* Dates
GLTRP TYPE SYDATUM,
GSTRP TYPE SYDATUM,
* Material
PLNBEZ TYPE MATNR, " Material Number
MAKTX TYPE MAKTX, " Material desc
* Bottleneck Resource
BOTLNCK TYPE ARBPL, " bottleneck resorc
RESDESC TYPE KTEXT, " resorc desc
* Efficiencies
EL_EFFC TYPE VGWRT, " expected line effic
AC_EFFC TYPE VGWRT, " actual line effic
* Qty
PRDQTY TYPE GAMNG, " PO qty displayed
PRDUOM TYPE MEINS, " PO UoM displayed
BPRDQTY TYPE GAMNG,
LMNGA TYPE RU_LMNGA, " Yield currently to be confirmed
MENGE TYPE MENGE_D, " GR Quantity
ERFMG TYPE ERFMG, " GR Quantity
GAMNG TYPE GAMNG, " Total Order Qty
BMENG TYPE BASMN, " Base Quantity in BOM
* Qty in base UoM
BLMNGA TYPE RU_LMNGA, " Yield currently to be confirmed
BMENGE TYPE MENGE_D, " GR Quantity
BGAMNG TYPE GAMNG, " Total Order Qty
BBMENG TYPE BASMN, " Base Quantity in Base UoM
* Std price
CSTPRS TYPE STPRS, " Calc Price
STPRS TYPE STPRS, " Std Price
PEINH TYPE PEINH, " Price unit
* UoM
GRUOM TYPE MEINS, " gr uom
CFUOM TYPE MEINS, " conf uom
BSUOM TYPE MEINS, " base uom
FRTME TYPE FRTME, " production unit
GEWEI TYPE GEWEI, " weight uom
NTGEW TYPE NTGEW,
END OF TY_HIER_ORDER,
BEGIN OF TY_HIER_PHASE,
AUFNR TYPE AUFNR,
AUFPL TYPE CO_AUFPL,
APLZL TYPE CO_APLZL,
VORNR TYPE VORNR,
LTXA1 TYPE LTXA1,
STEUS TYPE STEUS,
RUECK TYPE CO_RUECK,
ARBID TYPE ARBID,
ARBPL TYPE ARBPL,
KTEXT TYPE CR_KTEXT,
EL_EFFC TYPE VGWRT,
AC_EFFC TYPE VGWRT,
VGWTS TYPE VORGSCHL,
LMNGA TYPE LMNGA,
GMNGA TYPE GMNGA,
BLMNGA TYPE LMNGA,
BGMNGA TYPE GMNGA,
PRDQTY TYPE GAMNG,
PRDUOM TYPE MEINS,
BPRDQTY TYPE GAMNG,
CFUOM TYPE MEINS,
BSUOM TYPE MEINS,
GEWEI TYPE GEWEI,
NTGEW TYPE NTGEW,
RUNTIME,
END OF TY_HIER_PHASE,
BEGIN OF TY_HIER_ACT,
AUFNR TYPE AUFNR,
PARXX TYPE PARAMID,
AUFPL TYPE CO_AUFPL,
APLZL TYPE CO_APLZL,
VORNR TYPE VORNR,
VGWTS TYPE VORGSCHL,
MGVRG TYPE MGVRG,
BMSCH TYPE BMSCH,
MEINH TYPE VORME,
BMGVRG TYPE MGVRG,
BBMSCH TYPE BMSCH,
BMEINH TYPE VORME,
TXTXX TYPE PARALTXT,
* actual usage
ISMXX TYPE RU_ISMNG,
ILEXX TYPE CO_ISMNGEH,
* std usage
VGEXX TYPE VGWRTEH,
VGWXX TYPE TY_VGWRT,
TKGXX TYPE TKGXXX,
TKEXX TYPE TKEXXX,
TOGXX TYPE TOGXXX,
TOEXX TYPE TOEXXX,
ACTU TYPE TY_STPRS,
STDU TYPE TY_STPRS,
VARU TYPE TY_STPRS,
STDVAR TYPE TY_VGWRT,
VARPER TYPE CO_RUMNG,
CSTPRS TYPE STPRS,
STPRS TYPE STPRS,
PEINH TYPE PEINH,
END OF TY_HIER_ACT,
BEGIN OF TY_HIER_MAT,
AUFNR TYPE AUFNR,
MATNR TYPE MATNR,
BYPROD TYPE CHAR1,
AUFPL TYPE CO_AUFPL,
APLZL TYPE CO_APLZL,
VORNR TYPE VORNR,
MAKTX TYPE MAKTX,
ACTUSG TYPE MENGE_D,
STDUSG TYPE MENGE_D,
STDUSGS TYPE MENGE_D,
STDUSGZ TYPE MENGE_D,
STDVAR TYPE MENGE_D,
VARPER TYPE MENGE_D,
KAUSF TYPE KAUSF,
* yyzero TYPE /glb/rgtpt_yyzero,
BSUOM TYPE MEINS,
GRUOM TYPE MEINS,
GEWEI TYPE GEWEI,
NTGEW TYPE NTGEW,
BOMUOM TYPE MEINS,
CSTPRS TYPE STPRS,
VSTPRS TYPE TY_STPRS,
STPRS TYPE STPRS,
PEINH TYPE PEINH,
SUMI TYPE CHAR1,
BWART TYPE BWART,                                           "23-05-2005
END OF TY_HIER_MAT,
BEGIN OF TY_HIER_ACT_SUM,
PARXX TYPE PARAMID,
TXTXX TYPE PARALTXT,
ISMXX TYPE RU_ISMNG,
ILEXX TYPE CO_ISMNGEH,
VGEXX TYPE VGWRTEH,
VGWXX TYPE TY_VGWRT,
ACTU TYPE TY_STPRS,
STDU TYPE TY_STPRS,
VARU TYPE TY_STPRS,
STDVAR TYPE TY_VGWRT,
VARPER TYPE CO_RUMNG,
END OF TY_HIER_ACT_SUM,
BEGIN OF TY_HIER_MAT_SUM,
MATNR TYPE MATNR,
MAKTX TYPE MAKTX,
ACTUSG TYPE MENGE_D,
ACTUOM TYPE MEINS,
STDUSG TYPE MENGE_D,
STDUOM TYPE MEINS,
STDVAR TYPE MENGE_D,
VARUOM TYPE MEINS,
ASTPRS TYPE TY_STPRS,
SSTPRS TYPE TY_STPRS,
VARPRS TYPE TY_STPRS,
VARPER TYPE MENGE_D,
END OF TY_HIER_MAT_SUM,
* Type for Order confirmations
BEGIN OF TY_ORD_CONF,
RUECK TYPE CO_RUECK,
RMZHL TYPE CO_RMZHL,
ISM01 TYPE RU_ISMNG,
ILE01 TYPE CO_ISMNGEH,
ISM02 TYPE RU_ISMNG,
ILE02 TYPE CO_ISMNGEH,
ISM03 TYPE RU_ISMNG,
ILE03 TYPE CO_ISMNGEH,
ISM04 TYPE RU_ISMNG,
ILE04 TYPE CO_ISMNGEH,
ISM05 TYPE RU_ISMNG,
ILE05 TYPE CO_ISMNGEH,
ISM06 TYPE RU_ISMNG,
ILE06 TYPE CO_ISMNGEH,
STOKZ TYPE CO_STOKZ,
END OF TY_ORD_CONF,
* Type for Parameters
BEGIN OF TY_PAR,
PARXX TYPE PARAMID,
END OF TY_PAR,
* Type for selection parameters for reading PLPO
BEGIN OF TY_PLPO_SEL,
PLNTY TYPE PLNTY,
PLNNR TYPE PLNNR,
PLNKN TYPE PLNKN,
ZAEHL TYPE CIM_COUNT,
END OF TY_PLPO_SEL,
* Type for selection parameters for reading AFRU
BEGIN OF TY_AFRU_SEL,
RUECK TYPE CO_RUECK,
END OF TY_AFRU_SEL,
* Type for Control Keys
BEGIN OF TY_CKEY,
PLNAW TYPE PLNAW,
STEUS TYPE STEUS,
KALKZ TYPE CK_KALKZ,
END OF TY_CKEY,
* Type for object statuses
BEGIN OF TY_OBJ_STAT,
OBJNR TYPE J_OBJNR, " Object number
STAT TYPE J_ISTAT, " Status number
END OF TY_OBJ_STAT,
TY_T_STB TYPE STANDARD TABLE OF STPOX
WITH NON-UNIQUE DEFAULT KEY,
* Type for BOM data,
BEGIN OF TY_BOMDAT,
CAPID TYPE CAPID, " BOM Application
DATUV TYPE DATUV, " Valid-From Date
MTNRV TYPE MATNR, " Material
STLAL TYPE STALT, " Alternative BOM
STLAN TYPE STLAN, " BOM Usage
WERKS TYPE WERKS_D, " Plant
TMAT TYPE CSTMAT,
STB TYPE TY_T_STB,
END OF TY_BOMDAT,
TY_T_BOMDAT TYPE SORTED TABLE OF TY_BOMDAT
WITH UNIQUE KEY CAPID
DATUV
MTNRV
STLAL
STLAN
WERKS,
** Type for Orders
* BEGIN OF ty_orders,
* aufnr TYPE aufnr, " Order Number
* werks TYPE werks_d, " Plant
* kokrs TYPE kokrs, " Controlling Area
* objnr TYPE j_objnr, " Object number
* gltrp TYPE sydatum, " Date
* rsnum TYPE rsnum, " Reservation number
* gamng TYPE gamng, " Total order quantity
* gmein TYPE meins, " order uom
* plnbez TYPE matnr, " Material Number
* plnty TYPE plnty, " Task list type
* plnnr TYPE plnnr, " Key for task list group
* plnal TYPE plnal, " Group counter
* stlst TYPE stlst, " BOM Status " MOD-001
* stlty TYPE stlty, " BOM category
* stlnr TYPE stnum, " Bill of material
* stlal TYPE stalt, " Alternative BOM
* aufpl TYPE co_aufpl, " Routing no for operations in order
* zaehl TYPE cim_count, " Internal counter
* rueck TYPE co_rueck, " Confirmation number of operation
* END OF ty_orders,
*
** Type for Process orders details
* BEGIN OF ty_pro_orders,
* aufnr TYPE aufnr, " Order Number
* werks TYPE werks_d, " Plant
* kokrs TYPE kokrs, " Controlling Area
* objnr TYPE j_objnr, " Object number
* gltrp TYPE sydatum, " Date
* rsnum TYPE rsnum, " Reservation number
* gamng TYPE gamng, " Total order quantity
* gmein TYPE meins, " order uom
* plnbez TYPE matnr, " Material Number
* plnty TYPE plnty, " Task list type
* plnnr TYPE plnnr, " Key for task list group
* plnal TYPE plnal, " Group counter
* stlst TYPE stlst, " BOM Status " MOD-001
* stlty TYPE stlty, " BOM category
* stlnr TYPE stnum, " Bill of material
* stlal TYPE stalt, " Alternative BOM
* aufpl TYPE co_aufpl, " Routing no for operations in order
* zaehl TYPE cim_count, " Internal counter
* rueck TYPE co_rueck, " Confirmation number of operation
* wdate TYPE sydatum, " System date
* dayflg(1) TYPE n, " Day flag
* pos1(3) TYPE n, " position
* arbpl TYPE arbpl, " Work center
* sttxt(100) TYPE c, " Status text
* menge TYPE menge_d, " Quantity
* lmnga TYPE ru_lmnga, " Yield currently to be confirmed
* arbid TYPE objektid, " Object ID
* plnkn TYPE plnkn, " Number of the task list node
* pl_efic(3) TYPE n, " Plant effic
* gruom TYPE meins, " gr uom
* cfuom TYPE meins, " conf uom
* END OF ty_pro_orders,
** Type for Operation within an order
* BEGIN OF ty_afvc,
* aufpl TYPE co_aufpl,
* aplzl TYPE co_aplzl,
* plnkn TYPE plnkn,
* plnty TYPE plnty,
* plnnr TYPE plnnr,
* zaehl TYPE cim_count,
* vornr TYPE vornr,
* arbid TYPE cr_objid,
* rueck TYPE co_rueck,
* steus TYPE steus,
* phflg TYPE phflg,
* END OF ty_afvc,
*
** Type for quantities/dates/values in the operations
* BEGIN OF ty_afvv,
* aufpl TYPE co_aufpl, " Routing number of operations in the order
* aplzl TYPE co_aplzl, " General counter for order
* bmsch TYPE bmsch, " Base Quantity
* vgw02 TYPE vgwrt, " Standard value
* lmnga TYPE lmnga, " Total Yield Confirmed
* ism02 TYPE co_rumng, " Previously confirmed activity
* ssavd TYPE ssavd, " Latest scheduled start: Execution (date)
* END OF ty_afvv,
*
** Type for Order Operatons
* BEGIN OF ty_ordops,
* aufnr TYPE aufnr,
* aufpl TYPE co_aufpl,
* aplzl TYPE co_aplzl,
* plnkn TYPE plnkn,
* plnty TYPE plnty,
* plnnr TYPE plnnr,
* zaehl TYPE cim_count,
* vornr TYPE vornr,
* arbid TYPE cr_objid,
* rueck TYPE co_rueck,
* ssavd TYPE ssavd,
* plt_effic(3) TYPE n,
* arbpl TYPE arbpl,
**********MOD-005**************
* lmnga TYPE lmnga,
* cfuom TYPE meins,
*********MOD-005**************
* END OF ty_ordops,
*
** Type for Document Segment: Material
* BEGIN OF ty_mseg,
* aufnr TYPE aufnr,
* mblnr TYPE mblnr,
* mjahr TYPE mjahr,
* zeile TYPE mblpo,
* matnr TYPE matnr,
* bwart TYPE bwart,
* menge TYPE menge_d,
* meins TYPE meins,
** sjahr TYPE mjahr,
** smbln TYPE mblnr,
** smblp TYPE mblpo,
* rsnum TYPE rsnum,
* rspos TYPE rspos,
* rsart TYPE rsart,
***** Mod-002**********
* erfmg TYPE erfmg,
* erfme TYPE erfme,
**** Mod-002***********
* END OF ty_mseg,
*
** Type for Order completion confirmations
* BEGIN OF ty_afru,
* aufnr TYPE aufnr,
* rueck TYPE co_rueck,
* gmnga TYPE ru_gmnga,
* lmnga TYPE ru_lmnga,
* gmein TYPE meins,
* meinh TYPE ru_vorme,
* meilr TYPE meilr,
* stokz TYPE co_stokz,
* rueck_mst TYPE co_rueck,
* END OF ty_afru,
*
** Type for Document Segment material
* BEGIN OF ty_doc_segment,
* aufnr TYPE aufnr,
* mblnr TYPE mblnr,
* mjahr TYPE mjahr,
* zeile TYPE mblpo,
* matnr TYPE matnr,
* bwart TYPE bwart,
* menge TYPE menge_d,
* meins TYPE meins,
** sjahr TYPE mjahr,
** smbln TYPE mblnr,
** smblp TYPE mblpo,
* rsnum TYPE rsnum,
* rspos TYPE rspos,
* rsart TYPE rsart,
* END OF ty_doc_segment,
*
** Type for linked documents prev_doc
* BEGIN OF ty_prev_doc,
* mblnr TYPE mblnr,
* mjahr TYPE mjahr,
* zeile TYPE mblpo,
* sjahr TYPE mjahr,
* smbln TYPE mblnr,
* smblp TYPE mblpo,
* rsnum TYPE rsnum,
* rspos TYPE rspos,
* rsart TYPE rsart,
* END OF ty_prev_doc,
*
** Type for Issued materials
* BEGIN OF ty_issued_mat,
* aufnr TYPE aufnr,
* rsnum TYPE rsnum,
* rspos TYPE rspos,
* rsart TYPE rsart,
* matnr TYPE matnr,
* menge TYPE menge_d,
* meins TYPE meins,
* stprs TYPE stprs, "std price
* peinh TYPE peinh, "price uom
* END OF ty_issued_mat,
*
** Type for Reservation/dependent requirements
* BEGIN OF ty_reservations,
* rsnum TYPE rsnum,
* rspos TYPE rspos,
* rsart TYPE rsart,
* xloek TYPE xloek,
* matnr TYPE matnr,
* werks TYPE werks_d,
* bdmng TYPE bdmng,
* meins TYPE meins,
* shkzg TYPE shkzg,
* aufnr TYPE aufnr,
* dumps TYPE dumps,
* vornr TYPE vornr,
* rgekz TYPE rgekz,
* stlty TYPE stlty,
* stlnr TYPE stnum,
* stlkn TYPE stlkn,
* stpoz TYPE cim_count,
* END OF ty_reservations,
*
** Individual materials for production order.
* BEGIN OF ty_ordmats,
* aufnr TYPE aufnr, "Order number
* matnr TYPE matnr, "Component material
* vornr TYPE vornr, "Phase number
* rsnum TYPE rsnum, "Reservation number
* rspos TYPE rspos, "Reservation position
* rsart TYPE rsart,
* bdmng TYPE bdmng, "Component qty
* menge TYPE menge_d, "Issued qty
* stdqy TYPE bdmng, "component std qty
* zloss TYPE bdmng, "comp zero loss qty
* amein TYPE meins, "used uom
* meins TYPE meins, "std uom
* stprs TYPE stprs, "std price
* peinh TYPE peinh, "price uom
* END OF ty_ordmats,
*
** Type for BOM Item
* BEGIN OF ty_stpo,
* stlty TYPE stlty,
* stlnr TYPE stnum,
* stlkn TYPE stlkn,
* stpoz TYPE cim_count,
* meins TYPE kmpme,
* menge TYPE kmpmg,
* ausch TYPE kausf,
* yyzero TYPE /glb/rgtpt_yyzero,
* END OF ty_stpo,
** Type for Material Valuation
* BEGIN OF ty_mat_valuation,
* matnr TYPE matnr,
* bwkey TYPE bwkey,
* stprs TYPE stprs,
* peinh TYPE peinh,
* END OF ty_mat_valuation,
** Type for Order confirmations
* BEGIN OF ty_ord_conf,
* rueck TYPE co_rueck,
* rmzhl TYPE co_rmzhl,
* ism01 TYPE ru_ismng,
* ism02 TYPE ru_ismng,
* ism03 TYPE ru_ismng,
* ism04 TYPE ru_ismng,
* ism05 TYPE ru_ismng,
* ism06 TYPE ru_ismng,
* stokz TYPE co_stokz,
* END OF ty_ord_conf,
** Type for activities
*BEGIN OF ty_sum_activity,
* lar TYPE lstar,
* afru_ism TYPE ru_ismng,
* ism_should TYPE ru_ismng,
* ism_var TYPE ru_ismng,
* costd(8) TYPE p DECIMALS 2,
* coact(8) TYPE p DECIMALS 2,
* covar(8) TYPE p DECIMALS 2,
*END OF ty_sum_activity,
** Type for Summary Order Materials
* BEGIN OF ty_sum_ordmats,
* matnr TYPE matnr, " material number
* num(6) TYPE n, " count
* menge TYPE menge_d, " used qty
* stdqy TYPE menge_d, " std qty
* zloss TYPE menge_d, " zero loss qty
* amein TYPE meins, " used uom
* meins TYPE meins, " std uom
* stprs TYPE stprs, " std price
* peinh TYPE peinh, " price uom
* END OF ty_sum_ordmats,
*"END OF MOD-101
* Type for Materials
BEGIN OF TY_MATERIAL_NO,
MATNR TYPE MATNR,
BWART TYPE BWART,
END OF TY_MATERIAL_NO,
* Type for Materials Descriptions
BEGIN OF TY_MATERIAL_DES,
MATNR TYPE MATNR,
MAKTX TYPE MAKTX,
END OF TY_MATERIAL_DES,
* Type for Object Id and text
BEGIN OF TY_WC_TEXT,
OBJID TYPE CR_OBJID,
KTEXT TYPE CR_KTEXT,
END OF TY_WC_TEXT,
* Type for System Function Codes
BEGIN OF TY_FCODE,
FCODE TYPE SYUCOMM,
END OF TY_FCODE.
**START OF MOD-03.
*type definition for ty_mtart.
TYPES:BEGIN OF TY_MTART,
MATNR TYPE MATNR,
MTART TYPE MTART,
END OF TY_MTART.
**END OF MOD-03.
DATA: BEGIN OF STRUCT_ACTIVITY.
        INCLUDE STRUCTURE TTL_ACTIV.
DATA: END OF STRUCT_ACTIVITY.
*" BEGIN OF MOD-101+
DATA:
* Internal table for Work Center Header
I_CRHD TYPE STANDARD TABLE OF TY_CRHD,
WA_CRHD TYPE TY_CRHD,
* Internal table for Cost Center Master Data
I_CSKS TYPE STANDARD TABLE OF TY_CSKS,
WA_CSKS TYPE TY_CSKS,                                       "#EC NEEDED
* Internal table for Assignment of Work Center to Cost Center
I_CRCO TYPE STANDARD TABLE OF TY_CRCO,
WA_CRCO TYPE TY_CRCO,
* Internal table for status texts
I_TJ02T TYPE STANDARD TABLE OF TY_TJ02T,
WA_TJ02T TYPE TY_TJ02T,
* Internal table for View "Order Headers PP/CO"
I_ORDERS TYPE STANDARD TABLE OF TY_ORDERS,
WA_ORDERS TYPE TY_ORDERS,
* Internal table for Operation within an order
I_AFVC TYPE STANDARD TABLE OF TY_AFVC,
I_AFVC1 TYPE STANDARD TABLE OF TY_AFVC,
I_AFVC2 TYPE STANDARD TABLE OF TY_AFVC,
WA_AFVC TYPE TY_AFVC,
WA_AFVC1 TYPE TY_AFVC,
* Internal table for quantities/dates/values in the operations
I_AFVV TYPE STANDARD TABLE OF TY_AFVV,
I_AFVV1 TYPE STANDARD TABLE OF TY_AFVV,
WA_AFVV TYPE TY_AFVV,
WA_AFVV1 TYPE TY_AFVV,
* Internal table for Document Segment: Material
I_MSEG TYPE STANDARD TABLE OF TY_MSEG,
I_MSEG1 TYPE STANDARD TABLE OF TY_MSEG,
WA_MSEG TYPE TY_MSEG,
* Internal table for Document Segment: Material - Sum
I_MSEGS TYPE STANDARD TABLE OF TY_MSEG_SUM,
I_MSEGS1 TYPE STANDARD TABLE OF TY_MSEG_SUM,
WA_MSEGS TYPE TY_MSEG_SUM,
I_ISSUED_MAT TYPE STANDARD TABLE OF TY_MSEG,
WA_ISSUED_MAT TYPE TY_MSEG,
I_STBTMP TYPE STANDARD TABLE OF STPOX,
WA_STB TYPE STPOX,
I_CMAT TYPE STANDARD TABLE OF CSCMAT,
WA_TMAT TYPE CSTMAT,
I_BOMDAT TYPE TY_T_BOMDAT,
WA_BOMDAT TYPE TY_BOMDAT,
I_H_ORD TYPE STANDARD TABLE OF TY_HIER_ORDER,
WA_H_ORD TYPE TY_HIER_ORDER,
I_H_PHS TYPE STANDARD TABLE OF TY_HIER_PHASE,
WA_H_PHS TYPE TY_HIER_PHASE,
I_H_ACT TYPE STANDARD TABLE OF TY_HIER_ACT,
WA_H_ACT TYPE TY_HIER_ACT,
I_H_MAT TYPE STANDARD TABLE OF TY_HIER_MAT,
WA_H_MAT TYPE TY_HIER_MAT,
WA_ACTS TYPE TY_HIER_ACT_SUM,
WA_MATS TYPE TY_HIER_MAT_SUM,
I_AFRU TYPE STANDARD TABLE OF TY_AFRU,
I_AFRU1 TYPE STANDARD TABLE OF TY_AFRU,
WA_AFRU TYPE TY_AFRU,
WA_AFRU1 TYPE TY_AFRU,
* Internal table for Reservation/dependent requirements
I_RESB TYPE STANDARD TABLE OF TY_RESB,
WA_RESB TYPE TY_RESB,
I_MARC1 TYPE STANDARD TABLE OF TY_MARC1,
WA_MARC1 TYPE TY_MARC1,
I_MARA TYPE STANDARD TABLE OF TY_MARA,
WA_MARA TYPE TY_MARA,
I_PARAM TYPE STANDARD TABLE OF TY_PARAM,
WA_PARAM TYPE TY_PARAM,
I_PARAM_KEY TYPE STANDARD TABLE OF TY_PARAM_KEY,
WA_PARAM_KEY TYPE TY_PARAM_KEY,
I_MBEW1 TYPE STANDARD TABLE OF TY_MBEW1,
WA_MBEW1 TYPE TY_MBEW1,
I_ORDMATS TYPE STANDARD TABLE OF TY_ORDMATS,
WA_ORDMATS TYPE TY_ORDMATS,
I_PLPO TYPE STANDARD TABLE OF PLPO,
WA_PLPO TYPE PLPO,
I_PLPO1 TYPE STANDARD TABLE OF PLPO,
WA_PLPO1 TYPE PLPO,
I_PLPO2 TYPE STANDARD TABLE OF PLPO,
WA_PLPO2 TYPE PLPO,
I_ORD_CONF TYPE STANDARD TABLE OF TY_ORD_CONF,
WA_ORD_CONF TYPE TY_ORD_CONF,
I_ORD_CONF1 TYPE STANDARD TABLE OF TY_ORD_CONF,
WA_ORD_CONF1 TYPE TY_ORD_CONF,
* Internal table for Additional Information for Hierarchy Nodes
I_NODESTAB TYPE STANDARD TABLE OF SNODETEXT,
WA_NODESTAB TYPE SNODETEXT,
I_MATERIAL_DES TYPE STANDARD TABLE OF TY_MATERIAL_DES,
WA_MATERIAL_DES TYPE TY_MATERIAL_DES,
I_WC_TEXT TYPE STANDARD TABLE OF TY_WC_TEXT,
WA_WC_TEXT TYPE TY_WC_TEXT,
I_PLPO_SEL TYPE STANDARD TABLE OF TY_PLPO_SEL,
WA_PLPO_SEL TYPE TY_PLPO_SEL,
I_AFRU_SEL TYPE STANDARD TABLE OF TY_AFRU_SEL,
WA_AFRU_SEL TYPE TY_AFRU_SEL,
I_FCODE TYPE STANDARD TABLE OF TY_FCODE,
WA_FCODE TYPE TY_FCODE,
I_MTART TYPE STANDARD TABLE OF TY_MTART,
WA_MTART TYPE TY_MTART,
I_MATN TYPE STANDARD TABLE OF TY_MATERIAL_NO,
WA_MATN TYPE TY_MATERIAL_NO,
I_PARN TYPE STANDARD TABLE OF TY_PAR,
WA_PARN TYPE TY_PAR,
I_CKEY TYPE STANDARD TABLE OF TY_CKEY,
WA_CKEY TYPE TY_CKEY,
I_OBJ_STAT TYPE STANDARD TABLE OF TY_OBJ_STAT,
WA_OBJ_STAT TYPE TY_OBJ_STAT,
R_STEUS TYPE RANGE OF STEUS,
WA_STEUS LIKE LINE OF R_STEUS.
****** Include for Selection Screen
* include ZPROCESSORDTOPVARSEL.
*&---------------------------------------------------------------------*
*& Include ZPROCESSORDTOPVARSEL
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Include ZPROCESSORDTOPVARSEL
*&---------------------------------------------------------------------*
*------------------ Selection Screen --------------------------------
SELECTION-SCREEN BEGIN OF BLOCK SEL WITH FRAME
TITLE TEXT-001.
SELECT-OPTIONS: S_AUFNR FOR WA_AFKO-AUFNR MEMORY ID BR1,
"Process Order number
S_DATUV FOR SY-DATUM MEMORY ID DAT.
" Selection Date Range
SELECT-OPTIONS: S_ARBPL FOR WA_CRHD-ARBPL MATCHCODE OBJECT CRAM
MEMORY ID AGR, "Resource
S_FEVOR FOR WA_AFKO-FEVOR.
"Production Scheduler "MOD-101+
PARAMETERS: P_WERKS TYPE WERKS_D OBLIGATORY, "MEMORY ID wrk, " Plant
P_USAGE LIKE MAST-STLAN OBLIGATORY DEFAULT '1'. " BOM usage
SELECT-OPTIONS: S_STEUS FOR WA_PLPO-STEUS MEMORY ID AAT.
" Control Key
PARAMETERS:
*WORT TYPE C LENGTH 4 DEFAULT 'WORT'.
* p_machs TYPE lstar MEMORY ID lar," Activity Type "MOD-101-
* p_kokrs TYPE cssl-kokrs OBLIGATORY MEMORY ID cac,
P_KOKRS TYPE CSSL-KOKRS MEMORY ID CAC,
" Controlling Area - MOD IB like cssl-kokrs
P_MTART TYPE MARA-MTART MEMORY ID MTA.
" Material Type
SELECT-OPTIONS: S_MATNR FOR WA_MARA-MATNR MATCHCODE OBJECT MAT1
MEMORY ID MAT,
" Material
S_KOSTL FOR WA_CSSL-KOSTL MATCHCODE OBJECT KOST
MEMORY ID KOS.
" Cost center
*" START OF MOD-101
*s_stats FOR v_dummy MATCHCODE OBJECT /eur/rgbpte_ordstat. " Order
*Status
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT (28) TEXT-071.
SELECTION-SCREEN POSITION 33.
PARAMETERS: P_STATS1 TYPE CHAR4 MATCHCODE OBJECT /EUR/RGBPTE_ORDSTAT.
SELECTION-SCREEN POSITION 39.
PARAMETERS: P_S1_CHK AS CHECKBOX.
SELECTION-SCREEN COMMENT 41(5) TEXT-072.
SELECTION-SCREEN COMMENT 51(4) TEXT-073.
SELECTION-SCREEN POSITION 58.
PARAMETERS: P_STATS2 TYPE CHAR4 MATCHCODE OBJECT /EUR/RGBPTE_ORDSTAT.
SELECTION-SCREEN POSITION 64.
PARAMETERS: P_S2_CHK AS CHECKBOX.
SELECTION-SCREEN COMMENT 66(5) TEXT-072.
SELECTION-SCREEN END OF LINE.
*" END OF MOD-101
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN COMMENT 32(40) TEXT-020.
SELECTION-SCREEN END OF BLOCK SEL.
SELECTION-SCREEN BEGIN OF BLOCK TYP WITH FRAME TITLE TEXT-021.
*detail, summary or phase
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: RB_DETL RADIOBUTTON GROUP RAD1.
SELECTION-SCREEN COMMENT (20) TEXT-003 FOR FIELD RB_DETL.
SELECTION-SCREEN POSITION 30.
PARAMETERS: RB_SUMM RADIOBUTTON GROUP RAD1.
SELECTION-SCREEN COMMENT (20) TEXT-004 FOR FIELD RB_SUMM.
SELECTION-SCREEN POSITION 60.
PARAMETERS: RB_PHASE RADIOBUTTON GROUP RAD1.
SELECTION-SCREEN COMMENT (20) TEXT-005 FOR FIELD RB_PHASE.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK TYP.
SELECTION-SCREEN BEGIN OF BLOCK OUT WITH FRAME TITLE TEXT-002.
*fiscal or quantity
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: RB_FISCL RADIOBUTTON GROUP RAD2.
SELECTION-SCREEN COMMENT (20) TEXT-006 FOR FIELD RB_FISCL.
SELECTION-SCREEN POSITION 30.
PARAMETERS: RB_QUANT RADIOBUTTON GROUP RAD2.
SELECTION-SCREEN COMMENT (20) TEXT-007 FOR FIELD RB_QUANT.
SELECTION-SCREEN END OF LINE.
*actual or planned production
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: RB_ACTL RADIOBUTTON GROUP RAD3.
SELECTION-SCREEN COMMENT (20) TEXT-008 FOR FIELD RB_ACTL.
SELECTION-SCREEN POSITION 30.
PARAMETERS: RB_PLAND RADIOBUTTON GROUP RAD3.
SELECTION-SCREEN COMMENT (20) TEXT-009 FOR FIELD RB_PLAND.
SELECTION-SCREEN END OF LINE.
*produced or confirmed quantity
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: RB_PROD RADIOBUTTON GROUP RAD4.
SELECTION-SCREEN COMMENT (20) TEXT-010 FOR FIELD RB_PROD.
SELECTION-SCREEN POSITION 30.
PARAMETERS: RB_CONF RADIOBUTTON GROUP RAD4.
SELECTION-SCREEN COMMENT (20) TEXT-011 FOR FIELD RB_CONF.
SELECTION-SCREEN END OF LINE.
*all components or non b/flushed only
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: RB_BFLSH RADIOBUTTON GROUP RAD5.
SELECTION-SCREEN COMMENT (20) TEXT-013 FOR FIELD RB_BFLSH.
SELECTION-SCREEN POSITION 30.
PARAMETERS: RB_NFLSH RADIOBUTTON GROUP RAD5.
SELECTION-SCREEN COMMENT (20) TEXT-012 FOR FIELD RB_NFLSH.
SELECTION-SCREEN END OF LINE.
*include/exclude zero production
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: RB_EZERO RADIOBUTTON GROUP RAD6.
SELECTION-SCREEN COMMENT (20) TEXT-014 FOR FIELD RB_EZERO.
SELECTION-SCREEN POSITION 30.
PARAMETERS: RB_IZERO RADIOBUTTON GROUP RAD6.
SELECTION-SCREEN COMMENT (20) TEXT-015 FOR FIELD RB_IZERO.
SELECTION-SCREEN END OF LINE.
*standard planned or zero loss planned
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: RB_STDPL RADIOBUTTON GROUP RAD7.
SELECTION-SCREEN COMMENT (20) TEXT-016 FOR FIELD RB_STDPL.
SELECTION-SCREEN POSITION 30.
PARAMETERS: RB_ZLOSS RADIOBUTTON GROUP RAD7.
SELECTION-SCREEN COMMENT (20) TEXT-017 FOR FIELD RB_ZLOSS.
SELECTION-SCREEN END OF LINE.
*order uom or kgm
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: RB_ORDER RADIOBUTTON GROUP RAD8.
SELECTION-SCREEN COMMENT (20) TEXT-018 FOR FIELD RB_ORDER.
SELECTION-SCREEN POSITION 30.
PARAMETERS: RB_KGM RADIOBUTTON GROUP RAD8.
SELECTION-SCREEN COMMENT (20) TEXT-019 FOR FIELD RB_KGM.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK OUT.
*** Initialization Event
INITIALIZATION.
  PERFORM FILL_MOVEMENT_TYPES.
*******BEGIN OF MOD-003.
**"Validate BOM usage
*AT SELECTION-SCREEN ON p_usage.
* PERFORM validate_stlan.
*"Validate control key
*at selection-screen on s_steus.
*perform validate_steus.
*"validate machine hours indicator.
*at selection-screen on p_machs.
*perform validate_lstar.
******END OF MOD-003.
*"BEGIN OF MOD-101
AT SELECTION-SCREEN ON S_STEUS.
*"Validate control key
  PERFORM VALIDATE_STEUS.
*"END OF MOD-101.
*** At Selection Screen Event
AT SELECTION-SCREEN.
* Checking the plant and get currency
  PERFORM GET_CURRENCY.
* Checking Materials, material type.
  PERFORM CHECK_MATERIALS .
*** Start of Selection Event
START-OF-SELECTION.
  SET PF-STATUS 'MAIN'.
* Setup Control Key selection range
  CLEAR : S_STEUS, S_STEUS[].
  S_STEUS-SIGN = 'I'.
  S_STEUS-OPTION = 'EQ'.
  LOOP AT I_CKEY INTO WA_CKEY.
    S_STEUS-LOW = WA_CKEY-STEUS.
    APPEND S_STEUS.
  ENDLOOP.
*"END OF MOD-101
* Retrieve Order status
* PERFORM get_status . "MOD-101-
* Retrieve work center
* PERFORM get_work_center. "MOD-101-
* Retrieve Cost center
  PERFORM GET_COST_CENTER.
* Retrieve Order Headers PP/CO
  PERFORM GET_ORDERS.
* Orders are exists according to the selection
* then retrieve Operations, Material segment and bom details
  IF NOT I_ORDERS[] IS INITIAL.
    PERFORM GET_OPERATIONS.
    PERFORM GET_MAT_SEGMENT.
    PERFORM GET_BOM_INFO.
  ELSE.
    MESSAGE S007.
  ENDIF.
*** End of Selection Event
END-OF-SELECTION.
* Displaying output only for +ve records
  IF NOT I_ORDERS IS INITIAL.
* Displaying output by selection ( Detail, Summary or Phase report )
    PERFORM BUILD_OUTPUT_TABS.
    PERFORM OUTPUT.
    PERFORM LIST_DISPLAY.
  ELSE.
    MESSAGE S007.
    LEAVE LIST-PROCESSING.
  ENDIF.
****** Include for Forms
* include ZPROCESSORDVARF01.
*&---------------------------------------------------------------------*
*& Include ZPROCESSORDVARF01
*&---------------------------------------------------------------------*
**&---------------------------------------------------------------------
*
** Report: : ZPROCESSORD
** AUTHOR : Aveek Ghose
*
** SUPPLIER : *
**======================================================================
*
** CHANGE HISTORY LOG
*
**----------------------------------------------------------------------
*
** MOD. NO.| DATE | NAME | CORRECTION NUMBER | CHANGE REFERENCE
**----------------------------------------------------------------------
*
** MOD-001 |DD/MM/YYYY| XXXXXX | XXXXXXXXXX | XXXXXXXXX
*
** DESCRIPTION:
*
**----------------------------------------------------------------------
*
** MOD-002 |DD/MM/YYYY| XXXXXX | XXXXXXXXXX | XXXXXXXXX
*
** DESCRIPTION:
*
**----------------------------------------------------------------------
*
**&---------------------------------------------------------------------
*
**& Include ZPROCESSORDVARF01
**&---------------------------------------------------------------------
*
*
*FORM fill_movement_types .
*
* REFRESH i_r_bwart.
*
** wa_bwart-sign = c_sign.
** wa_bwart-option = c_option.
** wa_bwart-low = '101'.
** APPEND wa_bwart TO i_r_bwart.
** CLEAR wa_bwart.
**
** wa_bwart-sign = c_sign.
** wa_bwart-option = c_option.
** wa_bwart-low = '102'.
** APPEND wa_bwart TO i_r_bwart.
** CLEAR wa_bwart.
*
* wa_bwart-sign = c_sign.
* wa_bwart-option = c_option.
* wa_bwart-low = c_movm_low_261.
* APPEND wa_bwart TO i_r_bwart.
* CLEAR wa_bwart.
*
* wa_bwart-sign = c_sign.
* wa_bwart-option = c_option.
* wa_bwart-low = c_movm_low_262.
* APPEND wa_bwart TO i_r_bwart.
* CLEAR wa_bwart.
*
* wa_bwart-sign = c_sign.
* wa_bwart-option = c_option.
* wa_bwart-low = c_movm_low_531.
* APPEND wa_bwart TO i_r_bwart.
* CLEAR wa_bwart.
*
* wa_bwart-sign = c_sign.
* wa_bwart-option = c_option.
* wa_bwart-low = c_movm_low_532.
* APPEND wa_bwart TO i_r_bwart.
* CLEAR wa_bwart.
*ENDFORM. " fill_movement_types
*
**&---------------------------------------------------------------------
*
**& Form get_currency
**&---------------------------------------------------------------------
*
** text
**----------------------------------------------------------------------
*
*FORM get_currency.
*
*****Begin of MOD-001
* DATA : l_bukrs TYPE bukrs,
* l_waers TYPE waers.
*
* CLEAR : v_waers.
*
* IF NOT p_werks IS INITIAL.
* SELECT SINGLE werks FROM t001w INTO v_werks
* WHERE werks = p_werks.
* IF sy-subrc <> 0.
* MESSAGE e001 WITH p_werks. " Invalid Plant
* ENDIF.
* ENDIF.
**
**Retrieve the company code
* SELECT SINGLE bukrs
* FROM t001k
* INTO l_bukrs
* WHERE bwkey = p_werks.
*
* IF sy-subrc = 0.
*
**Get the currence at company
* SELECT SINGLE waers
* FROM t001
* INTO v_waers
* WHERE bukrs = l_bukrs.
*
* ENDIF.
*
** SELECT SINGLE waers
** FROM tka01 INTO l_waers
** WHERE kokrs = p_kokrs.
**
** IF sy-subrc <> 0.
** MESSAGE e046. " Invalid Controlling area entered.
**
** ELSEIF v_waers IS INITIAL.
***If the currency is not maintained at companmy level
** v_waers = l_waers.
** ENDIF.
******************MOD-004******************************
* AUTHORITY-CHECK OBJECT 'C_AFKO_AWK'
* ID 'WERKS' FIELD p_werks
* ID 'AUFART' DUMMY.
* IF sy-subrc <> 0.
* MESSAGE e000 WITH
* 'You do not have authorisation to display report'(070).
* ENDIF.
****************MOD-004************************************
*
** IF NOT p_werks IS INITIAL.
** SELECT SINGLE werks FROM t001w INTO v_werks
** WHERE werks = p_werks.
** IF sy-subrc <> 0.
** MESSAGE e001 WITH p_werks. " Invalid Plant
** ENDIF.
** ENDIF.
***********End of MOD-001.
*ENDFORM. " get_currency
*
**&---------------------------------------------------------------------
*
**& Form check_materials
**&---------------------------------------------------------------------
*
** text - Checking material number and material type values
**----------------------------------------------------------------------
*
*FORM check_materials.
* DATA : l_matnr TYPE matnr, "#EC NEEDED
* l_mtart TYPE mtart. "#EC NEEDED
*
** Checking material(s) valid or not
* IF NOT ( s_matnr[] IS INITIAL ).
** Checking at leaset one material is valid for select-options material.
* SELECT SINGLE matnr
* FROM mara
* INTO l_matnr
* WHERE matnr IN s_matnr. "#EC *
* IF sy-subrc <> 0.
* MESSAGE e000 WITH 'Material(s) not found for this selection'(062)
  .
* ENDIF.
* ENDIF.
*
** Checking material type valid or not
* IF NOT ( p_mtart IS INITIAL ).
* SELECT SINGLE mtart
* FROM t134 INTO l_mtart "MOD IB mara-mtart
* WHERE mtart = p_mtart.
* IF sy-subrc <> 0.
* MESSAGE e000 WITH 'Incorrect Material Type'(063).
* ENDIF.
* ENDIF.
*
** Checking material number and type valid or not.
* IF NOT ( s_matnr[] IS INITIAL ) AND
* NOT ( p_mtart IS INITIAL ).
** Checking at leaset one material is valid for select-options material
** and for material type
*
* CLEAR l_matnr.
* SELECT SINGLE matnr
* FROM mara
* INTO l_matnr
* WHERE matnr IN s_matnr AND
* mtart = p_mtart. "#EC *
* IF sy-subrc <> 0.
* MESSAGE e000
* WITH 'Incorrect material number & type combination'(064).
* ENDIF.
* ENDIF.
*ENDFORM. " check_materials
*
**&---------------------------------------------------------------------
*
**& Form get_status
**&---------------------------------------------------------------------
*
** text -- Retreving System status texts from table TJ02T
**----------------------------------------------------------------------
*
*FORM get_status USING fp_txt04 TYPE j_txt04
* CHANGING fp_stat TYPE j_istat.
*** >>>> MOD-101+
* CLEAR : fp_stat.
* SELECT SINGLE istat
* FROM tj02t
* INTO fp_stat
* WHERE txt04 = fp_txt04
* AND spras = sy-langu. "#EC CI_SGLSELECT
**** if select fails stat is returned empty, so no check required.
*
*** <<<< MOD-101+
** REFRESH i_tj02t.
** CLEAR wa_tj02t.
** IF NOT ( s_stats[] IS INITIAL ).
** SELECT txt04
** FROM tj02t INTO TABLE i_tj02t
** WHERE txt04 IN s_stats
** AND spras = sy-langu. "#EC CI_SGLSELECT
*** IF sy-subrc = 0.
**** The check is not required here since the
**** system status text is not mandatory
*** ENDIF.
** ENDIF.
**
** IF rb_ezero = c_x.
** IF rb_prod = c_x.
** wa_tj02t-txt04 = c_txt_dlv.
** ENDIF.
**
** IF rb_conf = c_x.
** wa_tj02t-txt04 = c_txt_cnf.
** ENDIF.
** APPEND wa_tj02t TO i_tj02t.
** CLEAR wa_tj02t.
** ENDIF.
** SORT i_tj02t BY txt04 AS TEXT. " MOD IB (SORT i_tj02t)
** DELETE ADJACENT DUPLICATES FROM i_tj02t.
*ENDFORM. " get_status
*
**&---------------------------------------------------------------------
*
**& Form get_status_info
**&---------------------------------------------------------------------
*
** text
**----------------------------------------------------------------------
*
*FORM get_status_info USING fp_l_orders_objnr TYPE j_objnr
* fp_l_sttxt TYPE any.
*
* DATA: l_text(4) TYPE c,
* l_stsma TYPE j_stsma,
*
** START MOD IB
* i_status TYPE STANDARD TABLE OF jstat INITIAL SIZE 0,
* wa_status TYPE jstat.
** END MOD IB
* REFRESH i_status.
*
** Get all active statuses for the order
* CALL FUNCTION 'STATUS_READ'
* EXPORTING
* objnr = fp_l_orders_objnr
* only_active = c_x
* IMPORTING
* stsma = l_stsma
* TABLES
* status = i_status.
*
* CLEAR: fp_l_sttxt.
*
* LOOP AT i_status INTO wa_status.
** Get the text for each status
* CALL FUNCTION 'STATUS_NUMBER_CONVERSION'
* EXPORTING
* language = sy-langu
* status_number = wa_status-stat
* stsma = l_stsma
* IMPORTING
* txt04 = l_text.
** Add status text found to current list
* CONCATENATE fp_l_sttxt l_text INTO fp_l_sttxt.
* CLEAR : wa_status.
* ENDLOOP.
*ENDFORM. " get_status_info
*
**&---------------------------------------------------------------------
*
**& Form get_work_center
**&---------------------------------------------------------------------
*
** text
**----------------------------------------------------------------------
*
*FORM get_work_center.
* CLEAR: wa_crhd.
* REFRESH: i_crhd.
*
* SELECT objid
* arbpl
* FROM crhd INTO TABLE i_crhd
* WHERE objty = c_objtyp
* AND werks = p_werks
* AND arbpl IN s_arbpl.
** IF sy-subrc = 0.
*** sy-subrc check is not required, there must be atleast one record for
*** this selection.
** ENDIF.
*ENDFORM. " get_work_center
*
**&---------------------------------------------------------------------
*
**& Form get_cost_center
**&---------------------------------------------------------------------
*
** text
**----------------------------------------------------------------------
*
*FORM get_cost_center.
* IF NOT ( s_kostl[] IS INITIAL ).
* CLEAR : i_csks.
* SELECT kokrs kostl
* FROM csks
* INTO TABLE i_csks
* WHERE kokrs = p_kokrs
* AND kostl IN s_kostl.
* IF sy-subrc = 0.
* SORT i_csks BY kokrs kostl.
* ENDIF.
* ENDIF.
*ENDFORM. " get_cost_center
*
*****
***** BEGIN OF MOD-101
*****
**&---------------------------------------------------------------------
*
**& Form get_orders
**&---------------------------------------------------------------------
*
** text
**----------------------------------------------------------------------
*
*FORM get_orders.
*
* DATA: l_sttxt(100) TYPE c,
* flg_status(1) TYPE c.
* FIELD-SYMBOLS : <fs_orders> TYPE ty_orders.
*
* MOVE 'Extracting Process Orders'(022) TO v_output_text.
* PERFORM inform_user_of_progress.
*
* IF NOT p_mtart IS INITIAL.
**"selection filter on material type
* SELECT matnr "material number
* mtart "material type
* INTO TABLE i_mtart
* FROM mara
* WHERE matnr IN s_matnr
* AND mtart = p_mtart.
* IF sy-subrc = c_0.
** refill S_MATNR with I_MTART values
* REFRESH : s_matnr.
*
* s_matnr-sign = c_sign.
* s_matnr-option = c_option.
* LOOP AT i_mtart INTO wa_mtart.
* s_matnr-low = wa_mtart-matnr.
* APPEND s_matnr.
* ENDLOOP.
*
* ELSE.
** No data was selected for material type
* MESSAGE i072 WITH p_mtart.
* LEAVE LIST-PROCESSING.
* ENDIF.
* ENDIF.
*
* SELECT aufnr
*
* werks
* kokrs
* objnr
*
* gltrp
* gstrp
*
* rsnum
*
* gamng
* gmein
* plnbez
*
* plnty
* plnnr
* plnal
*
* stlst
* stlty
* stlnr
* sdatv
* stlal
* stlan
*
* aufpl
* zaehl
* rueck
*
* auart
*
* aufld "31-05-2005
*
* INTO TABLE i_orders FROM caufv
* WHERE aufnr IN s_aufnr
* AND werks = p_werks
** AND kokrs = p_kokrs
* AND fevor IN s_fevor
* AND plnbez IN s_matnr
** AND stlan = p_usage
* AND ( gstrp IN s_datuv OR
* gltrp IN s_datuv ).
* IF sy-subrc <> 0.
* MESSAGE s007.
* LEAVE LIST-PROCESSING.
* ENDIF.
*
* SORT i_orders BY aufnr.
*
** Take status txt from sel screen and get status number
* IF NOT p_stats1 IS INITIAL.
* PERFORM get_status USING p_stats1 CHANGING v_stat1.
* ENDIF.
*
* IF NOT p_stats2 IS INITIAL.
* PERFORM get_status USING p_stats2 CHANGING v_stat2.
* ENDIF.
*
** get object numbers and statuses for orders
* CLEAR : i_obj_stat.
* SELECT objnr
* stat
* FROM jest
* INTO TABLE i_obj_stat
* FOR ALL ENTRIES IN i_orders
* WHERE objnr = i_orders-objnr
* AND stat IN (v_stat1,v_stat2).
*
** cull orders
* LOOP AT i_orders ASSIGNING <fs_orders>.
* IF NOT v_stat1 IS INITIAL.
* READ TABLE i_obj_stat INTO wa_obj_stat
* WITH KEY objnr = <fs_orders>-objnr
* stat = v_stat1.
* IF sy-subrc = 0 AND p_s1_chk EQ c_x.
* <fs_orders>-del = c_x.
* ELSEIF sy-subrc NE 0 AND p_s1_chk NE c_x.
* <fs_orders>-del = c_x.
* ENDIF.
* ENDIF.
*
* IF NOT v_stat2 IS INITIAL.
* READ TABLE i_obj_stat INTO wa_obj_stat
* WITH KEY objnr = <fs_orders>-objnr
* stat = v_stat2.
* IF sy-subrc = 0 AND p_s2_chk EQ c_x.
* <fs_orders>-del = c_x.
* ELSEIF sy-subrc NE 0 AND p_s2_chk NE c_x.
* <fs_orders>-del = c_x.
* ENDIF.
* ENDIF.
* ENDLOOP.
*
*MOD-004**********************************
* DELETE i_orders WHERE del = c_x.
*MOD-004**********************************
** LOOP AT i_orders INTO wa_orders.
** IF NOT i_tj02t[] IS INITIAL .
** PERFORM get_status_info USING wa_orders-objnr l_sttxt.
**
** CLEAR: flg_status, wa_tj02t.
** LOOP AT i_tj02t INTO wa_tj02t.
** IF l_sttxt NS wa_tj02t-txt04.
** CLEAR flg_status.
** EXIT.
** ELSE.
** flg_status = c_x.
** CONTINUE.
** ENDIF.
** CLEAR : wa_tj02t.
** ENDLOOP.
**
** IF flg_status <> c_x.
** DELETE i_orders.
** CONTINUE.
** ENDIF.
** ENDIF.
** ENDLOOP.
*ENDFORM. " get_orders
*
**&---------------------------------------------------------------------
*
**& Form get_operations
**&---------------------------------------------------------------------
*
** text
**----------------------------------------------------------------------
*
*FORM get_operations.
*
* DATA l_tabix TYPE sytabix.
*
** Let the user know whats up
* MOVE 'Extracting Phase Information'(023) TO v_output_text.
* PERFORM inform_user_of_progress.
*
** select process order item lines
* SELECT aufpl
* aplzl
*
* ltxa1
*
* plnkn
* plnty
* plnnr
* zaehl
*
* vornr
* steus
* arbid
* rueck
*
* phflg
* sumnr
* vgwts
*
* lar01
* lar02
* lar03
* lar04
* lar05
* lar06
* INTO TABLE i_afvc
* FROM afvc
* FOR ALL ENTRIES IN i_orders
* WHERE aufpl = i_orders-aufpl
* AND steus IN s_steus
* AND phflg = c_x.
*
* IF sy-subrc = 0.
** select process order item values
* SELECT aufpl
* aplzl
*
* meinh
* bmsch
*
* umren
* umrez
*
* vge01
* vgw01
* vge02
* vgw02
* vge03
* vgw03
* vge04
* vgw04
* vge05
* vgw05
* vge06
* vgw06
*
* mgvrg
* lmnga
* gmnga
*
* ism01
* ism02
* ism03
* ism04
* ism05
* ism06
*
* ssavd
* FROM afvv INTO TABLE i_afvv
* FOR ALL ENTRIES IN i_afvc
* WHERE aufpl = i_afvc-aufpl
* AND aplzl = i_afvc-aplzl
* AND ssavd IN s_datuv.
* IF sy-subrc = 0.
* SORT i_afvv BY aufpl aplzl.
* ENDIF.
*
** select process order related work centre data
* SELECT objty
* objid
* kokrs
* kostl
* lstar
* FROM crco
* INTO TABLE i_crco
* FOR ALL ENTRIES IN i_afvc
* WHERE objty = c_objtyp
* AND objid = i_afvc-arbid
* AND kostl IN s_kostl.
* IF sy-subrc = 0.
* SORT i_crco BY objty objid kostl.
* ENDIF.
*
** Retrieve work center details
* SELECT objid
* arbpl
* vgwts
* FROM crhd
* APPENDING TABLE i_crhd
* FOR ALL ENTRIES IN i_afvc
* WHERE objty = c_objtyp
* AND objid = i_afvc-arbid
* AND werks = p_werks
* AND arbpl IN s_arbpl.
*
* SORT i_crhd BY objid.
* SORT i_orders BY aufpl.
* SORT i_afvc BY aufpl vornr DESCENDING.
*
* LOOP AT i_afvc INTO wa_afvc.
* l_tabix = sy-tabix.
*
**** link PrO number to phase through the routing number
* CLEAR : wa_orders.
* READ TABLE i_orders INTO wa_orders WITH KEY aufpl = wa_afvc-aufpl
  .
* IF sy-subrc = 0.
* wa_afvc-aufnr = wa_orders-aufnr.
* MODIFY i_afvc FROM wa_afvc INDEX l_tabix TRANSPORTING aufnr.
*
**** check cost centre of phase
* IF NOT ( s_kostl[] IS INITIAL ).
* READ TABLE i_crco INTO wa_crco WITH KEY objty = c_objtyp
* objid = wa_afvc-arbid
* BINARY SEARCH.
* IF sy-subrc = 0.
**** see if cost centre of phase is valid
* READ TABLE i_csks INTO wa_csks
* WITH KEY kostl = wa_crco-kostl.
* IF sy-subrc <> 0.
**** delete invalid phases
* DELETE i_afvv WHERE aufpl = wa_afvc-aufpl
* AND aplzl = wa_afvc-aplzl.
* DELETE i_afvc INDEX l_tabix.
* CONTINUE.
* ENDIF.
* ENDIF.
* ENDIF.
*
**** Check work centre details with resource
* IF NOT ( s_arbpl[] IS INITIAL ).
* READ TABLE i_crhd INTO wa_crhd
* WITH KEY objid = wa_afvc-arbid.
* IF sy-subrc <> 0.
* DELETE i_afvv WHERE aufpl = wa_afvc-aufpl
* AND aplzl = wa_afvc-aplzl.
* DELETE i_afvc INDEX l_tabix.
* CONTINUE.
* ENDIF.
*
* ENDIF.
* CLEAR: wa_crco, wa_crhd, l_tabix.
*
* ELSE.
**** if routing number is not linked to any valid order
**** delete phase
* DELETE i_afvc INDEX l_tabix.
* ENDIF.
* ENDLOOP.
* ENDIF.
*
** Begin of MOD-002++
* LOOP AT i_orders INTO wa_orders.
* CLEAR: wa_afvc, l_tabix.
* l_tabix = sy-tabix.
* READ TABLE i_afvc INTO wa_afvc WITH KEY aufpl = wa_orders-aufpl.
*MOD-004********************************
** IF sy-subrc NE 0.
** DELETE i_orders INDEX l_tabix.
** ENDIF.
**MOD-004*******************************
* ENDLOOP.
** End of MOD-002++
*
*ENDFORM. " get_operations
*
**&--------------------------------------------------------------------*
**& Form get_order_mats
**&--------------------------------------------------------------------*
** text
**---------------------------------------------------------------------*
*FORM get_order_mats.
*
* DATA : l_v_erfme TYPE erfme,
* l_v_chec TYPE char1,
* l_bwart TYPE bwart.
*
** get materials issued/receipt against order
* SELECT aufnr aufpl aplzl matnr mblnr mjahr zeile bwart
* werks lgort charg
* menge meins erfmg erfme
* rsnum rspos rsart
* FROM aufm
* INTO TABLE i_mseg1
* FOR ALL ENTRIES IN i_orders
* WHERE aufnr = i_orders-aufnr.
* IF sy-subrc = 0.
*
**** get base UoM for all materials
* CLEAR: i_mara.
* SELECT matnr
* mtart
* meins
* gewei
* ntgew
* FROM mara
* APPENDING TABLE i_mara
* FOR ALL ENTRIES IN i_mseg1
* WHERE matnr = i_mseg1-matnr.
*
* SORT i_mseg1 BY aufnr aufpl aplzl matnr.
**** get material qty in base UoM and summarize material data
* LOOP AT i_mseg1 INTO wa_mseg.
* CLEAR : wa_mara.
**** read material master for base UoM
* READ TABLE i_mara INTO wa_mara WITH KEY matnr = wa_mseg-matnr.
* IF sy-subrc = 0.
* IF wa_mseg-meins <> wa_mara-meins.
* CLEAR : wa_mseg-bmenge.
**** convert GR quant into base units
* PERFORM conv_to_from_base USING 'X'
* wa_mseg-matnr
* wa_mseg-menge
* wa_mseg-meins
* wa_mara-meins
* CHANGING wa_mseg-bmenge
* v_conv_rc.
* ELSE.
* wa_mseg-bmenge = wa_mseg-menge.
* ENDIF.
*
* wa_mseg-bmeins = wa_mara-meins.
* wa_mseg-gewei = wa_mara-gewei.
* wa_mseg-ntgew = wa_mara-ntgew.
* MODIFY i_mseg1 FROM wa_mseg TRANSPORTING bmenge bmeins.
* ENDIF.
*
* wa_msegs-aufnr = wa_mseg-aufnr.
* wa_msegs-aufpl = wa_mseg-aufpl.
* wa_msegs-aplzl = wa_mseg-aplzl.
* wa_msegs-matnr = wa_mseg-matnr.
* wa_msegs-meins = wa_mseg-meins.
* wa_msegs-bmeins = wa_mseg-bmeins.
* wa_msegs-gewei = wa_mseg-gewei.
** Begin of MOD-002++
* IF ( wa_mseg-bwart <> 'ZU1' ) AND ( wa_mseg-bwart <> 'ZU2' ).
* wa_msegs-erfme = wa_mseg-erfme.
* ENDIF.
** End of MOD-002++
*
* AT NEW matnr.
* l_v_erfme = wa_msegs-erfme.
* CLEAR : l_v_chec.
* ENDAT.
*
* IF l_v_erfme <> wa_mseg-erfme.
**** set flag if different GR mvts have diff. GR UoM
* l_v_chec = c_x.
* ENDIF.
*
**** Sum up material qtys based on movement
* CASE wa_mseg-bwart.
* WHEN '101'.
**** GR of material
* wa_msegs-bmenge1 = wa_msegs-bmenge1 + wa_mseg-bmenge.
* wa_msegs-erfmg1 = wa_msegs-erfmg1 + wa_mseg-erfmg.
* wa_msegs-erfme = wa_mseg-erfme.
* l_bwart = '101'. "23-05-2005
*
* WHEN '261'.
**** Consumption of material
* wa_msegs-bmenge2 = wa_msegs-bmenge2 + wa_mseg-bmenge.
* wa_msegs-erfmg2 = wa_msegs-erfmg2 + wa_mseg-erfmg.
* l_bwart = '261'. "23-05-2005
*
*
* WHEN '532'.
**** reversal of 531
* wa_msegs-bmenge5 = wa_msegs-bmenge5 + wa_mseg-bmenge.
* wa_msegs-erfmg5 = wa_msegs-erfmg5 + wa_mseg-erfmg.
*
* WHEN '102'.
**** reversal of 101
* wa_msegs-bmenge1 = wa_msegs-bmenge1 - wa_mseg-bmenge.
* wa_msegs-erfmg1 = wa_msegs-erfmg1 + wa_mseg-erfmg.
*
* WHEN '262'.
**** reversal of 261
* wa_msegs-bmenge2 = wa_msegs-bmenge2 - wa_mseg-bmenge.
* wa_msegs-erfmg2 = wa_msegs-erfmg2 + wa_mseg-erfmg.
*
* WHEN '531'.
**** By-product material mvt
* wa_msegs-bmenge5 = wa_msegs-bmenge5 - wa_mseg-bmenge.
* wa_msegs-erfmg5 = wa_msegs-erfmg5 + wa_mseg-erfmg.
* l_bwart = '531'. "23-05-2005
*
* ENDCASE.
*
**** If the diff. GR qtys have different UoM then do not cumulate
**** actual qty values
* IF l_v_chec = c_x.
* CLEAR : wa_msegs-erfmg1, wa_msegs-erfmg2 , wa_msegs-erfmg5.
* ENDIF.
*
* AT END OF matnr.
* wa_msegs-bmenge = wa_msegs-bmenge1 + wa_msegs-bmenge2 +
* wa_msegs-bmenge5.
* wa_msegs-erfmg = wa_msegs-erfmg1 + wa_msegs-erfmg2 +
* wa_msegs-erfmg5.
* wa_msegs-bwart = l_bwart .
*
* APPEND wa_msegs TO i_msegs.
* CLEAR : wa_msegs,
* l_bwart.
* ENDAT.
* ENDLOOP.
* ENDIF.
*ENDFORM. "get_order_mats
*
**&---------------------------------------------------------------------
*
**& Form get_mat_segment
**&---------------------------------------------------------------------
*
*FORM get_mat_segment.
* DATA: l_tabix TYPE sytabix.
*
* FIELD-SYMBOLS : <l_fs_orders> TYPE ty_orders,
* <l_fs_afvc> TYPE ty_afvc.
*
* IF NOT ( i_orders[] IS INITIAL ).
**** get material master data for PO materials
* CLEAR: i_mara , i_mseg , i_mseg1 , i_msegs , i_msegs1.
* SELECT matnr
* mtart
* meins
* gewei
* ntgew
* FROM mara
* INTO TABLE i_mara
* FOR ALL ENTRIES IN i_orders
* WHERE matnr = i_orders-plnbez.
*
* IF NOT ( rb_prod IS INITIAL ).
**** Tell user we are Extracting goods receipt information
* MOVE 'Extracting Goods Receipt Information'(024) TO v_output_text
  .
* PERFORM inform_user_of_progress.
*
**** get the materials to process
* PERFORM get_order_mats.
*
**** create alternate working tables for mat. mvts
* i_mseg = i_mseg1.
* i_msegs1 = i_msegs.
*
**** retain only order material in internal table and get order qty in
**** base UoM
* LOOP AT i_orders ASSIGNING <l_fs_orders>.
*
**** retain mat. mvts only for the main material of the PrO
* DELETE i_mseg WHERE aufnr = <l_fs_orders>-aufnr
* AND matnr <> <l_fs_orders>-plnbez.
*
* DELETE i_msegs1 WHERE aufnr = <l_fs_orders>-aufnr
* AND matnr <> <l_fs_orders>-plnbez.
*
**** read material master for base UoM of material
* CLEAR : wa_mara.
* READ TABLE i_mara INTO wa_mara
* WITH KEY matnr = <l_fs_orders>-plnbez.
* IF sy-subrc = 0.
* IF wa_mara-meins <> <l_fs_orders>-gmein.
**** convert order quantity to base UoM
* PERFORM conv_to_from_base USING 'X'
* <l_fs_orders>-plnbez
* <l_fs_orders>-gamng
* <l_fs_orders>-gmein
* wa_mara-meins
* CHANGING <l_fs_orders>-bgamng
* v_conv_rc.
* ELSE.
* <l_fs_orders>-bgamng = wa_orders-gamng.
* ENDIF.
*
* <l_fs_orders>-bsuom = wa_mara-meins.
* <l_fs_orders>-gewei = wa_mara-gewei.
* <l_fs_orders>-ntgew = wa_mara-ntgew.
* ENDIF.
* ENDLOOP.
*
* SORT i_mseg BY aufnr.
* SORT i_msegs1 BY aufnr.
* SORT i_orders BY aufnr.
*
**** Calculatin the quantity according to the movement type and
**** assign the value to i_orders internal table
* LOOP AT i_orders ASSIGNING <l_fs_orders>.
* CLEAR : wa_msegs.
* READ TABLE i_msegs1 INTO wa_msegs
* WITH KEY aufnr = <l_fs_orders>-aufnr
* matnr = <l_fs_orders>-plnbez.
* IF rb_ezero EQ c_x AND wa_msegs-bmenge1 = 0.
**** Don't want zero production orders
* DELETE i_afvc WHERE aufnr = <l_fs_orders>-aufnr.
*MOD-004****************************************************
** DELETE i_orders WHERE aufnr = <l_fs_orders>-aufnr.
*MOD-004****************************************************
* CONTINUE.
* ENDIF.
*
* <l_fs_orders>-erfmg = wa_msegs-erfmg1.
* <l_fs_orders>-bmenge = wa_msegs-bmenge1.
* <l_fs_orders>-gruom = wa_msegs-erfme.
* ENDLOOP.
*
* ELSE.
**** Here we're Extracting confirmation information
* MOVE 'Extracting Confirmation Information'(025) TO v_output_text.
* PERFORM inform_user_of_progress.
*
**** get order qty in base UoM and get base UoM and weight UoM
* LOOP AT i_orders ASSIGNING <l_fs_orders>.
*
* CLEAR : wa_mara.
* READ TABLE i_mara INTO wa_mara
* WITH KEY matnr = <l_fs_orders>-plnbez.
*
* IF sy-subrc = 0.
* IF wa_mara-meins <> wa_orders-gmein.
**** convert order quantity to base UoM
* PERFORM conv_to_from_base USING 'X'
* <l_fs_orders>-plnbez
* <l_fs_orders>-gamng
* <l_fs_orders>-gmein
* wa_mara-meins
* CHANGING <l_fs_orders>-bgamng
* v_conv_rc.
* ELSE.
* <l_fs_orders>-bgamng = <l_fs_orders>-gamng.
* ENDIF.
*
* <l_fs_orders>-bsuom = wa_mara-meins.
* <l_fs_orders>-gewei = wa_mara-gewei.
* <l_fs_orders>-ntgew = wa_mara-ntgew.
* ENDIF.
* ENDLOOP.
*
**** Select confirmations using operation confirmation number instead of
**** order number
* CLEAR : i_afvv1 , i_afvc1 , i_afru , i_afru1.
**** get 'bottleneck' phases
* LOOP AT i_afvc INTO wa_afvc WHERE steus = 'YBN1'
* AND phflg = c_x.
* APPEND wa_afvc TO i_afvc1.
**** get 'bottleneck' phase values
* LOOP AT i_afvv INTO wa_afvv WHERE aufpl = wa_afvc-aufpl
* AND aplzl = wa_afvc-aplzl.
* APPEND wa_afvv TO i_afvv1.
* ENDLOOP.
* ENDLOOP.
*
* IF NOT i_afvc1 IS INITIAL.
* SORT i_afvc1 BY aufpl aplzl plnkn plnty plnnr.
**** get confirmations for the various phases
* SELECT aufnr
* rueck
* gmnga
* lmnga
* gmein
* meinh
* meilr
* stokz
* rueck_mst
* aufpl
* aplzl
* INTO TABLE i_afru
* FROM afru
* FOR ALL ENTRIES IN i_afvc
* WHERE rueck = i_afvc-rueck
* AND werks = p_werks
* AND aufpl = i_afvc-aufpl
* AND aplzl = i_afvc-aplzl.
*
* SORT i_afru BY aufnr rueck aufpl aplzl.
*
* LOOP AT i_afvc1 INTO wa_afvc.
* LOOP AT i_afru INTO wa_afru
* WHERE aufnr = wa_afvc-aufnr
* AND rueck = wa_afvc-rueck
* AND aufpl = wa_afvc-aufpl
* AND aplzl = wa_afvc-aplzl.
**** get 'bottleneck' related confirmations
* APPEND wa_afru TO i_afru1.
* ENDLOOP.
* ENDLOOP.
*
* IF NOT i_afvv1 IS INITIAL.
* SORT i_afvv1 BY aufpl aplzl.
*
**** get total confirmation on order for 'bottleneck' phases,
**** this will be the confirmed qty for whole order
* LOOP AT i_afvc ASSIGNING <l_fs_afvc>.
*
* wa_afvc = <l_fs_afvc>.
**** ensuring the phase is related to a valid PrO
* CLEAR : wa_orders.
* READ TABLE i_orders INTO wa_orders
* WITH KEY aufnr = wa_afvc-aufnr.
* IF sy-subrc = 0.
**** is it a bottleneck phase?
* READ TABLE i_afvc1 INTO wa_afvc1
* WITH KEY aufpl = wa_orders-aufpl
* plnty = wa_afvc-plnty
* plnnr = wa_afvc-plnnr
* plnkn = wa_afvc-plnkn
* zaehl = wa_afvc-zaehl.
* IF sy-subrc = 0.
**** get phase operation values
* READ TABLE i_afvv1 INTO wa_afvv1
* WITH KEY aufpl = wa_afvc1-aufpl
* aplzl = wa_afvc1-aplzl
* BINARY SEARCH.
* IF sy-subrc = 0.
**** does the phase have any std runtime m/c confirmations
* CHECK wa_afvv1-vgw02 NE 0.
*
**** get actual bottleneck phase confirmations
* PERFORM get_confirmation_qty_new
* USING wa_orders-aufnr
* wa_afvc1-rueck
* wa_afvc1-aufpl
* wa_afvc1-aplzl
* CHANGING
* wa_afvc-lmnga
* wa_afvc-cfuom.
**** save confirmation values against phase
* <l_fs_afvc>-lmnga = wa_afvc-lmnga.
* <l_fs_afvc>-cfuom = wa_afvc-cfuom.
* ENDIF.
* ENDIF.
* ENDIF.
* ENDLOOP.
* ENDIF.
* ENDIF.
*
**** retain only bottleneck related confirmation phases,
**** as this gives confirmation qty for order
* i_afvc2 = i_afvc.
* IF rb_ezero = c_x.
**** no zero confirmation qty phases wanted
* DELETE i_afvc2 WHERE lmnga EQ 0.
* ENDIF.
* DELETE ADJACENT DUPLICATES FROM i_afvc2
* COMPARING aufnr
* aufpl
* aplzl
* plnkn
* plnty
* plnnr
* zaehl
* vornr.
*
**** get order qty in base UoM and get base UoM and weight UoM
* LOOP AT i_orders ASSIGNING <l_fs_orders>.
*
**** get confirmed qty
* READ TABLE i_afvc2 INTO wa_afvc
* WITH KEY aufnr = <l_fs_orders>-aufnr.
* IF sy-subrc = 0.
* <l_fs_orders>-lmnga = wa_afvc-lmnga.
* <l_fs_orders>-cfuom = wa_afvc-cfuom.
*
* IF <l_fs_orders>-cfuom <> <l_fs_orders>-bsuom.
**** convert confirmation quantity to base UoM
* PERFORM conv_to_from_base USING 'X'
* <l_fs_orders>-plnbez
* <l_fs_orders>-lmnga
* <l_fs_orders>-cfuom
* <l_fs_orders>-bsuom
* CHANGING <l_fs_orders>-blmnga
* v_conv_rc.
* ELSE.
* <l_fs_orders>-blmnga = <l_fs_orders>-lmnga.
* ENDIF.
*
* ELSE.
**** if the order has no confirmed qty against it, remove it
**** from further processing
* <l_fs_orders>-del = c_x.
* ENDIF.
* ENDLOOP.
*MOD-004*********************************
* DELETE i_orders WHERE del = c_x.
*MOD-004*********************************
* ENDIF.
* ENDIF.
*ENDFORM. " get_mat_segment
*
**&---------------------------------------------------------------------
*
**& Form get_confirmation_qty_new
**&---------------------------------------------------------------------
*
*FORM get_confirmation_qty_new USING fp_aufnr TYPE aufnr
* fp_rueck TYPE co_rueck
* fp_aufpl TYPE co_aufpl
* fp_aplzl TYPE co_aplzl
* CHANGING fp_lmnga TYPE ru_lmnga
* fp_cfuom TYPE meins.
*
* DATA: last_lmnga TYPE ru_lmnga,
* last_lmnga1 TYPE ru_lmnga,
* last_lmnga2 TYPE ru_lmnga,
*
* l_v_meinh TYPE ru_vorme.
*
* CLEAR: last_lmnga.
*
** Check this record. If there is no link to another confirmation and
** a quantity has been confirmed and it is a milestone confirmation
** then we want to select all of the confirmations for it.
* LOOP AT i_afru1 INTO wa_afru1 WHERE aufnr = fp_aufnr
* AND rueck = fp_rueck
* AND aufpl = fp_aufpl
* AND aplzl = fp_aplzl.
* CHECK wa_afru1-lmnga NE 0.
*
* IF l_v_meinh IS INITIAL.
* l_v_meinh = wa_afru1-meinh.
* ENDIF.
*
* last_lmnga1 = wa_afru1-lmnga.
*
* IF l_v_meinh <> wa_afru1-meinh.
* CLEAR : last_lmnga2.
* PERFORM conv_to_from_base USING 'X'
* wa_orders-plnbez
* wa_afru1-lmnga
* wa_afru1-meinh
* wa_orders-bsuom
* CHANGING last_lmnga2
* v_conv_rc.
*
* PERFORM conv_to_from_base USING ' '
* wa_orders-plnbez
* last_lmnga2
* l_v_meinh
* wa_orders-bsuom
* CHANGING last_lmnga1
* v_conv_rc.
*
* ENDIF.
*
* IF wa_afru1-stokz IS INITIAL.
* last_lmnga = last_lmnga + last_lmnga1.
* ELSE.
* last_lmnga = last_lmnga - last_lmnga1.
* ENDIF.
* ENDLOOP.
*
* MOVE last_lmnga TO fp_lmnga.
* fp_cfuom = l_v_meinh.
*
*ENDFORM. " get_confirmation_qty_new
*
**&---------------------------------------------------------------------
*
**& Form get_bom_info
**&---------------------------------------------------------------------
*
*FORM get_bom_info.
* DATA: l_tabix TYPE sytabix,
*
* l_v_kausf TYPE kausf,
*
* l_v_dmeng TYPE ty_menge,
* l_v_dmengs TYPE ty_menge,
* l_v_dmengz TYPE ty_menge,
*
* l_v_menge TYPE kmpmg,
*
* l_v_mnglg TYPE cs_e_mnglg,
* l_v_mnglgs TYPE cs_e_mnglg,
* l_v_mnglgz TYPE cs_e_mnglg,
*
* l_i_bomapp TYPE STANDARD TABLE OF ty_bomapp,
* l_wa_bomapp TYPE ty_bomapp,
*
* l_idx TYPE ttidx. "NEEL 4/6/2005
*
* FIELD-SYMBOLS : <l_fs_orders> TYPE ty_orders,
* <l_fs_ordmats> TYPE ty_ordmats.
*
* IF NOT i_orders[] IS INITIAL.
** this tells users whats happening
* MOVE 'Extracting BOM Information'(026) TO v_output_text.
* PERFORM inform_user_of_progress.
*
** Get order related bom appln
* CLEAR : l_i_bomapp.
*
* SELECT werks
* auart
* capid
* FROM t399x
* INTO TABLE l_i_bomapp
* FOR ALL ENTRIES IN i_orders
* WHERE werks = i_orders-werks
* AND auart = i_orders-auart.
*
* SORT l_i_bomapp BY werks auart.
*
** Get issued materials for all process orders
* IF i_mseg1 IS INITIAL.
** get materials to process
* PERFORM get_order_mats.
*
* i_mseg = i_mseg1.
* i_msegs1 = i_msegs.
* ENDIF.
*
* LOOP AT i_orders ASSIGNING <l_fs_orders>.
* DELETE i_mseg WHERE aufnr = <l_fs_orders>-aufnr
* AND matnr <> <l_fs_orders>-plnbez.
*
* DELETE i_msegs1 WHERE aufnr = <l_fs_orders>-aufnr
* AND matnr <> <l_fs_orders>-plnbez.
*
*
* CLEAR : l_wa_bomapp.
**** Assign a default in case read fails
* l_wa_bomapp-capid = 'PI01'.
* READ TABLE l_i_bomapp INTO l_wa_bomapp
* WITH KEY werks = <l_fs_orders>-werks
* auart = <l_fs_orders>-auart
* BINARY SEARCH.
**** Get BOM application id
* <l_fs_orders>-capid = l_wa_bomapp-capid.
*
**** Get list of materials that have been issued
* LOOP AT i_mseg1 INTO wa_issued_mat
* WHERE aufnr = <l_fs_orders>-aufnr
* AND bwart IN i_r_bwart.
* APPEND wa_issued_mat TO i_issued_mat.
* ENDLOOP.
* ENDLOOP.
*
* CLEAR : i_bomdat.
** do BOM explosion and get related BOM data for the materials
* LOOP AT i_orders ASSIGNING <l_fs_orders>.
**** build key table for later selection from table PLPO,
**** the master recipe table
* wa_plpo_sel-plnty = <l_fs_orders>-plnty.
* wa_plpo_sel-plnnr = <l_fs_orders>-plnnr.
* wa_plpo_sel-zaehl = <l_fs_orders>-zaehl.
* APPEND wa_plpo_sel TO i_plpo_sel.
*
**** build key table for later selection from table AFRU,
**** the confirmations table
* wa_afru_sel-rueck = <l_fs_orders>-rueck.
* APPEND wa_afru_sel TO i_afru_sel.
*
* l_tabix = sy-tabix.
*
* CLEAR : wa_tmat , i_stbtmp , wa_bomdat.
**** check if same BOM has been retrieved before
* READ TABLE i_bomdat INTO wa_bomdat
* WITH KEY capid = <l_fs_orders>-capid
* datuv = <l_fs_orders>-sdatv
* mtnrv = <l_fs_orders>-plnbez
* stlal = <l_fs_orders>-stlal
* stlan = <l_fs_orders>-stlan
* werks = <l_fs_orders>-werks.
* IF sy-subrc = 0.
**** if yes then use it
* wa_tmat = wa_bomdat-tmat.
* i_stbtmp = wa_bomdat-stb.
*
* ELSE.
**** if no then get BOM explosion
* CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'
* EXPORTING
* aumgb = 'X'
* capid = <l_fs_orders>-capid
** datuv = <l_fs_orders>-sdatv
**** Begin of change on 31-05-2005
* datuv = <l_fs_orders>-aufld
* " 31-05-2005
**** End of change on 31-05-2005
* mbwls = 'X'
* mehrs = 'X'
* mtnrv = <l_fs_orders>-plnbez
* stlal = <l_fs_orders>-stlal
* stlan = <l_fs_orders>-stlan
* werks = <l_fs_orders>-werks
* IMPORTING
* topmat = wa_tmat
* TABLES
* stb = i_stbtmp
** matcat = i_cmat
* EXCEPTIONS
* alt_not_found = 1
* call_invalid = 2
* material_not_found = 3
* missing_authorization = 4
* no_bom_found = 5
* no_plant_data = 6
* no_suitable_bom_found = 7
* conversion_error = 8
* OTHERS = 9.
* IF sy-subrc = 0.
**** add to BOM buffer table
* wa_bomdat-capid = <l_fs_orders>-capid.
* wa_bomdat-datuv = <l_fs_orders>-sdatv.
* wa_bomdat-mtnrv = <l_fs_orders>-plnbez.
* wa_bomdat-stlal = <l_fs_orders>-stlal.
* wa_bomdat-stlan = <l_fs_orders>-stlan.
* wa_bomdat-werks = <l_fs_orders>-werks.
* wa_bomdat-tmat = wa_tmat.
* wa_bomdat-stb = i_stbtmp.
*
* INSERT wa_bomdat INTO TABLE i_bomdat.
*
* DELETE i_stbtmp WHERE schgt = c_x.
* ENDIF.
* ENDIF.
*
*
* IF NOT i_stbtmp IS INITIAL.
**** First get the primary level values from the exploded BOM
* LOOP AT i_stbtmp INTO wa_stb WHERE stlal = <l_fs_orders>-stlal
* AND stlan = <l_fs_orders>-stlan
* AND stlty = <l_fs_orders>-stlty
* AND stlnr = <l_fs_orders>-stlnr.
*
* CHECK wa_stb-postp <> 'N'.
*
* CLEAR : wa_ordmats.
* wa_ordmats-aufnr = <l_fs_orders>-aufnr.
* wa_ordmats-matnr = wa_stb-idnrk.
* wa_ordmats-mtart = wa_stb-mtart.
* wa_ordmats-stufe = wa_stb-stufe.
**>>NEEL 4/6/2005
* wa_ordmats-wegxx = wa_stb-wegxx.
* wa_ordmats-ttidx = wa_stb-ttidx.
* wa_ordmats-vwegx = wa_stb-vwegx.
**<<NEEL 4/6/2005
* wa_ordmats-ojtxb = wa_stb-ojtxb.
* wa_ordmats-ojtxp = wa_stb-ojtxp.
*
* wa_ordmats-ausch = wa_stb-ausch.
** wa_ordmats-yyzero = wa_stb-yyzero.
*
* IF NOT wa_stb-ausch IS INITIAL.
* l_v_kausf = 1 + ( wa_stb-ausch / 100 ).
* ELSE.
* l_v_kausf = 1 + ( wa_stb-kausf / 100 ).
* ENDIF.
*
* wa_ordmats-kausf = l_v_kausf.
*
* wa_ordmats-menge = wa_stb-menge.
* wa_ordmats-menges = wa_stb-menge * wa_ordmats-kausf.
** wa_ordmats-mengez = wa_stb-menge * wa_ordmats-yyzero.
* wa_ordmats-meins = wa_stb-meins.
*
* wa_ordmats-xmeng = wa_stb-xmeng.
* wa_ordmats-xmengs = wa_stb-xmeng * wa_ordmats-kausf.
** wa_ordmats-xmengz = wa_stb-xmeng * wa_ordmats-yyzero.
*
* wa_ordmats-xmein = wa_stb-xmein.
*
* wa_ordmats-mnglg = wa_stb-mnglg.
* wa_ordmats-mnglgs = wa_stb-mnglg.
* wa_ordmats-mnglgz = wa_stb-mnglg.
* wa_ordmats-mmein = wa_stb-mmein.
* wa_ordmats-msign = wa_stb-msign.
* wa_ordmats-postp = wa_stb-postp.
*
* IF wa_stb-kzkup = space AND wa_stb-msign = '-'.
* wa_ordmats-byprod = c_x.
* ENDIF.
*
* wa_ordmats-stprs = wa_stb-stprs.
* wa_ordmats-peinh = wa_stb-preih.
*
* wa_ordmats-bom = c_x.
*
* wa_ordmats-stlty = wa_stb-stlty.
* wa_ordmats-stlnr = wa_stb-stlnr.
* wa_ordmats-stlkn = wa_stb-stlkn.
* wa_ordmats-stpoz = wa_stb-stpoz.
*
* APPEND wa_ordmats TO i_ordmats.
* ENDLOOP.
*
**** now recurse into exploded BOM to get lower level details
* LOOP AT i_ordmats ASSIGNING <l_fs_ordmats> WHERE bomd <> c_x.
*
* IF <l_fs_ordmats>-xmeng > 0.
* l_v_dmeng = <l_fs_ordmats>-menge / <l_fs_ordmats>-xmeng.
* l_v_dmengs = <l_fs_ordmats>-menges / <l_fs_ordmats>-xmeng.
* l_v_dmengz = <l_fs_ordmats>-mengez / <l_fs_ordmats>-xmeng.
*
* ELSE.
* l_v_dmeng = 1.
* l_v_dmengs = 1.
* l_v_dmengz = 1.
* ENDIF.
*
*
* l_idx = <l_fs_ordmats>-stufe + 1. "NEEL 4/6/2005++
* LOOP AT i_stbtmp INTO wa_stb
** WHERE ojtxb = <l_fs_ordmats>ojtxp. NEEL-
* WHERE ttidx = l_idx "NEEL 4/6/2005
* AND vwegx = <l_fs_ordmats>-wegxx.
* CLEAR : wa_ordmats.
* wa_ordmats-aufnr = <l_fs_orders>-aufnr.
* wa_ordmats-matnr = wa_stb-idnrk.
* wa_ordmats-mtart = wa_stb-mtart.
* wa_ordmats-stufe = wa_stb-stufe.
**>>NEEL 4/6/2005
* wa_ordmats-wegxx = wa_stb-wegxx.
* wa_ordmats-ttidx = wa_stb-ttidx.
* wa_ordmats-vwegx = wa_stb-vwegx.
**<<NEEL 4/6/2005
* wa_ordmats-ojtxb = wa_stb-ojtxb.
* wa_ordmats-ojtxp = wa_stb-ojtxp.
*
* wa_ordmats-ausch = wa_stb-ausch.
** wa_ordmats-yyzero = wa_stb-yyzero.
*
* IF NOT wa_stb-ausch IS INITIAL.
* l_v_kausf = 1 + ( wa_stb-ausch / 100 ).
* ELSE.
* l_v_kausf = 1 + ( wa_stb-kausf / 100 ).
* ENDIF.
* wa_ordmats-kausf = l_v_kausf.
*
* l_v_menge = wa_stb-menge * l_v_dmengs.
* wa_ordmats-menges = l_v_menge * wa_ordmats-kausf.
*
* l_v_menge = wa_stb-menge * l_v_dmengz.
** wa_ordmats-mengez = l_v_menge * wa_ordmats-yyzero.
*
* l_v_menge = wa_stb-menge * l_v_dmeng.
* wa_ordmats-menge = l_v_menge.
*
* wa_ordmats-meins = wa_stb-meins.
*
* l_v_mnglg = wa_ordmats-menge.
* l_v_mnglgs = wa_ordmats-menges.
* l_v_mnglgz = wa_ordmats-mengez.
*
* IF wa_stb-meins = wa_stb-mmein.
* wa_ordmats-mnglg = l_v_mnglg.
* wa_ordmats-mnglgs = l_v_mnglgs.
* wa_ordmats-mnglgz = l_v_mnglgz.
*
* ELSE.
** convert BOM quantity to base UoM
* PERFORM conv_to_from_base USING 'X'
* wa_ordmats-matnr
* l_v_mnglg
* wa_ordmats-meins
* wa_ordmats-mmein
* CHANGING wa_ordmats-mnglg
* v_conv_rc.
*
* PERFORM conv_to_from_base USING 'X'
* wa_ordmats-matnr
* l_v_mnglgs
* wa_ordmats-meins
* wa_ordmats-mmein
* CHANGING wa_ordmats-mnglgs
* v_conv_rc.
*
* PERFORM conv_to_from_base USING 'X'
* wa_ordmats-matnr
* l_v_mnglgz
* wa_ordmats-meins
* wa_ordmats-mmein
* CHANGING wa_ordmats-mnglgz
* v_conv_rc.
* ENDIF.
* wa_ordmats-mmein = wa_stb-mmein.
* wa_ordmats-msign = wa_stb-msign.
*
* wa_ordmats-xmeng = wa_stb-xmeng.
* wa_ordmats-xmengs = wa_stb-xmeng * wa_ordmats-kausf.
** wa_ordmats-xmengz = wa_stb-xmeng * wa_ordmats-yyzero.
*
* wa_ordmats-xmein = wa_stb-xmein.
*
* wa_ordmats-stprs = wa_stb-stprs.
* wa_ordmats-peinh = wa_stb-preih.
** wa_ordmats-yyzero = wa_stb-yyzero.
* wa_ordmats-bom = c_x.
*
* wa_ordmats-stlty = wa_stb-stlty.
* wa_ordmats-stlnr = wa_stb-stlnr.
* wa_ordmats-stlkn = wa_stb-stlkn.
* wa_ordmats-stpoz = wa_stb-stpoz.
*
* APPEND wa_ordmats TO i_ordmats.
* ENDLOOP.
*
* <l_fs_ordmats>-bomd = c_x.
* ENDLOOP.
*
* <l_fs_orders>-maktx = wa_tmat-maktx.
* <l_fs_orders>-bmeng = wa_tmat-bmeng.
* <l_fs_orders>-bmein = wa_tmat-bmein.
* <l_fs_orders>-kausf = wa_tmat-kausf.
*
* IF <l_fs_orders>-bmein <> <l_fs_orders>-bsuom.
** convert BOM base quantity to base UoM
* PERFORM conv_to_from_base USING 'X'
* <l_fs_orders>-plnbez
* <l_fs_orders>-bmeng
* <l_fs_orders>-bmein
* <l_fs_orders>-bsuom
* CHANGING <l_fs_orders>-bbmeng
* v_conv_rc.
* ELSE.
* <l_fs_orders>-bbmeng = <l_fs_orders>-bmeng.
* ENDIF.
* ENDIF.
* ENDLOOP.
*
* SORT i_ordmats BY aufnr matnr.
*
** Selecting reservations for order
* SELECT rsnum rspos rsart xloek matnr werks bdmng meins shkzg
* aufnr dumps aufpl vornr aplzl
* postp kzkup rgekz ausch
* stlty stlnr stlkn stpoz bwart
* FROM resb INTO TABLE i_resb
* FOR ALL ENTRIES IN i_orders
* WHERE rsnum = i_orders-rsnum
** AND xloek = ' '
* AND aufnr = i_orders-aufnr
* AND bdmng > 0
* AND dumps = space
* AND postp <> 'N'
* AND schgt = space.
*
* LOOP AT i_resb INTO wa_resb.
* READ TABLE i_issued_mat INTO wa_issued_mat
* WITH KEY matnr = wa_resb-matnr.
* CHECK sy-subrc <> 0.
**** If a material was issued but is not part of the PrO
**** reservations, add it to list
* CLEAR : wa_issued_mat.
* wa_issued_mat-matnr = wa_resb-matnr.
* wa_issued_mat-werks = wa_resb-werks.
* APPEND wa_issued_mat TO i_issued_mat.
* ENDLOOP.
*
** we just need the issued mat numbers not captured by BOM explosion
* SORT i_issued_mat BY matnr.
* DELETE ADJACENT DUPLICATES FROM i_issued_mat COMPARING matnr.
*
* IF NOT i_issued_mat IS INITIAL.
** get material master data
* SELECT matnr
* mtart
* meins
* gewei
* FROM mara
* APPENDING TABLE i_mara
* FOR ALL ENTRIES IN i_issued_mat
* WHERE matnr = i_issued_mat-matnr.
*
** getting pricing data
* CLEAR : i_mbew1 , i_material_des.
* SELECT matnr bwkey stprs peinh
* FROM mbew
* INTO TABLE i_mbew1
* FOR ALL ENTRIES IN i_issued_mat
* WHERE matnr = i_issued_mat-matnr
* AND bwkey = i_issued_mat-werks.
*
** Selecting material descriptions
* SELECT matnr maktx
* FROM makt
* INTO TABLE i_material_des
* FOR ALL ENTRIES IN i_issued_mat
* WHERE spras = sy-langu
* AND matnr = i_issued_mat-matnr.
* ENDIF.
*
** prepare selection table for selecting from AFRU
* LOOP AT i_afvc INTO wa_afvc.
* wa_plpo_sel-plnty = wa_afvc-plnty.
* wa_plpo_sel-plnnr = wa_afvc-plnnr.
* wa_plpo_sel-plnkn = wa_afvc-plnkn.
* wa_plpo_sel-zaehl = wa_afvc-zaehl.
* APPEND wa_plpo_sel TO i_plpo_sel.
*
* wa_afru_sel-rueck = wa_afvc-rueck.
* APPEND wa_afru_sel TO i_afru_sel.
* ENDLOOP.
*
* SORT : i_plpo_sel , i_afru_sel.
*
* DELETE ADJACENT DUPLICATES FROM i_plpo_sel.
* DELETE ADJACENT DUPLICATES FROM i_afru_sel.
*
** Retrieve task list information of operations/activity from PLPO table
* SELECT *
* FROM plpo
* INTO TABLE i_plpo
* FOR ALL ENTRIES IN i_plpo_sel
* WHERE plnty = i_plpo_sel-plnty
* AND plnnr = i_plpo_sel-plnnr
* AND zaehl = i_plpo_sel-zaehl.
* IF sy-subrc = 0.
* SORT i_plpo BY plnty plnnr plnkn datuv DESCENDING.
* ENDIF.
** get confirmation data for order and its items
* SELECT rueck
* rmzhl
* ism01
* ile01
* ism02
* ile02
* ism03
* ile03
* ism04
* ile04
* ism05
* ile05
* ism06
* ile06
* stokz
* FROM afru
* INTO TABLE i_ord_conf
* FOR ALL ENTRIES IN i_afru_sel
* WHERE rueck = i_afru_sel-rueck.
* ENDIF.
*
* IF NOT i_afvc IS INITIAL.
* LOOP AT i_afvc INTO wa_afvc.
**** get master recipe records for selected phases
* LOOP AT i_plpo INTO wa_plpo WHERE plnty = wa_afvc-plnty
* AND plnnr = wa_afvc-plnnr
* AND plnkn = wa_afvc-plnkn
* AND zaehl = wa_afvc-zaehl.
* APPEND wa_plpo TO i_plpo1.
* ENDLOOP.
*
**** get confirmation records for selected phases
* LOOP AT i_ord_conf INTO wa_ord_conf WHERE rueck = wa_afvc-rueck.
* APPEND wa_ord_conf TO i_ord_conf1.
* ENDLOOP.
* ENDLOOP.
*
* SORT i_plpo1 BY plnty plnnr plnkn zaehl datuv DESCENDING.
* ENDIF.
*
* UNASSIGN : <l_fs_orders>.
*ENDFORM. " get_bom_info
*
**&--------------------------------------------------------------------*
**& Form build_output_tabs
**&--------------------------------------------------------------------*
** text
**---------------------------------------------------------------------*
*FORM build_output_tabs.
* DATA : l_qty TYPE gamng,
* l_effic TYPE vgwrt,
* l_tmp TYPE vgwrt,
* l_tmp1 TYPE vgwrt,
*
* l_lmnga TYPE lmnga,
*
* l_v_rc TYPE char1,
* l_v_kausf TYPE kausf,
* l_v_sumi TYPE char1,
*
* l_v_smeng TYPE ty_menge,
* l_v_smengs TYPE ty_menge,
* l_v_smengz TYPE ty_menge,
*
* l_wa_afvv TYPE ty_afvv.
*
* FIELD-SYMBOLS : <l_fs_resb> TYPE ty_resb.
*
* MOVE 'Formatting Output'(027) TO v_output_text.
* PERFORM inform_user_of_progress.
*
* CLEAR: i_marc1.
* SELECT matnr
* werks
* frtme
* FROM marc
* INTO TABLE i_marc1
* FOR ALL ENTRIES IN i_orders
* WHERE matnr = i_orders-plnbez
* AND werks = i_orders-werks.
** Not required to handle, ok if prod unit not found
*
** get parameter IDs
* SELECT vgwts
* par01
* par02
* par03
* par04
* par05
* par06
* FROM tc21
* INTO TABLE i_param
* FOR ALL ENTRIES IN i_afvc
* WHERE vgwts = i_afvc-vgwts.
*
* IF sy-subrc = 0.
** get parameter ID texts
* SELECT parid
* txtlg
* FROM tc20t
* INTO TABLE i_param_key
* FOR ALL ENTRIES IN i_param
* WHERE spras = sy-langu
* AND ( parid = i_param-par01
* OR parid = i_param-par02
* OR parid = i_param-par03
* OR parid = i_param-par04
* OR parid = i_param-par05
* OR parid = i_param-par06 ).
* ENDIF.
*
** Selecting Work centers descriptions
* SELECT objid ktext
* FROM crtx
* INTO TABLE i_wc_text
* FOR ALL ENTRIES IN i_afvc
* WHERE objty = c_objtyp
* AND objid = i_afvc-arbid
* AND spras = sy-langu.
**Work centers descriptions are optional
*
* SELECT matnr bwkey stprs peinh
* FROM mbew
* APPENDING TABLE i_mbew1
* FOR ALL ENTRIES IN i_orders
* WHERE matnr = i_orders-plnbez
* AND bwkey = i_orders-werks.
*
* LOOP AT i_orders INTO wa_orders.
****
**** Build Order Table
****
* wa_h_ord-aufnr = wa_orders-aufnr.
*
* wa_h_ord-gltrp = wa_orders-gltrp.
* wa_h_ord-gstrp = wa_orders-gstrp.
*
* wa_h_ord-plnbez = wa_orders-plnbez.
* wa_h_ord-maktx = wa_orders-maktx.
*
* wa_h_ord-lmnga = wa_orders-lmnga.
* wa_h_ord-blmnga = wa_orders-blmnga.
* wa_h_ord-bmenge = wa_orders-bmenge.
* wa_h_ord-bgamng = wa_orders-bgamng.
* wa_h_ord-bbmeng = wa_orders-bbmeng.
*
* wa_h_ord-gruom = wa_orders-gruom.
* wa_h_ord-cfuom = wa_orders-cfuom.
* wa_h_ord-bsuom = wa_orders-bsuom.
*
* CLEAR : wa_marc1.
* READ TABLE i_marc1 INTO wa_marc1 WITH KEY matnr = wa_orders-plnbez
* werks = wa_orders-werks.
* wa_h_ord-frtme = wa_marc1-frtme.
* wa_h_ord-gewei = wa_orders-gewei.
* wa_h_ord-ntgew = wa_orders-ntgew.
*
* IF rb_pland = c_x.
** Planned Production Quantities
* wa_h_ord-prduom = wa_h_ord-frtme.
* wa_h_ord-prdqty = wa_h_ord-bgamng.
* ELSE.
** Actual Production Quantities
* IF rb_prod = c_x.
**** Produced Qty
* wa_h_ord-prdqty = wa_h_ord-bmenge.
* wa_h_ord-prduom = wa_h_ord-gruom.
* ELSE.
**** Confirmed Qty
* wa_h_ord-prdqty = wa_h_ord-blmnga.
* wa_h_ord-prduom = wa_h_ord-cfuom.
* ENDIF.
* ENDIF.
*
* wa_h_ord-bprdqty = wa_h_ord-prdqty.
*
* IF wa_h_ord-prduom <> wa_h_ord-bsuom.
* l_qty = wa_h_ord-prdqty.
* PERFORM conv_to_from_base USING ' '
* wa_h_ord-plnbez
* l_qty
* wa_h_ord-prduom
* wa_h_ord-bsuom
* CHANGING wa_h_ord-prdqty
* v_conv_rc.
* IF v_conv_rc = 'X'.
* wa_h_ord-prdqty = l_qty.
* wa_h_ord-prduom = wa_h_ord-bsuom.
* ENDIF.
* ENDIF.
*
** Resource Information
* CLEAR : wa_afvc , wa_crhd , wa_wc_text.
* READ TABLE i_afvc INTO wa_afvc WITH KEY aufpl = wa_orders-aufpl
* steus = 'YBN1'.
* IF sy-subrc = 0.
* READ TABLE i_crhd INTO wa_crhd WITH KEY objid = wa_afvc-arbid.
* READ TABLE i_wc_text INTO wa_wc_text WITH KEY objid =
* wa_afvc-arbid.
* ENDIF.
*
* wa_h_ord-botlnck = wa_crhd-arbpl.
* wa_h_ord-resdesc = wa_wc_text-ktext.
*
** Expected Line Efficiency
* CLEAR : i_plpo2 , l_effic.
* LOOP AT i_plpo1 INTO wa_plpo WHERE plnty = wa_orders-plnty
* AND plnnr = wa_orders-plnnr
* AND steus = 'YBN1'.
* IF NOT wa_plpo-vgw02 IS INITIAL.
* l_effic = wa_plpo-usr04.
*
* wa_plpo2 = wa_plpo.
* APPEND wa_plpo2 TO i_plpo2.
* ENDIF.
* ENDLOOP.
*
* wa_h_ord-el_effc = l_effic.
*
** Actual Line Efficiency
* CLEAR : l_tmp , l_tmp1 , l_effic.
* LOOP AT i_plpo2 INTO wa_plpo2.
* CLEAR: wa_afvc, wa_afvv , l_effic.
* READ TABLE i_afvc INTO wa_afvc WITH KEY plnty = wa_plpo2-plnty
* plnnr = wa_plpo2-plnnr
* plnkn = wa_plpo2-plnkn
* zaehl = wa_plpo2-zaehl
* aufpl = wa_orders-aufpl.
* IF sy-subrc = 0.
* READ TABLE i_afvv INTO wa_afvv WITH KEY aufpl = wa_afvc-aufpl
* aplzl = wa_afvc-aplzl.
* IF wa_plpo2-vgw02 <> 0.
* l_tmp = wa_plpo2-bmsch / wa_plpo2-vgw02.
*
* IF l_tmp <> 0.
* l_tmp1 = wa_afvv-lmnga / l_tmp.
*
* IF wa_afvv-ism02 <> 0.
* l_tmp1 = ( l_tmp1 / wa_afvv-ism02 ) * 100.
* MOVE l_tmp1 TO l_effic.
* ENDIF.
* ENDIF.
* ENDIF.
* ENDIF.
* ENDLOOP.
*
* wa_h_ord-ac_effc = l_effic.
*
* CLEAR : wa_mbew1.
* READ TABLE i_mbew1 INTO wa_mbew1 WITH KEY matnr = wa_orders-plnbez
* bwkey = wa_orders-werks.
* wa_h_ord-stprs = wa_mbew1-stprs.
* wa_h_ord-peinh = wa_mbew1-peinh.
*
* APPEND wa_h_ord TO i_h_ord.
*
****
**** Build Phase Table
****
* LOOP AT i_afvc INTO wa_afvc WHERE aufnr = wa_orders-aufnr
* AND aufpl = wa_orders-aufpl.
* CLEAR : wa_h_phs.
*
* wa_h_phs-aufnr = wa_afvc-aufnr.
* wa_h_phs-aufpl = wa_afvc-aufpl.
* wa_h_phs-aplzl = wa_afvc-aplzl.
* wa_h_phs-vornr = wa_afvc-vornr.
*
* wa_h_phs-steus = wa_afvc-steus.
* wa_h_phs-rueck = wa_afvc-rueck.
* wa_h_phs-vgwts = wa_afvc-vgwts.
* wa_h_phs-ltxa1 = wa_afvc-ltxa1.
*
* IF wa_afvc-cfuom IS INITIAL.
* CLEAR : wa_afvv, l_lmnga.
* LOOP AT i_afvv INTO l_wa_afvv WHERE aufpl = wa_afvc-aufpl
* AND aplzl = wa_afvc-aplzl.
* wa_h_phs-lmnga = wa_h_phs-lmnga + l_wa_afvv-lmnga.
* ENDLOOP.
* wa_h_phs-cfuom = l_wa_afvv-meinh.
*
* ELSE.
* wa_h_phs-lmnga = wa_afvc-lmnga.
* wa_h_phs-cfuom = wa_afvc-cfuom.
*
** afvv contains std vals for operation qty
* CLEAR : l_wa_afvv.
* READ TABLE i_afvv INTO l_wa_afvv
* WITH KEY aufpl = wa_afvc-aufpl
* aplzl = wa_afvc-aplzl.
* ENDIF.
*
* wa_h_phs-bsuom = wa_h_ord-bsuom.
* wa_h_phs-gewei = wa_h_ord-gewei.
* wa_h_phs-ntgew = wa_h_ord-ntgew.
*
* IF wa_h_phs-cfuom <> wa_h_phs-bsuom.
* l_lmnga = wa_h_phs-lmnga.
* PERFORM conv_to_from_base USING 'X'
* wa_h_ord-plnbez
* l_lmnga
* wa_h_phs-cfuom
* wa_h_phs-bsuom
* CHANGING wa_h_phs-blmnga
* v_conv_rc.
* IF v_conv_rc = 'X'.
* CLEAR : wa_h_phs-blmnga.
* ENDIF.
*
* ELSE.
* wa_h_phs-blmnga = wa_h_phs-lmnga.
* ENDIF.
*
* IF rb_actl = c_x AND rb_conf = c_x.
* wa_h_phs-prduom = wa_h_ord-cfuom.
* wa_h_phs-prdqty = wa_h_ord-lmnga.
* wa_h_phs-bprdqty = wa_h_ord-blmnga.
*
* ELSE.
* wa_h_phs-prduom = wa_h_ord-prduom.
* wa_h_phs-prdqty = wa_h_ord-prdqty.
* wa_h_phs-bprdqty = wa_h_ord-bprdqty.
* ENDIF.
*
* wa_h_phs-arbid = wa_afvc-arbid.
*
* CLEAR : wa_crhd , wa_wc_text.
* READ TABLE i_crhd INTO wa_crhd WITH KEY objid = wa_afvc-arbid.
*
* READ TABLE i_wc_text INTO wa_wc_text
* WITH KEY objid = wa_afvc-arbid.
*
* wa_h_phs-arbpl = wa_crhd-arbpl.
* wa_h_phs-ktext = wa_wc_text-ktext.
*
* IF wa_h_phs-steus = 'YBN1'.
** Expected Line Efficiency
* CLEAR : i_plpo2 , l_effic.
* LOOP AT i_plpo1 INTO wa_plpo WHERE plnty = wa_afvc-plnty
* AND plnnr = wa_afvc-plnnr
* AND plnkn = wa_afvc-plnkn
* AND zaehl = wa_afvc-zaehl
* AND steus = 'YBN1'.
* IF NOT wa_plpo-vgw02 IS INITIAL.
* l_effic = wa_plpo-usr04.
*
* wa_plpo2 = wa_plpo.
* APPEND wa_plpo2 TO i_plpo2.
* ENDIF.
* ENDLOOP.
*
* wa_h_phs-el_effc = l_effic.
*
** Actual Line Efficiency
* CLEAR : l_tmp , l_tmp1 , l_effic.
* LOOP AT i_plpo2 INTO wa_plpo2.
* CLEAR: l_effic.
* IF wa_plpo2-vgw02 <> 0.
* l_tmp = wa_plpo2-bmsch / wa_plpo2-vgw02.
*
* IF l_tmp <> 0.
* l_tmp1 = l_wa_afvv-lmnga / l_tmp.
*
* IF l_wa_afvv-ism02 <> 0.
* l_tmp1 = ( l_tmp1 / l_wa_afvv-ism02 ) * 100.
* MOVE l_tmp1 TO l_effic.
*
* wa_h_phs-runtime = c_x.
* ENDIF.
* ENDIF.
* ENDIF.
* ENDLOOP.
*
* wa_h_phs-ac_effc = l_effic.
* ENDIF.
****
**** Build Phase-Activity Table
****
* CLEAR : l_v_rc.
* PERFORM build_act_tab USING wa_orders-aufnr wa_orders-plnbez
* wa_h_phs-bprdqty wa_h_phs-bsuom
* wa_orders-gmein
* wa_h_phs-el_effc wa_afvc
* l_wa_afvv
* CHANGING l_v_rc.
* IF l_v_rc = c_x.
* APPEND wa_h_phs TO i_h_phs.
* ENDIF.
****
**** Build Material-Phase Table
****
* LOOP AT i_resb ASSIGNING <l_fs_resb>
* WHERE aufnr = wa_orders-aufnr.
*
* IF <l_fs_resb>-aufpl = wa_afvc-aufpl AND
* <l_fs_resb>-vornr = wa_afvc-vornr AND
* <l_fs_resb>-aplzl = wa_afvc-aplzl.
*
* CLEAR : wa_resb.
* PERFORM build_mat_tab USING <l_fs_resb>.
* <l_fs_resb>-flagp = c_y.
*
* ELSEIF <l_fs_resb>-flagp IS INITIAL.
* <l_fs_resb>-flagp = 'N'.
* ENDIF.
* ENDLOOP.
* ENDLOOP.
*
*****
***** Add Extra Materials to Material-Phase Table
*****
* LOOP AT i_resb ASSIGNING <l_fs_resb>
* WHERE aufnr = wa_orders-aufnr
* AND flagp = 'N'.
* CLEAR : wa_resb.
* PERFORM build_mat_tab USING <l_fs_resb>.
* ENDLOOP.
* ENDLOOP.
*
* SORT i_h_ord BY aufnr.
* SORT i_h_mat BY aufnr aufpl aplzl matnr byprod.
*
* SORT i_h_phs BY aufnr vornr.
* SORT i_h_act BY aufnr vornr.
*
* LOOP AT i_h_mat INTO wa_h_mat.
* CLEAR : l_v_sumi.
*
* AT END OF byprod.
* l_v_sumi = c_x.
* ENDAT.
*
* wa_h_mat-sumi = l_v_sumi.
*
* MODIFY i_h_mat FROM wa_h_mat TRANSPORTING sumi.
* ENDLOOP.
*
*ENDFORM. "build_output_tabs
*
*
**&--------------------------------------------------------------------*
**& Form build_mat_tab
**&--------------------------------------------------------------------*
** text
**---------------------------------------------------------------------*
*FORM build_mat_tab USING fp_resb TYPE ty_resb.
*
* DATA : l_v_kausf TYPE kausf,
*
* l_v_smeng TYPE ty_menge,
* l_v_smengs TYPE ty_menge,
* l_v_smengz TYPE ty_menge.
*
* wa_resb = fp_resb.
*
* CLEAR : wa_h_mat , l_v_smeng , l_v_smengs ,
* l_v_smengz.
*
* CHECK wa_resb-postp <> 'N' AND
* NOT ( wa_resb-kzkup = c_x AND
* wa_resb-matnr = wa_h_ord-plnbez ).
*
* wa_h_mat-aufnr = wa_resb-aufnr.
* wa_h_mat-aufpl = wa_resb-aufpl.
* wa_h_mat-aplzl = wa_resb-aplzl.
* wa_h_mat-vornr = wa_resb-vornr.
*
* wa_h_mat-matnr = wa_resb-matnr.
*
* CLEAR : wa_mara.
* READ TABLE i_mara INTO wa_mara WITH KEY matnr = wa_h_mat-matnr.
*
* CLEAR : wa_msegs.
* READ TABLE i_msegs INTO wa_msegs WITH KEY aufnr = wa_h_mat-aufnr
* matnr = wa_h_mat-matnr
* bwart = wa_resb-bwart.
* IF sy-subrc <> 0.
* READ TABLE i_msegs INTO wa_msegs WITH KEY aufnr = wa_h_mat-aufnr
* matnr = wa_h_mat-matnr.
* ENDIF.
*
* CLEAR : wa_ordmats.
* READ TABLE i_ordmats INTO wa_ordmats
* WITH KEY aufnr = wa_resb-aufnr
* matnr = wa_resb-matnr
* stlty = wa_resb-stlty
* stlnr = wa_resb-stlnr
* stlkn = wa_resb-stlkn
* stpoz = wa_resb-stpoz.
* IF sy-subrc = 0.
* wa_h_mat-maktx = wa_ordmats-ojtxp.
*
* wa_h_mat-stprs = wa_ordmats-stprs.
* wa_h_mat-peinh = wa_ordmats-peinh.
*
* wa_h_mat-bomuom = wa_ordmats-meins.
*
* IF wa_orders-bbmeng <> 0.
* l_v_smeng = wa_ordmats-mnglg / wa_orders-bbmeng.
* l_v_smengs = wa_ordmats-mnglgs / wa_orders-bbmeng.
* l_v_smengz = wa_ordmats-mnglgz / wa_orders-bbmeng.
* ENDIF.
*
* wa_h_mat-byprod = wa_ordmats-byprod.
* ELSE.
* CLEAR : wa_mbew1.
* READ TABLE i_mbew1 INTO wa_mbew1
* WITH KEY matnr = wa_h_mat-matnr
* bwkey = p_werks.
* CLEAR : wa_material_des.
* READ TABLE i_material_des INTO wa_material_des
* WITH KEY matnr = wa_h_mat-matnr.
*
* wa_h_mat-maktx = wa_material_des-maktx.
*
* wa_h_mat-stprs = wa_mbew1-stprs.
* wa_h_mat-peinh = wa_mbew1-peinh.
*
* wa_h_mat-bomuom = wa_resb-meins.
*
* wa_resb-bmeins = wa_mara-meins.
* IF wa_mara-meins <> wa_resb-meins.
* PERFORM conv_to_from_base USING 'X'
* wa_resb-matnr
* wa_resb-bdmng
* wa_resb-meins
* wa_mara-meins
* CHANGING wa_resb-bbdmng
* v_conv_rc.
* IF v_conv_rc = 'X'.
* CLEAR : wa_resb-bbdmng.
* ENDIF.
*
* ELSE.
* wa_resb-bbdmng = wa_resb-bdmng.
* ENDIF.
*
* wa_ordmats-rgekz = wa_resb-rgekz.
* ENDIF.
*
* IF rb_nflsh <> c_x OR wa_ordmats-rgekz EQ c_x.
* wa_h_mat-stdusg = l_v_smeng * wa_h_ord-bprdqty.
* wa_h_mat-stdusgs = l_v_smengs * wa_h_ord-bprdqty.
* wa_h_mat-stdusgz = l_v_smengz * wa_h_ord-bprdqty.
* ELSE.
* CLEAR : wa_h_mat-stdusg.
* ENDIF.
*
* IF wa_h_mat-byprod = c_x.
* wa_h_mat-actusg = wa_msegs-bmenge5.
*
* ELSEIF wa_resb-kzkup = c_x.
* wa_h_mat-actusg = 0 - wa_msegs-bmenge1.
*
* ELSE.
* wa_h_mat-actusg = wa_msegs-bmenge2.
* ENDIF.
*
* wa_h_mat-bsuom = wa_mara-meins.
* wa_h_mat-gewei = wa_mara-gewei.
* wa_h_mat-ntgew = wa_mara-ntgew.
*
* IF wa_h_mat-actusg <> 0.
* wa_h_mat-gruom = wa_msegs-erfme.
* ENDIF.
*
* wa_h_mat-bwart = wa_resb-bwart. "NEEL 30/06/2005
*
* APPEND wa_h_mat TO i_h_mat.
*
* wa_matn-matnr = wa_h_mat-matnr.
* wa_matn-bwart = wa_h_mat-bwart. "23-06-2005
*
* COLLECT wa_matn INTO i_matn.
*
*ENDFORM. "build_mat_tab
*
**&--------------------------------------------------------------------*
**& Form build_act_tab
**&--------------------------------------------------------------------*
** text
**---------------------------------------------------------------------*
*FORM build_act_tab USING fp_aufnr TYPE aufnr
* fp_matnr TYPE matnr
* fp_bqty TYPE gamng
* fp_buom TYPE meins
* fp_gmein TYPE meins
* fp_effic TYPE vgwrt
* fp_afvc TYPE ty_afvc
* fp_afvv TYPE ty_afvv
* CHANGING fp_rc TYPE char1.
*
* DATA : l_ism01 TYPE ru_ismng,
* l_ile01 TYPE co_ismngeh,
* l_ism02 TYPE ru_ismng,
* l_ile02 TYPE co_ismngeh,
* l_ism03 TYPE ru_ismng,
* l_ile03 TYPE co_ismngeh,
* l_ism04 TYPE ru_ismng,
* l_ile04 TYPE co_ismngeh,
* l_ism05 TYPE ru_ismng,
* l_ile05 TYPE co_ismngeh,
* l_ism06 TYPE ru_ismng,
* l_ile06 TYPE co_ismngeh,
*
* l_effic TYPE vgwrt,
*
* l_v_bmsch TYPE bmsch,
* l_pqty TYPE gamng.
*
* DATA: l_vgw01 TYPE vgwrt,
* l_vgw02 TYPE vgwrt,
* l_vgw03 TYPE vgwrt,
* l_vgw04 TYPE vgwrt,
* l_vgw05 TYPE vgwrt,
* l_vgw06 TYPE vgwrt.
*
*
*
* CLEAR : wa_h_act.
*
* wa_h_act-aufnr = fp_aufnr.
* wa_h_act-aufpl = fp_afvc-aufpl.
* wa_h_act-aplzl = fp_afvc-aplzl.
* wa_h_act-vornr = fp_afvc-vornr.
*
* wa_h_act-vgwts = fp_afvc-vgwts.
*
* l_effic = fp_effic / 100.
* IF l_effic = 0.
* l_effic = 1.
* ENDIF.
*
* wa_afvv = fp_afvv.
* CHECK NOT wa_afvv IS INITIAL.
*
* wa_h_act-mgvrg = wa_afvv-mgvrg.
* wa_h_act-meinh = wa_afvv-meinh.
* wa_h_act-bmsch = wa_afvv-bmsch.
*
* CLEAR : wa_param.
* READ TABLE i_param INTO wa_param WITH KEY vgwts = wa_h_act-vgwts.
*
** Actual Usage
* CLEAR : wa_ord_conf1.
* LOOP AT i_ord_conf1 INTO wa_ord_conf1 WHERE rueck = fp_afvc-rueck.
* IF wa_ord_conf1-stokz IS INITIAL.
* l_ism01 = l_ism01 + wa_ord_conf1-ism01.
* l_ism02 = l_ism02 + wa_ord_conf1-ism02.
* l_ism03 = l_ism03 + wa_ord_conf1-ism03.
* l_ism04 = l_ism04 + wa_ord_conf1-ism04.
* l_ism05 = l_ism05 + wa_ord_conf1-ism05.
* l_ism06 = l_ism06 + wa_ord_conf1-ism06.
* ELSE.
* l_ism01 = l_ism01 - wa_ord_conf1-ism01.
* l_ism02 = l_ism02 - wa_ord_conf1-ism02.
* l_ism03 = l_ism03 - wa_ord_conf1-ism03.
* l_ism04 = l_ism04 - wa_ord_conf1-ism04.
* l_ism05 = l_ism05 - wa_ord_conf1-ism05.
* l_ism06 = l_ism06 - wa_ord_conf1-ism06.
* ENDIF.
* ENDLOOP.
*
* l_ile01 = wa_ord_conf1-ile01.
* l_ile02 = wa_ord_conf1-ile02.
* l_ile03 = wa_ord_conf1-ile03.
* l_ile04 = wa_ord_conf1-ile04.
* l_ile05 = wa_ord_conf1-ile05.
* l_ile06 = wa_ord_conf1-ile06.
*
* CLEAR : fp_rc , l_pqty.
*
* l_pqty = fp_bqty.
* l_v_bmsch = wa_afvv-bmsch.
*
* IF wa_afvv-umren > 0.
* l_v_bmsch = l_v_bmsch * ( wa_afvv-umrez / wa_afvv-umren ).
* ENDIF.
*
* IF wa_afvv-meinh <> fp_buom.
* PERFORM conv_to_from_base USING 'X'
* fp_matnr
* l_v_bmsch
* wa_afvv-meinh
* fp_buom
* CHANGING wa_afvv-bmsch
* v_conv_rc.
* IF v_conv_rc = 'X'.
* wa_afvv-bmsch = l_v_bmsch.
* ENDIF.
*
**** Begin of Change on 25-05-2005
*
* IF fp_afvc-vgwts+0(3) = 'YGE'.
* PERFORM conv_to_from_base USING 'X'
* fp_matnr
* wa_afvv-vgw01
* wa_afvv-meinh
* fp_buom
* CHANGING l_vgw01
* v_conv_rc.
* IF v_conv_rc = space.
* wa_afvv-vgw01 = l_vgw01.
* ENDIF.
* ENDIF.
*
* PERFORM conv_to_from_base USING 'X'
* fp_matnr
* wa_afvv-vgw02
* wa_afvv-meinh
* fp_buom
* CHANGING l_vgw02
* v_conv_rc.
* IF v_conv_rc = space.
* wa_afvv-vgw02 = l_vgw02.
* ENDIF.
*
* IF fp_afvc-vgwts+0(3) = 'YGE'.
* PERFORM conv_to_from_base USING 'X'
* fp_matnr
* wa_afvv-vgw03
* wa_afvv-meinh
* fp_buom
* CHANGING l_vgw03
* v_conv_rc.
* IF v_conv_rc = space.
* wa_afvv-vgw03 = l_vgw03.
* ENDIF.
* ENDIF.
*
* PERFORM conv_to_from_base USING 'X'
* fp_matnr
* wa_afvv-vgw04
* wa_afvv-meinh
* fp_buom
* CHANGING l_vgw04
* v_conv_rc.
* IF v_conv_rc = space.
* wa_afvv-vgw04 = l_vgw04.
* ENDIF.
*
* PERFORM conv_to_from_base USING 'X'
* fp_matnr
* wa_afvv-vgw05
* wa_afvv-meinh
* fp_buom
* CHANGING l_vgw05
* v_conv_rc.
* IF v_conv_rc = space.
* wa_afvv-vgw05 = l_vgw05.
* ENDIF.
*
* PERFORM conv_to_from_base USING 'X'
* fp_matnr
* wa_afvv-vgw06
* wa_afvv-meinh
* fp_buom
* CHANGING l_vgw06
* v_conv_rc.
* IF v_conv_rc = space.
* wa_afvv-vgw06 = l_vgw06.
* ENDIF.
**** End of Change on 25-05-2005
*
*
* ENDIF.
*
* IF NOT fp_afvc-lar01 IS INITIAL OR NOT fp_afvc-lar02 IS INITIAL OR
* NOT fp_afvc-lar03 IS INITIAL OR NOT fp_afvc-lar04 IS INITIAL OR
* NOT fp_afvc-lar05 IS INITIAL OR NOT fp_afvc-lar06 IS INITIAL.
*
* IF NOT fp_afvc-lar01 IS INITIAL OR
* NOT wa_afvv-vgw01 IS INITIAL.
* CLEAR : wa_param_key.
* READ TABLE i_param_key INTO wa_param_key
* WITH KEY parid = wa_param-par01.
*
* wa_h_act-parxx = wa_param-par01.
* wa_h_act-txtxx = wa_param_key-txtlg.
* wa_h_act-ismxx = l_ism01.
* wa_h_act-ilexx = l_ile01.
*
* IF fp_afvc-sumnr = 0.
* wa_h_act-vgwxx = wa_afvv-vgw01.
* wa_h_act-vgexx = wa_afvv-vge01.
* ELSE.
* wa_h_act-vgwxx = wa_afvv-vgw01 * ( l_pqty / wa_afvv-bmsch ).
* wa_h_act-vgexx = wa_afvv-vge01.
* ENDIF.
*
* wa_h_act-stdvar = wa_h_act-vgwxx - wa_h_act-ismxx.
*
* PERFORM get_act_cost USING fp_afvc-arbid
* fp_afvc-lar01
* CHANGING wa_h_act-togxx
* wa_h_act-toexx.
* APPEND wa_h_act TO i_h_act.
*
* wa_parn-parxx = wa_h_act-parxx.
* COLLECT wa_parn INTO i_parn.
*
* fp_rc = c_x.
* ENDIF.
*
* IF NOT fp_afvc-lar02 IS INITIAL OR
* NOT wa_afvv-vgw02 IS INITIAL.
* CLEAR : wa_param_key.
* READ TABLE i_param_key INTO wa_param_key
* WITH KEY parid = wa_param-par02.
*
* wa_h_act-parxx = wa_param-par02.
* wa_h_act-txtxx = wa_param_key-txtlg.
* wa_h_act-ismxx = l_ism02.
* wa_h_act-ilexx = l_ile02.
** Begin of MOD-002++
** wa_h_act-vgwxx = wa_afvv-vgw02 * ( l_pqty / wa_afvv-bmsch ).
** wa_h_act-vgwxx = wa_h_act-vgwxx / l_effic.
* wa_h_act-vgwxx =
* ( wa_afvv-vgw02 * l_pqty / wa_afvv-bmsch ) / l_effic.
** End of MOD-002++
* wa_h_act-vgexx = wa_afvv-vge02.
*
* wa_h_act-stdvar = wa_h_act-vgwxx - wa_h_act-ismxx.
*
* PERFORM get_act_cost USING fp_afvc-arbid
* fp_afvc-lar02
* CHANGING wa_h_act-togxx
* wa_h_act-toexx.
*
* APPEND wa_h_act TO i_h_act.
*
* wa_parn-parxx = wa_h_act-parxx.
* COLLECT wa_parn INTO i_parn.
*
* fp_rc = c_x.
* ENDIF.
*
* IF NOT fp_afvc-lar03 IS INITIAL OR
* NOT wa_afvv-vgw03 IS INITIAL.
* CLEAR : wa_param_key.
* READ TABLE i_param_key INTO wa_param_key
* WITH KEY parid = wa_param-par03.
*
* wa_h_act-parxx = wa_param-par03.
* wa_h_act-txtxx = wa_param_key-txtlg.
* wa_h_act-ismxx = l_ism03.
* wa_h_act-ilexx = l_ile03.
*
* IF fp_afvc-sumnr = 0.
* wa_h_act-vgwxx = wa_afvv-vgw03.
* wa_h_act-vgexx = wa_afvv-vge03.
* ELSE.
* wa_h_act-vgwxx = wa_afvv-vgw03 * ( l_pqty / wa_afvv-bmsch ).
* wa_h_act-vgexx = wa_afvv-vge03.
* ENDIF.
*
* wa_h_act-stdvar = wa_h_act-vgwxx - wa_h_act-ismxx.
*
* PERFORM get_act_cost USING fp_afvc-arbid
* fp_afvc-lar03
* CHANGING wa_h_act-togxx
* wa_h_act-toexx.
*
* APPEND wa_h_act TO i_h_act.
*
* wa_parn-parxx = wa_h_act-parxx.
* COLLECT wa_parn INTO i_parn.
*
* fp_rc = c_x.
* ENDIF.
*
* IF NOT fp_afvc-lar04 IS INITIAL OR
* NOT wa_afvv-vgw04 IS INITIAL.
* CLEAR : wa_param_key.
* READ TABLE i_param_key INTO wa_param_key
* WITH KEY parid = wa_param-par04.
*
* wa_h_act-parxx = wa_param-par04.
* wa_h_act-txtxx = wa_param_key-txtlg.
* wa_h_act-ismxx = l_ism04.
* wa_h_act-ilexx = l_ile04.
** Begin of MOD-002++
** wa_h_act-vgwxx = wa_afvv-vgw04 * ( l_pqty / wa_afvv-bmsch ).
** wa_h_act-vgwxx = wa_h_act-vgwxx / l_effic.
* wa_h_act-vgwxx =
* ( wa_afvv-vgw04 * l_pqty / wa_afvv-bmsch ) / l_effic.
** End of MOD-002++
*
* wa_h_act-vgexx = wa_afvv-vge04.
*
* wa_h_act-stdvar = wa_h_act-vgwxx - wa_h_act-ismxx.
*
* PERFORM get_act_cost USING fp_afvc-arbid
* fp_afvc-lar04
* CHANGING wa_h_act-togxx
* wa_h_act-toexx.
*
* APPEND wa_h_act TO i_h_act.
*
* wa_parn-parxx = wa_h_act-parxx.
* COLLECT wa_parn INTO i_parn.
*
* fp_rc = c_x.
* ENDIF.
*
* IF NOT fp_afvc-lar05 IS INITIAL OR
* NOT wa_afvv-vgw05 IS INITIAL.
* CLEAR : wa_param_key.
* READ TABLE i_param_key INTO wa_param_key
* WITH KEY parid = wa_param-par05.
*
* wa_h_act-parxx = wa_param-par05.
* wa_h_act-txtxx = wa_param_key-txtlg.
* wa_h_act-ismxx = l_ism05.
* wa_h_act-ilexx = l_ile05.
* wa_h_act-vgwxx = wa_afvv-vgw05 * ( l_pqty / wa_afvv-bmsch ).
* wa_h_act-vgexx = wa_afvv-vge05.
*
* wa_h_act-stdvar = wa_h_act-vgwxx - wa_h_act-ismxx.
*
* PERFORM get_act_cost USING fp_afvc-arbid
* fp_afvc-lar05
* CHANGING wa_h_act-togxx
* wa_h_act-toexx.
*
* APPEND wa_h_act TO i_h_act.
*
* wa_parn-parxx = wa_h_act-parxx.
* COLLECT wa_parn INTO i_parn.
*
* fp_rc = c_x.
* ENDIF.
*
* IF NOT fp_afvc-lar06 IS INITIAL OR
* NOT wa_afvv-vgw06 IS INITIAL.
* CLEAR : wa_param_key.
* READ TABLE i_param_key INTO wa_param_key
* WITH KEY parid = wa_param-par06.
*
* wa_h_act-parxx = wa_param-par06.
* wa_h_act-txtxx = wa_param_key-txtlg.
* wa_h_act-ismxx = l_ism06.
* wa_h_act-ilexx = l_ile06.
* wa_h_act-vgwxx = wa_afvv-vgw06 * ( l_pqty / wa_afvv-bmsch ).
* wa_h_act-vgexx = wa_afvv-vge06.
*
* wa_h_act-stdvar = wa_h_act-vgwxx - wa_h_act-ismxx.
*
* PERFORM get_act_cost USING fp_afvc-arbid
* fp_afvc-lar06
* CHANGING wa_h_act-togxx
* wa_h_act-toexx.
*
* APPEND wa_h_act TO i_h_act.
*
* wa_parn-parxx = wa_h_act-parxx.
* COLLECT wa_parn INTO i_parn.
*
* fp_rc = c_x.
* ENDIF.
* ENDIF.
*ENDFORM. "build_act_tab
*
**&--------------------------------------------------------------------*
**& Form get_act_cost
**&--------------------------------------------------------------------*
** text
**---------------------------------------------------------------------*
*FORM get_act_cost USING fp_arbid TYPE cr_objid
* fp_larxx TYPE lstar
* CHANGING fp_tog001 TYPE togxxx
* fp_toe001 TYPE toexxx.
* DATA: l_kokrs TYPE kokrs,
* l_kostl TYPE kostl,
* l_objnr TYPE j_objnr.
*
* CLEAR: l_kokrs, l_kostl, l_objnr,
* fp_tog001.
*
* fp_toe001 = 1.
*
* SELECT SINGLE kokrs kostl
* FROM crco
* INTO (l_kokrs, l_kostl)
* WHERE objty = c_a
* AND objid = fp_arbid
* AND lstar = fp_larxx.
* IF sy-subrc = 0.
*
* SELECT SINGLE objnr
* FROM cssl
* INTO l_objnr
* WHERE kokrs = l_kokrs
* AND kostl = l_kostl
* AND lstar = fp_larxx
* AND gjahr = sy-datum(4).
* IF sy-subrc = 0.
*
* SELECT SINGLE tog001 toe001
* FROM cost
* INTO (fp_tog001, fp_toe001)
* WHERE objnr = l_objnr
* AND gjahr = sy-datum(4)
* AND versn = c_000.
*
* fp_tog001 = fp_tog001 / 10.
* fp_toe001 = fp_toe001 / 10.
*
* IF fp_toe001 = 0.
* fp_toe001 = 1.
* ENDIF.
*
* ENDIF.
* ENDIF.
*ENDFORM. "get_act_cost
*
**&---------------------------------------------------------------------
*
**& Form output
**&---------------------------------------------------------------------
*
** text
**----------------------------------------------------------------------
*
*FORM output.
* CASE c_x.
* WHEN rb_detl.
* v_rep = c_detl.
* PERFORM display_detail_report.
*
* WHEN rb_summ.
* v_rep = c_sums.
* PERFORM display_summary_report.
*
* WHEN rb_phase.
* v_rep = c_phas.
* PERFORM display_phase_report.
* ENDCASE.
*
* PERFORM tree_rebuild.
*ENDFORM. " output
*
**&--------------------------------------------------------------------*
**& Form display_detail_report
**&--------------------------------------------------------------------*
** text
**---------------------------------------------------------------------*
*FORM display_detail_report.
* DATA : l_date_low TYPE char10,
* l_date_high TYPE char10,
*
* l_prdqty TYPE gamng,
* l_wprdqty TYPE menge_d,
*
* l_prduom TYPE meins,
* l_uom TYPE meins,
* l_prdq(20),
*
* l_effic TYPE char16,
*
* l_act TYPE char16,
* l_std TYPE char16,
*
* l_amenge TYPE menge_d,
* l_smenge TYPE menge_d,
* l_menge TYPE menge_d,
*
* l_aqty TYPE char18,
* l_sqty TYPE char18,
* l_svar TYPE char18,
* l_svarp TYPE char18,
*
* l_aqtys TYPE char18,
* l_sqtys TYPE char18,
* l_svars TYPE char18,
*
* l_aqtyg TYPE char18,
* l_sqtyg TYPE char18,
* l_svarg TYPE char18,
*
* l_matuom TYPE meins,
* l_stduom TYPE meins,
* l_varuom TYPE meins,
*
* l_astprs TYPE ty_stprs,
* l_sstprs TYPE ty_stprs,
* l_stprs TYPE ty_stprs,
*
* l_total1 TYPE char1,
* l_total2 TYPE char1,
* l_total3 TYPE char1,
*
* l_totalg1 TYPE char1,
* l_totalg2 TYPE char1,
* l_totalg3 TYPE char1,
*
* l_aplzl TYPE co_aplzl,
*
* l_wa_act TYPE ty_hier_act,
* l_wa_mat TYPE ty_hier_mat_sum,
* l_wa_matg TYPE ty_hier_mat_sum.
*
* PERFORM pfstatus.
* SET PF-STATUS 'MAIN' EXCLUDING i_fcode.
* SET TITLEBAR 'VARI' WITH text-066.
*
* MOVE 'Display Detail Report'(028) TO v_output_text.
* PERFORM inform_user_of_progress.
*
** Clearing local variables
* CLEAR wa_nodestab.
* REFRESH i_nodestab.
*
* wa_nodestab-id = c_1_1.
* wa_nodestab-tlevel = c_1.
* wa_nodestab-text = 'Production Variances'(031).
* wa_nodestab-tlength = c_20.
* wa_nodestab-compress = c_x.
* APPEND wa_nodestab TO i_nodestab.
*
* CLEAR : l_wa_matg , l_sqtyg , l_aqtyg , l_svarg,
* l_totalg1 , l_totalg2 , l_totalg3.
* LOOP AT i_h_ord INTO wa_h_ord.
* CLEAR: wa_nodestab, l_date_low, l_date_high, l_prdqty, l_prduom.
*
* wa_nodestab-id = c_2_1.
* wa_nodestab-tlevel = c_2.
* wa_nodestab-parent = c_1_1.
*
** Order Number text
* wa_nodestab-text = 'Order Num:'(032).
* wa_nodestab-tlength = c_12.
* wa_nodestab-tcolor = c_1.
*
** Order number
* WRITE wa_h_ord-aufnr TO wa_nodestab-text1 NO-ZERO.
* wa_nodestab-tlength1 = c_12.
* wa_nodestab-tcolor1 = c_1.
*
** Date Range
* WRITE wa_h_ord-gstrp TO l_date_low.
* WRITE wa_h_ord-gltrp TO l_date_high.
* CONCATENATE l_date_low c_hyp l_date_high INTO wa_nodestab-text2
* SEPARATED BY space.
* wa_nodestab-tlength2 = c_25.
* wa_nodestab-tcolor2 = c_1.
*
** Material Number
* WRITE wa_h_ord-plnbez TO wa_nodestab-text3 NO-ZERO.
* wa_nodestab-tlength3 = c_18.
* wa_nodestab-tcolor3 = c_1.
*
** Material Description
* wa_nodestab-text4 = wa_h_ord-maktx.
* wa_nodestab-tlength4 = c_33.
* wa_nodestab-tcolor4 = c_1.
*
** Produced Quantity / Confirmed Quantity
* l_prdqty = wa_h_ord-prdqty.
* l_prduom = wa_h_ord-prduom.
*
** convert to KG?
* IF rb_kgm = c_x AND l_prduom <> 'KG'.
* IF wa_h_ord-bsuom <> 'KG'.
* PERFORM convert_to_kg USING wa_h_ord-plnbez wa_h_ord-bsuom
* wa_h_ord-gewei wa_h_ord-ntgew
* wa_h_ord-bprdqty
* CHANGING l_wprdqty
* v_conv_rc.
* IF v_conv_rc <> 'X'.
* l_prdqty = l_wprdqty.
* l_prduom = 'KG'.
* ENDIF.
*
* ELSE.
* l_prdqty = wa_h_ord-bprdqty.
* l_prduom = 'KG'.
* ENDIF.
* ENDIF.
*
* WRITE l_prdqty TO l_prdq UNIT l_prduom.
* WRITE l_prduom TO l_uom.
*
**** text for Order Qty
* IF rb_pland = c_x.
*** Planned Production
* CONCATENATE 'Plan Qty:'(076) l_prdq l_uom
* INTO wa_nodestab-text5 SEPARATED BY space.
* ELSE.
*** Actual Production
* IF rb_prod = c_x.
** Produced
* CONCATENATE 'Prod Qty:'(033) l_prdq l_uom
* INTO wa_nodestab-text5 SEPARATED BY space.
* ELSE.
** Confirmed
* CONCATENATE 'Conf Qty:'(034) l_prdq l_uom
* INTO wa_nodestab-text5 SEPARATED BY space.
* ENDIF.
* ENDIF.
*
* CONDENSE : wa_nodestab-text5.
*
* wa_nodestab-tlength5 = c_35.
* wa_nodestab-tcolor5 = c_1.
*
* APPEND wa_nodestab TO i_nodestab.
*
** Resource Information
* CLEAR : wa_nodestab , l_effic.
* wa_nodestab-id = c_3_1.
* wa_nodestab-tlevel = c_3.
* wa_nodestab-parent = c_2_1.
*
* wa_nodestab-text = 'Resource:'(035).
* wa_nodestab-tlength = c_14.
* wa_nodestab-tcolor = c_4.
*
* wa_nodestab-text1 = wa_h_ord-botlnck.
* wa_nodestab-tlength1 = c_8.
* wa_nodestab-tcolor1 = c_4.
*
* wa_nodestab-text2 = wa_h_ord-resdesc.
* wa_nodestab-tlength2 = c_37.
* wa_nodestab-tcolor2 = c_4.
*
* l_effic = wa_h_ord-el_effc.
* CONCATENATE 'Exp. Line Eff.'(036) l_effic c_perc
* INTO wa_nodestab-text3 SEPARATED BY space.
* CONDENSE wa_nodestab-text3.
* wa_nodestab-tlength3 = c_30.
* wa_nodestab-tcolor3 = c_4.
*
* l_effic = wa_h_ord-ac_effc.
* CONCATENATE 'Act. Line Eff.'(037) l_effic c_perc
* INTO wa_nodestab-text4 SEPARATED BY space.
* CONDENSE wa_nodestab-text4.
* wa_nodestab-tlength4 = c_30.
* wa_nodestab-tcolor4 = c_4.
*
* APPEND wa_nodestab TO i_nodestab.
*
** Phase Information
* READ TABLE i_h_act INTO wa_h_act WITH KEY aufnr = wa_h_ord-aufnr.
* IF sy-subrc = 0.
* CLEAR : wa_nodestab.
*
* wa_nodestab-id = c_3_2.
* wa_nodestab-tlevel = c_3.
* wa_nodestab-parent = c_2_1.
*
* wa_nodestab-text = 'Phase'(038).
* wa_nodestab-tlength = c_8.
* wa_nodestab-tcolor = c_4.
*
* wa_nodestab-tlength1 = c_42.
** wa_nodestab-tcolor1 = c_4.
*
* IF rb_fiscl = c_x.
* CONCATENATE 'Actual Usage'(040) v_waers
* INTO wa_nodestab-text2 SEPARATED BY space.
* ELSE.
* CONCATENATE 'Actual Usage'(040) 'UoM'
* INTO wa_nodestab-text2 SEPARATED BY space.
* ENDIF.
* wa_nodestab-tlength2 = c_20.
* wa_nodestab-tcolor2 = c_4.
*
* IF rb_fiscl = c_x.
* CONCATENATE 'Standard Usage'(041) v_waers
* INTO wa_nodestab-text3 SEPARATED BY space.
* ELSE.
* CONCATENATE 'Standard Usage'(041) 'UoM'
* INTO wa_nodestab-text3 SEPARATED BY space.
* ENDIF.
* wa_nodestab-tlength3 = c_20.
* wa_nodestab-tcolor3 = c_4.
*
* IF rb_fiscl = c_x.
* CONCATENATE 'Standard Usage Var'(042) v_waers
* INTO wa_nodestab-text4 SEPARATED BY space.
* ELSE.
* CONCATENATE 'Standard Usage Var'(042) 'UoM'
* INTO wa_nodestab-text4 SEPARATED BY space.
* ENDIF.
* wa_nodestab-tlength4 = c_24.
* wa_nodestab-tcolor4 = c_4.
*
* CONCATENATE 'Standard Usage Var'(042) c_perc
* INTO wa_nodestab-text5 SEPARATED BY space.
* wa_nodestab-tlength5 = c_20.
* wa_nodestab-tcolor5 = c_4.
*
* APPEND wa_nodestab TO i_nodestab.
*
**** Activities
* CLEAR : flg_color, l_act , l_std , l_svar , l_svarp ,
* l_wa_act , l_total1 , l_total2 , l_aplzl.
* LOOP AT i_h_act INTO wa_h_act WHERE aufnr = wa_h_ord-aufnr.
*
* IF l_aplzl <> wa_h_act-aplzl.
* CLEAR : wa_afvc.
* READ TABLE i_h_phs INTO wa_h_phs WITH KEY aufnr =
* wa_h_act-aufnr
* aufpl =
* wa_h_act-aufpl
* aplzl =
* wa_h_act-aplzl.
* l_aplzl = wa_h_act-aplzl.
* ENDIF.
*
* CLEAR wa_nodestab.
* wa_nodestab-id = c_4_1.
* wa_nodestab-tlevel = c_4.
* wa_nodestab-parent = c_3_2.
*
* wa_nodestab-text = wa_h_act-vornr.
* wa_nodestab-tlength = c_4.
*
* CONCATENATE wa_h_phs-steus wa_h_phs-arbpl
* wa_h_act-txtxx INTO wa_nodestab-text1
* SEPARATED BY ' '.
* wa_nodestab-tlength1 = c_42.
*
* IF rb_quant = c_x.
* WRITE : wa_h_act-ismxx TO l_act UNIT wa_h_act-ilexx
* NO-GROUPING,
* wa_h_act-ilexx TO l_uom.
* CONCATENATE l_act l_uom INTO wa_nodestab-text2
* SEPARATED BY space.
* wa_nodestab-tlength2 = c_20.
*
* WRITE : wa_h_act-vgwxx TO l_std UNIT wa_h_act-vgexx
* NO-GROUPING,
* wa_h_act-vgexx TO l_uom.
* CONCATENATE l_std l_uom INTO wa_nodestab-text3
* SEPARATED BY space.
* wa_nodestab-tlength3 = c_20.
*
* WRITE : wa_h_act-stdvar TO l_svar UNIT wa_h_act-vgexx
* NO-GROUPING,
* wa_h_act-vgexx TO l_uom.
* CONCATENATE l_svar l_uom INTO wa_nodestab-text4
* SEPARATED BY space.
* wa_nodestab-tlength4 = c_24.
*
* IF wa_h_act-ismxx <> 0.
* IF l_total2 <> c_x.
* l_total2 = c_x.
* l_wa_act-ilexx = wa_h_act-ilexx.
* ENDIF.
*
* IF l_wa_act-ilexx = wa_h_act-ilexx.
*
* l_wa_act-ismxx = l_wa_act-ismxx + wa_h_act-ismxx.
* l_wa_act-ilexx = wa_h_act-ilexx.
*
* ELSEIF wa_h_act-ismxx <> 0.
* CLEAR : l_wa_act-ismxx , l_wa_act-ilexx.
* ENDIF.
* ENDIF.
*
* IF wa_h_act-vgwxx <> 0.
* IF l_total1 <> c_x.
* l_total1 = c_x.
* l_wa_act-vgexx = wa_h_act-vgexx.
* ENDIF.
*
* IF l_wa_act-vgexx = wa_h_act-vgexx.
* l_wa_act-vgwxx = l_wa_act-vgwxx + wa_h_act-vgwxx.
* l_wa_act-stdvar = l_wa_act-stdvar + wa_h_act-stdvar.
* l_wa_act-vgexx = wa_h_act-vgexx.
*
* ELSEIF wa_h_act-vgwxx <> 0.
* CLEAR : l_wa_act-vgwxx , l_wa_act-vgexx, l_wa_act-stdvar.
* ENDIF.
* ENDIF.
*
* IF wa_h_act-vgwxx <> 0.
* wa_h_act-varper = ( wa_h_act-stdvar / wa_h_act-vgwxx ) * 100
* .
* ENDIF.
*
* ELSE.
* wa_h_act-actu = wa_h_act-ismxx *
* ( wa_h_act-togxx / wa_h_act-toexx ).
*
* WRITE : wa_h_act-actu TO l_act CURRENCY v_waers NO-GROUPING,
* v_waers TO l_uom.
* CONCATENATE l_act l_uom INTO wa_nodestab-text2
* SEPARATED BY space.
* wa_nodestab-tlength2 = c_20.
*
* wa_h_act-stdu = wa_h_act-vgwxx *
* ( wa_h_act-togxx / wa_h_act-toexx ).
*
* WRITE : wa_h_act-stdu TO l_std CURRENCY v_waers NO-GROUPING.
* CONCATENATE l_std l_uom INTO wa_nodestab-text3
* SEPARATED BY space.
* wa_nodestab-tlength3 = c_20.
*
* wa_h_act-varu = wa_h_act-stdvar *
* ( wa_h_act-togxx / wa_h_act-toexx ).
*
* WRITE wa_h_act-varu TO l_svar CURRENCY v_waers NO-GROUPING.
* CONCATENATE l_svar l_uom INTO wa_nodestab-text4
* SEPARATED BY space.
* wa_nodestab-tlength4 = c_24.
*
* l_wa_act-actu = l_wa_act-actu + wa_h_act-actu.
* l_wa_act-stdu = l_wa_act-stdu + wa_h_act-stdu.
* l_wa_act-varu = l_wa_act-varu + wa_h_act-varu.
*
* IF wa_h_act-stdu <> 0.
* wa_h_act-varper = ( wa_h_act-varu / wa_h_act-stdu ) * 100.
* ENDIF.
* ENDIF.
*
* WRITE wa_h_act-varper TO l_svarp NO-GROUPING DECIMALS 2.
* CONCATENATE l_svarp c_perc INTO wa_nodestab-text5
* SEPARATED BY space.
* wa_nodestab-tlength5 = c_20.
*
* IF flg_color = c_x.
* CLEAR flg_color.
* wa_nodestab-tcolor = c_3.
* wa_nodestab-tcolor1 = c_3.
* wa_nodestab-tcolor2 = c_3.
* wa_nodestab-tcolor3 = c_3.
* wa_nodestab-tcolor4 = c_3.
* wa_nodestab-tcolor5 = c_3.
* wa_nodestab-tcolor6 = c_3.
* wa_nodestab-tcolor7 = c_3.
* wa_nodestab-tcolor8 = c_3.
* ELSE.
* flg_color = c_x.
* wa_nodestab-tcolor = c_2.
* wa_nodestab-tcolor1 = c_2.
* wa_nodestab-tcolor2 = c_2.
* wa_nodestab-tcolor3 = c_2.
* wa_nodestab-tcolor4 = c_2.
* wa_nodestab-tcolor5 = c_2.
* wa_nodestab-tcolor6 = c_2.
* wa_nodestab-tcolor7 = c_2.
* wa_nodestab-tcolor8 = c_2.
* ENDIF.
* APPEND wa_nodestab TO i_nodestab.
* ENDLOOP.
**** Displaying Activity Subtotals
* CLEAR wa_nodestab.
* wa_nodestab-id = c_4_1.
* wa_nodestab-tlevel = c_4.
* wa_nodestab-parent = c_3_2.
*
* wa_nodestab-text = 'Activity Totals'(074).
* wa_nodestab-tlength = c_20.
* wa_nodestab-tcolor = c_6.
*
* wa_nodestab-text1 = space.
* wa_nodestab-tlength1 = c_26.
* wa_nodestab-tcolor1 = c_6.
*
* IF rb_quant = c_x.
* WRITE : l_wa_act-ismxx TO l_act UNIT l_wa_act-ilexx
* NO-GROUPING,
* l_wa_act-vgwxx TO l_std UNIT l_wa_act-vgexx
* NO-GROUPING,
* l_wa_act-stdvar TO l_svar UNIT l_wa_act-vgexx
* NO-GROUPING,
* wa_h_act-ilexx TO l_uom.
*
* CONCATENATE l_act l_uom INTO wa_nodestab-text2
* SEPARATED BY space.
* WRITE : wa_h_act-vgexx TO l_uom.
* CONCATENATE l_std l_uom INTO wa_nodestab-text3
* SEPARATED BY space.
* CONCATENATE l_svar l_uom INTO wa_nodestab-text4
* SEPARATED BY space.
* ELSE.
* WRITE : l_wa_act-actu TO l_act CURRENCY v_waers NO-GROUPING,
* l_wa_act-stdu TO l_std CURRENCY v_waers NO-GROUPING,
* l_wa_act-varu TO l_svar CURRENCY v_waers NO-GROUPING,
* v_waers TO l_uom.
*
* CONCATENATE l_act l_uom INTO wa_nodestab-text2
* SEPARATED BY space.
* CONCATENATE l_std l_uom INTO wa_nodestab-text3
* SEPARATED BY space.
* CONCATENATE l_svar l_uom INTO wa_nodestab-text4
* SEPARATED BY space.
* ENDIF.
* wa_nodestab-tlength2 = c_20.
* wa_nodestab-tcolor2 = c_6.
*
* wa_nodestab-tlength3 = c_20.
* wa_nodestab-tcolor3 = c_6.
*
* wa_nodestab-tlength4 = c_24.
* wa_nodestab-tcolor4 = c_6.
*
* APPEND wa_nodestab TO i_nodestab.
* CLEAR : wa_nodestab.
* ENDIF.
*
** Material Information
* READ TABLE i_h_mat INTO wa_h_mat WITH KEY aufnr = wa_h_ord-aufnr.
* CHECK sy-subrc = 0.
*
* CLEAR : wa_nodestab.
* wa_nodestab-id = c_3_3.
* wa_nodestab-tlevel = c_3.
* wa_nodestab-parent = c_2_1.
* PERFORM material_header USING wa_nodestab.
*
* APPEND wa_nodestab TO i_nodestab.
*
* CLEAR : wa_nodestab , l_menge , l_stprs ,
* l_wa_mat ,
* l_total1 , l_total2 , l_total3 ,
* l_aqtys , l_sqtys , l_svars .
* LOOP AT i_h_mat INTO wa_h_mat WHERE aufnr = wa_h_ord-aufnr.
*
* l_smenge = l_menge.
* l_sstprs = l_stprs.
* PERFORM do_mat_calc CHANGING wa_h_mat
* l_aqty l_matuom
* l_sqty l_stduom
* l_svar l_varuom
* l_svarp
* l_amenge l_smenge
* l_astprs l_sstprs.
* l_menge = l_menge + l_smenge.
* l_stprs = l_stprs + l_sstprs.
*
* CHECK wa_h_mat-sumi = c_x.
*
* CLEAR: wa_nodestab , l_menge , l_stprs.
* wa_nodestab-id = c_4_2.
* wa_nodestab-tlevel = c_4.
* wa_nodestab-parent = c_3_3.
*
** Material Number
* WRITE wa_h_mat-matnr TO wa_nodestab-text NO-ZERO.
** Material Description
* wa_nodestab-text1 = wa_h_mat-maktx.
*
* wa_nodestab-tlength = c_18.
* wa_nodestab-tlength1 = c_30.
* wa_nodestab-tlength2 = c_22.
* wa_nodestab-tlength3 = c_22.
* wa_nodestab-tlength4 = c_24.
* wa_nodestab-tlength5 = c_20.
*
* IF l_matuom <> v_waers.
* WRITE : l_matuom TO l_uom.
* ELSE.
* WRITE : v_waers TO l_uom.
* ENDIF.
* CONCATENATE l_aqty l_uom INTO wa_nodestab-text2
* SEPARATED BY space.
* IF l_stduom <> v_waers.
* WRITE : l_stduom TO l_uom.
* ELSE.
* WRITE : v_waers TO l_uom.
* ENDIF.
* CONCATENATE l_sqty l_uom INTO wa_nodestab-text3
* SEPARATED BY space.
* IF l_varuom <> v_waers.
* WRITE : l_varuom TO l_uom.
* ELSE.
* WRITE : v_waers TO l_uom.
* ENDIF.
* CONCATENATE l_svar l_uom INTO wa_nodestab-text4
* SEPARATED BY space.
*
* CONCATENATE l_svarp c_perc INTO wa_nodestab-text5
* SEPARATED BY space.
*
* wa_nodestab-tcolor = c_3.
* wa_nodestab-tcolor1 = c_3.
* wa_nodestab-tcolor2 = c_3.
* wa_nodestab-tcolor3 = c_3.
* wa_nodestab-tcolor4 = c_3.
* wa_nodestab-tcolor5 = c_3.
*
* APPEND wa_nodestab TO i_nodestab.
* CLEAR : wa_nodestab.
*
* IF l_aqty CA '123456789'.
* IF l_total1 <> c_x.
* l_total1 = c_x.
* l_wa_mat-actuom = l_matuom.
* ENDIF.
*
* IF l_wa_mat-actuom <> l_matuom.
* CLEAR : l_wa_mat-actusg, l_wa_mat-astprs, l_wa_mat-actuom,
* l_aqtys, l_amenge,
* l_wa_matg-actusg, l_wa_matg-astprs, l_wa_matg-actuom,
* l_aqtyg, l_astprs.
* ENDIF.
* ENDIF.
*
* IF l_sqty CA '123456789'.
* IF l_total2 <> c_x.
* l_total2 = c_x.
* l_wa_mat-stduom = l_stduom.
* ENDIF.
*
* IF l_wa_mat-stduom <> l_stduom.
* CLEAR : l_wa_mat-stdusg, l_wa_mat-sstprs, l_wa_mat-stduom,
* l_sqtys, l_smenge, l_wa_matg-stdusg,
* l_wa_matg-sstprs, l_wa_matg-stduom,
* l_sqtyg, l_sstprs.
* ENDIF.
* ENDIF.
*
* IF l_svar CA '123456789'.
* IF l_total3 <> c_x.
* l_total3 = c_x.
* l_wa_mat-varuom = l_varuom.
* ENDIF.
*
* IF l_wa_mat-varuom <> l_varuom.
* CLEAR : l_wa_mat-stdvar , l_wa_mat-varprs , l_wa_mat-varuom
* l_svars, wa_h_mat-stdvar,
* l_wa_matg-stdvar, l_wa_matg-varprs , l_wa_matg-varuom
* l_svarg, wa_h_mat-vstprs.
* ENDIF.
* ENDIF.
*
* CASE c_x.
* WHEN rb_quant.
* l_wa_mat-actusg = l_wa_mat-actusg + l_amenge.
* WRITE l_wa_mat-actusg TO l_aqtys UNIT l_wa_mat-actuom
* NO-GROUPING.
*
* l_wa_mat-stdusg = l_wa_mat-stdusg + l_smenge.
* WRITE l_wa_mat-stdusg TO l_sqtys UNIT l_wa_mat-stduom
* NO-GROUPING.
*
* l_wa_mat-stdvar = l_wa_mat-stdvar + wa_h_mat-stdvar.
* WRITE : l_wa_mat-stdvar TO l_svars UNIT l_wa_mat-stduom
* NO-GROUPING.
*
* WHEN rb_fiscl.
* l_wa_mat-astprs = l_wa_mat-astprs + l_astprs.
* v_prs = l_wa_mat-astprs.
* WRITE v_prs TO l_aqtys CURRENCY v_waers NO-GROUPING.
*
* l_wa_mat-varprs = l_wa_mat-varprs + wa_h_mat-vstprs.
* v_prs = l_wa_mat-varprs.
* WRITE v_prs TO l_svars CURRENCY v_waers NO-GROUPING.
*
* l_wa_mat-sstprs = l_wa_mat-sstprs + l_sstprs.
* v_prs = l_wa_mat-sstprs.
* WRITE v_prs TO l_sqtys CURRENCY v_waers NO-GROUPING.
* ENDCASE.
* ENDLOOP.
*
**** Displaying Material Subtotals
* CLEAR wa_nodestab.
* wa_nodestab-id = c_4_2.
* wa_nodestab-tlevel = c_4.
* wa_nodestab-parent = c_3_3.
*
* wa_nodestab-text = 'Material Totals'(043).
* wa_nodestab-text1 = space.
*
* wa_nodestab-tlength = c_18.
* wa_nodestab-tlength1 = c_30.
* wa_nodestab-tlength2 = c_22.
* wa_nodestab-tlength3 = c_22.
* wa_nodestab-tlength4 = c_24.
*
* IF l_wa_mat-actuom <> v_waers.
* WRITE : l_wa_mat-actuom TO l_uom.
* ELSE.
* WRITE : v_waers TO l_uom.
* ENDIF.
* CONCATENATE l_aqtys l_uom INTO wa_nodestab-text2
* SEPARATED BY space.
* IF l_wa_mat-stduom <> v_waers.
* WRITE : l_wa_mat-stduom TO l_uom.
* ELSE.
* WRITE : v_waers TO l_uom.
* ENDIF.
* CONCATENATE l_sqtys l_uom INTO wa_nodestab-text3
* SEPARATED BY space.
*
* IF l_wa_mat-varuom <> v_waers.
* WRITE : l_wa_mat-varuom TO l_uom.
* ELSE.
* WRITE : v_waers TO l_uom.
* ENDIF.
* CONCATENATE l_svars l_uom INTO wa_nodestab-text4
* SEPARATED BY space.
* wa_nodestab-tcolor = c_6.
* wa_nodestab-tcolor1 = c_6.
* wa_nodestab-tcolor2 = c_6.
* wa_nodestab-tcolor3 = c_6.
* wa_nodestab-tcolor4 = c_6.
*
* APPEND wa_nodestab TO i_nodestab.
* CLEAR : wa_nodestab.
*
* IF l_aqtys CA '123456789'.
* IF l_totalg1 <> c_x.
* l_totalg1 = c_x.
* l_wa_matg-actuom = l_wa_mat-actuom.
* ENDIF.
*
* IF l_wa_matg-actuom <> l_wa_mat-actuom.
* CLEAR : l_wa_matg-actusg , l_wa_matg-astprs , l_wa_matg-actuom,
* l_aqtyg, l_wa_mat-actusg, l_wa_mat-astprs.
* ENDIF.
* ENDIF.
*
* IF l_sqtys CA '123456789'.
* IF l_totalg2 <> c_x.
* l_totalg2 = c_x.
* l_wa_matg-stduom = l_wa_mat-stduom.
* ENDIF.
*
* IF l_wa_matg-stduom <> l_wa_mat-stduom.
* CLEAR : l_wa_matg-stdusg , l_wa_matg-stduom , l_wa_matg-sstprs
* l_sqtyg, l_wa_mat-stdusg, l_wa_mat-sstprs.
* ENDIF.
* ENDIF.
*
* IF l_svars CA '123456789'.
* IF l_totalg3 <> c_x.
* l_totalg3 = c_x.
* l_wa_matg-varuom = l_wa_mat-varuom.
* ENDIF.
*
* IF l_wa_matg-varuom <> l_wa_mat-varuom.
* CLEAR : l_wa_matg-stdvar, l_wa_matg-varprs , l_wa_matg-varuom,
* l_svarg, l_wa_mat-stdvar, l_wa_mat-varprs.
* ENDIF.
* ENDIF.
*
* CASE c_x.
* WHEN rb_quant.
* l_wa_matg-actusg = l_wa_matg-actusg + l_wa_mat-actusg.
* WRITE : l_wa_matg-actusg TO l_aqtyg UNIT l_wa_mat-actuom
* NO-GROUPING.
*
* l_wa_matg-stdusg = l_wa_matg-stdusg + l_wa_mat-stdusg.
* WRITE : l_wa_matg-stdusg TO l_sqtyg UNIT l_wa_mat-stduom
* NO-GROUPING.
*
* l_wa_matg-stdvar = l_wa_matg-stdvar + l_wa_mat-stdvar.
* WRITE : l_wa_matg-stdvar TO l_svarg UNIT l_wa_mat-varuom
* NO-GROUPING.
*
* WHEN rb_fiscl.
* l_wa_matg-astprs = l_wa_matg-astprs + l_wa_mat-astprs
* + l_wa_act-actu.
** + l_wa_act-actu * 10. "NEEL++ 13/07/2005++
* v_prs = l_wa_matg-astprs.
* WRITE v_prs TO l_aqtyg CURRENCY v_waers NO-GROUPING.
*
* l_wa_matg-sstprs = l_wa_matg-sstprs + l_wa_mat-sstprs
* + l_wa_act-stdu.
** + l_wa_act-stdu * 10. "NEEL++ 13/07/2005++
*
* v_prs = l_wa_matg-sstprs.
* WRITE v_prs TO l_sqtyg CURRENCY v_waers NO-GROUPING.
*
* l_wa_matg-varprs = l_wa_matg-varprs + l_wa_mat-varprs
* + l_wa_act-varu.
** + l_wa_act-varu * 10. "NEEL++ 13/07/2005++
*
* v_prs = l_wa_matg-varprs.
* WRITE v_prs TO l_svarg CURRENCY v_waers NO-GROUPING.
* ENDCASE.
*
* CLEAR : l_sqtys , l_aqtys , l_svars.
*
**** Displaying Grand Total
* AT LAST.
* CLEAR wa_nodestab.
* wa_nodestab-id = c_2_2.
* wa_nodestab-tlevel = c_2.
* wa_nodestab-parent = c_1_1.
*
* wa_nodestab-text = 'Process Order Totals'(044).
* wa_nodestab-text1 = space.
*
* wa_nodestab-tlength = c_26.
* wa_nodestab-tlength1 = c_30.
* wa_nodestab-tlength2 = c_22.
* wa_nodestab-tlength3 = c_22.
* wa_nodestab-tlength4 = c_24.
*
* IF l_wa_matg-actuom <> v_waers.
* WRITE : l_wa_matg-actuom TO l_uom.
* ELSE.
* WRITE : v_waers TO l_uom.
* ENDIF.
* CONCATENATE l_aqtyg l_uom INTO wa_nodestab-text2
* SEPARATED BY space.
*
* IF l_wa_matg-stduom <> v_waers.
* WRITE : l_wa_matg-stduom TO l_uom.
* ELSE.
* WRITE : v_waers TO l_uom.
* ENDIF.
* CONCATENATE l_sqtyg l_uom INTO wa_nodestab-text3
* SEPARATED BY space.
*
* IF l_wa_matg-varuom <> v_waers.
* WRITE : l_wa_matg-varuom TO l_uom.
* ELSE.
* WRITE : v_waers TO l_uom.
* ENDIF.
* CONCATENATE l_svarg l_uom INTO wa_nodestab-text4
* SEPARATED BY space.
* wa_nodestab-tcolor = c_5.
* wa_nodestab-tcolor1 = c_5.
* wa_nodestab-tcolor2 = c_5.
* wa_nodestab-tcolor3 = c_5.
* wa_nodestab-tcolor4 = c_5.
*
* APPEND wa_nodestab TO i_nodestab.
* ENDAT.
* ENDLOOP.
*ENDFORM. " DISPLAY_DETAIL_REPORT
*
**&--------------------------------------------------------------------*
**& Form display_phase_report
**&--------------------------------------------------------------------*
** text
**---------------------------------------------------------------------*
*FORM display_phase_report.
*
* DATA: l_date_low(10) TYPE c,
* l_date_high(10) TYPE c,
*
* l_effic TYPE char16,
* l_arbpl TYPE arbpl,
*
* l_prdqty TYPE gamng,
* l_prdq TYPE char18,
* l_wprdqty TYPE menge_d,
* l_prduom TYPE meins,
*
* l_act TYPE char16,
* l_std TYPE char16,
*
* l_amenge TYPE menge_d,
* l_smenge TYPE menge_d,
* l_menge TYPE menge_d,
*
* l_aqty TYPE char18,
* l_sqty TYPE char18,
* l_svar TYPE char18,
* l_svarp TYPE char18,
*
* l_aqtys TYPE char18,
* l_sqtys TYPE char18,
* l_svars TYPE char18,
*
* l_matuom TYPE meins,
* l_stduom TYPE meins,
* l_varuom TYPE meins,
* l_uom TYPE meins,
*
* l_astprs TYPE ty_stprs,
* l_sstprs TYPE ty_stprs,
* l_stprs TYPE ty_stprs,
*
* l_total1 TYPE char1,
* l_total2 TYPE char1,
* l_total3 TYPE char1,
*
* l_wa_act TYPE ty_hier_act,
* l_wa_mat TYPE ty_hier_mat_sum,
* l_wa_phs TYPE ty_hier_phase,
* l_i_phs TYPE STANDARD TABLE OF ty_hier_phase.
*
* PERFORM pfstatus.
* SET PF-STATUS 'MAIN' EXCLUDING i_fcode.
* SET TITLEBAR 'VARI' WITH text-068.
*
* l_i_phs = i_h_phs.
*
* SORT i_h_phs BY aufnr arbpl vornr.
*
* CLEAR wa_nodestab.
* REFRESH i_nodestab.
*
* MOVE 'Display Phase Report'(030) TO v_output_text.
* PERFORM inform_user_of_progress.
*
* CLEAR wa_nodestab.
* wa_nodestab-id = c_1_1.
* wa_nodestab-tlevel = c_1.
* wa_nodestab-text = 'Production Variances'(031).
* wa_nodestab-tlength = c_20.
* wa_nodestab-compress = c_x.
* APPEND wa_nodestab TO i_nodestab.
*
* LOOP AT i_h_ord INTO wa_h_ord.
*
* CLEAR: wa_nodestab, l_date_low, l_date_high.
*
* wa_nodestab-id = c_2_1.
* wa_nodestab-tlevel = c_2.
* wa_nodestab-parent = c_1_1.
*
** Order Number text
* wa_nodestab-text = 'Order Num:'(032).
* wa_nodestab-tlength = c_12.
* wa_nodestab-tcolor = c_1.
*
** Order number
* WRITE wa_h_ord-aufnr TO wa_nodestab-text1 NO-ZERO.
* wa_nodestab-tlength1 = c_12.
* wa_nodestab-tcolor1 = c_1.
*
** Date Range
* WRITE wa_h_ord-gstrp TO l_date_low.
* WRITE wa_h_ord-gltrp TO l_date_high.
* CONCATENATE l_date_low c_hyp l_date_high INTO wa_nodestab-text2
* SEPARATED BY space.
* wa_nodestab-tlength2 = c_25.
* wa_nodestab-tcolor2 = c_1.
*
** Material Number
* WRITE wa_h_ord-plnbez TO wa_nodestab-text3 NO-ZERO.
* wa_nodestab-tlength3 = c_18.
* wa_nodestab-tcolor3 = c_1.
*
** Material Description
* wa_nodestab-text4 = wa_h_ord-maktx.
* wa_nodestab-tlength4 = c_33.
* wa_nodestab-tcolor4 = c_1.
*
* APPEND wa_nodestab TO i_nodestab.
*
* CLEAR : l_aqtys, l_sqtys, l_svars, l_arbpl.
* LOOP AT i_h_phs INTO wa_h_phs WHERE aufnr = wa_h_ord-aufnr.
* l_wa_phs = wa_h_phs.
*
* IF l_arbpl <> wa_h_phs-arbpl.
* CLEAR : wa_h_phs.
* READ TABLE i_h_phs INTO wa_h_phs
* WITH KEY aufnr = wa_h_ord-aufnr
* arbpl = l_wa_phs-arbpl
* steus = 'YBN1'
* runtime = c_x.
** Resource Information
* CLEAR : wa_nodestab.
* wa_nodestab-id = c_3_1.
* wa_nodestab-tlevel = c_3.
* wa_nodestab-parent = c_2_1.
*
* wa_nodestab-text = 'Resource:'(035).
* wa_nodestab-tlength = c_14.
* wa_nodestab-tcolor = c_4.
*
* wa_nodestab-text1 = l_wa_phs-arbpl.
* wa_nodestab-tlength1 = c_8.
* wa_nodestab-tcolor1 = c_4.
*
* wa_nodestab-text2 = l_wa_phs-ktext.
* wa_nodestab-tlength2 = c_37.
* wa_nodestab-tcolor2 = c_4.
*
* IF l_wa_phs-steus = 'YBN1'.
* l_effic = wa_h_phs-el_effc.
* CONCATENATE 'Exp. Line Eff.'(036) l_effic c_perc
* INTO wa_nodestab-text3 SEPARATED BY space.
* CONDENSE wa_nodestab-text3.
* wa_nodestab-tlength3 = c_30.
* wa_nodestab-tcolor3 = c_4.
*
* l_effic = wa_h_phs-ac_effc.
* CONCATENATE 'Act. Line Eff.'(037) l_effic c_perc
* INTO wa_nodestab-text4 SEPARATED BY space.
* CONDENSE wa_nodestab-text4.
* wa_nodestab-tlength4 = c_30.
* wa_nodestab-tcolor4 = c_4.
* ENDIF.
* APPEND wa_nodestab TO i_nodestab.
*
* l_arbpl = l_wa_phs-arbpl.
* wa_h_phs = l_wa_phs.
* ENDIF.
*
* CLEAR : wa_nodestab.
* wa_nodestab-id = c_4_1.
* wa_nodestab-tlevel = c_4.
* wa_nodestab-parent = c_3_1.
*** Phase Number
* wa_nodestab-text = 'Phase'(038).
* wa_nodestab-tlength = c_10.
* wa_nodestab-tcolor = c_4.
*
* CONCATENATE wa_h_phs-vornr wa_h_phs-steus
* wa_h_phs-ltxa1
* INTO wa_nodestab-text1
* SEPARATED BY space.
* wa_nodestab-tlength1 = c_40.
* wa_nodestab-tcolor1 = c_4.
*
*** PO Quantity
** l_prdqty = wa_h_phs-lmnga.
* l_prdqty = wa_h_phs-prdqty.
* l_prduom = wa_h_phs-prduom.
*
* IF rb_kgm = c_x AND l_prduom <> 'KG'.
* IF wa_h_phs-bsuom <> 'KG'.
* PERFORM convert_to_kg USING wa_h_ord-plnbez wa_h_phs-bsuom
* wa_h_phs-gewei wa_h_phs-ntgew
* wa_h_phs-bprdqty
* CHANGING l_wprdqty
* v_conv_rc.
* IF v_conv_rc <> 'X'.
* l_prdqty = l_wprdqty.
* l_prduom = 'KG'.
* ENDIF.
*
* ELSE.
* l_prdqty = wa_h_phs-bprdqty.
* l_prduom = 'KG'.
* ENDIF.
* ENDIF.
*
* WRITE : l_prdqty TO l_prdq UNIT l_prduom NO-GROUPING,
* l_prduom TO l_uom.
*
**** text for Order Qty
* IF rb_pland = c_x.
*** Planned Production
* CONCATENATE 'Plan Qty:'(076) l_prdq l_uom
* INTO wa_nodestab-text2 SEPARATED BY space.
* ELSE.
*** Actual Production
* IF rb_prod = c_x.
** Produced
* CONCATENATE 'Prod Qty:'(033) l_prdq l_uom
* INTO wa_nodestab-text2 SEPARATED BY space.
* ELSE.
** Confirmed
* CONCATENATE 'Conf Qty:'(034) l_prdq l_uom
* INTO wa_nodestab-text2 SEPARATED BY space.
* ENDIF.
* ENDIF.
*
* CONDENSE : wa_nodestab-text2.
*
* wa_nodestab-tlength2 = 32.
* wa_nodestab-tcolor2 = c_4.
* APPEND wa_nodestab TO i_nodestab.
****
**** Activity Information
****
* CLEAR wa_nodestab.
* wa_nodestab-id = c_5_1.
* wa_nodestab-tlevel = c_5.
* wa_nodestab-parent = c_4_1.
*
* wa_nodestab-text = 'Activity'(052).
* wa_nodestab-tlength = 34.
*
* wa_nodestab-text1 = 'Actual Usage'(040).
* wa_nodestab-tlength1 = c_20.
*
* wa_nodestab-text2 = 'Standard Usage'(041).
* wa_nodestab-tlength2 = c_20.
*
* IF rb_fiscl = c_x.
* CONCATENATE 'Standard Usage Var'(042) v_waers
* INTO wa_nodestab-text3 SEPARATED BY space.
* ELSE.
* CONCATENATE 'Standard Usage Var'(042) 'UoM'
* INTO wa_nodestab-text3 SEPARATED BY space.
* ENDIF.
* wa_nodestab-tlength3 = c_24.
*
* CONCATENATE 'Standard Usage Var'(042) c_perc
* INTO wa_nodestab-text4 SEPARATED BY space.
* wa_nodestab-tlength4 = c_20.
*
* wa_nodestab-tcolor = c_4.
* wa_nodestab-tcolor1 = c_4.
* wa_nodestab-tcolor2 = c_4.
* wa_nodestab-tcolor3 = c_4.
* wa_nodestab-tcolor4 = c_4.
*
* APPEND wa_nodestab TO i_nodestab.
*
* CLEAR : flg_color , l_act , l_std , l_svar , l_svarp , l_wa_act,
* l_total1 , l_total2.
* LOOP AT i_h_act INTO wa_h_act WHERE aufnr = wa_h_phs-aufnr
* AND aufpl = wa_h_phs-aufpl
* AND aplzl = wa_h_phs-aplzl
* AND vornr = wa_h_phs-vornr.
* CLEAR : wa_nodestab.
* wa_nodestab-id = c_6_1.
* wa_nodestab-tlevel = c_6.
* wa_nodestab-parent = c_5_1.
*
* wa_nodestab-text = wa_h_act-txtxx.
* wa_nodestab-tlength = c_30.
* wa_nodestab-tlength1 = c_20.
* wa_nodestab-tlength2 = c_20.
* wa_nodestab-tlength3 = c_24.
* wa_nodestab-tlength4 = c_20.
*
* IF rb_quant = c_x.
* WRITE : wa_h_act-ismxx TO l_act UNIT wa_h_act-ilexx
* NO-GROUPING,
* wa_h_act-ilexx TO l_uom.
* CONCATENATE l_act l_uom INTO wa_nodestab-text1
* SEPARATED BY space.
*
* WRITE : wa_h_act-vgwxx TO l_std UNIT wa_h_act-vgexx
* NO-GROUPING,
* wa_h_act-vgexx TO l_uom.
* CONCATENATE l_std l_uom INTO wa_nodestab-text2
* SEPARATED BY space.
*
* WRITE wa_h_act-stdvar TO l_svar UNIT wa_h_act-vgexx
* NO-GROUPING.
* CONCATENATE l_svar l_uom INTO wa_nodestab-text3
* SEPARATED BY space.
* IF wa_h_act-ismxx <> 0.
* IF l_total2 <> c_x.
* l_total2 = c_x.
* l_wa_act-ilexx = wa_h_act-ilexx.
* ENDIF.
*
* IF l_wa_act-ilexx = wa_h_act-ilexx.
* l_wa_act-ismxx = l_wa_act-ismxx + wa_h_act-ismxx.
* l_wa_act-ilexx = wa_h_act-ilexx.
*
* ELSEIF wa_h_act-ismxx <> 0.
* CLEAR : l_wa_act-ismxx , l_wa_act-ilexx.
* ENDIF.
* ENDIF.
*
* IF wa_h_act-vgwxx <> 0.
* IF l_total1 <> c_x.
* l_total1 = c_x.
* l_wa_act-vgexx = wa_h_act-vgexx.
* ENDIF.
*
* IF l_wa_act-vgexx = wa_h_act-vgexx.
* l_wa_act-vgwxx = l_wa_act-vgwxx + wa_h_act-vgwxx.
* l_wa_act-stdvar = l_wa_act-stdvar + wa_h_act-stdvar.
* l_wa_act-vgexx = wa_h_act-vgexx.
*
* ELSEIF wa_h_act-vgwxx <> 0.
* CLEAR : l_wa_act-vgwxx , l_wa_act-vgexx, l_wa_act-stdvar.
* ENDIF.
* ENDIF.
*
* IF wa_h_act-vgwxx <> 0.
* wa_h_act-varper = ( wa_h_act-stdvar / wa_h_act-vgwxx ) * 100
* .
* ENDIF.
*
* ELSE.
*
* wa_h_act-actu = wa_h_act-ismxx * ( wa_h_act-togxx /
* wa_h_act-toexx ).
*
* WRITE : wa_h_act-actu TO l_act CURRENCY v_waers NO-GROUPING,
* v_waers TO l_uom.
* CONCATENATE l_act l_uom INTO wa_nodestab-text1
* SEPARATED BY space.
*
* wa_h_act-stdu = wa_h_act-vgwxx *
* ( wa_h_act-togxx / wa_h_act-toexx ).
*
* WRITE wa_h_act-stdu TO l_std CURRENCY v_waers NO-GROUPING.
* CONCATENATE l_std l_uom INTO wa_nodestab-text2
* SEPARATED BY space.
*
* wa_h_act-varu = wa_h_act-stdvar *
* ( wa_h_act-togxx / wa_h_act-toexx ).
*
* WRITE wa_h_act-varu TO l_svar CURRENCY v_waers NO-GROUPING.
* CONCATENATE l_svar l_uom INTO wa_nodestab-text3
* SEPARATED BY space.
* IF wa_h_act-stdu <> 0.
* wa_h_act-varper = ( wa_h_act-varu / wa_h_act-stdu ) * 100.
* ENDIF.
*
* l_wa_act-actu = l_wa_act-actu + wa_h_act-actu.
* l_wa_act-stdu = l_wa_act-stdu + wa_h_act-stdu.
* l_wa_act-varu = l_wa_act-varu + wa_h_act-varu.
* ENDIF.
*
* WRITE wa_h_act-varper TO l_svarp NO-GROUPING DECIMALS 2.
* CONCATENATE l_svarp c_perc INTO wa_nodestab-text4
* SEPARATED BY space.
* IF flg_color = c_x.
* CLEAR flg_color.
* wa_nodestab-tcolor = c_3.
* wa_nodestab-tcolor1 = c_3.
* wa_nodestab-tcolor2 = c_3.
* wa_nodestab-tcolor3 = c_3.
* wa_nodestab-tcolor4 = c_3.
* wa_nodestab-tcolor5 = c_3.
* wa_nodestab-tcolor6 = c_3.
* wa_nodestab-tcolor7 = c_3.
* wa_nodestab-tcolor8 = c_3.
* ELSE.
* flg_color = c_x.
* wa_nodestab-tcolor = c_2.
* wa_nodestab-tcolor1 = c_2.
* wa_nodestab-tcolor2 = c_2.
* wa_nodestab-tcolor3 = c_2.
* wa_nodestab-tcolor4 = c_2.
* wa_nodestab-tcolor5 = c_2.
* wa_nodestab-tcolor6 = c_2.
* wa_nodestab-tcolor7 = c_2.
* wa_nodestab-tcolor8 = c_2.
* ENDIF.
*
* APPEND wa_nodestab TO i_nodestab.
* ENDLOOP.
**** Displaying Activity Subtotals
* CLEAR wa_nodestab.
* wa_nodestab-id = c_6_1.
* wa_nodestab-tlevel = c_6.
* wa_nodestab-parent = c_5_1.
*
* wa_nodestab-text = 'Activity Totals'(074).
* wa_nodestab-tlength = c_30.
* wa_nodestab-tcolor = c_6.
*
* IF rb_quant = c_x.
* WRITE : l_wa_act-ismxx TO l_act UNIT l_wa_act-ilexx NO-GROUPING
* l_wa_act-ilexx TO l_uom.
* CONCATENATE l_act l_uom INTO wa_nodestab-text1
* SEPARATED BY space.
*
* WRITE : l_wa_act-vgwxx TO l_std UNIT l_wa_act-vgexx NO-GROUPING
* l_wa_act-vgexx TO l_uom.
* CONCATENATE l_std l_uom INTO wa_nodestab-text2
* SEPARATED BY space.
*
* WRITE : l_wa_act-stdvar TO l_svar UNIT l_wa_act-vgexx
* NO-GROUPING.
* CONCATENATE l_svar l_uom INTO wa_nodestab-text3
* SEPARATED BY space.
*
* ELSE.
* WRITE : l_wa_act-actu TO l_act CURRENCY v_waers NO-GROUPING,
* v_waers TO l_uom.
* CONCATENATE l_act l_uom INTO wa_nodestab-text1
* SEPARATED BY space.
*
* WRITE : l_wa_act-stdu TO l_std CURRENCY v_waers NO-GROUPING.
* CONCATENATE l_std l_uom INTO wa_nodestab-text2
* SEPARATED BY space.
*
* WRITE : l_wa_act-varu TO l_svar UNIT l_wa_act-vgexx NO-GROUPING
  .
* CONCATENATE l_svar l_uom INTO wa_nodestab-text3
* SEPARATED BY space.
* ENDIF.
*
* wa_nodestab-tlength1 = c_20.
* wa_nodestab-tlength2 = c_20.
* wa_nodestab-tlength3 = c_24.
*
* wa_nodestab-tcolor1 = c_6.
* wa_nodestab-tcolor2 = c_6.
* wa_nodestab-tcolor3 = c_6.
* APPEND wa_nodestab TO i_nodestab.
* CLEAR : wa_nodestab.
*
****
**** Material Information
****
* READ TABLE i_h_mat INTO wa_h_mat WITH KEY aufnr = wa_h_phs-aufnr
* aufpl = wa_h_phs-aufpl
* aplzl = wa_h_phs-aplzl
* vornr = wa_h_phs-vornr.
* CHECK sy-subrc = 0.
*
* CLEAR : wa_nodestab.
* wa_nodestab-id = c_5_2.
* wa_nodestab-tlevel = c_5.
* wa_nodestab-parent = c_4_1.
* PERFORM material_header USING wa_nodestab.
*
* APPEND wa_nodestab TO i_nodestab.
*
* CLEAR : wa_nodestab , l_menge , l_stprs ,
* l_total1 , l_total2 , l_total3 ,
* l_wa_mat , l_aqtys , l_sqtys , l_svars.
* LOOP AT i_h_mat INTO wa_h_mat WHERE aufnr = wa_h_phs-aufnr
* AND aufpl = wa_h_phs-aufpl
* AND aplzl = wa_h_phs-aplzl
* AND vornr = wa_h_phs-vornr.
* l_smenge = l_menge.
* l_sstprs = l_stprs.
* PERFORM do_mat_calc CHANGING wa_h_mat
* l_aqty l_matuom
* l_sqty l_stduom
* l_svar l_varuom
* l_svarp
* l_amenge l_smenge
* l_astprs l_sstprs.
* l_menge = l_menge + l_smenge.
* l_stprs = l_stprs + l_sstprs.
*
* CHECK wa_h_mat-sumi = c_x.
*
* CLEAR: wa_nodestab , l_menge , l_stprs.
* wa_nodestab-id = c_6_2.
* wa_nodestab-tlevel = c_6.
* wa_nodestab-parent = c_5_2.
** Material Number
* WRITE wa_h_mat-matnr TO wa_nodestab-text NO-ZERO.
** Material Description
* wa_nodestab-text1 = wa_h_mat-maktx.
*
* wa_nodestab-tlength = c_18.
* wa_nodestab-tlength1 = c_30.
* wa_nodestab-tlength2 = c_22.
* wa_nodestab-tlength3 = c_22.
* wa_nodestab-tlength4 = c_24.
* wa_nodestab-tlength5 = c_20.
*
* IF l_matuom <> v_waers.
* WRITE : l_matuom TO l_uom.
* ELSE.
* WRITE : v_waers TO l_uom.
* ENDIF.
* CONCATENATE l_aqty l_uom INTO wa_nodestab-text2
* SEPARATED BY space.
*
* IF l_stduom <> v_waers.
* WRITE : l_stduom TO l_uom.
* ELSE.
* WRITE : v_waers TO l_uom.
* ENDIF.
* CONCATENATE l_sqty l_uom INTO wa_nodestab-text3
* SEPARATED BY space.
*
* IF l_varuom <> v_waers.
* WRITE : l_varuom TO l_uom.
* ELSE.
* WRITE : v_waers TO l_uom.
* ENDIF.
* CONCATENATE l_svar l_uom INTO wa_nodestab-text4
* SEPARATED BY space.
*
* CONCATENATE l_svarp c_perc INTO wa_nodestab-text5
* SEPARATED BY space.
* wa_nodestab-tcolor = c_3.
* wa_nodestab-tcolor1 = c_3.
* wa_nodestab-tcolor2 = c_3.
* wa_nodestab-tcolor3 = c_3.
* wa_nodestab-tcolor4 = c_3.
* wa_nodestab-tcolor5 = c_3.
*
* APPEND wa_nodestab TO i_nodestab.
*
* IF l_aqty CA '123456789'.
* IF l_total1 <> c_x.
* l_total1 = c_x.
* l_wa_mat-actuom = l_matuom.
* ENDIF.
*
* IF l_wa_mat-actuom <> l_matuom.
* CLEAR : l_wa_mat-actusg , l_wa_mat-astprs , l_wa_mat-actuom
* l_aqtys, l_amenge , l_astprs.
* ENDIF.
* ENDIF.
*
* IF l_sqty CA '123456789'.
* IF l_total2 <> c_x.
* l_total2 = c_x.
* l_wa_mat-stduom = l_stduom.
* ENDIF.
*
* IF l_wa_mat-stduom <> l_stduom.
* CLEAR : l_wa_mat-stdusg , l_wa_mat-sstprs ,
* l_wa_mat-stduom ,
* l_sqtys, l_smenge , l_sstprs.
* ENDIF.
* ENDIF.
*
* IF l_svar CA '123456789'.
* IF l_total3 <> c_x.
* l_total3 = c_x.
* l_wa_mat-varuom = l_varuom.
* ENDIF.
*
* IF l_wa_mat-varuom <> l_varuom.
* CLEAR : l_wa_mat-stdvar, l_wa_mat-varprs , l_wa_mat-varuom,
* l_svars, wa_h_mat-vstprs , wa_h_mat-stdvar.
* ENDIF.
* ENDIF.
*
* CASE c_x.
* WHEN rb_quant.
* l_wa_mat-actusg = l_wa_mat-actusg + l_amenge.
* WRITE l_wa_mat-actusg TO l_aqtys UNIT l_wa_mat-actuom
* NO-GROUPING.
*
* l_wa_mat-stdusg = l_wa_mat-stdusg + l_smenge.
* WRITE l_wa_mat-stdusg TO l_sqtys UNIT l_wa_mat-stduom
* NO-GROUPING.
*
* l_wa_mat-stdvar = l_wa_mat-stdvar + wa_h_mat-stdvar.
* WRITE : l_wa_mat-stdvar TO l_svars UNIT l_wa_mat-stduom
* NO-GROUPING.
*
* WHEN rb_fiscl.
* l_wa_mat-astprs = l_wa_mat-astprs + l_astprs.
* v_prs = l_wa_mat-astprs.
* WRITE v_prs TO l_aqtys CURRENCY v_waers NO-GROUPING.
*
* l_wa_mat-sstprs = l_wa_mat-sstprs + l_sstprs.
* v_prs = l_wa_mat-sstprs.
* WRITE v_prs TO l_sqtys CURRENCY v_waers NO-GROUPING.
*
* l_wa_mat-varprs = l_wa_mat-varprs + wa_h_mat-vstprs.
* v_prs = l_wa_mat-varprs.
* WRITE v_prs TO l_svars CURRENCY v_waers NO-GROUPING.
* ENDCASE.
* ENDLOOP.
**** Displaying Material Subtotals
* CLEAR wa_nodestab.
* wa_nodestab-id = c_6_2.
* wa_nodestab-tlevel = c_6.
* wa_nodestab-parent = c_5_2.
*
* wa_nodestab-text = 'Material Totals'(043).
* wa_nodestab-text1 = space.
*
* wa_nodestab-tlength = c_18.
* wa_nodestab-tlength1 = c_30.
* wa_nodestab-tlength2 = c_22.
* wa_nodestab-tlength3 = c_22.
* wa_nodestab-tlength4 = c_24.
*
* IF l_wa_mat-actuom <> v_waers.
* WRITE : l_wa_mat-actuom TO l_uom.
* ELSE.
* WRITE : v_waers TO l_uom.
* ENDIF.
* CONCATENATE l_aqtys l_uom INTO wa_nodestab-text2
* SEPARATED BY space.
*
* IF l_wa_mat-stduom <> v_waers.
* WRITE : l_wa_mat-stduom TO l_uom.
* ELSE.
* WRITE : v_waers TO l_uom.
* ENDIF.
* CONCATENATE l_sqtys l_uom INTO wa_nodestab-text3
* SEPARATED BY space.
*
* IF l_wa_mat-varuom <> v_waers.
* WRITE : l_wa_mat-varuom TO l_uom.
* ELSE.
* WRITE : v_waers TO l_uom.
* ENDIF.
* CONCATENATE l_svars l_uom INTO wa_nodestab-text4
* SEPARATED BY space.
* wa_nodestab-tcolor = c_6.
* wa_nodestab-tcolor1 = c_6.
* wa_nodestab-tcolor2 = c_6.
* wa_nodestab-tcolor3 = c_6.
* wa_nodestab-tcolor4 = c_6.
*
* APPEND wa_nodestab TO i_nodestab.
* CLEAR : wa_nodestab, l_aqtys, l_sqtys, l_svars.
* ENDLOOP.
* ENDLOOP.
*
* i_h_phs = l_i_phs.
*ENDFORM. " DISPLAY_PHASE_REPORT
*
**&--------------------------------------------------------------------*
**& Form display_summary_report
**&--------------------------------------------------------------------*
** text
**---------------------------------------------------------------------*
*FORM display_summary_report.
*
* DATA: l_prdqty TYPE gamng,
* l_prdq TYPE char18,
* l_wprdqty TYPE menge_d,
* l_tprdqty TYPE menge_d,
* l_prduom TYPE meins,
*
* l_act TYPE char16,
* l_std TYPE char16,
*
* l_actt TYPE char16,
* l_stdt TYPE char16,
* l_svart TYPE char18,
*
* l_amenge TYPE menge_d,
* l_smenge TYPE menge_d,
* l_menge TYPE menge_d,
*
* l_astprs TYPE ty_stprs,
* l_sstprs TYPE ty_stprs,
* l_stprs TYPE ty_stprs,
* l_stprsq TYPE ty_stprs,
* l_varprsq TYPE ty_stprs,
*
* l_matuom TYPE meins,
* l_stduom TYPE meins,
* l_varuom TYPE meins,
* l_uom TYPE meins,
*
* l_aqty TYPE char18,
* l_sqty TYPE char18,
* l_svar TYPE char18,
* l_svarp TYPE char18,
* l_svarq TYPE char18,
*
* l_aqtyv TYPE char18,
* l_sqtyv TYPE char18,
* l_svarv TYPE char18,
* l_svarpv TYPE char18,
*
* l_aqtyg TYPE char18,
* l_sqtyg TYPE char18,
* l_svarg TYPE char18,
* l_svargq TYPE char18,
*
* l_aqtys TYPE char18,
* l_sqtys TYPE char18,
* l_svars TYPE char18,
*
* l_total1 TYPE char1,
* l_total2 TYPE char1,
* l_total3 TYPE char1,
*
* l_totalg1 TYPE char1,
* l_totalg2 TYPE char1,
* l_totalg3 TYPE char1,
*
* l_wa_acts TYPE ty_hier_act_sum,
* l_wa_mats TYPE ty_hier_mat_sum.
*
* PERFORM pfstatus.
* SET PF-STATUS 'MAIN' EXCLUDING i_fcode.
* SET TITLEBAR 'VARI' WITH text-067.
*
* REFRESH : i_nodestab.
*
* MOVE 'Display Summary Report'(029) TO v_output_text.
* PERFORM inform_user_of_progress.
*
* CLEAR wa_nodestab.
* wa_nodestab-id = c_1_1.
* wa_nodestab-tlevel = c_1.
* wa_nodestab-text = 'Production Variances'(031).
* wa_nodestab-tlength = c_20.
* wa_nodestab-compress = c_x.
* APPEND wa_nodestab TO i_nodestab.
*
* CLEAR: wa_nodestab.
* wa_nodestab-id = c_2_1.
* wa_nodestab-tlevel = c_2.
* wa_nodestab-parent = c_1_1.
*
* CONCATENATE 'Summary of Orders for'(046) 'Plant:'(047) p_werks
* INTO wa_nodestab-text SEPARATED BY space.
* wa_nodestab-tlength = c_45.
* wa_nodestab-tcolor = c_1.
*
* IF r_steus IS INITIAL.
* wa_nodestab-text1 = 'Control Key : ALL'(075).
* ELSE.
* CLEAR : wa_steus.
* READ TABLE r_steus INTO wa_steus INDEX 1.
* CONCATENATE 'Control Key:'(048) wa_steus-low 'TO' wa_steus-high
* INTO wa_nodestab-text1 SEPARATED BY space.
* ENDIF.
* wa_nodestab-tlength1 = c_25.
* wa_nodestab-tcolor1 = c_1.
*
* IF s_arbpl[] IS INITIAL.
* wa_nodestab-text2 = 'Resources: All'(049).
* ELSE.
* CONCATENATE 'Resources:'(065) s_arbpl-low c_hyp s_arbpl-high
* INTO wa_nodestab-text2 SEPARATED BY space.
* ENDIF.
* wa_nodestab-tlength2 = c_25.
* wa_nodestab-tcolor2 = c_1.
*
* APPEND wa_nodestab TO i_nodestab.
*
* CLEAR : l_tprdqty.
* LOOP AT i_h_ord INTO wa_h_ord.
** convert to KG
* CLEAR : l_wprdqty.
* IF wa_h_ord-bsuom <> 'KG'.
* PERFORM convert_to_kg USING wa_h_ord-plnbez wa_h_ord-bsuom
* wa_h_ord-gewei wa_h_ord-ntgew
* wa_h_ord-bprdqty
* CHANGING l_wprdqty
* v_conv_rc.
* IF v_conv_rc <> 'X'.
* l_prdqty = l_wprdqty.
* l_prduom = 'KG'.
* ELSE.
* CLEAR : l_wprdqty.
* ENDIF.
*
* ELSE.
* l_prdqty = wa_h_ord-bprdqty.
* l_prduom = 'KG'.
* ENDIF.
*
* l_tprdqty = l_tprdqty + l_prdqty.
* ENDLOOP.
*
* WRITE : l_tprdqty TO l_prdq UNIT 'KG' NO-GROUPING.
*
* CLEAR : wa_nodestab.
* wa_nodestab-id = c_3_1.
* wa_nodestab-tlevel = c_3.
* wa_nodestab-parent = c_2_1.
*
**** text for Order Qty
* IF rb_pland = c_x.
*** Planned Production
* CONCATENATE 'Plan Qty:'(076) l_prdq 'KG'
* INTO wa_nodestab-text SEPARATED BY space.
* ELSE.
*** Actual Production
* IF rb_prod = c_x.
** Produced
* CONCATENATE 'Prod Qty:'(033) l_prdq 'KG'
* INTO wa_nodestab-text SEPARATED BY space.
* ELSE.
** Confirmed
* CONCATENATE 'Conf Qty:'(034) l_prdq 'KG'
* INTO wa_nodestab-text SEPARATED BY space.
* ENDIF.
* ENDIF.
*
* CONDENSE : wa_nodestab-text.
*
* wa_nodestab-tlength = c_35.
* wa_nodestab-tcolor = c_1.
*
* APPEND wa_nodestab TO i_nodestab.
*
****
**** Activity Summary
****
* CLEAR : wa_nodestab.
* wa_nodestab-id = c_3_2.
* wa_nodestab-tlevel = c_3.
* wa_nodestab-parent = c_2_1.
*
* wa_nodestab-text = 'Activity'(052).
* wa_nodestab-tlength = 34.
*
* wa_nodestab-tlength1 = c_20.
* wa_nodestab-tlength2 = c_20.
* wa_nodestab-tlength3 = c_24.
* wa_nodestab-tlength4 = c_20.
*
* IF rb_fiscl = c_x.
* CONCATENATE 'Actual Usage'(040) v_waers
* INTO wa_nodestab-text1 SEPARATED BY space.
*
* CONCATENATE 'Standard Usage'(041) v_waers
* INTO wa_nodestab-text2 SEPARATED BY space.
*
* CONCATENATE 'Standard Usage Var'(042) v_waers
* INTO wa_nodestab-text3 SEPARATED BY space.
*
* ELSE.
* CONCATENATE 'Actual Usage'(040) 'UoM'
* INTO wa_nodestab-text1 SEPARATED BY space.
*
* CONCATENATE 'Standard Usage'(041) 'UoM'
* INTO wa_nodestab-text2 SEPARATED BY space.
*
* CONCATENATE 'Standard Usage Var'(042) 'UoM'
* INTO wa_nodestab-text3 SEPARATED BY space.
*
* ENDIF.
*
* CONCATENATE 'Standard Usage Var'(042) c_perc
* INTO wa_nodestab-text4 SEPARATED BY space.
*
* wa_nodestab-tcolor = c_4.
* wa_nodestab-tcolor1 = c_4.
* wa_nodestab-tcolor2 = c_4.
* wa_nodestab-tcolor3 = c_4.
* wa_nodestab-tcolor4 = c_4.
* APPEND wa_nodestab TO i_nodestab.
*
* CLEAR : flg_color , l_actt , l_stdt , l_svart , l_svarp,
* l_wa_acts.
* LOOP AT i_parn INTO wa_parn.
* CLEAR : wa_acts, flg_color , l_act , l_std , l_svar , l_svarp.
* LOOP AT i_h_act INTO wa_h_act WHERE parxx = wa_parn-parxx.
* wa_acts-parxx = wa_h_act-parxx.
* wa_acts-txtxx = wa_h_act-txtxx.
*
* IF rb_quant EQ c_x.
* wa_acts-ilexx = wa_h_act-ilexx.
* wa_acts-ismxx = wa_acts-ismxx + wa_h_act-ismxx.
* wa_acts-vgexx = wa_h_act-vgexx.
* wa_acts-vgwxx = wa_acts-vgwxx + wa_h_act-vgwxx.
* wa_acts-stdvar = wa_acts-stdvar + wa_h_act-stdvar.
*
* IF wa_acts-ilexx IS INITIAL AND NOT wa_acts-vgexx IS INITIAL.
* wa_acts-ilexx = wa_acts-vgexx.
*
* ELSEIF NOT wa_acts-ilexx IS INITIAL AND
* wa_acts-vgexx IS INITIAL.
* wa_acts-vgexx = wa_acts-ilexx.
* ENDIF.
*
* ELSE.
*
* IF wa_h_act-toexx <> 0.
* wa_acts-actu = wa_acts-actu + wa_h_act-ismxx *
* ( wa_h_act-togxx / wa_h_act-toexx ).
* wa_acts-stdu = wa_acts-stdu + wa_h_act-vgwxx *
* ( wa_h_act-togxx / wa_h_act-toexx ).
* wa_acts-varu = wa_acts-varu + wa_h_act-stdvar *
* ( wa_h_act-togxx / wa_h_act-toexx ).
* ENDIF.
* ENDIF.
* ENDLOOP.
*
* CLEAR : wa_nodestab.
* wa_nodestab-id = c_4_1.
* wa_nodestab-tlevel = c_4.
* wa_nodestab-parent = c_3_2.
*
* wa_nodestab-text = wa_acts-txtxx.
* wa_nodestab-tlength = c_30.
* wa_nodestab-tlength1 = c_20.
* wa_nodestab-tlength2 = c_20.
* wa_nodestab-tlength3 = c_24.
* wa_nodestab-tlength4 = c_20.
*
* IF rb_quant = c_x.
* WRITE : wa_acts-ismxx TO l_act UNIT wa_acts-ilexx NO-GROUPING,
* wa_acts-ilexx TO l_uom.
* CONCATENATE l_act l_uom INTO wa_nodestab-text1
* SEPARATED BY space.
*
* WRITE : wa_acts-vgwxx TO l_std UNIT wa_acts-vgexx NO-GROUPING,
* wa_acts-vgexx TO l_uom.
* CONCATENATE l_std l_uom INTO wa_nodestab-text2
* SEPARATED BY space.
*
* WRITE : wa_acts-stdvar TO l_svar UNIT wa_acts-vgexx NO-GROUPING.
* CONCATENATE l_svar l_uom INTO wa_nodestab-text3
* SEPARATED BY space.
* IF wa_acts-vgwxx <> 0.
* wa_acts-varper = ( wa_acts-stdvar / wa_acts-vgwxx ) * 100.
* ENDIF.
*
* WRITE wa_acts-varper TO l_svarp DECIMALS 2 NO-GROUPING.
* CONCATENATE l_svarp c_perc INTO wa_nodestab-text4
* SEPARATED BY space.
* IF wa_acts-ismxx <> 0.
* IF l_total2 <> c_x.
* l_total2 = c_x.
* l_wa_acts-ilexx = wa_acts-ilexx.
* ENDIF.
*
* IF l_wa_acts-ilexx = wa_acts-ilexx AND NOT l_wa_acts-ilexx IS
* INITIAL.
* l_wa_acts-ismxx = l_wa_acts-ismxx + wa_acts-ismxx.
* l_wa_acts-ilexx = wa_acts-ilexx.
*
* ELSEIF wa_acts-ismxx <> 0.
* CLEAR : l_wa_acts-ismxx , l_wa_acts-ilexx, l_actt.
* ENDIF.
* ENDIF.
*
* IF wa_acts-vgwxx <> 0.
* IF l_total1 <> c_x.
* l_total1 = c_x.
* l_wa_acts-vgexx = wa_acts-vgexx.
* ENDIF.
*
* IF l_wa_acts-vgexx = wa_acts-vgexx AND NOT l_wa_acts-vgexx IS
* INITIAL.
* l_wa_acts-vgwxx = l_wa_acts-vgwxx + wa_acts-vgwxx.
* l_wa_acts-stdvar = l_wa_acts-stdvar + wa_acts-stdvar.
* l_wa_acts-vgexx = wa_acts-vgexx.
*
* ELSEIF wa_acts-vgwxx <> 0.
* CLEAR : l_wa_acts-vgwxx , l_wa_acts-vgexx, l_wa_acts-stdvar,
* l_stdt, l_svart.
* ENDIF.
* ENDIF.
*
* WRITE l_wa_acts-ismxx TO l_actt
* UNIT l_wa_acts-ilexx NO-GROUPING
* .
* WRITE l_wa_acts-vgwxx TO l_stdt
* UNIT l_wa_acts-vgexx NO-GROUPING
* .
* WRITE l_wa_acts-stdvar TO l_svart
* UNIT l_wa_acts-vgexx NO-GROUPING
* .
*
* ELSE.
* WRITE : wa_acts-actu TO l_act CURRENCY v_waers NO-GROUPING.
** l_act = wa_acts-actu.
* CONCATENATE l_act v_waers INTO wa_nodestab-text1
* SEPARATED BY space.
*
* WRITE : wa_acts-stdu TO l_std CURRENCY v_waers NO-GROUPING.
** l_std = wa_acts-stdu.
* CONCATENATE l_std v_waers INTO wa_nodestab-text2
* SEPARATED BY space.
*
* WRITE : wa_acts-varu TO l_svar CURRENCY v_waers NO-GROUPING.
** l_svar = wa_acts-varu.
* CONCATENATE l_svar v_waers INTO wa_nodestab-text3
* SEPARATED BY space.
*
* IF wa_acts-stdu <> 0.
* wa_acts-varper = ( wa_acts-varu / wa_acts-stdu ) * 100.
* ENDIF.
* l_svarp = wa_acts-varper.
* CONCATENATE l_svarp c_perc INTO wa_nodestab-text4
* SEPARATED BY space.
*
* l_wa_acts-actu = l_wa_acts-actu + wa_acts-actu.
* l_wa_acts-stdu = l_wa_acts-stdu + wa_acts-stdu.
* l_wa_acts-varu = l_wa_acts-varu + wa_acts-varu.
*
* WRITE l_wa_acts-actu TO l_actt CURRENCY v_waers NO-GROUPING.
* WRITE l_wa_acts-stdu TO l_stdt CURRENCY v_waers NO-GROUPING.
* WRITE l_wa_acts-varu TO l_svart CURRENCY v_waers NO-GROUPING.
* l_wa_acts-ilexx = v_waers.
* l_wa_acts-vgexx = v_waers.
* ENDIF.
*
* IF flg_color = c_x.
* CLEAR flg_color.
* wa_nodestab-tcolor = c_3.
* wa_nodestab-tcolor1 = c_3.
* wa_nodestab-tcolor2 = c_3.
* wa_nodestab-tcolor3 = c_3.
* wa_nodestab-tcolor4 = c_3.
* ELSE.
* flg_color = c_x.
* wa_nodestab-tcolor = c_2.
* wa_nodestab-tcolor1 = c_2.
* wa_nodestab-tcolor2 = c_2.
* wa_nodestab-tcolor3 = c_2.
* wa_nodestab-tcolor4 = c_2.
* ENDIF.
* APPEND wa_nodestab TO i_nodestab.
* ENDLOOP.
** Displaying Activity Subtotals
* CLEAR wa_nodestab.
* wa_nodestab-id = c_4_1.
* wa_nodestab-tlevel = c_4.
* wa_nodestab-parent = c_3_2.
*
* wa_nodestab-text = 'Activity Totals'(074).
* wa_nodestab-tlength = c_30.
* wa_nodestab-tlength1 = c_20.
* wa_nodestab-tlength2 = c_20.
* wa_nodestab-tlength3 = c_24.
*
* IF l_wa_acts-ilexx <> v_waers.
* WRITE : l_wa_acts-ilexx TO l_uom.
* ELSE.
* WRITE : v_waers TO l_uom.
* ENDIF.
* CONCATENATE l_actt l_uom INTO wa_nodestab-text1
* SEPARATED BY space.
*
* IF l_wa_acts-vgexx <> v_waers.
* WRITE : l_wa_acts-vgexx TO l_uom.
* ELSE.
* WRITE : v_waers TO l_uom.
* ENDIF.
* CONCATENATE l_stdt l_uom INTO wa_nodestab-text2
* SEPARATED BY space.
*
* CONCATENATE l_svart l_uom INTO wa_nodestab-text3
* SEPARATED BY space.
*
* wa_nodestab-tcolor = c_6.
* wa_nodestab-tcolor1 = c_6.
* wa_nodestab-tcolor2 = c_6.
* wa_nodestab-tcolor3 = c_6.
*
* APPEND wa_nodestab TO i_nodestab.
* CLEAR : wa_nodestab.
*
****
**** Material Information
****
* READ TABLE i_h_mat INTO wa_h_mat INDEX 1.
* IF sy-subrc = 0.
*
* CLEAR : wa_nodestab.
* wa_nodestab-id = c_3_3.
* wa_nodestab-tlevel = c_3.
* wa_nodestab-parent = c_2_1.
* PERFORM material_header USING wa_nodestab.
*
* APPEND wa_nodestab TO i_nodestab.
*
* CLEAR : wa_nodestab , l_amenge , l_smenge , l_wa_mats,
* l_totalg1 , l_totalg2 , l_totalg3 ,
* l_sqtyg , l_aqtyg , l_svarg ,
* l_svargq , l_stprsq.
*
* LOOP AT i_matn INTO wa_matn.
* CLEAR : wa_mats , l_sqty , l_aqty , l_svar , l_svarp,
* l_svarq , l_varprsq,
* l_total1 , l_total2 , l_total3, l_menge , l_stprs.
*
* LOOP AT i_h_mat INTO wa_h_mat WHERE matnr = wa_matn-matnr
* AND bwart = wa_matn-bwart.
* "28/06/2005++
* CLEAR : l_amenge , l_astprs , l_smenge , l_sstprs.
*
* l_sstprs = l_stprs.
* l_smenge = l_menge.
* PERFORM do_mat_calc CHANGING wa_h_mat
* l_aqtyv l_matuom
* l_sqtyv l_stduom
* l_svarv l_varuom
* l_svarpv
* l_amenge l_smenge
* l_astprs l_sstprs.
* l_stprs = l_stprs + l_sstprs.
* l_menge = l_menge + l_smenge.
*
* CHECK wa_h_mat-sumi = c_x.
* CLEAR : l_menge , l_stprs.
*
* IF rb_quant EQ c_x.
* IF l_matuom IS INITIAL OR l_matuom EQ l_stduom.
* wa_h_mat-stdvar = l_smenge - l_amenge.
* ENDIF.
*
* IF l_amenge <> 0.
* IF l_total1 <> c_x.
* l_total1 = c_x.
* wa_mats-actuom = l_matuom.
* ENDIF.
*
* IF wa_mats-actuom = l_matuom.
* wa_mats-actusg = wa_mats-actusg + l_amenge.
* ELSE.
* CLEAR : wa_mats-actusg , wa_mats-actuom, l_aqty ,
* wa_mats-actuom.
* ENDIF.
* ENDIF.
*
* IF l_smenge <> 0.
* IF l_total2 <> c_x.
* l_total2 = c_x.
* wa_mats-stduom = l_stduom.
* ENDIF.
*
* IF wa_mats-stduom = l_stduom.
* wa_mats-stdusg = wa_mats-stdusg + l_smenge.
* ELSE.
* CLEAR : wa_mats-stdusg , wa_mats-stduom, l_sqty ,
* wa_mats-stduom.
* ENDIF.
* ENDIF.
*
* IF wa_h_mat-stdvar <> 0.
* IF l_total3 <> c_x.
* l_total3 = c_x.
* wa_mats-varuom = l_stduom.
* ENDIF.
*
* IF wa_mats-varuom = l_stduom.
* wa_mats-stdvar = wa_mats-stdvar + wa_h_mat-stdvar.
* ELSE.
* CLEAR : wa_mats-stdvar, wa_mats-varuom, l_svar.
* ENDIF.
* ENDIF.
*
* WRITE : wa_mats-actusg TO l_aqty UNIT wa_mats-actuom
* NO-GROUPING.
* WRITE : wa_mats-stdusg TO l_sqty UNIT wa_mats-stduom
* NO-GROUPING.
* WRITE : wa_mats-stdvar TO l_svar UNIT wa_mats-stduom
* NO-GROUPING.
*
* wa_mats-astprs = wa_mats-astprs + l_astprs.
* wa_mats-sstprs = wa_mats-sstprs + l_sstprs.
* wa_mats-varprs = wa_mats-varprs + l_sstprs - l_astprs.
*
* v_prs = wa_mats-varprs.
* WRITE : v_prs TO l_svarq CURRENCY v_waers NO-GROUPING.
* ELSE.
*
* wa_mats-astprs = wa_mats-astprs + l_astprs.
* wa_mats-sstprs = wa_mats-sstprs + l_sstprs.
* wa_mats-varprs = wa_mats-varprs + l_sstprs - l_astprs.
*
* wa_mats-actuom = v_waers.
* wa_mats-stduom = v_waers.
* wa_mats-varuom = v_waers.
*
* v_prs = wa_mats-astprs.
* WRITE : v_prs TO l_aqty CURRENCY v_waers NO-GROUPING.
* v_prs = wa_mats-sstprs.
* WRITE : v_prs TO l_sqty CURRENCY v_waers NO-GROUPING.
* v_prs = wa_mats-varprs.
* WRITE : v_prs TO l_svar CURRENCY v_waers NO-GROUPING.
* ENDIF.
*
* wa_mats-matnr = wa_h_mat-matnr.
* wa_mats-maktx = wa_h_mat-maktx.
*
* l_varprsq = wa_mats-varprs.
* ENDLOOP.
*
* IF wa_mats-stduom = wa_mats-actuom OR wa_mats-actuom IS INITIAL.
* CASE c_x.
* WHEN rb_quant.
* IF wa_mats-stdusg > 0.
* wa_mats-varper = ( wa_mats-stdvar / wa_mats-stdusg ) *
* 100.
* ELSE.
* wa_mats-varper = 0.
* ENDIF.
*
* WHEN rb_fiscl.
* IF wa_mats-sstprs > 0.
* wa_mats-varper = ( wa_mats-varprs / wa_mats-sstprs ) *
* 100.
* ELSE.
* wa_mats-varper = 0.
* ENDIF.
* ENDCASE.
* ENDIF.
* WRITE wa_mats-varper TO l_svarp DECIMALS 2 NO-GROUPING.
*
* IF l_aqty CA '123456789'.
* IF l_totalg1 <> c_x.
* l_totalg1 = c_x.
* l_wa_mats-actuom = wa_mats-actuom.
* ENDIF.
*
* IF l_wa_mats-actuom <> wa_mats-actuom.
* CLEAR : l_wa_mats-actusg , l_wa_mats-astprs , l_aqtyg ,
* l_wa_mats-actuom , wa_mats-actusg , wa_mats-astprs.
* ENDIF.
* ENDIF.
*
* IF l_sqty CA '123456789'.
* IF l_totalg2 <> c_x.
* l_totalg2 = c_x.
* l_wa_mats-stduom = wa_mats-stduom.
* ENDIF.
*
* IF l_wa_mats-stduom <> wa_mats-stduom.
* CLEAR : l_wa_mats-stdusg , l_wa_mats-sstprs , l_sqtyg ,
* l_wa_mats-stduom , wa_mats-stdusg , wa_mats-sstprs .
* ENDIF.
* ENDIF.
*
* IF l_svar CA '123456789'.
* IF l_totalg3 <> c_x.
* l_totalg3 = c_x.
* l_wa_mats-varuom = wa_mats-varuom.
* ENDIF.
*
* IF l_wa_mats-varuom <> wa_mats-varuom.
* CLEAR : l_wa_mats-stdvar, l_wa_mats-varprs , l_svarg ,
* l_wa_mats-varuom, wa_mats-stdvar , wa_mats-varprs.
* ENDIF.
* ENDIF.
*
* CASE c_x.
* WHEN rb_quant.
* l_wa_mats-actusg = l_wa_mats-actusg + wa_mats-actusg.
* WRITE : l_wa_mats-actusg TO l_aqtyg UNIT l_wa_mats-actuom
* NO-GROUPING.
*
* l_wa_mats-stdusg = l_wa_mats-stdusg + wa_mats-stdusg.
* WRITE : l_wa_mats-stdusg TO l_sqtyg UNIT l_wa_mats-stduom
* NO-GROUPING.
*
* l_wa_mats-stdvar = l_wa_mats-stdvar + wa_mats-stdvar.
* WRITE : l_wa_mats-stdvar TO l_svarg UNIT l_wa_mats-varuom
* NO-GROUPING.
*
* l_stprsq = l_stprsq + l_varprsq.
* v_prs = l_stprsq.
* WRITE : v_prs TO l_svargq CURRENCY v_waers NO-GROUPING.
*
* WHEN rb_fiscl.
* l_wa_mats-astprs = l_wa_mats-astprs + wa_mats-astprs.
* v_prs = l_wa_mats-astprs.
* WRITE : v_prs TO l_aqtyg CURRENCY v_waers NO-GROUPING.
*
* l_wa_mats-sstprs = l_wa_mats-sstprs + wa_mats-sstprs.
* v_prs = l_wa_mats-sstprs.
* WRITE : v_prs TO l_sqtyg CURRENCY v_waers NO-GROUPING.
*
* l_wa_mats-varprs = l_wa_mats-varprs + wa_mats-varprs.
* v_prs = l_wa_mats-varprs.
* WRITE : v_prs TO l_svarg CURRENCY v_waers NO-GROUPING.
* ENDCASE.
*
* CLEAR: wa_nodestab.
* wa_nodestab-id = c_4_2.
* wa_nodestab-tlevel = c_4.
* wa_nodestab-parent = c_3_3.
*
* wa_nodestab-tcolor = c_3.
* wa_nodestab-tcolor1 = c_3.
* wa_nodestab-tcolor2 = c_3.
* wa_nodestab-tcolor3 = c_3.
* wa_nodestab-tcolor4 = c_3.
* wa_nodestab-tcolor5 = c_3.
*
* wa_nodestab-tlength = c_18.
* wa_nodestab-tlength1 = c_30.
* wa_nodestab-tlength2 = c_22.
* wa_nodestab-tlength3 = c_22.
* wa_nodestab-tlength4 = c_24.
* wa_nodestab-tlength5 = c_20.
*
** Material Number
* WRITE wa_mats-matnr TO wa_nodestab-text NO-ZERO.
** Material Description
* wa_nodestab-text1 = wa_mats-maktx.
*
* IF wa_mats-actuom <> v_waers.
* WRITE : wa_mats-actuom TO l_uom.
* ELSE.
* WRITE : v_waers TO l_uom.
* ENDIF.
* CONCATENATE l_aqty l_uom INTO wa_nodestab-text2
* SEPARATED BY space.
*
* IF wa_mats-stduom <> v_waers.
* WRITE : wa_mats-stduom TO l_uom.
* ELSE.
* WRITE : v_waers TO l_uom.
* ENDIF.
* CONCATENATE l_sqty l_uom INTO wa_nodestab-text3
* SEPARATED BY space.
*
* IF wa_mats-varuom <> v_waers.
* WRITE : wa_mats-varuom TO l_uom.
* ELSE.
* WRITE : v_waers TO l_uom.
* ENDIF.
* CONCATENATE l_svar l_uom INTO wa_nodestab-text4
* SEPARATED BY space.
*
* CONCATENATE l_svarp c_perc INTO wa_nodestab-text5
* SEPARATED BY space.
*
* IF rb_quant = c_x.
* wa_nodestab-tcolor6 = c_3.
* wa_nodestab-tlength6 = c_24.
* CONCATENATE l_svarq v_waers INTO wa_nodestab-text6
* SEPARATED BY space.
* ENDIF.
*
* APPEND wa_nodestab TO i_nodestab.
* CLEAR : wa_nodestab.
* ENDLOOP.
*
**** Displaying Material Subtotals
* CLEAR wa_nodestab.
* wa_nodestab-id = c_4_2.
* wa_nodestab-tlevel = c_4.
* wa_nodestab-parent = c_3_3.
*
* wa_nodestab-text = 'Material Totals'(043).
* wa_nodestab-text1 = space.
*
* wa_nodestab-tlength = c_18.
* wa_nodestab-tlength2 = c_22.
* wa_nodestab-tlength1 = c_30.
* wa_nodestab-tlength3 = c_22.
* wa_nodestab-tlength4 = c_24.
* wa_nodestab-tlength5 = c_20.
*
* IF l_wa_mats-actuom <> v_waers.
* WRITE : l_wa_mats-actuom TO l_uom.
* ELSE.
* WRITE : v_waers TO l_uom.
* ENDIF.
* CONCATENATE l_aqtyg l_uom INTO wa_nodestab-text2
* SEPARATED BY space.
*
* IF l_wa_mats-stduom <> v_waers.
* WRITE : l_wa_mats-stduom TO l_uom.
* ELSE.
* WRITE : v_waers TO l_uom.
* ENDIF.
* CONCATENATE l_sqtyg l_uom INTO wa_nodestab-text3
* SEPARATED BY space.
*
* IF l_wa_mats-varuom <> v_waers.
* WRITE : l_wa_mats-varuom TO l_uom.
* ELSE.
* WRITE : v_waers TO l_uom.
* ENDIF.
* CONCATENATE l_svarg l_uom INTO wa_nodestab-text4
* SEPARATED BY space.
*
* IF rb_quant = c_x.
* wa_nodestab-tcolor6 = c_6.
* wa_nodestab-tlength6 = c_24.
* CONCATENATE l_svargq v_waers INTO wa_nodestab-text6
* SEPARATED BY space.
* ENDIF.
*
* wa_nodestab-tcolor = c_6.
* wa_nodestab-tcolor2 = c_6.
* wa_nodestab-tcolor3 = c_6.
* wa_nodestab-tcolor4 = c_6.
*
* APPEND wa_nodestab TO i_nodestab.
* CLEAR : wa_nodestab.
* ENDIF.
*
**** Displaying Summary totals
* IF rb_fiscl = c_x.
** l_astprs = l_wa_acts-actu * 10 + l_wa_mats-astprs.
** l_sstprs = l_wa_acts-stdu * 10 + l_wa_mats-sstprs.
* l_astprs = l_wa_acts-actu + l_wa_mats-astprs.
* l_sstprs = l_wa_acts-stdu + l_wa_mats-sstprs.
*
* l_stprs = l_sstprs - l_astprs.
*
* v_prs = l_astprs.
* WRITE : v_prs TO l_aqtys CURRENCY v_waers NO-GROUPING.
* v_prs = l_sstprs.
* WRITE : v_prs TO l_sqtys CURRENCY v_waers NO-GROUPING.
* v_prs = l_stprs.
* WRITE : v_prs TO l_svars CURRENCY v_waers NO-GROUPING.
*
* CLEAR wa_nodestab.
* wa_nodestab-id = c_3_4.
* wa_nodestab-tlevel = c_3.
* wa_nodestab-parent = c_2_1.
*
* wa_nodestab-text = 'Summary Totals'.
* wa_nodestab-text1 = space.
*
* wa_nodestab-tlength = c_18.
* wa_nodestab-tlength2 = c_22.
* wa_nodestab-tlength1 = c_30.
* wa_nodestab-tlength3 = c_22.
* wa_nodestab-tlength4 = c_24.
*
* WRITE : v_waers TO l_uom.
* CONCATENATE l_aqtys l_uom INTO wa_nodestab-text2
* SEPARATED BY space.
*
* CONCATENATE l_sqtys l_uom INTO wa_nodestab-text3
* SEPARATED BY space.
*
* CONCATENATE l_svars l_uom INTO wa_nodestab-text4
* SEPARATED BY space.
* wa_nodestab-tcolor = c_5.
* wa_nodestab-tcolor1 = c_5.
* wa_nodestab-tcolor2 = c_5.
* wa_nodestab-tcolor3 = c_5.
* wa_nodestab-tcolor4 = c_5.
*
* APPEND wa_nodestab TO i_nodestab.
* CLEAR : wa_nodestab.
* ENDIF.
*
*ENDFORM. " DISPLAY_SUMMARY_REPORT
*
**&--------------------------------------------------------------------*
**& Form material_header
**&--------------------------------------------------------------------*
** text
**---------------------------------------------------------------------*
*FORM material_header USING fp_nodestab TYPE snodetext.
*
* fp_nodestab-text = 'Material'(058).
* fp_nodestab-tlength = c_22.
* fp_nodestab-tcolor = c_4.
* fp_nodestab-propfaw = c_x.
*
* fp_nodestab-text1 = 'Description'(059).
* fp_nodestab-tlength1 = c_30.
* fp_nodestab-tcolor1 = c_4.
*
* IF rb_fiscl = c_x.
* CONCATENATE 'Actual Usage'(040) v_waers INTO fp_nodestab-text2
* SEPARATED BY space.
* ELSE.
* CONCATENATE 'Actual Usage'(040) 'UoM' INTO fp_nodestab-text2
* SEPARATED BY space.
* ENDIF.
* fp_nodestab-tlength2 = c_22.
* fp_nodestab-tcolor2 = c_4.
*
* IF rb_fiscl = c_x.
* CONCATENATE 'Standard Usage'(041) v_waers INTO fp_nodestab-text3
* SEPARATED BY space.
* ELSE.
* CONCATENATE 'Standard Usage'(041) 'UoM' INTO fp_nodestab-text3
* SEPARATED BY space.
* ENDIF.
* fp_nodestab-tlength3 = c_22.
* fp_nodestab-tcolor3 = c_4.
*
* IF rb_fiscl = c_x.
* CONCATENATE 'Standard Usage Var'(042)
* v_waers INTO fp_nodestab-text4
* SEPARATED BY space.
* ELSE.
* CONCATENATE 'Standard Usage Var'(042) 'UoM' INTO fp_nodestab-text4
* SEPARATED BY space.
* ENDIF.
* fp_nodestab-tlength4 = c_24.
* fp_nodestab-tcolor4 = c_4.
*
* CONCATENATE 'Standard Usage Var'(042) c_perc INTO fp_nodestab-text5
* SEPARATED BY space.
* fp_nodestab-tlength5 = c_20.
* fp_nodestab-tcolor5 = c_4.
*
* IF rb_summ = c_x AND rb_quant = c_x.
* CONCATENATE 'Standard Usage Var'(042)
* v_waers INTO fp_nodestab-text6
* SEPARATED BY space.
* fp_nodestab-tlength6 = c_24.
* fp_nodestab-tcolor6 = c_4.
* ENDIF.
*
*ENDFORM. " MATERIAL_HEADER
*
***&--------------------------------------------------------------------
***
***& Form get_orders
***&--------------------------------------------------------------------
***
*** text
***---------------------------------------------------------------------
***
**FORM get_orders.
**
** DATA: l_sttxt(100) TYPE c,
** flg_status(1) TYPE c.
**
**
** MOVE 'Extracting Process Orders'(022) TO v_output_text.
**
** PERFORM inform_user_of_progress.
**
**
****START OF MOD-003.
** IF NOT p_mtart IS INITIAL.
***"selection filter on material type
** SELECT matnr "material number
** mtart "material type
** INTO TABLE i_mtart
** FROM mara
** WHERE matnr IN s_matnr
** AND mtart = p_mtart.
**
** IF sy-subrc <> 0. " if no corresponding data is found
**
** MESSAGE i072 WITH p_mtart.
** "No data was selected for material type
** LEAVE LIST-PROCESSING.
**
** ENDIF.
** ENDIF.
**
**
** IF NOT i_mtart IS INITIAL.
** SELECT aufnr
** werks
** kokrs
** objnr
** gltrp
** rsnum
** gamng
** gmein
** plnbez
** plnty
** plnnr
** plnal
** stlst "mod-001
** stlty
** stlnr
** stlal
** aufpl
** zaehl
** rueck
** INTO TABLE i_orders FROM caufv
** FOR ALL ENTRIES IN i_mtart "*----MOD-003
** WHERE aufnr IN s_aufnr AND
** werks = p_werks AND
** kokrs = p_kokrs AND
** stlan = p_usage AND
** plnbez = i_mtart-matnr AND "*----MOD-003
** ( gstrp IN s_datuv OR gltrp IN s_datuv ).
****END OF MOD-003.
**
** ELSE. "----MOD-003
** SELECT aufnr
** werks
** kokrs
** objnr
** gltrp
** rsnum
** gamng
** gmein
** plnbez
** plnty
** plnnr
** plnal
** stlst " MOD-001
** stlty
** stlnr
** stlal
** aufpl
** zaehl
** rueck
** INTO TABLE i_orders FROM caufv
** WHERE aufnr IN s_aufnr AND
** werks = p_werks AND
** kokrs = p_kokrs AND
** plnbez IN s_matnr AND
** stlan = p_usage AND
** ( gstrp IN s_datuv OR gltrp IN s_datuv ).
**
** ENDIF. "----MOD-003
**
**
** IF sy-subrc <> 0.
** MESSAGE s007.
** LEAVE LIST-PROCESSING.
** ENDIF.
**
** SORT i_orders BY aufnr.
**
** LOOP AT i_orders INTO wa_orders.
**
** IF NOT i_tj02t[] IS INITIAL .
** PERFORM get_status_info USING wa_orders-objnr l_sttxt.
**
** CLEAR: flg_status, wa_tj02t.
** LOOP AT i_tj02t INTO wa_tj02t.
** IF l_sttxt NS wa_tj02t-txt04.
** CLEAR flg_status.
** EXIT.
** ELSE.
** flg_status = c_x.
** CONTINUE.
** ENDIF.
** CLEAR : wa_tj02t.
** ENDLOOP.
**
** IF flg_status <> c_x.
** DELETE i_orders.
** CONTINUE.
** ENDIF.
**
** wa_order_status_text-aufnr = wa_orders-aufnr.
** wa_order_status_text-sttxt = l_sttxt.
** APPEND wa_order_status_text TO i_order_status_text.
** CLEAR wa_order_status_text.
** ENDIF.
**
** CLEAR : wa_orders.
**
** ENDLOOP.
**
*** ENDIF.
**
**ENDFORM. " get_orders
***&--------------------------------------------------------------------
***
***& Form get_operations
***&--------------------------------------------------------------------
***
*** text
***---------------------------------------------------------------------
**
***---------------------------------------------------------------------
**
**FORM get_operations.
**
** DATA l_tabix TYPE sytabix.
**
** MOVE 'Extracting Phase Information'(023) TO v_output_text.
** PERFORM inform_user_of_progress.
**
** SELECT aufpl
** aplzl
** plnkn
** plnty
** plnnr
** zaehl
** vornr
** arbid
** rueck
** steus
** phflg
** INTO TABLE i_afvc
** FROM afvc
** FOR ALL ENTRIES IN i_orders
** WHERE aufpl = i_orders-aufpl AND
** steus IN s_steus AND
** phflg = c_x.
**
** IF sy-subrc = 0.
** SELECT aufpl
** aplzl
** bmsch
** vgw02
** lmnga
** ism02
** ssavd
** FROM afvv INTO TABLE i_afvv
** FOR ALL ENTRIES IN i_afvc
** WHERE aufpl = i_afvc-aufpl AND
** aplzl = i_afvc-aplzl AND
** ssavd IN s_datuv.
**
** IF sy-subrc = 0.
** SORT i_afvv BY aufpl aplzl.
** ENDIF.
** IF NOT ( s_kostl[] IS INITIAL ).
**
** SELECT objty objid kokrs kostl
** FROM crco INTO TABLE i_crco
** FOR ALL ENTRIES IN i_afvc
** WHERE objty = c_objtyp
** AND objid = i_afvc-arbid.
** IF sy-subrc = 0.
** SORT i_crco BY kostl.
** ENDIF.
** ENDIF.
**
** SORT i_crhd BY objid.
** SORT i_orders BY aufpl.
**
** SORT i_afvc BY aufpl vornr DESCENDING.
**
** LOOP AT i_afvc INTO wa_afvc.
**
** l_tabix = sy-tabix.
**
** IF NOT ( s_kostl[] IS INITIAL ).
** READ TABLE i_crco INTO wa_crco
** WITH KEY objty = c_objtyp
** objid = wa_afvc-arbid
** BINARY SEARCH.
** IF sy-subrc = 0.
** READ TABLE i_csks INTO wa_csks
** WITH KEY kostl = wa_crco-kostl.
** IF sy-subrc <> 0.
** DELETE i_afvv WHERE aufpl = wa_afvc-aufpl
** AND aplzl = wa_afvc-aplzl.
** DELETE i_afvc INDEX l_tabix.
** CONTINUE.
** ENDIF.
** ENDIF.
** ENDIF.
**
*** Check work centre details with resource
** IF NOT ( s_arbpl[] IS INITIAL ).
** READ TABLE i_crhd INTO wa_crhd
** WITH KEY objid = wa_afvc-arbid BINARY SEARCH.
** IF sy-subrc <> 0.
** DELETE i_afvv WHERE aufpl = wa_afvc-aufpl
** AND aplzl = wa_afvc-aplzl.
** DELETE i_afvc INDEX l_tabix.
** CONTINUE.
** ELSE.
** PERFORM move_data2_ordops.
** ENDIF.
** ELSE.
** READ TABLE i_crhd INTO wa_crhd
** WITH KEY objid = wa_afvc-arbid BINARY SEARCH.
** PERFORM move_data2_ordops.
** ENDIF.
** CLEAR: wa_crco, wa_crhd, l_tabix, wa_afvc.
** ENDLOOP.
**
** ENDIF.
**
**ENDFORM. " get_operations
***&--------------------------------------------------------------------
***
***& Form get_mat_segment
***&--------------------------------------------------------------------
***
*** text
***---------------------------------------------------------------------
***
***---------------------------------------------------------------------
***
**FORM get_mat_segment.
** DATA: l_menge TYPE menge_d,
** l_gamng type menge_d,
** v_menge type menge_d,
** l_meins TYPE meins,
** struct_mara type mara,
** struct_marc type marc.
** DATA: l_lmnga TYPE LMNGA,
** L_CFUOM type meins.
**
** IF NOT ( i_pro_orders[] IS INITIAL ).
** IF NOT ( rb_prod IS INITIAL ).
**
*** Extracting goods receipt information
**MOVE 'Extracting Goods Receipt Information'(024) TO v_output_text.
** PERFORM inform_user_of_progress.
******* Mod-002******************************************************
** SELECT aufnr mblnr mjahr zeile matnr bwart menge meins
** " sjahr smbln smblp
** rsnum rspos rsart erfmg erfme
** FROM aufm "Table : Goods movements for order
** INTO TABLE i_mseg1
** FOR ALL ENTRIES IN i_pro_orders
** WHERE aufnr = i_pro_orders-aufnr.
*** AND matnr = i_pro_orders-plnbez.
*******Mod-002********************************************************
** IF sy-subrc = 0.
**
***Addition
** i_mseg = i_mseg1.
** LOOP AT i_pro_orders INTO wa_pro_orders.
** DELETE i_mseg WHERE aufnr = wa_pro_orders-aufnr
** AND matnr <> wa_pro_orders-plnbez.
** ENDLOOP.
***End of addition
************************Mod-002***************************************
*
**
** clear: struct_marc.
** select single *
** into struct_marc
** from marc
** where matnr = wa_pro_orders-plnbez and
** werks = wa_pro_orders-werks.
**
** clear: struct_mara.
** select single *
** into struct_mara
** from mara
** where matnr = wa_pro_orders-plnbez.
**
***************MOD-002************************************************
*
**
** SORT i_mseg BY aufnr.
** SORT i_pro_orders BY aufnr.
*** Calculatin the quantity according to the movement type and
*** assign the value to i_pro_orders internal table
**
** LOOP AT i_mseg INTO wa_mseg.
** AT NEW aufnr.
** CLEAR: l_menge, l_meins, v_menge.
** ENDAT.
** IF wa_mseg-bwart = c_101.
** if struct_marc-frtme is initial.
*** l_menge = l_menge + wa_mseg-menge.
*** l_meins = wa_mseg-erfme.
** if wa_mseg-erfme = struct_mara-meins.
** l_menge = l_menge + wa_mseg-erfmg.
** l_meins = wa_mseg-erfme.
** else.
** CALL FUNCTION 'MD_CONVERT_MATERIAL_UNIT'
** EXPORTING
** i_matnr = wa_pro_orders-plnbez
** i_in_me = wa_mseg-erfme
** i_out_me = struct_mara-meins
** i_menge = wa_mseg-erfmg
** IMPORTING
** e_menge = v_menge
** EXCEPTIONS
** error_in_application = 1
** error = 2
** OTHERS = 3.
** IF sy-subrc = 0.
** wa_mseg-erfmg = v_menge.
** ENDIF.
** l_menge = l_menge + wa_mseg-erfmg.
** l_meins = wa_mseg-erfme.
** endif.
** ELSEIF struct_marc-frtme is not initial.
** if ( struct_marc-frtme = struct_mara-meins ) and
** ( wa_mseg-erfme = struct_marc-frtme ).
** l_menge = l_menge + wa_mseg-erfmg.
** l_meins = wa_mseg-erfme.
** elseif ( struct_marc-frtme = struct_mara-meins ) and
** ( wa_mseg-erfme ne struct_marc-frtme ).
** CALL FUNCTION 'MD_CONVERT_MATERIAL_UNIT'
** EXPORTING
** i_matnr = wa_pro_orders-plnbez
** i_in_me = wa_mseg-erfme
** i_out_me = struct_marc-frtme
** i_menge = wa_mseg-erfmg
** IMPORTING
** e_menge = v_menge
** EXCEPTIONS
** error_in_application = 1
** error = 2
** OTHERS = 3.
** IF sy-subrc = 0.
** wa_mseg-erfmg = v_menge.
** ENDIF.
** l_menge = l_menge + wa_mseg-erfmg.
** l_meins = wa_mseg-erfme.
** elseif ( struct_marc-frtme ne struct_mara-meins ) and
** ( wa_mseg-erfme ne struct_marc-frtme ).
** CALL FUNCTION 'MD_CONVERT_MATERIAL_UNIT'
** EXPORTING
** i_matnr = wa_pro_orders-plnbez
** i_in_me = wa_mseg-erfme
** i_out_me = struct_marc-frtme
** i_menge = wa_mseg-erfmg
** IMPORTING
** e_menge = v_menge
** EXCEPTIONS
** error_in_application = 1
** error = 2
** OTHERS = 3.
** IF sy-subrc = 0.
** wa_mseg-erfmg = v_menge.
** ENDIF.
** l_menge = l_menge + wa_mseg-erfmg.
** l_meins = wa_mseg-erfme.
** else.
** CALL FUNCTION 'MD_CONVERT_MATERIAL_UNIT'
** EXPORTING
** i_matnr = wa_pro_orders-plnbez
** i_in_me = wa_mseg-erfme
** i_out_me = struct_marc-frtme
** i_menge = wa_mseg-erfmg
** IMPORTING
** e_menge = v_menge
** EXCEPTIONS
** error_in_application = 1
** error = 2
** OTHERS = 3.
** IF sy-subrc = 0.
** wa_mseg-erfmg = v_menge.
** ENDIF.
** l_menge = l_menge + wa_mseg-erfmg.
** l_meins = wa_mseg-erfme.
**
** endif.
** endif.
** ELSEIF wa_mseg-bwart = c_102.
** if struct_marc-frtme is initial.
*** l_menge = l_menge - wa_mseg-menge.
*** l_meins = wa_mseg-erfme.
**
** if wa_mseg-erfme = struct_mara-meins.
** l_menge = l_menge - wa_mseg-erfmg.
** l_meins = wa_mseg-erfme.
** else.
** CALL FUNCTION 'MD_CONVERT_MATERIAL_UNIT'
** EXPORTING
** i_matnr = wa_pro_orders-plnbez
** i_in_me = wa_mseg-erfme
** i_out_me = struct_mara-meins
** i_menge = wa_mseg-erfmg
** IMPORTING
** e_menge = v_menge
** EXCEPTIONS
** error_in_application = 1
** error = 2
** OTHERS = 3.
** IF sy-subrc = 0.
** wa_mseg-erfmg = v_menge.
** ENDIF.
** l_menge = l_menge - wa_mseg-erfmg.
** l_meins = wa_mseg-erfme.
** endif.
** ELSEIF struct_marc-frtme is not initial.
** if ( struct_marc-frtme = struct_mara-meins ) and
** ( wa_mseg-erfme = struct_marc-frtme ).
** l_menge = l_menge - wa_mseg-erfmg.
** l_meins = wa_mseg-erfme.
** elseif ( struct_marc-frtme = struct_mara-meins ) and
** ( wa_mseg-erfme ne struct_marc-frtme ).
** CALL FUNCTION 'MD_CONVERT_MATERIAL_UNIT'
** EXPORTING
** i_matnr = wa_pro_orders-plnbez
** i_in_me = wa_mseg-erfme
** i_out_me = struct_marc-frtme
** i_menge = wa_mseg-erfmg
** IMPORTING
** e_menge = v_menge
** EXCEPTIONS
** error_in_application = 1
** error = 2
** OTHERS = 3.
** IF sy-subrc = 0.
** wa_mseg-erfmg = v_menge.
** ENDIF.
** l_menge = l_menge - wa_mseg-erfmg.
** l_meins = wa_mseg-erfme.
** elseif ( struct_marc-frtme ne struct_mara-meins ) and
** ( wa_mseg-erfme ne struct_marc-frtme ).
** CALL FUNCTION 'MD_CONVERT_MATERIAL_UNIT'
** EXPORTING
** i_matnr = wa_pro_orders-plnbez
** i_in_me = wa_mseg-erfme
** i_out_me = struct_marc-frtme
** i_menge = wa_mseg-erfmg
** IMPORTING
** e_menge = v_menge
** EXCEPTIONS
** error_in_application = 1
** error = 2
** OTHERS = 3.
** IF sy-subrc = 0.
** wa_mseg-erfmg = v_menge.
** ENDIF.
** l_menge = l_menge - wa_mseg-erfmg.
** l_meins = wa_mseg-erfme.
** else.
** CALL FUNCTION 'MD_CONVERT_MATERIAL_UNIT'
** EXPORTING
** i_matnr = wa_pro_orders-plnbez
** i_in_me = wa_mseg-erfme
** i_out_me = struct_marc-frtme
** i_menge = wa_mseg-erfmg
** IMPORTING
** e_menge = v_menge
** EXCEPTIONS
** error_in_application = 1
** error = 2
** OTHERS = 3.
** IF sy-subrc = 0.
** wa_mseg-erfmg = v_menge.
** ENDIF.
** l_menge = l_menge - wa_mseg-erfmg.
** l_meins = wa_mseg-erfme.
** endif.
** endif.
*** l_menge = l_menge - wa_mseg-menge.*
** ENDIF.
*** l_meins = wa_mseg-meins.
**
******* End of MOD-002***************************************
**
** AT END OF aufnr.
**********Mod-002********************************************
*** Don't want zero production orders
** IF NOT ( rb_ezero IS INITIAL ) AND l_menge = 0.
** DELETE i_ordops WHERE aufnr = wa_mseg-aufnr.
** DELETE i_pro_orders WHERE aufnr = wa_mseg-aufnr.
** CONTINUE.
** ENDIF.
** READ TABLE i_pro_orders INTO wa_pro_orders
** WITH KEY aufnr = wa_mseg-aufnr.
** wa_pro_orders-menge = l_menge.
** wa_pro_orders-gruom = l_meins.
** IF wa_pro_orders-gruom NE wa_pro_orders-gmein.
** CLEAR l_menge.
**
*** If no conversion possible just use gr qty
** CALL FUNCTION 'MATERIAL_UNIT_CONVERSION'
** EXPORTING
** kzmeinh = c_x
** input = wa_pro_orders-menge
** matnr = wa_pro_orders-plnbez
** meinh = wa_pro_orders-gmein
** meins = wa_pro_orders-gruom
** IMPORTING
** output = l_menge
** EXCEPTIONS
** conversion_not_found = 1
** input_invalid = 2
** material_not_found = 3
** meinh_not_found = 4
** meins_missing = 5
** no_meinh = 6
** output_invalid = 7
** overflow = 8
** OTHERS = 9.
** IF sy-subrc = 0.
** wa_pro_orders-menge = l_menge.
** ENDIF.
************************MOD-003**************************************
** clear: l_gamng.
**
** CALL FUNCTION 'MATERIAL_UNIT_CONVERSION'
** EXPORTING
** kzmeinh = c_x
** input = wa_pro_orders-gamng
** matnr = wa_pro_orders-plnbez
** meinh = wa_pro_orders-gmein
** meins = wa_pro_orders-gruom
** IMPORTING
** output = l_gamng
** EXCEPTIONS
** conversion_not_found = 1
** input_invalid = 2
** material_not_found = 3
** meinh_not_found = 4
** meins_missing = 5
** no_meinh = 6
** output_invalid = 7
** overflow = 8
** OTHERS = 9.
** IF sy-subrc = 0.
** wa_pro_orders-gamng = l_gamng.
** ENDIF.
**************************MOD-003*************************************
*
***
** ENDIF.
** MODIFY i_pro_orders FROM wa_pro_orders
** TRANSPORTING menge gruom gamng
** WHERE aufnr = wa_mseg-aufnr.
** ENDAT.
*************************MOD-003**************************************
** CLEAR : wa_mseg.
*************************MOD-003**************************************
**
** ENDLOOP.
** ENDIF.
*********************MOD-008******************************************
***** Select confirmations using operation confirmation
* number instead of
***** order number
*** SELECT aufpl
*** aplzl
*** plnkn
*** plnty
*** plnnr
*** zaehl
*** vornr
*** arbid
*** rueck
*** steus
*** phflg
*** INTO TABLE i_afvc1
*** FROM afvc
*** FOR ALL ENTRIES IN i_ordops
*** WHERE aufpl = I_ORDOPS-aufpl AND
*** steus = 'YBN1' AND
*** phflg = c_x.
***
*** IF sy-subrc = 0.
*** SORT I_AFVC1 BY aufpl
*** aplzl
*** plnkn
*** plnty
*** plnnr.
***
*** SELECT aufpl
*** aplzl
*** bmsch
*** vgw02
*** lmnga
*** ism02
*** ssavd
*** FROM afvv INTO TABLE i_afvv1
*** FOR ALL ENTRIES IN i_afvc1
*** WHERE aufpl = i_afvc1-aufpl AND
*** aplzl = i_afvc1-aplzl.
***
*** IF SY-SUBRC = 0.
*** SORT I_AFVV1 BY AUFPL APLZL.
*** ENDIF.
*** ENDIF.
**
*********************MOD-008******************************************
** ELSE.
*** Extracting confirmation information
**MOVE 'Extracting Confirmation Information'(025) TO v_output_text.
** PERFORM inform_user_of_progress.
**
*** SELECT aufnr rueck gmnga lmnga gmein meinh
*** meilr stokz rueck_mst
*** FROM afru INTO TABLE i_afru
*** FOR ALL ENTRIES IN i_pro_orders
*** WHERE rueck = i_pro_orders-rueck AND
**** MOD-001- Begin of change
*** lmnga NE c_0. " AND
**** meilr NE space.
**** MOD-001- End of change
*** IF sy-subrc = 0.
*** SORT i_afru BY aufnr .
*************MOD-002************************************************
**
**
******************MOD-004*********************************************
***
*** LOOP AT I_ORDOPS INTO WA_ORDOPS.
*** SELECT SINGLE *
*** INTO WA_PLPO3
*** FROM plpo
*** WHERE plnty = WA_ordops-plnty and
*** plnnr = wa_ordops-plnnr and
*** PLNKN = wa_ordops-plnkn and
*** ZAEHL = wa_ordops-zaehl.
*** IF SY-SUBRC = 0.
*** APPEND WA_PLPO3 TO I_PLPO3.
*** ENDIF.
*** ENDLOOP.
**** and steus = 'YBN1'.
***
******************MOD-005*********************************************
*
**** LOOP AT I_PRO_ORDERS into WA_PRO_ORDERS.
***********************mod-004****************************************
**** READ TABLE I_PLPO3 INTO WA_PLPO3 WITH KEY
**** plnty = wa_pro_orders-plnty
**** plnnr = wa_pro_orders-plnnr
**** plnkn = wa_pro_orders-plnkn
**** zaehl = wa_pro_orders-zaehl.
***** steus = 'YBN1'.
*********************MOD-004******************************************
*
***
***
******************************MOD-005*******************************
*** LOOP AT I_ORDOPS INTO WA_ORDOPS.
******************************MOD-005******************************
**** READ table i_afvc into wa_afvc with key
***** aufpl = wa_pro_orders-aufpl
**** aufpl = wa_ordops-aufpl binary search.
**** steus = 'YBN1'
**** phflg = c_x binary search.
***
***********************MOD-005*************************************
***
**********************MOD-006*************************************
*** CLEAR: WA_PLPO3.
*** READ TABLE I_PLPO3 INTO WA_PLPO3 WITH KEY
*** plnty = wa_ordops-plnty
*** plnnr = wa_ordops-plnnr
**** plnkn = wa_ordops-plnkn
**** zaehl = wa_ordops-zaehl
*** steus = 'YBN1' binary search.
**** vornr = wa_ordops-vornr
**** werks = p_werks binary search.
***
**********************MOD-006*************************************
*** IF SY-SUBRC = 0.
**** READ table i_afvc into wa_afvc with key
**** aufpl = wa_ordops-aufpl
**** aplzl = wa_ordops-aplzl
**** plnkn = wa_ordops-plnkn
**** plnty = wa_ordops-plnty
**** plnnr = wa_ordops-plnnr
**** zaehl = wa_ordops-zaehl BINARY SEARCH.
*******************mod-006*******************************************
*** check wa_plpo3-vgw02 IS NOT INITIAL.
*** clear: wa_afvc.
*** READ TABLE i_afvc INTO wa_afvc
*** WITH KEY plnty = wa_plpo3-plnty
*** plnnr = wa_plpo3-plnnr
*** plnkn = wa_plpo3-plnkn
*** zaehl = wa_plpo3-zaehl
*** aufpl = wa_ordops-aufpl.
***********************MOD-006*************************************
*** if sy-subrc = 0.
********************mod-004*******************************************
*
***
*** CLEAR: WA_AFVV.
*** READ TABLE I_AFVV into wa_afvv with key
*** aufpl = wa_afvc-aufpl
*** aplzl = wa_afvc-aplzl binary search.
*** if sy-subrc = 0.
*** CLEAR: I_AFRU.
*** SELECT aufnr rueck gmnga lmnga gmein meinh
*** meilr stokz rueck_mst
*** FROM afru INTO TABLE i_afru
*** WHERE rueck = wa_afvc-rueck AND
**** WHERE rueck = wa_ordops-rueck AND
**** aufnr = wa_pro_orders-aufnr.
*** aufnr = wa_ordops-aufnr.
***
*** if sy-subrc = 0.
*** SORT i_afru BY aufnr RUECK.
*** LOOP AT i_afru INTO wa_afru.
**** READ TABLE i_pro_orders INTO wa_pro_orders
**** WITH KEY aufnr = wa_afru-aufnr.
*** IF sy-subrc = 0.
*** l_lmnga = l_lmnga + wa_afru-lmnga.
*** l_cfuom = wa_afru-gmein.
**** wa_pro_orders-lmnga = wa_afru-lmnga.
**** wa_pro_orders-cfuom = wa_afru-gmein.
**** MODIFY i_pro_orders FROM wa_pro_orders
**** TRANSPORTING lmnga cfuom
**** WHERE aufnr = wa_afru-aufnr.
*** ENDIF.
*** ENDLOOP.
*** endif.
*************************MOD-005**************************************
*** wa_ordops-lmnga = l_lmnga.
*** wa_ordops-cfuom = l_cfuom.
*** MODIFY i_ordops FROM wa_ordops
*** TRANSPORTING lmnga cfuom
******************************MOD-006********************************
*** where plnty = wa_ordops-plnty and
*** plnnr = wa_ordops-plnnr and
**** plnkn = wa_ordops-plnkn and
**** zaehl = wa_ordops-zaehl and
*** aufpl = wa_ordops-aufpl.
****************************MOD-006*********************************
***
*******************MOD-003******************************************
*** clear: l_lmnga, l_cfuom.
*******************mod-003**************************************
*** ENDIF.
*** ENDIF.
**** clear: wa_pro_orders.
*****************************mod-004********************************
*** ENDIF.
*** clear: wa_ordops.
*** ENDLOOP.
**************************MOD-005*************************************
***
*** i_ordops1[] = i_ordops[].
*** delete i_ordops1 where lmnga eq 0.
***
*** LOOP AT I_PRO_ORDERS INTO WA_PRO_ORDERS.
*** read table i_ordops1 into wa_ordops1 with key
*** aufnr = wa_pro_orders-aufnr binary search.
*** IF SY-SUBRC = 0.
*** wa_pro_orders-lmnga = wa_ordops1-lmnga.
*** wa_pro_orders-cfuom = wa_ordops1-cfuom.
*** if wa_pro_orders-menge is initial.
*** wa_pro_orders-menge = wa_pro_orders-gamng.
*** endif.
*** MODIFY i_pro_orders FROM wa_pro_orders
*** TRANSPORTING lmnga cfuom menge
*** where aufnr = wa_ordops1-aufnr.
*** ENDIF.
*** ENDLOOP.
*** endif.
*********************************MOD-007******************************
**
**** Select confirmations using operation confirmation number instead of
**** order number
** SELECT aufpl
** aplzl
** plnkn
** plnty
** plnnr
** zaehl
** vornr
** arbid
** rueck
** steus
** phflg
** INTO TABLE i_afvc1
** FROM afvc
** FOR ALL ENTRIES IN i_ordops
** WHERE aufpl = I_ORDOPS-aufpl AND
** steus = 'YBN1' AND
** phflg = c_x.
**
** IF sy-subrc = 0.
** SORT I_AFVC1 BY aufpl
** aplzl
** plnkn
** plnty
** plnnr.
**
** SELECT aufpl
** aplzl
** bmsch
** vgw02
** lmnga
** ism02
** ssavd
** FROM afvv INTO TABLE i_afvv1
** FOR ALL ENTRIES IN i_afvc1
** WHERE aufpl = i_afvc1-aufpl AND
** aplzl = i_afvc1-aplzl.
**
** IF SY-SUBRC = 0.
** SORT I_AFVV1 BY AUFPL APLZL.
**
** LOOP AT I_ORDOPS INTO WA_ORDOPS.
** READ TABLE I_PRO_ORDERS INTO WA_PRO_ORDERS WITH KEY
** AUFNR = WA_ORDOPS-AUFNR
** BINARY SEARCH.
** IF SY-SUBRC = 0.
** READ table i_afvc1 into wa_afvc1 with key
** plnty = wa_ORDOPS-plnty
** plnnr = wa_ORDOPS-plnnr
** plnkn = wa_ORDOPS-plnkn
** zaehl = wa_ORDOPS-zaehl
** aufpl = wa_pro_orders-aufpl.
** IF SY-SUBRC = 0.
** READ TABLE I_AFVV1 into wa_afvv1 with key
** aufpl = wa_afvc1-aufpl
** aplzl = wa_afvc1-aplzl binary search.
** IF SY-SUBRC = 0.
** CHECK WA_AFVV1-VGW02 NE 0.
** select aufnr
** rueck
** gmnga
** lmnga
** gmein
** meinh
** meilr
** stokz
** rueck_mst
** INTO TABLE I_AFRU1
** from afru
** where rueck = wa_afvc1-rueck AND
** werks = p_werks and
** aufnr = WA_PRO_ORDERS-aufnr and
** AUFPL = WA_AFVC1-AUFPL AND
** APLZL = WA_AFVC1-APLZL.
**
** IF SY-SUBRC = 0.
**
** perform get_confirmation_qty_new using
** wa_ordops-lmnga
** wa_ordops-cfuom.
**
** MODIFY i_ordops FROM wa_ordops
** TRANSPORTING lmnga cfuom.
** ENDIF.
** ENDIF.
** ENDIF.
** ENDIF.
**
** ENDLOOP.
** ENDIF.
** ENDIF.
**
** i_ordops1[] = i_ordops[].
** delete i_ordops1 where lmnga eq 0.
** delete adjacent duplicates from i_ordops1 comparing
** aufnr
** aufpl
** aplzl
** plnkn
** plnty
** plnnr
** zaehl
** vornr.
**
**
** LOOP AT I_PRO_ORDERS INTO WA_PRO_ORDERS.
** read table i_ordops1 into wa_ordops1 with key
** aufnr = wa_pro_orders-aufnr binary search.
** IF SY-SUBRC = 0.
** wa_pro_orders-lmnga = wa_ordops1-lmnga.
** wa_pro_orders-cfuom = wa_ordops1-cfuom.
** if wa_pro_orders-menge is initial.
** wa_pro_orders-menge = wa_pro_orders-gamng.
** endif.
** MODIFY i_pro_orders FROM wa_pro_orders
** TRANSPORTING lmnga cfuom menge
** where aufnr = wa_ordops1-aufnr.
** ENDIF.
** ENDLOOP.
** endif.
** endif.
*********MOD-007******************************************************
**
**
**ENDFORM. " get_mat_segment
***&--------------------------------------------------------------------
***
***& Form get_bom_info
***&--------------------------------------------------------------------
***
*** text
***---------------------------------------------------------------------
***
***---------------------------------------------------------------------
***
**FORM get_bom_info.
** DATA: wa_doc_segment1 TYPE ty_doc_segment,
** l_qty TYPE bdmng,
** l_per TYPE p DECIMALS 3,
** l_tabix TYPE sytabix,
** v_menge like ekpo-menge.
** DATA: STRUCT_MARC TYPE MARC,
** STRUCT_MARA TYPE MARA.
**
***- Begin of MOD-001
**
** TYPES: BEGIN OF l_ty_bom_header,
** stlty TYPE stlty, " BOM category
** stlnr TYPE stnum, " Bill of material
** stlal TYPE stalt, " Alternative BOM
** bmein TYPE basme, " Base unit of measure for BOM
** bmeng TYPE basmn, " Base Quantity
** END OF l_ty_bom_header.
**
** DATA: l_i_bom_header TYPE STANDARD TABLE OF l_ty_bom_header
** INITIAL SIZE 0,
**
** l_wa_bom_header TYPE l_ty_bom_header.
**
***- End of MOD-001
**
** IF NOT i_pro_orders[] IS INITIAL.
** MOVE 'Extracting BOM Information'(026) TO v_output_text.
** PERFORM inform_user_of_progress.
**
*** Get issued materials for all process orders
**
***Begin of addition
**
** IF i_mseg1 IS INITIAL.
**** Mod-002*******************************************************
** SELECT aufnr mblnr mjahr zeile matnr bwart menge meins
** rsnum rspos rsart erfmg erfme
** FROM aufm "Table : Goods movements for order
** INTO TABLE i_mseg1
** FOR ALL ENTRIES IN i_pro_orders
** WHERE aufnr = i_pro_orders-aufnr.
*** AND matnr = i_pro_orders-plnbez.
****** Mod-002***************************************************
** ENDIF.
**
** LOOP AT i_pro_orders INTO wa_pro_orders.
**
** LOOP AT i_mseg1 INTO wa_doc_segment
** WHERE mjahr = wa_pro_orders-wdate+0(4)
** AND bwart IN i_r_bwart
** AND aufnr = wa_pro_orders-aufnr.
**
** APPEND wa_doc_segment TO i_doc_segment.
**
** CLEAR : wa_doc_segment.
** ENDLOOP.
** CLEAR : wa_pro_orders.
** ENDLOOP.
**
** IF NOT i_doc_segment IS INITIAL.
**
** SELECT mblnr mjahr zeile sjahr smbln smblp rsnum rspos rsart
** FROM mseg INTO TABLE i_prev_doc
** FOR ALL ENTRIES IN i_doc_segment
** WHERE mblnr = i_doc_segment-mblnr
** AND mjahr = i_doc_segment-mjahr
** AND zeile = i_doc_segment-zeile.
**
** ENDIF.
**
** IF NOT i_doc_segment IS INITIAL.
**
***End of addition
**
** SORT i_doc_segment BY aufnr.
**
** LOOP AT i_doc_segment INTO wa_doc_segment1.
**
** wa_issued_mat-aufnr = wa_doc_segment1-aufnr.
**
*** No reservation number so see if any other link exists
**
** IF wa_doc_segment1-rsnum IS INITIAL.
**
*** Try to find any linked previous movements
** READ TABLE i_prev_doc INTO wa_prev_doc
** WITH KEY mblnr = wa_doc_segment1-mblnr
** mjahr = wa_doc_segment1-mjahr
** zeile = wa_doc_segment1-zeile.
** ENDIF.
**
** IF wa_doc_segment1-rsnum IS INITIAL AND
** wa_prev_doc-smbln NE space.
**
** READ TABLE i_prev_doc INTO wa_prev_doc
** WITH KEY mblnr = wa_prev_doc-smbln
** mjahr = wa_prev_doc-sjahr
** zeile = wa_prev_doc-smblp.
**
** IF sy-subrc = 0 AND NOT ( wa_doc_segment1-rsnum IS INITIAL )
  .
*** found a previous record
** wa_issued_mat-rsnum = wa_prev_doc-rsnum.
** wa_issued_mat-rspos = wa_prev_doc-rspos.
** wa_issued_mat-rsart = wa_prev_doc-rsart.
** ENDIF.
**
** ELSE.
** wa_issued_mat-rsnum = wa_doc_segment1-rsnum.
** wa_issued_mat-rspos = wa_doc_segment1-rspos.
** wa_issued_mat-rsart = wa_doc_segment1-rsart.
** ENDIF.
** wa_issued_mat-matnr = wa_doc_segment1-matnr.
** IF wa_doc_segment1-bwart = c_movm_low_262
** OR wa_doc_segment1-bwart = c_movm_low_531.
** wa_issued_mat-menge = wa_doc_segment1-menge * -1.
** ELSE.
** wa_issued_mat-menge = wa_doc_segment1-menge.
** ENDIF.
** wa_issued_mat-meins = wa_doc_segment1-meins.
** COLLECT wa_issued_mat INTO i_issued_mat.
** CLEAR : wa_doc_segment1, wa_prev_doc.
** ENDLOOP.
** ENDIF.
**
*** Selecting reservations
** SELECT rsnum rspos rsart xloek matnr werks bdmng
** meins shkzg aufnr dumps vornr rgekz
** stlty stlnr stlkn stpoz
** FROM resb INTO TABLE i_reservations
** FOR ALL ENTRIES IN i_pro_orders
** WHERE rsnum = i_pro_orders-rsnum AND
** aufnr = i_pro_orders-aufnr
** AND bdmng > 0
** AND dumps = space.
** IF sy-subrc = 0.
** SORT i_reservations.
*** Selecting material standard price and price unit
*** SELECT stlty stlnr stlkn stpoz ausch " MOD-001 --
** SELECT stlty stlnr stlkn stpoz
** meins menge ausch yyzero"MOD-001++
** FROM stpo INTO TABLE i_stpo
** FOR ALL ENTRIES IN i_reservations
** WHERE stlty = i_reservations-stlty
** AND stlnr = i_reservations-stlnr
** AND stlkn = i_reservations-stlkn
** AND stpoz = i_reservations-stpoz.
**
** IF sy-subrc = 0.
***Not required to handle as Component scrap in percent is optional
** ENDIF.
**
** SELECT matnr werks kausf
** FROM marc INTO TABLE i_marc
** FOR ALL ENTRIES IN i_reservations
** WHERE matnr = i_reservations-matnr
** AND werks = i_reservations-werks.
**
** IF sy-subrc = 0.
***Not required to handle as Component scrap in percent (plant level) is
***optional
** ENDIF.
**
** SELECT matnr bwkey stprs peinh
** FROM mbew INTO TABLE i_mat_valuation
** FOR ALL ENTRIES IN i_reservations
** WHERE matnr = i_reservations-matnr
** AND bwkey = i_reservations-werks.
**
** IF sy-subrc = 0.
***Not required to handle Standard Price and
** Price Unit are not mandatory
** ENDIF.
***- Begin of MOD-001
** SELECT stlty stlnr stlal bmein bmeng
** INTO TABLE l_i_bom_header
** FROM stko
** FOR ALL ENTRIES IN i_pro_orders
** WHERE stlty = i_pro_orders-stlty
** AND stlnr = i_pro_orders-stlnr
** AND stlal = i_pro_orders-stlal.
**
** IF sy-subrc = 0.
*** There must be at least one record for process order.
** ENDIF.
**
***- End of MOD-001
**
** LOOP AT i_reservations INTO wa_reservations.
** CLEAR: wa_order_status_text.
** l_tabix = sy-tabix.
**
** IF wa_reservations-xloek NE space.
** READ TABLE i_order_status_text INTO wa_order_status_text
** WITH KEY aufnr = wa_reservations-aufnr.
** IF sy-subrc = 0
** AND wa_order_status_text-sttxt NS c_teco.
** DELETE i_issued_mat WHERE rsnum = wa_reservations-rsnum
** AND rspos = wa_reservations-rspos
** AND rsart = wa_reservations-rsart.
** DELETE i_reservations INDEX l_tabix.
** CONTINUE.
** ENDIF.
** ENDIF.
**
** IF NOT ( rb_nflsh IS INITIAL )
** AND wa_reservations-rgekz NE space.
** DELETE i_issued_mat WHERE rsnum = wa_reservations-rsnum
** AND rspos = wa_reservations-rspos
** AND rsart = wa_reservations-rsart.
** DELETE i_reservations INDEX l_tabix.
** CONTINUE.
** ENDIF.
** wa_ordmats-aufnr = wa_reservations-aufnr.
** wa_ordmats-matnr = wa_reservations-matnr.
** wa_ordmats-vornr = wa_reservations-vornr.
** wa_ordmats-rsnum = wa_reservations-rsnum.
** wa_ordmats-rspos = wa_reservations-rspos.
** wa_ordmats-rsart = wa_reservations-rsart.
** wa_ordmats-bdmng = wa_reservations-bdmng.
** wa_ordmats-meins = wa_reservations-meins.
**
** READ TABLE i_issued_mat INTO wa_issued_mat
** WITH KEY rsnum = wa_reservations-rsnum
** rspos = wa_reservations-rspos
** rsart = wa_reservations-rsart.
** IF sy-subrc = 0.
** wa_ordmats-menge = wa_ordmats-menge + wa_issued_mat-menge.
** wa_ordmats-amein = wa_issued_mat-meins.
** ELSE.
** wa_ordmats-amein = wa_reservations-meins.
** ENDIF.
*** Use the reservation quantity as the standard planned quantity
*** If material is by-product need to turn it into a negative number
  .
** IF wa_reservations-shkzg = c_s.
** wa_ordmats-bdmng = wa_ordmats-bdmng * -1.
** ENDIF.
**
** READ TABLE i_pro_orders INTO wa_pro_orders
** WITH KEY aufnr = wa_reservations-aufnr.
***************MOD-003*************************************
** clear: l_qty.
***************MOD-003*************************************
** IF rb_prod IS INITIAL.
** l_qty = wa_pro_orders-lmnga. "confirmed qty
****************MOD-003************************************
** ELSEIF ( rb_prod is not initial ) and ( rb_actl is initial ).
** l_qty = wa_pro_orders-gamng.
** ELSEIF ( RB_PROD IS NOT INITIAL ) and
** ( RB_ACTL is not initial ).
** l_qty = wa_pro_orders-menge. "goods receipt qty
** ENDIF.
**
*** Calculate the standard quantity
********************MOD-003****************************
*** IF NOT rb_actl IS INITIAL.
********************MOD-003****************************
**
*********************mod-007*****************************
** IF L_QTY IS INITIAL.
** SELECT aufnr rueck gmnga lmnga gmein meinh
** meilr stokz rueck_mst
** FROM afru INTO TABLE i_afru
** FOR ALL ENTRIES IN i_pro_orders
** WHERE rueck = i_pro_orders-rueck AND
** lmnga NE c_0.
**
** READ TABLE i_pro_orders INTO wa_pro_orders
** WITH KEY aufnr = wa_reservations-aufnr.
** IF SY-SUBRC = 0.
** READ table i_afvc into wa_afvc with key
** aufpl = wa_pro_orders-aufpl
** steus = 'YBN1'
** phflg = c_x binary search.
** IF SY-SUBRC = 0.
** READ TABLE I_AFVV into wa_afvv with key
** aufpl = wa_afvc-aufpl
** aplzl = wa_afvc-aplzl binary search.
** if sy-subrc = 0.
** SORT i_afru BY aufnr RUECK.
** LOOP AT i_afru INTO wa_afru
** WHERE AUFNR = WA_PRO_ORDERS-AUFNR AND
** RUECK = WA_AFVC-RUECK.
** IF sy-subrc = 0.
** l_QTY = l_QTY + wa_afru-lmnga.
** ENDIF.
** ENDLOOP.
** check wa_pro_orders-gamng ne 0.
** clear: wa_ordmats-stdqy.
** wa_ordmats-stdqy = ( l_qty / wa_pro_orders-gamng ) *
** wa_ordmats-bdmng
**
** endif.
** ENDIF.
** ENDIF.
**********************************MOD-007*****************************
** ELSE.
** check wa_pro_orders-gamng ne 0.
** clear: wa_ordmats-stdqy.
** wa_ordmats-stdqy = ( l_qty / wa_pro_orders-gamng ) *
** wa_ordmats-bdmng.
** ENDIF.
********************MOD-006***********************
**
*** check wa_pro_orders-gamng ne 0.
*** clear: wa_ordmats-stdqy.
*** wa_ordmats-stdqy = ( l_qty / wa_pro_orders-gamng ) *
*** wa_ordmats-bdmng.
********************mod-006************************
*** ELSE.
*********MOD-002****************************************
**** check wa_pro_orders-menge ne 0.
**** wa_ordmats-stdqy = ( l_qty / wa_pro_orders-menge ) *
**** wa_ordmats-bdmng.
*** check wa_pro_orders-gamng ne 0.
*** wa_ordmats-stdqy = ( l_qty / wa_pro_orders-gamng ) *
*** wa_ordmats-bdmng.
*** ENDIF.
********MOD-002*******************************************
**********************MOD-003*******************************
**
**
*** gets the zero loss figure from the bom
**
***- Begin of MOD-001
**
*** READ TABLE i_stpo INTO wa_stpo
*** WITH KEY stlty = wa_reservations-stlty
*** stlnr = wa_reservations-stlnr
*** stlkn = wa_reservations-stlkn
*** stpoz = wa_reservations-stpoz.
*** IF sy-subrc = 0 AND NOT ( wa_stpo-ausch IS INITIAL ).
*** l_per = ( wa_stpo-ausch / c_100 ) * wa_ordmats-stdqy.
*** ELSE.
*** READ TABLE i_marc INTO wa_marc
*** WITH KEY matnr = wa_reservations-matnr
*** werks = wa_reservations-werks.
*** IF sy-subrc = 0 AND NOT ( wa_marc-kausf IS INITIAL ).
*** l_per = ( wa_marc-kausf / c_100 ) * wa_ordmats-stdqy.
*** ELSE.
*** MOVE c_0 TO l_per.
*** ENDIF.
*** ENDIF.
**
*** wa_ordmats-zloss = wa_ordmats-stdqy - l_per.
**
** CLEAR l_qty.
** IF rb_actl IS INITIAL.
** l_qty = wa_pro_orders-gamng.
** ELSEIF rb_pland IS INITIAL.
** l_qty = wa_pro_orders-menge.
** ENDIF.
**
** READ TABLE l_i_bom_header INTO l_wa_bom_header
** WITH KEY stlty = wa_pro_orders-stlty
** stlnr = wa_pro_orders-stlnr
** stlal = wa_pro_orders-stlal.
**
** IF sy-subrc IS INITIAL.
***************mod-002**************************************
** IF L_WA_BOM_HEADER-BMEIN NE WA_PRO_ORDERS-GMEIN.
** CALL FUNCTION 'MD_CONVERT_MATERIAL_UNIT'
** EXPORTING
** i_matnr = wa_pro_orders-PLNBEZ
** i_in_me = wa_pro_orders-gmein
** i_out_me = l_wa_bom_header-bmein
** i_menge = l_qty
** IMPORTING
** e_menge = v_menge
** EXCEPTIONS
** error_in_application = 1
** error = 2
** OTHERS = 3.
** IF sy-subrc = 0.
** l_qty = v_menge.
** ENDIF.
** ENDIF.
**
**
*************mod-002*****************************************
** IF l_wa_bom_header-bmeng IS NOT INITIAL.
**
** READ TABLE i_stpo INTO wa_stpo
** WITH KEY stlty = wa_reservations-stlty
** stlnr = wa_reservations-stlnr
** stlkn = wa_reservations-stlkn
** stpoz = wa_reservations-stpoz.
**
** l_per = wa_stpo-menge *
** ( l_qty / l_wa_bom_header-bmeng ).
**
** wa_ordmats-zloss = l_per * wa_stpo-yyzero.
**
** ENDIF.
**
** ENDIF.
**
***- End of MOD-001
** READ TABLE i_mat_valuation INTO wa_mat_valuation
** WITH KEY matnr = wa_reservations-matnr
** bwkey = wa_reservations-werks.
** IF sy-subrc = 0.
** wa_ordmats-stprs = wa_mat_valuation-stprs.
** wa_ordmats-peinh = wa_mat_valuation-peinh.
** ENDIF.
**
*** Adding material number to I_MATERIAL_NO internal table
** wa_material_no-matnr = wa_reservations-matnr.
**
** APPEND: wa_ordmats TO i_ordmats,
** wa_material_no TO i_material_no.
** CLEAR: wa_ordmats, l_qty, l_per, wa_stpo, wa_marc,
** wa_issued_mat, wa_pro_orders, wa_mat_valuation,
** wa_material_no, l_tabix, wa_reservations.
**
** ENDLOOP.
*** Now we need to see if any of the materials issued to the order
*** are not on the BOM (ie replacement materials)
*** First summarise the data
** SORT i_ordmats BY aufnr matnr rsnum.
** LOOP AT i_issued_mat INTO wa_issued_mat.
** READ TABLE i_ordmats INTO wa_ordmats
** WITH KEY aufnr = wa_issued_mat-aufnr
** matnr = wa_issued_mat-matnr
** rsnum = wa_issued_mat-rsnum
** BINARY SEARCH.
** IF sy-subrc GE 4.
*** material not on bom table so add it
** CLEAR: wa_ordmats.
*** Get the standard price info for costing purposes in output
** READ TABLE i_mat_valuation INTO wa_mat_valuation
** WITH KEY matnr = wa_issued_mat-matnr
** bwkey = p_werks.
** wa_issued_mat-stprs = wa_mat_valuation-stprs.
** wa_issued_mat-peinh = wa_mat_valuation-peinh.
** MODIFY i_issued_mat FROM wa_issued_mat.
** wa_ordmats-stprs = wa_mat_valuation-stprs.
** wa_ordmats-peinh = wa_mat_valuation-peinh.
** MOVE: wa_issued_mat-aufnr TO wa_ordmats-aufnr,
** wa_issued_mat-matnr TO wa_ordmats-matnr,
** wa_issued_mat-menge TO wa_ordmats-menge,
** wa_issued_mat-meins TO wa_ordmats-meins,
** wa_issued_mat-meins TO wa_ordmats-amein.
** COLLECT wa_ordmats INTO i_ordmats.
**
** ELSE.
*** material is on bom table so delete from sum_msegi
** DELETE i_issued_mat. " FROM wa_issued_mat.
** ENDIF.
** CLEAR : wa_issued_mat.
** ENDLOOP.
**
** CLEAR wa_issued_mat.
**
*** Retrieve task list information of operations/activity
** from PLPO table
** SELECT * FROM plpo INTO TABLE i_plpo
** FOR ALL ENTRIES IN i_pro_orders
** WHERE plnty = i_pro_orders-plnty
** AND plnnr = i_pro_orders-plnnr
** AND plnkn = i_pro_orders-plnkn
** AND zaehl = i_pro_orders-zaehl.
**
** IF sy-subrc = 0.
***Not required to handle
***Task list - operation/activity information is optional
** ENDIF.
**
** SELECT rueck rmzhl ism01 ism02 ism03 ism04 ism05 ism06 stokz
** FROM afru INTO TABLE i_ord_conf
** FOR ALL ENTRIES IN i_pro_orders
** WHERE rueck = i_pro_orders-rueck.
**
**
** IF sy-subrc = 0.
***Not required to handle
***Order Confirmations information is not mandatiory
** ENDIF.
** ENDIF.
**
** IF NOT i_ordops[] IS INITIAL.
**
** SELECT * FROM plpo INTO TABLE i_plpo1
** FOR ALL ENTRIES IN i_ordops
** WHERE plnty = i_ordops-plnty
** AND plnnr = i_ordops-plnnr
** AND plnkn = i_ordops-plnkn
** AND zaehl = i_ordops-zaehl.
**
** IF sy-subrc = 0.
***Not required to handle
***operations information is optional.
** ENDIF.
**
** SELECT rueck rmzhl ism01 ism02 ism03 ism04 ism05 ism06 stokz
** FROM afru INTO TABLE i_ord_conf1
** FOR ALL ENTRIES IN i_ordops
** WHERE rueck = i_ordops-rueck.
**
** IF sy-subrc = 0.
***Not required to handle
***Order Confirmations information is not mandatiory
** ENDIF.
**
** ENDIF.
** ENDIF.
**ENDFORM. " get_bom_info
**
***&--------------------------------------------------------------------
***
***& Form output
***&--------------------------------------------------------------------
***
*** text
***---------------------------------------------------------------------
***
***---------------------------------------------------------------------
***
**FORM output.
**
** MOVE 'Formatting Output'(027) TO v_output_text.
** PERFORM inform_user_of_progress.
**
*** Selecting material descriptions
** SELECT matnr maktx
** FROM makt INTO TABLE i_material_des
** FOR ALL ENTRIES IN i_material_no
** WHERE spras = sy-langu
** AND matnr = i_material_no-matnr.
**
** IF sy-subrc = 0.
***Not required to handle
***Material desc is optinal
** ENDIF.
**
**
*** Selecting Work centers descriptions
** SELECT objid ktext
** FROM crtx INTO TABLE i_wc_text
** FOR ALL ENTRIES IN i_pro_orders
** WHERE objty = c_objtyp
** AND objid = i_pro_orders-arbid
** AND spras = sy-langu.
**
** IF sy-subrc = 0.
***Not required to handle
***Work centers descriptions are optional
** ENDIF.
**
** CASE c_x.
** WHEN rb_detl.
** PERFORM display_detail_report.
** WHEN rb_summ.
** PERFORM display_summary_report.
** WHEN rb_phase.
** PERFORM display_phase_report.
** ENDCASE.
**
**
**ENDFORM. " output
**
***&--------------------------------------------------------------------
**
***& Form move_data2_ordops
***&--------------------------------------------------------------------
***
*** text
***---------------------------------------------------------------------
***
***---------------------------------------------------------------------
***
**FORM move_data2_ordops.
**
** READ TABLE i_afvv INTO wa_afvv WITH KEY aufpl = wa_afvc-aufpl
** aplzl = wa_afvc-aplzl BINARY SEARCH.
** READ TABLE i_orders INTO wa_orders WITH KEY aufpl = wa_afvc-aufpl.
** " BINRAY SEARCH.
** IF sy-subrc = 0.
*******************
**
**READ TABLE i_ordops INTO wa_ordops WITH KEY aufnr = wa_orders-aufnr.
*******************
** IF sy-subrc <> 0.
** MOVE-CORRESPONDING wa_orders TO wa_pro_orders.
** wa_pro_orders-wdate = wa_afvv-ssavd.
** wa_pro_orders-zaehl = wa_afvc-zaehl.
** wa_pro_orders-arbpl = wa_crhd-arbpl.
** wa_pro_orders-arbid = wa_afvc-arbid.
** wa_pro_orders-plnnr = wa_afvc-plnnr.
** wa_pro_orders-plnkn = wa_afvc-plnkn.
*********MOD-002*****************************
*** wa_pro_orders-rueck = wa_afvc-rueck.
********MOD-002*******************************
** IF wa_pro_orders-rueck IS INITIAL.
** wa_pro_orders-rueck = wa_afvc-rueck.
** ENDIF.
**
** wa_material_no-matnr = wa_orders-plnbez.
**
** APPEND: wa_pro_orders TO i_pro_orders,
** wa_material_no TO i_material_no.
** CLEAR: wa_pro_orders, wa_material_no.
** ENDIF.
**
** wa_ordops-aufnr = wa_orders-aufnr.
** wa_ordops-aufpl = wa_afvc-aufpl.
** wa_ordops-aplzl = wa_afvc-aplzl.
** wa_ordops-plnty = wa_afvc-plnty.
** wa_ordops-plnkn = wa_afvc-plnkn.
** wa_ordops-plnnr = wa_afvc-plnnr.
** wa_ordops-zaehl = wa_afvc-zaehl.
** wa_ordops-vornr = wa_afvc-vornr.
** wa_ordops-arbid = wa_afvc-arbid.
** wa_ordops-rueck = wa_afvc-rueck.
** wa_ordops-ssavd = wa_afvv-ssavd.
** wa_ordops-arbpl = wa_crhd-arbpl.
**
** APPEND wa_ordops TO i_ordops.
** CLEAR wa_ordops.
** ENDIF.
** CLEAR: wa_afvv, wa_orders.
**
**ENDFORM. " move_data2_ordops
***&--------------------------------------------------------------------
***
***& Form DISPLAY_DETAIL_REPORT
***&--------------------------------------------------------------------
***
*** text
***---------------------------------------------------------------------
***
***---------------------------------------------------------------------
**
**FORM display_detail_report.
**
** DATA: l_date_low(10) TYPE c,
** l_date_high(10) TYPE c,
** l_diff TYPE menge_d,
** l_plan_effic TYPE char05, "MOD-001++
** l_plant_effic TYPE char05, "MOD-001++
** l_gamng TYPE menge_d,
** l_gamng1(20) TYPE c,
** l_qty TYPE menge_d,
** l_prdqty TYPE menge_d,
** l_conv TYPE menge_d,
** l_aqty TYPE menge_d,
** l_sqty TYPE menge_d,
** l_gmein TYPE meins,
**
** l_pcent(3) TYPE p DECIMALS 2,
** l_cost(8) TYPE p DECIMALS 2,
**
** l_act_total(8) TYPE p DECIMALS 2,
** l_std_total(8) TYPE p DECIMALS 2,
** l_var_total(8) TYPE p DECIMALS 2,
**
** l_act_gtot(8) TYPE p DECIMALS 2,
** l_std_gtot(8) TYPE p DECIMALS 2,
** l_var_gtot(8) TYPE p DECIMALS 2,
**
** l_fromuom TYPE meins.
***- Begin of MOD-001
** DATA: l_value TYPE char16,
** l_tmp TYPE lmnga,
** l_tmp1 TYPE lmnga,
** l_effic TYPE p DECIMALS 1,
** l_uom TYPE char03.
***- End of MOD-001
**
** PERFORM pfstatus.
** SET PF-STATUS 'MAIN' EXCLUDING i_fcode.
** SET TITLEBAR 'VARI' WITH text-066.
** MOVE 'Display Detail Report'(028) TO v_output_text.
** PERFORM inform_user_of_progress.
**
*** Clearing local variables
** CLEAR: l_cost, l_pcent, l_qty, l_conv, l_aqty, l_sqty,
** l_diff, l_plan_effic, l_gamng, l_date_low,l_date_high,
** l_act_gtot, l_std_gtot, l_var_gtot.
** CLEAR wa_nodestab.
** REFRESH i_nodestab.
**
*****Begin of MOD-001
** IF sy-ucomm = c_zero OR rb_zloss IS NOT INITIAL.
**
** v_ucomm = c_zero.
**
** ELSEIF sy-ucomm = c_std OR rb_stdpl IS NOT INITIAL.
**
** CLEAR : v_ucomm.
**
** ENDIF.
**
** IF sy-ucomm = c_fisc.
**
** v_ucomm1 = c_fisc.
**
** ELSEIF sy-ucomm = c_qty.
**
** v_ucomm1 = c_qty.
**
** ENDIF.
*****End of MOD-001
**
** wa_nodestab-id = c_1_1.
** wa_nodestab-tlevel = c_1.
** wa_nodestab-text = 'Production Variances'(031).
** wa_nodestab-tlength = c_20.
** wa_nodestab-compress = c_x.
** APPEND wa_nodestab TO i_nodestab.
**
** LOOP AT i_pro_orders INTO wa_pro_orders.
**
** CLEAR: wa_nodestab, l_date_low, l_date_high, l_gamng,
** wa_material_des.
**
** l_gamng = wa_pro_orders-gamng.
**************MOD-002************************
** l_gmein = wa_pro_orders-gmein.
**************MOD-002***********************
** wa_nodestab-id = c_2_1.
** wa_nodestab-tlevel = c_2.
** wa_nodestab-parent = c_1_1.
**
*** Order Number text
** wa_nodestab-text = 'Order Num:'(032).
** wa_nodestab-tlength = c_12.
** wa_nodestab-tcolor = c_1.
*** Order number
** WRITE wa_pro_orders-aufnr TO wa_nodestab-text1 NO-ZERO.
** wa_nodestab-tlength1 = c_12.
** wa_nodestab-tcolor1 = c_1.
**
*** Date Range
** WRITE wa_pro_orders-wdate TO l_date_low.
** WRITE wa_pro_orders-gltrp TO l_date_high.
** CONCATENATE l_date_low c_hyp l_date_high
** INTO wa_nodestab-text2 SEPARATED BY space.
** wa_nodestab-tlength2 = c_25.
** wa_nodestab-tcolor2 = c_1.
**
*** Material Number
** WRITE wa_pro_orders-plnbez TO wa_nodestab-text3 NO-ZERO.
** wa_nodestab-tlength3 = c_18.
** wa_nodestab-tcolor3 = c_1.
**
*** Material Description
** READ TABLE i_material_des INTO wa_material_des
** WITH KEY matnr = wa_pro_orders-plnbez.
** wa_nodestab-text4 = wa_material_des-maktx.
** wa_nodestab-tlength4 = c_33.
** wa_nodestab-tcolor4 = c_1.
**
*** Get actual produced Quantity or Confirm Quantity
** IF NOT ( rb_prod IS INITIAL ).
** l_prdqty = wa_pro_orders-menge.
** l_fromuom = wa_pro_orders-gruom.
** ELSE.
***********MOD-002***************************************
** LOOP AT i_plpo1 INTO wa_plpo1
** WHERE plnty = wa_pro_orders-plnty
** AND plnnr = wa_pro_orders-plnnr
** AND steus = 'YBN1'.
** IF wa_plpo1-vgw02 IS NOT INITIAL.
*************MOD-005****************************
*** wa_plpo2 = wa_plpo1.
*** append wa_plpo2 to i_plpo2.
*** ENDIF.
*** ENDLOOP.
*************mod-005***************************
** CLEAR: wa_afvc, wa_afvv.
** READ TABLE i_afvc INTO wa_afvc
** WITH KEY plnty = wa_plpo1-plnty
** plnnr = wa_plpo1-plnnr
** plnkn = wa_plpo1-plnkn
** zaehl = wa_plpo1-zaehl
** aufpl = wa_pro_orders-aufpl.
**
**
** IF sy-subrc IS INITIAL.
** READ TABLE i_afvv INTO wa_afvv
** WITH KEY aufpl = wa_afvc-aufpl
** aplzl = wa_afvc-aplzl.
**
*** READ table i_afvc into wa_afvc with key
*** aufpl = wa_pro_orders-aufpl binary search.
*** if sy-subrc = 0.
*** READ TABLE I_AFVV into wa_afvv with key
*** aufpl = wa_afvc-aufpl
*** aplzl = wa_afvc-aplzl binary search.
** IF sy-subrc = 0.
** l_prdqty = wa_afvv-lmnga.
*********************MOD-006**********************
** IF wa_pro_orders-cfuom IS INITIAL.
** SELECT aufnr rueck gmnga lmnga gmein meinh
** meilr stokz rueck_mst
** FROM afru INTO TABLE i_afru
** WHERE rueck = wa_afvc-rueck AND
** aufnr = wa_pro_orders-aufnr.
** IF NOT i_afru[] IS INITIAL.
** READ TABLE i_afru INTO wa_afru INDEX 1.
** IF sy-subrc = 0.
** l_fromuom = wa_afru-gmein.
** ENDIF.
** ENDIF.
** ELSE.
** l_fromuom = wa_pro_orders-cfuom.
** ENDIF.
********************MOD-006***********************
** ENDIF.
** ENDIF.
***********MOD-002***************************************
*** l_prdqty = wa_pro_orders-lmnga.
*** l_fromuom = wa_pro_orders-cfuom.
** ENDIF.
** ENDLOOP.
** ENDIF.
**
*************mod-003**********************
** IF NOT rb_pland IS INITIAL.
** IF rb_conf IS INITIAL.
** l_prdqty = wa_pro_orders-gamng.
** ELSE.
** l_prdqty = wa_afvv-lmnga.
** ENDIF.
** ENDIF.
************mod-003***********************
** IF rb_kgm = c_x.
*** do actual conversion
** PERFORM uom_convert USING wa_pro_orders-plnbez
** l_prdqty
** l_fromuom
** l_conv.
** l_prdqty = l_conv.
*** do planned conversion
**********MOD-002*************************
*** l_fromuom = wa_pro_orders-gmein.
** l_fromuom = 'KG'.
**
** PERFORM uom_convert USING wa_pro_orders-plnbez
** wa_pro_orders-gamng
** l_fromuom
** l_conv.
**
** l_gamng = l_conv.
** ENDIF.
**
*** Produced Quantity / Confirmed Quantity
** MOVE l_prdqty TO wa_nodestab-text5(20).
** MOVE l_fromuom TO l_uom. "MOD-001++
*** WRITE l_prdqty TO i_nodestab-text5(20).
**
** IF NOT ( rb_prod IS INITIAL ).
*** CONCATENATE 'Prod Qty: '(033) wa_nodestab-text5 "MOD-001-
** CONCATENATE 'Prod Qty: '(033) wa_nodestab-text5 l_uom "MOD-001+
** INTO wa_nodestab-text5 SEPARATED BY space.
**
** ELSE.
*** CONCATENATE 'Conf Qty: '(034) wa_nodestab-text5 "MOD-001-
** CONCATENATE 'Conf Qty: '(034) wa_nodestab-text5 l_uom "MOD-001+
** INTO wa_nodestab-text5 SEPARATED BY space.
** ENDIF.
**
**
*** wa_nodestab-tlength5 = c_30. "MOD-001-
** wa_nodestab-tlength5 = c_35_1. "MOD-001+
** wa_nodestab-tcolor5 = c_1.
**
** APPEND wa_nodestab TO i_nodestab.
**
*** Resource Information
** CLEAR wa_nodestab.
** wa_nodestab-id = c_2_2.
** wa_nodestab-tlevel = c_3.
** wa_nodestab-parent = c_1_1.
**
** CONCATENATE 'Resource:'(035) wa_pro_orders-arbpl
** INTO wa_nodestab-text SEPARATED BY space.
** wa_nodestab-tlength = c_25.
** wa_nodestab-tcolor = c_4.
**
** READ TABLE i_wc_text INTO wa_wc_text
** WITH KEY objid = wa_pro_orders-arbid.
** wa_nodestab-text1 = wa_wc_text-ktext.
** wa_nodestab-tlength1 = c_37.
** wa_nodestab-tcolor1 = c_4.
**
*** Calculating Plan Effic value
***- Begin of MOD-001
*** IF l_gamng GT 0.
*** l_diff = l_gamng - l_prdqty.
*** l_plan_effic = c_100 - c_100 * ( l_diff / l_gamng ).
*** ELSE.
*** CLEAR l_plan_effic.
*** ENDIF.
**
***** Mod-002*********************
** CLEAR: wa_plpo1.
******mOD-002*********************
** LOOP AT i_plpo1 INTO wa_plpo1
** WHERE plnty = wa_pro_orders-plnty
** AND plnnr = wa_pro_orders-plnnr
** AND steus = 'YBN1'.
** IF wa_plpo1-vgw02 IS NOT INITIAL.
** MOVE wa_plpo1-usr04 TO l_effic. "L_VALUE.
** WRITE l_effic TO l_plan_effic.
** wa_plpo2 = wa_plpo1.
** APPEND wa_plpo2 TO i_plpo2.
**
*** L_PLAN_EFFIC = floor( L_VALUE )
***************MOD-002**************************
*** ELSE.
*** CLEAR l_plan_effic.
** ENDIF.
**************MOD-002***************************
** ENDLOOP.
**
**
*** CONCATENATE 'Plan Effic:'(036) l_plan_effic c_perc "'%'
** CONCATENATE 'Exp. Line Eff.'(036) l_plan_effic c_perc "'%'
** INTO wa_nodestab-text2 SEPARATED BY space.
** wa_nodestab-tlength2 = c_25.
** wa_nodestab-tcolor2 = c_4.
**
** CLEAR l_effic.
**** Mod-002***************
**
**
*** READ TABLE i_afvc INTO wa_afvc
*** WITH KEY plnty = wa_plpo1-plnty
*** plnnr = wa_plpo1-plnnr
*** zaehl = wa_plpo1-zaehl.
**
****************MOD-008***********************
*** LOOP AT I_ORDOPS INTO WA_ORDOPS.
*** READ TABLE I_PRO_ORDERS INTO WA_PRO_ORDERS WITH KEY
*** AUFNR = WA_ORDOPS-AUFNR
*** BINARY SEARCH.
*** IF SY-SUBRC = 0.
*** READ table i_afvc1 into wa_afvc1 with key
*** plnty = wa_ORDOPS-plnty
*** plnnr = wa_ORDOPS-plnnr
*** plnkn = wa_ORDOPS-plnkn
*** zaehl = wa_ORDOPS-zaehl
*** aufpl = wa_pro_orders-aufpl.
*** IF SY-SUBRC = 0.
*** READ TABLE I_AFVV1 into wa_afvv1 with key
*** aufpl = wa_afvc1-aufpl
*** aplzl = wa_afvc1-aplzl binary search.
*** IF SY-SUBRC = 0.
*** CHECK WA_AFVV1-VGW02 NE 0.
*** l_tmp = wa_afvv1-bmsch * wa_afvv1-ism02.
*** IF l_tmp IS NOT INITIAL.
***
*** l_tmp1 = ( wa_afvv1-lmnga * wa_afvv1-vgw02 ) / l_tmp.
***
*** l_tmp1 = l_tmp1 * 100.
***
*** MOVE l_tmp1 TO l_effic.
***
*** ENDIF.
*** ENDIF.
*** ENDIF.
*** ENDIF.
*** ENDLOOP.
**
***************MOD-008************************
** CLEAR: wa_afvc, wa_afvv.
** LOOP AT i_plpo2 INTO wa_plpo2.
** READ TABLE i_afvc INTO wa_afvc
** WITH KEY plnty = wa_plpo2-plnty
** plnnr = wa_plpo2-plnnr
** plnkn = wa_plpo2-plnkn
** zaehl = wa_plpo2-zaehl
** aufpl = wa_pro_orders-aufpl.
**
** IF sy-subrc IS INITIAL.
** READ TABLE i_afvv INTO wa_afvv
** WITH KEY aufpl = wa_afvc-aufpl
** aplzl = wa_afvc-aplzl.
**
** l_tmp = wa_afvv-bmsch * wa_afvv-ism02.
** IF l_tmp IS NOT INITIAL.
**
** l_tmp1 = ( wa_afvv-lmnga * wa_afvv-vgw02 ) / l_tmp.
**
** l_tmp1 = l_tmp1 * 100.
**
** MOVE l_tmp1 TO l_effic.
**
** ENDIF.
** ENDIF.
** ENDLOOP.
**
** WRITE l_effic TO l_plant_effic.
**
*** CLEAR v_plant_effic.
*** PERFORM plant_effic USING wa_pro_orders-plnty
*** wa_pro_orders-plnnr
*** wa_pro_orders-plnkn
*** wa_pro_orders-zaehl
*** CHANGING v_plant_effic.
**
*** CONCATENATE 'Plant Effic:'(037) v_plant_effic c_perc "'%'
** CONCATENATE 'Act. Line Eff.'(037) l_plant_effic c_perc "'%'
** " MOD-001+
** INTO wa_nodestab-text3 SEPARATED BY space.
** wa_nodestab-tlength3 = c_25.
** wa_nodestab-tcolor3 = c_4.
***- End of MOD-001
**
** APPEND wa_nodestab TO i_nodestab.
**
*** Phase Information
** CLEAR wa_nodestab.
** wa_nodestab-id = c_3_3.
** wa_nodestab-tlevel = c_3.
** wa_nodestab-parent = c_1_1.
**
** wa_nodestab-text = 'Phase'(038).
** wa_nodestab-tlength = c_10.
** wa_nodestab-tcolor = c_4.
**
** MOVE l_gamng TO l_gamng1.
** CONCATENATE 'Activity (Std Plan:'(039) l_gamng1 c_brac " ')'
** INTO wa_nodestab-text1 SEPARATED BY space.
** wa_nodestab-tlength1 = c_42.
** wa_nodestab-tcolor1 = c_4.
**
** IF rb_fiscl = c_x.
** CONCATENATE 'Actual Usage'(040) v_waers
** INTO wa_nodestab-text2 SEPARATED BY space.
** ELSE.
** wa_nodestab-text2 = 'Actual Usage'(040).
** ENDIF.
** wa_nodestab-tlength2 = c_20.
** wa_nodestab-tcolor2 = c_4.
**
** IF rb_fiscl = c_x.
** CONCATENATE 'Standard Usage'(041) v_waers
** INTO wa_nodestab-text3 SEPARATED BY space.
** ELSE.
** wa_nodestab-text3 = 'Standard Usage'(041).
** ENDIF.
** wa_nodestab-tlength3 = c_20.
** wa_nodestab-tcolor3 = c_4.
**
** IF rb_fiscl = c_x.
** CONCATENATE 'Activity Variance'(042) v_waers
** INTO wa_nodestab-text4 SEPARATED BY space.
** ELSE.
** wa_nodestab-text4 = 'Activity Variance'(042).
** ENDIF.
** wa_nodestab-tlength4 = c_35.
** wa_nodestab-tcolor4 = c_4.
**
** APPEND wa_nodestab TO i_nodestab.
**
*** Display acitivity report
** CLEAR flg_color.
** LOOP AT i_ordops INTO wa_ordops
** WHERE aufnr = wa_pro_orders-aufnr.
** IF flg_color IS INITIAL.
** flg_color = c_x.
** ELSE.
** CLEAR flg_color.
** ENDIF.
** PERFORM activity_report USING l_prdqty l_gamng l_uom l_gmein.
** ENDLOOP.
**
*** Material Information
** CLEAR wa_nodestab.
** wa_nodestab-id = c_3_4.
** wa_nodestab-tlevel = c_3.
** wa_nodestab-parent = c_1_1.
**
** PERFORM material_header.
**
** CLEAR: l_act_total, l_std_total, l_var_total.
*** Individual material details
** LOOP AT i_ordmats INTO wa_ordmats
** WHERE aufnr = wa_pro_orders-aufnr.
**
******************mod-003************************
** CLEAR: l_aqty, l_sqty, l_qty.
*****************mod-003*************************
**
** CLEAR: wa_nodestab.
** wa_nodestab-id = c_4_1.
** wa_nodestab-tlevel = c_4.
** wa_nodestab-parent = c_3_2.
**
*** Material Number
** WRITE wa_ordmats-matnr TO wa_nodestab-text NO-ZERO.
** wa_nodestab-tlength = c_18.
** wa_nodestab-tcolor = c_3.
**
*** Material Description
** CLEAR wa_material_des.
** READ TABLE i_material_des INTO wa_material_des
** WITH KEY matnr = wa_ordmats-matnr.
** wa_nodestab-text1 = wa_material_des-maktx.
** wa_nodestab-tlength1 = c_30.
** wa_nodestab-tcolor1 = c_3.
**
*** Standard planned or zero loss planned
**
** IF rb_zloss IS INITIAL.
** l_qty = wa_ordmats-stdqy.
****************MOD-004***********************
**
**************MOD-004************************
** ELSE.
** l_qty = wa_ordmats-zloss.
** ENDIF.
**
*** Order uom or kgm
** IF rb_kgm IS INITIAL.
** l_aqty = wa_ordmats-menge.
** l_sqty = l_qty.
** ELSE.
*** do actual conversion
** PERFORM uom_convert USING wa_ordmats-matnr
** wa_ordmats-menge
** wa_ordmats-amein
** l_aqty.
*** do std/zloss conversion
** PERFORM uom_convert USING wa_ordmats-matnr
** wa_ordmats-stdqy
** wa_ordmats-meins
** l_sqty.
** ENDIF.
********************MOD-003**********************************
** IF wa_ordmats-meins = 'EA' OR
** wa_ordmats-meins = 'CS'.
** l_sqty = CEIL( l_sqty ).
** ENDIF.
********************MOD-003**********************************
**
** PERFORM std_percentage_calc USING l_aqty l_sqty l_pcent.
**
*** Fiscal or quantity
** IF rb_fiscl IS INITIAL.
** MOVE l_aqty TO wa_nodestab-text2(20). " Actual Usage
** wa_nodestab-tlength2 = c_20.
** wa_nodestab-tcolor2 = c_3.
** MOVE l_sqty TO wa_nodestab-text3(20). " Standard Usage
** wa_nodestab-tlength3 = c_20.
** wa_nodestab-tcolor3 = c_3.
**
** ELSE.
** IF NOT wa_ordmats-peinh IS INITIAL.
** CLEAR l_cost.
** l_cost = ( wa_ordmats-stprs * wa_ordmats-menge )
** / wa_ordmats-peinh.
** MOVE l_cost TO wa_nodestab-text2(20). " Acutal Usage
** wa_nodestab-tlength2 = c_20.
** wa_nodestab-tcolor2 = c_3.
**
** l_act_total = l_act_total + l_cost. " Subtotal of actual
** l_act_gtot = l_act_gtot + l_cost. " Grand total
**
** ENDIF.
** IF NOT wa_ordmats-peinh IS INITIAL.
** CLEAR l_cost.
*****Begin of MOD-001
** IF v_ucomm = c_zero.
****************************MOD-003*******************************
** IF wa_ordmats-meins = 'EA' OR
** wa_ordmats-meins = 'CS'.
** l_qty = CEIL( l_qty ).
** ENDIF.
****************************MOD-003*******************************
** l_cost = ( wa_ordmats-stprs * l_qty ) "wa_ordmats-stdqy )
** / wa_ordmats-peinh.
**
**
** ELSE.
****************************MOD-003*******************************
** IF wa_ordmats-meins = 'EA' OR
** wa_ordmats-meins = 'CS'.
** wa_ordmats-stdqy = CEIL( wa_ordmats-stdqy ).
** ENDIF.
****************************MOD-003*******************************
**
** l_cost = ( wa_ordmats-stprs * wa_ordmats-stdqy )
** / wa_ordmats-peinh.
**
**
** ENDIF.
*****End of MOD-001
**
** MOVE l_cost TO wa_nodestab-text3(20). " Standard Usage
** wa_nodestab-tlength3 = c_20.
** wa_nodestab-tcolor3 = c_3.
**
** l_std_total = l_std_total + l_cost. " Subtotal of standard
** l_std_gtot = l_std_gtot + l_cost. " Grand Total
**
** ENDIF.
** ENDIF.
**
** MOVE l_pcent TO wa_nodestab-text4(17). " Variance Percentage
** CONCATENATE wa_nodestab-text4(17) c_perc "'%'
** INTO wa_nodestab-text4(19) SEPARATED BY space.
** wa_nodestab-tlength4 = c_19.
** wa_nodestab-tcolor4 = c_3.
** CLEAR: l_diff, l_cost.
**
*******Begin of MOD-001
** IF ( v_ucomm = c_zero ).
**
** l_diff = wa_ordmats-menge - l_qty.
**
** ELSE.
**
** l_diff = wa_ordmats-menge - wa_ordmats-stdqy.
**
** ENDIF.
*******End of MOD-001
**
** IF NOT wa_ordmats-peinh IS INITIAL.
** l_cost = ( wa_ordmats-stprs * l_diff ) / wa_ordmats-peinh.
** l_cost = l_cost * -1.
** ENDIF.
**
*******Begin of MOD-001
*** IF v_ucomm1 = c_qty.
***
*** MOVE l_diff TO wa_nodestab-text5(15). " Variance
***
*** ELSE.
**
** MOVE l_cost TO wa_nodestab-text5(15). " Variance
**
*** ENDIF.
********End of MOD-001
**
** wa_nodestab-tlength5 = c_15.
** wa_nodestab-tcolor5 = c_3.
**
** l_var_total = l_var_total + l_cost. " Subtotal of Variance
** l_var_gtot = l_var_gtot + l_cost. " Grand total
**
** APPEND wa_nodestab TO i_nodestab.
*****************MOD-003*********************
** CLEAR: wa_ordmats.
****************mod-003**********************
**
** ENDLOOP.
**
*** Displaying Subtotals
**
** CLEAR wa_nodestab.
** wa_nodestab-id = c_4_1.
** wa_nodestab-tlevel = c_4.
** wa_nodestab-parent = c_3_2.
**
** wa_nodestab-text = 'Material Totals'(043).
** wa_nodestab-tlength = c_18.
** wa_nodestab-tcolor = c_6.
**
** wa_nodestab-text1 = space.
** wa_nodestab-tlength1 = c_30.
** wa_nodestab-tcolor1 = c_6.
**
** MOVE l_act_total TO wa_nodestab-text2(20) .
** wa_nodestab-tlength2 = c_20.
** wa_nodestab-tcolor2 = c_6.
**
** MOVE l_std_total TO wa_nodestab-text3(20) .
** wa_nodestab-tlength3 = c_20.
** wa_nodestab-tcolor3 = c_6.
**
** wa_nodestab-text4 = space.
** wa_nodestab-tlength4 = c_19.
** wa_nodestab-tcolor4 = c_6.
**
** MOVE l_var_total TO wa_nodestab-text5(15) .
** wa_nodestab-tlength5 = c_15.
** wa_nodestab-tcolor5 = c_6.
**
** APPEND wa_nodestab TO i_nodestab.
** CLEAR : wa_pro_orders, wa_nodestab.
**
** ENDLOOP.
**
*** Displaying Grand total
** CLEAR wa_nodestab.
** wa_nodestab-id = c_2_1.
** wa_nodestab-tlevel = c_2.
** wa_nodestab-parent = c_1_1.
**
** wa_nodestab-text = 'Process Order Totals'(044).
** wa_nodestab-tlength = c_26.
** wa_nodestab-tcolor = c_5.
**
** wa_nodestab-text1 = space.
** wa_nodestab-tlength1 = c_30.
** wa_nodestab-tcolor1 = c_5.
**
** MOVE l_act_gtot TO wa_nodestab-text2(20) .
** wa_nodestab-tlength2 = c_20.
** wa_nodestab-tcolor2 = c_5.
**
** MOVE l_std_gtot TO wa_nodestab-text3(20) .
** wa_nodestab-tlength3 = c_20.
** wa_nodestab-tcolor3 = c_5.
**
** wa_nodestab-text4 = space.
** wa_nodestab-tlength4 = c_19.
** wa_nodestab-tcolor4 = c_5.
**
** MOVE l_var_gtot TO wa_nodestab-text5(15) .
** wa_nodestab-tlength5 = c_15.
** wa_nodestab-tcolor5 = c_5 .
**
** APPEND wa_nodestab TO i_nodestab.
**
** CLEAR : wa_nodestab.
**
**ENDFORM. " DISPLAY_DETAIL_REPORT
***&--------------------------------------------------------------------
***
***& Form DISPLAY_SUMMARY_REPORT
***&--------------------------------------------------------------------
***
*** text
***---------------------------------------------------------------------
***
***---------------------------------------------------------------------
***
**FORM display_summary_report.
** DATA: l_diff TYPE menge_d,
** l_gamng TYPE menge_d,
** l_gmein TYPE meins,
**
** l_ltext TYPE ktext,
**
** l_tot_orders TYPE i,
**
** l_effic TYPE p DECIMALS 1, "
** MOD-001++
** l_effic1 TYPE p DECIMALS 1, "
** MOD-001++
** l_plan_effic TYPE char05, "
** MOD-001++
** l_plant_effic TYPE char05, "
** MOD-001++
** l_sum_plan_effic TYPE p DECIMALS 1,
** l_sum_plant_effic TYPE p DECIMALS 1,
**
** l_qty TYPE menge_d,
** l_conv TYPE menge_d,
** l_aqty TYPE menge_d,
** l_sqty TYPE menge_d,
**
** l_prdqty TYPE menge_d,
** l_sum_prdqty TYPE menge_d,
**
** l_pcent(3) TYPE p DECIMALS 2,
** l_cost(8) TYPE p DECIMALS 2,
**
** l_act_total(8) TYPE p DECIMALS 2,
** l_std_total(8) TYPE p DECIMALS 2,
** l_var_total(8) TYPE p DECIMALS 2,
**
** l_fromuom TYPE meins.
**
***- Begin of MOD-001
** DATA: l_value TYPE char16,
** l_tmp TYPE lmnga,
** l_tmp1 TYPE lmnga.
***- End of MOD-001
**
** PERFORM pfstatus.
** SET PF-STATUS 'MAIN' EXCLUDING i_fcode.
** SET TITLEBAR 'VARI' WITH text-067.
**
** CLEAR wa_nodestab.
** REFRESH i_nodestab.
**
** MOVE 'Display summary Report'(029) TO v_output_text.
** PERFORM inform_user_of_progress.
**
** CLEAR wa_nodestab.
** wa_nodestab-id = c_1.
** wa_nodestab-tlevel = c_1.
** wa_nodestab-text = 'Production Variances (Summary Report)'(045).
** wa_nodestab-tlength = c_40.
** wa_nodestab-compress = c_x.
** APPEND wa_nodestab TO i_nodestab.
**
** CLEAR wa_nodestab.
** wa_nodestab-id = c_2_1.
** wa_nodestab-tlevel = c_2.
** wa_nodestab-parent = c_1_1.
**
** wa_nodestab-text = 'Summary of Orders for'(046).
** wa_nodestab-tlength = c_22.
** wa_nodestab-tcolor = c_1.
**
** CONCATENATE 'Plant:'(047) p_werks
** INTO wa_nodestab-text1 SEPARATED BY space.
** wa_nodestab-tlength1 = c_15.
** wa_nodestab-tcolor1 = c_1.
**
** CONCATENATE 'Phase Key:'(048) s_steus-low s_steus-high
** INTO wa_nodestab-text2 SEPARATED BY space.
** wa_nodestab-tlength2 = c_25.
** wa_nodestab-tcolor2 = c_1.
**
** IF s_arbpl[] IS INITIAL.
** wa_nodestab-text3 = 'Resources: All'(049).
** ELSE.
** CONCATENATE 'Resources:'(065) s_arbpl-low c_hyp s_arbpl-high
** INTO wa_nodestab-text3 SEPARATED BY space.
** ENDIF.
** wa_nodestab-tlength3 = c_20.
** wa_nodestab-tcolor3 = c_1.
**
** APPEND wa_nodestab TO i_nodestab.
**
******Begin of MOD-001
** CLEAR: l_sum_plan_effic, i_sum_ordmats, i_sum_activity.
******End of MOD-001
**
** LOOP AT i_pro_orders INTO wa_pro_orders.
**
** l_gamng = wa_pro_orders-gamng.
** l_gmein = wa_pro_orders-gmein.
**
*** Get actual produced Quantity or Confirm Quantity
** IF NOT ( rb_prod IS INITIAL ).
** l_prdqty = wa_pro_orders-menge.
** l_fromuom = wa_pro_orders-gruom.
** ELSE.
** l_prdqty = wa_pro_orders-lmnga.
**
**************************MOD-006**********************
*** l_fromuom = wa_pro_orders-cfuom.
** IF wa_pro_orders-cfuom IS INITIAL.
** SELECT aufnr rueck gmnga lmnga gmein meinh
** meilr stokz rueck_mst
** FROM afru INTO TABLE i_afru
** WHERE aufnr = wa_pro_orders-aufnr.
** IF NOT i_afru[] IS INITIAL.
** READ TABLE i_afru INTO wa_afru INDEX 1.
** IF sy-subrc = 0.
** l_fromuom = wa_afru-gmein.
** ENDIF.
** ENDIF.
** ELSE.
** l_fromuom = wa_pro_orders-cfuom.
** ENDIF.
**************************MOD-006*********************
** ENDIF.
** IF rb_kgm = c_x.
*** do actual conversion
** PERFORM uom_convert USING wa_pro_orders-plnbez
** l_prdqty
** l_fromuom
** l_conv.
** l_prdqty = l_conv.
*** do planned conversion
*********MOD-002********************************
*** l_fromuom = wa_pro_orders-gmein.
** l_fromuom = 'KG'.
*********Mod-002********************************
** PERFORM uom_convert USING wa_pro_orders-plnbez
** wa_pro_orders-gamng
** l_fromuom
** l_conv.
** l_gamng = l_conv.
** ENDIF.
*** Calculating Plan Effic value
** CLEAR l_plan_effic.
***- Begin of MOD-001
*** IF l_gamng GT 0.
*** l_diff = l_gamng - l_prdqty.
*** l_plan_effic = 100 - 100 * ( l_diff / l_gamng ).
*** ELSE.
*** CLEAR l_plan_effic.
*** ENDIF.
**
** LOOP AT i_plpo1 INTO wa_plpo1
** WHERE plnty = wa_pro_orders-plnty
** AND plnnr = wa_pro_orders-plnnr
** AND steus = 'YBN1'.
** IF wa_plpo1-vgw02 IS NOT INITIAL.
** MOVE wa_plpo1-usr04 TO l_effic. "L_VALUE.
** wa_plpo2 = wa_plpo1.
** APPEND wa_plpo2 TO i_plpo2.
******************mod-002************************
*** CONDENSE L_VALUE.
*** write l_effic to l_plan_effic.
*** L_PLAN_EFFIC = floor( L_VALUE ).
******************mod-002************************
** ELSE.
** CLEAR l_plan_effic.
** ENDIF.
**
** ENDLOOP.
**
**********************MOD-008**************************************
*** LOOP AT I_ORDOPS INTO WA_ORDOPS.
*** READ TABLE I_PRO_ORDERS INTO WA_PRO_ORDERS WITH KEY
*** AUFNR = WA_ORDOPS-AUFNR
*** BINARY SEARCH.
*** IF SY-SUBRC = 0.
*** READ table i_afvc1 into wa_afvc1 with key
*** plnty = wa_ORDOPS-plnty
*** plnnr = wa_ORDOPS-plnnr
*** plnkn = wa_ORDOPS-plnkn
*** zaehl = wa_ORDOPS-zaehl
*** aufpl = wa_pro_orders-aufpl.
*** IF SY-SUBRC = 0.
*** READ TABLE I_AFVV1 into wa_afvv1 with key
*** aufpl = wa_afvc1-aufpl
*** aplzl = wa_afvc1-aplzl binary search.
*** IF SY-SUBRC = 0.
*** CHECK WA_AFVV1-VGW02 NE 0.
*** l_tmp = wa_afvv1-bmsch * wa_afvv1-ism02.
*** IF l_tmp IS NOT INITIAL.
***
*** l_tmp1 = ( wa_afvv1-lmnga * wa_afvv1-vgw02 ) / l_tmp.
***
*** l_tmp1 = l_tmp1 * 100.
***
*** MOVE l_tmp1 TO l_effic.
***
*** ENDIF.
*** ENDIF.
*** ENDIF.
*** ENDIF.
*** ENDLOOP.
********************MOD-008*******************************************
*
**
*******Mod-002*******************************
*** READ TABLE i_afvc INTO wa_afvc
*** WITH KEY plnty = wa_plpo1-plnty
*** plnnr = wa_plpo1-plnnr
*** zaehl = wa_plpo1-zaehl.
**
** LOOP AT i_plpo2 INTO wa_plpo2..
** CLEAR: wa_afvc, wa_afvv.
** READ TABLE i_afvc INTO wa_afvc
** WITH KEY plnty = wa_plpo2-plnty
** plnnr = wa_plpo2-plnnr
** plnkn = wa_plpo2-plnkn
** zaehl = wa_plpo2-zaehl
** aufpl = wa_pro_orders-aufpl.
**
***Mod-002*************************************
**
** IF sy-subrc IS INITIAL.
** READ TABLE i_afvv INTO wa_afvv
** WITH KEY aufpl = wa_afvc-aufpl
** aplzl = wa_afvc-aplzl.
**
** l_tmp = wa_afvv-bmsch * wa_afvv-ism02.
** IF l_tmp IS NOT INITIAL.
**
** l_tmp1 = ( wa_afvv-lmnga * wa_afvv-vgw02 ) / l_tmp.
**
** l_tmp1 = l_tmp1 * 100.
**
** MOVE l_tmp1 TO l_effic1.
**
** ENDIF.
**
** ENDIF.
** ENDLOOP.
**
*** CLEAR v_plant_effic.
*** PERFORM plant_effic USING wa_pro_orders-plnty
*** wa_pro_orders-plnnr wa_pro_orders-plnkn
*** wa_pro_orders-zaehl
*** CHANGING v_plant_effic.
*** l_sum_plan_effic = l_sum_plan_effic + l_plan_effic.
** l_sum_plan_effic = l_sum_plan_effic + l_effic.
*** l_sum_plant_effic = l_sum_plant_effic + v_plant_effic.
** l_sum_plant_effic = l_sum_plant_effic + l_effic1.
***- End of MOD-001
** l_sum_prdqty = l_sum_prdqty + l_prdqty.
**
*****Begin of MOD-001
*** CLEAR: i_sum_activity. "l_prdqty
*****End of MOD-001
** LOOP AT i_ordops INTO wa_ordops
** WHERE aufnr = wa_pro_orders-aufnr.
** PERFORM activity_report USING l_prdqty l_gamng l_fromuom l_gmein
  .
** CLEAR : wa_ordops.
** ENDLOOP.
**
**LOOP AT i_ordmats INTO wa_ordmats WHERE aufnr = wa_pro_orders-aufnr.
** PERFORM summary_materials.
** CLEAR : wa_ordmats.
** ENDLOOP.
** CLEAR : wa_pro_orders.
** ENDLOOP.
** CLEAR: l_plan_effic, v_plant_effic, l_prdqty, l_tot_orders.
**
*** Passing summraised data to internal table for printing.
** DESCRIBE TABLE i_pro_orders LINES l_tot_orders.
** IF l_tot_orders > 0.
*** l_plan_effic = l_sum_plan_effic / l_tot_orders. " MOD-001--
** l_effic = l_sum_plan_effic / l_tot_orders. "
** MOD-001++
*** v_plant_effic = l_sum_plant_effic / l_tot_orders." MOD-001--
** l_effic1 = l_sum_plant_effic / l_tot_orders. "
** MOD-001++
** ENDIF.
** CLEAR wa_nodestab.
** wa_nodestab-id = c_2_2.
** wa_nodestab-tlevel = c_3.
** wa_nodestab-parent = c_1_1.
**
** IF NOT ( rb_prod IS INITIAL ).
** wa_nodestab-text = 'Produced Qty:'(050).
** ELSE.
** wa_nodestab-text = 'Confirmed Qty:'(051).
** ENDIF.
** wa_nodestab-tlength = c_15.
** wa_nodestab-tcolor = c_4.
**
** MOVE l_sum_prdqty TO wa_nodestab-text1(20).
** wa_nodestab-tlength1 = c_20.
** wa_nodestab-tcolor1 = c_4.
**
*** CONCATENATE 'Plan Effic:'(036) l_plan_effic c_perc "'%'
** WRITE l_effic TO l_plan_effic.
** CONCATENATE 'Exp. Line Eff.'(036) l_plan_effic c_perc "'%'
** INTO wa_nodestab-text2 SEPARATED BY space.
** wa_nodestab-tlength2 = c_25.
** wa_nodestab-tcolor2 = c_4.
**
*** CONCATENATE 'Plant Effic:'(037) v_plant_effic c_perc "'%'
** WRITE l_effic1 TO l_plant_effic.
** CONCATENATE 'Act. Line Eff.'(037) l_plant_effic c_perc "'%'
** INTO wa_nodestab-text3 SEPARATED BY space.
** wa_nodestab-tlength3 = c_25.
** wa_nodestab-tcolor3 = c_4.
**
** APPEND wa_nodestab TO i_nodestab.
**
*** Summarised Phase Information
** CLEAR wa_nodestab.
** wa_nodestab-id = c_3_3.
** wa_nodestab-tlevel = c_3.
** wa_nodestab-parent = c_1_1.
**
** wa_nodestab-text = 'Activity'(052).
** wa_nodestab-tlength = c_40.
** wa_nodestab-tcolor = c_4.
**
** IF rb_fiscl = c_x.
** CONCATENATE 'Actual Usage'(040) v_waers
** INTO wa_nodestab-text1 SEPARATED BY space.
** ELSE.
** wa_nodestab-text1 = 'Actual Usage'(040).
** ENDIF.
** wa_nodestab-tlength1 = c_20.
** wa_nodestab-tcolor1 = c_4.
**
** IF rb_fiscl = c_x.
** CONCATENATE 'Standard Usage'(041) v_waers
** INTO wa_nodestab-text2 SEPARATED BY space.
** ELSE.
** wa_nodestab-text2 = 'Standard Usage'(041).
** ENDIF.
** wa_nodestab-tlength2 = c_20.
** wa_nodestab-tcolor2 = c_4.
**
** IF rb_fiscl = c_x.
** CONCATENATE 'Activity Variance'(042) v_waers
** INTO wa_nodestab-text3 SEPARATED BY space.
** ELSE.
** wa_nodestab-text3 = 'Activity Variance'(042).
** ENDIF.
** wa_nodestab-tlength3 = c_35.
** wa_nodestab-tcolor3 = c_4.
**
** APPEND wa_nodestab TO i_nodestab.
**
*** Summarized activities
** CLEAR: l_act_total, l_std_total, l_var_total.
** SORT i_sum_activity BY lar.
** LOOP AT i_sum_activity INTO wa_sum_activity.
**
** SELECT ltext FROM cslt INTO l_ltext
** WHERE spras = sy-langu
** AND kokrs = p_kokrs
** AND lstar = wa_sum_activity-lar.
** ENDSELECT.
**
**
** IF sy-subrc = 0.
***Not required to handle
** ENDIF.
**
**
** CLEAR wa_nodestab.
** wa_nodestab-id = c_3_4.
** wa_nodestab-tlevel = c_4.
** wa_nodestab-parent = c_3_3.
**
** wa_nodestab-text1 = l_ltext.
** wa_nodestab-tlength1 = c_36.
** wa_nodestab-tcolor1 = c_3.
**
** IF rb_fiscl IS INITIAL.
** MOVE wa_sum_activity-afru_ism TO wa_nodestab-text2(20).
** wa_nodestab-tlength2 = c_20.
** wa_nodestab-tcolor2 = c_3.
**
** MOVE wa_sum_activity-ism_should TO wa_nodestab-text3(20).
** wa_nodestab-tlength3 = c_20.
** wa_nodestab-tcolor3 = c_3.
**
** MOVE wa_sum_activity-ism_var TO wa_nodestab-text4(20).
** wa_nodestab-tlength4 = c_20.
** wa_nodestab-tcolor4 = c_3.
**
** ELSE.
** MOVE wa_sum_activity-coact TO wa_nodestab-text2(20).
** wa_nodestab-tlength2 = c_20.
** wa_nodestab-tcolor2 = c_3.
**
** MOVE wa_sum_activity-costd TO wa_nodestab-text3(20).
** wa_nodestab-tlength3 = c_20.
** wa_nodestab-tcolor3 = c_3.
**
** MOVE wa_sum_activity-covar TO wa_nodestab-text4(20).
** wa_nodestab-tlength4 = c_20.
** wa_nodestab-tcolor4 = c_3.
**
** l_act_total = l_act_total + wa_sum_activity-coact.
** l_std_total = l_std_total + wa_sum_activity-costd.
** l_var_total = l_var_total + wa_sum_activity-covar.
** ENDIF.
** APPEND wa_nodestab TO i_nodestab.
** CLEAR : wa_nodestab, wa_sum_activity.
** ENDLOOP.
** IF NOT ( rb_fiscl IS INITIAL ).
**
*** Display sub-total of Activities.
** CLEAR wa_nodestab.
** wa_nodestab-id = c_3_4.
** wa_nodestab-tlevel = c_4.
** wa_nodestab-parent = c_3_3.
**
** IF rb_fiscl = c_x.
** CONCATENATE 'Fiscal Activity Totals:'(053) v_waers
** INTO wa_nodestab-text1 SEPARATED BY space.
** ELSE.
** wa_nodestab-text1 = 'Fiscal Activity Totals:'(053).
** ENDIF.
** wa_nodestab-tlength1 = c_36.
** wa_nodestab-tcolor1 = c_2.
**
** MOVE l_act_total TO wa_nodestab-text2(20).
** wa_nodestab-tlength2 = c_20.
** wa_nodestab-tcolor2 = c_2.
**
** MOVE l_std_total TO wa_nodestab-text3(20).
** wa_nodestab-tlength3 = c_20.
** wa_nodestab-tcolor3 = c_2.
**
** MOVE l_var_total TO wa_nodestab-text4(20).
** wa_nodestab-tlength4 = c_20.
** wa_nodestab-tcolor4 = c_2.
**
** APPEND wa_nodestab TO i_nodestab.
** ENDIF.
*** Summarized Material Information
** CLEAR wa_nodestab.
** wa_nodestab-id = c_6_1.
** wa_nodestab-tlevel = c_3.
** wa_nodestab-parent = c_2_2.
**
** PERFORM material_header.
**
** CLEAR: l_act_total, l_std_total, l_var_total.
** SORT i_sum_ordmats BY matnr.
** LOOP AT i_sum_ordmats INTO wa_sum_ordmats .
** CLEAR: wa_nodestab.
** wa_nodestab-id = c_4_1.
** wa_nodestab-tlevel = c_4.
** wa_nodestab-parent = c_3_2.
**
*** Material Number
** WRITE wa_sum_ordmats-matnr TO wa_nodestab-text NO-ZERO.
** wa_nodestab-tlength = c_18.
** wa_nodestab-tcolor = c_3.
**
*** Material Description
** CLEAR wa_material_des.
** READ TABLE i_material_des INTO wa_material_des
** WITH KEY matnr = wa_sum_ordmats-matnr.
** wa_nodestab-text1 = wa_material_des-maktx.
** wa_nodestab-tlength1 = c_30.
** wa_nodestab-tcolor1 = c_3.
**
*** Standard planned or zero loss planned
**
** IF rb_zloss IS INITIAL.
** l_qty = wa_sum_ordmats-stdqy.
** ELSE.
** l_qty = wa_sum_ordmats-zloss.
** ENDIF.
**
*** Order uom or kgm
** IF rb_kgm IS INITIAL.
** l_aqty = wa_sum_ordmats-menge.
** l_sqty = l_qty.
** ELSE.
*** do actual conversion
** PERFORM uom_convert USING wa_sum_ordmats-matnr
** wa_sum_ordmats-menge
** wa_sum_ordmats-amein
** l_aqty.
*** do std/zloss conversion
** PERFORM uom_convert USING wa_ordmats-matnr
** wa_ordmats-stdqy
** wa_ordmats-meins
** l_sqty.
** ENDIF.
**
** PERFORM std_percentage_calc USING l_aqty l_sqty l_pcent.
**
*** Fiscal or quantity
** IF rb_fiscl IS INITIAL.
** MOVE l_aqty TO wa_nodestab-text2(20). " Actual Usage
** wa_nodestab-tlength2 = c_20.
** wa_nodestab-tcolor2 = c_3.
**
** MOVE l_sqty TO wa_nodestab-text3(20). " Standard Usage
** wa_nodestab-tlength3 = c_20.
** wa_nodestab-tcolor3 = c_3.
**
** ELSE.
** IF NOT wa_sum_ordmats-peinh IS INITIAL.
** CLEAR l_cost.
** l_cost = ( wa_sum_ordmats-stprs * wa_sum_ordmats-menge )
** / wa_sum_ordmats-peinh.
** MOVE l_cost TO wa_nodestab-text2(20). " Acutal Usage
** wa_nodestab-tlength2 = c_20.
** wa_nodestab-tcolor2 = c_3.
**
** l_act_total = l_act_total + l_cost. " Subtotal of actual
**
** ENDIF.
** IF NOT wa_sum_ordmats-peinh IS INITIAL.
** CLEAR l_cost.
** l_cost = ( wa_sum_ordmats-stprs * wa_sum_ordmats-stdqy )
** / wa_sum_ordmats-peinh.
** MOVE l_cost TO wa_nodestab-text3(20). " Standard Usage
** wa_nodestab-tlength3 = c_20.
** wa_nodestab-tcolor3 = c_3.
**
** l_std_total = l_std_total + l_cost. " Subtotal of standard
**
** ENDIF.
** ENDIF.
**
** MOVE l_pcent TO wa_nodestab-text4(18). " Variance Percentage
** CONCATENATE wa_nodestab-text4(18) c_perc "'%'
** INTO wa_nodestab-text4(20) SEPARATED BY space.
** wa_nodestab-tlength4 = c_20. "c_19.
** wa_nodestab-tcolor4 = c_3.
**
** CLEAR: l_diff, l_cost.
** l_diff = wa_sum_ordmats-menge - wa_sum_ordmats-stdqy.
** IF NOT wa_sum_ordmats-peinh IS INITIAL.
**l_cost = ( wa_sum_ordmats-stprs * l_diff ) / wa_sum_ordmats-peinh.
** l_cost = l_cost * -1.
** ENDIF.
**
** MOVE l_cost TO wa_nodestab-text5(20). " Variance "15
** wa_nodestab-tlength5 = c_20. "c_15
** wa_nodestab-tcolor5 = c_3.
**
** l_var_total = l_var_total + l_cost. " Subtotal of Variance
**
** APPEND wa_nodestab TO i_nodestab.
** CLEAR : wa_nodestab, wa_sum_ordmats.
** ENDLOOP.
*** Displaying Subtotals
** IF NOT ( rb_fiscl IS INITIAL ).
**
** CLEAR wa_nodestab.
** wa_nodestab-id = c_4_1.
** wa_nodestab-tlevel = c_4.
** wa_nodestab-parent = c_3_2.
**
** IF rb_fiscl = c_x.
** CONCATENATE 'Fiscal quantity Totals:'(054) v_waers
** INTO wa_nodestab-text SEPARATED BY space.
** ELSE.
** wa_nodestab-text = 'Fiscal quantity Totals:'(054).
** ENDIF.
** wa_nodestab-tlength = c_30.
** wa_nodestab-tcolor = c_6.
**
** wa_nodestab-text1 = space.
** wa_nodestab-tlength1 = c_18.
** wa_nodestab-tcolor1 = c_6.
**
** MOVE l_act_total TO wa_nodestab-text2(20) .
** wa_nodestab-tlength2 = c_20.
** wa_nodestab-tcolor2 = c_6.
**
** MOVE l_std_total TO wa_nodestab-text3(20) .
** wa_nodestab-tlength3 = c_20.
** wa_nodestab-tcolor3 = c_6.
**
** wa_nodestab-text4 = space.
** wa_nodestab-tlength4 = c_19.
** wa_nodestab-tcolor4 = c_6.
**
** MOVE l_var_total TO wa_nodestab-text5(21) .
** wa_nodestab-tlength5 = c_21. "15.
** wa_nodestab-tcolor5 = c_6.
**
** APPEND wa_nodestab TO i_nodestab.
** ELSE.
** CLEAR wa_nodestab.
** wa_nodestab-id = c_4_1.
** wa_nodestab-tlevel = c_4.
** wa_nodestab-parent = c_3_2.
**
** IF rb_fiscl = c_x.
** CONCATENATE 'Variance Fiscal Total:'(055) v_waers
** INTO wa_nodestab-text SEPARATED BY space.
** ELSE.
** wa_nodestab-text = 'Variance Fiscal Total:'(055).
** ENDIF.
** wa_nodestab-tlength = c_29.
** wa_nodestab-tcolor = c_6.
**
** wa_nodestab-text1 = space.
** wa_nodestab-tlength1 = c_40.
** wa_nodestab-tcolor1 = c_6.
**
** wa_nodestab-text2 = space.
** wa_nodestab-tlength2 = '41'. "c_40.
** wa_nodestab-tcolor2 = c_6.
**
** MOVE l_var_total TO wa_nodestab-text3(20) .
** wa_nodestab-tlength3 = c_20. "c_15.
** wa_nodestab-tcolor3 = c_6.
**
** APPEND wa_nodestab TO i_nodestab.
** ENDIF.
**ENDFORM. " DISPLAY_SUMMARY_REPORT
***&--------------------------------------------------------------------
***
***& Form DISPLAY_PHASE_REPORT
***&--------------------------------------------------------------------
***
*** text
***---------------------------------------------------------------------
***
***---------------------------------------------------------------------
***
**FORM display_phase_report.
**
** DATA: l_date_low(10) TYPE c,
** l_date_high(10) TYPE c,
** l_diff TYPE menge_d,
*** l_plan_effic(3) TYPE c,
** l_plan_effic TYPE char05, "MOD-001++
** l_plant_effic TYPE char05, "MOD-001++
** l_gamng TYPE menge_d,
** l_gamng1(20) TYPE c,
** l_gmein TYPE meins,
**
** l_qty TYPE menge_d,
** l_prdqty TYPE menge_d,
** l_conv TYPE menge_d,
** l_aqty TYPE menge_d,
** l_sqty TYPE menge_d,
**
** l_pcent(3) TYPE p DECIMALS 2,
** l_cost(8) TYPE p DECIMALS 2,
**
** l_act_total(8) TYPE p DECIMALS 2,
** l_std_total(8) TYPE p DECIMALS 2,
** l_var_total(8) TYPE p DECIMALS 2,
**
** l_fromuom TYPE meins,
** l_cfuom TYPE meins,
**
** l_ph_bmsch TYPE i.
***- Begin of MOD-001
** DATA: l_value TYPE char16,
** l_tmp TYPE lmnga,
** l_tmp1 TYPE lmnga,
** l_effic TYPE p DECIMALS 1,
** l_uom TYPE char03.
***- End of MOD-001
**
**
** PERFORM pfstatus.
** SET PF-STATUS 'MAIN' EXCLUDING i_fcode.
** SET TITLEBAR 'VARI' WITH text-068.
**
** CLEAR wa_nodestab.
** REFRESH i_nodestab.
**
** MOVE 'Display Phase Report'(030) TO v_output_text.
** PERFORM inform_user_of_progress.
**
** CLEAR wa_nodestab.
** wa_nodestab-id = c_1_1.
** wa_nodestab-tlevel = c_1.
** wa_nodestab-text = 'Production Variances'(031).
** wa_nodestab-tlength = c_20.
** wa_nodestab-compress = c_x.
** APPEND wa_nodestab TO i_nodestab.
**
** LOOP AT i_pro_orders INTO wa_pro_orders.
**
** CLEAR: wa_nodestab, l_date_low, l_date_high, l_gamng,
** wa_material_des.
**
** l_gamng = wa_pro_orders-gamng.
** l_gmein = wa_pro_orders-gmein.
** wa_nodestab-id = c_2_1.
** wa_nodestab-tlevel = c_2.
** wa_nodestab-parent = c_1_1.
**
*** Order Number text
** wa_nodestab-text = 'Order Num:'(032).
** wa_nodestab-tlength = c_12.
** wa_nodestab-tcolor = c_1.
*** Order number
** WRITE wa_pro_orders-aufnr TO wa_nodestab-text1 NO-ZERO.
** wa_nodestab-tlength1 = c_12.
** wa_nodestab-tcolor1 = c_1.
** wa_nodestab-hotspot1 = c_x.
**
*** Date Range
** WRITE wa_pro_orders-wdate TO l_date_low.
** WRITE wa_pro_orders-gltrp TO l_date_high.
** CONCATENATE l_date_low c_hyp l_date_high
** INTO wa_nodestab-text2 SEPARATED BY space.
** wa_nodestab-tlength2 = c_25.
** wa_nodestab-tcolor2 = c_1.
**
*** Material Number
** WRITE wa_pro_orders-plnbez TO wa_nodestab-text3 NO-ZERO.
** wa_nodestab-tlength3 = c_18.
** wa_nodestab-tcolor3 = c_1.
**
*** Material Description
** READ TABLE i_material_des INTO wa_material_des
** WITH KEY matnr = wa_pro_orders-plnbez.
** wa_nodestab-text4 = wa_material_des-maktx.
** wa_nodestab-tlength4 = c_33.
** wa_nodestab-tcolor4 = c_1.
**
** APPEND wa_nodestab TO i_nodestab.
**
** LOOP AT i_ordops INTO wa_ordops
** WHERE aufnr = wa_pro_orders-aufnr.
** PERFORM get_confirmation_qty USING wa_ordops-rueck
** l_prdqty l_cfuom.
** IF rb_kgm = c_x.
** IF rb_conf IS INITIAL.
** l_prdqty = wa_pro_orders-menge.
** l_fromuom = wa_pro_orders-gruom.
** ELSE.
** l_fromuom = l_cfuom.
** ENDIF.
*** do gr/conf conversion
** PERFORM uom_convert USING wa_pro_orders-plnbez l_prdqty
** l_fromuom l_conv.
** l_prdqty = l_conv.
** l_qty = l_prdqty.
*** do planned conversion
*********mod-002*******************************
*** l_fromuom = wa_pro_orders-gmein.
** l_fromuom = 'KG'.
********MOD-002********************************
**
** PERFORM uom_convert USING wa_pro_orders-plnbez
** wa_pro_orders-gamng
** l_fromuom l_conv.
** l_gamng = l_conv.
** ELSE.
*** Get Standard Numbers from the phase
** READ TABLE i_plpo INTO wa_plpo
** WITH KEY plnty = wa_pro_orders-plnty
** plnnr = wa_pro_orders-plnnr
** plnkn = wa_pro_orders-plnkn
** zaehl = wa_pro_orders-zaehl.
** PERFORM get_stds USING wa_ordops-plnty wa_ordops-plnnr
** wa_ordops-plnkn wa_ordops-zaehl.
*** Factor in any differences in uoms (plpo selected in get_stds form)
** l_ph_bmsch = wa_plpo-bmsch / ( wa_plpo-umrez / wa_plpo-umren )
  .
*** calculate planned phase qty as planned order qty / final phase std
**qty
*** current phase std qty
** l_gamng = ( wa_pro_orders-gamng / wa_plpo-bmsch ) * l_ph_bmsch
  .
*** Get actual produced Qty (from order) or use Confirm Qty (from phase)
** IF rb_conf IS INITIAL.
*** Factor in any differences in uoms (plpo
** selected in plant_effic form)
** l_qty = ( wa_pro_orders-menge / wa_plpo-bmsch ) * l_ph_bmsch
  .
** l_prdqty = wa_pro_orders-menge.
** l_fromuom = wa_pro_orders-gruom.
** ELSE.
** l_qty = ( l_prdqty / wa_plpo-bmsch ) * l_ph_bmsch.
** l_fromuom = l_cfuom.
** ENDIF.
** ENDIF.
**
***- begin of MOD-001
*** Calculate Plan effic.
*** CLEAR l_plan_effic.
***
*** IF l_gamng > 0.
*** l_diff = ABS( l_gamng - l_qty ).
*** l_plan_effic = c_100 - c_100 * ( l_diff / l_gamng ).
*** ELSE.
*** CLEAR l_plan_effic.
*** ENDIF.
**
** LOOP AT i_plpo1 INTO wa_plpo1
** WHERE plnty = wa_pro_orders-plnty
** AND plnnr = wa_pro_orders-plnnr
** AND steus = 'YBN1'.
** IF wa_plpo1-vgw02 IS NOT INITIAL.
** MOVE wa_plpo1-usr04 TO l_effic. "L_VALUE.
** WRITE l_effic TO l_plan_effic.
** wa_plpo2 = wa_plpo1.
** APPEND wa_plpo2 TO i_plpo2.
***********MOD-002*******************************
*** ELSE.
*** CLEAR l_plan_effic.
** ENDIF.
**********MOD-002********************************
** ENDLOOP.
**
**
***- End of MOD-001
*** Resource Information
** CLEAR wa_nodestab.
** wa_nodestab-id = c_2_2.
** wa_nodestab-tlevel = c_3.
** wa_nodestab-parent = c_1_1.
**
** CONCATENATE 'Resource:'(056) wa_pro_orders-arbpl
** INTO wa_nodestab-text SEPARATED BY space.
** wa_nodestab-tlength = c_25.
** wa_nodestab-tcolor = c_4.
**
** READ TABLE i_wc_text INTO wa_wc_text
** WITH KEY objid = wa_pro_orders-arbid.
** wa_nodestab-text1 = wa_wc_text-ktext.
** wa_nodestab-tlength1 = c_30.
** wa_nodestab-tcolor1 = c_4.
**
*************MOD-002*********************************
** wa_nodestab-text2 = wa_ordops-vornr.
** wa_nodestab-tlength2 = c_4.
** wa_nodestab-tcolor2 = c_4.
**
**********mod-002************************************
**
*** Produced Quantity / Confirmed Quantity
** MOVE l_prdqty TO wa_nodestab-text3(20).
** MOVE l_fromuom TO l_uom. "
** MOD-001++
** IF NOT ( rb_prod IS INITIAL ).
*** CONCATENATE 'Prod Qty: '(033) wa_nodestab-text2 "MOD-001-
** CONCATENATE 'Prod Qty: '(033) wa_nodestab-text3 l_uom"MOD-001+
** INTO wa_nodestab-text3 SEPARATED BY space.
** ELSE.
*** CONCATENATE 'Conf Qty: '(034) wa_nodestab-text2 "MOD-001-
** CONCATENATE 'Conf Qty: '(034) wa_nodestab-text3 l_uom"MOD-001+
** INTO wa_nodestab-text3 SEPARATED BY space.
** ENDIF.
**
*** wa_nodestab-tlength2 = c_30. "MOD-001-
** wa_nodestab-tlength3 = c_35_1. "MOD-001+
** wa_nodestab-tcolor3 = c_1.
**
*** CONCATENATE 'Plan Effic:'(036) l_plan_effic c_perc "'%'
** CONCATENATE 'Exp. Line Eff.'(036) l_plan_effic c_perc "'%'
** INTO wa_nodestab-text4 SEPARATED BY space.
** wa_nodestab-tlength4 = c_25.
** wa_nodestab-tcolor4 = c_4.
**
*** CLEAR v_plant_effic.
*** PERFORM plant_effic USING wa_ordops-plnty
*** wa_ordops-plnnr
*** wa_ordops-plnkn
*** wa_ordops-zaehl
*** CHANGING v_plant_effic.
** CLEAR l_effic.
***************mod-002**************************
*** READ TABLE I_AFVC INTO WA_AFVC
*** WITH KEY PLNTY = WA_PLPO1-PLNTY
*** PLNNR = WA_PLPO1-PLNNR
*** ZAEHL = WA_PLPO1-ZAEHL.
**** Mod-002***********************************
**
*****************MOD-008************************
*** LOOP AT I_ORDOPS INTO WA_ORDOPS.
*** READ TABLE I_PRO_ORDERS INTO WA_PRO_ORDERS WITH KEY
*** AUFNR = WA_ORDOPS-AUFNR
*** BINARY SEARCH.
*** IF SY-SUBRC = 0.
*** READ table i_afvc1 into wa_afvc1 with key
*** plnty = wa_ORDOPS-plnty
*** plnnr = wa_ORDOPS-plnnr
*** plnkn = wa_ORDOPS-plnkn
*** zaehl = wa_ORDOPS-zaehl
*** aufpl = wa_pro_orders-aufpl.
*** IF SY-SUBRC = 0.
*** READ TABLE I_AFVV1 into wa_afvv1 with key
*** aufpl = wa_afvc1-aufpl
*** aplzl = wa_afvc1-aplzl binary search.
*** IF SY-SUBRC = 0.
*** CHECK WA_AFVV1-VGW02 NE 0.
*** l_tmp = wa_afvv1-bmsch * wa_afvv1-ism02.
*** IF l_tmp IS NOT INITIAL.
***
*** l_tmp1 = ( wa_afvv1-lmnga * wa_afvv1-vgw02 ) / l_tmp.
***
*** l_tmp1 = l_tmp1 * 100.
***
*** MOVE l_tmp1 TO l_effic.
***
*** ENDIF.
*** ENDIF.
*** ENDIF.
*** ENDIF.
*** ENDLOOP.
***
***************MOD-008***************************
**
** LOOP AT i_plpo2 INTO wa_plpo2.
** READ TABLE i_afvc INTO wa_afvc
** WITH KEY plnty = wa_plpo2-plnty
** plnnr = wa_plpo2-plnnr
** plnkn = wa_plpo2-plnkn
** zaehl = wa_plpo2-zaehl
** aufpl = wa_pro_orders-aufpl.
**
**
**
**** Mod-002***********************************
**
** IF sy-subrc IS INITIAL.
** READ TABLE i_afvv INTO wa_afvv
** WITH KEY aufpl = wa_afvc-aufpl
** aplzl = wa_afvc-aplzl.
**
** l_tmp = wa_afvv-bmsch * wa_afvv-ism02.
** IF l_tmp IS NOT INITIAL.
**
** l_tmp1 = ( wa_afvv-lmnga * wa_afvv-vgw02 ) / l_tmp.
**
** l_tmp1 = l_tmp1 * 100.
**
** MOVE l_tmp1 TO l_effic.
**
** ENDIF.
**
** ENDIF.
** ENDLOOP.
**
** WRITE l_effic TO l_plant_effic.
**
*** CONCATENATE 'Plant Effic:'(037) v_plant_effic c_perc "'%'
** CONCATENATE 'Act. Line Eff.'(037) l_plant_effic c_perc "'%'
** " MOD-001+
** INTO wa_nodestab-text5 SEPARATED BY space.
** wa_nodestab-tlength5 = c_25.
** wa_nodestab-tcolor5 = c_4.
**
** APPEND wa_nodestab TO i_nodestab.
**
*** Phase Information
** CLEAR wa_nodestab.
** wa_nodestab-id = c_3_3.
** wa_nodestab-tlevel = c_3.
** wa_nodestab-parent = c_1_1.
**
** wa_nodestab-text = 'Phase'(038).
** wa_nodestab-tlength = c_10.
** wa_nodestab-tcolor = c_4.
**
** MOVE l_gamng TO l_gamng1.
** CONCATENATE 'Activity (Std Plan:'(039) l_gamng1 c_brac "')'
** INTO wa_nodestab-text1 SEPARATED BY space.
** wa_nodestab-tlength1 = c_42.
** wa_nodestab-tcolor1 = c_4.
**
** IF rb_fiscl = c_x.
** CONCATENATE 'Actual Usage'(040) v_waers
** INTO wa_nodestab-text2 SEPARATED BY space.
** ELSE.
** wa_nodestab-text2 = 'Actual Usage'(040).
** ENDIF.
** wa_nodestab-tlength2 = c_20.
** wa_nodestab-tcolor2 = c_4.
**
** IF rb_fiscl = c_x.
** CONCATENATE 'Standard Usage'(041) v_waers
** INTO wa_nodestab-text3 SEPARATED BY space.
** ELSE.
** wa_nodestab-text3 = 'Standard Usage'(041).
** ENDIF.
** wa_nodestab-tlength3 = c_20.
** wa_nodestab-tcolor3 = c_4.
**
** IF rb_fiscl = c_x.
** CONCATENATE 'Activity Variance'(042) v_waers
** INTO wa_nodestab-text4 SEPARATED BY space.
** ELSE.
** wa_nodestab-text4 = 'Activity Variance'(042).
** ENDIF.
** wa_nodestab-tlength4 = c_35.
** wa_nodestab-tcolor4 = c_4.
**
** APPEND wa_nodestab TO i_nodestab.
**
*** Display acitivity report
** PERFORM activity_report USING l_prdqty l_gamng l_uom l_gmein.
**
*** Material Information
** CLEAR: wa_nodestab, l_act_total, l_std_total, l_var_total.
** wa_nodestab-id = c_3_4.
** wa_nodestab-tlevel = c_3.
** wa_nodestab-parent = c_1_1.
**
** PERFORM material_header.
**
*** Individual material details
** LOOP AT i_ordmats INTO wa_ordmats
** WHERE aufnr = wa_pro_orders-aufnr
** AND vornr = wa_ordops-vornr.
**
** CLEAR: wa_nodestab.
** wa_nodestab-id = c_4_1.
** wa_nodestab-tlevel = c_4.
** wa_nodestab-parent = c_3_2.
**
*** Material Number
** WRITE wa_ordmats-matnr TO wa_nodestab-text NO-ZERO.
** wa_nodestab-tlength = c_18.
** wa_nodestab-tcolor = c_3.
**
*** Material Description
** CLEAR wa_material_des.
** READ TABLE i_material_des INTO wa_material_des
** WITH KEY matnr = wa_ordmats-matnr.
** wa_nodestab-text1 = wa_material_des-maktx.
** wa_nodestab-tlength1 = c_30.
** wa_nodestab-tcolor1 = c_3.
**
*** Standard planned or zero loss planned
**
** IF rb_zloss IS INITIAL.
** l_qty = wa_ordmats-stdqy.
** ELSE.
** l_qty = wa_ordmats-zloss.
** ENDIF.
**
*** Order uom or kgm
** IF rb_kgm IS INITIAL.
** l_aqty = wa_ordmats-menge.
** l_sqty = l_qty.
** ELSE.
*** do actual conversion
** PERFORM uom_convert USING wa_ordmats-matnr
** wa_ordmats-menge
** wa_ordmats-amein
** l_aqty.
*** do std/zloss conversion
** PERFORM uom_convert USING wa_ordmats-matnr
** wa_ordmats-stdqy
** wa_ordmats-meins
** l_sqty.
** ENDIF.
**
** PERFORM std_percentage_calc USING l_aqty l_sqty l_pcent.
**
*** Fiscal or quantity
** IF rb_fiscl IS INITIAL.
** MOVE l_aqty TO wa_nodestab-text2(20). " Actual Usage
** wa_nodestab-tlength2 = c_20.
** wa_nodestab-tcolor2 = c_3.
**
** MOVE l_sqty TO wa_nodestab-text3(20). " Standard Usage
** wa_nodestab-tlength3 = c_20.
** wa_nodestab-tcolor3 = c_3.
**
** ELSE.
** IF NOT wa_ordmats-peinh IS INITIAL.
** CLEAR l_cost.
** l_cost = ( wa_ordmats-stprs * wa_ordmats-menge )
** / wa_ordmats-peinh.
** MOVE l_cost TO wa_nodestab-text2(20). " Acutal Usage
** wa_nodestab-tlength2 = c_20.
** wa_nodestab-tcolor2 = c_3.
**
** l_act_total = l_act_total + l_cost. " Subtotal of actual
** ENDIF.
** IF NOT wa_ordmats-peinh IS INITIAL.
** CLEAR l_cost.
** l_cost = ( wa_ordmats-stprs * wa_ordmats-stdqy )
** / wa_ordmats-peinh.
** MOVE l_cost TO wa_nodestab-text3(20). " Standard Usage
** wa_nodestab-tlength3 = c_20.
** wa_nodestab-tcolor3 = c_3.
**
** l_std_total = l_std_total + l_cost. " Subtotal of standard
** ENDIF.
**
** ENDIF.
**
** MOVE l_pcent TO wa_nodestab-text4(17). " Variance Percentage
** CONCATENATE wa_nodestab-text4(17) c_perc "'%'
** INTO wa_nodestab-text4(19) SEPARATED BY space.
** wa_nodestab-tlength4 = 19.
** wa_nodestab-tcolor4 = c_3.
**
** CLEAR: l_diff, l_cost.
** l_diff = wa_ordmats-menge - wa_ordmats-stdqy.
** IF NOT wa_ordmats-peinh IS INITIAL.
** l_cost = ( wa_ordmats-stprs * l_diff ) / wa_ordmats-peinh.
** l_cost = l_cost * -1.
** ENDIF.
**
** MOVE l_cost TO wa_nodestab-text5(15). " Variance
** wa_nodestab-tlength5 = c_15.
** wa_nodestab-tcolor5 = c_3.
**
** l_var_total = l_var_total + l_cost. " Subtotal of Variance
**
** APPEND wa_nodestab TO i_nodestab.
**
** ENDLOOP.
**
*** Displaying Subtotals
** CHECK sy-subrc IS INITIAL.
** CLEAR wa_nodestab.
** wa_nodestab-id = c_4_1.
** wa_nodestab-tlevel = c_4.
** wa_nodestab-parent = c_3_2.
**
** wa_nodestab-text = 'Material Totals'(043).
** wa_nodestab-tlength = c_18.
** wa_nodestab-tcolor = c_6.
**
** wa_nodestab-text1 = space.
** wa_nodestab-tlength1 = c_30.
** wa_nodestab-tcolor1 = c_6.
**
** MOVE l_act_total TO wa_nodestab-text2(20) .
** wa_nodestab-tlength2 = c_20.
** wa_nodestab-tcolor2 = c_6.
**
** MOVE l_std_total TO wa_nodestab-text3(20) .
** wa_nodestab-tlength3 = c_20.
** wa_nodestab-tcolor3 = c_6.
**
** wa_nodestab-text4 = space.
** wa_nodestab-tlength4 = c_19.
** wa_nodestab-tcolor4 = c_6.
**
** MOVE l_var_total TO wa_nodestab-text5(15) .
** wa_nodestab-tlength5 = c_15.
** wa_nodestab-tcolor5 = c_6.
**
** APPEND wa_nodestab TO i_nodestab.
**
** ENDLOOP.
*** Output the materials which were issued to order but aren't on bom
** READ TABLE i_issued_mat INTO wa_issued_mat
** WITH KEY aufnr = wa_pro_orders-aufnr.
** IF sy-subrc = 0.
**
** CLEAR wa_nodestab.
** wa_nodestab-id = c_3_5.
** wa_nodestab-tlevel = c_3 .
** wa_nodestab-parent = c_1_1.
**
** wa_nodestab-text =
** 'Materials issued to order but not in Recipe'(057).
** wa_nodestab-tlength = c_45.
** wa_nodestab-tcolor = c_6.
**
** APPEND wa_nodestab TO i_nodestab.
**
*** Material Information
** CLEAR wa_nodestab.
** wa_nodestab-id = c_3_6.
** wa_nodestab-tlevel = c_3.
** wa_nodestab-parent = c_3_5.
**
** PERFORM material_header.
*** now write the components
**
** CLEAR: l_pcent, l_act_total, l_std_total, l_var_total.
**
** LOOP AT i_issued_mat INTO wa_issued_mat
** WHERE aufnr = wa_pro_orders-aufnr.
**
** CLEAR: wa_nodestab, l_aqty, l_sqty, l_cost, wa_material_des.
** wa_nodestab-id = c_6_1.
** wa_nodestab-tlevel = c_6.
** wa_nodestab-parent = c_3_6.
**
*** Material Number
** WRITE wa_issued_mat-matnr TO wa_nodestab-text NO-ZERO.
** wa_nodestab-tlength = c_18.
** wa_nodestab-tcolor = c_3.
**
*** Material Description
** READ TABLE i_material_des INTO wa_material_des
** WITH KEY matnr = wa_issued_mat-matnr.
** wa_nodestab-text1 = wa_material_des-maktx.
** wa_nodestab-tlength1 = c_30.
** wa_nodestab-tcolor1 = c_3.
**
** IF rb_fiscl IS INITIAL.
*** Actual Usage
** l_aqty = wa_issued_mat-menge.
** MOVE l_aqty TO wa_nodestab-text2(20). " Actual Usage
** wa_nodestab-tlength2 = c_20.
** wa_nodestab-tcolor2 = c_3.
**
*** Standard Usage
** MOVE l_sqty TO wa_nodestab-text3(20). " Standard Usage
** wa_nodestab-tlength3 = c_20.
** wa_nodestab-tcolor3 = c_3.
**
** ELSE.
** IF NOT wa_issued_mat-peinh IS INITIAL.
** l_cost = ( wa_issued_mat-stprs * wa_issued_mat-menge )
** / wa_issued_mat-peinh.
** ENDIF.
** l_act_total = l_act_total + l_cost. " Subtotal of actual
**
** MOVE l_cost TO wa_nodestab-text2(20). " Acutal Usage
** wa_nodestab-tlength2 = c_20.
** wa_nodestab-tcolor2 = c_3.
**
** CLEAR l_cost.
** MOVE l_cost TO wa_nodestab-text3(20). " Standard Usage
** wa_nodestab-tlength3 = c_20.
** wa_nodestab-tcolor3 = c_3.
**
** ENDIF.
*** Variance percentage
** l_pcent = 100.
** MOVE l_pcent TO wa_nodestab-text4(17). " Variance Percentage
** CONCATENATE wa_nodestab-text4(17) c_perc "'%'
** INTO wa_nodestab-text4(19) SEPARATED BY space.
** wa_nodestab-tlength4 = c_19.
** wa_nodestab-tcolor4 = c_3.
*** Variance
** CLEAR l_cost.
** IF NOT wa_issued_mat-peinh IS INITIAL.
** l_cost = ( wa_issued_mat-stprs * wa_issued_mat-menge )
** / wa_issued_mat-peinh.
** l_cost = l_cost * -1.
** ENDIF.
** l_var_total = l_var_total + l_cost. " Subtotal of Variance
**
** MOVE l_cost TO wa_nodestab-text5(15). " Variance
** wa_nodestab-tlength5 = c_15.
** wa_nodestab-tcolor5 = c_3.
**
** APPEND wa_nodestab TO i_nodestab.
**
** ENDLOOP.
**
*** Displaying Subtotals of material recipe
**
** CLEAR wa_nodestab.
** wa_nodestab-id = c_6_1.
** wa_nodestab-tlevel = c_6.
** wa_nodestab-parent = c_3_5.
**
** wa_nodestab-text = 'Material Totals'(043).
** wa_nodestab-tlength = c_18.
** wa_nodestab-tcolor = c_6.
**
** wa_nodestab-text1 = space.
** wa_nodestab-tlength1 = c_30.
** wa_nodestab-tcolor1 = c_6.
**
** MOVE l_act_total TO wa_nodestab-text2(20) .
** wa_nodestab-tlength2 = c_20.
** wa_nodestab-tcolor2 = c_6.
**
** MOVE l_std_total TO wa_nodestab-text3(20) .
** wa_nodestab-tlength3 = c_20.
** wa_nodestab-tcolor3 = c_6.
**
** wa_nodestab-text4 = space.
** wa_nodestab-tlength4 = c_19.
** wa_nodestab-tcolor4 = c_6.
**
** MOVE l_var_total TO wa_nodestab-text5(15) .
** wa_nodestab-tlength5 = c_15.
** wa_nodestab-tcolor5 = c_6.
**
** APPEND wa_nodestab TO i_nodestab.
**
** ENDIF.
**
** ENDLOOP.
**
**ENDFORM. " DISPLAY_PHASE_REPORT
***&--------------------------------------------------------------------
***
***& Form ACTIVITY_REPORT
***&--------------------------------------------------------------------
***
*** text
***---------------------------------------------------------------------
***
***---------------------------------------------------------------------
***
**FORM activity_report USING fp_l_prdqty TYPE menge_d
** fp_l_gamng TYPE menge_d
** fp_l_uom TYPE meins
** fp_l_gmein TYPE meins.
** DATA: l_value TYPE gamng,
** l_ism01_var TYPE ru_ismng,
** l_ism02_var TYPE ru_ismng,
** l_ism03_var TYPE ru_ismng,
** l_ism04_var TYPE ru_ismng,
** l_ism05_var TYPE ru_ismng,
** l_ism06_var TYPE ru_ismng.
** DATA: struct_afvgd TYPE afvgd.
** DATA: struct_mara TYPE mara,
** struct_marc TYPE marc.
** DATA: v_menge TYPE menge_d.
**
*** Get Standard Numbers from the phase
** PERFORM get_stds USING wa_ordops-plnty wa_ordops-plnnr
** wa_ordops-plnkn wa_ordops-zaehl.
**
*** Calculate Standard Labour/Fitter/Machine Hours.
** CLEAR struct_activity.
** MOVE-CORRESPONDING wa_plpo1 TO struct_afvgd. "#EC ENHOK
** MOVE: wa_ordops-arbid TO struct_afvgd-arbid,
** wa_ordops-ssavd TO struct_afvgd-ssavd.
** MOVE wa_plpo1-vge01 TO v_msehi.
**
** IF rb_actl IS INITIAL.
*** Planned qty
** l_value = fp_l_gamng.
** ELSE.
*** Actual qty
** l_value = fp_l_prdqty.
** ENDIF.
**
** CALL FUNCTION 'CO_R0_DET_TOTAL_ACTIVITY'
** EXPORTING
** act_afvgd = struct_afvgd
** act_quantity = l_value
** act_flg_consider_conf = space
** act_unit_of_time = v_msehi
** IMPORTING
** exp_activities = struct_activity.
**
*** Now get the confirmed values
** PERFORM get_confirmation_details.
**
*** Get Activity 1
** l_ism01_var = struct_activity-acti1 - wa_ord_conf1-ism01.
*** Get Activity 2
** l_ism02_var = struct_activity-acti2 - wa_ord_conf1-ism02.
*** Get Activity 3
** l_ism03_var = struct_activity-acti3 - wa_ord_conf1-ism03.
*** Get Activity 4
** l_ism04_var = struct_activity-acti4 - wa_ord_conf1-ism04.
*** Get Activity 5
** l_ism05_var = struct_activity-acti5 - wa_ord_conf1-ism05.
*** Get Activity 6
** l_ism06_var = struct_activity-acti6 - wa_ord_conf1-ism06.
**
** IF rb_summ IS INITIAL.
*** Now output the activities for each phase
** IF NOT ( wa_plpo1-lar01 IS INITIAL ).
** PERFORM activity_cost_report USING wa_plpo1-lar01
** wa_ord_conf1-ism01
** struct_activity-acti1
** l_ism01_var.
** ENDIF.
** IF NOT ( wa_plpo1-lar02 IS INITIAL ).
** PERFORM activity_cost_report USING wa_plpo1-lar02
** wa_ord_conf1-ism02
** struct_activity-acti2
** l_ism02_var.
** ENDIF.
** IF NOT ( wa_plpo1-lar03 IS INITIAL ).
** PERFORM activity_cost_report USING wa_plpo1-lar03
** wa_ord_conf1-ism03
** struct_activity-acti3
** l_ism03_var.
** ENDIF.
** IF NOT ( wa_plpo1-lar04 IS INITIAL ).
** PERFORM activity_cost_report USING wa_plpo1-lar04
** wa_ord_conf1-ism04
** struct_activity-acti4
** l_ism04_var.
** ENDIF.
** IF NOT ( wa_plpo1-lar05 IS INITIAL ).
** PERFORM activity_cost_report USING wa_plpo1-lar05
** wa_ord_conf1-ism05
** struct_activity-acti5
** l_ism05_var.
** ENDIF.
** IF NOT ( wa_plpo1-lar06 IS INITIAL ).
** PERFORM activity_cost_report USING wa_plpo1-lar06
** wa_ord_conf1-ism06
** struct_activity-acti6
** l_ism06_var.
** ENDIF.
** ELSEIF rb_summ = c_x.
** IF NOT ( wa_plpo1-lar01 IS INITIAL ).
** PERFORM sum_activity_costs USING wa_plpo1-lar01
** wa_ord_conf1-ism01
** struct_activity-acti1
** l_ism01_var.
** ENDIF.
** IF NOT ( wa_plpo1-lar02 IS INITIAL ).
** PERFORM sum_activity_costs USING wa_plpo1-lar02
** wa_ord_conf1-ism02
** struct_activity-acti2
** l_ism02_var.
** ENDIF.
** IF NOT ( wa_plpo1-lar03 IS INITIAL ).
** PERFORM sum_activity_costs USING wa_plpo1-lar03
** wa_ord_conf1-ism03
** struct_activity-acti3
** l_ism03_var.
** ENDIF.
** IF NOT ( wa_plpo1-lar04 IS INITIAL ).
** PERFORM sum_activity_costs USING wa_plpo1-lar04
** wa_ord_conf1-ism04
** struct_activity-acti4
** l_ism04_var.
** ENDIF.
** IF NOT ( wa_plpo1-lar05 IS INITIAL ).
** PERFORM sum_activity_costs USING wa_plpo1-lar05
** wa_ord_conf1-ism05
** struct_activity-acti5
** l_ism05_var.
** ENDIF.
** IF NOT ( wa_plpo1-lar06 IS INITIAL ).
** PERFORM sum_activity_costs USING wa_plpo1-lar06
** wa_ord_conf1-ism06
** struct_activity-acti6
** l_ism06_var.
** ENDIF.
**
** ENDIF.
**
**ENDFORM. " ACTIVITY_REPORT
***&--------------------------------------------------------------------
***
***& Form GET_STDS
***&--------------------------------------------------------------------
***
*** text
***---------------------------------------------------------------------
***
*** --> p1 text
*** <-- p2 text
***---------------------------------------------------------------------
***
**FORM get_stds USING fp_p_plnty TYPE plnty
** fp_p_plnnr TYPE plnnr
** fp_p_plnkn TYPE plnkn
** fp_p_zaehl TYPE cim_count.
**
** TYPES: BEGIN OF ty_crco_info,
** objty TYPE cr_objty,
** objid TYPE cr_objid,
** laset TYPE cr_laset,
** endda TYPE enddatum,
** lanum TYPE cr_lanum,
** begda TYPE begdatum,
** lstar_ref TYPE ap_kzref,
** lstar TYPE lstar,
** END OF ty_crco_info.
**
** DATA : i_crco_info TYPE STANDARD TABLE OF ty_crco_info,
** wa_crco_info TYPE ty_crco_info.
**
**
** DATA: l_wcinfo TYPE c,
** l_datuv TYPE plpo-datuv,
** lc_objty TYPE plpo-objty VALUE 'A'.
**
** READ TABLE i_plpo1 INTO wa_plpo1 WITH KEY plnty = fp_p_plnty
** plnnr = fp_p_plnnr
** plnkn = fp_p_plnkn
** zaehl = fp_p_zaehl.
** IF sy-subrc = 0.
**
** IF ( wa_plpo1-lar01 IS INITIAL AND NOT ( wa_plpo1-vgw01 = 0 ) ) OR
** ( wa_plpo1-lar02 IS INITIAL AND NOT ( wa_plpo1-vgw02 = 0 ) ) OR
** ( wa_plpo1-lar03 IS INITIAL AND NOT ( wa_plpo1-vgw03 = 0 ) ) OR
** ( wa_plpo1-lar04 IS INITIAL AND NOT ( wa_plpo1-vgw04 = 0 ) ) OR
** ( wa_plpo1-lar05 IS INITIAL AND NOT ( wa_plpo1-vgw05 = 0 ) ) OR
** ( wa_plpo1-lar06 IS INITIAL AND NOT ( wa_plpo1-vgw06 = 0 ) ).
** REFRESH: i_crco_info.
*** Check the work centre is on the phase, if not go to the operation
** IF wa_plpo1-arbid IS INITIAL.
** SELECT datuv arbid objty
** INTO (l_datuv,wa_plpo1-arbid,wa_plpo1-objty)
** FROM plpo
** WHERE plnty = wa_pro_orders-plnty
** AND plnnr = wa_pro_orders-plnnr
** AND plnkn = wa_plpo1-pvzkn
** AND datuv <= sy-datum
** ORDER BY datuv DESCENDING.
** EXIT.
** ENDSELECT.
** ENDIF.
*** Default to work centre object if it's blank
** IF wa_plpo1-objty IS INITIAL.
** wa_plpo1-objty = lc_objty.
** ENDIF.
*** Get the work centre activity info
** SELECT objty objid laset endda lanum begda lstar_ref lstar
** INTO TABLE i_crco_info
** FROM crco
** WHERE objty = wa_plpo1-objty
** AND objid = wa_plpo1-arbid
** AND laset = 1.
*** order by primary key.
**
** IF sy-subrc = 0.
***Not required to handle
** ENDIF.
**
** l_wcinfo = c_y.
** ENDIF.
** IF l_wcinfo = c_y.
*** Use work centre info.
** LOOP AT i_crco_info INTO wa_crco_info
** WHERE begda <= wa_plpo1-datuv AND
** endda >= wa_plpo1-datuv.
** CHECK NOT wa_crco_info-lstar_ref IS INITIAL.
** CASE wa_crco_info-lanum.
*** Only put the activity type in if there is a std value entered
** WHEN 1.
** IF wa_plpo1-vgw01 NE 0.
** wa_plpo1-lar01 = wa_crco_info-lstar.
** ENDIF.
** WHEN 2.
** IF wa_plpo1-vgw02 NE 0.
** wa_plpo1-lar02 = wa_crco_info-lstar.
** ENDIF.
** WHEN 3.
** IF wa_plpo1-vgw03 NE 0.
** wa_plpo1-lar03 = wa_crco_info-lstar.
** ENDIF.
** WHEN 4.
** IF wa_plpo1-vgw04 NE 0.
** wa_plpo1-lar04 = wa_crco_info-lstar.
** ENDIF.
** WHEN 5.
** IF wa_plpo1-vgw05 NE 0.
** wa_plpo1-lar05 = wa_crco_info-lstar.
** ENDIF.
** WHEN 6.
** IF wa_plpo1-vgw06 NE 0.
** wa_plpo1-lar06 = wa_crco_info-lstar.
** ENDIF.
** ENDCASE.
** ENDLOOP.
** ENDIF.
**
** ENDIF.
**
**ENDFORM. " GET_STDS
***&--------------------------------------------------------------------
**
***& Form get_confirmation_details
***&--------------------------------------------------------------------
***
*** text
***---------------------------------------------------------------------
***
***---------------------------------------------------------------------
***
**FORM get_confirmation_details.
**
** DATA: l_last_ism01 TYPE ru_ismng,
** l_last_ism02 TYPE ru_ismng,
** l_last_ism03 TYPE ru_ismng,
** l_last_ism04 TYPE ru_ismng,
** l_last_ism05 TYPE ru_ismng,
** l_last_ism06 TYPE ru_ismng.
**
** LOOP AT i_ord_conf1 INTO wa_ord_conf1
** WHERE rueck = wa_ordops-rueck.
** IF wa_ord_conf1-stokz IS INITIAL.
** l_last_ism01 = l_last_ism01 + wa_ord_conf1-ism01.
** l_last_ism02 = l_last_ism02 + wa_ord_conf1-ism02.
** l_last_ism03 = l_last_ism03 + wa_ord_conf1-ism03.
** l_last_ism04 = l_last_ism04 + wa_ord_conf1-ism04.
** l_last_ism05 = l_last_ism05 + wa_ord_conf1-ism05.
** l_last_ism06 = l_last_ism06 + wa_ord_conf1-ism06.
** ELSE.
** l_last_ism01 = l_last_ism01 - wa_ord_conf1-ism01.
** l_last_ism02 = l_last_ism02 - wa_ord_conf1-ism02.
** l_last_ism03 = l_last_ism03 - wa_ord_conf1-ism03.
** l_last_ism04 = l_last_ism04 - wa_ord_conf1-ism04.
** l_last_ism05 = l_last_ism05 - wa_ord_conf1-ism05.
** l_last_ism06 = l_last_ism06 - wa_ord_conf1-ism06.
** ENDIF.
** CLEAR : wa_ord_conf1.
** ENDLOOP.
**
** MOVE l_last_ism01 TO wa_ord_conf1-ism01.
** MOVE l_last_ism02 TO wa_ord_conf1-ism02.
** MOVE l_last_ism03 TO wa_ord_conf1-ism03.
** MOVE l_last_ism04 TO wa_ord_conf1-ism04.
** MOVE l_last_ism05 TO wa_ord_conf1-ism05.
** MOVE l_last_ism06 TO wa_ord_conf1-ism06.
**
**
**ENDFORM. " get_confirmation_details
***&--------------------------------------------------------------------
***
***& Form activity_cost_report
***&--------------------------------------------------------------------
***
*** text
***---------------------------------------------------------------------
***
*** -->P_I_PLPO1_LAR01 text
*** -->P_I_ORD_CONF1_ISM01 text
*** -->P_struct_activity_ACTI1 text
*** -->P_ISM01_VAR text
***---------------------------------------------------------------------
***
**FORM activity_cost_report USING fp_p_i_plpo1_lar01 TYPE lstar
** fp_p_i_ord_conf1_ism01 TYPE ru_ismng
** fp_p_struct_activity_acti1 TYPE co_smng13
** fp_p_ism01_var TYPE ru_ismng.
** DATA: l_ltext TYPE ktext,
** l_kokrs TYPE kokrs,
** l_kostl TYPE kostl,
** l_objnr TYPE j_objnr,
** l_tkg001 TYPE tkgxxx,
** l_tke001 TYPE tkexxx,
** l_std(8) TYPE p DECIMALS 2,
** l_act(8) TYPE p DECIMALS 2,
** l_var(8) TYPE p DECIMALS 2.
**
** SELECT ltext FROM cslt INTO l_ltext
** WHERE spras = sy-langu
** AND kokrs = p_kokrs
** AND lstar = fp_p_i_plpo1_lar01.
** ENDSELECT.
**
** IF sy-subrc = 0.
***Not required to handle
** ENDIF.
**
** IF rb_fiscl IS INITIAL.
**
** CLEAR wa_nodestab.
** wa_nodestab-id = c_3_1.
** wa_nodestab-tlevel = c_4.
** wa_nodestab-parent = c_3_2.
**
** wa_nodestab-text = wa_ordops-vornr.
** wa_nodestab-tlength = c_4.
**
** wa_nodestab-text1 = l_ltext.
** wa_nodestab-tlength1 = c_44.
**
** MOVE fp_p_i_ord_conf1_ism01 TO wa_nodestab-text2(20).
** wa_nodestab-tlength2 = c_20.
**
** MOVE fp_p_struct_activity_acti1 TO wa_nodestab-text3(20).
** wa_nodestab-tlength3 = c_20.
**
** MOVE fp_p_ism01_var TO wa_nodestab-text4(20).
** wa_nodestab-tlength4 = c_20.
**
** ELSE.
**
** SELECT kokrs kostl
** FROM crco UP TO 1 ROWS
** INTO (l_kokrs, l_kostl)
** WHERE objty = c_a
** AND objid = wa_ordops-arbid
** AND lstar = fp_p_i_plpo1_lar01.
** ENDSELECT.
**
** IF sy-subrc = 0.
***Not required to handle
** ENDIF.
**
** SELECT SINGLE objnr INTO l_objnr
** FROM cssl
** WHERE kokrs = l_kokrs
** AND kostl = l_kostl
** AND lstar = fp_p_i_plpo1_lar01
** AND gjahr = sy-datum+0(4).
**
** IF sy-subrc = 0.
***Not required to handle
** ENDIF.
**
** SELECT tkg001 tke001 INTO (l_tkg001, l_tke001)
** FROM cost
** WHERE objnr = l_objnr
** AND gjahr = sy-datum+0(4)
** AND versn = c_000.
** ENDSELECT.
**
** IF sy-subrc = 0.
***Not required to handle
** ENDIF.
**
** CLEAR: l_act, l_std, l_var.
**** The following were changed to take into account the unit
**** price factor.
** l_act = ( fp_p_i_ord_conf1_ism01 * l_tkg001 ) / l_tke001.
** l_std = ( fp_p_struct_activity_acti1 * l_tkg001 ) / l_tke001.
** l_var = ( fp_p_ism01_var * l_tkg001 ) / l_tke001.
**
** CLEAR wa_nodestab.
** wa_nodestab-id = c_3_1.
** wa_nodestab-tlevel = c_4.
** wa_nodestab-parent = c_3_2.
**
** wa_nodestab-text = wa_ordops-vornr.
** wa_nodestab-tlength = c_4.
**
** wa_nodestab-text1 = l_ltext.
** wa_nodestab-tlength1 = c_44.
**
** MOVE l_act TO wa_nodestab-text2(20).
** wa_nodestab-tlength2 = c_20.
**
** MOVE l_std TO wa_nodestab-text3(20).
** wa_nodestab-tlength3 = c_20.
**
** MOVE l_var TO wa_nodestab-text4(20).
** wa_nodestab-tlength4 = c_20.
**
** ENDIF.
**
** IF flg_color = c_x.
** CLEAR flg_color.
** wa_nodestab-tcolor = c_3.
** wa_nodestab-tcolor1 = c_3.
** wa_nodestab-tcolor2 = c_3.
** wa_nodestab-tcolor3 = c_3.
** wa_nodestab-tcolor4 = c_3.
** ELSE.
** flg_color = c_x.
** wa_nodestab-tcolor = c_2.
** wa_nodestab-tcolor1 = c_2.
** wa_nodestab-tcolor2 = c_2.
** wa_nodestab-tcolor3 = c_2.
** wa_nodestab-tcolor4 = c_2.
** ENDIF.
**
** APPEND wa_nodestab TO i_nodestab.
**
**
**ENDFORM. " activity_cost_report
***&--------------------------------------------------------------------
**
***& Form uom_convert
***&--------------------------------------------------------------------
***
*** text
***---------------------------------------------------------------------
***
*** -->P_I_ORDMATS_MATNR text
*** -->P_I_ORDMATS_MENGE text
*** -->P_I_ORDMATS_AMEIN text
*** -->P_L_AQTY text
***---------------------------------------------------------------------
**** FORM uom_convert USING fp_p_i_ordmats_matnr TYPE matnr
** fp_p_i_ordmats_menge TYPE menge_d
** fp_p_i_ordmats_amein TYPE meins
** fp_p_l_aqty TYPE menge_d.
**
***Added for WIRR
** DATA : struct_mara TYPE mara,
** struct_t006 TYPE t006.
** DATA: v_menge TYPE menge_d.
**
** CONSTANTS : c_halb TYPE mtart VALUE 'HALB',
** c_fert TYPE mtart VALUE 'FERT',
** c_kgm TYPE msehi VALUE 'KGM'.
**
******************************************
*** Need some clarification on this form *
******************************************
**
*** If the material is type FERT or HALB then use the net weight field
*** from the material master. Otherwise use the alt uom for KG.
** SELECT SINGLE * FROM mara
***Added for WIRR
** INTO struct_mara
***Added for WIRR
**
** WHERE matnr = fp_p_i_ordmats_matnr.
**
** IF ( struct_mara-mtart = c_fert
** OR struct_mara-mtart = c_halb )
** AND NOT ( struct_mara-ntgew IS INITIAL ).
***************MOD-002************************************************
*
***
** CLEAR: v_menge.
** IF struct_mara-gewei NE 'KG'.
** IF struct_mara-gewei = 'G'.
** CALL FUNCTION 'MD_CONVERT_MATERIAL_UNIT'
** EXPORTING
** i_matnr = fp_p_i_ordmats_matnr
** i_in_me = fp_p_i_ordmats_amein
** i_out_me = struct_mara-meins
** i_menge = fp_p_i_ordmats_menge
** IMPORTING
** e_menge = v_menge
** EXCEPTIONS
** error_in_application = 1
** error = 2
** OTHERS = 3.
** IF sy-subrc = 0.
** fp_p_l_aqty =
** v_menge * ( struct_mara-ntgew / 1000 ).
** ENDIF.
** ENDIF.
** ELSE.
**************MOD-002*************************************************
*
***
**************MOD-003*************************************************
*
** IF struct_mara-meins NE fp_p_i_ordmats_amein.
** CALL FUNCTION 'MD_CONVERT_MATERIAL_UNIT'
** EXPORTING
** i_matnr = fp_p_i_ordmats_matnr
** i_in_me = fp_p_i_ordmats_amein
** i_out_me = struct_mara-meins
** i_menge = fp_p_i_ordmats_menge
** IMPORTING
** e_menge = fp_p_i_ordmats_menge
** EXCEPTIONS
** error_in_application = 1
** error = 2
** OTHERS = 3.
** IF sy-subrc = 0.
** fp_p_l_aqty = fp_p_i_ordmats_menge * struct_mara-ntgew.
** ENDIF.
** ELSE.
** fp_p_l_aqty = fp_p_i_ordmats_menge * struct_mara-ntgew.
** ENDIF.
*************MOD-003**************************************************
*
** ENDIF.
** ELSE.
*** Get the isocode for kgm
** SELECT SINGLE * FROM t006
** INTO struct_t006
** WHERE msehi = c_kgm.
**
** IF fp_p_i_ordmats_amein = struct_t006-msehi.
** MOVE fp_p_i_ordmats_menge TO fp_p_l_aqty.
** ELSE.
** CALL FUNCTION 'MATERIAL_UNIT_CONVERSION'
** EXPORTING
** kzmeinh = c_x
** input = fp_p_i_ordmats_menge
** matnr = fp_p_i_ordmats_matnr
** meinh = struct_t006-msehi
** IMPORTING
** output = fp_p_l_aqty
** EXCEPTIONS
** conversion_not_found = 1
** input_invalid = 2
** material_not_found = 3
** meinh_not_found = 4
** meins_missing = 5
** no_meinh = 6
** output_invalid = 7
** overflow = 8
** OTHERS = 9.
**
*******************
** IF sy-subrc NE 0.
** fp_p_l_aqty = 0.
** ENDIF.
**
**
*******************
** ENDIF.
** ENDIF.
**
**ENDFORM. " uom_convert
***&--------------------------------------------------------------------
***
***& Form STD_PERCENTAGE_CALC
***&--------------------------------------------------------------------
***
*** text
***---------------------------------------------------------------------
***
*** -->P_L_AQTY text
*** -->P_L_SQTY text
*** -->P_L_PCENT text
***---------------------------------------------------------------------
***
**FORM std_percentage_calc USING fp_l_aqty TYPE menge_d
** fp_l_sqty TYPE menge_d
** fp_l_pcent TYPE any.
**
** CONSTANTS: c_percent_p TYPE stprs VALUE '999.99',
** c_percent_n TYPE stprs VALUE '-999.99'.
**
** DATA: l_tcent(10) TYPE p DECIMALS 5,
** l_pecent(3) TYPE p DECIMALS 2.
**
** CLEAR: l_tcent, l_pecent.
** IF fp_l_aqty NE 0 AND fp_l_sqty NE 0.
** l_tcent = ( ( fp_l_sqty - fp_l_aqty ) / fp_l_sqty ) * c_100.
** ELSEIF fp_l_aqty EQ 0 AND fp_l_sqty EQ 0.
** l_tcent = 0.
** ELSE.
** MOVE c_100 TO l_tcent.
** ENDIF.
** IF l_tcent GT c_percent_p.
** MOVE c_percent_p TO l_pecent.
** ELSEIF l_tcent LT c_percent_n.
** MOVE c_percent_n TO l_pecent.
** ELSE.
** MOVE l_tcent TO l_pecent.
** ENDIF.
**** Add a calculation to convert by-product percentages to the correct
**** sign.
** IF fp_l_sqty < 0.
** l_pecent = l_pecent * -1.
** ENDIF.
** fp_l_pcent = l_pecent.
**
**ENDFORM. " STD_PERCENTAGE_CALC
**
***&--------------------------------------------------------------------
***
***& Form DISPLAY
***&--------------------------------------------------------------------
***
*** text
***---------------------------------------------------------------------
***
***---------------------------------------------------------------------
***
**FORM display.
**
** CASE c_x.
** WHEN rb_summ.
** PERFORM display_summary_report.
** WHEN rb_detl.
** PERFORM display_detail_report.
** WHEN rb_phase.
** PERFORM display_phase_report.
** ENDCASE.
** PERFORM list_display.
**
**ENDFORM. " DISPLAY
***&--------------------------------------------------------------------
***
***& Form plant_effic
***&--------------------------------------------------------------------
***
*** text
***---------------------------------------------------------------------
***
*** -->P_I_PRO_ORDERS_RUECK text
*** -->P_I_PRO_ORDERS_PLNTY text
*** -->P_I_PRO_ORDERS_PLNNR text
*** -->P_I_PRO_ORDERS_PLNKN text
*** -->P_I_PRO_ORDERS_ZAEHL text
*** <--P_V_plant_effic text
***---------------------------------------------------------------------
***
**FORM plant_effic USING fp_p_plnty TYPE plnty
** fp_p_plnnr TYPE plnnr
** fp_p_plnkn TYPE plnkn
** fp_p_zaehl TYPE cim_count
** CHANGING fp_v_plant_effic TYPE any.
**
** FIELD-SYMBOLS: <fs_ism> TYPE ANY,
** <fs_vgw> TYPE ANY.
**
** DATA: l_last_ism01 TYPE ru_ismng,
** l_last_ism02 TYPE ru_ismng,
** l_last_ism03 TYPE ru_ismng,
** l_last_ism04 TYPE ru_ismng,
** l_last_ism05 TYPE ru_ismng,
** l_last_ism06 TYPE ru_ismng,
** l_pqty TYPE menge_d,
** l_real_effic(8) TYPE p DECIMALS 4,
** l_should_effic(8) TYPE p DECIMALS 4.
**
** PERFORM get_stds_main USING fp_p_plnty fp_p_plnnr fp_p_plnkn
** fp_p_zaehl.
**
**
** LOOP AT i_ord_conf INTO wa_ord_conf
** WHERE rueck = wa_ordops-rueck.
** IF wa_ord_conf1-stokz IS INITIAL.
** l_last_ism01 = l_last_ism01 + wa_ord_conf-ism01.
** l_last_ism02 = l_last_ism02 + wa_ord_conf-ism02.
** l_last_ism03 = l_last_ism03 + wa_ord_conf-ism03.
** l_last_ism04 = l_last_ism04 + wa_ord_conf-ism04.
** l_last_ism05 = l_last_ism05 + wa_ord_conf-ism05.
** l_last_ism06 = l_last_ism06 + wa_ord_conf-ism06.
** ELSE.
** l_last_ism01 = l_last_ism01 - wa_ord_conf-ism01.
** l_last_ism02 = l_last_ism02 - wa_ord_conf-ism02.
** l_last_ism03 = l_last_ism03 - wa_ord_conf-ism03.
** l_last_ism04 = l_last_ism04 - wa_ord_conf-ism04.
** l_last_ism05 = l_last_ism05 - wa_ord_conf-ism05.
** l_last_ism06 = l_last_ism06 - wa_ord_conf-ism06.
** ENDIF.
**
** CLEAR : wa_ord_conf.
** ENDLOOP.
**
** MOVE l_last_ism01 TO wa_ord_conf-ism01.
** MOVE l_last_ism02 TO wa_ord_conf-ism02.
** MOVE l_last_ism03 TO wa_ord_conf-ism03.
** MOVE l_last_ism04 TO wa_ord_conf-ism04.
** MOVE l_last_ism05 TO wa_ord_conf-ism05.
** MOVE l_last_ism06 TO wa_ord_conf-ism06.
**
** ASSIGN c_0 TO <fs_ism>.
** ASSIGN c_0 TO <fs_vgw>.
**
** IF wa_plpo-lar01 EQ p_machs.
** ASSIGN wa_ord_conf-ism01 TO <fs_ism>.
** ASSIGN wa_plpo-vgw01 TO <fs_vgw>.
** ENDIF.
** IF wa_plpo-lar02 EQ p_machs.
** ASSIGN wa_ord_conf-ism02 TO <fs_ism>.
** ASSIGN wa_plpo-vgw02 TO <fs_vgw>.
** ENDIF.
** IF wa_plpo-lar03 EQ p_machs.
** ASSIGN wa_ord_conf-ism03 TO <fs_ism>.
** ASSIGN wa_plpo-vgw03 TO <fs_vgw>.
** ENDIF.
** IF wa_plpo-lar04 EQ p_machs.
** ASSIGN wa_ord_conf-ism04 TO <fs_ism>.
** ASSIGN wa_plpo-vgw04 TO <fs_vgw>.
** ENDIF.
** IF wa_plpo-lar05 EQ p_machs.
** ASSIGN wa_ord_conf-ism05 TO <fs_ism>.
** ASSIGN wa_plpo-vgw05 TO <fs_vgw>.
** ENDIF.
** IF wa_plpo-lar06 EQ p_machs.
** ASSIGN wa_ord_conf-ism06 TO <fs_ism>.
** ASSIGN wa_plpo-vgw06 TO <fs_vgw>.
** ENDIF.
**
** CLEAR l_pqty.
** IF NOT ( rb_prod IS INITIAL ).
** l_pqty = wa_pro_orders-menge.
** ELSE.
** l_pqty = wa_pro_orders-lmnga.
** ENDIF.
**
** IF <fs_ism> GT c_0.
*** IF NOT <FS_ISM> IS INITIAL.
** l_real_effic = ( l_pqty / <fs_ism> ).
** ELSE.
** MOVE 0 TO l_real_effic.
** ENDIF.
** IF <fs_vgw> GT c_0.
*** IF NOT <FS_VGW> IS INITIAL.
** l_should_effic = ( wa_plpo-bmsch / <fs_vgw> ).
** ELSE.
** MOVE 0 TO l_should_effic.
** ENDIF.
** IF l_should_effic GT c_0.
** v_plant_effic = ( l_real_effic / l_should_effic ) * c_100.
** ELSE.
** MOVE 0 TO fp_v_plant_effic.
** ENDIF.
**
**ENDFORM. " plant_effic
***&--------------------------------------------------------------------
***
***& Form get_stds_main
***&--------------------------------------------------------------------
***
*** text
***---------------------------------------------------------------------
***
*** -->P_PLNTY text
*** -->P_PLNNR text
*** -->P_PLNKN text
*** -->P_ZAEHL text
***---------------------------------------------------------------------
***
**FORM get_stds_main USING fp_p_plnty TYPE plnty
** fp_p_plnnr TYPE plnnr
** fp_p_plnkn TYPE plnkn
** fp_p_zaehl TYPE cim_count.
** TYPES: BEGIN OF ty_crco_info,
** objty TYPE cr_objty,
** objid TYPE cr_objid,
** laset TYPE cr_laset,
** endda TYPE enddatum,
** lanum TYPE cr_lanum,
** begda TYPE begdatum,
** lstar_ref TYPE ap_kzref,
** lstar TYPE lstar,
** END OF ty_crco_info.
**
** DATA : i_crco_info TYPE STANDARD TABLE OF ty_crco_info,
** wa_crco_info TYPE ty_crco_info.
** DATA: l_wcinfo TYPE c,
** l_datuv TYPE plpo-datuv,
** lc_objty TYPE plpo-objty VALUE 'A'.
**
** READ TABLE i_plpo INTO wa_plpo WITH KEY plnty = fp_p_plnty
** plnnr = fp_p_plnnr
** plnkn = fp_p_plnkn
** zaehl = fp_p_zaehl.
** IF sy-subrc = 0.
**
** IF ( wa_plpo-lar01 IS INITIAL AND NOT ( wa_plpo-vgw01 = 0 ) ) OR
** ( wa_plpo-lar02 IS INITIAL AND NOT ( wa_plpo-vgw02 = 0 ) ) OR
** ( wa_plpo-lar03 IS INITIAL AND NOT ( wa_plpo-vgw03 = 0 ) ) OR
** ( wa_plpo-lar04 IS INITIAL AND NOT ( wa_plpo-vgw04 = 0 ) ) OR
** ( wa_plpo-lar05 IS INITIAL AND NOT ( wa_plpo-vgw05 = 0 ) ) OR
** ( wa_plpo-lar06 IS INITIAL AND NOT ( wa_plpo-vgw06 = 0 ) ).
** REFRESH: i_crco_info.
*** Check the work centre is on the phase, if not go to the operation
** IF wa_plpo-arbid IS INITIAL.
** SELECT datuv arbid objty
** INTO (l_datuv,wa_plpo-arbid,wa_plpo-objty)
** FROM plpo
** WHERE plnty = fp_p_plnty
** AND plnnr = fp_p_plnnr
** AND plnkn = wa_plpo-pvzkn
** AND datuv <= sy-datum
** ORDER BY datuv DESCENDING.
** EXIT.
** ENDSELECT.
**
** IF sy-subrc = 0.
***Not required to handle
** ENDIF.
**
** ENDIF.
*** Default to work centre object if it's blank
** IF wa_plpo-objty IS INITIAL.
** wa_plpo-objty = lc_objty.
** ENDIF.
*** Get the work centre activity info
** SELECT objty objid laset endda lanum begda lstar_ref lstar
** INTO TABLE i_crco_info
** FROM crco
** WHERE objty = wa_plpo-objty
** AND objid = wa_plpo-arbid
** AND laset = 1.
*** order by primary key.
**
** IF sy-subrc = 0.
***Not required to handle
** ENDIF.
**
** l_wcinfo = c_y.
** ENDIF.
** IF l_wcinfo = c_y.
*** Use work centre info.
** LOOP AT i_crco_info INTO wa_crco_info
** WHERE begda <= wa_plpo-datuv AND
** endda >= wa_plpo-datuv.
** CHECK NOT wa_crco_info-lstar_ref IS INITIAL.
** CASE wa_crco_info-lanum.
*** Only put the activity type in if there is a std value entered
** WHEN 1.
** IF wa_plpo-vgw01 NE 0.
** wa_plpo-lar01 = wa_crco_info-lstar.
** ENDIF.
** WHEN 2.
** IF wa_plpo-vgw02 NE 0.
** wa_plpo-lar02 = wa_crco_info-lstar.
** ENDIF.
** WHEN 3.
** IF wa_plpo-vgw03 NE 0.
** wa_plpo-lar03 = wa_crco_info-lstar.
** ENDIF.
** WHEN 4.
** IF wa_plpo-vgw04 NE 0.
** wa_plpo-lar04 = wa_crco_info-lstar.
** ENDIF.
** WHEN 5.
** IF wa_plpo-vgw05 NE 0.
** wa_plpo-lar05 = wa_crco_info-lstar.
** ENDIF.
** WHEN 6.
** IF wa_plpo-vgw06 NE 0.
** wa_plpo-lar06 = wa_crco_info-lstar.
** ENDIF.
** ENDCASE.
** ENDLOOP.
** ENDIF.
**
** ENDIF.
**
**ENDFORM. " get_stds_main
***&--------------------------------------------------------------------
***
***& Form get_confirmation_qty
***&--------------------------------------------------------------------
***
*** text
***---------------------------------------------------------------------
**
*** -->P_I_ORDOPS_RUECK text
*** -->P_I_PRO_ORDERS_PLNBEZ text
*** -->P_L_PRDQTY text
*** -->P_L_CFUOM text
***---------------------------------------------------------------------
***
**FORM get_confirmation_qty USING fp_p_i_ordops_rueck TYPE co_rueck
** fp_p_l_prdqty TYPE menge_d
** fp_p_l_cfuom TYPE meins.
** DATA: l_lmnga TYPE ru_lmnga,
** l_gmnga TYPE ru_gmnga.
**
************MOD-002**************************************
** SELECT aufnr rueck gmnga lmnga gmein meinh
** meilr stokz rueck_mst
** FROM afru INTO TABLE itab_afru
** FOR ALL ENTRIES IN i_pro_orders
** WHERE aufnr = i_pro_orders-aufnr.
**
** SORT itab_afru BY aufnr rueck .
************MOD-002***************************************
** IF NOT itab_afru[] IS INITIAL.
** CLEAR: l_lmnga, l_gmnga.
** LOOP AT itab_afru INTO wa_afru WHERE rueck = fp_p_i_ordops_rueck.
*** IF ( wa_afru-rueck_mst IS INITIAL ) AND
*** ( wa_afru-lmnga NE 0 ) AND
*** NOT ( wa_afru-meilr IS INITIAL ).
** IF wa_afru-stokz IS INITIAL.
** l_lmnga = l_lmnga + wa_afru-lmnga.
** l_gmnga = l_gmnga + wa_afru-gmnga.
** ELSE.
** l_lmnga = l_lmnga - wa_afru-lmnga.
** l_gmnga = l_gmnga - wa_afru-gmnga.
** ENDIF.
*** ENDIF.
** ENDLOOP.
** IF wa_afru-meinh NE wa_afru-gmein.
** fp_p_l_prdqty = l_lmnga.
** fp_p_l_cfuom = wa_afru-gmein.
** ELSE.
** fp_p_l_prdqty = l_gmnga.
** fp_p_l_cfuom = wa_afru-meinh.
** ENDIF.
** ENDIF.
**ENDFORM. " get_confirmation_qty
***&--------------------------------------------------------------------
***
***& Form MATERIAL_HEADER
***&--------------------------------------------------------------------
***
*** text
***---------------------------------------------------------------------
***
*** --> p1 text
*** <-- p2 text
***---------------------------------------------------------------------
***
**FORM material_header.
**
** wa_nodestab-text = 'Material'(058).
** wa_nodestab-tlength = c_22.
** wa_nodestab-tcolor = c_4.
** wa_nodestab-propfaw = c_x.
**
** wa_nodestab-text1 = 'Description'(059).
** wa_nodestab-tlength1 = c_30.
** wa_nodestab-tcolor1 = c_4.
**
** IF rb_fiscl = c_x.
** CONCATENATE 'Actual Usage'(040) v_waers
** INTO wa_nodestab-text2 SEPARATED BY space.
** ELSE.
** wa_nodestab-text2 = 'Actual Usage'(040).
** ENDIF.
** wa_nodestab-tlength2 = c_20.
** wa_nodestab-tcolor2 = c_4.
**
** IF rb_fiscl = c_x.
** CONCATENATE 'Standard Usage'(041) v_waers
** INTO wa_nodestab-text3 SEPARATED BY space.
** ELSE.
** wa_nodestab-text3 = 'Standard Usage'(041).
** ENDIF.
** wa_nodestab-tlength3 = c_20.
** wa_nodestab-tcolor3 = c_4.
**
** wa_nodestab-text4 = 'Var'(060).
** wa_nodestab-tlength4 = c_19.
** wa_nodestab-tcolor4 = c_4.
**
*** IF rb_fiscl = c_x.
** CONCATENATE 'Variance'(061) v_waers
** INTO wa_nodestab-text5 SEPARATED BY space.
*** ELSE.
*** wa_nodestab-text5 = 'Variance'(061).
*** ENDIF.
** wa_nodestab-tlength5 = c_15.
** wa_nodestab-tcolor5 = c_4.
**
** APPEND wa_nodestab TO i_nodestab.
** CLEAR : wa_nodestab.
**ENDFORM. " MATERIAL_HEADER
***&--------------------------------------------------------------------
***
***& Form sum_activity_costs
***&--------------------------------------------------------------------
***
*** text
***---------------------------------------------------------------------
***
*** -->P_I_PLPO1_LAR01 text
*** -->P_I_ORD_CONF1_ISM01 text
*** -->P_struct_activity_ACTI1 text
*** -->P_ISM01_VAR text
***---------------------------------------------------------------------
***
**FORM sum_activity_costs USING fp_p_i_plpo1_lar01 TYPE lstar
** fp_p_i_ord_conf1_ism01 TYPE ru_ismng
**fp_p_struct_activity_acti1 TYPE co_smng13
**fp_p_ism01_var TYPE ru_ismng.
** DATA: l_kokrs TYPE kokrs,
** l_kostl TYPE kostl,
** l_objnr TYPE j_objnr,
** l_tkg001 TYPE tkgxxx,
** l_tke001 TYPE tkexxx,
** l_std(8) TYPE p DECIMALS 2,
** l_act(8) TYPE p DECIMALS 2,
** l_var(8) TYPE p DECIMALS 2.
**
** SELECT kokrs kostl
** FROM crco UP TO 1 ROWS
** INTO (l_kokrs, l_kostl)
** WHERE objty = c_objtyp
** AND objid = wa_ordops-arbid
** AND lstar = fp_p_i_plpo1_lar01.
** ENDSELECT.
**
** IF sy-subrc = 0.
***Not required to handle
** ENDIF.
**
** SELECT SINGLE objnr INTO l_objnr
** FROM cssl
** WHERE kokrs = l_kokrs
** AND kostl = l_kostl
** AND lstar = fp_p_i_plpo1_lar01
** AND gjahr = sy-datum+0(4).
**
** IF sy-subrc = 0.
***Not required to handle
** ENDIF.
**
** SELECT tkg001 tke001 INTO (l_tkg001, l_tke001)
** FROM cost
** WHERE objnr = l_objnr
** AND gjahr = sy-datum+0(4)
** AND versn = c_000.
** ENDSELECT.
**
** IF sy-subrc = 0.
***Not required to handle
** ENDIF.
**
** CLEAR: l_act, l_std, l_var.
** l_act = ( fp_p_i_ord_conf1_ism01 * l_tkg001 ) / l_tke001.
** l_std = ( fp_p_struct_activity_acti1 * l_tkg001 ) / l_tke001.
** l_var = ( fp_p_ism01_var * l_tkg001 ) / l_tke001.
**
** CLEAR wa_sum_activity.
**
** LOOP AT i_sum_activity INTO wa_sum_activity
** WHERE lar = fp_p_i_plpo1_lar01.
** wa_sum_activity-afru_ism = wa_sum_activity-afru_ism
** + fp_p_i_ord_conf1_ism01.
** wa_sum_activity-ism_should = wa_sum_activity-ism_should
** + fp_p_struct_activity_acti1.
** wa_sum_activity-ism_var = wa_sum_activity-ism_var
** + fp_p_ism01_var.
** wa_sum_activity-coact = wa_sum_activity-coact + l_act.
** wa_sum_activity-costd = wa_sum_activity-costd + l_std.
** wa_sum_activity-covar = wa_sum_activity-covar + l_var.
** MODIFY i_sum_activity FROM wa_sum_activity.
** CLEAR : wa_sum_activity.
** ENDLOOP.
**
** IF sy-subrc NE 0.
** MOVE fp_p_i_plpo1_lar01 TO wa_sum_activity-lar.
** MOVE fp_p_i_ord_conf1_ism01 TO wa_sum_activity-afru_ism.
** MOVE fp_p_struct_activity_acti1 TO wa_sum_activity-ism_should.
** MOVE fp_p_ism01_var TO wa_sum_activity-ism_var.
** wa_sum_activity-coact = l_act.
** wa_sum_activity-costd = l_std.
** wa_sum_activity-covar = l_var.
** APPEND wa_sum_activity TO i_sum_activity.
** CLEAR : wa_sum_activity.
** ENDIF.
**
**ENDFORM. " sum_activity_costs
***&--------------------------------------------------------------------
***
***& Form SUMMARY_MATERIALS
***&--------------------------------------------------------------------
***
*** text
***---------------------------------------------------------------------
***
***---------------------------------------------------------------------
***
**FORM summary_materials.
**
*** Sum Ingredient Tots
** CLEAR wa_sum_ordmats.
** LOOP AT i_sum_ordmats INTO wa_sum_ordmats
** WHERE matnr = wa_ordmats-matnr.
** wa_sum_ordmats-num = wa_sum_ordmats-num + c_1.
** wa_sum_ordmats-menge = wa_sum_ordmats-menge + wa_ordmats-menge.
** wa_sum_ordmats-stdqy = wa_sum_ordmats-stdqy + wa_ordmats-stdqy.
** wa_sum_ordmats-zloss = wa_sum_ordmats-zloss + wa_ordmats-zloss.
** wa_sum_ordmats-amein = wa_ordmats-amein.
** wa_sum_ordmats-meins = wa_ordmats-meins.
** wa_sum_ordmats-stprs = wa_ordmats-stprs.
** wa_sum_ordmats-peinh = wa_ordmats-peinh.
** MODIFY i_sum_ordmats FROM wa_sum_ordmats.
** CLEAR : wa_sum_ordmats.
** ENDLOOP.
** IF sy-subrc NE 0.
** MOVE wa_ordmats-matnr TO wa_sum_ordmats-matnr.
** MOVE 1 TO wa_sum_ordmats-num.
** MOVE wa_ordmats-menge TO wa_sum_ordmats-menge.
** MOVE wa_ordmats-stdqy TO wa_sum_ordmats-stdqy.
** MOVE wa_ordmats-zloss TO wa_sum_ordmats-zloss.
** wa_sum_ordmats-amein = wa_ordmats-amein.
** wa_sum_ordmats-meins = wa_ordmats-meins.
** wa_sum_ordmats-stprs = wa_ordmats-stprs.
** wa_sum_ordmats-peinh = wa_ordmats-peinh.
** APPEND wa_sum_ordmats TO i_sum_ordmats.
** CLEAR : wa_sum_ordmats.
** ENDIF.
**
**ENDFORM. " SUMMARY_MATERIALS
***&--------------------------------------------------------------------
***
***& Form get_confirmation_qty_new
***&--------------------------------------------------------------------
***
*** text
***---------------------------------------------------------------------
***
*** -->P_WA_PRO_ORDERS_RUECK text
*** -->P_WA_PRO_ORDERS_PLNBEZ text
*** -->P_WA_PRO_ORDERS_LMNGA text
*** -->P_WA_PRO_ORDERS_CFUOM text
***---------------------------------------------------------------------
***
**FORM get_confirmation_qty_new USING p_lmnga TYPE ru_lmnga
** p_cfuom TYPE meins.
**
*****************************************************
***USING
*** P_RUECK TYPE CO_RUECK
*** p_aufnr type aufnr
*** P_LMNGA TYPE RU_LMNGA
*** P_CFUOM TYPE MEINS
*** p_aufpl type CO_AUFPL
*** p_vornr type vornr
*** p_aplzl type CO_APLZL.
*****************************************************
** DATA: last_lmnga LIKE afru-lmnga,
** last_gmnga TYPE afru-gmnga.
**
** CLEAR: last_lmnga, last_gmnga.
** CLEAR:i_afru, wa_afru.
**
**
**
**
*** Check this record. If there is no link to another confirmation and
*** a quantity has been confirmed and it is a milestone
** confirmation
*** then we want to select all of the confirmations for .
** LOOP AT i_afru1 INTO wa_afru1.
*** check WA_afru-rueck_mst is initial.
** CHECK wa_afru1-lmnga NE 0.
*** check not ( WA_afru-meilr is initial ).
** IF wa_afru1-stokz IS INITIAL.
** last_lmnga = last_lmnga + wa_afru1-lmnga.
** last_gmnga = last_gmnga + wa_afru1-gmnga.
** ELSE.
** last_lmnga = last_lmnga - wa_afru1-lmnga.
** last_gmnga = last_gmnga - wa_afru1-gmnga.
** ENDIF.
** ENDLOOP.
**
*** use order unit quantity if necessary
** IF wa_afru1-meinh NE wa_afru1-gmein.
*** afru-gmein is order unit of measure
** MOVE last_gmnga TO p_lmnga.
** p_cfuom = wa_afru1-gmein.
** ELSE.
*** use normal quantity
** MOVE last_lmnga TO p_lmnga.
** p_cfuom = wa_afru1-meinh.
** ENDIF.
**
**ENDFORM. " get_confirmation_qty_new
*****
***** END OF MOD-101
*****
*
**&---------------------------------------------------------------------
*
**& Form USER_COMMNAD
**&---------------------------------------------------------------------
*
** text
**----------------------------------------------------------------------
*
*FORM user_command TABLES fp_i_nodestab STRUCTURE snodetext"#EC *
* USING fp_l_ucomm TYPE any
* CHANGING fp_l_exit TYPE any
* fp_l_list_refresh TYPE any. "#EC *
*
* DATA : v_aufnr TYPE aufnr,
* l_arbpl TYPE arbpl, "MOD-101+
* l_txt(14) TYPE c. "MOD-101+
*
* DATA: PROGNAME LIKE SY-REPID,
* SELECTED TYPE C,
* EXIT_SAV TYPE C,
* LIST_REFRESH_SAV TYPE C.
*
*
* fp_l_list_refresh = c_m.
*
* CASE fp_l_ucomm.
****
**** BEGIN OF MOD-101
****
* WHEN c_trpi.
* CLEAR : v_aufnr , l_txt.
* GET CURSOR FIELD fp_i_nodestab-text1 VALUE l_txt.
*
* IF fp_i_nodestab-text1 = c_text1 AND NOT l_txt IS INITIAL.
* CASE fp_i_nodestab-tlevel.
* WHEN c_tlevel_2.
* v_aufnr = l_txt(12).
* SUBMIT zprocessord WITH s_aufnr-low = v_aufnr
* AND RETURN.
** SUBMIT zprocessord WITH p_aufnr = v_aufnr
** AND RETURN.
*
* WHEN c_tlevel_3.
* l_arbpl = l_txt(8).
*
* SET PARAMETER ID 'WRK' FIELD p_werks.
* SET PARAMETER ID 'AGR' FIELD l_arbpl.
*
* CALL TRANSACTION 'CRC3' AND SKIP FIRST SCREEN.
* WHEN c_tlevel_4.
* l_arbpl = l_txt+6(8).
*
* SET PARAMETER ID 'WRK' FIELD p_werks.
* SET PARAMETER ID 'AGR' FIELD l_arbpl.
*
* CALL TRANSACTION 'CRC3' AND SKIP FIRST SCREEN.
* ENDCASE.
*
* ELSEIF fp_i_nodestab-text1 <> c_plus AND fp_i_nodestab-text1 <>
* c_minus AND
* sy-title <> 'Process Order Variance - Summary Report'(069)
  .
**Please select order number!
* MESSAGE s063.
* ENDIF.
*
**** TRSL
** CLEAR : v_aufnr , l_txt.
** GET CURSOR FIELD fp_i_nodestab-text1 VALUE l_txt.
** IF fp_i_nodestab-text1 = c_text1 AND NOT l_txt IS INITIAL.
** CASE fp_i_nodestab-tlevel.
** WHEN c_tlevel_2.
** v_aufnr = l_txt.
** call function 'RS_TREE_EXPAND'
** exporting
** node_id = nodelist-id
** list_scroll = 'X'
** exceptions
** others.
** WHEN c_tlevel_3.
** l_arbpl = l_txt(8).
** call function 'RS_TREE_EXPAND'
** exporting
** node_id = nodelist-id
** list_scroll = 'X'
** exceptions
** others.
**
** WHEN c_tlevel_4.
** l_arbpl = l_txt+5(8).
** call function 'RS_TREE_EXPAND'
** exporting
** node_id = nodelist-id
** list_scroll = 'X'
** exceptions
** others.
**
** ENDCASE.
**
** when 'NODE'.
** if selname = 'MINUS' or selname = 'MINUSLINE'.
** call function 'RS_TREE_COMPRESS'
** exporting
** node_id = nodelist-id
** exceptions
** others.
** elseif selname = 'PLUS' or selname = 'PLUSLINE'.
** call function 'RS_TREE_EXPAND'
** exporting
** node_id = nodelist-id
** list_scroll = 'X'
** exceptions
** others.
** else.
** perform uc_prepare_nodetab.
** perform uc_user_callback.
** if exit ne space.
** exit_from_screen.
** endif.
** endif.
** ENDCASE.
**
** ELSEIF fp_i_nodestab-text1 <> c_plus AND fp_i_nodestab-text1 <>
** c_minus AND
** sy-title <> 'Process Order Variance - Summary Report'(069).
***Please select order number!
** MESSAGE s063.
** ENDIF.
*
* WHEN c_trde.
* CLEAR : v_aufnr , l_txt.
* GET CURSOR FIELD fp_i_nodestab-text1 VALUE l_txt.
*
* IF fp_i_nodestab-text1 = c_text1 AND NOT l_txt IS INITIAL.
* CASE fp_i_nodestab-tlevel.
* WHEN c_tlevel_2.
* v_aufnr = l_txt(12).
** SUBMIT zprocessord WITH p_aufnr = v_aufnr
** AND RETURN.
* SUBMIT zprocessord WITH s_aufnr-low = v_aufnr
* AND RETURN.
*
* WHEN c_tlevel_3.
* l_arbpl = l_txt(8).
*
* SET PARAMETER ID 'WRK' FIELD p_werks.
* SET PARAMETER ID 'AGR' FIELD l_arbpl.
*
* CALL TRANSACTION 'CRC3' AND SKIP FIRST SCREEN.
* WHEN c_tlevel_4.
* l_arbpl = l_txt+5(8).
*
* SET PARAMETER ID 'WRK' FIELD p_werks.
* SET PARAMETER ID 'AGR' FIELD l_arbpl.
*
* CALL TRANSACTION 'CRC3' AND SKIP FIRST SCREEN.
* ENDCASE.
*
* ELSEIF fp_i_nodestab-text1 <> c_plus AND fp_i_nodestab-text1 <>
* c_minus.
**Please select order number!
* MESSAGE s063.
* ENDIF.
*
* WHEN c_trpi.
* CLEAR : v_aufnr , l_txt.
* GET CURSOR FIELD fp_i_nodestab-text1 VALUE l_txt.
*
* CLEAR v_aufnr.
* GET CURSOR FIELD fp_i_nodestab-text1 VALUE v_aufnr.
*
* IF fp_i_nodestab-text1 = c_text1 "'NODELIST-TEXT1'
* AND NOT v_aufnr IS INITIAL
* AND fp_i_nodestab-tlevel = c_tlevel_2.
* SUBMIT /eur/rgbptr_order_vari_detail
* WITH p_aufnr = v_aufnr AND RETURN.
* ELSEIF fp_i_nodestab-text1 <> c_plus
* AND fp_i_nodestab-text1 <> c_minus
* AND sy-title <> 'Process Order Variance - Summary Report'(069).
**Please select order number!
* MESSAGE s063.
* ENDIF.
*
* WHEN c_trde.
* CLEAR v_aufnr.
* GET CURSOR FIELD fp_i_nodestab-text1 VALUE v_aufnr.
* IF fp_i_nodestab-text1 = c_text1 "'NODELIST-TEXT1'
* AND NOT v_aufnr IS INITIAL
* AND fp_i_nodestab-tlevel = c_tlevel_2.
* SUBMIT /eur/rgbptr_order_vari_detail
* WITH p_aufnr = v_aufnr AND RETURN.
* ELSEIF fp_i_nodestab-text1 <> c_plus
* AND fp_i_nodestab-text1 <> c_minus.
**Please select order number!
* MESSAGE s063.
* ENDIF.
*
* WHEN c_detl.
* CLEAR: rb_summ, rb_phase.
* rb_detl = c_x.
* PERFORM output.
*
* WHEN c_phas.
* CLEAR: rb_detl, rb_summ.
* rb_phase = c_x.
* PERFORM output.
*
****
**** END OF MOD-101
****
* WHEN c_sums.
* CLEAR: rb_detl, rb_phase.
* rb_summ = c_x.
** fp_l_exit = c_x. "MOD-101-
** PERFORM display. "MOD-101-
* PERFORM output. "MOD-101+
*
* WHEN c_qty.
** Display quantities
* rb_quant = c_x.
* rb_fiscl = space.
*
** fp_l_exit = c_x. "MOD-101-
** PERFORM display. "MOD-101-
* PERFORM output. "MOD-101+
*
* WHEN c_fisc.
** Display fiscal values
* rb_quant = space.
* rb_fiscl = c_x.
*
** fp_l_exit = c_x. "MOD-101-
** PERFORM display. "MOD-101-
* PERFORM output. "MOD-101+
*
* WHEN c_kgm.
** Display in KGMs
* rb_order = space.
* rb_kgm = c_x.
*
** fp_l_exit = c_x. "MOD-101-
** PERFORM display. "MOD-101-
* PERFORM output. "MOD-101+
*
* WHEN c_ordu.
** Display order units
* rb_kgm = space.
* rb_order = c_x.
*
** fp_l_exit = c_x. "MOD-101-
** PERFORM display. "MOD-101-
* PERFORM output. "MOD-101+
*
* WHEN c_zero.
** Display zero loss values
* rb_stdpl = space.
* rb_zloss = c_x.
*
** fp_l_exit = c_x. "MOD-101-
** PERFORM display. "MOD-101-
* PERFORM output. "MOD-101+
*
* WHEN c_std.
** Display standard recipe values
* rb_zloss = space.
* rb_stdpl = c_x.
*
** fp_l_exit = c_x. "MOD-101-
** PERFORM display. "MOD-101-
* PERFORM output. "MOD-101+
*
* WHEN c_trep.
* IF fp_i_nodestab-child IS INITIAL.
**Invalid row selected!
* MESSAGE s064.
* ENDIF.
*
* WHEN c_trcm.
* IF fp_i_nodestab-child IS INITIAL.
**Invalid row selected!
* MESSAGE s064.
* ENDIF.
*
* WHEN 'AUAN'.
* SET PARAMETER ID 'ANR' FIELD s_aufnr.
* CALL TRANSACTION 'COR3' AND SKIP FIRST SCREEN.
* WHEN 'AUAE'.
* SET PARAMETER ID 'ANR' FIELD s_aufnr.
* CALL TRANSACTION 'COR2' AND SKIP FIRST SCREEN.
* WHEN c_exit.
* LEAVE PROGRAM.
* ENDCASE.
*
***"BEGIN OF MOD-101
** IF sy-ucomm = c_back AND fp_l_ucomm = c_sums.
** CLEAR: rb_summ, rb_phase.
** rb_detl = c_x.
** fp_l_list_refresh = c_m.
** PERFORM list_display.
** fp_l_exit = c_x.
** ENDIF.
***"END OF MOD-101
*ENDFORM. "user_command
*
**&---------------------------------------------------------------------
*
**& Form LIST_DISPLAY
**&---------------------------------------------------------------------
*
** text
**----------------------------------------------------------------------
*
*FORM list_display.
**" >>> MOD-101-
* CALL FUNCTION 'RS_TREE_CONSTRUCT'
* TABLES
* nodetab = i_nodestab
* EXCEPTIONS
* tree_failure = 1
* id_not_found = 2
* wrong_relationship = 3
* OTHERS = 4.
* IF sy-subrc <> 0.
* MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
* WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
* ENDIF.
**" <<< MOD-101-
*
* CALL FUNCTION 'RS_TREE_LIST_DISPLAY'
* EXPORTING
** callback_program = c_prog "MOD-101-
* callback_program = sy-repid "MOD-101+
* callback_user_command = 'USER_COMMAND'.
*ENDFORM. " LIST_DISPLAY
*
**&---------------------------------------------------------------------
*
**& Form inform_user_of_progress
**&---------------------------------------------------------------------
*
** text
**----------------------------------------------------------------------
*
*FORM inform_user_of_progress.
** Update Gui
* CONDENSE v_output_text.
* CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
* EXPORTING
* text = v_output_text.
*ENDFORM. " inform_user_of_progress
*
**&---------------------------------------------------------------------
*
**& Form pfstatus
**&---------------------------------------------------------------------
*
** text
**----------------------------------------------------------------------
*
*FORM pfstatus.
*
** Build table of excluded functions for buttons in report
* REFRESH i_fcode.
*
** Not summary report
* IF NOT ( rb_summ IS INITIAL ). " MOD-101-
* MOVE c_trde TO wa_fcode-fcode.
* APPEND wa_fcode TO i_fcode. CLEAR wa_fcode.
* MOVE c_sums TO wa_fcode-fcode.
* APPEND wa_fcode TO i_fcode.
* CLEAR wa_fcode.
**** BEGIN OF MOD-101
* ELSEIF rb_detl = c_x.
* MOVE c_trde TO wa_fcode-fcode.
* APPEND wa_fcode TO i_fcode. CLEAR wa_fcode.
*
* MOVE c_detl TO wa_fcode-fcode.
* APPEND wa_fcode TO i_fcode.
*
* CLEAR wa_fcode.
*
* ELSEIF rb_phase = c_x.
* MOVE c_trde TO wa_fcode-fcode.
* APPEND wa_fcode TO i_fcode. CLEAR wa_fcode.
*
* MOVE c_phas TO wa_fcode-fcode.
* APPEND wa_fcode TO i_fcode.
*
* CLEAR wa_fcode.
**** END OF MOD-101
* ENDIF.
*
** Fiscal / quantity
* IF rb_fiscl IS INITIAL.
* MOVE c_qty TO wa_fcode-fcode.
* APPEND wa_fcode TO i_fcode.
* CLEAR wa_fcode.
* ELSE.
* MOVE c_fisc TO wa_fcode-fcode.
* APPEND wa_fcode TO i_fcode.
* CLEAR wa_fcode.
*
*****Begin of MOD-001
** MOVE c_ordu TO wa_fcode-fcode.
** APPEND wa_fcode TO i_fcode.
** CLEAR wa_fcode.
** MOVE c_kgm TO wa_fcode-fcode.
** APPEND wa_fcode TO i_fcode.
** CLEAR wa_fcode.
*****End of MOD-001
* ENDIF.
*
** KGM / Order uom
* IF rb_kgm IS INITIAL.
* MOVE c_ordu TO wa_fcode-fcode.
* APPEND wa_fcode TO i_fcode.
* CLEAR wa_fcode.
* ELSE.
* MOVE c_kgm TO wa_fcode-fcode.
* APPEND wa_fcode TO i_fcode.
* CLEAR wa_fcode.
* ENDIF.
*
** Zero loss / std values
* IF rb_zloss IS INITIAL.
* MOVE c_std TO wa_fcode-fcode.
* APPEND wa_fcode TO i_fcode.
* CLEAR wa_fcode.
* ELSE.
* MOVE c_zero TO wa_fcode-fcode.
* APPEND wa_fcode TO i_fcode. CLEAR wa_fcode.
* ENDIF.
*ENDFORM. " pfstatus
*
**=========================================================*
******BEGIN OF MOD-003.
**&---------------------------------------------------------------------
*
**& Form validate_stlan
**&---------------------------------------------------------------------
*
** subroutine to validate BOM usage
**----------------------------------------------------------------------
*
*FORM validate_stlan .
* DATA: l_usage TYPE stlan.
** IF p_usage IS INITIAL. "MOD-101-
** MESSAGE e030. "Plese enter BOM usage "MOD-101-
** ELSE. "MOD-101-
* SELECT stlan INTO l_usage "get BOM usage
* FROM t416 UP TO 1 ROWS
* WHERE stlan = p_usage.
* ENDSELECT.
*
* IF sy-subrc NE 0.
** MESSAGE e030. "BOM usage doesn't exist. "MOD-101-
* MESSAGE e030 WITH p_usage. "MOD-101+
* ENDIF.
** ENDIF. "MOD-101-
*ENDFORM. " validate_stlan
*
**&---------------------------------------------------------------------
*
**& Form validate_steus
**&---------------------------------------------------------------------
*
** subroutine to validate control key
**----------------------------------------------------------------------
*
*FORM validate_steus .
**** BEGIN OF MOD-101
* r_steus = s_steus[].
**"Get control key from T430
* SELECT plnaw
* steus
* kalkz
* FROM t430
* INTO TABLE i_ckey
* WHERE steus IN s_steus
* AND kalkz EQ c_x.
* IF sy-subrc NE 0.
* MESSAGE e054. "enter valid control key.
* ENDIF.
*
***"Get control key from T430
** DATA: l_steus TYPE steus.
**
***"if control key is not entered
** IF s_steus[] IS INITIAL.
** MESSAGE e071. "Please enter control key.
** ELSE.
***"get control key
** SELECT steus INTO l_steus
** FROM t430
** UP TO 1 ROWS
** WHERE steus IN s_steus.
** ENDSELECT.
** IF sy-subrc NE 0.
** MESSAGE e054. "enter valid control key.
** ENDIF.
** ENDIF.
**** END OF MOD-101
*ENDFORM. " validate_steus
*
**&---------------------------------------------------------------------
*
**& Form validate_lstar
**&---------------------------------------------------------------------
*
** subroutine to validate machine hours indicator
**----------------------------------------------------------------------
*
**form validate_lstar .
**data:l_lstar tyep lstar.
**
**endform. " validate_lstar
******END OF MOD-003.
*
**** BEGIN OF MOD-101
**&--------------------------------------------------------------------*
**& Form tree_rebuild
**&--------------------------------------------------------------------*
** build / rebuild tree
**---------------------------------------------------------------------*
*FORM tree_rebuild.
* CALL FUNCTION 'RS_TREE_CONSTRUCT'
* TABLES
* nodetab = i_nodestab
* EXCEPTIONS
* tree_failure = 1
* id_not_found = 2
* wrong_relationship = 3
* OTHERS = 4.
*
* IF sy-subrc <> 0.
* MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
* WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
* ENDIF.
*ENDFORM. "tree_rebuild
*
**&--------------------------------------------------------------------*
**& Form conv_to_from_base
**&--------------------------------------------------------------------*
** text
**---------------------------------------------------------------------*
*FORM conv_to_from_base USING fp_kzmeinh
* fp_matnr
* fp_input
* fp_meinh
* fp_meins
* CHANGING fp_output
* fp_rc.
* CLEAR : fp_rc , fp_output.
* CALL FUNCTION 'MATERIAL_UNIT_CONVERSION'
* EXPORTING
* input = fp_input
* kzmeinh = fp_kzmeinh
* matnr = fp_matnr
* meinh = fp_meinh
* meins = fp_meins
** CHARGE =
** WERKS =
* IMPORTING
* output = fp_output
** UMREN =
** UMREZ =
* EXCEPTIONS
* conversion_not_found = 1
* input_invalid = 2
* material_not_found = 3
* meinh_not_found = 4
* meins_missing = 5
* no_meinh = 6
* output_invalid = 7
* overflow = 8
* OTHERS = 9.
* IF sy-subrc <> 0.
* fp_rc = 'X'.
* ENDIF.
*ENDFORM. "conv_to_from_base
*
**&--------------------------------------------------------------------*
**& Form convert_to_kg
**&--------------------------------------------------------------------*
** text
**---------------------------------------------------------------------*
*FORM convert_to_kg USING fp_matnr TYPE matnr
* fp_bsuom TYPE meins
* fp_gewei TYPE gewei
* fp_ntgew TYPE ntgew
* fp_qtyin TYPE menge_d
* CHANGING fp_qtout TYPE menge_d
* fp_rc.
* DATA : l_out TYPE menge_d.
*
* CLEAR : fp_rc , fp_qtout.
*
* l_out = fp_qtyin * fp_ntgew.
*
* IF fp_gewei <> 'KG'.
* CALL FUNCTION 'UNIT_CONVERSION_SIMPLE'
* EXPORTING
* input = l_out
* unit_in = fp_gewei
* unit_out = 'KG'
* IMPORTING
* output = fp_qtout
* EXCEPTIONS
* conversion_not_found = 1
* division_by_zero = 2
* input_invalid = 3
* output_invalid = 4
* overflow = 5
* type_invalid = 6
* units_missing = 7
* unit_in_not_found = 8
* unit_out_not_found = 9
* OTHERS = 10.
* IF sy-subrc <> 0.
* fp_rc = 'X'.
* ENDIF.
*
* ELSE.
* fp_qtout = l_out.
* ENDIF.
*ENDFORM. "convert_to_kg
*
**&--------------------------------------------------------------------*
**& Form do_mat_calc
**&--------------------------------------------------------------------*
** text
**---------------------------------------------------------------------*
*FORM do_mat_calc CHANGING fp_h_mat TYPE ty_hier_mat
* fp_aqty TYPE char18
* fp_matuom TYPE meins
* fp_sqty TYPE char18
* fp_stduom TYPE meins
* fp_svar TYPE char18
* fp_varuom TYPE meins
* fp_svarp TYPE char18
* fp_amenge TYPE menge_d
* fp_smenge TYPE menge_d
* fp_astprs TYPE ty_stprs
* fp_sstprs TYPE ty_stprs.
*
* DATA : l_aqty TYPE char18,
* l_sqty TYPE char18,
* l_svar TYPE char18,
* l_svarp TYPE char18,
*
* l_matuom TYPE meins,
* l_stduom TYPE meins,
* l_varuom TYPE meins,
*
* l_amenge TYPE menge_d,
* l_smenge TYPE menge_d,
* l_menge TYPE menge_d,
* l_mvar TYPE menge_d,
*
* l_astprs TYPE ty_stprs,
* l_sstprs TYPE ty_stprs,
* l_vstprs TYPE ty_stprs,
*
* l_wa_h_mat TYPE ty_hier_mat,
*
* l_fact_a TYPE menge_d VALUE 1,
* l_fact_s TYPE menge_d VALUE 1.
*
* CLEAR : l_smenge, l_amenge, l_astprs, l_sstprs, l_stduom, l_matuom,
* l_varuom, l_aqty , l_sqty , l_svar , l_svarp .
*
* l_wa_h_mat = fp_h_mat.
** Standard planned or zero loss planned
* IF rb_zloss IS INITIAL.
* l_wa_h_mat-stdusg = l_wa_h_mat-stdusgs.
*
* ELSE.
* l_wa_h_mat-stdusg = l_wa_h_mat-stdusgz.
* ENDIF.
*
* l_smenge = fp_smenge + l_wa_h_mat-stdusg.
* l_amenge = l_wa_h_mat-actusg.
*
* IF l_wa_h_mat-bsuom = 'EA' OR l_wa_h_mat-bsuom = 'CS'.
** Begin of MOD-002++
** l_smenge = CEIL( l_wa_h_mat-stdusg ).
** l_amenge = CEIL( l_wa_h_mat-actusg ).
** End of MOD-002++
*
* l_wa_h_mat-stdusg = l_smenge.
* l_wa_h_mat-actusg = l_amenge.
* ENDIF.
*
** Order UoM or KG
** IF rb_quant EQ c_x AND rb_kgm IS INITIAL.
* IF rb_kgm IS INITIAL.
* l_matuom = l_wa_h_mat-gruom.
* l_stduom = l_wa_h_mat-bomuom.
*
* IF l_wa_h_mat-gruom <> l_wa_h_mat-bsuom.
* PERFORM conv_to_from_base USING ' '
* l_wa_h_mat-matnr
* l_amenge
* l_wa_h_mat-gruom
* l_wa_h_mat-bsuom
* CHANGING l_menge
* v_conv_rc.
* IF v_conv_rc <> c_x.
* l_amenge = l_menge.
* PERFORM convert_unit USING l_wa_h_mat-matnr
* 1
* l_wa_h_mat-gruom
* l_wa_h_mat-bsuom
* CHANGING l_fact_a.
* IF l_fact_a = 0.
* l_fact_a = 1.
* ENDIF.
* ENDIF.
* ENDIF.
*
* IF l_wa_h_mat-bsuom <> l_wa_h_mat-bomuom.
* PERFORM conv_to_from_base USING ' '
* l_wa_h_mat-matnr
* l_smenge
* l_wa_h_mat-bomuom
* l_wa_h_mat-bsuom
* CHANGING l_menge
* v_conv_rc.
* IF v_conv_rc <> c_x.
* l_smenge = l_menge.
* PERFORM convert_unit USING l_wa_h_mat-matnr
* 1
* l_wa_h_mat-bomuom
* l_wa_h_mat-bsuom
* CHANGING l_fact_s.
* IF l_fact_s = 0.
* l_fact_s = 1.
* ENDIF.
* ENDIF.
* ENDIF.
*
* ELSE.
* l_matuom = l_wa_h_mat-bsuom.
* l_stduom = l_wa_h_mat-bsuom.
*
* IF l_wa_h_mat-bsuom <> 'KG'.
* PERFORM convert_to_kg USING l_wa_h_mat-matnr l_wa_h_mat-bsuom
* l_wa_h_mat-gewei l_wa_h_mat-ntgew
* l_amenge
* CHANGING l_menge
* v_conv_rc.
* IF v_conv_rc = 'X'.
* CLEAR : l_amenge , l_matuom.
*
* ELSE.
* l_amenge = l_menge.
* l_matuom = 'KG'.
* PERFORM convert_to_kg USING l_wa_h_mat-matnr l_wa_h_mat-bsuom
* l_wa_h_mat-gewei l_wa_h_mat-ntgew
* 1
* CHANGING l_fact_a
* v_conv_rc.
* IF l_fact_a = 0.
* l_fact_a = 1.
* ENDIF.
* l_fact_a = 1 / l_fact_a.
* ENDIF.
*
* PERFORM convert_to_kg USING l_wa_h_mat-matnr l_wa_h_mat-bsuom
* l_wa_h_mat-gewei l_wa_h_mat-ntgew
* l_smenge
* CHANGING l_menge
* v_conv_rc.
* IF v_conv_rc = 'X'.
* CLEAR : l_smenge , l_stduom.
*
* ELSE.
* l_smenge = l_menge.
* l_stduom = 'KG'.
* PERFORM convert_to_kg USING l_wa_h_mat-matnr l_wa_h_mat-bsuom
* l_wa_h_mat-gewei l_wa_h_mat-ntgew
* 1
* CHANGING l_fact_s
* v_conv_rc.
* IF l_fact_s = 0.
* l_fact_s = 1.
* ENDIF.
* l_fact_s = 1 / l_fact_s.
* ENDIF.
* ENDIF.
* ENDIF.
*
** Fiscal or quantity
* CLEAR : l_sqty , l_aqty, l_svar, l_svarp, l_mvar, l_vstprs.
* IF rb_quant EQ c_x.
* IF l_wa_h_mat-bsuom = 'EA' OR l_wa_h_mat-bsuom = 'CS'.
** Begin of MOD-002++
** l_smenge = CEIL( l_smenge ).
** l_amenge = CEIL( l_amenge ).
** End of MOD-002++
* IF l_wa_h_mat-peinh <> 0.
* l_astprs = l_amenge * l_fact_a *
* ( l_wa_h_mat-stprs / l_wa_h_mat-peinh ).
* l_sstprs = fp_sstprs + l_smenge * l_fact_s *
* ( l_wa_h_mat-stprs / l_wa_h_mat-peinh ).
* ENDIF.
* ELSE.
* IF l_wa_h_mat-peinh <> 0.
* l_astprs = l_wa_h_mat-actusg *
* ( l_wa_h_mat-stprs / l_wa_h_mat-peinh ).
* l_sstprs = fp_sstprs + l_wa_h_mat-stdusg *
* ( l_wa_h_mat-stprs / l_wa_h_mat-peinh ).
* ENDIF.
* ENDIF.
* l_vstprs = l_sstprs - l_astprs.
*
* WRITE : l_amenge TO l_aqty UNIT l_matuom NO-GROUPING.
* WRITE : l_smenge TO l_sqty UNIT l_stduom NO-GROUPING.
*
* IF l_matuom IS INITIAL OR l_matuom EQ l_stduom.
* l_mvar = l_smenge - l_amenge.
*
* IF l_smenge <> 0.
* l_wa_h_mat-varper = ( l_mvar / l_smenge ) * 100.
* ELSE.
* l_wa_h_mat-varper = 0.
* ENDIF.
* ENDIF.
*
* WRITE : l_mvar TO l_svar UNIT l_stduom NO-GROUPING.
* WRITE : l_wa_h_mat-varper TO l_svarp NO-GROUPING DECIMALS 2.
* l_varuom = l_stduom.
*
* ELSE.
* l_matuom = v_waers.
* l_stduom = v_waers.
* l_varuom = v_waers.
*
* IF l_wa_h_mat-bsuom = 'EA' OR l_wa_h_mat-bsuom = 'CS'.
** Begin of MOD-002++
** l_smenge = CEIL( l_smenge ).
** l_amenge = CEIL( l_amenge ).
** End of MOD-002++
* IF l_wa_h_mat-peinh <> 0.
* l_astprs = l_amenge * l_fact_a *
* ( l_wa_h_mat-stprs / l_wa_h_mat-peinh ).
* l_sstprs = fp_sstprs + l_smenge * l_fact_s *
* ( l_wa_h_mat-stprs / l_wa_h_mat-peinh ).
* ENDIF.
* ELSE.
* IF l_wa_h_mat-peinh <> 0.
* l_astprs = l_wa_h_mat-actusg *
* ( l_wa_h_mat-stprs / l_wa_h_mat-peinh ).
* l_sstprs = fp_sstprs + l_wa_h_mat-stdusg *
* ( l_wa_h_mat-stprs / l_wa_h_mat-peinh ).
* ENDIF.
* ENDIF.
*
* l_vstprs = l_sstprs - l_astprs.
*
* IF l_sstprs <> 0.
* l_wa_h_mat-varper = ( l_vstprs / l_sstprs ) * 100.
* ELSE.
* l_wa_h_mat-varper = 0.
* ENDIF.
*
* v_prs = l_astprs.
* WRITE : v_prs TO l_aqty CURRENCY v_waers NO-GROUPING.
*
* v_prs = l_sstprs.
* WRITE : v_prs TO l_sqty CURRENCY v_waers NO-GROUPING.
*
* v_prs = l_vstprs.
* WRITE : v_prs TO l_svar CURRENCY v_waers NO-GROUPING.
*
* WRITE : l_wa_h_mat-varper TO l_svarp NO-GROUPING DECIMALS 2.
* ENDIF.
*
* l_wa_h_mat-stdvar = l_mvar.
* l_wa_h_mat-vstprs = l_vstprs.
*
* fp_aqty = l_aqty.
* fp_matuom = l_matuom.
*
* fp_sqty = l_sqty.
* fp_stduom = l_stduom.
*
* fp_svar = l_svar.
* fp_varuom = l_varuom.
*
* fp_svarp = l_svarp.
*
* fp_amenge = l_amenge.
* fp_astprs = l_astprs.
*
* fp_smenge = l_smenge.
* fp_sstprs = l_sstprs.
*
* fp_h_mat = l_wa_h_mat.
*ENDFORM. "do_mat_calc
*
**&---------------------------------------------------------------------
*
**& Form convert_unit
**&---------------------------------------------------------------------
*
** Convert UoM
**----------------------------------------------------------------------
*
** -->fp_matnr Material
** -->fp_in_qty In Qty
** -->fp_in_uom In UoM
** -->fp_out_uom Out UoM
** <--fp_out_qty Out Qty
**----------------------------------------------------------------------
*
*FORM convert_unit USING fp_matnr TYPE matnr
* fp_in_qty TYPE bstmg
* fp_in_uom TYPE meins
* fp_out_uom TYPE meins
* CHANGING fp_out_qty TYPE bstmg.
*
* IF fp_in_uom = fp_out_uom.
* fp_out_qty = fp_in_qty.
* EXIT.
* ENDIF.
*
* CALL FUNCTION 'MD_CONVERT_MATERIAL_UNIT'
* EXPORTING
* i_matnr = fp_matnr
* i_in_me = fp_in_uom
* i_out_me = fp_out_uom
* i_menge = fp_in_qty
* IMPORTING
* e_menge = fp_out_qty
* EXCEPTIONS
* error_in_application = 1
* error = 2
* OTHERS = 3.
* IF sy-subrc <> 0.
* fp_out_qty = 0.
* ENDIF.
*
*ENDFORM. " convert_unit
************************************************************************
**************
*&---------------------------------------------------------------------*
*& Include ZPROCESSORDVARF01 *
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
* Report: : ZPROCESSORD
* AUTHOR : Aveek Ghose *
* SUPPLIER : IBM *
*======================================================================*
* CHANGE HISTORY LOG *
*----------------------------------------------------------------------*
* MOD. NO.| DATE | NAME | CORRECTION NUMBER | CHANGE REFERENCE #*
*----------------------------------------------------------------------*
* MOD-001 |DD/MM/YYYY| XXXXXX | XXXXXXXXXX | XXXXXXXXX *
* DESCRIPTION: *
*----------------------------------------------------------------------*
* MOD-002 |DD/MM/YYYY| XXXXXX | XXXXXXXXXX | XXXXXXXXX *
* DESCRIPTION: *
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Include ZPROCESSORDVARF01
*&---------------------------------------------------------------------*
FORM FILL_MOVEMENT_TYPES .
  REFRESH I_R_BWART.
* wa_bwart-sign = c_sign.
* wa_bwart-option = c_option.
* wa_bwart-low = '101'.
* APPEND wa_bwart TO i_r_bwart.
* CLEAR wa_bwart.
*
* wa_bwart-sign = c_sign.
* wa_bwart-option = c_option.
* wa_bwart-low = '102'.
* APPEND wa_bwart TO i_r_bwart.
* CLEAR wa_bwart.
  WA_BWART-SIGN = C_SIGN.
  WA_BWART-OPTION = C_OPTION.
  WA_BWART-LOW = C_MOVM_LOW_261.
  APPEND WA_BWART TO I_R_BWART.
  CLEAR WA_BWART.
  WA_BWART-SIGN = C_SIGN.
  WA_BWART-OPTION = C_OPTION.
  WA_BWART-LOW = C_MOVM_LOW_262.
  APPEND WA_BWART TO I_R_BWART.
  CLEAR WA_BWART.
  WA_BWART-SIGN = C_SIGN.
  WA_BWART-OPTION = C_OPTION.
  WA_BWART-LOW = C_MOVM_LOW_531.
  APPEND WA_BWART TO I_R_BWART.
  CLEAR WA_BWART.
  WA_BWART-SIGN = C_SIGN.
  WA_BWART-OPTION = C_OPTION.
  WA_BWART-LOW = C_MOVM_LOW_532.
  APPEND WA_BWART TO I_R_BWART.
  CLEAR WA_BWART.
ENDFORM. " fill_movement_types
*&---------------------------------------------------------------------*
*& Form get_currency
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM GET_CURRENCY.
****Begin of MOD-001
  DATA : L_BUKRS TYPE BUKRS,
  L_WAERS TYPE WAERS.
  CLEAR : V_WAERS.
  IF NOT P_WERKS IS INITIAL.
    SELECT SINGLE WERKS FROM T001W INTO V_WERKS
    WHERE WERKS = P_WERKS.
    IF SY-SUBRC <> 0.
      MESSAGE E001 WITH P_WERKS. " Invalid Plant
    ENDIF.
  ENDIF.
*
*Retrieve the company code
  SELECT SINGLE BUKRS
  FROM T001K
  INTO L_BUKRS
  WHERE BWKEY = P_WERKS.
  IF SY-SUBRC = 0.
*Get the currence at company
    SELECT SINGLE WAERS
    FROM T001
    INTO V_WAERS
    WHERE BUKRS = L_BUKRS.
  ENDIF.
******************MOD-004******************************
* SELECT SINGLE waers
* FROM tka01 INTO l_waers
* WHERE kokrs = p_kokrs.
*
* IF sy-subrc <> 0.
* MESSAGE e046. " Invalid Controlling area entered.
*
* ELSEIF v_waers IS INITIAL.
** If the currency is not maintained at companmy level
* v_waers = l_waers.
* ENDIF.
*****************MOD-004******************************
* AUTHORITY-CHECK OBJECT 'C_AFKO_AWK'
* ID 'WERKS' FIELD p_werks
* ID 'AUFART' DUMMY.
* IF sy-subrc <> 0.
* MESSAGE e000 WITH
* 'You do not have authorisation to display report'(070).
* ENDIF.
***************MOD-004************************************
* IF NOT p_werks IS INITIAL.
* SELECT SINGLE werks FROM t001w INTO v_werks
* WHERE werks = p_werks.
* IF sy-subrc <> 0.
* MESSAGE e001 WITH p_werks. " Invalid Plant
* ENDIF.
* ENDIF.
**********End of MOD-001.
ENDFORM. " get_currency
*&---------------------------------------------------------------------*
*& Form check_materials
*&---------------------------------------------------------------------*
* text - Checking material number and material type values
*----------------------------------------------------------------------*
FORM CHECK_MATERIALS.
  DATA : L_MATNR TYPE MATNR,                                "#EC NEEDED
  L_MTART TYPE MTART.                                       "#EC NEEDED
* Checking material(s) valid or not
  IF NOT ( S_MATNR[] IS INITIAL ).
* Checking at leaset one material is valid for select-options material.
    SELECT SINGLE MATNR
    FROM MARA
    INTO L_MATNR
    WHERE MATNR IN S_MATNR.                                 "#EC *
    IF SY-SUBRC <> 0.
      MESSAGE E000 WITH 'Material(s) not found for this selection'(062).
    ENDIF.
  ENDIF.
* Checking material type valid or not
  IF NOT ( P_MTART IS INITIAL ).
    SELECT SINGLE MTART
    FROM T134 INTO L_MTART "MOD IB mara-mtart
    WHERE MTART = P_MTART.
    IF SY-SUBRC <> 0.
      MESSAGE E000 WITH 'Incorrect Material Type'(063).
    ENDIF.
  ENDIF.
* Checking material number and type valid or not.
  IF NOT ( S_MATNR[] IS INITIAL ) AND
  NOT ( P_MTART IS INITIAL ).
* Checking at leaset one material is valid for select-options material
* and for material type
    CLEAR L_MATNR.
    SELECT SINGLE MATNR
    FROM MARA
    INTO L_MATNR
    WHERE MATNR IN S_MATNR AND
    MTART = P_MTART.                                        "#EC *
    IF SY-SUBRC <> 0.
      MESSAGE E000
      WITH 'Incorrect material number & type combination'(064).
    ENDIF.
  ENDIF.
ENDFORM. " check_materials
*&---------------------------------------------------------------------*
*& Form get_status
*&---------------------------------------------------------------------*
* text -- Retreving System status texts from table TJ02T
*----------------------------------------------------------------------*
FORM GET_STATUS USING FP_TXT04 TYPE J_TXT04
CHANGING FP_STAT TYPE J_ISTAT.
** >>>> MOD-101+
  CLEAR : FP_STAT.
  SELECT SINGLE ISTAT
  FROM TJ02T
  INTO FP_STAT
  WHERE TXT04 = FP_TXT04
  AND SPRAS = SY-LANGU.                               "#EC CI_SGLSELECT
*** if select fails stat is returned empty, so no check required.
** <<<< MOD-101+
* REFRESH i_tj02t.
* CLEAR wa_tj02t.
* IF NOT ( s_stats[] IS INITIAL ).
* SELECT txt04
* FROM tj02t INTO TABLE i_tj02t
* WHERE txt04 IN s_stats
* AND spras = sy-langu. "#EC CI_SGLSELECT
** IF sy-subrc = 0.
*** The check is not required here since the
*** system status text is not mandatory
** ENDIF.
* ENDIF.
*
* IF rb_ezero = c_x.
* IF rb_prod = c_x.
* wa_tj02t-txt04 = c_txt_dlv.
* ENDIF.
*
* IF rb_conf = c_x.
* wa_tj02t-txt04 = c_txt_cnf.
* ENDIF.
* APPEND wa_tj02t TO i_tj02t.
* CLEAR wa_tj02t.
* ENDIF.
* SORT i_tj02t BY txt04 AS TEXT. " MOD IB (SORT i_tj02t)
* DELETE ADJACENT DUPLICATES FROM i_tj02t.
ENDFORM. " get_status
*&---------------------------------------------------------------------*
*& Form get_status_info
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM GET_STATUS_INFO USING FP_L_ORDERS_OBJNR TYPE J_OBJNR
FP_L_STTXT TYPE ANY.
  DATA: L_TEXT(4) TYPE C,
  L_STSMA TYPE J_STSMA,
* START MOD IB
  I_STATUS TYPE STANDARD TABLE OF JSTAT INITIAL SIZE 0,
  WA_STATUS TYPE JSTAT.
* END MOD IB
  REFRESH I_STATUS.
* Get all active statuses for the order
  CALL FUNCTION 'STATUS_READ'
    EXPORTING
      OBJNR       = FP_L_ORDERS_OBJNR
      ONLY_ACTIVE = C_X
    IMPORTING
      STSMA       = L_STSMA
    TABLES
      STATUS      = I_STATUS.
  CLEAR: FP_L_STTXT.
  LOOP AT I_STATUS INTO WA_STATUS.
* Get the text for each status
    CALL FUNCTION 'STATUS_NUMBER_CONVERSION'
      EXPORTING
        LANGUAGE      = SY-LANGU
        STATUS_NUMBER = WA_STATUS-STAT
        STSMA         = L_STSMA
      IMPORTING
        TXT04         = L_TEXT.
* Add status text found to current list
    CONCATENATE FP_L_STTXT L_TEXT INTO FP_L_STTXT.
    CLEAR : WA_STATUS.
  ENDLOOP.
ENDFORM. " get_status_info
*&---------------------------------------------------------------------*
*& Form get_work_center
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM GET_WORK_CENTER.
  CLEAR: WA_CRHD.
  REFRESH: I_CRHD.
  SELECT OBJID
  ARBPL
  FROM CRHD INTO TABLE I_CRHD
  WHERE OBJTY = C_OBJTYP
  AND WERKS = P_WERKS
  AND ARBPL IN S_ARBPL.
* IF sy-subrc = 0.
** sy-subrc check is not required, there must be atleast one record for
** this selection.
* ENDIF.
ENDFORM. " get_work_center
*&---------------------------------------------------------------------*
*& Form get_cost_center
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM GET_COST_CENTER.
  IF NOT ( S_KOSTL[] IS INITIAL ).
    CLEAR : I_CSKS.
    SELECT KOKRS KOSTL
    FROM CSKS
    INTO TABLE I_CSKS
    WHERE KOKRS = P_KOKRS
    AND KOSTL IN S_KOSTL.
    IF SY-SUBRC = 0.
      SORT I_CSKS BY KOKRS KOSTL.
    ENDIF.
  ENDIF.
ENDFORM. " get_cost_center
****
**** BEGIN OF MOD-101
****
*&---------------------------------------------------------------------*
*& Form get_orders
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM GET_ORDERS.
  DATA: L_STTXT(100) TYPE C,
  FLG_STATUS(1) TYPE C.
  FIELD-SYMBOLS : <FS_ORDERS> TYPE TY_ORDERS.
  MOVE 'Extracting Process Orders'(022) TO V_OUTPUT_TEXT.
  PERFORM INFORM_USER_OF_PROGRESS.
  IF NOT P_MTART IS INITIAL.
*"selection filter on material type
    SELECT MATNR "material number
    MTART "material type
    INTO TABLE I_MTART
    FROM MARA
    WHERE MATNR IN S_MATNR
    AND MTART = P_MTART.
    IF SY-SUBRC = C_0.
* refill S_MATNR with I_MTART values
      REFRESH : S_MATNR.
      S_MATNR-SIGN = C_SIGN.
      S_MATNR-OPTION = C_OPTION.
      LOOP AT I_MTART INTO WA_MTART.
        S_MATNR-LOW = WA_MTART-MATNR.
        APPEND S_MATNR.
      ENDLOOP.
    ELSE.
* No data was selected for material type
      MESSAGE I072 WITH P_MTART.
      LEAVE LIST-PROCESSING.
    ENDIF.
  ENDIF.
  SELECT AUFNR
  WERKS
  KOKRS
  OBJNR
  GLTRP
  GSTRP
  RSNUM
  GAMNG
  GMEIN
  PLNBEZ
  PLNTY
  PLNNR
  PLNAL
  STLST
  STLTY
  STLNR
  SDATV
  STLAL
  STLAN
  AUFPL
  ZAEHL
  RUECK
  AUART
  AUFLD                                                     "31-05-2005
  INTO TABLE I_ORDERS FROM CAUFV
  WHERE AUFNR IN S_AUFNR
  AND WERKS = P_WERKS
* AND kokrs = p_kokrs
  AND FEVOR IN S_FEVOR
  AND PLNBEZ IN S_MATNR
  AND STLAN = P_USAGE
  AND ( GSTRP IN S_DATUV OR
  GLTRP IN S_DATUV ).
  IF SY-SUBRC <> 0.
    MESSAGE S007.
    LEAVE LIST-PROCESSING.
  ENDIF.
  SORT I_ORDERS BY AUFNR.
* Take status txt from sel screen and get status number
  IF NOT P_STATS1 IS INITIAL.
    PERFORM GET_STATUS USING P_STATS1 CHANGING V_STAT1.
  ENDIF.
  IF NOT P_STATS2 IS INITIAL.
    PERFORM GET_STATUS USING P_STATS2 CHANGING V_STAT2.
  ENDIF.
* get object numbers and statuses for orders
  CLEAR : I_OBJ_STAT.
  SELECT OBJNR
  STAT
  FROM JEST
  INTO TABLE I_OBJ_STAT
  FOR ALL ENTRIES IN I_ORDERS
  WHERE OBJNR = I_ORDERS-OBJNR
  AND STAT IN (V_STAT1,V_STAT2).
* cull orders
  LOOP AT I_ORDERS ASSIGNING <FS_ORDERS>.
    IF NOT V_STAT1 IS INITIAL.
      READ TABLE I_OBJ_STAT INTO WA_OBJ_STAT
      WITH KEY OBJNR = <FS_ORDERS>-OBJNR
      STAT = V_STAT1.
      IF SY-SUBRC = 0 AND P_S1_CHK EQ C_X.
        <FS_ORDERS>-DEL = C_X.
      ELSEIF SY-SUBRC NE 0 AND P_S1_CHK NE C_X.
        <FS_ORDERS>-DEL = C_X.
      ENDIF.
    ENDIF.
    IF NOT V_STAT2 IS INITIAL.
      READ TABLE I_OBJ_STAT INTO WA_OBJ_STAT
      WITH KEY OBJNR = <FS_ORDERS>-OBJNR
      STAT = V_STAT2.
      IF SY-SUBRC = 0 AND P_S2_CHK EQ C_X.
        <FS_ORDERS>-DEL = C_X.
      ELSEIF SY-SUBRC NE 0 AND P_S2_CHK NE C_X.
        <FS_ORDERS>-DEL = C_X.
      ENDIF.
    ENDIF.
  ENDLOOP.
* DELETE i_orders WHERE del = c_x.
* LOOP AT i_orders INTO wa_orders.
* IF NOT i_tj02t[] IS INITIAL .
* PERFORM get_status_info USING wa_orders-objnr l_sttxt.
*
* CLEAR: flg_status, wa_tj02t.
* LOOP AT i_tj02t INTO wa_tj02t.
* IF l_sttxt NS wa_tj02t-txt04.
* CLEAR flg_status.
* EXIT.
* ELSE.
* flg_status = c_x.
* CONTINUE.
* ENDIF.
* CLEAR : wa_tj02t.
* ENDLOOP.
*
* IF flg_status <> c_x.
* DELETE i_orders.
* CONTINUE.
* ENDIF.
* ENDIF.
* ENDLOOP.
ENDFORM. " get_orders
*&---------------------------------------------------------------------*
*& Form get_operations
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM GET_OPERATIONS.
  DATA L_TABIX TYPE SYTABIX.
* Let the user know whats up
  MOVE 'Extracting Phase Information'(023) TO V_OUTPUT_TEXT.
  PERFORM INFORM_USER_OF_PROGRESS.
* select process order item lines
  SELECT AUFPL
  APLZL
  LTXA1
  PLNKN
  PLNTY
  PLNNR
  ZAEHL
  VORNR
  STEUS
  ARBID
  RUECK
  PHFLG
  SUMNR
  VGWTS
  LAR01
  LAR02
  LAR03
  LAR04
  LAR05
  LAR06
  INTO TABLE I_AFVC
  FROM AFVC
  FOR ALL ENTRIES IN I_ORDERS
  WHERE AUFPL = I_ORDERS-AUFPL
  AND STEUS IN S_STEUS.
***********MOD-004*****************************
* AND phflg = c_x.
***********MOD-004*****************************
  IF SY-SUBRC = 0.
* select process order item values
    SELECT AUFPL
    APLZL
    MEINH
    BMSCH
    UMREN
    UMREZ
    VGE01
    VGW01
    VGE02
    VGW02
    VGE03
    VGW03
    VGE04
    VGW04
    VGE05
    VGW05
    VGE06
    VGW06
    MGVRG
    LMNGA
    GMNGA
    ISM01
    ISM02
    ISM03
    ISM04
    ISM05
    ISM06
    SSAVD
    FROM AFVV INTO TABLE I_AFVV
    FOR ALL ENTRIES IN I_AFVC
    WHERE AUFPL = I_AFVC-AUFPL
    AND APLZL = I_AFVC-APLZL
    AND SSAVD IN S_DATUV.
    IF SY-SUBRC = 0.
      SORT I_AFVV BY AUFPL APLZL.
    ENDIF.
* select process order related work centre data
    SELECT OBJTY
    OBJID
    KOKRS
    KOSTL
    LSTAR
    FROM CRCO
    INTO TABLE I_CRCO
    FOR ALL ENTRIES IN I_AFVC
    WHERE OBJTY = C_OBJTYP
    AND OBJID = I_AFVC-ARBID
    AND KOSTL IN S_KOSTL.
    IF SY-SUBRC = 0.
      SORT I_CRCO BY OBJTY OBJID KOSTL.
    ENDIF.
* Retrieve work center details
    SELECT OBJID
    ARBPL
    VGWTS
    FROM CRHD
    APPENDING TABLE I_CRHD
    FOR ALL ENTRIES IN I_AFVC
    WHERE OBJTY = C_OBJTYP
    AND OBJID = I_AFVC-ARBID
    AND WERKS = P_WERKS
    AND ARBPL IN S_ARBPL.
    SORT I_CRHD BY OBJID.
    SORT I_ORDERS BY AUFPL.
    SORT I_AFVC BY AUFPL VORNR DESCENDING.
    LOOP AT I_AFVC INTO WA_AFVC.
      L_TABIX = SY-TABIX.
*** link PrO number to phase through the routing number
      CLEAR : WA_ORDERS.
      READ TABLE I_ORDERS INTO WA_ORDERS WITH KEY AUFPL = WA_AFVC-AUFPL.
      IF SY-SUBRC = 0.
        WA_AFVC-AUFNR = WA_ORDERS-AUFNR.
        MODIFY I_AFVC FROM WA_AFVC INDEX L_TABIX TRANSPORTING AUFNR.
*** check cost centre of phase
        IF NOT ( S_KOSTL[] IS INITIAL ).
          READ TABLE I_CRCO INTO WA_CRCO WITH KEY OBJTY = C_OBJTYP
          OBJID = WA_AFVC-ARBID
          BINARY SEARCH.
          IF SY-SUBRC = 0.
*** see if cost centre of phase is valid
            READ TABLE I_CSKS INTO WA_CSKS
            WITH KEY KOSTL = WA_CRCO-KOSTL.
            IF SY-SUBRC <> 0.
*** delete invalid phases
              DELETE I_AFVV WHERE AUFPL = WA_AFVC-AUFPL
              AND APLZL = WA_AFVC-APLZL.
              DELETE I_AFVC INDEX L_TABIX.
              CONTINUE.
            ENDIF.
          ENDIF.
        ENDIF.
*** Check work centre details with resource
        IF NOT ( S_ARBPL[] IS INITIAL ).
          READ TABLE I_CRHD INTO WA_CRHD
          WITH KEY OBJID = WA_AFVC-ARBID.
          IF SY-SUBRC <> 0.
            DELETE I_AFVV WHERE AUFPL = WA_AFVC-AUFPL
            AND APLZL = WA_AFVC-APLZL.
            DELETE I_AFVC INDEX L_TABIX.
            CONTINUE.
          ENDIF.
        ENDIF.
        CLEAR: WA_CRCO, WA_CRHD, L_TABIX.
      ELSE.
*** if routing number is not linked to any valid order
*** delete phase
        DELETE I_AFVC INDEX L_TABIX.
      ENDIF.
    ENDLOOP.
  ENDIF.
* Begin of MOD-002++
  LOOP AT I_ORDERS INTO WA_ORDERS.
    CLEAR: WA_AFVC, L_TABIX.
    L_TABIX = SY-TABIX.
    READ TABLE I_AFVC INTO WA_AFVC WITH KEY AUFPL = WA_ORDERS-AUFPL.
    IF SY-SUBRC NE 0.
      DELETE I_ORDERS INDEX L_TABIX.
    ENDIF.
  ENDLOOP.
* End of MOD-002++
ENDFORM. " get_operations
*&--------------------------------------------------------------------*
*& Form get_order_mats
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM GET_ORDER_MATS.
  DATA : L_V_ERFME TYPE ERFME,
  L_V_CHEC TYPE CHAR1,
  L_BWART TYPE BWART.
* get materials issued/receipt against order
  SELECT AUFNR AUFPL APLZL MATNR MBLNR MJAHR ZEILE BWART
  WERKS LGORT CHARG
  MENGE MEINS ERFMG ERFME
  RSNUM RSPOS RSART
  FROM AUFM
  INTO TABLE I_MSEG1
  FOR ALL ENTRIES IN I_ORDERS
  WHERE AUFNR = I_ORDERS-AUFNR.
  IF SY-SUBRC = 0.
*** get base UoM for all materials
    CLEAR: I_MARA.
    SELECT MATNR
    MTART
    MEINS
    GEWEI
    NTGEW
    FROM MARA
    APPENDING TABLE I_MARA
    FOR ALL ENTRIES IN I_MSEG1
    WHERE MATNR = I_MSEG1-MATNR.
    SORT I_MSEG1 BY AUFNR AUFPL APLZL MATNR.
*** get material qty in base UoM and summarize material data
    LOOP AT I_MSEG1 INTO WA_MSEG.
      CLEAR : WA_MARA.
*** read material master for base UoM
      READ TABLE I_MARA INTO WA_MARA WITH KEY MATNR = WA_MSEG-MATNR.
      IF SY-SUBRC = 0.
        IF WA_MSEG-MEINS <> WA_MARA-MEINS.
          CLEAR : WA_MSEG-BMENGE.
*** convert GR quant into base units
          PERFORM CONV_TO_FROM_BASE USING 'X'
          WA_MSEG-MATNR
          WA_MSEG-MENGE
          WA_MSEG-MEINS
          WA_MARA-MEINS
          CHANGING WA_MSEG-BMENGE
          V_CONV_RC.
        ELSE.
          WA_MSEG-BMENGE = WA_MSEG-MENGE.
        ENDIF.
        WA_MSEG-BMEINS = WA_MARA-MEINS.
        WA_MSEG-GEWEI = WA_MARA-GEWEI.
        WA_MSEG-NTGEW = WA_MARA-NTGEW.
        MODIFY I_MSEG1 FROM WA_MSEG TRANSPORTING BMENGE BMEINS.
      ENDIF.
      WA_MSEGS-AUFNR = WA_MSEG-AUFNR.
      WA_MSEGS-AUFPL = WA_MSEG-AUFPL.
      WA_MSEGS-APLZL = WA_MSEG-APLZL.
      WA_MSEGS-MATNR = WA_MSEG-MATNR.
      WA_MSEGS-MEINS = WA_MSEG-MEINS.
      WA_MSEGS-BMEINS = WA_MSEG-BMEINS.
      WA_MSEGS-GEWEI = WA_MSEG-GEWEI.
* Begin of MOD-002++
      IF ( WA_MSEG-BWART <> 'ZU1' ) AND ( WA_MSEG-BWART <> 'ZU2' ).
        WA_MSEGS-ERFME = WA_MSEG-ERFME.
      ENDIF.
* End of MOD-002++
      AT NEW MATNR.
        L_V_ERFME = WA_MSEGS-ERFME.
        CLEAR : L_V_CHEC.
      ENDAT.
      IF L_V_ERFME <> WA_MSEG-ERFME.
*** set flag if different GR mvts have diff. GR UoM
        L_V_CHEC = C_X.
      ENDIF.
*** Sum up material qtys based on movement
      CASE WA_MSEG-BWART.
        WHEN '101'.
*** GR of material
          WA_MSEGS-BMENGE1 = WA_MSEGS-BMENGE1 + WA_MSEG-BMENGE.
          WA_MSEGS-ERFMG1 = WA_MSEGS-ERFMG1 + WA_MSEG-ERFMG.
          WA_MSEGS-ERFME = WA_MSEG-ERFME.
          L_BWART = '101'.                                  "23-05-2005
        WHEN '261'.
*** Consumption of material
          WA_MSEGS-BMENGE2 = WA_MSEGS-BMENGE2 + WA_MSEG-BMENGE.
          WA_MSEGS-ERFMG2 = WA_MSEGS-ERFMG2 + WA_MSEG-ERFMG.
          L_BWART = '261'.                                  "23-05-2005
        WHEN '532'.
*** reversal of 531
          WA_MSEGS-BMENGE5 = WA_MSEGS-BMENGE5 + WA_MSEG-BMENGE.
          WA_MSEGS-ERFMG5 = WA_MSEGS-ERFMG5 + WA_MSEG-ERFMG.
        WHEN '102'.
*** reversal of 101
          WA_MSEGS-BMENGE1 = WA_MSEGS-BMENGE1 - WA_MSEG-BMENGE.
          WA_MSEGS-ERFMG1 = WA_MSEGS-ERFMG1 + WA_MSEG-ERFMG.
        WHEN '262'.
*** reversal of 261
          WA_MSEGS-BMENGE2 = WA_MSEGS-BMENGE2 - WA_MSEG-BMENGE.
          WA_MSEGS-ERFMG2 = WA_MSEGS-ERFMG2 + WA_MSEG-ERFMG.
        WHEN '531'.
*** By-product material mvt
          WA_MSEGS-BMENGE5 = WA_MSEGS-BMENGE5 - WA_MSEG-BMENGE.
          WA_MSEGS-ERFMG5 = WA_MSEGS-ERFMG5 + WA_MSEG-ERFMG.
          L_BWART = '531'.                                  "23-05-2005
      ENDCASE.
*** If the diff. GR qtys have different UoM then do not cumulate
*** actual qty values
      IF L_V_CHEC = C_X.
        CLEAR : WA_MSEGS-ERFMG1, WA_MSEGS-ERFMG2 , WA_MSEGS-ERFMG5.
      ENDIF.
      AT END OF MATNR.
        WA_MSEGS-BMENGE = WA_MSEGS-BMENGE1 + WA_MSEGS-BMENGE2 +
        WA_MSEGS-BMENGE5.
        WA_MSEGS-ERFMG = WA_MSEGS-ERFMG1 + WA_MSEGS-ERFMG2 +
        WA_MSEGS-ERFMG5.
        WA_MSEGS-BWART = L_BWART .
        APPEND WA_MSEGS TO I_MSEGS.
        CLEAR : WA_MSEGS,
        L_BWART.
      ENDAT.
    ENDLOOP.
  ENDIF.
ENDFORM. "get_order_mats
*&---------------------------------------------------------------------*
*& Form get_mat_segment
*&---------------------------------------------------------------------*
FORM GET_MAT_SEGMENT.
  DATA: L_TABIX TYPE SYTABIX.
  FIELD-SYMBOLS : <L_FS_ORDERS> TYPE TY_ORDERS,
  <L_FS_AFVC> TYPE TY_AFVC.
  IF NOT ( I_ORDERS[] IS INITIAL ).
*** get material master data for PO materials
    CLEAR: I_MARA , I_MSEG , I_MSEG1 , I_MSEGS , I_MSEGS1.
    SELECT MATNR
    MTART
    MEINS
    GEWEI
    NTGEW
    FROM MARA
    INTO TABLE I_MARA
    FOR ALL ENTRIES IN I_ORDERS
    WHERE MATNR = I_ORDERS-PLNBEZ.
    IF NOT ( RB_PROD IS INITIAL ).
*** Tell user we are Extracting goods receipt information
      MOVE 'Extracting Goods Receipt Information'(024) TO V_OUTPUT_TEXT.
      PERFORM INFORM_USER_OF_PROGRESS.
*** get the materials to process
      PERFORM GET_ORDER_MATS.
*** create alternate working tables for mat. mvts
      I_MSEG = I_MSEG1.
      I_MSEGS1 = I_MSEGS.
*** retain only order material in internal table and get order qty in
*** base UoM
      LOOP AT I_ORDERS ASSIGNING <L_FS_ORDERS>.
*** retain mat. mvts only for the main material of the PrO
        DELETE I_MSEG WHERE AUFNR = <L_FS_ORDERS>-AUFNR
        AND MATNR <> <L_FS_ORDERS>-PLNBEZ.
        DELETE I_MSEGS1 WHERE AUFNR = <L_FS_ORDERS>-AUFNR
        AND MATNR <> <L_FS_ORDERS>-PLNBEZ.
*** read material master for base UoM of material
        CLEAR : WA_MARA.
        READ TABLE I_MARA INTO WA_MARA
        WITH KEY MATNR = <L_FS_ORDERS>-PLNBEZ.
        IF SY-SUBRC = 0.
          IF WA_MARA-MEINS <> <L_FS_ORDERS>-GMEIN.
*** convert order quantity to base UoM
            PERFORM CONV_TO_FROM_BASE USING 'X'
            <L_FS_ORDERS>-PLNBEZ
            <L_FS_ORDERS>-GAMNG
            <L_FS_ORDERS>-GMEIN
            WA_MARA-MEINS
            CHANGING <L_FS_ORDERS>-BGAMNG
            V_CONV_RC.
          ELSE.
            <L_FS_ORDERS>-BGAMNG = WA_ORDERS-GAMNG.
          ENDIF.
          <L_FS_ORDERS>-BSUOM = WA_MARA-MEINS.
          <L_FS_ORDERS>-GEWEI = WA_MARA-GEWEI.
          <L_FS_ORDERS>-NTGEW = WA_MARA-NTGEW.
        ENDIF.
      ENDLOOP.
      SORT I_MSEG BY AUFNR.
      SORT I_MSEGS1 BY AUFNR.
      SORT I_ORDERS BY AUFNR.
*** Calculatin the quantity according to the movement type and
*** assign the value to i_orders internal table
      LOOP AT I_ORDERS ASSIGNING <L_FS_ORDERS>.
        CLEAR : WA_MSEGS.
        READ TABLE I_MSEGS1 INTO WA_MSEGS
        WITH KEY AUFNR = <L_FS_ORDERS>-AUFNR
        MATNR = <L_FS_ORDERS>-PLNBEZ.
        IF RB_EZERO EQ C_X AND WA_MSEGS-BMENGE1 = 0.
*** Don't want zero production orders
          DELETE I_AFVC WHERE AUFNR = <L_FS_ORDERS>-AUFNR.
* DELETE i_orders WHERE aufnr = <l_fs_orders>-aufnr.
          CONTINUE.
        ENDIF.
        <L_FS_ORDERS>-ERFMG = WA_MSEGS-ERFMG1.
        <L_FS_ORDERS>-BMENGE = WA_MSEGS-BMENGE1.
        <L_FS_ORDERS>-GRUOM = WA_MSEGS-ERFME.
      ENDLOOP.
    ELSE.
*** Here we're Extracting confirmation information
      MOVE 'Extracting Confirmation Information'(025) TO V_OUTPUT_TEXT.
      PERFORM INFORM_USER_OF_PROGRESS.
*** get order qty in base UoM and get base UoM and weight UoM
      LOOP AT I_ORDERS ASSIGNING <L_FS_ORDERS>.
        CLEAR : WA_MARA.
        READ TABLE I_MARA INTO WA_MARA
        WITH KEY MATNR = <L_FS_ORDERS>-PLNBEZ.
        IF SY-SUBRC = 0.
          IF WA_MARA-MEINS <> WA_ORDERS-GMEIN.
*** convert order quantity to base UoM
            PERFORM CONV_TO_FROM_BASE USING 'X'
            <L_FS_ORDERS>-PLNBEZ
            <L_FS_ORDERS>-GAMNG
            <L_FS_ORDERS>-GMEIN
            WA_MARA-MEINS
            CHANGING <L_FS_ORDERS>-BGAMNG
            V_CONV_RC.
          ELSE.
            <L_FS_ORDERS>-BGAMNG = <L_FS_ORDERS>-GAMNG.
          ENDIF.
          <L_FS_ORDERS>-BSUOM = WA_MARA-MEINS.
          <L_FS_ORDERS>-GEWEI = WA_MARA-GEWEI.
          <L_FS_ORDERS>-NTGEW = WA_MARA-NTGEW.
        ENDIF.
      ENDLOOP.
*** Select confirmations using operation confirmation number instead of
*** order number
      CLEAR : I_AFVV1 , I_AFVC1 , I_AFRU , I_AFRU1.
*** get 'bottleneck' phases
      LOOP AT I_AFVC INTO WA_AFVC WHERE STEUS = 'YBN1'
      AND PHFLG = C_X.
        APPEND WA_AFVC TO I_AFVC1.
*** get 'bottleneck' phase values
        LOOP AT I_AFVV INTO WA_AFVV WHERE AUFPL = WA_AFVC-AUFPL
        AND APLZL = WA_AFVC-APLZL.
          APPEND WA_AFVV TO I_AFVV1.
        ENDLOOP.
      ENDLOOP.
      IF NOT I_AFVC1 IS INITIAL.
        SORT I_AFVC1 BY AUFPL APLZL PLNKN PLNTY PLNNR.
*** get confirmations for the various phases
        SELECT AUFNR
        RUECK
        GMNGA
        LMNGA
        GMEIN
        MEINH
        MEILR
        STOKZ
        RUECK_MST
        AUFPL
        APLZL
        INTO TABLE I_AFRU
        FROM AFRU
        FOR ALL ENTRIES IN I_AFVC
        WHERE RUECK = I_AFVC-RUECK
        AND WERKS = P_WERKS
        AND AUFPL = I_AFVC-AUFPL
        AND APLZL = I_AFVC-APLZL.
        SORT I_AFRU BY AUFNR RUECK AUFPL APLZL.
        LOOP AT I_AFVC1 INTO WA_AFVC.
          LOOP AT I_AFRU INTO WA_AFRU
          WHERE AUFNR = WA_AFVC-AUFNR
          AND RUECK = WA_AFVC-RUECK
          AND AUFPL = WA_AFVC-AUFPL
          AND APLZL = WA_AFVC-APLZL.
*** get 'bottleneck' related confirmations
            APPEND WA_AFRU TO I_AFRU1.
          ENDLOOP.
        ENDLOOP.
        IF NOT I_AFVV1 IS INITIAL.
          SORT I_AFVV1 BY AUFPL APLZL.
*** get total confirmation on order for 'bottleneck' phases,
*** this will be the confirmed qty for whole order
          LOOP AT I_AFVC ASSIGNING <L_FS_AFVC>.
            WA_AFVC = <L_FS_AFVC>.
*** ensuring the phase is related to a valid PrO
            CLEAR : WA_ORDERS.
            READ TABLE I_ORDERS INTO WA_ORDERS
            WITH KEY AUFNR = WA_AFVC-AUFNR.
            IF SY-SUBRC = 0.
*** is it a bottleneck phase?
              READ TABLE I_AFVC1 INTO WA_AFVC1
              WITH KEY AUFPL = WA_ORDERS-AUFPL
              PLNTY = WA_AFVC-PLNTY
              PLNNR = WA_AFVC-PLNNR
              PLNKN = WA_AFVC-PLNKN
              ZAEHL = WA_AFVC-ZAEHL.
              IF SY-SUBRC = 0.
*** get phase operation values
                READ TABLE I_AFVV1 INTO WA_AFVV1
                WITH KEY AUFPL = WA_AFVC1-AUFPL
                APLZL = WA_AFVC1-APLZL
                BINARY SEARCH.
                IF SY-SUBRC = 0.
*** does the phase have any std runtime m/c confirmations
                  CHECK WA_AFVV1-VGW02 NE 0.
*** get actual bottleneck phase confirmations
                  PERFORM GET_CONFIRMATION_QTY_NEW
                  USING WA_ORDERS-AUFNR
                  WA_AFVC1-RUECK
                  WA_AFVC1-AUFPL
                  WA_AFVC1-APLZL
                  CHANGING
                  WA_AFVC-LMNGA
                  WA_AFVC-CFUOM.
*** save confirmation values against phase
                  <L_FS_AFVC>-LMNGA = WA_AFVC-LMNGA.
                  <L_FS_AFVC>-CFUOM = WA_AFVC-CFUOM.
                ENDIF.
              ENDIF.
            ENDIF.
          ENDLOOP.
        ENDIF.
      ENDIF.
*** retain only bottleneck related confirmation phases,
*** as this gives confirmation qty for order
      I_AFVC2 = I_AFVC.
* IF rb_ezero = c_x.
**** no zero confirmation qty phases wanted
* DELETE i_afvc2 WHERE lmnga EQ 0.
* ENDIF.
      DELETE ADJACENT DUPLICATES FROM I_AFVC2
      COMPARING AUFNR
      AUFPL
      APLZL
      PLNKN
      PLNTY
      PLNNR
      ZAEHL
      VORNR.
*** get order qty in base UoM and get base UoM and weight UoM
      LOOP AT I_ORDERS ASSIGNING <L_FS_ORDERS>.
*** get confirmed qty
        READ TABLE I_AFVC2 INTO WA_AFVC
        WITH KEY AUFNR = <L_FS_ORDERS>-AUFNR.
        IF SY-SUBRC = 0.
          <L_FS_ORDERS>-LMNGA = WA_AFVC-LMNGA.
          <L_FS_ORDERS>-CFUOM = WA_AFVC-CFUOM.
          IF <L_FS_ORDERS>-CFUOM <> <L_FS_ORDERS>-BSUOM.
*** convert confirmation quantity to base UoM
            PERFORM CONV_TO_FROM_BASE USING 'X'
            <L_FS_ORDERS>-PLNBEZ
            <L_FS_ORDERS>-LMNGA
            <L_FS_ORDERS>-CFUOM
            <L_FS_ORDERS>-BSUOM
            CHANGING <L_FS_ORDERS>-BLMNGA
            V_CONV_RC.
          ELSE.
            <L_FS_ORDERS>-BLMNGA = <L_FS_ORDERS>-LMNGA.
          ENDIF.
        ELSE.
*** if the order has no confirmed qty against it, remove it
*** from further processing
          <L_FS_ORDERS>-DEL = C_X.
        ENDIF.
      ENDLOOP.
* DELETE i_orders WHERE del = c_x.
    ENDIF.
  ENDIF.
ENDFORM. " get_mat_segment
*&---------------------------------------------------------------------*
*& Form get_confirmation_qty_new
*&---------------------------------------------------------------------*
FORM GET_CONFIRMATION_QTY_NEW USING FP_AUFNR TYPE AUFNR
FP_RUECK TYPE CO_RUECK
FP_AUFPL TYPE CO_AUFPL
FP_APLZL TYPE CO_APLZL
CHANGING FP_LMNGA TYPE RU_LMNGA
FP_CFUOM TYPE MEINS.
  DATA: LAST_LMNGA TYPE RU_LMNGA,
  LAST_LMNGA1 TYPE RU_LMNGA,
  LAST_LMNGA2 TYPE RU_LMNGA,
  L_V_MEINH TYPE RU_VORME.
  CLEAR: LAST_LMNGA.
* Check this record. If there is no link to another confirmation and
* a quantity has been confirmed and it is a milestone confirmation
* then we want to select all of the confirmations for it.
  LOOP AT I_AFRU1 INTO WA_AFRU1 WHERE AUFNR = FP_AUFNR
  AND RUECK = FP_RUECK
  AND AUFPL = FP_AUFPL
  AND APLZL = FP_APLZL.
    CHECK WA_AFRU1-LMNGA NE 0.
    IF L_V_MEINH IS INITIAL.
      L_V_MEINH = WA_AFRU1-MEINH.
    ENDIF.
    LAST_LMNGA1 = WA_AFRU1-LMNGA.
    IF L_V_MEINH <> WA_AFRU1-MEINH.
      CLEAR : LAST_LMNGA2.
      PERFORM CONV_TO_FROM_BASE USING 'X'
      WA_ORDERS-PLNBEZ
      WA_AFRU1-LMNGA
      WA_AFRU1-MEINH
      WA_ORDERS-BSUOM
      CHANGING LAST_LMNGA2
      V_CONV_RC.
      PERFORM CONV_TO_FROM_BASE USING ' '
      WA_ORDERS-PLNBEZ
      LAST_LMNGA2
      L_V_MEINH
      WA_ORDERS-BSUOM
      CHANGING LAST_LMNGA1
      V_CONV_RC.
    ENDIF.
    IF WA_AFRU1-STOKZ IS INITIAL.
      LAST_LMNGA = LAST_LMNGA + LAST_LMNGA1.
    ELSE.
      LAST_LMNGA = LAST_LMNGA - LAST_LMNGA1.
    ENDIF.
  ENDLOOP.
  MOVE LAST_LMNGA TO FP_LMNGA.
  FP_CFUOM = L_V_MEINH.
ENDFORM. " get_confirmation_qty_new
*&---------------------------------------------------------------------*
*& Form get_bom_info
*&---------------------------------------------------------------------*
FORM GET_BOM_INFO.
  DATA: L_TABIX TYPE SYTABIX,
  L_V_KAUSF TYPE KAUSF,
  L_V_DMENG TYPE TY_MENGE,
  L_V_DMENGS TYPE TY_MENGE,
  L_V_DMENGZ TYPE TY_MENGE,
  L_V_MENGE TYPE KMPMG,
  L_V_MNGLG TYPE CS_E_MNGLG,
  L_V_MNGLGS TYPE CS_E_MNGLG,
  L_V_MNGLGZ TYPE CS_E_MNGLG,
  L_I_BOMAPP TYPE STANDARD TABLE OF TY_BOMAPP,
  L_WA_BOMAPP TYPE TY_BOMAPP,
  L_IDX TYPE TTIDX. "NEEL 4/6/2005
  FIELD-SYMBOLS : <L_FS_ORDERS> TYPE TY_ORDERS,
  <L_FS_ORDMATS> TYPE TY_ORDMATS.
  IF NOT I_ORDERS[] IS INITIAL.
* this tells users whats happening
    MOVE 'Extracting BOM Information'(026) TO V_OUTPUT_TEXT.
    PERFORM INFORM_USER_OF_PROGRESS.
* Get order related bom appln
    CLEAR : L_I_BOMAPP.
    SELECT WERKS
    AUART
    CAPID
    FROM T399X
    INTO TABLE L_I_BOMAPP
    FOR ALL ENTRIES IN I_ORDERS
    WHERE WERKS = I_ORDERS-WERKS
    AND AUART = I_ORDERS-AUART.
    SORT L_I_BOMAPP BY WERKS AUART.
* Get issued materials for all process orders
    IF I_MSEG1 IS INITIAL.
* get materials to process
      PERFORM GET_ORDER_MATS.
      I_MSEG = I_MSEG1.
      I_MSEGS1 = I_MSEGS.
    ENDIF.
    LOOP AT I_ORDERS ASSIGNING <L_FS_ORDERS>.
      DELETE I_MSEG WHERE AUFNR = <L_FS_ORDERS>-AUFNR
      AND MATNR <> <L_FS_ORDERS>-PLNBEZ.
      DELETE I_MSEGS1 WHERE AUFNR = <L_FS_ORDERS>-AUFNR
      AND MATNR <> <L_FS_ORDERS>-PLNBEZ.
      CLEAR : L_WA_BOMAPP.
*** Assign a default in case read fails
      L_WA_BOMAPP-CAPID = 'PI01'.
      READ TABLE L_I_BOMAPP INTO L_WA_BOMAPP
      WITH KEY WERKS = <L_FS_ORDERS>-WERKS
      AUART = <L_FS_ORDERS>-AUART
      BINARY SEARCH.
*** Get BOM application id
      <L_FS_ORDERS>-CAPID = L_WA_BOMAPP-CAPID.
*** Get list of materials that have been issued
      LOOP AT I_MSEG1 INTO WA_ISSUED_MAT
      WHERE AUFNR = <L_FS_ORDERS>-AUFNR
      AND BWART IN I_R_BWART.
        APPEND WA_ISSUED_MAT TO I_ISSUED_MAT.
      ENDLOOP.
    ENDLOOP.
    CLEAR : I_BOMDAT.
* do BOM explosion and get related BOM data for the materials
    LOOP AT I_ORDERS ASSIGNING <L_FS_ORDERS>.
*** build key table for later selection from table PLPO,
*** the master recipe table
      WA_PLPO_SEL-PLNTY = <L_FS_ORDERS>-PLNTY.
      WA_PLPO_SEL-PLNNR = <L_FS_ORDERS>-PLNNR.
      WA_PLPO_SEL-ZAEHL = <L_FS_ORDERS>-ZAEHL.
      APPEND WA_PLPO_SEL TO I_PLPO_SEL.
*** build key table for later selection from table AFRU,
*** the confirmations table
      WA_AFRU_SEL-RUECK = <L_FS_ORDERS>-RUECK.
      APPEND WA_AFRU_SEL TO I_AFRU_SEL.
      L_TABIX = SY-TABIX.
      CLEAR : WA_TMAT , I_STBTMP , WA_BOMDAT.
*** check if same BOM has been retrieved before
      READ TABLE I_BOMDAT INTO WA_BOMDAT
      WITH KEY CAPID = <L_FS_ORDERS>-CAPID
      DATUV = <L_FS_ORDERS>-SDATV
      MTNRV = <L_FS_ORDERS>-PLNBEZ
      STLAL = <L_FS_ORDERS>-STLAL
      STLAN = <L_FS_ORDERS>-STLAN
      WERKS = <L_FS_ORDERS>-WERKS.
      IF SY-SUBRC = 0.
*** if yes then use it
        WA_TMAT = WA_BOMDAT-TMAT.
        I_STBTMP = WA_BOMDAT-STB.
      ELSE.
*** if no then get BOM explosion
        CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'
        EXPORTING
        AUMGB = 'X'
        CAPID = <L_FS_ORDERS>-CAPID
* datuv = <l_fs_orders>-sdatv
*** Begin of change on 31-05-2005
        DATUV = <L_FS_ORDERS>-AUFLD
        " 31-05-2005
*** End of change on 31-05-2005
        MBWLS = 'X'
        MEHRS = 'X'
        MTNRV = <L_FS_ORDERS>-PLNBEZ
        STLAL = <L_FS_ORDERS>-STLAL
        STLAN = <L_FS_ORDERS>-STLAN
        WERKS = <L_FS_ORDERS>-WERKS
        IMPORTING
        TOPMAT = WA_TMAT
        TABLES
        STB = I_STBTMP
* matcat = i_cmat
        EXCEPTIONS
        ALT_NOT_FOUND = 1
        CALL_INVALID = 2
        MATERIAL_NOT_FOUND = 3
        MISSING_AUTHORIZATION = 4
        NO_BOM_FOUND = 5
        NO_PLANT_DATA = 6
        NO_SUITABLE_BOM_FOUND = 7
        CONVERSION_ERROR = 8
        OTHERS = 9.
        IF SY-SUBRC = 0.
*** add to BOM buffer table
          WA_BOMDAT-CAPID = <L_FS_ORDERS>-CAPID.
          WA_BOMDAT-DATUV = <L_FS_ORDERS>-SDATV.
          WA_BOMDAT-MTNRV = <L_FS_ORDERS>-PLNBEZ.
          WA_BOMDAT-STLAL = <L_FS_ORDERS>-STLAL.
          WA_BOMDAT-STLAN = <L_FS_ORDERS>-STLAN.
          WA_BOMDAT-WERKS = <L_FS_ORDERS>-WERKS.
          WA_BOMDAT-TMAT = WA_TMAT.
          WA_BOMDAT-STB = I_STBTMP.
          INSERT WA_BOMDAT INTO TABLE I_BOMDAT.
          DELETE I_STBTMP WHERE SCHGT = C_X.
        ENDIF.
      ENDIF.
      IF NOT I_STBTMP IS INITIAL.
*** First get the primary level values from the exploded BOM
        LOOP AT I_STBTMP INTO WA_STB WHERE STLAL = <L_FS_ORDERS>-STLAL
        AND STLAN = <L_FS_ORDERS>-STLAN
        AND STLTY = <L_FS_ORDERS>-STLTY
        AND STLNR = <L_FS_ORDERS>-STLNR.
          CHECK WA_STB-POSTP <> 'N'.
          CLEAR : WA_ORDMATS.
          WA_ORDMATS-AUFNR = <L_FS_ORDERS>-AUFNR.
          WA_ORDMATS-MATNR = WA_STB-IDNRK.
          WA_ORDMATS-MTART = WA_STB-MTART.
          WA_ORDMATS-STUFE = WA_STB-STUFE.
*>>NEEL 4/6/2005
          WA_ORDMATS-WEGXX = WA_STB-WEGXX.
          WA_ORDMATS-TTIDX = WA_STB-TTIDX.
          WA_ORDMATS-VWEGX = WA_STB-VWEGX.
*<<NEEL 4/6/2005
          WA_ORDMATS-OJTXB = WA_STB-OJTXB.
          WA_ORDMATS-OJTXP = WA_STB-OJTXP.
          WA_ORDMATS-AUSCH = WA_STB-AUSCH.
* wa_ordmats-yyzero = wa_stb-yyzero.
          IF NOT WA_STB-AUSCH IS INITIAL.
            L_V_KAUSF = 1 + ( WA_STB-AUSCH / 100 ).
          ELSE.
            L_V_KAUSF = 1 + ( WA_STB-KAUSF / 100 ).
          ENDIF.
          WA_ORDMATS-KAUSF = L_V_KAUSF.
          WA_ORDMATS-MENGE = WA_STB-MENGE.
          WA_ORDMATS-MENGES = WA_STB-MENGE * WA_ORDMATS-KAUSF.
* wa_ordmats-mengez = wa_stb-menge * wa_ordmats-yyzero.
          WA_ORDMATS-MEINS = WA_STB-MEINS.
          WA_ORDMATS-XMENG = WA_STB-XMENG.
          WA_ORDMATS-XMENGS = WA_STB-XMENG * WA_ORDMATS-KAUSF.
* wa_ordmats-xmengz = wa_stb-xmeng * wa_ordmats-yyzero.
          WA_ORDMATS-XMEIN = WA_STB-XMEIN.
          WA_ORDMATS-MNGLG = WA_STB-MNGLG.
          WA_ORDMATS-MNGLGS = WA_STB-MNGLG.
          WA_ORDMATS-MNGLGZ = WA_STB-MNGLG.
          WA_ORDMATS-MMEIN = WA_STB-MMEIN.
          WA_ORDMATS-MSIGN = WA_STB-MSIGN.
          WA_ORDMATS-POSTP = WA_STB-POSTP.
          IF WA_STB-KZKUP = SPACE AND WA_STB-MSIGN = '-'.
            WA_ORDMATS-BYPROD = C_X.
          ENDIF.
          WA_ORDMATS-STPRS = WA_STB-STPRS.
          WA_ORDMATS-PEINH = WA_STB-PREIH.
          WA_ORDMATS-BOM = C_X.
          WA_ORDMATS-STLTY = WA_STB-STLTY.
          WA_ORDMATS-STLNR = WA_STB-STLNR.
          WA_ORDMATS-STLKN = WA_STB-STLKN.
          WA_ORDMATS-STPOZ = WA_STB-STPOZ.
          APPEND WA_ORDMATS TO I_ORDMATS.
        ENDLOOP.
*** now recurse into exploded BOM to get lower level details
        LOOP AT I_ORDMATS ASSIGNING <L_FS_ORDMATS> WHERE BOMD <> C_X.
          IF <L_FS_ORDMATS>-XMENG > 0.
            L_V_DMENG = <L_FS_ORDMATS>-MENGE / <L_FS_ORDMATS>-XMENG.
            L_V_DMENGS = <L_FS_ORDMATS>-MENGES / <L_FS_ORDMATS>-XMENG.
            L_V_DMENGZ = <L_FS_ORDMATS>-MENGEZ / <L_FS_ORDMATS>-XMENG.
          ELSE.
            L_V_DMENG = 1.
            L_V_DMENGS = 1.
            L_V_DMENGZ = 1.
          ENDIF.
          L_IDX = <L_FS_ORDMATS>-STUFE + 1. "NEEL 4/6/2005++
          LOOP AT I_STBTMP INTO WA_STB
* WHERE ojtxb = <l_fs_ordmats>ojtxp. NEEL-
          WHERE TTIDX = L_IDX "NEEL 4/6/2005
          AND VWEGX = <L_FS_ORDMATS>-WEGXX.
            CLEAR : WA_ORDMATS.
            WA_ORDMATS-AUFNR = <L_FS_ORDERS>-AUFNR.
            WA_ORDMATS-MATNR = WA_STB-IDNRK.
            WA_ORDMATS-MTART = WA_STB-MTART.
            WA_ORDMATS-STUFE = WA_STB-STUFE.
*>>NEEL 4/6/2005
            WA_ORDMATS-WEGXX = WA_STB-WEGXX.
            WA_ORDMATS-TTIDX = WA_STB-TTIDX.
            WA_ORDMATS-VWEGX = WA_STB-VWEGX.
*<<NEEL 4/6/2005
            WA_ORDMATS-OJTXB = WA_STB-OJTXB.
            WA_ORDMATS-OJTXP = WA_STB-OJTXP.
            WA_ORDMATS-AUSCH = WA_STB-AUSCH.
* wa_ordmats-yyzero = wa_stb-yyzero.
            IF NOT WA_STB-AUSCH IS INITIAL.
              L_V_KAUSF = 1 + ( WA_STB-AUSCH / 100 ).
            ELSE.
              L_V_KAUSF = 1 + ( WA_STB-KAUSF / 100 ).
            ENDIF.
            WA_ORDMATS-KAUSF = L_V_KAUSF.
            L_V_MENGE = WA_STB-MENGE * L_V_DMENGS.
            WA_ORDMATS-MENGES = L_V_MENGE * WA_ORDMATS-KAUSF.
            L_V_MENGE = WA_STB-MENGE * L_V_DMENGZ.
* wa_ordmats-mengez = l_v_menge * wa_ordmats-yyzero.
            L_V_MENGE = WA_STB-MENGE * L_V_DMENG.
            WA_ORDMATS-MENGE = L_V_MENGE.
            WA_ORDMATS-MEINS = WA_STB-MEINS.
            L_V_MNGLG = WA_ORDMATS-MENGE.
            L_V_MNGLGS = WA_ORDMATS-MENGES.
            L_V_MNGLGZ = WA_ORDMATS-MENGEZ.
            IF WA_STB-MEINS = WA_STB-MMEIN.
              WA_ORDMATS-MNGLG = L_V_MNGLG.
              WA_ORDMATS-MNGLGS = L_V_MNGLGS.
              WA_ORDMATS-MNGLGZ = L_V_MNGLGZ.
            ELSE.
* convert BOM quantity to base UoM
              PERFORM CONV_TO_FROM_BASE USING 'X'
              WA_ORDMATS-MATNR
              L_V_MNGLG
              WA_ORDMATS-MEINS
              WA_ORDMATS-MMEIN
              CHANGING WA_ORDMATS-MNGLG
              V_CONV_RC.
              PERFORM CONV_TO_FROM_BASE USING 'X'
              WA_ORDMATS-MATNR
              L_V_MNGLGS
              WA_ORDMATS-MEINS
              WA_ORDMATS-MMEIN
              CHANGING WA_ORDMATS-MNGLGS
              V_CONV_RC.
              PERFORM CONV_TO_FROM_BASE USING 'X'
              WA_ORDMATS-MATNR
              L_V_MNGLGZ
              WA_ORDMATS-MEINS
              WA_ORDMATS-MMEIN
              CHANGING WA_ORDMATS-MNGLGZ
              V_CONV_RC.
            ENDIF.
            WA_ORDMATS-MMEIN = WA_STB-MMEIN.
            WA_ORDMATS-MSIGN = WA_STB-MSIGN.
            WA_ORDMATS-XMENG = WA_STB-XMENG.
            WA_ORDMATS-XMENGS = WA_STB-XMENG * WA_ORDMATS-KAUSF.
* wa_ordmats-xmengz = wa_stb-xmeng * wa_ordmats-yyzero.
            WA_ORDMATS-XMEIN = WA_STB-XMEIN.
            WA_ORDMATS-STPRS = WA_STB-STPRS.
            WA_ORDMATS-PEINH = WA_STB-PREIH.
* wa_ordmats-yyzero = wa_stb-yyzero.
            WA_ORDMATS-BOM = C_X.
            WA_ORDMATS-STLTY = WA_STB-STLTY.
            WA_ORDMATS-STLNR = WA_STB-STLNR.
            WA_ORDMATS-STLKN = WA_STB-STLKN.
            WA_ORDMATS-STPOZ = WA_STB-STPOZ.
            APPEND WA_ORDMATS TO I_ORDMATS.
          ENDLOOP.
          <L_FS_ORDMATS>-BOMD = C_X.
        ENDLOOP.
        <L_FS_ORDERS>-MAKTX = WA_TMAT-MAKTX.
        <L_FS_ORDERS>-BMENG = WA_TMAT-BMENG.
        <L_FS_ORDERS>-BMEIN = WA_TMAT-BMEIN.
        <L_FS_ORDERS>-KAUSF = WA_TMAT-KAUSF.
        IF <L_FS_ORDERS>-BMEIN <> <L_FS_ORDERS>-BSUOM.
* convert BOM base quantity to base UoM
          PERFORM CONV_TO_FROM_BASE USING 'X'
          <L_FS_ORDERS>-PLNBEZ
          <L_FS_ORDERS>-BMENG
          <L_FS_ORDERS>-BMEIN
          <L_FS_ORDERS>-BSUOM
          CHANGING <L_FS_ORDERS>-BBMENG
          V_CONV_RC.
        ELSE.
          <L_FS_ORDERS>-BBMENG = <L_FS_ORDERS>-BMENG.
        ENDIF.
      ENDIF.
    ENDLOOP.
    SORT I_ORDMATS BY AUFNR MATNR.
* Selecting reservations for order
    SELECT RSNUM RSPOS RSART XLOEK MATNR WERKS BDMNG MEINS SHKZG
    AUFNR DUMPS AUFPL VORNR APLZL
    POSTP KZKUP RGEKZ AUSCH
    STLTY STLNR STLKN STPOZ BWART
    FROM RESB INTO TABLE I_RESB
    FOR ALL ENTRIES IN I_ORDERS
    WHERE RSNUM = I_ORDERS-RSNUM
* AND xloek = ' '
    AND AUFNR = I_ORDERS-AUFNR
    AND BDMNG > 0
    AND DUMPS = SPACE
    AND POSTP <> 'N'
    AND SCHGT = SPACE.
    LOOP AT I_RESB INTO WA_RESB.
      READ TABLE I_ISSUED_MAT INTO WA_ISSUED_MAT
      WITH KEY MATNR = WA_RESB-MATNR.
      CHECK SY-SUBRC <> 0.
*** If a material was issued but is not part of the PrO
*** reservations, add it to list
      CLEAR : WA_ISSUED_MAT.
      WA_ISSUED_MAT-MATNR = WA_RESB-MATNR.
      WA_ISSUED_MAT-WERKS = WA_RESB-WERKS.
      APPEND WA_ISSUED_MAT TO I_ISSUED_MAT.
    ENDLOOP.
* we just need the issued mat numbers not captured by BOM explosion
    SORT I_ISSUED_MAT BY MATNR.
    DELETE ADJACENT DUPLICATES FROM I_ISSUED_MAT COMPARING MATNR.
    IF NOT I_ISSUED_MAT IS INITIAL.
* get material master data
      SELECT MATNR
      MTART
      MEINS
      GEWEI
      FROM MARA
      APPENDING TABLE I_MARA
      FOR ALL ENTRIES IN I_ISSUED_MAT
      WHERE MATNR = I_ISSUED_MAT-MATNR.
* getting pricing data
      CLEAR : I_MBEW1 , I_MATERIAL_DES.
      SELECT MATNR BWKEY STPRS PEINH
      FROM MBEW
      INTO TABLE I_MBEW1
      FOR ALL ENTRIES IN I_ISSUED_MAT
      WHERE MATNR = I_ISSUED_MAT-MATNR
      AND BWKEY = I_ISSUED_MAT-WERKS.
* Selecting material descriptions
      SELECT MATNR MAKTX
      FROM MAKT
      INTO TABLE I_MATERIAL_DES
      FOR ALL ENTRIES IN I_ISSUED_MAT
      WHERE SPRAS = SY-LANGU
      AND MATNR = I_ISSUED_MAT-MATNR.
    ENDIF.
* prepare selection table for selecting from AFRU
    LOOP AT I_AFVC INTO WA_AFVC.
      WA_PLPO_SEL-PLNTY = WA_AFVC-PLNTY.
      WA_PLPO_SEL-PLNNR = WA_AFVC-PLNNR.
      WA_PLPO_SEL-PLNKN = WA_AFVC-PLNKN.
      WA_PLPO_SEL-ZAEHL = WA_AFVC-ZAEHL.
      APPEND WA_PLPO_SEL TO I_PLPO_SEL.
      WA_AFRU_SEL-RUECK = WA_AFVC-RUECK.
      APPEND WA_AFRU_SEL TO I_AFRU_SEL.
    ENDLOOP.
    SORT : I_PLPO_SEL , I_AFRU_SEL.
    DELETE ADJACENT DUPLICATES FROM I_PLPO_SEL.
    DELETE ADJACENT DUPLICATES FROM I_AFRU_SEL.
* Retrieve task list information of operations/activity from PLPO table
    SELECT *
    FROM PLPO
    INTO TABLE I_PLPO
    FOR ALL ENTRIES IN I_PLPO_SEL
    WHERE PLNTY = I_PLPO_SEL-PLNTY
    AND PLNNR = I_PLPO_SEL-PLNNR
    AND ZAEHL = I_PLPO_SEL-ZAEHL.
    IF SY-SUBRC = 0.
      SORT I_PLPO BY PLNTY PLNNR PLNKN DATUV DESCENDING.
    ENDIF.
* get confirmation data for order and its items
    SELECT RUECK
    RMZHL
    ISM01
    ILE01
    ISM02
    ILE02
    ISM03
    ILE03
    ISM04
    ILE04
    ISM05
    ILE05
    ISM06
    ILE06
    STOKZ
    FROM AFRU
    INTO TABLE I_ORD_CONF
    FOR ALL ENTRIES IN I_AFRU_SEL
    WHERE RUECK = I_AFRU_SEL-RUECK.
  ENDIF.
  IF NOT I_AFVC IS INITIAL.
    LOOP AT I_AFVC INTO WA_AFVC.
*** get master recipe records for selected phases
      LOOP AT I_PLPO INTO WA_PLPO WHERE PLNTY = WA_AFVC-PLNTY
      AND PLNNR = WA_AFVC-PLNNR
      AND PLNKN = WA_AFVC-PLNKN
      AND ZAEHL = WA_AFVC-ZAEHL.
        APPEND WA_PLPO TO I_PLPO1.
      ENDLOOP.
*** get confirmation records for selected phases
      LOOP AT I_ORD_CONF INTO WA_ORD_CONF WHERE RUECK = WA_AFVC-RUECK.
        APPEND WA_ORD_CONF TO I_ORD_CONF1.
      ENDLOOP.
    ENDLOOP.
    SORT I_PLPO1 BY PLNTY PLNNR PLNKN ZAEHL DATUV DESCENDING.
  ENDIF.
  UNASSIGN : <L_FS_ORDERS>.
ENDFORM. " get_bom_info
*&--------------------------------------------------------------------*
*& Form build_output_tabs
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM BUILD_OUTPUT_TABS.
  DATA : L_QTY TYPE GAMNG,
  L_EFFIC TYPE VGWRT,
  L_TMP TYPE VGWRT,
  L_TMP1 TYPE VGWRT,
  L_LMNGA TYPE LMNGA,
  L_V_RC TYPE CHAR1,
  L_V_KAUSF TYPE KAUSF,
  L_V_SUMI TYPE CHAR1,
  L_V_SMENG TYPE TY_MENGE,
  L_V_SMENGS TYPE TY_MENGE,
  L_V_SMENGZ TYPE TY_MENGE,
  L_WA_AFVV TYPE TY_AFVV.
  FIELD-SYMBOLS : <L_FS_RESB> TYPE TY_RESB.
  MOVE 'Formatting Output'(027) TO V_OUTPUT_TEXT.
  PERFORM INFORM_USER_OF_PROGRESS.
  CLEAR: I_MARC1.
  SELECT MATNR
  WERKS
  FRTME
  FROM MARC
  INTO TABLE I_MARC1
  FOR ALL ENTRIES IN I_ORDERS
  WHERE MATNR = I_ORDERS-PLNBEZ
  AND WERKS = I_ORDERS-WERKS.
* Not required to handle, ok if prod unit not found
* get parameter IDs
  SELECT VGWTS
  PAR01
  PAR02
  PAR03
  PAR04
  PAR05
  PAR06
  FROM TC21
  INTO TABLE I_PARAM
  FOR ALL ENTRIES IN I_AFVC
  WHERE VGWTS = I_AFVC-VGWTS.
  IF SY-SUBRC = 0.
* get parameter ID texts
    SELECT PARID
    TXTLG
    FROM TC20T
    INTO TABLE I_PARAM_KEY
    FOR ALL ENTRIES IN I_PARAM
    WHERE SPRAS = SY-LANGU
    AND ( PARID = I_PARAM-PAR01
    OR PARID = I_PARAM-PAR02
    OR PARID = I_PARAM-PAR03
    OR PARID = I_PARAM-PAR04
    OR PARID = I_PARAM-PAR05
    OR PARID = I_PARAM-PAR06 ).
  ENDIF.
* Selecting Work centers descriptions
  SELECT OBJID KTEXT
  FROM CRTX
  INTO TABLE I_WC_TEXT
  FOR ALL ENTRIES IN I_AFVC
  WHERE OBJTY = C_OBJTYP
  AND OBJID = I_AFVC-ARBID
  AND SPRAS = SY-LANGU.
*Work centers descriptions are optional
  SELECT MATNR BWKEY STPRS PEINH
  FROM MBEW
  APPENDING TABLE I_MBEW1
  FOR ALL ENTRIES IN I_ORDERS
  WHERE MATNR = I_ORDERS-PLNBEZ
  AND BWKEY = I_ORDERS-WERKS.
  LOOP AT I_ORDERS INTO WA_ORDERS.
***
*** Build Order Table
***
    WA_H_ORD-AUFNR = WA_ORDERS-AUFNR.
    WA_H_ORD-GLTRP = WA_ORDERS-GLTRP.
    WA_H_ORD-GSTRP = WA_ORDERS-GSTRP.
    WA_H_ORD-PLNBEZ = WA_ORDERS-PLNBEZ.
    WA_H_ORD-MAKTX = WA_ORDERS-MAKTX.
    WA_H_ORD-LMNGA = WA_ORDERS-LMNGA.
    WA_H_ORD-BLMNGA = WA_ORDERS-BLMNGA.
    WA_H_ORD-BMENGE = WA_ORDERS-BMENGE.
    WA_H_ORD-BGAMNG = WA_ORDERS-BGAMNG.
    WA_H_ORD-BBMENG = WA_ORDERS-BBMENG.
    WA_H_ORD-GRUOM = WA_ORDERS-GRUOM.
    WA_H_ORD-CFUOM = WA_ORDERS-CFUOM.
    WA_H_ORD-BSUOM = WA_ORDERS-BSUOM.
    CLEAR : WA_MARC1.
    READ TABLE I_MARC1 INTO WA_MARC1 WITH KEY MATNR = WA_ORDERS-PLNBEZ
    WERKS = WA_ORDERS-WERKS.
    WA_H_ORD-FRTME = WA_MARC1-FRTME.
    WA_H_ORD-GEWEI = WA_ORDERS-GEWEI.
    WA_H_ORD-NTGEW = WA_ORDERS-NTGEW.
    IF RB_PLAND = C_X.
* Planned Production Quantities
      WA_H_ORD-PRDUOM = WA_H_ORD-FRTME.
      WA_H_ORD-PRDQTY = WA_H_ORD-BGAMNG.
    ELSE.
* Actual Production Quantities
      IF RB_PROD = C_X.
*** Produced Qty
        WA_H_ORD-PRDQTY = WA_H_ORD-BMENGE.
        WA_H_ORD-PRDUOM = WA_H_ORD-GRUOM.
      ELSE.
*** Confirmed Qty
        WA_H_ORD-PRDQTY = WA_H_ORD-BLMNGA.
        WA_H_ORD-PRDUOM = WA_H_ORD-CFUOM.
      ENDIF.
    ENDIF.
    WA_H_ORD-BPRDQTY = WA_H_ORD-PRDQTY.
    IF WA_H_ORD-PRDUOM <> WA_H_ORD-BSUOM.
      L_QTY = WA_H_ORD-PRDQTY.
      PERFORM CONV_TO_FROM_BASE USING ' '
      WA_H_ORD-PLNBEZ
      L_QTY
      WA_H_ORD-PRDUOM
      WA_H_ORD-BSUOM
      CHANGING WA_H_ORD-PRDQTY
      V_CONV_RC.
      IF V_CONV_RC = 'X'.
        WA_H_ORD-PRDQTY = L_QTY.
        WA_H_ORD-PRDUOM = WA_H_ORD-BSUOM.
      ENDIF.
    ENDIF.
* Resource Information
    CLEAR : WA_AFVC , WA_CRHD , WA_WC_TEXT.
    READ TABLE I_AFVC INTO WA_AFVC WITH KEY AUFPL = WA_ORDERS-AUFPL
    STEUS = 'YBN1'.
    IF SY-SUBRC = 0.
      READ TABLE I_CRHD INTO WA_CRHD WITH KEY OBJID = WA_AFVC-ARBID.
      READ TABLE I_WC_TEXT INTO WA_WC_TEXT WITH KEY OBJID =
      WA_AFVC-ARBID.
    ENDIF.
    WA_H_ORD-BOTLNCK = WA_CRHD-ARBPL.
    WA_H_ORD-RESDESC = WA_WC_TEXT-KTEXT.
* Expected Line Efficiency
    CLEAR : I_PLPO2 , L_EFFIC.
    LOOP AT I_PLPO1 INTO WA_PLPO WHERE PLNTY = WA_ORDERS-PLNTY
    AND PLNNR = WA_ORDERS-PLNNR
    AND STEUS = 'YBN1'.
      IF NOT WA_PLPO-VGW02 IS INITIAL.
        L_EFFIC = WA_PLPO-USR04.
        WA_PLPO2 = WA_PLPO.
        APPEND WA_PLPO2 TO I_PLPO2.
      ENDIF.
    ENDLOOP.
    WA_H_ORD-EL_EFFC = L_EFFIC.
* Actual Line Efficiency
    CLEAR : L_TMP , L_TMP1 , L_EFFIC.
    LOOP AT I_PLPO2 INTO WA_PLPO2.
      CLEAR: WA_AFVC, WA_AFVV , L_EFFIC.
      READ TABLE I_AFVC INTO WA_AFVC WITH KEY PLNTY = WA_PLPO2-PLNTY
      PLNNR = WA_PLPO2-PLNNR
      PLNKN = WA_PLPO2-PLNKN
      ZAEHL = WA_PLPO2-ZAEHL
      AUFPL = WA_ORDERS-AUFPL.
      IF SY-SUBRC = 0.
        READ TABLE I_AFVV INTO WA_AFVV WITH KEY AUFPL = WA_AFVC-AUFPL
        APLZL = WA_AFVC-APLZL.
        IF WA_PLPO2-VGW02 <> 0.
          L_TMP = WA_PLPO2-BMSCH / WA_PLPO2-VGW02.
          IF L_TMP <> 0.
            L_TMP1 = WA_AFVV-LMNGA / L_TMP.
            IF WA_AFVV-ISM02 <> 0.
              L_TMP1 = ( L_TMP1 / WA_AFVV-ISM02 ) * 100.
              MOVE L_TMP1 TO L_EFFIC.
            ENDIF.
          ENDIF.
        ENDIF.
      ENDIF.
    ENDLOOP.
    WA_H_ORD-AC_EFFC = L_EFFIC.
    CLEAR : WA_MBEW1.
    READ TABLE I_MBEW1 INTO WA_MBEW1 WITH KEY MATNR = WA_ORDERS-PLNBEZ
    BWKEY = WA_ORDERS-WERKS.
    WA_H_ORD-STPRS = WA_MBEW1-STPRS.
    WA_H_ORD-PEINH = WA_MBEW1-PEINH.
    APPEND WA_H_ORD TO I_H_ORD.
***
*** Build Phase Table
***
    LOOP AT I_AFVC INTO WA_AFVC WHERE AUFNR = WA_ORDERS-AUFNR
    AND AUFPL = WA_ORDERS-AUFPL.
      CLEAR : WA_H_PHS.
      WA_H_PHS-AUFNR = WA_AFVC-AUFNR.
      WA_H_PHS-AUFPL = WA_AFVC-AUFPL.
      WA_H_PHS-APLZL = WA_AFVC-APLZL.
      WA_H_PHS-VORNR = WA_AFVC-VORNR.
      WA_H_PHS-STEUS = WA_AFVC-STEUS.
      WA_H_PHS-RUECK = WA_AFVC-RUECK.
      WA_H_PHS-VGWTS = WA_AFVC-VGWTS.
      WA_H_PHS-LTXA1 = WA_AFVC-LTXA1.
      IF WA_AFVC-CFUOM IS INITIAL.
        CLEAR : WA_AFVV, L_LMNGA.
        LOOP AT I_AFVV INTO L_WA_AFVV WHERE AUFPL = WA_AFVC-AUFPL
        AND APLZL = WA_AFVC-APLZL.
          WA_H_PHS-LMNGA = WA_H_PHS-LMNGA + L_WA_AFVV-LMNGA.
        ENDLOOP.
        WA_H_PHS-CFUOM = L_WA_AFVV-MEINH.
      ELSE.
        WA_H_PHS-LMNGA = WA_AFVC-LMNGA.
        WA_H_PHS-CFUOM = WA_AFVC-CFUOM.
* afvv contains std vals for operation qty
        CLEAR : L_WA_AFVV.
        READ TABLE I_AFVV INTO L_WA_AFVV
        WITH KEY AUFPL = WA_AFVC-AUFPL
        APLZL = WA_AFVC-APLZL.
      ENDIF.
      WA_H_PHS-BSUOM = WA_H_ORD-BSUOM.
      WA_H_PHS-GEWEI = WA_H_ORD-GEWEI.
      WA_H_PHS-NTGEW = WA_H_ORD-NTGEW.
      IF WA_H_PHS-CFUOM <> WA_H_PHS-BSUOM.
        L_LMNGA = WA_H_PHS-LMNGA.
        PERFORM CONV_TO_FROM_BASE USING 'X'
        WA_H_ORD-PLNBEZ
        L_LMNGA
        WA_H_PHS-CFUOM
        WA_H_PHS-BSUOM
        CHANGING WA_H_PHS-BLMNGA
        V_CONV_RC.
        IF V_CONV_RC = 'X'.
          CLEAR : WA_H_PHS-BLMNGA.
        ENDIF.
      ELSE.
        WA_H_PHS-BLMNGA = WA_H_PHS-LMNGA.
      ENDIF.
      IF RB_ACTL = C_X AND RB_CONF = C_X.
        WA_H_PHS-PRDUOM = WA_H_ORD-CFUOM.
        WA_H_PHS-PRDQTY = WA_H_ORD-LMNGA.
        WA_H_PHS-BPRDQTY = WA_H_ORD-BLMNGA.
      ELSE.
        WA_H_PHS-PRDUOM = WA_H_ORD-PRDUOM.
        WA_H_PHS-PRDQTY = WA_H_ORD-PRDQTY.
        WA_H_PHS-BPRDQTY = WA_H_ORD-BPRDQTY.
      ENDIF.
      WA_H_PHS-ARBID = WA_AFVC-ARBID.
      CLEAR : WA_CRHD , WA_WC_TEXT.
      READ TABLE I_CRHD INTO WA_CRHD WITH KEY OBJID = WA_AFVC-ARBID.
      READ TABLE I_WC_TEXT INTO WA_WC_TEXT
      WITH KEY OBJID = WA_AFVC-ARBID.
      WA_H_PHS-ARBPL = WA_CRHD-ARBPL.
      WA_H_PHS-KTEXT = WA_WC_TEXT-KTEXT.
      IF WA_H_PHS-STEUS = 'YBN1'.
* Expected Line Efficiency
        CLEAR : I_PLPO2 , L_EFFIC.
        LOOP AT I_PLPO1 INTO WA_PLPO WHERE PLNTY = WA_AFVC-PLNTY
        AND PLNNR = WA_AFVC-PLNNR
        AND PLNKN = WA_AFVC-PLNKN
        AND ZAEHL = WA_AFVC-ZAEHL
        AND STEUS = 'YBN1'.
          IF NOT WA_PLPO-VGW02 IS INITIAL.
            L_EFFIC = WA_PLPO-USR04.
            WA_PLPO2 = WA_PLPO.
            APPEND WA_PLPO2 TO I_PLPO2.
          ENDIF.
        ENDLOOP.
        WA_H_PHS-EL_EFFC = L_EFFIC.
* Actual Line Efficiency
        CLEAR : L_TMP , L_TMP1 , L_EFFIC.
        LOOP AT I_PLPO2 INTO WA_PLPO2.
          CLEAR: L_EFFIC.
          IF WA_PLPO2-VGW02 <> 0.
            L_TMP = WA_PLPO2-BMSCH / WA_PLPO2-VGW02.
            IF L_TMP <> 0.
              L_TMP1 = L_WA_AFVV-LMNGA / L_TMP.
              IF L_WA_AFVV-ISM02 <> 0.
                L_TMP1 = ( L_TMP1 / L_WA_AFVV-ISM02 ) * 100.
                MOVE L_TMP1 TO L_EFFIC.
                WA_H_PHS-RUNTIME = C_X.
              ENDIF.
            ENDIF.
          ENDIF.
        ENDLOOP.
        WA_H_PHS-AC_EFFC = L_EFFIC.
      ENDIF.
***
*** Build Phase-Activity Table
***
      CLEAR : L_V_RC.
      PERFORM BUILD_ACT_TAB USING WA_ORDERS-AUFNR WA_ORDERS-PLNBEZ
      WA_H_PHS-BPRDQTY WA_H_PHS-BSUOM
      WA_ORDERS-GMEIN
      WA_H_PHS-EL_EFFC WA_AFVC
      L_WA_AFVV
      CHANGING L_V_RC.
      IF L_V_RC = C_X.
        APPEND WA_H_PHS TO I_H_PHS.
      ENDIF.
***
*** Build Material-Phase Table
***
      LOOP AT I_RESB ASSIGNING <L_FS_RESB>
      WHERE AUFNR = WA_ORDERS-AUFNR.
        IF <L_FS_RESB>-AUFPL = WA_AFVC-AUFPL AND
        <L_FS_RESB>-VORNR = WA_AFVC-VORNR AND
        <L_FS_RESB>-APLZL = WA_AFVC-APLZL.
          CLEAR : WA_RESB.
          PERFORM BUILD_MAT_TAB USING <L_FS_RESB>.
          <L_FS_RESB>-FLAGP = C_Y.
        ELSEIF <L_FS_RESB>-FLAGP IS INITIAL.
          <L_FS_RESB>-FLAGP = 'N'.
        ENDIF.
      ENDLOOP.
    ENDLOOP.
****
**** Add Extra Materials to Material-Phase Table
****
    LOOP AT I_RESB ASSIGNING <L_FS_RESB>
    WHERE AUFNR = WA_ORDERS-AUFNR
    AND FLAGP = 'N'.
      CLEAR : WA_RESB.
      PERFORM BUILD_MAT_TAB USING <L_FS_RESB>.
    ENDLOOP.
  ENDLOOP.
  SORT I_H_ORD BY AUFNR.
  SORT I_H_MAT BY AUFNR AUFPL APLZL MATNR BYPROD.
  SORT I_H_PHS BY AUFNR VORNR.
  SORT I_H_ACT BY AUFNR VORNR.
  LOOP AT I_H_MAT INTO WA_H_MAT.
    CLEAR : L_V_SUMI.
    AT END OF BYPROD.
      L_V_SUMI = C_X.
    ENDAT.
    WA_H_MAT-SUMI = L_V_SUMI.
    MODIFY I_H_MAT FROM WA_H_MAT TRANSPORTING SUMI.
  ENDLOOP.
ENDFORM. "build_output_tabs
*&--------------------------------------------------------------------*
*& Form build_mat_tab
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM BUILD_MAT_TAB USING FP_RESB TYPE TY_RESB.
  DATA : L_V_KAUSF TYPE KAUSF,
  L_V_SMENG TYPE TY_MENGE,
  L_V_SMENGS TYPE TY_MENGE,
  L_V_SMENGZ TYPE TY_MENGE.
  WA_RESB = FP_RESB.
  CLEAR : WA_H_MAT , L_V_SMENG , L_V_SMENGS ,
  L_V_SMENGZ.
  CHECK WA_RESB-POSTP <> 'N' AND
  NOT ( WA_RESB-KZKUP = C_X AND
  WA_RESB-MATNR = WA_H_ORD-PLNBEZ ).
  WA_H_MAT-AUFNR = WA_RESB-AUFNR.
  WA_H_MAT-AUFPL = WA_RESB-AUFPL.
  WA_H_MAT-APLZL = WA_RESB-APLZL.
  WA_H_MAT-VORNR = WA_RESB-VORNR.
  WA_H_MAT-MATNR = WA_RESB-MATNR.
  CLEAR : WA_MARA.
  READ TABLE I_MARA INTO WA_MARA WITH KEY MATNR = WA_H_MAT-MATNR.
  CLEAR : WA_MSEGS.
  READ TABLE I_MSEGS INTO WA_MSEGS WITH KEY AUFNR = WA_H_MAT-AUFNR
  MATNR = WA_H_MAT-MATNR
  BWART = WA_RESB-BWART.
  IF SY-SUBRC <> 0.
    READ TABLE I_MSEGS INTO WA_MSEGS WITH KEY AUFNR = WA_H_MAT-AUFNR
    MATNR = WA_H_MAT-MATNR.
  ENDIF.
  CLEAR : WA_ORDMATS.
  READ TABLE I_ORDMATS INTO WA_ORDMATS
  WITH KEY AUFNR = WA_RESB-AUFNR
  MATNR = WA_RESB-MATNR
  STLTY = WA_RESB-STLTY
  STLNR = WA_RESB-STLNR
  STLKN = WA_RESB-STLKN
  STPOZ = WA_RESB-STPOZ.
  IF SY-SUBRC = 0.
    WA_H_MAT-MAKTX = WA_ORDMATS-OJTXP.
    WA_H_MAT-STPRS = WA_ORDMATS-STPRS.
    WA_H_MAT-PEINH = WA_ORDMATS-PEINH.
    WA_H_MAT-BOMUOM = WA_ORDMATS-MEINS.
    IF WA_ORDERS-BBMENG <> 0.
      L_V_SMENG = WA_ORDMATS-MNGLG / WA_ORDERS-BBMENG.
      L_V_SMENGS = WA_ORDMATS-MNGLGS / WA_ORDERS-BBMENG.
      L_V_SMENGZ = WA_ORDMATS-MNGLGZ / WA_ORDERS-BBMENG.
    ENDIF.
    WA_H_MAT-BYPROD = WA_ORDMATS-BYPROD.
  ELSE.
    CLEAR : WA_MBEW1.
    READ TABLE I_MBEW1 INTO WA_MBEW1
    WITH KEY MATNR = WA_H_MAT-MATNR
    BWKEY = P_WERKS.
    CLEAR : WA_MATERIAL_DES.
    READ TABLE I_MATERIAL_DES INTO WA_MATERIAL_DES
    WITH KEY MATNR = WA_H_MAT-MATNR.
    WA_H_MAT-MAKTX = WA_MATERIAL_DES-MAKTX.
    WA_H_MAT-STPRS = WA_MBEW1-STPRS.
    WA_H_MAT-PEINH = WA_MBEW1-PEINH.
    WA_H_MAT-BOMUOM = WA_RESB-MEINS.
    WA_RESB-BMEINS = WA_MARA-MEINS.
    IF WA_MARA-MEINS <> WA_RESB-MEINS.
      PERFORM CONV_TO_FROM_BASE USING 'X'
      WA_RESB-MATNR
      WA_RESB-BDMNG
      WA_RESB-MEINS
      WA_MARA-MEINS
      CHANGING WA_RESB-BBDMNG
      V_CONV_RC.
      IF V_CONV_RC = 'X'.
        CLEAR : WA_RESB-BBDMNG.
      ENDIF.
    ELSE.
      WA_RESB-BBDMNG = WA_RESB-BDMNG.
    ENDIF.
    WA_ORDMATS-RGEKZ = WA_RESB-RGEKZ.
  ENDIF.
  IF RB_NFLSH <> C_X OR WA_ORDMATS-RGEKZ EQ C_X.
    WA_H_MAT-STDUSG = L_V_SMENG * WA_H_ORD-BPRDQTY.
    WA_H_MAT-STDUSGS = L_V_SMENGS * WA_H_ORD-BPRDQTY.
    WA_H_MAT-STDUSGZ = L_V_SMENGZ * WA_H_ORD-BPRDQTY.
  ELSE.
    CLEAR : WA_H_MAT-STDUSG.
  ENDIF.
  IF WA_H_MAT-BYPROD = C_X.
    WA_H_MAT-ACTUSG = WA_MSEGS-BMENGE5.
  ELSEIF WA_RESB-KZKUP = C_X.
    WA_H_MAT-ACTUSG = 0 - WA_MSEGS-BMENGE1.
  ELSE.
    WA_H_MAT-ACTUSG = WA_MSEGS-BMENGE2.
  ENDIF.
  WA_H_MAT-BSUOM = WA_MARA-MEINS.
  WA_H_MAT-GEWEI = WA_MARA-GEWEI.
  WA_H_MAT-NTGEW = WA_MARA-NTGEW.
  IF WA_H_MAT-ACTUSG <> 0.
    WA_H_MAT-GRUOM = WA_MSEGS-ERFME.
  ENDIF.
  WA_H_MAT-BWART = WA_RESB-BWART. "NEEL 30/06/2005
  APPEND WA_H_MAT TO I_H_MAT.
  WA_MATN-MATNR = WA_H_MAT-MATNR.
  WA_MATN-BWART = WA_H_MAT-BWART.                           "23-06-2005
  COLLECT WA_MATN INTO I_MATN.
ENDFORM. "build_mat_tab
*&--------------------------------------------------------------------*
*& Form build_act_tab
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM BUILD_ACT_TAB USING FP_AUFNR TYPE AUFNR
FP_MATNR TYPE MATNR
FP_BQTY TYPE GAMNG
FP_BUOM TYPE MEINS
FP_GMEIN TYPE MEINS
FP_EFFIC TYPE VGWRT
FP_AFVC TYPE TY_AFVC
FP_AFVV TYPE TY_AFVV
CHANGING FP_RC TYPE CHAR1.
  DATA : L_ISM01 TYPE RU_ISMNG,
  L_ILE01 TYPE CO_ISMNGEH,
  L_ISM02 TYPE RU_ISMNG,
  L_ILE02 TYPE CO_ISMNGEH,
  L_ISM03 TYPE RU_ISMNG,
  L_ILE03 TYPE CO_ISMNGEH,
  L_ISM04 TYPE RU_ISMNG,
  L_ILE04 TYPE CO_ISMNGEH,
  L_ISM05 TYPE RU_ISMNG,
  L_ILE05 TYPE CO_ISMNGEH,
  L_ISM06 TYPE RU_ISMNG,
  L_ILE06 TYPE CO_ISMNGEH,
  L_EFFIC TYPE VGWRT,
  L_V_BMSCH TYPE BMSCH,
  L_PQTY TYPE GAMNG.
  DATA: L_VGW01 TYPE VGWRT,
  L_VGW02 TYPE VGWRT,
  L_VGW03 TYPE VGWRT,
  L_VGW04 TYPE VGWRT,
  L_VGW05 TYPE VGWRT,
  L_VGW06 TYPE VGWRT.
  CLEAR : WA_H_ACT.
  WA_H_ACT-AUFNR = FP_AUFNR.
  WA_H_ACT-AUFPL = FP_AFVC-AUFPL.
  WA_H_ACT-APLZL = FP_AFVC-APLZL.
  WA_H_ACT-VORNR = FP_AFVC-VORNR.
  WA_H_ACT-VGWTS = FP_AFVC-VGWTS.
  L_EFFIC = FP_EFFIC / 100.
  IF L_EFFIC = 0.
    L_EFFIC = 1.
  ENDIF.
  WA_AFVV = FP_AFVV.
  CHECK NOT WA_AFVV IS INITIAL.
  WA_H_ACT-MGVRG = WA_AFVV-MGVRG.
  WA_H_ACT-MEINH = WA_AFVV-MEINH.
  WA_H_ACT-BMSCH = WA_AFVV-BMSCH.
  CLEAR : WA_PARAM.
  READ TABLE I_PARAM INTO WA_PARAM WITH KEY VGWTS = WA_H_ACT-VGWTS.
* Actual Usage
  CLEAR : WA_ORD_CONF1.
  LOOP AT I_ORD_CONF1 INTO WA_ORD_CONF1 WHERE RUECK = FP_AFVC-RUECK.
    IF WA_ORD_CONF1-STOKZ IS INITIAL.
      L_ISM01 = L_ISM01 + WA_ORD_CONF1-ISM01.
      L_ISM02 = L_ISM02 + WA_ORD_CONF1-ISM02.
      L_ISM03 = L_ISM03 + WA_ORD_CONF1-ISM03.
      L_ISM04 = L_ISM04 + WA_ORD_CONF1-ISM04.
      L_ISM05 = L_ISM05 + WA_ORD_CONF1-ISM05.
      L_ISM06 = L_ISM06 + WA_ORD_CONF1-ISM06.
    ELSE.
      L_ISM01 = L_ISM01 - WA_ORD_CONF1-ISM01.
      L_ISM02 = L_ISM02 - WA_ORD_CONF1-ISM02.
      L_ISM03 = L_ISM03 - WA_ORD_CONF1-ISM03.
      L_ISM04 = L_ISM04 - WA_ORD_CONF1-ISM04.
      L_ISM05 = L_ISM05 - WA_ORD_CONF1-ISM05.
      L_ISM06 = L_ISM06 - WA_ORD_CONF1-ISM06.
    ENDIF.
  ENDLOOP.
  L_ILE01 = WA_ORD_CONF1-ILE01.
  L_ILE02 = WA_ORD_CONF1-ILE02.
  L_ILE03 = WA_ORD_CONF1-ILE03.
  L_ILE04 = WA_ORD_CONF1-ILE04.
  L_ILE05 = WA_ORD_CONF1-ILE05.
  L_ILE06 = WA_ORD_CONF1-ILE06.
  CLEAR : FP_RC , L_PQTY.
  L_PQTY = FP_BQTY.
  L_V_BMSCH = WA_AFVV-BMSCH.
  IF WA_AFVV-UMREN > 0.
    L_V_BMSCH = L_V_BMSCH * ( WA_AFVV-UMREZ / WA_AFVV-UMREN ).
  ENDIF.
  IF WA_AFVV-MEINH <> FP_BUOM.
    PERFORM CONV_TO_FROM_BASE USING 'X'
    FP_MATNR
    L_V_BMSCH
    WA_AFVV-MEINH
    FP_BUOM
    CHANGING WA_AFVV-BMSCH
    V_CONV_RC.
    IF V_CONV_RC = 'X'.
      WA_AFVV-BMSCH = L_V_BMSCH.
    ENDIF.
*** Begin of Change on 25-05-2005
    IF FP_AFVC-VGWTS+0(3) = 'YGE'.
      PERFORM CONV_TO_FROM_BASE USING 'X'
      FP_MATNR
      WA_AFVV-VGW01
      WA_AFVV-MEINH
      FP_BUOM
      CHANGING L_VGW01
      V_CONV_RC.
      IF V_CONV_RC = SPACE.
        WA_AFVV-VGW01 = L_VGW01.
      ENDIF.
    ENDIF.
    PERFORM CONV_TO_FROM_BASE USING 'X'
    FP_MATNR
    WA_AFVV-VGW02
    WA_AFVV-MEINH
    FP_BUOM
    CHANGING L_VGW02
    V_CONV_RC.
    IF V_CONV_RC = SPACE.
      WA_AFVV-VGW02 = L_VGW02.
    ENDIF.
    IF FP_AFVC-VGWTS+0(3) = 'YGE'.
      PERFORM CONV_TO_FROM_BASE USING 'X'
      FP_MATNR
      WA_AFVV-VGW03
      WA_AFVV-MEINH
      FP_BUOM
      CHANGING L_VGW03
      V_CONV_RC.
      IF V_CONV_RC = SPACE.
        WA_AFVV-VGW03 = L_VGW03.
      ENDIF.
    ENDIF.
    PERFORM CONV_TO_FROM_BASE USING 'X'
    FP_MATNR
    WA_AFVV-VGW04
    WA_AFVV-MEINH
    FP_BUOM
    CHANGING L_VGW04
    V_CONV_RC.
    IF V_CONV_RC = SPACE.
      WA_AFVV-VGW04 = L_VGW04.
    ENDIF.
    PERFORM CONV_TO_FROM_BASE USING 'X'
    FP_MATNR
    WA_AFVV-VGW05
    WA_AFVV-MEINH
    FP_BUOM
    CHANGING L_VGW05
    V_CONV_RC.
    IF V_CONV_RC = SPACE.
      WA_AFVV-VGW05 = L_VGW05.
    ENDIF.
    PERFORM CONV_TO_FROM_BASE USING 'X'
    FP_MATNR
    WA_AFVV-VGW06
    WA_AFVV-MEINH
    FP_BUOM
    CHANGING L_VGW06
    V_CONV_RC.
    IF V_CONV_RC = SPACE.
      WA_AFVV-VGW06 = L_VGW06.
    ENDIF.
*** End of Change on 25-05-2005
  ENDIF.
  IF NOT FP_AFVC-LAR01 IS INITIAL OR NOT FP_AFVC-LAR02 IS INITIAL OR
  NOT FP_AFVC-LAR03 IS INITIAL OR NOT FP_AFVC-LAR04 IS INITIAL OR
  NOT FP_AFVC-LAR05 IS INITIAL OR NOT FP_AFVC-LAR06 IS INITIAL.
    IF NOT FP_AFVC-LAR01 IS INITIAL OR
    NOT WA_AFVV-VGW01 IS INITIAL.
      CLEAR : WA_PARAM_KEY.
      READ TABLE I_PARAM_KEY INTO WA_PARAM_KEY
      WITH KEY PARID = WA_PARAM-PAR01.
      WA_H_ACT-PARXX = WA_PARAM-PAR01.
      WA_H_ACT-TXTXX = WA_PARAM_KEY-TXTLG.
      WA_H_ACT-ISMXX = L_ISM01.
      WA_H_ACT-ILEXX = L_ILE01.
      IF FP_AFVC-SUMNR = 0.
        WA_H_ACT-VGWXX = WA_AFVV-VGW01.
        WA_H_ACT-VGEXX = WA_AFVV-VGE01.
      ELSE.
        WA_H_ACT-VGWXX = WA_AFVV-VGW01 * ( L_PQTY / WA_AFVV-BMSCH ).
        WA_H_ACT-VGEXX = WA_AFVV-VGE01.
      ENDIF.
      WA_H_ACT-STDVAR = WA_H_ACT-VGWXX - WA_H_ACT-ISMXX.
      PERFORM GET_ACT_COST USING FP_AFVC-ARBID
      FP_AFVC-LAR01
      CHANGING WA_H_ACT-TOGXX
      WA_H_ACT-TOEXX.
      APPEND WA_H_ACT TO I_H_ACT.
      WA_PARN-PARXX = WA_H_ACT-PARXX.
      COLLECT WA_PARN INTO I_PARN.
      FP_RC = C_X.
    ENDIF.
    IF NOT FP_AFVC-LAR02 IS INITIAL OR
    NOT WA_AFVV-VGW02 IS INITIAL.
      CLEAR : WA_PARAM_KEY.
      READ TABLE I_PARAM_KEY INTO WA_PARAM_KEY
      WITH KEY PARID = WA_PARAM-PAR02.
      WA_H_ACT-PARXX = WA_PARAM-PAR02.
      WA_H_ACT-TXTXX = WA_PARAM_KEY-TXTLG.
      WA_H_ACT-ISMXX = L_ISM02.
      WA_H_ACT-ILEXX = L_ILE02.
* Begin of MOD-002++
* wa_h_act-vgwxx = wa_afvv-vgw02 * ( l_pqty / wa_afvv-bmsch ).
* wa_h_act-vgwxx = wa_h_act-vgwxx / l_effic.
      WA_H_ACT-VGWXX = ( WA_AFVV-VGW02 * L_PQTY / WA_AFVV-BMSCH ) /
      L_EFFIC.
* End of MOD-002++
      WA_H_ACT-VGEXX = WA_AFVV-VGE02.
      WA_H_ACT-STDVAR = WA_H_ACT-VGWXX - WA_H_ACT-ISMXX.
      PERFORM GET_ACT_COST USING FP_AFVC-ARBID
      FP_AFVC-LAR02
      CHANGING WA_H_ACT-TOGXX
      WA_H_ACT-TOEXX.
      APPEND WA_H_ACT TO I_H_ACT.
      WA_PARN-PARXX = WA_H_ACT-PARXX.
      COLLECT WA_PARN INTO I_PARN.
      FP_RC = C_X.
    ENDIF.
    IF NOT FP_AFVC-LAR03 IS INITIAL OR
    NOT WA_AFVV-VGW03 IS INITIAL.
      CLEAR : WA_PARAM_KEY.
      READ TABLE I_PARAM_KEY INTO WA_PARAM_KEY
      WITH KEY PARID = WA_PARAM-PAR03.
      WA_H_ACT-PARXX = WA_PARAM-PAR03.
      WA_H_ACT-TXTXX = WA_PARAM_KEY-TXTLG.
      WA_H_ACT-ISMXX = L_ISM03.
      WA_H_ACT-ILEXX = L_ILE03.
      IF FP_AFVC-SUMNR = 0.
        WA_H_ACT-VGWXX = WA_AFVV-VGW03.
        WA_H_ACT-VGEXX = WA_AFVV-VGE03.
      ELSE.
        WA_H_ACT-VGWXX = WA_AFVV-VGW03 * ( L_PQTY / WA_AFVV-BMSCH ).
        WA_H_ACT-VGEXX = WA_AFVV-VGE03.
      ENDIF.
      WA_H_ACT-STDVAR = WA_H_ACT-VGWXX - WA_H_ACT-ISMXX.
      PERFORM GET_ACT_COST USING FP_AFVC-ARBID
      FP_AFVC-LAR03
      CHANGING WA_H_ACT-TOGXX
      WA_H_ACT-TOEXX.
      APPEND WA_H_ACT TO I_H_ACT.
      WA_PARN-PARXX = WA_H_ACT-PARXX.
      COLLECT WA_PARN INTO I_PARN.
      FP_RC = C_X.
    ENDIF.
    IF NOT FP_AFVC-LAR04 IS INITIAL OR
    NOT WA_AFVV-VGW04 IS INITIAL.
      CLEAR : WA_PARAM_KEY.
      READ TABLE I_PARAM_KEY INTO WA_PARAM_KEY
      WITH KEY PARID = WA_PARAM-PAR04.
      WA_H_ACT-PARXX = WA_PARAM-PAR04.
      WA_H_ACT-TXTXX = WA_PARAM_KEY-TXTLG.
      WA_H_ACT-ISMXX = L_ISM04.
      WA_H_ACT-ILEXX = L_ILE04.
* Begin of MOD-002++
* wa_h_act-vgwxx = wa_afvv-vgw04 * ( l_pqty / wa_afvv-bmsch ).
* wa_h_act-vgwxx = wa_h_act-vgwxx / l_effic.
      WA_H_ACT-VGWXX = ( WA_AFVV-VGW04 * L_PQTY / WA_AFVV-BMSCH ) /
      L_EFFIC.
* End of MOD-002++
      WA_H_ACT-VGEXX = WA_AFVV-VGE04.
      WA_H_ACT-STDVAR = WA_H_ACT-VGWXX - WA_H_ACT-ISMXX.
      PERFORM GET_ACT_COST USING FP_AFVC-ARBID
      FP_AFVC-LAR04
      CHANGING WA_H_ACT-TOGXX
      WA_H_ACT-TOEXX.
      APPEND WA_H_ACT TO I_H_ACT.
      WA_PARN-PARXX = WA_H_ACT-PARXX.
      COLLECT WA_PARN INTO I_PARN.
      FP_RC = C_X.
    ENDIF.
    IF NOT FP_AFVC-LAR05 IS INITIAL OR
    NOT WA_AFVV-VGW05 IS INITIAL.
      CLEAR : WA_PARAM_KEY.
      READ TABLE I_PARAM_KEY INTO WA_PARAM_KEY
      WITH KEY PARID = WA_PARAM-PAR05.
      WA_H_ACT-PARXX = WA_PARAM-PAR05.
      WA_H_ACT-TXTXX = WA_PARAM_KEY-TXTLG.
      WA_H_ACT-ISMXX = L_ISM05.
      WA_H_ACT-ILEXX = L_ILE05.
      WA_H_ACT-VGWXX = WA_AFVV-VGW05 * ( L_PQTY / WA_AFVV-BMSCH ).
      WA_H_ACT-VGEXX = WA_AFVV-VGE05.
      WA_H_ACT-STDVAR = WA_H_ACT-VGWXX - WA_H_ACT-ISMXX.
      PERFORM GET_ACT_COST USING FP_AFVC-ARBID
      FP_AFVC-LAR05
      CHANGING WA_H_ACT-TOGXX
      WA_H_ACT-TOEXX.
      APPEND WA_H_ACT TO I_H_ACT.
      WA_PARN-PARXX = WA_H_ACT-PARXX.
      COLLECT WA_PARN INTO I_PARN.
      FP_RC = C_X.
    ENDIF.
    IF NOT FP_AFVC-LAR06 IS INITIAL OR
    NOT WA_AFVV-VGW06 IS INITIAL.
      CLEAR : WA_PARAM_KEY.
      READ TABLE I_PARAM_KEY INTO WA_PARAM_KEY
      WITH KEY PARID = WA_PARAM-PAR06.
      WA_H_ACT-PARXX = WA_PARAM-PAR06.
      WA_H_ACT-TXTXX = WA_PARAM_KEY-TXTLG.
      WA_H_ACT-ISMXX = L_ISM06.
      WA_H_ACT-ILEXX = L_ILE06.
      WA_H_ACT-VGWXX = WA_AFVV-VGW06 * ( L_PQTY / WA_AFVV-BMSCH ).
      WA_H_ACT-VGEXX = WA_AFVV-VGE06.
      WA_H_ACT-STDVAR = WA_H_ACT-VGWXX - WA_H_ACT-ISMXX.
      PERFORM GET_ACT_COST USING FP_AFVC-ARBID
      FP_AFVC-LAR06
      CHANGING WA_H_ACT-TOGXX
      WA_H_ACT-TOEXX.
      APPEND WA_H_ACT TO I_H_ACT.
      WA_PARN-PARXX = WA_H_ACT-PARXX.
      COLLECT WA_PARN INTO I_PARN.
      FP_RC = C_X.
    ENDIF.
  ENDIF.
ENDFORM. "build_act_tab
*&--------------------------------------------------------------------*
*& Form get_act_cost
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM GET_ACT_COST USING FP_ARBID TYPE CR_OBJID
FP_LARXX TYPE LSTAR
CHANGING FP_TOG001 TYPE TOGXXX
FP_TOE001 TYPE TOEXXX.
  DATA: L_KOKRS TYPE KOKRS,
  L_KOSTL TYPE KOSTL,
  L_OBJNR TYPE J_OBJNR.
  CLEAR: L_KOKRS, L_KOSTL, L_OBJNR,
  FP_TOG001.
  FP_TOE001 = 1.
  SELECT SINGLE KOKRS KOSTL
  FROM CRCO
  INTO (L_KOKRS, L_KOSTL)
  WHERE OBJTY = C_A
  AND OBJID = FP_ARBID
  AND LSTAR = FP_LARXX.
  IF SY-SUBRC = 0.
    SELECT SINGLE OBJNR
    FROM CSSL
    INTO L_OBJNR
    WHERE KOKRS = L_KOKRS
    AND KOSTL = L_KOSTL
    AND LSTAR = FP_LARXX
    AND GJAHR = SY-DATUM(4).
    IF SY-SUBRC = 0.
      SELECT SINGLE TOG001 TOE001
      FROM COST
      INTO (FP_TOG001, FP_TOE001)
      WHERE OBJNR = L_OBJNR
      AND GJAHR = SY-DATUM(4)
      AND VERSN = C_000.
      FP_TOG001 = FP_TOG001 / 10.
      FP_TOE001 = FP_TOE001 / 10.
      IF FP_TOE001 = 0.
        FP_TOE001 = 1.
      ENDIF.
    ENDIF.
  ENDIF.
ENDFORM. "get_act_cost
*&---------------------------------------------------------------------*
*& Form output
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM OUTPUT.
  CASE C_X.
    WHEN RB_DETL.
      V_REP = C_DETL.
      PERFORM DISPLAY_DETAIL_REPORT.
    WHEN RB_SUMM.
      V_REP = C_SUMS.
      PERFORM DISPLAY_SUMMARY_REPORT.
    WHEN RB_PHASE.
      V_REP = C_PHAS.
      PERFORM DISPLAY_PHASE_REPORT.
  ENDCASE.
  PERFORM TREE_REBUILD.
ENDFORM. " output
*&--------------------------------------------------------------------*
*& Form display_detail_report
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM DISPLAY_DETAIL_REPORT.
  DATA : L_DATE_LOW TYPE CHAR10,
  L_DATE_HIGH TYPE CHAR10,
  L_PRDQTY TYPE GAMNG,
  L_WPRDQTY TYPE MENGE_D,
  L_PRDUOM TYPE MEINS,
  L_UOM TYPE MEINS,
  L_PRDQ(20),
  L_EFFIC TYPE CHAR16,
  L_ACT TYPE CHAR16,
  L_STD TYPE CHAR16,
  L_AMENGE TYPE MENGE_D,
  L_SMENGE TYPE MENGE_D,
  L_MENGE TYPE MENGE_D,
  L_AQTY TYPE CHAR18,
  L_SQTY TYPE CHAR18,
  L_SVAR TYPE CHAR18,
  L_SVARP TYPE CHAR18,
  L_AQTYS TYPE CHAR18,
  L_SQTYS TYPE CHAR18,
  L_SVARS TYPE CHAR18,
  L_AQTYG TYPE CHAR18,
  L_SQTYG TYPE CHAR18,
  L_SVARG TYPE CHAR18,
  L_MATUOM TYPE MEINS,
  L_STDUOM TYPE MEINS,
  L_VARUOM TYPE MEINS,
  L_ASTPRS TYPE TY_STPRS,
  L_SSTPRS TYPE TY_STPRS,
  L_STPRS TYPE TY_STPRS,
  L_TOTAL1 TYPE CHAR1,
  L_TOTAL2 TYPE CHAR1,
  L_TOTAL3 TYPE CHAR1,
  L_TOTALG1 TYPE CHAR1,
  L_TOTALG2 TYPE CHAR1,
  L_TOTALG3 TYPE CHAR1,
  L_APLZL TYPE CO_APLZL,
  L_WA_ACT TYPE TY_HIER_ACT,
  L_WA_MAT TYPE TY_HIER_MAT_SUM,
  L_WA_MATG TYPE TY_HIER_MAT_SUM.
  PERFORM PFSTATUS.
  SET PF-STATUS 'MAIN' EXCLUDING I_FCODE.
  SET TITLEBAR 'VARI' WITH TEXT-066.
  MOVE 'Display Detail Report'(028) TO V_OUTPUT_TEXT.
  PERFORM INFORM_USER_OF_PROGRESS.
* Clearing local variables
  CLEAR WA_NODESTAB.
  REFRESH I_NODESTAB.
  WA_NODESTAB-ID = C_1_1.
  WA_NODESTAB-TLEVEL = C_1.
  WA_NODESTAB-TEXT = 'Production Variances'(031).
  WA_NODESTAB-TLENGTH = C_20.
  WA_NODESTAB-COMPRESS = C_X.
  APPEND WA_NODESTAB TO I_NODESTAB.
  CLEAR : L_WA_MATG , L_SQTYG , L_AQTYG , L_SVARG,
  L_TOTALG1 , L_TOTALG2 , L_TOTALG3.
  LOOP AT I_H_ORD INTO WA_H_ORD.
    CLEAR: WA_NODESTAB, L_DATE_LOW, L_DATE_HIGH, L_PRDQTY, L_PRDUOM.
    WA_NODESTAB-ID = C_2_1.
    WA_NODESTAB-TLEVEL = C_2.
    WA_NODESTAB-PARENT = C_1_1.
* Order Number text
    WA_NODESTAB-TEXT = 'Order Num:'(032).
    WA_NODESTAB-TLENGTH = C_12.
    WA_NODESTAB-TCOLOR = C_1.
* Order number
    WRITE WA_H_ORD-AUFNR TO WA_NODESTAB-TEXT1 NO-ZERO.
    WA_NODESTAB-TLENGTH1 = C_12.
    WA_NODESTAB-TCOLOR1 = C_1.
* Date Range
    WRITE WA_H_ORD-GSTRP TO L_DATE_LOW.
    WRITE WA_H_ORD-GLTRP TO L_DATE_HIGH.
    CONCATENATE L_DATE_LOW C_HYP L_DATE_HIGH INTO WA_NODESTAB-TEXT2
    SEPARATED BY SPACE.
    WA_NODESTAB-TLENGTH2 = C_25.
    WA_NODESTAB-TCOLOR2 = C_1.
* Material Number
    WRITE WA_H_ORD-PLNBEZ TO WA_NODESTAB-TEXT3 NO-ZERO.
    WA_NODESTAB-TLENGTH3 = C_18.
    WA_NODESTAB-TCOLOR3 = C_1.
* Material Description
    WA_NODESTAB-TEXT4 = WA_H_ORD-MAKTX.
    WA_NODESTAB-TLENGTH4 = C_33.
    WA_NODESTAB-TCOLOR4 = C_1.
* Produced Quantity / Confirmed Quantity
    L_PRDQTY = WA_H_ORD-PRDQTY.
    L_PRDUOM = WA_H_ORD-PRDUOM.
* convert to KG?
    IF RB_KGM = C_X AND L_PRDUOM <> 'KG'.
      IF WA_H_ORD-BSUOM <> 'KG'.
        PERFORM CONVERT_TO_KG USING WA_H_ORD-PLNBEZ WA_H_ORD-BSUOM
        WA_H_ORD-GEWEI WA_H_ORD-NTGEW
        WA_H_ORD-BPRDQTY
        CHANGING L_WPRDQTY
        V_CONV_RC.
        IF V_CONV_RC <> 'X'.
          L_PRDQTY = L_WPRDQTY.
          L_PRDUOM = 'KG'.
        ENDIF.
      ELSE.
        L_PRDQTY = WA_H_ORD-BPRDQTY.
        L_PRDUOM = 'KG'.
      ENDIF.
    ENDIF.
    WRITE L_PRDQTY TO L_PRDQ UNIT L_PRDUOM.
    WRITE L_PRDUOM TO L_UOM.
*** text for Order Qty
    IF RB_PLAND = C_X.
** Planned Production
      CONCATENATE 'Plan Qty:'(076) L_PRDQ L_UOM
      INTO WA_NODESTAB-TEXT5 SEPARATED BY SPACE.
    ELSE.
** Actual Production
      IF RB_PROD = C_X.
* Produced
        CONCATENATE 'Prod Qty:'(033) L_PRDQ L_UOM
        INTO WA_NODESTAB-TEXT5 SEPARATED BY SPACE.
      ELSE.
* Confirmed
        CONCATENATE 'Conf Qty:'(034) L_PRDQ L_UOM
        INTO WA_NODESTAB-TEXT5 SEPARATED BY SPACE.
      ENDIF.
    ENDIF.
    CONDENSE : WA_NODESTAB-TEXT5.
    WA_NODESTAB-TLENGTH5 = C_35.
    WA_NODESTAB-TCOLOR5 = C_1.
    APPEND WA_NODESTAB TO I_NODESTAB.
* Resource Information
    CLEAR : WA_NODESTAB , L_EFFIC.
    WA_NODESTAB-ID = C_3_1.
    WA_NODESTAB-TLEVEL = C_3.
    WA_NODESTAB-PARENT = C_2_1.
    WA_NODESTAB-TEXT = 'Resource:'(035).
    WA_NODESTAB-TLENGTH = C_14.
    WA_NODESTAB-TCOLOR = C_4.
    WA_NODESTAB-TEXT1 = WA_H_ORD-BOTLNCK.
    WA_NODESTAB-TLENGTH1 = C_8.
    WA_NODESTAB-TCOLOR1 = C_4.
    WA_NODESTAB-TEXT2 = WA_H_ORD-RESDESC.
    WA_NODESTAB-TLENGTH2 = C_37.
    WA_NODESTAB-TCOLOR2 = C_4.
    L_EFFIC = WA_H_ORD-EL_EFFC.
    CONCATENATE 'Exp. Line Eff.'(036) L_EFFIC C_PERC
    INTO WA_NODESTAB-TEXT3 SEPARATED BY SPACE.
    CONDENSE WA_NODESTAB-TEXT3.
    WA_NODESTAB-TLENGTH3 = C_30.
    WA_NODESTAB-TCOLOR3 = C_4.
    L_EFFIC = WA_H_ORD-AC_EFFC.
    CONCATENATE 'Act. Line Eff.'(037) L_EFFIC C_PERC
    INTO WA_NODESTAB-TEXT4 SEPARATED BY SPACE.
    CONDENSE WA_NODESTAB-TEXT4.
    WA_NODESTAB-TLENGTH4 = C_30.
    WA_NODESTAB-TCOLOR4 = C_4.
    APPEND WA_NODESTAB TO I_NODESTAB.
* Phase Information
    READ TABLE I_H_ACT INTO WA_H_ACT WITH KEY AUFNR = WA_H_ORD-AUFNR.
    IF SY-SUBRC = 0.
      CLEAR : WA_NODESTAB.
      WA_NODESTAB-ID = C_3_2.
      WA_NODESTAB-TLEVEL = C_3.
      WA_NODESTAB-PARENT = C_2_1.
      WA_NODESTAB-TEXT = 'Phase'(038).
      WA_NODESTAB-TLENGTH = C_8.
      WA_NODESTAB-TCOLOR = C_4.
      WA_NODESTAB-TLENGTH1 = C_42.
* wa_nodestab-tcolor1 = c_4.
      IF RB_FISCL = C_X.
        CONCATENATE 'Actual Usage'(040) V_WAERS
        INTO WA_NODESTAB-TEXT2 SEPARATED BY SPACE.
      ELSE.
        CONCATENATE 'Actual Usage'(040) 'UoM'
        INTO WA_NODESTAB-TEXT2 SEPARATED BY SPACE.
      ENDIF.
      WA_NODESTAB-TLENGTH2 = C_20.
      WA_NODESTAB-TCOLOR2 = C_4.
      IF RB_FISCL = C_X.
        CONCATENATE 'Standard Usage'(041) V_WAERS
        INTO WA_NODESTAB-TEXT3 SEPARATED BY SPACE.
      ELSE.
        CONCATENATE 'Standard Usage'(041) 'UoM'
        INTO WA_NODESTAB-TEXT3 SEPARATED BY SPACE.
      ENDIF.
      WA_NODESTAB-TLENGTH3 = C_20.
      WA_NODESTAB-TCOLOR3 = C_4.
      IF RB_FISCL = C_X.
        CONCATENATE 'Standard Usage Var'(042) V_WAERS
        INTO WA_NODESTAB-TEXT4 SEPARATED BY SPACE.
      ELSE.
        CONCATENATE 'Standard Usage Var'(042) 'UoM'
        INTO WA_NODESTAB-TEXT4 SEPARATED BY SPACE.
      ENDIF.
      WA_NODESTAB-TLENGTH4 = C_24.
      WA_NODESTAB-TCOLOR4 = C_4.
      CONCATENATE 'Standard Usage Var'(042) C_PERC
      INTO WA_NODESTAB-TEXT5 SEPARATED BY SPACE.
      WA_NODESTAB-TLENGTH5 = C_20.
      WA_NODESTAB-TCOLOR5 = C_4.
      APPEND WA_NODESTAB TO I_NODESTAB.
*** Activities
      CLEAR : FLG_COLOR, L_ACT , L_STD , L_SVAR , L_SVARP ,
      L_WA_ACT , L_TOTAL1 , L_TOTAL2 , L_APLZL.
      LOOP AT I_H_ACT INTO WA_H_ACT WHERE AUFNR = WA_H_ORD-AUFNR.
        IF L_APLZL <> WA_H_ACT-APLZL.
          CLEAR : WA_AFVC.
          READ TABLE I_H_PHS INTO WA_H_PHS WITH KEY AUFNR =
          WA_H_ACT-AUFNR
          AUFPL =
          WA_H_ACT-AUFPL
          APLZL =
          WA_H_ACT-APLZL.
          L_APLZL = WA_H_ACT-APLZL.
        ENDIF.
        CLEAR WA_NODESTAB.
        WA_NODESTAB-ID = C_4_1.
        WA_NODESTAB-TLEVEL = C_4.
        WA_NODESTAB-PARENT = C_3_2.
        WA_NODESTAB-TEXT = WA_H_ACT-VORNR.
        WA_NODESTAB-TLENGTH = C_4.
        CONCATENATE WA_H_PHS-STEUS WA_H_PHS-ARBPL
        WA_H_ACT-TXTXX INTO WA_NODESTAB-TEXT1
        SEPARATED BY ' '.
        WA_NODESTAB-TLENGTH1 = C_42.
        IF RB_QUANT = C_X.
          WRITE : WA_H_ACT-ISMXX TO L_ACT UNIT WA_H_ACT-ILEXX
          NO-GROUPING,
          WA_H_ACT-ILEXX TO L_UOM.
          CONCATENATE L_ACT L_UOM INTO WA_NODESTAB-TEXT2
          SEPARATED BY SPACE.
          WA_NODESTAB-TLENGTH2 = C_20.
          WRITE : WA_H_ACT-VGWXX TO L_STD UNIT WA_H_ACT-VGEXX
          NO-GROUPING,
          WA_H_ACT-VGEXX TO L_UOM.
          CONCATENATE L_STD L_UOM INTO WA_NODESTAB-TEXT3
          SEPARATED BY SPACE.
          WA_NODESTAB-TLENGTH3 = C_20.
          WRITE : WA_H_ACT-STDVAR TO L_SVAR UNIT WA_H_ACT-VGEXX
          NO-GROUPING,
          WA_H_ACT-VGEXX TO L_UOM.
          CONCATENATE L_SVAR L_UOM INTO WA_NODESTAB-TEXT4
          SEPARATED BY SPACE.
          WA_NODESTAB-TLENGTH4 = C_24.
          IF WA_H_ACT-ISMXX <> 0.
            IF L_TOTAL2 <> C_X.
              L_TOTAL2 = C_X.
              L_WA_ACT-ILEXX = WA_H_ACT-ILEXX.
            ENDIF.
            IF L_WA_ACT-ILEXX = WA_H_ACT-ILEXX.
              L_WA_ACT-ISMXX = L_WA_ACT-ISMXX + WA_H_ACT-ISMXX.
              L_WA_ACT-ILEXX = WA_H_ACT-ILEXX.
            ELSEIF WA_H_ACT-ISMXX <> 0.
              CLEAR : L_WA_ACT-ISMXX , L_WA_ACT-ILEXX.
            ENDIF.
          ENDIF.
          IF WA_H_ACT-VGWXX <> 0.
            IF L_TOTAL1 <> C_X.
              L_TOTAL1 = C_X.
              L_WA_ACT-VGEXX = WA_H_ACT-VGEXX.
            ENDIF.
            IF L_WA_ACT-VGEXX = WA_H_ACT-VGEXX.
              L_WA_ACT-VGWXX = L_WA_ACT-VGWXX + WA_H_ACT-VGWXX.
              L_WA_ACT-STDVAR = L_WA_ACT-STDVAR + WA_H_ACT-STDVAR.
              L_WA_ACT-VGEXX = WA_H_ACT-VGEXX.
            ELSEIF WA_H_ACT-VGWXX <> 0.
              CLEAR : L_WA_ACT-VGWXX , L_WA_ACT-VGEXX, L_WA_ACT-STDVAR.
            ENDIF.
          ENDIF.
          IF WA_H_ACT-VGWXX <> 0.
            WA_H_ACT-VARPER = ( WA_H_ACT-STDVAR / WA_H_ACT-VGWXX ) * 100
            .
          ENDIF.
        ELSE.
          WA_H_ACT-ACTU = WA_H_ACT-ISMXX *
          ( WA_H_ACT-TOGXX / WA_H_ACT-TOEXX ).
          WRITE : WA_H_ACT-ACTU TO L_ACT CURRENCY V_WAERS NO-GROUPING,
          V_WAERS TO L_UOM.
          CONCATENATE L_ACT L_UOM INTO WA_NODESTAB-TEXT2
          SEPARATED BY SPACE.
          WA_NODESTAB-TLENGTH2 = C_20.
          WA_H_ACT-STDU = WA_H_ACT-VGWXX *
          ( WA_H_ACT-TOGXX / WA_H_ACT-TOEXX ).
          WRITE : WA_H_ACT-STDU TO L_STD CURRENCY V_WAERS NO-GROUPING.
          CONCATENATE L_STD L_UOM INTO WA_NODESTAB-TEXT3
          SEPARATED BY SPACE.
          WA_NODESTAB-TLENGTH3 = C_20.
          WA_H_ACT-VARU = WA_H_ACT-STDVAR *
          ( WA_H_ACT-TOGXX / WA_H_ACT-TOEXX ).
          WRITE WA_H_ACT-VARU TO L_SVAR CURRENCY V_WAERS NO-GROUPING.
          CONCATENATE L_SVAR L_UOM INTO WA_NODESTAB-TEXT4
          SEPARATED BY SPACE.
          WA_NODESTAB-TLENGTH4 = C_24.
          L_WA_ACT-ACTU = L_WA_ACT-ACTU + WA_H_ACT-ACTU.
          L_WA_ACT-STDU = L_WA_ACT-STDU + WA_H_ACT-STDU.
          L_WA_ACT-VARU = L_WA_ACT-VARU + WA_H_ACT-VARU.
          IF WA_H_ACT-STDU <> 0.
            WA_H_ACT-VARPER = ( WA_H_ACT-VARU / WA_H_ACT-STDU ) * 100.
          ENDIF.
        ENDIF.
        WRITE WA_H_ACT-VARPER TO L_SVARP NO-GROUPING DECIMALS 2.
        CONCATENATE L_SVARP C_PERC INTO WA_NODESTAB-TEXT5
        SEPARATED BY SPACE.
        WA_NODESTAB-TLENGTH5 = C_20.
        IF FLG_COLOR = C_X.
          CLEAR FLG_COLOR.
          WA_NODESTAB-TCOLOR = C_3.
          WA_NODESTAB-TCOLOR1 = C_3.
          WA_NODESTAB-TCOLOR2 = C_3.
          WA_NODESTAB-TCOLOR3 = C_3.
          WA_NODESTAB-TCOLOR4 = C_3.
          WA_NODESTAB-TCOLOR5 = C_3.
          WA_NODESTAB-TCOLOR6 = C_3.
          WA_NODESTAB-TCOLOR7 = C_3.
          WA_NODESTAB-TCOLOR8 = C_3.
        ELSE.
          FLG_COLOR = C_X.
          WA_NODESTAB-TCOLOR = C_2.
          WA_NODESTAB-TCOLOR1 = C_2.
          WA_NODESTAB-TCOLOR2 = C_2.
          WA_NODESTAB-TCOLOR3 = C_2.
          WA_NODESTAB-TCOLOR4 = C_2.
          WA_NODESTAB-TCOLOR5 = C_2.
          WA_NODESTAB-TCOLOR6 = C_2.
          WA_NODESTAB-TCOLOR7 = C_2.
          WA_NODESTAB-TCOLOR8 = C_2.
        ENDIF.
        APPEND WA_NODESTAB TO I_NODESTAB.
      ENDLOOP.
*** Displaying Activity Subtotals
      CLEAR WA_NODESTAB.
      WA_NODESTAB-ID = C_4_1.
      WA_NODESTAB-TLEVEL = C_4.
      WA_NODESTAB-PARENT = C_3_2.
      WA_NODESTAB-TEXT = 'Activity Totals'(074).
      WA_NODESTAB-TLENGTH = C_20.
      WA_NODESTAB-TCOLOR = C_6.
      WA_NODESTAB-TEXT1 = SPACE.
      WA_NODESTAB-TLENGTH1 = C_26.
      WA_NODESTAB-TCOLOR1 = C_6.
      IF RB_QUANT = C_X.
        WRITE : L_WA_ACT-ISMXX TO L_ACT UNIT L_WA_ACT-ILEXX
        NO-GROUPING,
        L_WA_ACT-VGWXX TO L_STD UNIT L_WA_ACT-VGEXX
        NO-GROUPING,
        L_WA_ACT-STDVAR TO L_SVAR UNIT L_WA_ACT-VGEXX
        NO-GROUPING,
        WA_H_ACT-ILEXX TO L_UOM.
        CONCATENATE L_ACT L_UOM INTO WA_NODESTAB-TEXT2
        SEPARATED BY SPACE.
        WRITE : WA_H_ACT-VGEXX TO L_UOM.
        CONCATENATE L_STD L_UOM INTO WA_NODESTAB-TEXT3
        SEPARATED BY SPACE.
        CONCATENATE L_SVAR L_UOM INTO WA_NODESTAB-TEXT4
        SEPARATED BY SPACE.
      ELSE.
        WRITE : L_WA_ACT-ACTU TO L_ACT CURRENCY V_WAERS NO-GROUPING,
        L_WA_ACT-STDU TO L_STD CURRENCY V_WAERS NO-GROUPING,
        L_WA_ACT-VARU TO L_SVAR CURRENCY V_WAERS NO-GROUPING,
        V_WAERS TO L_UOM.
        CONCATENATE L_ACT L_UOM INTO WA_NODESTAB-TEXT2
        SEPARATED BY SPACE.
        CONCATENATE L_STD L_UOM INTO WA_NODESTAB-TEXT3
        SEPARATED BY SPACE.
        CONCATENATE L_SVAR L_UOM INTO WA_NODESTAB-TEXT4
        SEPARATED BY SPACE.
      ENDIF.
      WA_NODESTAB-TLENGTH2 = C_20.
      WA_NODESTAB-TCOLOR2 = C_6.
      WA_NODESTAB-TLENGTH3 = C_20.
      WA_NODESTAB-TCOLOR3 = C_6.
      WA_NODESTAB-TLENGTH4 = C_24.
      WA_NODESTAB-TCOLOR4 = C_6.
      APPEND WA_NODESTAB TO I_NODESTAB.
      CLEAR : WA_NODESTAB.
    ENDIF.
* Material Information
    READ TABLE I_H_MAT INTO WA_H_MAT WITH KEY AUFNR = WA_H_ORD-AUFNR.
    CHECK SY-SUBRC = 0.
    CLEAR : WA_NODESTAB.
    WA_NODESTAB-ID = C_3_3.
    WA_NODESTAB-TLEVEL = C_3.
    WA_NODESTAB-PARENT = C_2_1.
    PERFORM MATERIAL_HEADER USING WA_NODESTAB.
    APPEND WA_NODESTAB TO I_NODESTAB.
    CLEAR : WA_NODESTAB , L_MENGE , L_STPRS ,
    L_WA_MAT ,
    L_TOTAL1 , L_TOTAL2 , L_TOTAL3 ,
    L_AQTYS , L_SQTYS , L_SVARS .
    LOOP AT I_H_MAT INTO WA_H_MAT WHERE AUFNR = WA_H_ORD-AUFNR.
      L_SMENGE = L_MENGE.
      L_SSTPRS = L_STPRS.
      PERFORM DO_MAT_CALC CHANGING WA_H_MAT
      L_AQTY L_MATUOM
      L_SQTY L_STDUOM
      L_SVAR L_VARUOM
      L_SVARP
      L_AMENGE L_SMENGE
      L_ASTPRS L_SSTPRS.
      L_MENGE = L_MENGE + L_SMENGE.
      L_STPRS = L_STPRS + L_SSTPRS.
      CHECK WA_H_MAT-SUMI = C_X.
      CLEAR: WA_NODESTAB , L_MENGE , L_STPRS.
      WA_NODESTAB-ID = C_4_2.
      WA_NODESTAB-TLEVEL = C_4.
      WA_NODESTAB-PARENT = C_3_3.
* Material Number
      WRITE WA_H_MAT-MATNR TO WA_NODESTAB-TEXT NO-ZERO.
* Material Description
      WA_NODESTAB-TEXT1 = WA_H_MAT-MAKTX.
      WA_NODESTAB-TLENGTH = C_18.
      WA_NODESTAB-TLENGTH1 = C_30.
      WA_NODESTAB-TLENGTH2 = C_22.
      WA_NODESTAB-TLENGTH3 = C_22.
      WA_NODESTAB-TLENGTH4 = C_24.
      WA_NODESTAB-TLENGTH5 = C_20.
      IF L_MATUOM <> V_WAERS.
        WRITE : L_MATUOM TO L_UOM.
      ELSE.
        WRITE : V_WAERS TO L_UOM.
      ENDIF.
      CONCATENATE L_AQTY L_UOM INTO WA_NODESTAB-TEXT2
      SEPARATED BY SPACE.
      IF L_STDUOM <> V_WAERS.
        WRITE : L_STDUOM TO L_UOM.
      ELSE.
        WRITE : V_WAERS TO L_UOM.
      ENDIF.
      CONCATENATE L_SQTY L_UOM INTO WA_NODESTAB-TEXT3
      SEPARATED BY SPACE.
      IF L_VARUOM <> V_WAERS.
        WRITE : L_VARUOM TO L_UOM.
      ELSE.
        WRITE : V_WAERS TO L_UOM.
      ENDIF.
      CONCATENATE L_SVAR L_UOM INTO WA_NODESTAB-TEXT4
      SEPARATED BY SPACE.
      CONCATENATE L_SVARP C_PERC INTO WA_NODESTAB-TEXT5
      SEPARATED BY SPACE.
      WA_NODESTAB-TCOLOR = C_3.
      WA_NODESTAB-TCOLOR1 = C_3.
      WA_NODESTAB-TCOLOR2 = C_3.
      WA_NODESTAB-TCOLOR3 = C_3.
      WA_NODESTAB-TCOLOR4 = C_3.
      WA_NODESTAB-TCOLOR5 = C_3.
      APPEND WA_NODESTAB TO I_NODESTAB.
      CLEAR : WA_NODESTAB.
      IF L_AQTY CA '123456789'.
        IF L_TOTAL1 <> C_X.
          L_TOTAL1 = C_X.
          L_WA_MAT-ACTUOM = L_MATUOM.
        ENDIF.
        IF L_WA_MAT-ACTUOM <> L_MATUOM.
          CLEAR : L_WA_MAT-ACTUSG, L_WA_MAT-ASTPRS, L_WA_MAT-ACTUOM,
          L_AQTYS, L_AMENGE,
          L_WA_MATG-ACTUSG, L_WA_MATG-ASTPRS, L_WA_MATG-ACTUOM,
          L_AQTYG, L_ASTPRS.
        ENDIF.
      ENDIF.
      IF L_SQTY CA '123456789'.
        IF L_TOTAL2 <> C_X.
          L_TOTAL2 = C_X.
          L_WA_MAT-STDUOM = L_STDUOM.
        ENDIF.
        IF L_WA_MAT-STDUOM <> L_STDUOM.
          CLEAR : L_WA_MAT-STDUSG, L_WA_MAT-SSTPRS, L_WA_MAT-STDUOM,
          L_SQTYS, L_SMENGE, L_WA_MATG-STDUSG,
          L_WA_MATG-SSTPRS, L_WA_MATG-STDUOM,
          L_SQTYG, L_SSTPRS.
        ENDIF.
      ENDIF.
      IF L_SVAR CA '123456789'.
        IF L_TOTAL3 <> C_X.
          L_TOTAL3 = C_X.
          L_WA_MAT-VARUOM = L_VARUOM.
        ENDIF.
        IF L_WA_MAT-VARUOM <> L_VARUOM.
          CLEAR : L_WA_MAT-STDVAR , L_WA_MAT-VARPRS , L_WA_MAT-VARUOM ,
          L_SVARS, WA_H_MAT-STDVAR,
          L_WA_MATG-STDVAR, L_WA_MATG-VARPRS , L_WA_MATG-VARUOM,
          L_SVARG, WA_H_MAT-VSTPRS.
        ENDIF.
      ENDIF.
      CASE C_X.
        WHEN RB_QUANT.
          L_WA_MAT-ACTUSG = L_WA_MAT-ACTUSG + L_AMENGE.
          WRITE L_WA_MAT-ACTUSG TO L_AQTYS UNIT L_WA_MAT-ACTUOM
          NO-GROUPING.
          L_WA_MAT-STDUSG = L_WA_MAT-STDUSG + L_SMENGE.
          WRITE L_WA_MAT-STDUSG TO L_SQTYS UNIT L_WA_MAT-STDUOM
          NO-GROUPING.
          L_WA_MAT-STDVAR = L_WA_MAT-STDVAR + WA_H_MAT-STDVAR.
          WRITE : L_WA_MAT-STDVAR TO L_SVARS UNIT L_WA_MAT-STDUOM
          NO-GROUPING.
        WHEN RB_FISCL.
          L_WA_MAT-ASTPRS = L_WA_MAT-ASTPRS + L_ASTPRS.
          V_PRS = L_WA_MAT-ASTPRS.
          WRITE V_PRS TO L_AQTYS CURRENCY V_WAERS NO-GROUPING.
          L_WA_MAT-VARPRS = L_WA_MAT-VARPRS + WA_H_MAT-VSTPRS.
          V_PRS = L_WA_MAT-VARPRS.
          WRITE V_PRS TO L_SVARS CURRENCY V_WAERS NO-GROUPING.
          L_WA_MAT-SSTPRS = L_WA_MAT-SSTPRS + L_SSTPRS.
          V_PRS = L_WA_MAT-SSTPRS.
          WRITE V_PRS TO L_SQTYS CURRENCY V_WAERS NO-GROUPING.
      ENDCASE.
    ENDLOOP.
*** Displaying Material Subtotals
    CLEAR WA_NODESTAB.
    WA_NODESTAB-ID = C_4_2.
    WA_NODESTAB-TLEVEL = C_4.
    WA_NODESTAB-PARENT = C_3_3.
    WA_NODESTAB-TEXT = 'Material Totals'(043).
    WA_NODESTAB-TEXT1 = SPACE.
    WA_NODESTAB-TLENGTH = C_18.
    WA_NODESTAB-TLENGTH1 = C_30.
    WA_NODESTAB-TLENGTH2 = C_22.
    WA_NODESTAB-TLENGTH3 = C_22.
    WA_NODESTAB-TLENGTH4 = C_24.
    IF L_WA_MAT-ACTUOM <> V_WAERS.
      WRITE : L_WA_MAT-ACTUOM TO L_UOM.
    ELSE.
      WRITE : V_WAERS TO L_UOM.
    ENDIF.
    CONCATENATE L_AQTYS L_UOM INTO WA_NODESTAB-TEXT2
    SEPARATED BY SPACE.
    IF L_WA_MAT-STDUOM <> V_WAERS.
      WRITE : L_WA_MAT-STDUOM TO L_UOM.
    ELSE.
      WRITE : V_WAERS TO L_UOM.
    ENDIF.
    CONCATENATE L_SQTYS L_UOM INTO WA_NODESTAB-TEXT3
    SEPARATED BY SPACE.
    IF L_WA_MAT-VARUOM <> V_WAERS.
      WRITE : L_WA_MAT-VARUOM TO L_UOM.
    ELSE.
      WRITE : V_WAERS TO L_UOM.
    ENDIF.
    CONCATENATE L_SVARS L_UOM INTO WA_NODESTAB-TEXT4
    SEPARATED BY SPACE.
    WA_NODESTAB-TCOLOR = C_6.
    WA_NODESTAB-TCOLOR1 = C_6.
    WA_NODESTAB-TCOLOR2 = C_6.
    WA_NODESTAB-TCOLOR3 = C_6.
    WA_NODESTAB-TCOLOR4 = C_6.
    APPEND WA_NODESTAB TO I_NODESTAB.
    CLEAR : WA_NODESTAB.
    IF L_AQTYS CA '123456789'.
      IF L_TOTALG1 <> C_X.
        L_TOTALG1 = C_X.
        L_WA_MATG-ACTUOM = L_WA_MAT-ACTUOM.
      ENDIF.
      IF L_WA_MATG-ACTUOM <> L_WA_MAT-ACTUOM.
        CLEAR : L_WA_MATG-ACTUSG , L_WA_MATG-ASTPRS , L_WA_MATG-ACTUOM,
        L_AQTYG, L_WA_MAT-ACTUSG, L_WA_MAT-ASTPRS.
      ENDIF.
    ENDIF.
    IF L_SQTYS CA '123456789'.
      IF L_TOTALG2 <> C_X.
        L_TOTALG2 = C_X.
        L_WA_MATG-STDUOM = L_WA_MAT-STDUOM.
      ENDIF.
      IF L_WA_MATG-STDUOM <> L_WA_MAT-STDUOM.
        CLEAR : L_WA_MATG-STDUSG , L_WA_MATG-STDUOM , L_WA_MATG-SSTPRS ,
        L_SQTYG, L_WA_MAT-STDUSG, L_WA_MAT-SSTPRS.
      ENDIF.
    ENDIF.
    IF L_SVARS CA '123456789'.
      IF L_TOTALG3 <> C_X.
        L_TOTALG3 = C_X.
        L_WA_MATG-VARUOM = L_WA_MAT-VARUOM.
      ENDIF.
      IF L_WA_MATG-VARUOM <> L_WA_MAT-VARUOM.
        CLEAR : L_WA_MATG-STDVAR, L_WA_MATG-VARPRS , L_WA_MATG-VARUOM,
        L_SVARG, L_WA_MAT-STDVAR, L_WA_MAT-VARPRS.
      ENDIF.
    ENDIF.
    CASE C_X.
      WHEN RB_QUANT.
        L_WA_MATG-ACTUSG = L_WA_MATG-ACTUSG + L_WA_MAT-ACTUSG.
        WRITE : L_WA_MATG-ACTUSG TO L_AQTYG UNIT L_WA_MAT-ACTUOM
        NO-GROUPING.
        L_WA_MATG-STDUSG = L_WA_MATG-STDUSG + L_WA_MAT-STDUSG.
        WRITE : L_WA_MATG-STDUSG TO L_SQTYG UNIT L_WA_MAT-STDUOM
        NO-GROUPING.
        L_WA_MATG-STDVAR = L_WA_MATG-STDVAR + L_WA_MAT-STDVAR.
        WRITE : L_WA_MATG-STDVAR TO L_SVARG UNIT L_WA_MAT-VARUOM
        NO-GROUPING.
      WHEN RB_FISCL.
        L_WA_MATG-ASTPRS = L_WA_MATG-ASTPRS + L_WA_MAT-ASTPRS
        + L_WA_ACT-ACTU.
* + l_wa_act-actu * 10. "NEEL++ 13/07/2005++
        V_PRS = L_WA_MATG-ASTPRS.
        WRITE V_PRS TO L_AQTYG CURRENCY V_WAERS NO-GROUPING.
        L_WA_MATG-SSTPRS = L_WA_MATG-SSTPRS + L_WA_MAT-SSTPRS
        + L_WA_ACT-STDU.
* + l_wa_act-stdu * 10. "NEEL++ 13/07/2005++
        V_PRS = L_WA_MATG-SSTPRS.
        WRITE V_PRS TO L_SQTYG CURRENCY V_WAERS NO-GROUPING.
        L_WA_MATG-VARPRS = L_WA_MATG-VARPRS + L_WA_MAT-VARPRS
        + L_WA_ACT-VARU.
* + l_wa_act-varu * 10. "NEEL++ 13/07/2005++
        V_PRS = L_WA_MATG-VARPRS.
        WRITE V_PRS TO L_SVARG CURRENCY V_WAERS NO-GROUPING.
    ENDCASE.
    CLEAR : L_SQTYS , L_AQTYS , L_SVARS.
*** Displaying Grand Total
    AT LAST.
      CLEAR WA_NODESTAB.
      WA_NODESTAB-ID = C_2_2.
      WA_NODESTAB-TLEVEL = C_2.
      WA_NODESTAB-PARENT = C_1_1.
      WA_NODESTAB-TEXT = 'Process Order Totals'(044).
      WA_NODESTAB-TEXT1 = SPACE.
      WA_NODESTAB-TLENGTH = C_26.
      WA_NODESTAB-TLENGTH1 = C_30.
      WA_NODESTAB-TLENGTH2 = C_22.
      WA_NODESTAB-TLENGTH3 = C_22.
      WA_NODESTAB-TLENGTH4 = C_24.
      IF L_WA_MATG-ACTUOM <> V_WAERS.
        WRITE : L_WA_MATG-ACTUOM TO L_UOM.
      ELSE.
        WRITE : V_WAERS TO L_UOM.
      ENDIF.
      CONCATENATE L_AQTYG L_UOM INTO WA_NODESTAB-TEXT2
      SEPARATED BY SPACE.
      IF L_WA_MATG-STDUOM <> V_WAERS.
        WRITE : L_WA_MATG-STDUOM TO L_UOM.
      ELSE.
        WRITE : V_WAERS TO L_UOM.
      ENDIF.
      CONCATENATE L_SQTYG L_UOM INTO WA_NODESTAB-TEXT3
      SEPARATED BY SPACE.
      IF L_WA_MATG-VARUOM <> V_WAERS.
        WRITE : L_WA_MATG-VARUOM TO L_UOM.
      ELSE.
        WRITE : V_WAERS TO L_UOM.
      ENDIF.
      CONCATENATE L_SVARG L_UOM INTO WA_NODESTAB-TEXT4
      SEPARATED BY SPACE.
      WA_NODESTAB-TCOLOR = C_5.
      WA_NODESTAB-TCOLOR1 = C_5.
      WA_NODESTAB-TCOLOR2 = C_5.
      WA_NODESTAB-TCOLOR3 = C_5.
      WA_NODESTAB-TCOLOR4 = C_5.
      APPEND WA_NODESTAB TO I_NODESTAB.
    ENDAT.
  ENDLOOP.
ENDFORM. " DISPLAY_DETAIL_REPORT
*&--------------------------------------------------------------------*
*& Form display_phase_report
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM DISPLAY_PHASE_REPORT.
  DATA: L_DATE_LOW(10) TYPE C,
  L_DATE_HIGH(10) TYPE C,
  L_EFFIC TYPE CHAR16,
  L_ARBPL TYPE ARBPL,
  L_PRDQTY TYPE GAMNG,
  L_PRDQ TYPE CHAR18,
  L_WPRDQTY TYPE MENGE_D,
  L_PRDUOM TYPE MEINS,
  L_ACT TYPE CHAR16,
  L_STD TYPE CHAR16,
  L_AMENGE TYPE MENGE_D,
  L_SMENGE TYPE MENGE_D,
  L_MENGE TYPE MENGE_D,
  L_AQTY TYPE CHAR18,
  L_SQTY TYPE CHAR18,
  L_SVAR TYPE CHAR18,
  L_SVARP TYPE CHAR18,
  L_AQTYS TYPE CHAR18,
  L_SQTYS TYPE CHAR18,
  L_SVARS TYPE CHAR18,
  L_MATUOM TYPE MEINS,
  L_STDUOM TYPE MEINS,
  L_VARUOM TYPE MEINS,
  L_UOM TYPE MEINS,
  L_ASTPRS TYPE TY_STPRS,
  L_SSTPRS TYPE TY_STPRS,
  L_STPRS TYPE TY_STPRS,
  L_TOTAL1 TYPE CHAR1,
  L_TOTAL2 TYPE CHAR1,
  L_TOTAL3 TYPE CHAR1,
  L_WA_ACT TYPE TY_HIER_ACT,
  L_WA_MAT TYPE TY_HIER_MAT_SUM,
  L_WA_PHS TYPE TY_HIER_PHASE,
  L_I_PHS TYPE STANDARD TABLE OF TY_HIER_PHASE.
  PERFORM PFSTATUS.
  SET PF-STATUS 'MAIN' EXCLUDING I_FCODE.
  SET TITLEBAR 'VARI' WITH TEXT-068.
  L_I_PHS = I_H_PHS.
  SORT I_H_PHS BY AUFNR ARBPL VORNR.
  CLEAR WA_NODESTAB.
  REFRESH I_NODESTAB.
  MOVE 'Display Phase Report'(030) TO V_OUTPUT_TEXT.
  PERFORM INFORM_USER_OF_PROGRESS.
  CLEAR WA_NODESTAB.
  WA_NODESTAB-ID = C_1_1.
  WA_NODESTAB-TLEVEL = C_1.
  WA_NODESTAB-TEXT = 'Production Variances'(031).
  WA_NODESTAB-TLENGTH = C_20.
  WA_NODESTAB-COMPRESS = C_X.
  APPEND WA_NODESTAB TO I_NODESTAB.
  LOOP AT I_H_ORD INTO WA_H_ORD.
    CLEAR: WA_NODESTAB, L_DATE_LOW, L_DATE_HIGH.
    WA_NODESTAB-ID = C_2_1.
    WA_NODESTAB-TLEVEL = C_2.
    WA_NODESTAB-PARENT = C_1_1.
* Order Number text
    WA_NODESTAB-TEXT = 'Order Num:'(032).
    WA_NODESTAB-TLENGTH = C_12.
    WA_NODESTAB-TCOLOR = C_1.
* Order number
    WRITE WA_H_ORD-AUFNR TO WA_NODESTAB-TEXT1 NO-ZERO.
    WA_NODESTAB-TLENGTH1 = C_12.
    WA_NODESTAB-TCOLOR1 = C_1.
* Date Range
    WRITE WA_H_ORD-GSTRP TO L_DATE_LOW.
    WRITE WA_H_ORD-GLTRP TO L_DATE_HIGH.
    CONCATENATE L_DATE_LOW C_HYP L_DATE_HIGH INTO WA_NODESTAB-TEXT2
    SEPARATED BY SPACE.
    WA_NODESTAB-TLENGTH2 = C_25.
    WA_NODESTAB-TCOLOR2 = C_1.
* Material Number
    WRITE WA_H_ORD-PLNBEZ TO WA_NODESTAB-TEXT3 NO-ZERO.
    WA_NODESTAB-TLENGTH3 = C_18.
    WA_NODESTAB-TCOLOR3 = C_1.
* Material Description
    WA_NODESTAB-TEXT4 = WA_H_ORD-MAKTX.
    WA_NODESTAB-TLENGTH4 = C_33.
    WA_NODESTAB-TCOLOR4 = C_1.
    APPEND WA_NODESTAB TO I_NODESTAB.
    CLEAR : L_AQTYS, L_SQTYS, L_SVARS, L_ARBPL.
    LOOP AT I_H_PHS INTO WA_H_PHS WHERE AUFNR = WA_H_ORD-AUFNR.
      L_WA_PHS = WA_H_PHS.
      IF L_ARBPL <> WA_H_PHS-ARBPL.
        CLEAR : WA_H_PHS.
        READ TABLE I_H_PHS INTO WA_H_PHS WITH KEY AUFNR = WA_H_ORD-AUFNR
        ARBPL = L_WA_PHS-ARBPL
        STEUS = 'YBN1'
        RUNTIME = C_X.
* Resource Information
        CLEAR : WA_NODESTAB.
        WA_NODESTAB-ID = C_3_1.
        WA_NODESTAB-TLEVEL = C_3.
        WA_NODESTAB-PARENT = C_2_1.
        WA_NODESTAB-TEXT = 'Resource:'(035).
        WA_NODESTAB-TLENGTH = C_14.
        WA_NODESTAB-TCOLOR = C_4.
        WA_NODESTAB-TEXT1 = L_WA_PHS-ARBPL.
        WA_NODESTAB-TLENGTH1 = C_8.
        WA_NODESTAB-TCOLOR1 = C_4.
        WA_NODESTAB-TEXT2 = L_WA_PHS-KTEXT.
        WA_NODESTAB-TLENGTH2 = C_37.
        WA_NODESTAB-TCOLOR2 = C_4.
        IF L_WA_PHS-STEUS = 'YBN1'.
          L_EFFIC = WA_H_PHS-EL_EFFC.
          CONCATENATE 'Exp. Line Eff.'(036) L_EFFIC C_PERC
          INTO WA_NODESTAB-TEXT3 SEPARATED BY SPACE.
          CONDENSE WA_NODESTAB-TEXT3.
          WA_NODESTAB-TLENGTH3 = C_30.
          WA_NODESTAB-TCOLOR3 = C_4.
          L_EFFIC = WA_H_PHS-AC_EFFC.
          CONCATENATE 'Act. Line Eff.'(037) L_EFFIC C_PERC
          INTO WA_NODESTAB-TEXT4 SEPARATED BY SPACE.
          CONDENSE WA_NODESTAB-TEXT4.
          WA_NODESTAB-TLENGTH4 = C_30.
          WA_NODESTAB-TCOLOR4 = C_4.
        ENDIF.
        APPEND WA_NODESTAB TO I_NODESTAB.
        L_ARBPL = L_WA_PHS-ARBPL.
        WA_H_PHS = L_WA_PHS.
      ENDIF.
      CLEAR : WA_NODESTAB.
      WA_NODESTAB-ID = C_4_1.
      WA_NODESTAB-TLEVEL = C_4.
      WA_NODESTAB-PARENT = C_3_1.
** Phase Number
      WA_NODESTAB-TEXT = 'Phase'(038).
      WA_NODESTAB-TLENGTH = C_10.
      WA_NODESTAB-TCOLOR = C_4.
      CONCATENATE WA_H_PHS-VORNR WA_H_PHS-STEUS
      WA_H_PHS-LTXA1
      INTO WA_NODESTAB-TEXT1
      SEPARATED BY SPACE.
      WA_NODESTAB-TLENGTH1 = C_40.
      WA_NODESTAB-TCOLOR1 = C_4.
** PO Quantity
* l_prdqty = wa_h_phs-lmnga.
      L_PRDQTY = WA_H_PHS-PRDQTY.
      L_PRDUOM = WA_H_PHS-PRDUOM.
      IF RB_KGM = C_X AND L_PRDUOM <> 'KG'.
        IF WA_H_PHS-BSUOM <> 'KG'.
          PERFORM CONVERT_TO_KG USING WA_H_ORD-PLNBEZ WA_H_PHS-BSUOM
          WA_H_PHS-GEWEI WA_H_PHS-NTGEW
          WA_H_PHS-BPRDQTY
          CHANGING L_WPRDQTY
          V_CONV_RC.
          IF V_CONV_RC <> 'X'.
            L_PRDQTY = L_WPRDQTY.
            L_PRDUOM = 'KG'.
          ENDIF.
        ELSE.
          L_PRDQTY = WA_H_PHS-BPRDQTY.
          L_PRDUOM = 'KG'.
        ENDIF.
      ENDIF.
      WRITE : L_PRDQTY TO L_PRDQ UNIT L_PRDUOM NO-GROUPING,
      L_PRDUOM TO L_UOM.
*** text for Order Qty
      IF RB_PLAND = C_X.
** Planned Production
        CONCATENATE 'Plan Qty:'(076) L_PRDQ L_UOM
        INTO WA_NODESTAB-TEXT2 SEPARATED BY SPACE.
      ELSE.
** Actual Production
        IF RB_PROD = C_X.
* Produced
          CONCATENATE 'Prod Qty:'(033) L_PRDQ L_UOM
          INTO WA_NODESTAB-TEXT2 SEPARATED BY SPACE.
        ELSE.
* Confirmed
          CONCATENATE 'Conf Qty:'(034) L_PRDQ L_UOM
          INTO WA_NODESTAB-TEXT2 SEPARATED BY SPACE.
        ENDIF.
      ENDIF.
      CONDENSE : WA_NODESTAB-TEXT2.
      WA_NODESTAB-TLENGTH2 = 32.
      WA_NODESTAB-TCOLOR2 = C_4.
      APPEND WA_NODESTAB TO I_NODESTAB.
***
*** Activity Information
***
      CLEAR WA_NODESTAB.
      WA_NODESTAB-ID = C_5_1.
      WA_NODESTAB-TLEVEL = C_5.
      WA_NODESTAB-PARENT = C_4_1.
      WA_NODESTAB-TEXT = 'Activity'(052).
      WA_NODESTAB-TLENGTH = 34.
      WA_NODESTAB-TEXT1 = 'Actual Usage'(040).
      WA_NODESTAB-TLENGTH1 = C_20.
      WA_NODESTAB-TEXT2 = 'Standard Usage'(041).
      WA_NODESTAB-TLENGTH2 = C_20.
      IF RB_FISCL = C_X.
        CONCATENATE 'Standard Usage Var'(042) V_WAERS
        INTO WA_NODESTAB-TEXT3 SEPARATED BY SPACE.
      ELSE.
        CONCATENATE 'Standard Usage Var'(042) 'UoM'
        INTO WA_NODESTAB-TEXT3 SEPARATED BY SPACE.
      ENDIF.
      WA_NODESTAB-TLENGTH3 = C_24.
      CONCATENATE 'Standard Usage Var'(042) C_PERC
      INTO WA_NODESTAB-TEXT4 SEPARATED BY SPACE.
      WA_NODESTAB-TLENGTH4 = C_20.
      WA_NODESTAB-TCOLOR = C_4.
      WA_NODESTAB-TCOLOR1 = C_4.
      WA_NODESTAB-TCOLOR2 = C_4.
      WA_NODESTAB-TCOLOR3 = C_4.
      WA_NODESTAB-TCOLOR4 = C_4.
      APPEND WA_NODESTAB TO I_NODESTAB.
      CLEAR : FLG_COLOR , L_ACT , L_STD , L_SVAR , L_SVARP , L_WA_ACT,
      L_TOTAL1 , L_TOTAL2.
      LOOP AT I_H_ACT INTO WA_H_ACT WHERE AUFNR = WA_H_PHS-AUFNR
      AND AUFPL = WA_H_PHS-AUFPL
      AND APLZL = WA_H_PHS-APLZL
      AND VORNR = WA_H_PHS-VORNR.
        CLEAR : WA_NODESTAB.
        WA_NODESTAB-ID = C_6_1.
        WA_NODESTAB-TLEVEL = C_6.
        WA_NODESTAB-PARENT = C_5_1.
        WA_NODESTAB-TEXT = WA_H_ACT-TXTXX.
        WA_NODESTAB-TLENGTH = C_30.
        WA_NODESTAB-TLENGTH1 = C_20.
        WA_NODESTAB-TLENGTH2 = C_20.
        WA_NODESTAB-TLENGTH3 = C_24.
        WA_NODESTAB-TLENGTH4 = C_20.
        IF RB_QUANT = C_X.
          WRITE : WA_H_ACT-ISMXX TO L_ACT UNIT WA_H_ACT-ILEXX
          NO-GROUPING,
          WA_H_ACT-ILEXX TO L_UOM.
          CONCATENATE L_ACT L_UOM INTO WA_NODESTAB-TEXT1
          SEPARATED BY SPACE.
          WRITE : WA_H_ACT-VGWXX TO L_STD UNIT WA_H_ACT-VGEXX
          NO-GROUPING,
          WA_H_ACT-VGEXX TO L_UOM.
          CONCATENATE L_STD L_UOM INTO WA_NODESTAB-TEXT2
          SEPARATED BY SPACE.
          WRITE WA_H_ACT-STDVAR TO L_SVAR UNIT WA_H_ACT-VGEXX
          NO-GROUPING.
          CONCATENATE L_SVAR L_UOM INTO WA_NODESTAB-TEXT3
          SEPARATED BY SPACE.
          IF WA_H_ACT-ISMXX <> 0.
            IF L_TOTAL2 <> C_X.
              L_TOTAL2 = C_X.
              L_WA_ACT-ILEXX = WA_H_ACT-ILEXX.
            ENDIF.
            IF L_WA_ACT-ILEXX = WA_H_ACT-ILEXX.
              L_WA_ACT-ISMXX = L_WA_ACT-ISMXX + WA_H_ACT-ISMXX.
              L_WA_ACT-ILEXX = WA_H_ACT-ILEXX.
            ELSEIF WA_H_ACT-ISMXX <> 0.
              CLEAR : L_WA_ACT-ISMXX , L_WA_ACT-ILEXX.
            ENDIF.
          ENDIF.
          IF WA_H_ACT-VGWXX <> 0.
            IF L_TOTAL1 <> C_X.
              L_TOTAL1 = C_X.
              L_WA_ACT-VGEXX = WA_H_ACT-VGEXX.
            ENDIF.
            IF L_WA_ACT-VGEXX = WA_H_ACT-VGEXX.
              L_WA_ACT-VGWXX = L_WA_ACT-VGWXX + WA_H_ACT-VGWXX.
              L_WA_ACT-STDVAR = L_WA_ACT-STDVAR + WA_H_ACT-STDVAR.
              L_WA_ACT-VGEXX = WA_H_ACT-VGEXX.
            ELSEIF WA_H_ACT-VGWXX <> 0.
              CLEAR : L_WA_ACT-VGWXX , L_WA_ACT-VGEXX, L_WA_ACT-STDVAR.
            ENDIF.
          ENDIF.
          IF WA_H_ACT-VGWXX <> 0.
            WA_H_ACT-VARPER = ( WA_H_ACT-STDVAR / WA_H_ACT-VGWXX ) * 100
            .
          ENDIF.
        ELSE.
          WA_H_ACT-ACTU = WA_H_ACT-ISMXX * ( WA_H_ACT-TOGXX /
          WA_H_ACT-TOEXX ).
          WRITE : WA_H_ACT-ACTU TO L_ACT CURRENCY V_WAERS NO-GROUPING,
          V_WAERS TO L_UOM.
          CONCATENATE L_ACT L_UOM INTO WA_NODESTAB-TEXT1
          SEPARATED BY SPACE.
          WA_H_ACT-STDU = WA_H_ACT-VGWXX *
          ( WA_H_ACT-TOGXX / WA_H_ACT-TOEXX ).
          WRITE WA_H_ACT-STDU TO L_STD CURRENCY V_WAERS NO-GROUPING.
          CONCATENATE L_STD L_UOM INTO WA_NODESTAB-TEXT2
          SEPARATED BY SPACE.
          WA_H_ACT-VARU = WA_H_ACT-STDVAR *
          ( WA_H_ACT-TOGXX / WA_H_ACT-TOEXX ).
          WRITE WA_H_ACT-VARU TO L_SVAR CURRENCY V_WAERS NO-GROUPING.
          CONCATENATE L_SVAR L_UOM INTO WA_NODESTAB-TEXT3
          SEPARATED BY SPACE.
          IF WA_H_ACT-STDU <> 0.
            WA_H_ACT-VARPER = ( WA_H_ACT-VARU / WA_H_ACT-STDU ) * 100.
          ENDIF.
          L_WA_ACT-ACTU = L_WA_ACT-ACTU + WA_H_ACT-ACTU.
          L_WA_ACT-STDU = L_WA_ACT-STDU + WA_H_ACT-STDU.
          L_WA_ACT-VARU = L_WA_ACT-VARU + WA_H_ACT-VARU.
        ENDIF.
        WRITE WA_H_ACT-VARPER TO L_SVARP NO-GROUPING DECIMALS 2.
        CONCATENATE L_SVARP C_PERC INTO WA_NODESTAB-TEXT4
        SEPARATED BY SPACE.
        IF FLG_COLOR = C_X.
          CLEAR FLG_COLOR.
          WA_NODESTAB-TCOLOR = C_3.
          WA_NODESTAB-TCOLOR1 = C_3.
          WA_NODESTAB-TCOLOR2 = C_3.
          WA_NODESTAB-TCOLOR3 = C_3.
          WA_NODESTAB-TCOLOR4 = C_3.
          WA_NODESTAB-TCOLOR5 = C_3.
          WA_NODESTAB-TCOLOR6 = C_3.
          WA_NODESTAB-TCOLOR7 = C_3.
          WA_NODESTAB-TCOLOR8 = C_3.
        ELSE.
          FLG_COLOR = C_X.
          WA_NODESTAB-TCOLOR = C_2.
          WA_NODESTAB-TCOLOR1 = C_2.
          WA_NODESTAB-TCOLOR2 = C_2.
          WA_NODESTAB-TCOLOR3 = C_2.
          WA_NODESTAB-TCOLOR4 = C_2.
          WA_NODESTAB-TCOLOR5 = C_2.
          WA_NODESTAB-TCOLOR6 = C_2.
          WA_NODESTAB-TCOLOR7 = C_2.
          WA_NODESTAB-TCOLOR8 = C_2.
        ENDIF.
        APPEND WA_NODESTAB TO I_NODESTAB.
      ENDLOOP.
*** Displaying Activity Subtotals
      CLEAR WA_NODESTAB.
      WA_NODESTAB-ID = C_6_1.
      WA_NODESTAB-TLEVEL = C_6.
      WA_NODESTAB-PARENT = C_5_1.
      WA_NODESTAB-TEXT = 'Activity Totals'(074).
      WA_NODESTAB-TLENGTH = C_30.
      WA_NODESTAB-TCOLOR = C_6.
      IF RB_QUANT = C_X.
        WRITE : L_WA_ACT-ISMXX TO L_ACT UNIT L_WA_ACT-ILEXX NO-GROUPING,
        L_WA_ACT-ILEXX TO L_UOM.
        CONCATENATE L_ACT L_UOM INTO WA_NODESTAB-TEXT1
        SEPARATED BY SPACE.
        WRITE : L_WA_ACT-VGWXX TO L_STD UNIT L_WA_ACT-VGEXX NO-GROUPING,
        L_WA_ACT-VGEXX TO L_UOM.
        CONCATENATE L_STD L_UOM INTO WA_NODESTAB-TEXT2
        SEPARATED BY SPACE.
        WRITE : L_WA_ACT-STDVAR TO L_SVAR UNIT L_WA_ACT-VGEXX
        NO-GROUPING.
        CONCATENATE L_SVAR L_UOM INTO WA_NODESTAB-TEXT3
        SEPARATED BY SPACE.
      ELSE.
        WRITE : L_WA_ACT-ACTU TO L_ACT CURRENCY V_WAERS NO-GROUPING,
        V_WAERS TO L_UOM.
        CONCATENATE L_ACT L_UOM INTO WA_NODESTAB-TEXT1
        SEPARATED BY SPACE.
        WRITE : L_WA_ACT-STDU TO L_STD CURRENCY V_WAERS NO-GROUPING.
        CONCATENATE L_STD L_UOM INTO WA_NODESTAB-TEXT2
        SEPARATED BY SPACE.
        WRITE : L_WA_ACT-VARU TO L_SVAR UNIT L_WA_ACT-VGEXX NO-GROUPING.
        CONCATENATE L_SVAR L_UOM INTO WA_NODESTAB-TEXT3
        SEPARATED BY SPACE.
      ENDIF.
      WA_NODESTAB-TLENGTH1 = C_20.
      WA_NODESTAB-TLENGTH2 = C_20.
      WA_NODESTAB-TLENGTH3 = C_24.
      WA_NODESTAB-TCOLOR1 = C_6.
      WA_NODESTAB-TCOLOR2 = C_6.
      WA_NODESTAB-TCOLOR3 = C_6.
      APPEND WA_NODESTAB TO I_NODESTAB.
      CLEAR : WA_NODESTAB.
***
*** Material Information
***
      READ TABLE I_H_MAT INTO WA_H_MAT WITH KEY AUFNR = WA_H_PHS-AUFNR
      AUFPL = WA_H_PHS-AUFPL
      APLZL = WA_H_PHS-APLZL
      VORNR = WA_H_PHS-VORNR.
      CHECK SY-SUBRC = 0.
      CLEAR : WA_NODESTAB.
      WA_NODESTAB-ID = C_5_2.
      WA_NODESTAB-TLEVEL = C_5.
      WA_NODESTAB-PARENT = C_4_1.
      PERFORM MATERIAL_HEADER USING WA_NODESTAB.
      APPEND WA_NODESTAB TO I_NODESTAB.
      CLEAR : WA_NODESTAB , L_MENGE , L_STPRS ,
      L_TOTAL1 , L_TOTAL2 , L_TOTAL3 ,
      L_WA_MAT , L_AQTYS , L_SQTYS , L_SVARS.
      LOOP AT I_H_MAT INTO WA_H_MAT WHERE AUFNR = WA_H_PHS-AUFNR
      AND AUFPL = WA_H_PHS-AUFPL
      AND APLZL = WA_H_PHS-APLZL
      AND VORNR = WA_H_PHS-VORNR.
        L_SMENGE = L_MENGE.
        L_SSTPRS = L_STPRS.
        PERFORM DO_MAT_CALC CHANGING WA_H_MAT
        L_AQTY L_MATUOM
        L_SQTY L_STDUOM
        L_SVAR L_VARUOM
        L_SVARP
        L_AMENGE L_SMENGE
        L_ASTPRS L_SSTPRS.
        L_MENGE = L_MENGE + L_SMENGE.
        L_STPRS = L_STPRS + L_SSTPRS.
        CHECK WA_H_MAT-SUMI = C_X.
        CLEAR: WA_NODESTAB , L_MENGE , L_STPRS.
        WA_NODESTAB-ID = C_6_2.
        WA_NODESTAB-TLEVEL = C_6.
        WA_NODESTAB-PARENT = C_5_2.
* Material Number
        WRITE WA_H_MAT-MATNR TO WA_NODESTAB-TEXT NO-ZERO.
* Material Description
        WA_NODESTAB-TEXT1 = WA_H_MAT-MAKTX.
        WA_NODESTAB-TLENGTH = C_18.
        WA_NODESTAB-TLENGTH1 = C_30.
        WA_NODESTAB-TLENGTH2 = C_22.
        WA_NODESTAB-TLENGTH3 = C_22.
        WA_NODESTAB-TLENGTH4 = C_24.
        WA_NODESTAB-TLENGTH5 = C_20.
        IF L_MATUOM <> V_WAERS.
          WRITE : L_MATUOM TO L_UOM.
        ELSE.
          WRITE : V_WAERS TO L_UOM.
        ENDIF.
        CONCATENATE L_AQTY L_UOM INTO WA_NODESTAB-TEXT2
        SEPARATED BY SPACE.
        IF L_STDUOM <> V_WAERS.
          WRITE : L_STDUOM TO L_UOM.
        ELSE.
          WRITE : V_WAERS TO L_UOM.
        ENDIF.
        CONCATENATE L_SQTY L_UOM INTO WA_NODESTAB-TEXT3
        SEPARATED BY SPACE.
        IF L_VARUOM <> V_WAERS.
          WRITE : L_VARUOM TO L_UOM.
        ELSE.
          WRITE : V_WAERS TO L_UOM.
        ENDIF.
        CONCATENATE L_SVAR L_UOM INTO WA_NODESTAB-TEXT4
        SEPARATED BY SPACE.
        CONCATENATE L_SVARP C_PERC INTO WA_NODESTAB-TEXT5
        SEPARATED BY SPACE.
        WA_NODESTAB-TCOLOR = C_3.
        WA_NODESTAB-TCOLOR1 = C_3.
        WA_NODESTAB-TCOLOR2 = C_3.
        WA_NODESTAB-TCOLOR3 = C_3.
        WA_NODESTAB-TCOLOR4 = C_3.
        WA_NODESTAB-TCOLOR5 = C_3.
        APPEND WA_NODESTAB TO I_NODESTAB.
        IF L_AQTY CA '123456789'.
          IF L_TOTAL1 <> C_X.
            L_TOTAL1 = C_X.
            L_WA_MAT-ACTUOM = L_MATUOM.
          ENDIF.
          IF L_WA_MAT-ACTUOM <> L_MATUOM.
            CLEAR : L_WA_MAT-ACTUSG , L_WA_MAT-ASTPRS , L_WA_MAT-ACTUOM,
            L_AQTYS, L_AMENGE , L_ASTPRS.
          ENDIF.
        ENDIF.
        IF L_SQTY CA '123456789'.
          IF L_TOTAL2 <> C_X.
            L_TOTAL2 = C_X.
            L_WA_MAT-STDUOM = L_STDUOM.
          ENDIF.
          IF L_WA_MAT-STDUOM <> L_STDUOM.
            CLEAR : L_WA_MAT-STDUSG , L_WA_MAT-SSTPRS ,
            L_WA_MAT-STDUOM ,
            L_SQTYS, L_SMENGE , L_SSTPRS.
          ENDIF.
        ENDIF.
        IF L_SVAR CA '123456789'.
          IF L_TOTAL3 <> C_X.
            L_TOTAL3 = C_X.
            L_WA_MAT-VARUOM = L_VARUOM.
          ENDIF.
          IF L_WA_MAT-VARUOM <> L_VARUOM.
            CLEAR : L_WA_MAT-STDVAR, L_WA_MAT-VARPRS , L_WA_MAT-VARUOM,
            L_SVARS, WA_H_MAT-VSTPRS , WA_H_MAT-STDVAR.
          ENDIF.
        ENDIF.
        CASE C_X.
          WHEN RB_QUANT.
            L_WA_MAT-ACTUSG = L_WA_MAT-ACTUSG + L_AMENGE.
            WRITE L_WA_MAT-ACTUSG TO L_AQTYS UNIT L_WA_MAT-ACTUOM
            NO-GROUPING.
            L_WA_MAT-STDUSG = L_WA_MAT-STDUSG + L_SMENGE.
            WRITE L_WA_MAT-STDUSG TO L_SQTYS UNIT L_WA_MAT-STDUOM
            NO-GROUPING.
            L_WA_MAT-STDVAR = L_WA_MAT-STDVAR + WA_H_MAT-STDVAR.
            WRITE : L_WA_MAT-STDVAR TO L_SVARS UNIT L_WA_MAT-STDUOM
            NO-GROUPING.
          WHEN RB_FISCL.
            L_WA_MAT-ASTPRS = L_WA_MAT-ASTPRS + L_ASTPRS.
            V_PRS = L_WA_MAT-ASTPRS.
            WRITE V_PRS TO L_AQTYS CURRENCY V_WAERS NO-GROUPING.
            L_WA_MAT-SSTPRS = L_WA_MAT-SSTPRS + L_SSTPRS.
            V_PRS = L_WA_MAT-SSTPRS.
            WRITE V_PRS TO L_SQTYS CURRENCY V_WAERS NO-GROUPING.
            L_WA_MAT-VARPRS = L_WA_MAT-VARPRS + WA_H_MAT-VSTPRS.
            V_PRS = L_WA_MAT-VARPRS.
            WRITE V_PRS TO L_SVARS CURRENCY V_WAERS NO-GROUPING.
        ENDCASE.
      ENDLOOP.
*** Displaying Material Subtotals
      CLEAR WA_NODESTAB.
      WA_NODESTAB-ID = C_6_2.
      WA_NODESTAB-TLEVEL = C_6.
      WA_NODESTAB-PARENT = C_5_2.
      WA_NODESTAB-TEXT = 'Material Totals'(043).
      WA_NODESTAB-TEXT1 = SPACE.
      WA_NODESTAB-TLENGTH = C_18.
      WA_NODESTAB-TLENGTH1 = C_30.
      WA_NODESTAB-TLENGTH2 = C_22.
      WA_NODESTAB-TLENGTH3 = C_22.
      WA_NODESTAB-TLENGTH4 = C_24.
      IF L_WA_MAT-ACTUOM <> V_WAERS.
        WRITE : L_WA_MAT-ACTUOM TO L_UOM.
      ELSE.
        WRITE : V_WAERS TO L_UOM.
      ENDIF.
      CONCATENATE L_AQTYS L_UOM INTO WA_NODESTAB-TEXT2
      SEPARATED BY SPACE.
      IF L_WA_MAT-STDUOM <> V_WAERS.
        WRITE : L_WA_MAT-STDUOM TO L_UOM.
      ELSE.
        WRITE : V_WAERS TO L_UOM.
      ENDIF.
      CONCATENATE L_SQTYS L_UOM INTO WA_NODESTAB-TEXT3
      SEPARATED BY SPACE.
      IF L_WA_MAT-VARUOM <> V_WAERS.
        WRITE : L_WA_MAT-VARUOM TO L_UOM.
      ELSE.
        WRITE : V_WAERS TO L_UOM.
      ENDIF.
      CONCATENATE L_SVARS L_UOM INTO WA_NODESTAB-TEXT4
      SEPARATED BY SPACE.
      WA_NODESTAB-TCOLOR = C_6.
      WA_NODESTAB-TCOLOR1 = C_6.
      WA_NODESTAB-TCOLOR2 = C_6.
      WA_NODESTAB-TCOLOR3 = C_6.
      WA_NODESTAB-TCOLOR4 = C_6.
      APPEND WA_NODESTAB TO I_NODESTAB.
      CLEAR : WA_NODESTAB, L_AQTYS, L_SQTYS, L_SVARS.
    ENDLOOP.
  ENDLOOP.
  I_H_PHS = L_I_PHS.
ENDFORM. " DISPLAY_PHASE_REPORT
*&--------------------------------------------------------------------*
*& Form display_summary_report
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM DISPLAY_SUMMARY_REPORT.
  DATA: L_PRDQTY TYPE GAMNG,
  L_PRDQ TYPE CHAR18,
  L_WPRDQTY TYPE MENGE_D,
  L_TPRDQTY TYPE MENGE_D,
  L_PRDUOM TYPE MEINS,
  L_ACT TYPE CHAR16,
  L_STD TYPE CHAR16,
  L_ACTT TYPE CHAR16,
  L_STDT TYPE CHAR16,
  L_SVART TYPE CHAR18,
  L_AMENGE TYPE MENGE_D,
  L_SMENGE TYPE MENGE_D,
  L_MENGE TYPE MENGE_D,
  L_ASTPRS TYPE TY_STPRS,
  L_SSTPRS TYPE TY_STPRS,
  L_STPRS TYPE TY_STPRS,
  L_STPRSQ TYPE TY_STPRS,
  L_VARPRSQ TYPE TY_STPRS,
  L_MATUOM TYPE MEINS,
  L_STDUOM TYPE MEINS,
  L_VARUOM TYPE MEINS,
  L_UOM TYPE MEINS,
  L_AQTY TYPE CHAR18,
  L_SQTY TYPE CHAR18,
  L_SVAR TYPE CHAR18,
  L_SVARP TYPE CHAR18,
  L_SVARQ TYPE CHAR18,
  L_AQTYV TYPE CHAR18,
  L_SQTYV TYPE CHAR18,
  L_SVARV TYPE CHAR18,
  L_SVARPV TYPE CHAR18,
  L_AQTYG TYPE CHAR18,
  L_SQTYG TYPE CHAR18,
  L_SVARG TYPE CHAR18,
  L_SVARGQ TYPE CHAR18,
  L_AQTYS TYPE CHAR18,
  L_SQTYS TYPE CHAR18,
  L_SVARS TYPE CHAR18,
  L_TOTAL1 TYPE CHAR1,
  L_TOTAL2 TYPE CHAR1,
  L_TOTAL3 TYPE CHAR1,
  L_TOTALG1 TYPE CHAR1,
  L_TOTALG2 TYPE CHAR1,
  L_TOTALG3 TYPE CHAR1,
  L_WA_ACTS TYPE TY_HIER_ACT_SUM,
  L_WA_MATS TYPE TY_HIER_MAT_SUM.
  PERFORM PFSTATUS.
  SET PF-STATUS 'MAIN' EXCLUDING I_FCODE.
  SET TITLEBAR 'VARI' WITH TEXT-067.
  REFRESH : I_NODESTAB.
  MOVE 'Display Summary Report'(029) TO V_OUTPUT_TEXT.
  PERFORM INFORM_USER_OF_PROGRESS.
  CLEAR WA_NODESTAB.
  WA_NODESTAB-ID = C_1_1.
  WA_NODESTAB-TLEVEL = C_1.
  WA_NODESTAB-TEXT = 'Production Variances'(031).
  WA_NODESTAB-TLENGTH = C_20.
  WA_NODESTAB-COMPRESS = C_X.
  APPEND WA_NODESTAB TO I_NODESTAB.
  CLEAR: WA_NODESTAB.
  WA_NODESTAB-ID = C_2_1.
  WA_NODESTAB-TLEVEL = C_2.
  WA_NODESTAB-PARENT = C_1_1.
  CONCATENATE 'Summary of Orders for'(046) 'Plant:'(047) P_WERKS
  INTO WA_NODESTAB-TEXT SEPARATED BY SPACE.
  WA_NODESTAB-TLENGTH = C_45.
  WA_NODESTAB-TCOLOR = C_1.
  IF R_STEUS IS INITIAL.
    WA_NODESTAB-TEXT1 = 'Control Key : ALL'(075).
  ELSE.
    CLEAR : WA_STEUS.
    READ TABLE R_STEUS INTO WA_STEUS INDEX 1.
    CONCATENATE 'Control Key:'(048) WA_STEUS-LOW 'TO' WA_STEUS-HIGH
    INTO WA_NODESTAB-TEXT1 SEPARATED BY SPACE.
  ENDIF.
  WA_NODESTAB-TLENGTH1 = C_25.
  WA_NODESTAB-TCOLOR1 = C_1.
  IF S_ARBPL[] IS INITIAL.
    WA_NODESTAB-TEXT2 = 'Resources: All'(049).
  ELSE.
    CONCATENATE 'Resources:'(065) S_ARBPL-LOW C_HYP S_ARBPL-HIGH
    INTO WA_NODESTAB-TEXT2 SEPARATED BY SPACE.
  ENDIF.
  WA_NODESTAB-TLENGTH2 = C_25.
  WA_NODESTAB-TCOLOR2 = C_1.
  APPEND WA_NODESTAB TO I_NODESTAB.
  CLEAR : L_TPRDQTY.
  LOOP AT I_H_ORD INTO WA_H_ORD.
* convert to KG
    CLEAR : L_WPRDQTY.
    IF WA_H_ORD-BSUOM <> 'KG'.
      PERFORM CONVERT_TO_KG USING WA_H_ORD-PLNBEZ WA_H_ORD-BSUOM
      WA_H_ORD-GEWEI WA_H_ORD-NTGEW
      WA_H_ORD-BPRDQTY
      CHANGING L_WPRDQTY
      V_CONV_RC.
      IF V_CONV_RC <> 'X'.
        L_PRDQTY = L_WPRDQTY.
        L_PRDUOM = 'KG'.
      ELSE.
        CLEAR : L_WPRDQTY.
      ENDIF.
    ELSE.
      L_PRDQTY = WA_H_ORD-BPRDQTY.
      L_PRDUOM = 'KG'.
    ENDIF.
    L_TPRDQTY = L_TPRDQTY + L_PRDQTY.
  ENDLOOP.
  WRITE : L_TPRDQTY TO L_PRDQ UNIT 'KG' NO-GROUPING.
  CLEAR : WA_NODESTAB.
  WA_NODESTAB-ID = C_3_1.
  WA_NODESTAB-TLEVEL = C_3.
  WA_NODESTAB-PARENT = C_2_1.
*** text for Order Qty
  IF RB_PLAND = C_X.
** Planned Production
    CONCATENATE 'Plan Qty:'(076) L_PRDQ 'KG'
    INTO WA_NODESTAB-TEXT SEPARATED BY SPACE.
  ELSE.
** Actual Production
    IF RB_PROD = C_X.
* Produced
      CONCATENATE 'Prod Qty:'(033) L_PRDQ 'KG'
      INTO WA_NODESTAB-TEXT SEPARATED BY SPACE.
    ELSE.
* Confirmed
      CONCATENATE 'Conf Qty:'(034) L_PRDQ 'KG'
      INTO WA_NODESTAB-TEXT SEPARATED BY SPACE.
    ENDIF.
  ENDIF.
  CONDENSE : WA_NODESTAB-TEXT.
  WA_NODESTAB-TLENGTH = C_35.
  WA_NODESTAB-TCOLOR = C_1.
  APPEND WA_NODESTAB TO I_NODESTAB.
***
*** Activity Summary
***
  CLEAR : WA_NODESTAB.
  WA_NODESTAB-ID = C_3_2.
  WA_NODESTAB-TLEVEL = C_3.
  WA_NODESTAB-PARENT = C_2_1.
  WA_NODESTAB-TEXT = 'Activity'(052).
  WA_NODESTAB-TLENGTH = 34.
  WA_NODESTAB-TLENGTH1 = C_20.
  WA_NODESTAB-TLENGTH2 = C_20.
  WA_NODESTAB-TLENGTH3 = C_24.
  WA_NODESTAB-TLENGTH4 = C_20.
  IF RB_FISCL = C_X.
    CONCATENATE 'Actual Usage'(040) V_WAERS
    INTO WA_NODESTAB-TEXT1 SEPARATED BY SPACE.
    CONCATENATE 'Standard Usage'(041) V_WAERS
    INTO WA_NODESTAB-TEXT2 SEPARATED BY SPACE.
    CONCATENATE 'Standard Usage Var'(042) V_WAERS
    INTO WA_NODESTAB-TEXT3 SEPARATED BY SPACE.
  ELSE.
    CONCATENATE 'Actual Usage'(040) 'UoM'
    INTO WA_NODESTAB-TEXT1 SEPARATED BY SPACE.
    CONCATENATE 'Standard Usage'(041) 'UoM'
    INTO WA_NODESTAB-TEXT2 SEPARATED BY SPACE.
    CONCATENATE 'Standard Usage Var'(042) 'UoM'
    INTO WA_NODESTAB-TEXT3 SEPARATED BY SPACE.
  ENDIF.
  CONCATENATE 'Standard Usage Var'(042) C_PERC
  INTO WA_NODESTAB-TEXT4 SEPARATED BY SPACE.
  WA_NODESTAB-TCOLOR = C_4.
  WA_NODESTAB-TCOLOR1 = C_4.
  WA_NODESTAB-TCOLOR2 = C_4.
  WA_NODESTAB-TCOLOR3 = C_4.
  WA_NODESTAB-TCOLOR4 = C_4.
  APPEND WA_NODESTAB TO I_NODESTAB.
  CLEAR : FLG_COLOR , L_ACTT , L_STDT , L_SVART , L_SVARP,
  L_WA_ACTS.
  LOOP AT I_PARN INTO WA_PARN.
    CLEAR : WA_ACTS, FLG_COLOR , L_ACT , L_STD , L_SVAR , L_SVARP.
    LOOP AT I_H_ACT INTO WA_H_ACT WHERE PARXX = WA_PARN-PARXX.
      WA_ACTS-PARXX = WA_H_ACT-PARXX.
      WA_ACTS-TXTXX = WA_H_ACT-TXTXX.
      IF RB_QUANT EQ C_X.
        WA_ACTS-ILEXX = WA_H_ACT-ILEXX.
        WA_ACTS-ISMXX = WA_ACTS-ISMXX + WA_H_ACT-ISMXX.
        WA_ACTS-VGEXX = WA_H_ACT-VGEXX.
        WA_ACTS-VGWXX = WA_ACTS-VGWXX + WA_H_ACT-VGWXX.
        WA_ACTS-STDVAR = WA_ACTS-STDVAR + WA_H_ACT-STDVAR.
        IF WA_ACTS-ILEXX IS INITIAL AND NOT WA_ACTS-VGEXX IS INITIAL.
          WA_ACTS-ILEXX = WA_ACTS-VGEXX.
        ELSEIF NOT WA_ACTS-ILEXX IS INITIAL AND
        WA_ACTS-VGEXX IS INITIAL.
          WA_ACTS-VGEXX = WA_ACTS-ILEXX.
        ENDIF.
      ELSE.
        IF WA_H_ACT-TOEXX <> 0.
          WA_ACTS-ACTU = WA_ACTS-ACTU + WA_H_ACT-ISMXX *
          ( WA_H_ACT-TOGXX / WA_H_ACT-TOEXX ).
          WA_ACTS-STDU = WA_ACTS-STDU + WA_H_ACT-VGWXX *
          ( WA_H_ACT-TOGXX / WA_H_ACT-TOEXX ).
          WA_ACTS-VARU = WA_ACTS-VARU + WA_H_ACT-STDVAR *
          ( WA_H_ACT-TOGXX / WA_H_ACT-TOEXX ).
        ENDIF.
      ENDIF.
    ENDLOOP.
    CLEAR : WA_NODESTAB.
    WA_NODESTAB-ID = C_4_1.
    WA_NODESTAB-TLEVEL = C_4.
    WA_NODESTAB-PARENT = C_3_2.
    WA_NODESTAB-TEXT = WA_ACTS-TXTXX.
    WA_NODESTAB-TLENGTH = C_30.
    WA_NODESTAB-TLENGTH1 = C_20.
    WA_NODESTAB-TLENGTH2 = C_20.
    WA_NODESTAB-TLENGTH3 = C_24.
    WA_NODESTAB-TLENGTH4 = C_20.
    IF RB_QUANT = C_X.
      WRITE : WA_ACTS-ISMXX TO L_ACT UNIT WA_ACTS-ILEXX NO-GROUPING,
      WA_ACTS-ILEXX TO L_UOM.
      CONCATENATE L_ACT L_UOM INTO WA_NODESTAB-TEXT1
      SEPARATED BY SPACE.
      WRITE : WA_ACTS-VGWXX TO L_STD UNIT WA_ACTS-VGEXX NO-GROUPING,
      WA_ACTS-VGEXX TO L_UOM.
      CONCATENATE L_STD L_UOM INTO WA_NODESTAB-TEXT2
      SEPARATED BY SPACE.
      WRITE : WA_ACTS-STDVAR TO L_SVAR UNIT WA_ACTS-VGEXX NO-GROUPING.
      CONCATENATE L_SVAR L_UOM INTO WA_NODESTAB-TEXT3
      SEPARATED BY SPACE.
      IF WA_ACTS-VGWXX <> 0.
        WA_ACTS-VARPER = ( WA_ACTS-STDVAR / WA_ACTS-VGWXX ) * 100.
      ENDIF.
      WRITE WA_ACTS-VARPER TO L_SVARP DECIMALS 2 NO-GROUPING.
      CONCATENATE L_SVARP C_PERC INTO WA_NODESTAB-TEXT4
      SEPARATED BY SPACE.
      IF WA_ACTS-ISMXX <> 0.
        IF L_TOTAL2 <> C_X.
          L_TOTAL2 = C_X.
          L_WA_ACTS-ILEXX = WA_ACTS-ILEXX.
        ENDIF.
        IF L_WA_ACTS-ILEXX = WA_ACTS-ILEXX AND NOT L_WA_ACTS-ILEXX IS
        INITIAL.
          L_WA_ACTS-ISMXX = L_WA_ACTS-ISMXX + WA_ACTS-ISMXX.
          L_WA_ACTS-ILEXX = WA_ACTS-ILEXX.
        ELSEIF WA_ACTS-ISMXX <> 0.
          CLEAR : L_WA_ACTS-ISMXX , L_WA_ACTS-ILEXX, L_ACTT.
        ENDIF.
      ENDIF.
      IF WA_ACTS-VGWXX <> 0.
        IF L_TOTAL1 <> C_X.
          L_TOTAL1 = C_X.
          L_WA_ACTS-VGEXX = WA_ACTS-VGEXX.
        ENDIF.
        IF L_WA_ACTS-VGEXX = WA_ACTS-VGEXX AND NOT L_WA_ACTS-VGEXX IS
        INITIAL.
          L_WA_ACTS-VGWXX = L_WA_ACTS-VGWXX + WA_ACTS-VGWXX.
          L_WA_ACTS-STDVAR = L_WA_ACTS-STDVAR + WA_ACTS-STDVAR.
          L_WA_ACTS-VGEXX = WA_ACTS-VGEXX.
        ELSEIF WA_ACTS-VGWXX <> 0.
          CLEAR : L_WA_ACTS-VGWXX , L_WA_ACTS-VGEXX, L_WA_ACTS-STDVAR,
          L_STDT, L_SVART.
        ENDIF.
      ENDIF.
      WRITE L_WA_ACTS-ISMXX TO L_ACTT UNIT L_WA_ACTS-ILEXX NO-GROUPING
      .
      WRITE L_WA_ACTS-VGWXX TO L_STDT UNIT L_WA_ACTS-VGEXX NO-GROUPING
      .
      WRITE L_WA_ACTS-STDVAR TO L_SVART UNIT L_WA_ACTS-VGEXX NO-GROUPING
      .
    ELSE.
      WRITE : WA_ACTS-ACTU TO L_ACT CURRENCY V_WAERS NO-GROUPING.
* l_act = wa_acts-actu.
      CONCATENATE L_ACT V_WAERS INTO WA_NODESTAB-TEXT1
      SEPARATED BY SPACE.
      WRITE : WA_ACTS-STDU TO L_STD CURRENCY V_WAERS NO-GROUPING.
* l_std = wa_acts-stdu.
      CONCATENATE L_STD V_WAERS INTO WA_NODESTAB-TEXT2
      SEPARATED BY SPACE.
      WRITE : WA_ACTS-VARU TO L_SVAR CURRENCY V_WAERS NO-GROUPING.
* l_svar = wa_acts-varu.
      CONCATENATE L_SVAR V_WAERS INTO WA_NODESTAB-TEXT3
      SEPARATED BY SPACE.
      IF WA_ACTS-STDU <> 0.
        WA_ACTS-VARPER = ( WA_ACTS-VARU / WA_ACTS-STDU ) * 100.
      ENDIF.
      L_SVARP = WA_ACTS-VARPER.
      CONCATENATE L_SVARP C_PERC INTO WA_NODESTAB-TEXT4
      SEPARATED BY SPACE.
      L_WA_ACTS-ACTU = L_WA_ACTS-ACTU + WA_ACTS-ACTU.
      L_WA_ACTS-STDU = L_WA_ACTS-STDU + WA_ACTS-STDU.
      L_WA_ACTS-VARU = L_WA_ACTS-VARU + WA_ACTS-VARU.
      WRITE L_WA_ACTS-ACTU TO L_ACTT CURRENCY V_WAERS NO-GROUPING.
      WRITE L_WA_ACTS-STDU TO L_STDT CURRENCY V_WAERS NO-GROUPING.
      WRITE L_WA_ACTS-VARU TO L_SVART CURRENCY V_WAERS NO-GROUPING.
      L_WA_ACTS-ILEXX = V_WAERS.
      L_WA_ACTS-VGEXX = V_WAERS.
    ENDIF.
    IF FLG_COLOR = C_X.
      CLEAR FLG_COLOR.
      WA_NODESTAB-TCOLOR = C_3.
      WA_NODESTAB-TCOLOR1 = C_3.
      WA_NODESTAB-TCOLOR2 = C_3.
      WA_NODESTAB-TCOLOR3 = C_3.
      WA_NODESTAB-TCOLOR4 = C_3.
    ELSE.
      FLG_COLOR = C_X.
      WA_NODESTAB-TCOLOR = C_2.
      WA_NODESTAB-TCOLOR1 = C_2.
      WA_NODESTAB-TCOLOR2 = C_2.
      WA_NODESTAB-TCOLOR3 = C_2.
      WA_NODESTAB-TCOLOR4 = C_2.
    ENDIF.
    APPEND WA_NODESTAB TO I_NODESTAB.
  ENDLOOP.
* Displaying Activity Subtotals
  CLEAR WA_NODESTAB.
  WA_NODESTAB-ID = C_4_1.
  WA_NODESTAB-TLEVEL = C_4.
  WA_NODESTAB-PARENT = C_3_2.
  WA_NODESTAB-TEXT = 'Activity Totals'(074).
  WA_NODESTAB-TLENGTH = C_30.
  WA_NODESTAB-TLENGTH1 = C_20.
  WA_NODESTAB-TLENGTH2 = C_20.
  WA_NODESTAB-TLENGTH3 = C_24.
  IF L_WA_ACTS-ILEXX <> V_WAERS.
    WRITE : L_WA_ACTS-ILEXX TO L_UOM.
  ELSE.
    WRITE : V_WAERS TO L_UOM.
  ENDIF.
  CONCATENATE L_ACTT L_UOM INTO WA_NODESTAB-TEXT1
  SEPARATED BY SPACE.
  IF L_WA_ACTS-VGEXX <> V_WAERS.
    WRITE : L_WA_ACTS-VGEXX TO L_UOM.
  ELSE.
    WRITE : V_WAERS TO L_UOM.
  ENDIF.
  CONCATENATE L_STDT L_UOM INTO WA_NODESTAB-TEXT2
  SEPARATED BY SPACE.
  CONCATENATE L_SVART L_UOM INTO WA_NODESTAB-TEXT3
  SEPARATED BY SPACE.
  WA_NODESTAB-TCOLOR = C_6.
  WA_NODESTAB-TCOLOR1 = C_6.
  WA_NODESTAB-TCOLOR2 = C_6.
  WA_NODESTAB-TCOLOR3 = C_6.
  APPEND WA_NODESTAB TO I_NODESTAB.
  CLEAR : WA_NODESTAB.
***
*** Material Information
***
  READ TABLE I_H_MAT INTO WA_H_MAT INDEX 1.
  IF SY-SUBRC = 0.
    CLEAR : WA_NODESTAB.
    WA_NODESTAB-ID = C_3_3.
    WA_NODESTAB-TLEVEL = C_3.
    WA_NODESTAB-PARENT = C_2_1.
    PERFORM MATERIAL_HEADER USING WA_NODESTAB.
    APPEND WA_NODESTAB TO I_NODESTAB.
    CLEAR : WA_NODESTAB , L_AMENGE , L_SMENGE , L_WA_MATS,
    L_TOTALG1 , L_TOTALG2 , L_TOTALG3 ,
    L_SQTYG , L_AQTYG , L_SVARG ,
    L_SVARGQ , L_STPRSQ.
    LOOP AT I_MATN INTO WA_MATN.
      CLEAR : WA_MATS , L_SQTY , L_AQTY , L_SVAR , L_SVARP,
      L_SVARQ , L_VARPRSQ,
      L_TOTAL1 , L_TOTAL2 , L_TOTAL3, L_MENGE , L_STPRS.
      LOOP AT I_H_MAT INTO WA_H_MAT WHERE MATNR = WA_MATN-MATNR
      AND BWART = WA_MATN-BWART.
        "28/06/2005++
        CLEAR : L_AMENGE , L_ASTPRS , L_SMENGE , L_SSTPRS.
        L_SSTPRS = L_STPRS.
        L_SMENGE = L_MENGE.
        PERFORM DO_MAT_CALC CHANGING WA_H_MAT
        L_AQTYV L_MATUOM
        L_SQTYV L_STDUOM
        L_SVARV L_VARUOM
        L_SVARPV
        L_AMENGE L_SMENGE
        L_ASTPRS L_SSTPRS.
        L_STPRS = L_STPRS + L_SSTPRS.
        L_MENGE = L_MENGE + L_SMENGE.
        CHECK WA_H_MAT-SUMI = C_X.
        CLEAR : L_MENGE , L_STPRS.
        IF RB_QUANT EQ C_X.
          IF L_MATUOM IS INITIAL OR L_MATUOM EQ L_STDUOM.
            WA_H_MAT-STDVAR = L_SMENGE - L_AMENGE.
          ENDIF.
          IF L_AMENGE <> 0.
            IF L_TOTAL1 <> C_X.
              L_TOTAL1 = C_X.
              WA_MATS-ACTUOM = L_MATUOM.
            ENDIF.
            IF WA_MATS-ACTUOM = L_MATUOM.
              WA_MATS-ACTUSG = WA_MATS-ACTUSG + L_AMENGE.
            ELSE.
              CLEAR : WA_MATS-ACTUSG , WA_MATS-ACTUOM, L_AQTY ,
              WA_MATS-ACTUOM.
            ENDIF.
          ENDIF.
          IF L_SMENGE <> 0.
            IF L_TOTAL2 <> C_X.
              L_TOTAL2 = C_X.
              WA_MATS-STDUOM = L_STDUOM.
            ENDIF.
            IF WA_MATS-STDUOM = L_STDUOM.
              WA_MATS-STDUSG = WA_MATS-STDUSG + L_SMENGE.
            ELSE.
              CLEAR : WA_MATS-STDUSG , WA_MATS-STDUOM, L_SQTY ,
              WA_MATS-STDUOM.
            ENDIF.
          ENDIF.
          IF WA_H_MAT-STDVAR <> 0.
            IF L_TOTAL3 <> C_X.
              L_TOTAL3 = C_X.
              WA_MATS-VARUOM = L_STDUOM.
            ENDIF.
            IF WA_MATS-VARUOM = L_STDUOM.
              WA_MATS-STDVAR = WA_MATS-STDVAR + WA_H_MAT-STDVAR.
            ELSE.
              CLEAR : WA_MATS-STDVAR, WA_MATS-VARUOM, L_SVAR.
            ENDIF.
          ENDIF.
          WRITE : WA_MATS-ACTUSG TO L_AQTY UNIT WA_MATS-ACTUOM
          NO-GROUPING.
          WRITE : WA_MATS-STDUSG TO L_SQTY UNIT WA_MATS-STDUOM
          NO-GROUPING.
          WRITE : WA_MATS-STDVAR TO L_SVAR UNIT WA_MATS-STDUOM
          NO-GROUPING.
          WA_MATS-ASTPRS = WA_MATS-ASTPRS + L_ASTPRS.
          WA_MATS-SSTPRS = WA_MATS-SSTPRS + L_SSTPRS.
          WA_MATS-VARPRS = WA_MATS-VARPRS + L_SSTPRS - L_ASTPRS.
          V_PRS = WA_MATS-VARPRS.
          WRITE : V_PRS TO L_SVARQ CURRENCY V_WAERS NO-GROUPING.
        ELSE.
          WA_MATS-ASTPRS = WA_MATS-ASTPRS + L_ASTPRS.
          WA_MATS-SSTPRS = WA_MATS-SSTPRS + L_SSTPRS.
          WA_MATS-VARPRS = WA_MATS-VARPRS + L_SSTPRS - L_ASTPRS.
          WA_MATS-ACTUOM = V_WAERS.
          WA_MATS-STDUOM = V_WAERS.
          WA_MATS-VARUOM = V_WAERS.
          V_PRS = WA_MATS-ASTPRS.
          WRITE : V_PRS TO L_AQTY CURRENCY V_WAERS NO-GROUPING.
          V_PRS = WA_MATS-SSTPRS.
          WRITE : V_PRS TO L_SQTY CURRENCY V_WAERS NO-GROUPING.
          V_PRS = WA_MATS-VARPRS.
          WRITE : V_PRS TO L_SVAR CURRENCY V_WAERS NO-GROUPING.
        ENDIF.
        WA_MATS-MATNR = WA_H_MAT-MATNR.
        WA_MATS-MAKTX = WA_H_MAT-MAKTX.
        L_VARPRSQ = WA_MATS-VARPRS.
      ENDLOOP.
      IF WA_MATS-STDUOM = WA_MATS-ACTUOM OR WA_MATS-ACTUOM IS INITIAL.
        CASE C_X.
          WHEN RB_QUANT.
            IF WA_MATS-STDUSG > 0.
              WA_MATS-VARPER = ( WA_MATS-STDVAR / WA_MATS-STDUSG ) *
              100.
            ELSE.
              WA_MATS-VARPER = 0.
            ENDIF.
          WHEN RB_FISCL.
            IF WA_MATS-SSTPRS > 0.
              WA_MATS-VARPER = ( WA_MATS-VARPRS / WA_MATS-SSTPRS ) *
              100.
            ELSE.
              WA_MATS-VARPER = 0.
            ENDIF.
        ENDCASE.
      ENDIF.
      WRITE WA_MATS-VARPER TO L_SVARP DECIMALS 2 NO-GROUPING.
      IF L_AQTY CA '123456789'.
        IF L_TOTALG1 <> C_X.
          L_TOTALG1 = C_X.
          L_WA_MATS-ACTUOM = WA_MATS-ACTUOM.
        ENDIF.
        IF L_WA_MATS-ACTUOM <> WA_MATS-ACTUOM.
          CLEAR : L_WA_MATS-ACTUSG , L_WA_MATS-ASTPRS , L_AQTYG ,
          L_WA_MATS-ACTUOM , WA_MATS-ACTUSG , WA_MATS-ASTPRS.
        ENDIF.
      ENDIF.
      IF L_SQTY CA '123456789'.
        IF L_TOTALG2 <> C_X.
          L_TOTALG2 = C_X.
          L_WA_MATS-STDUOM = WA_MATS-STDUOM.
        ENDIF.
        IF L_WA_MATS-STDUOM <> WA_MATS-STDUOM.
          CLEAR : L_WA_MATS-STDUSG , L_WA_MATS-SSTPRS , L_SQTYG ,
          L_WA_MATS-STDUOM , WA_MATS-STDUSG , WA_MATS-SSTPRS .
        ENDIF.
      ENDIF.
      IF L_SVAR CA '123456789'.
        IF L_TOTALG3 <> C_X.
          L_TOTALG3 = C_X.
          L_WA_MATS-VARUOM = WA_MATS-VARUOM.
        ENDIF.
        IF L_WA_MATS-VARUOM <> WA_MATS-VARUOM.
          CLEAR : L_WA_MATS-STDVAR, L_WA_MATS-VARPRS , L_SVARG ,
          L_WA_MATS-VARUOM, WA_MATS-STDVAR , WA_MATS-VARPRS.
        ENDIF.
      ENDIF.
      CASE C_X.
        WHEN RB_QUANT.
          L_WA_MATS-ACTUSG = L_WA_MATS-ACTUSG + WA_MATS-ACTUSG.
          WRITE : L_WA_MATS-ACTUSG TO L_AQTYG UNIT L_WA_MATS-ACTUOM
          NO-GROUPING.
          L_WA_MATS-STDUSG = L_WA_MATS-STDUSG + WA_MATS-STDUSG.
          WRITE : L_WA_MATS-STDUSG TO L_SQTYG UNIT L_WA_MATS-STDUOM
          NO-GROUPING.
          L_WA_MATS-STDVAR = L_WA_MATS-STDVAR + WA_MATS-STDVAR.
          WRITE : L_WA_MATS-STDVAR TO L_SVARG UNIT L_WA_MATS-VARUOM
          NO-GROUPING.
          L_STPRSQ = L_STPRSQ + L_VARPRSQ.
          V_PRS = L_STPRSQ.
          WRITE : V_PRS TO L_SVARGQ CURRENCY V_WAERS NO-GROUPING.
        WHEN RB_FISCL.
          L_WA_MATS-ASTPRS = L_WA_MATS-ASTPRS + WA_MATS-ASTPRS.
          V_PRS = L_WA_MATS-ASTPRS.
          WRITE : V_PRS TO L_AQTYG CURRENCY V_WAERS NO-GROUPING.
          L_WA_MATS-SSTPRS = L_WA_MATS-SSTPRS + WA_MATS-SSTPRS.
          V_PRS = L_WA_MATS-SSTPRS.
          WRITE : V_PRS TO L_SQTYG CURRENCY V_WAERS NO-GROUPING.
          L_WA_MATS-VARPRS = L_WA_MATS-VARPRS + WA_MATS-VARPRS.
          V_PRS = L_WA_MATS-VARPRS.
          WRITE : V_PRS TO L_SVARG CURRENCY V_WAERS NO-GROUPING.
      ENDCASE.
      CLEAR: WA_NODESTAB.
      WA_NODESTAB-ID = C_4_2.
      WA_NODESTAB-TLEVEL = C_4.
      WA_NODESTAB-PARENT = C_3_3.
      WA_NODESTAB-TCOLOR = C_3.
      WA_NODESTAB-TCOLOR1 = C_3.
      WA_NODESTAB-TCOLOR2 = C_3.
      WA_NODESTAB-TCOLOR3 = C_3.
      WA_NODESTAB-TCOLOR4 = C_3.
      WA_NODESTAB-TCOLOR5 = C_3.
      WA_NODESTAB-TLENGTH = C_18.
      WA_NODESTAB-TLENGTH1 = C_30.
      WA_NODESTAB-TLENGTH2 = C_22.
      WA_NODESTAB-TLENGTH3 = C_22.
      WA_NODESTAB-TLENGTH4 = C_24.
      WA_NODESTAB-TLENGTH5 = C_20.
* Material Number
      WRITE WA_MATS-MATNR TO WA_NODESTAB-TEXT NO-ZERO.
* Material Description
      WA_NODESTAB-TEXT1 = WA_MATS-MAKTX.
      IF WA_MATS-ACTUOM <> V_WAERS.
        WRITE : WA_MATS-ACTUOM TO L_UOM.
      ELSE.
        WRITE : V_WAERS TO L_UOM.
      ENDIF.
      CONCATENATE L_AQTY L_UOM INTO WA_NODESTAB-TEXT2
      SEPARATED BY SPACE.
      IF WA_MATS-STDUOM <> V_WAERS.
        WRITE : WA_MATS-STDUOM TO L_UOM.
      ELSE.
        WRITE : V_WAERS TO L_UOM.
      ENDIF.
      CONCATENATE L_SQTY L_UOM INTO WA_NODESTAB-TEXT3
      SEPARATED BY SPACE.
      IF WA_MATS-VARUOM <> V_WAERS.
        WRITE : WA_MATS-VARUOM TO L_UOM.
      ELSE.
        WRITE : V_WAERS TO L_UOM.
      ENDIF.
      CONCATENATE L_SVAR L_UOM INTO WA_NODESTAB-TEXT4
      SEPARATED BY SPACE.
      CONCATENATE L_SVARP C_PERC INTO WA_NODESTAB-TEXT5
      SEPARATED BY SPACE.
      IF RB_QUANT = C_X.
        WA_NODESTAB-TCOLOR6 = C_3.
        WA_NODESTAB-TLENGTH6 = C_24.
        CONCATENATE L_SVARQ V_WAERS INTO WA_NODESTAB-TEXT6
        SEPARATED BY SPACE.
      ENDIF.
      APPEND WA_NODESTAB TO I_NODESTAB.
      CLEAR : WA_NODESTAB.
    ENDLOOP.
*** Displaying Material Subtotals
    CLEAR WA_NODESTAB.
    WA_NODESTAB-ID = C_4_2.
    WA_NODESTAB-TLEVEL = C_4.
    WA_NODESTAB-PARENT = C_3_3.
    WA_NODESTAB-TEXT = 'Material Totals'(043).
    WA_NODESTAB-TEXT1 = SPACE.
    WA_NODESTAB-TLENGTH = C_18.
    WA_NODESTAB-TLENGTH2 = C_22.
    WA_NODESTAB-TLENGTH1 = C_30.
    WA_NODESTAB-TLENGTH3 = C_22.
    WA_NODESTAB-TLENGTH4 = C_24.
    WA_NODESTAB-TLENGTH5 = C_20.
    IF L_WA_MATS-ACTUOM <> V_WAERS.
      WRITE : L_WA_MATS-ACTUOM TO L_UOM.
    ELSE.
      WRITE : V_WAERS TO L_UOM.
    ENDIF.
    CONCATENATE L_AQTYG L_UOM INTO WA_NODESTAB-TEXT2
    SEPARATED BY SPACE.
    IF L_WA_MATS-STDUOM <> V_WAERS.
      WRITE : L_WA_MATS-STDUOM TO L_UOM.
    ELSE.
      WRITE : V_WAERS TO L_UOM.
    ENDIF.
    CONCATENATE L_SQTYG L_UOM INTO WA_NODESTAB-TEXT3
    SEPARATED BY SPACE.
    IF L_WA_MATS-VARUOM <> V_WAERS.
      WRITE : L_WA_MATS-VARUOM TO L_UOM.
    ELSE.
      WRITE : V_WAERS TO L_UOM.
    ENDIF.
    CONCATENATE L_SVARG L_UOM INTO WA_NODESTAB-TEXT4
    SEPARATED BY SPACE.
    IF RB_QUANT = C_X.
      WA_NODESTAB-TCOLOR6 = C_6.
      WA_NODESTAB-TLENGTH6 = C_24.
      CONCATENATE L_SVARGQ V_WAERS INTO WA_NODESTAB-TEXT6
      SEPARATED BY SPACE.
    ENDIF.
    WA_NODESTAB-TCOLOR = C_6.
    WA_NODESTAB-TCOLOR2 = C_6.
    WA_NODESTAB-TCOLOR3 = C_6.
    WA_NODESTAB-TCOLOR4 = C_6.
    APPEND WA_NODESTAB TO I_NODESTAB.
    CLEAR : WA_NODESTAB.
  ENDIF.
*** Displaying Summary totals
  IF RB_FISCL = C_X.
* l_astprs = l_wa_acts-actu * 10 + l_wa_mats-astprs.
* l_sstprs = l_wa_acts-stdu * 10 + l_wa_mats-sstprs.
    L_ASTPRS = L_WA_ACTS-ACTU + L_WA_MATS-ASTPRS.
    L_SSTPRS = L_WA_ACTS-STDU + L_WA_MATS-SSTPRS.
    L_STPRS = L_SSTPRS - L_ASTPRS.
    V_PRS = L_ASTPRS.
    WRITE : V_PRS TO L_AQTYS CURRENCY V_WAERS NO-GROUPING.
    V_PRS = L_SSTPRS.
    WRITE : V_PRS TO L_SQTYS CURRENCY V_WAERS NO-GROUPING.
    V_PRS = L_STPRS.
    WRITE : V_PRS TO L_SVARS CURRENCY V_WAERS NO-GROUPING.
    CLEAR WA_NODESTAB.
    WA_NODESTAB-ID = C_3_4.
    WA_NODESTAB-TLEVEL = C_3.
    WA_NODESTAB-PARENT = C_2_1.
    WA_NODESTAB-TEXT = 'Summary Totals'.
    WA_NODESTAB-TEXT1 = SPACE.
    WA_NODESTAB-TLENGTH = C_18.
    WA_NODESTAB-TLENGTH2 = C_22.
    WA_NODESTAB-TLENGTH1 = C_30.
    WA_NODESTAB-TLENGTH3 = C_22.
    WA_NODESTAB-TLENGTH4 = C_24.
    WRITE : V_WAERS TO L_UOM.
    CONCATENATE L_AQTYS L_UOM INTO WA_NODESTAB-TEXT2
    SEPARATED BY SPACE.
    CONCATENATE L_SQTYS L_UOM INTO WA_NODESTAB-TEXT3
    SEPARATED BY SPACE.
    CONCATENATE L_SVARS L_UOM INTO WA_NODESTAB-TEXT4
    SEPARATED BY SPACE.
    WA_NODESTAB-TCOLOR = C_5.
    WA_NODESTAB-TCOLOR1 = C_5.
    WA_NODESTAB-TCOLOR2 = C_5.
    WA_NODESTAB-TCOLOR3 = C_5.
    WA_NODESTAB-TCOLOR4 = C_5.
    APPEND WA_NODESTAB TO I_NODESTAB.
    CLEAR : WA_NODESTAB.
  ENDIF.
ENDFORM. " DISPLAY_SUMMARY_REPORT
*&--------------------------------------------------------------------*
*& Form material_header
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM MATERIAL_HEADER USING FP_NODESTAB TYPE SNODETEXT.
  FP_NODESTAB-TEXT = 'Material'(058).
  FP_NODESTAB-TLENGTH = C_22.
  FP_NODESTAB-TCOLOR = C_4.
  FP_NODESTAB-PROPFAW = C_X.
  FP_NODESTAB-TEXT1 = 'Description'(059).
  FP_NODESTAB-TLENGTH1 = C_30.
  FP_NODESTAB-TCOLOR1 = C_4.
  IF RB_FISCL = C_X.
    CONCATENATE 'Actual Usage'(040) V_WAERS INTO FP_NODESTAB-TEXT2
    SEPARATED BY SPACE.
  ELSE.
    CONCATENATE 'Actual Usage'(040) 'UoM' INTO FP_NODESTAB-TEXT2
    SEPARATED BY SPACE.
  ENDIF.
  FP_NODESTAB-TLENGTH2 = C_22.
  FP_NODESTAB-TCOLOR2 = C_4.
  IF RB_FISCL = C_X.
    CONCATENATE 'Standard Usage'(041) V_WAERS INTO FP_NODESTAB-TEXT3
    SEPARATED BY SPACE.
  ELSE.
    CONCATENATE 'Standard Usage'(041) 'UoM' INTO FP_NODESTAB-TEXT3
    SEPARATED BY SPACE.
  ENDIF.
  FP_NODESTAB-TLENGTH3 = C_22.
  FP_NODESTAB-TCOLOR3 = C_4.
  IF RB_FISCL = C_X.
    CONCATENATE 'Standard Usage Var'(042) V_WAERS INTO FP_NODESTAB-TEXT4
    SEPARATED BY SPACE.
  ELSE.
    CONCATENATE 'Standard Usage Var'(042) 'UoM' INTO FP_NODESTAB-TEXT4
    SEPARATED BY SPACE.
  ENDIF.
  FP_NODESTAB-TLENGTH4 = C_24.
  FP_NODESTAB-TCOLOR4 = C_4.
  CONCATENATE 'Standard Usage Var'(042) C_PERC INTO FP_NODESTAB-TEXT5
  SEPARATED BY SPACE.
  FP_NODESTAB-TLENGTH5 = C_20.
  FP_NODESTAB-TCOLOR5 = C_4.
  IF RB_SUMM = C_X AND RB_QUANT = C_X.
    CONCATENATE 'Standard Usage Var'(042) V_WAERS INTO FP_NODESTAB-TEXT6
    SEPARATED BY SPACE.
    FP_NODESTAB-TLENGTH6 = C_24.
    FP_NODESTAB-TCOLOR6 = C_4.
  ENDIF.
ENDFORM. " MATERIAL_HEADER
**&---------------------------------------------------------------------
**
**& Form get_orders
**&---------------------------------------------------------------------
**
** text
**----------------------------------------------------------------------
**
*FORM get_orders.
*
* DATA: l_sttxt(100) TYPE c,
* flg_status(1) TYPE c.
*
*
* MOVE 'Extracting Process Orders'(022) TO v_output_text.
*
* PERFORM inform_user_of_progress.
*
*
***START OF MOD-003.
* IF NOT p_mtart IS INITIAL.
**"selection filter on material type
* SELECT matnr "material number
* mtart "material type
* INTO TABLE i_mtart
* FROM mara
* WHERE matnr IN s_matnr
* AND mtart = p_mtart.
*
* IF sy-subrc <> 0. " if no corresponding data is found
*
* MESSAGE i072 WITH p_mtart.
* "No data was selected for material type
* LEAVE LIST-PROCESSING.
*
* ENDIF.
* ENDIF.
*
*
* IF NOT i_mtart IS INITIAL.
* SELECT aufnr
* werks
* kokrs
* objnr
* gltrp
* rsnum
* gamng
* gmein
* plnbez
* plnty
* plnnr
* plnal
* stlst "mod-001
* stlty
* stlnr
* stlal
* aufpl
* zaehl
* rueck
* INTO TABLE i_orders FROM caufv
* FOR ALL ENTRIES IN i_mtart "*----MOD-003
* WHERE aufnr IN s_aufnr AND
* werks = p_werks AND
* kokrs = p_kokrs AND
* stlan = p_usage AND
* plnbez = i_mtart-matnr AND "*----MOD-003
* ( gstrp IN s_datuv OR gltrp IN s_datuv ).
***END OF MOD-003.
*
* ELSE. "----MOD-003
* SELECT aufnr
* werks
* kokrs
* objnr
* gltrp
* rsnum
* gamng
* gmein
* plnbez
* plnty
* plnnr
* plnal
* stlst " MOD-001
* stlty
* stlnr
* stlal
* aufpl
* zaehl
* rueck
* INTO TABLE i_orders FROM caufv
* WHERE aufnr IN s_aufnr AND
* werks = p_werks AND
* kokrs = p_kokrs AND
* plnbez IN s_matnr AND
* stlan = p_usage AND
* ( gstrp IN s_datuv OR gltrp IN s_datuv ).
*
* ENDIF. "----MOD-003
*
*
* IF sy-subrc <> 0.
* MESSAGE s007.
* LEAVE LIST-PROCESSING.
* ENDIF.
*
* SORT i_orders BY aufnr.
*
* LOOP AT i_orders INTO wa_orders.
*
* IF NOT i_tj02t[] IS INITIAL .
* PERFORM get_status_info USING wa_orders-objnr l_sttxt.
*
* CLEAR: flg_status, wa_tj02t.
* LOOP AT i_tj02t INTO wa_tj02t.
* IF l_sttxt NS wa_tj02t-txt04.
* CLEAR flg_status.
* EXIT.
* ELSE.
* flg_status = c_x.
* CONTINUE.
* ENDIF.
* CLEAR : wa_tj02t.
* ENDLOOP.
*
* IF flg_status <> c_x.
* DELETE i_orders.
* CONTINUE.
* ENDIF.
*
* wa_order_status_text-aufnr = wa_orders-aufnr.
* wa_order_status_text-sttxt = l_sttxt.
* APPEND wa_order_status_text TO i_order_status_text.
* CLEAR wa_order_status_text.
* ENDIF.
*
* CLEAR : wa_orders.
*
* ENDLOOP.
*
** ENDIF.
*
*ENDFORM. " get_orders
**&---------------------------------------------------------------------
**
**& Form get_operations
**&---------------------------------------------------------------------
**
** text
**----------------------------------------------------------------------
**
**----------------------------------------------------------------------
**
*FORM get_operations.
*
* DATA l_tabix TYPE sytabix.
*
* MOVE 'Extracting Phase Information'(023) TO v_output_text.
* PERFORM inform_user_of_progress.
*
* SELECT aufpl
* aplzl
* plnkn
* plnty
* plnnr
* zaehl
* vornr
* arbid
* rueck
* steus
* phflg
* INTO TABLE i_afvc
* FROM afvc
* FOR ALL ENTRIES IN i_orders
* WHERE aufpl = i_orders-aufpl AND
* steus IN s_steus AND
* phflg = c_x.
*
* IF sy-subrc = 0.
* SELECT aufpl
* aplzl
* bmsch
* vgw02
* lmnga
* ism02
* ssavd
* FROM afvv INTO TABLE i_afvv
* FOR ALL ENTRIES IN i_afvc
* WHERE aufpl = i_afvc-aufpl AND
* aplzl = i_afvc-aplzl AND
* ssavd IN s_datuv.
*
* IF sy-subrc = 0.
* SORT i_afvv BY aufpl aplzl.
* ENDIF.
* IF NOT ( s_kostl[] IS INITIAL ).
*
* SELECT objty objid kokrs kostl
* FROM crco INTO TABLE i_crco
* FOR ALL ENTRIES IN i_afvc
* WHERE objty = c_objtyp
* AND objid = i_afvc-arbid.
* IF sy-subrc = 0.
* SORT i_crco BY kostl.
* ENDIF.
* ENDIF.
*
* SORT i_crhd BY objid.
* SORT i_orders BY aufpl.
*
* SORT i_afvc BY aufpl vornr DESCENDING.
*
* LOOP AT i_afvc INTO wa_afvc.
*
* l_tabix = sy-tabix.
*
* IF NOT ( s_kostl[] IS INITIAL ).
* READ TABLE i_crco INTO wa_crco
* WITH KEY objty = c_objtyp
* objid = wa_afvc-arbid
* BINARY SEARCH.
* IF sy-subrc = 0.
* READ TABLE i_csks INTO wa_csks
* WITH KEY kostl = wa_crco-kostl.
* IF sy-subrc <> 0.
* DELETE i_afvv WHERE aufpl = wa_afvc-aufpl
* AND aplzl = wa_afvc-aplzl.
* DELETE i_afvc INDEX l_tabix.
* CONTINUE.
* ENDIF.
* ENDIF.
* ENDIF.
*
** Check work centre details with resource
* IF NOT ( s_arbpl[] IS INITIAL ).
* READ TABLE i_crhd INTO wa_crhd
* WITH KEY objid = wa_afvc-arbid BINARY SEARCH.
* IF sy-subrc <> 0.
* DELETE i_afvv WHERE aufpl = wa_afvc-aufpl
* AND aplzl = wa_afvc-aplzl.
* DELETE i_afvc INDEX l_tabix.
* CONTINUE.
* ELSE.
* PERFORM move_data2_ordops.
* ENDIF.
* ELSE.
* READ TABLE i_crhd INTO wa_crhd
* WITH KEY objid = wa_afvc-arbid BINARY SEARCH.
* PERFORM move_data2_ordops.
* ENDIF.
* CLEAR: wa_crco, wa_crhd, l_tabix, wa_afvc.
* ENDLOOP.
*
* ENDIF.
*
*ENDFORM. " get_operations
**&---------------------------------------------------------------------
**
**& Form get_mat_segment
**&---------------------------------------------------------------------
**
** text
**----------------------------------------------------------------------
**
**----------------------------------------------------------------------
**
*FORM get_mat_segment.
* DATA: l_menge TYPE menge_d,
* l_gamng type menge_d,
* v_menge type menge_d,
* l_meins TYPE meins,
* struct_mara type mara,
* struct_marc type marc.
* DATA: l_lmnga TYPE LMNGA,
* L_CFUOM type meins.
*
* IF NOT ( i_pro_orders[] IS INITIAL ).
* IF NOT ( rb_prod IS INITIAL ).
*
** Extracting goods receipt information
*MOVE 'Extracting Goods Receipt Information'(024) TO v_output_text.
* PERFORM inform_user_of_progress.
****** Mod-002******************************************************
* SELECT aufnr mblnr mjahr zeile matnr bwart menge meins
* " sjahr smbln smblp
* rsnum rspos rsart erfmg erfme
* FROM aufm "Table : Goods movements for order
* INTO TABLE i_mseg1
* FOR ALL ENTRIES IN i_pro_orders
* WHERE aufnr = i_pro_orders-aufnr.
** AND matnr = i_pro_orders-plnbez.
******Mod-002********************************************************
* IF sy-subrc = 0.
*
**Addition
* i_mseg = i_mseg1.
* LOOP AT i_pro_orders INTO wa_pro_orders.
* DELETE i_mseg WHERE aufnr = wa_pro_orders-aufnr
* AND matnr <> wa_pro_orders-plnbez.
* ENDLOOP.
**End of addition
***********************Mod-002****************************************
*
* clear: struct_marc.
* select single *
* into struct_marc
* from marc
* where matnr = wa_pro_orders-plnbez and
* werks = wa_pro_orders-werks.
*
* clear: struct_mara.
* select single *
* into struct_mara
* from mara
* where matnr = wa_pro_orders-plnbez.
*
**************MOD-002*************************************************
*
* SORT i_mseg BY aufnr.
* SORT i_pro_orders BY aufnr.
** Calculatin the quantity according to the movement type and
** assign the value to i_pro_orders internal table
*
* LOOP AT i_mseg INTO wa_mseg.
* AT NEW aufnr.
* CLEAR: l_menge, l_meins, v_menge.
* ENDAT.
* IF wa_mseg-bwart = c_101.
* if struct_marc-frtme is initial.
** l_menge = l_menge + wa_mseg-menge.
** l_meins = wa_mseg-erfme.
* if wa_mseg-erfme = struct_mara-meins.
* l_menge = l_menge + wa_mseg-erfmg.
* l_meins = wa_mseg-erfme.
* else.
* CALL FUNCTION 'MD_CONVERT_MATERIAL_UNIT'
* EXPORTING
* i_matnr = wa_pro_orders-plnbez
* i_in_me = wa_mseg-erfme
* i_out_me = struct_mara-meins
* i_menge = wa_mseg-erfmg
* IMPORTING
* e_menge = v_menge
* EXCEPTIONS
* error_in_application = 1
* error = 2
* OTHERS = 3.
* IF sy-subrc = 0.
* wa_mseg-erfmg = v_menge.
* ENDIF.
* l_menge = l_menge + wa_mseg-erfmg.
* l_meins = wa_mseg-erfme.
* endif.
* ELSEIF struct_marc-frtme is not initial.
* if ( struct_marc-frtme = struct_mara-meins ) and
* ( wa_mseg-erfme = struct_marc-frtme ).
* l_menge = l_menge + wa_mseg-erfmg.
* l_meins = wa_mseg-erfme.
* elseif ( struct_marc-frtme = struct_mara-meins ) and
* ( wa_mseg-erfme ne struct_marc-frtme ).
* CALL FUNCTION 'MD_CONVERT_MATERIAL_UNIT'
* EXPORTING
* i_matnr = wa_pro_orders-plnbez
* i_in_me = wa_mseg-erfme
* i_out_me = struct_marc-frtme
* i_menge = wa_mseg-erfmg
* IMPORTING
* e_menge = v_menge
* EXCEPTIONS
* error_in_application = 1
* error = 2
* OTHERS = 3.
* IF sy-subrc = 0.
* wa_mseg-erfmg = v_menge.
* ENDIF.
* l_menge = l_menge + wa_mseg-erfmg.
* l_meins = wa_mseg-erfme.
* elseif ( struct_marc-frtme ne struct_mara-meins ) and
* ( wa_mseg-erfme ne struct_marc-frtme ).
* CALL FUNCTION 'MD_CONVERT_MATERIAL_UNIT'
* EXPORTING
* i_matnr = wa_pro_orders-plnbez
* i_in_me = wa_mseg-erfme
* i_out_me = struct_marc-frtme
* i_menge = wa_mseg-erfmg
* IMPORTING
* e_menge = v_menge
* EXCEPTIONS
* error_in_application = 1
* error = 2
* OTHERS = 3.
* IF sy-subrc = 0.
* wa_mseg-erfmg = v_menge.
* ENDIF.
* l_menge = l_menge + wa_mseg-erfmg.
* l_meins = wa_mseg-erfme.
* else.
* CALL FUNCTION 'MD_CONVERT_MATERIAL_UNIT'
* EXPORTING
* i_matnr = wa_pro_orders-plnbez
* i_in_me = wa_mseg-erfme
* i_out_me = struct_marc-frtme
* i_menge = wa_mseg-erfmg
* IMPORTING
* e_menge = v_menge
* EXCEPTIONS
* error_in_application = 1
* error = 2
* OTHERS = 3.
* IF sy-subrc = 0.
* wa_mseg-erfmg = v_menge.
* ENDIF.
* l_menge = l_menge + wa_mseg-erfmg.
* l_meins = wa_mseg-erfme.
*
* endif.
* endif.
* ELSEIF wa_mseg-bwart = c_102.
* if struct_marc-frtme is initial.
** l_menge = l_menge - wa_mseg-menge.
** l_meins = wa_mseg-erfme.
*
* if wa_mseg-erfme = struct_mara-meins.
* l_menge = l_menge - wa_mseg-erfmg.
* l_meins = wa_mseg-erfme.
* else.
* CALL FUNCTION 'MD_CONVERT_MATERIAL_UNIT'
* EXPORTING
* i_matnr = wa_pro_orders-plnbez
* i_in_me = wa_mseg-erfme
* i_out_me = struct_mara-meins
* i_menge = wa_mseg-erfmg
* IMPORTING
* e_menge = v_menge
* EXCEPTIONS
* error_in_application = 1
* error = 2
* OTHERS = 3.
* IF sy-subrc = 0.
* wa_mseg-erfmg = v_menge.
* ENDIF.
* l_menge = l_menge - wa_mseg-erfmg.
* l_meins = wa_mseg-erfme.
* endif.
* ELSEIF struct_marc-frtme is not initial.
* if ( struct_marc-frtme = struct_mara-meins ) and
* ( wa_mseg-erfme = struct_marc-frtme ).
* l_menge = l_menge - wa_mseg-erfmg.
* l_meins = wa_mseg-erfme.
* elseif ( struct_marc-frtme = struct_mara-meins ) and
* ( wa_mseg-erfme ne struct_marc-frtme ).
* CALL FUNCTION 'MD_CONVERT_MATERIAL_UNIT'
* EXPORTING
* i_matnr = wa_pro_orders-plnbez
* i_in_me = wa_mseg-erfme
* i_out_me = struct_marc-frtme
* i_menge = wa_mseg-erfmg
* IMPORTING
* e_menge = v_menge
* EXCEPTIONS
* error_in_application = 1
* error = 2
* OTHERS = 3.
* IF sy-subrc = 0.
* wa_mseg-erfmg = v_menge.
* ENDIF.
* l_menge = l_menge - wa_mseg-erfmg.
* l_meins = wa_mseg-erfme.
* elseif ( struct_marc-frtme ne struct_mara-meins ) and
* ( wa_mseg-erfme ne struct_marc-frtme ).
* CALL FUNCTION 'MD_CONVERT_MATERIAL_UNIT'
* EXPORTING
* i_matnr = wa_pro_orders-plnbez
* i_in_me = wa_mseg-erfme
* i_out_me = struct_marc-frtme
* i_menge = wa_mseg-erfmg
* IMPORTING
* e_menge = v_menge
* EXCEPTIONS
* error_in_application = 1
* error = 2
* OTHERS = 3.
* IF sy-subrc = 0.
* wa_mseg-erfmg = v_menge.
* ENDIF.
* l_menge = l_menge - wa_mseg-erfmg.
* l_meins = wa_mseg-erfme.
* else.
* CALL FUNCTION 'MD_CONVERT_MATERIAL_UNIT'
* EXPORTING
* i_matnr = wa_pro_orders-plnbez
* i_in_me = wa_mseg-erfme
* i_out_me = struct_marc-frtme
* i_menge = wa_mseg-erfmg
* IMPORTING
* e_menge = v_menge
* EXCEPTIONS
* error_in_application = 1
* error = 2
* OTHERS = 3.
* IF sy-subrc = 0.
* wa_mseg-erfmg = v_menge.
* ENDIF.
* l_menge = l_menge - wa_mseg-erfmg.
* l_meins = wa_mseg-erfme.
* endif.
* endif.
** l_menge = l_menge - wa_mseg-menge.*
* ENDIF.
** l_meins = wa_mseg-meins.
*
****** End of MOD-002***************************************
*
* AT END OF aufnr.
*********Mod-002********************************************
** Don't want zero production orders
* IF NOT ( rb_ezero IS INITIAL ) AND l_menge = 0.
* DELETE i_ordops WHERE aufnr = wa_mseg-aufnr.
* DELETE i_pro_orders WHERE aufnr = wa_mseg-aufnr.
* CONTINUE.
* ENDIF.
* READ TABLE i_pro_orders INTO wa_pro_orders
* WITH KEY aufnr = wa_mseg-aufnr.
* wa_pro_orders-menge = l_menge.
* wa_pro_orders-gruom = l_meins.
* IF wa_pro_orders-gruom NE wa_pro_orders-gmein.
* CLEAR l_menge.
*
** If no conversion possible just use gr qty
* CALL FUNCTION 'MATERIAL_UNIT_CONVERSION'
* EXPORTING
* kzmeinh = c_x
* input = wa_pro_orders-menge
* matnr = wa_pro_orders-plnbez
* meinh = wa_pro_orders-gmein
* meins = wa_pro_orders-gruom
* IMPORTING
* output = l_menge
* EXCEPTIONS
* conversion_not_found = 1
* input_invalid = 2
* material_not_found = 3
* meinh_not_found = 4
* meins_missing = 5
* no_meinh = 6
* output_invalid = 7
* overflow = 8
* OTHERS = 9.
* IF sy-subrc = 0.
* wa_pro_orders-menge = l_menge.
* ENDIF.
***********************MOD-003**************************************
* clear: l_gamng.
*
* CALL FUNCTION 'MATERIAL_UNIT_CONVERSION'
* EXPORTING
* kzmeinh = c_x
* input = wa_pro_orders-gamng
* matnr = wa_pro_orders-plnbez
* meinh = wa_pro_orders-gmein
* meins = wa_pro_orders-gruom
* IMPORTING
* output = l_gamng
* EXCEPTIONS
* conversion_not_found = 1
* input_invalid = 2
* material_not_found = 3
* meinh_not_found = 4
* meins_missing = 5
* no_meinh = 6
* output_invalid = 7
* overflow = 8
* OTHERS = 9.
* IF sy-subrc = 0.
* wa_pro_orders-gamng = l_gamng.
* ENDIF.
*************************MOD-003**************************************
**
* ENDIF.
* MODIFY i_pro_orders FROM wa_pro_orders
* TRANSPORTING menge gruom gamng
* WHERE aufnr = wa_mseg-aufnr.
* ENDAT.
************************MOD-003**************************************
* CLEAR : wa_mseg.
************************MOD-003**************************************
*
* ENDLOOP.
* ENDIF.
********************MOD-008******************************************
**** Select confirmations using operation confirmation number instead of
**** order number
** SELECT aufpl
** aplzl
** plnkn
** plnty
** plnnr
** zaehl
** vornr
** arbid
** rueck
** steus
** phflg
** INTO TABLE i_afvc1
** FROM afvc
** FOR ALL ENTRIES IN i_ordops
** WHERE aufpl = I_ORDOPS-aufpl AND
** steus = 'YBN1' AND
** phflg = c_x.
**
** IF sy-subrc = 0.
** SORT I_AFVC1 BY aufpl
** aplzl
** plnkn
** plnty
** plnnr.
**
** SELECT aufpl
** aplzl
** bmsch
** vgw02
** lmnga
** ism02
** ssavd
** FROM afvv INTO TABLE i_afvv1
** FOR ALL ENTRIES IN i_afvc1
** WHERE aufpl = i_afvc1-aufpl AND
** aplzl = i_afvc1-aplzl.
**
** IF SY-SUBRC = 0.
** SORT I_AFVV1 BY AUFPL APLZL.
** ENDIF.
** ENDIF.
*
********************MOD-008******************************************
* ELSE.
** Extracting confirmation information
*MOVE 'Extracting Confirmation Information'(025) TO v_output_text.
* PERFORM inform_user_of_progress.
*
** SELECT aufnr rueck gmnga lmnga gmein meinh
** meilr stokz rueck_mst
** FROM afru INTO TABLE i_afru
** FOR ALL ENTRIES IN i_pro_orders
** WHERE rueck = i_pro_orders-rueck AND
*** MOD-001- Begin of change
** lmnga NE c_0. " AND
*** meilr NE space.
*** MOD-001- End of change
** IF sy-subrc = 0.
** SORT i_afru BY aufnr .
************MOD-002************************************************
*
*
*****************MOD-004*********************************************
**
** LOOP AT I_ORDOPS INTO WA_ORDOPS.
** SELECT SINGLE *
** INTO WA_PLPO3
** FROM plpo
** WHERE plnty = WA_ordops-plnty and
** plnnr = wa_ordops-plnnr and
** PLNKN = wa_ordops-plnkn and
** ZAEHL = wa_ordops-zaehl.
** IF SY-SUBRC = 0.
** APPEND WA_PLPO3 TO I_PLPO3.
** ENDIF.
** ENDLOOP.
*** and steus = 'YBN1'.
**
*****************MOD-005**********************************************
*** LOOP AT I_PRO_ORDERS into WA_PRO_ORDERS.
**********************mod-004****************************************
*** READ TABLE I_PLPO3 INTO WA_PLPO3 WITH KEY
*** plnty = wa_pro_orders-plnty
*** plnnr = wa_pro_orders-plnnr
*** plnkn = wa_pro_orders-plnkn
*** zaehl = wa_pro_orders-zaehl.
**** steus = 'YBN1'.
********************MOD-004*******************************************
**
**
*****************************MOD-005*******************************
** LOOP AT I_ORDOPS INTO WA_ORDOPS.
*****************************MOD-005******************************
*** READ table i_afvc into wa_afvc with key
**** aufpl = wa_pro_orders-aufpl
*** aufpl = wa_ordops-aufpl binary search.
*** steus = 'YBN1'
*** phflg = c_x binary search.
**
**********************MOD-005*************************************
**
*********************MOD-006*************************************
** CLEAR: WA_PLPO3.
** READ TABLE I_PLPO3 INTO WA_PLPO3 WITH KEY
** plnty = wa_ordops-plnty
** plnnr = wa_ordops-plnnr
*** plnkn = wa_ordops-plnkn
*** zaehl = wa_ordops-zaehl
** steus = 'YBN1' binary search.
*** vornr = wa_ordops-vornr
*** werks = p_werks binary search.
**
*********************MOD-006*************************************
** IF SY-SUBRC = 0.
*** READ table i_afvc into wa_afvc with key
*** aufpl = wa_ordops-aufpl
*** aplzl = wa_ordops-aplzl
*** plnkn = wa_ordops-plnkn
*** plnty = wa_ordops-plnty
*** plnnr = wa_ordops-plnnr
*** zaehl = wa_ordops-zaehl BINARY SEARCH.
******************mod-006*******************************************
** check wa_plpo3-vgw02 IS NOT INITIAL.
** clear: wa_afvc.
** READ TABLE i_afvc INTO wa_afvc
** WITH KEY plnty = wa_plpo3-plnty
** plnnr = wa_plpo3-plnnr
** plnkn = wa_plpo3-plnkn
** zaehl = wa_plpo3-zaehl
** aufpl = wa_ordops-aufpl.
**********************MOD-006*************************************
** if sy-subrc = 0.
*******************mod-004********************************************
**
** CLEAR: WA_AFVV.
** READ TABLE I_AFVV into wa_afvv with key
** aufpl = wa_afvc-aufpl
** aplzl = wa_afvc-aplzl binary search.
** if sy-subrc = 0.
** CLEAR: I_AFRU.
** SELECT aufnr rueck gmnga lmnga gmein meinh
** meilr stokz rueck_mst
** FROM afru INTO TABLE i_afru
** WHERE rueck = wa_afvc-rueck AND
*** WHERE rueck = wa_ordops-rueck AND
*** aufnr = wa_pro_orders-aufnr.
** aufnr = wa_ordops-aufnr.
**
** if sy-subrc = 0.
** SORT i_afru BY aufnr RUECK.
** LOOP AT i_afru INTO wa_afru.
*** READ TABLE i_pro_orders INTO wa_pro_orders
*** WITH KEY aufnr = wa_afru-aufnr.
** IF sy-subrc = 0.
** l_lmnga = l_lmnga + wa_afru-lmnga.
** l_cfuom = wa_afru-gmein.
*** wa_pro_orders-lmnga = wa_afru-lmnga.
*** wa_pro_orders-cfuom = wa_afru-gmein.
*** MODIFY i_pro_orders FROM wa_pro_orders
*** TRANSPORTING lmnga cfuom
*** WHERE aufnr = wa_afru-aufnr.
** ENDIF.
** ENDLOOP.
** endif.
************************MOD-005**************************************
** wa_ordops-lmnga = l_lmnga.
** wa_ordops-cfuom = l_cfuom.
** MODIFY i_ordops FROM wa_ordops
** TRANSPORTING lmnga cfuom
*****************************MOD-006********************************
** where plnty = wa_ordops-plnty and
** plnnr = wa_ordops-plnnr and
*** plnkn = wa_ordops-plnkn and
*** zaehl = wa_ordops-zaehl and
** aufpl = wa_ordops-aufpl.
***************************MOD-006*********************************
**
******************MOD-003******************************************
** clear: l_lmnga, l_cfuom.
******************mod-003**************************************
** ENDIF.
** ENDIF.
*** clear: wa_pro_orders.
****************************mod-004********************************
** ENDIF.
** clear: wa_ordops.
** ENDLOOP.
*************************MOD-005*************************************
**
** i_ordops1[] = i_ordops[].
** delete i_ordops1 where lmnga eq 0.
**
** LOOP AT I_PRO_ORDERS INTO WA_PRO_ORDERS.
** read table i_ordops1 into wa_ordops1 with key
** aufnr = wa_pro_orders-aufnr binary search.
** IF SY-SUBRC = 0.
** wa_pro_orders-lmnga = wa_ordops1-lmnga.
** wa_pro_orders-cfuom = wa_ordops1-cfuom.
** if wa_pro_orders-menge is initial.
** wa_pro_orders-menge = wa_pro_orders-gamng.
** endif.
** MODIFY i_pro_orders FROM wa_pro_orders
** TRANSPORTING lmnga cfuom menge
** where aufnr = wa_ordops1-aufnr.
** ENDIF.
** ENDLOOP.
** endif.
********************************MOD-007******************************
*
*** Select confirmations using operation confirmation number instead of
*** order number
* SELECT aufpl
* aplzl
* plnkn
* plnty
* plnnr
* zaehl
* vornr
* arbid
* rueck
* steus
* phflg
* INTO TABLE i_afvc1
* FROM afvc
* FOR ALL ENTRIES IN i_ordops
* WHERE aufpl = I_ORDOPS-aufpl AND
* steus = 'YBN1' AND
* phflg = c_x.
*
* IF sy-subrc = 0.
* SORT I_AFVC1 BY aufpl
* aplzl
* plnkn
* plnty
* plnnr.
*
* SELECT aufpl
* aplzl
* bmsch
* vgw02
* lmnga
* ism02
* ssavd
* FROM afvv INTO TABLE i_afvv1
* FOR ALL ENTRIES IN i_afvc1
* WHERE aufpl = i_afvc1-aufpl AND
* aplzl = i_afvc1-aplzl.
*
* IF SY-SUBRC = 0.
* SORT I_AFVV1 BY AUFPL APLZL.
*
* LOOP AT I_ORDOPS INTO WA_ORDOPS.
* READ TABLE I_PRO_ORDERS INTO WA_PRO_ORDERS WITH KEY
* AUFNR = WA_ORDOPS-AUFNR
* BINARY SEARCH.
* IF SY-SUBRC = 0.
* READ table i_afvc1 into wa_afvc1 with key
* plnty = wa_ORDOPS-plnty
* plnnr = wa_ORDOPS-plnnr
* plnkn = wa_ORDOPS-plnkn
* zaehl = wa_ORDOPS-zaehl
* aufpl = wa_pro_orders-aufpl.
* IF SY-SUBRC = 0.
* READ TABLE I_AFVV1 into wa_afvv1 with key
* aufpl = wa_afvc1-aufpl
* aplzl = wa_afvc1-aplzl binary search.
* IF SY-SUBRC = 0.
* CHECK WA_AFVV1-VGW02 NE 0.
* select aufnr
* rueck
* gmnga
* lmnga
* gmein
* meinh
* meilr
* stokz
* rueck_mst
* INTO TABLE I_AFRU1
* from afru
* where rueck = wa_afvc1-rueck AND
* werks = p_werks and
* aufnr = WA_PRO_ORDERS-aufnr and
* AUFPL = WA_AFVC1-AUFPL AND
* APLZL = WA_AFVC1-APLZL.
*
* IF SY-SUBRC = 0.
*
* perform get_confirmation_qty_new using
* wa_ordops-lmnga
* wa_ordops-cfuom.
*
* MODIFY i_ordops FROM wa_ordops
* TRANSPORTING lmnga cfuom.
* ENDIF.
* ENDIF.
* ENDIF.
* ENDIF.
*
* ENDLOOP.
* ENDIF.
* ENDIF.
*
* i_ordops1[] = i_ordops[].
* delete i_ordops1 where lmnga eq 0.
* delete adjacent duplicates from i_ordops1 comparing
* aufnr
* aufpl
* aplzl
* plnkn
* plnty
* plnnr
* zaehl
* vornr.
*
*
* LOOP AT I_PRO_ORDERS INTO WA_PRO_ORDERS.
* read table i_ordops1 into wa_ordops1 with key
* aufnr = wa_pro_orders-aufnr binary search.
* IF SY-SUBRC = 0.
* wa_pro_orders-lmnga = wa_ordops1-lmnga.
* wa_pro_orders-cfuom = wa_ordops1-cfuom.
* if wa_pro_orders-menge is initial.
* wa_pro_orders-menge = wa_pro_orders-gamng.
* endif.
* MODIFY i_pro_orders FROM wa_pro_orders
* TRANSPORTING lmnga cfuom menge
* where aufnr = wa_ordops1-aufnr.
* ENDIF.
* ENDLOOP.
* endif.
* endif.
********MOD-007******************************************************
*
*
*ENDFORM. " get_mat_segment
**&---------------------------------------------------------------------
**
**& Form get_bom_info
**&---------------------------------------------------------------------
**
** text
**----------------------------------------------------------------------
**
**----------------------------------------------------------------------
**
*FORM get_bom_info.
* DATA: wa_doc_segment1 TYPE ty_doc_segment,
* l_qty TYPE bdmng,
* l_per TYPE p DECIMALS 3,
* l_tabix TYPE sytabix,
* v_menge like ekpo-menge.
* DATA: STRUCT_MARC TYPE MARC,
* STRUCT_MARA TYPE MARA.
*
**- Begin of MOD-001
*
* TYPES: BEGIN OF l_ty_bom_header,
* stlty TYPE stlty, " BOM category
* stlnr TYPE stnum, " Bill of material
* stlal TYPE stalt, " Alternative BOM
* bmein TYPE basme, " Base unit of measure for BOM
* bmeng TYPE basmn, " Base Quantity
* END OF l_ty_bom_header.
*
* DATA: l_i_bom_header TYPE STANDARD TABLE OF l_ty_bom_header
* INITIAL SIZE 0,
*
* l_wa_bom_header TYPE l_ty_bom_header.
*
**- End of MOD-001
*
* IF NOT i_pro_orders[] IS INITIAL.
* MOVE 'Extracting BOM Information'(026) TO v_output_text.
* PERFORM inform_user_of_progress.
*
** Get issued materials for all process orders
*
**Begin of addition
*
* IF i_mseg1 IS INITIAL.
*** Mod-002*******************************************************
* SELECT aufnr mblnr mjahr zeile matnr bwart menge meins
* rsnum rspos rsart erfmg erfme
* FROM aufm "Table : Goods movements for order
* INTO TABLE i_mseg1
* FOR ALL ENTRIES IN i_pro_orders
* WHERE aufnr = i_pro_orders-aufnr.
** AND matnr = i_pro_orders-plnbez.
***** Mod-002***************************************************
* ENDIF.
*
* LOOP AT i_pro_orders INTO wa_pro_orders.
*
* LOOP AT i_mseg1 INTO wa_doc_segment
* WHERE mjahr = wa_pro_orders-wdate+0(4)
* AND bwart IN i_r_bwart
* AND aufnr = wa_pro_orders-aufnr.
*
* APPEND wa_doc_segment TO i_doc_segment.
*
* CLEAR : wa_doc_segment.
* ENDLOOP.
* CLEAR : wa_pro_orders.
* ENDLOOP.
*
* IF NOT i_doc_segment IS INITIAL.
*
* SELECT mblnr mjahr zeile sjahr smbln smblp rsnum rspos rsart
* FROM mseg INTO TABLE i_prev_doc
* FOR ALL ENTRIES IN i_doc_segment
* WHERE mblnr = i_doc_segment-mblnr
* AND mjahr = i_doc_segment-mjahr
* AND zeile = i_doc_segment-zeile.
*
* ENDIF.
*
* IF NOT i_doc_segment IS INITIAL.
*
**End of addition
*
* SORT i_doc_segment BY aufnr.
*
* LOOP AT i_doc_segment INTO wa_doc_segment1.
*
* wa_issued_mat-aufnr = wa_doc_segment1-aufnr.
*
** No reservation number so see if any other link exists
*
* IF wa_doc_segment1-rsnum IS INITIAL.
*
** Try to find any linked previous movements
* READ TABLE i_prev_doc INTO wa_prev_doc
* WITH KEY mblnr = wa_doc_segment1-mblnr
* mjahr = wa_doc_segment1-mjahr
* zeile = wa_doc_segment1-zeile.
* ENDIF.
*
* IF wa_doc_segment1-rsnum IS INITIAL AND
* wa_prev_doc-smbln NE space.
*
* READ TABLE i_prev_doc INTO wa_prev_doc
* WITH KEY mblnr = wa_prev_doc-smbln
* mjahr = wa_prev_doc-sjahr
* zeile = wa_prev_doc-smblp.
*
* IF sy-subrc = 0 AND NOT ( wa_doc_segment1-rsnum IS INITIAL ).
** found a previous record
* wa_issued_mat-rsnum = wa_prev_doc-rsnum.
* wa_issued_mat-rspos = wa_prev_doc-rspos.
* wa_issued_mat-rsart = wa_prev_doc-rsart.
* ENDIF.
*
* ELSE.
* wa_issued_mat-rsnum = wa_doc_segment1-rsnum.
* wa_issued_mat-rspos = wa_doc_segment1-rspos.
* wa_issued_mat-rsart = wa_doc_segment1-rsart.
* ENDIF.
* wa_issued_mat-matnr = wa_doc_segment1-matnr.
* IF wa_doc_segment1-bwart = c_movm_low_262
* OR wa_doc_segment1-bwart = c_movm_low_531.
* wa_issued_mat-menge = wa_doc_segment1-menge * -1.
* ELSE.
* wa_issued_mat-menge = wa_doc_segment1-menge.
* ENDIF.
* wa_issued_mat-meins = wa_doc_segment1-meins.
* COLLECT wa_issued_mat INTO i_issued_mat.
* CLEAR : wa_doc_segment1, wa_prev_doc.
* ENDLOOP.
* ENDIF.
*
** Selecting reservations
* SELECT rsnum rspos rsart xloek matnr werks bdmng
* meins shkzg aufnr dumps vornr rgekz
* stlty stlnr stlkn stpoz
* FROM resb INTO TABLE i_reservations
* FOR ALL ENTRIES IN i_pro_orders
* WHERE rsnum = i_pro_orders-rsnum AND
* aufnr = i_pro_orders-aufnr
* AND bdmng > 0
* AND dumps = space.
* IF sy-subrc = 0.
* SORT i_reservations.
** Selecting material standard price and price unit
** SELECT stlty stlnr stlkn stpoz ausch " MOD-001 --
* SELECT stlty stlnr stlkn stpoz meins menge ausch yyzero"MOD-001++
* FROM stpo INTO TABLE i_stpo
* FOR ALL ENTRIES IN i_reservations
* WHERE stlty = i_reservations-stlty
* AND stlnr = i_reservations-stlnr
* AND stlkn = i_reservations-stlkn
* AND stpoz = i_reservations-stpoz.
*
* IF sy-subrc = 0.
**Not required to handle as Component scrap in percent is optional
* ENDIF.
*
* SELECT matnr werks kausf
* FROM marc INTO TABLE i_marc
* FOR ALL ENTRIES IN i_reservations
* WHERE matnr = i_reservations-matnr
* AND werks = i_reservations-werks.
*
* IF sy-subrc = 0.
**Not required to handle as Component scrap in percent (plant level) is
**optional
* ENDIF.
*
* SELECT matnr bwkey stprs peinh
* FROM mbew INTO TABLE i_mat_valuation
* FOR ALL ENTRIES IN i_reservations
* WHERE matnr = i_reservations-matnr
* AND bwkey = i_reservations-werks.
*
* IF sy-subrc = 0.
**Not required to handle Standard Price and Price Unit are not mandatory
* ENDIF.
**- Begin of MOD-001
* SELECT stlty stlnr stlal bmein bmeng
* INTO TABLE l_i_bom_header
* FROM stko
* FOR ALL ENTRIES IN i_pro_orders
* WHERE stlty = i_pro_orders-stlty
* AND stlnr = i_pro_orders-stlnr
* AND stlal = i_pro_orders-stlal.
*
* IF sy-subrc = 0.
** There must be at least one record for process order.
* ENDIF.
*
**- End of MOD-001
*
* LOOP AT i_reservations INTO wa_reservations.
* CLEAR: wa_order_status_text.
* l_tabix = sy-tabix.
*
* IF wa_reservations-xloek NE space.
* READ TABLE i_order_status_text INTO wa_order_status_text
* WITH KEY aufnr = wa_reservations-aufnr.
* IF sy-subrc = 0
* AND wa_order_status_text-sttxt NS c_teco.
* DELETE i_issued_mat WHERE rsnum = wa_reservations-rsnum
* AND rspos = wa_reservations-rspos
* AND rsart = wa_reservations-rsart.
* DELETE i_reservations INDEX l_tabix.
* CONTINUE.
* ENDIF.
* ENDIF.
*
* IF NOT ( rb_nflsh IS INITIAL )
* AND wa_reservations-rgekz NE space.
* DELETE i_issued_mat WHERE rsnum = wa_reservations-rsnum
* AND rspos = wa_reservations-rspos
* AND rsart = wa_reservations-rsart.
* DELETE i_reservations INDEX l_tabix.
* CONTINUE.
* ENDIF.
* wa_ordmats-aufnr = wa_reservations-aufnr.
* wa_ordmats-matnr = wa_reservations-matnr.
* wa_ordmats-vornr = wa_reservations-vornr.
* wa_ordmats-rsnum = wa_reservations-rsnum.
* wa_ordmats-rspos = wa_reservations-rspos.
* wa_ordmats-rsart = wa_reservations-rsart.
* wa_ordmats-bdmng = wa_reservations-bdmng.
* wa_ordmats-meins = wa_reservations-meins.
*
* READ TABLE i_issued_mat INTO wa_issued_mat
* WITH KEY rsnum = wa_reservations-rsnum
* rspos = wa_reservations-rspos
* rsart = wa_reservations-rsart.
* IF sy-subrc = 0.
* wa_ordmats-menge = wa_ordmats-menge + wa_issued_mat-menge.
* wa_ordmats-amein = wa_issued_mat-meins.
* ELSE.
* wa_ordmats-amein = wa_reservations-meins.
* ENDIF.
** Use the reservation quantity as the standard planned quantity
** If material is by-product need to turn it into a negative number.
* IF wa_reservations-shkzg = c_s.
* wa_ordmats-bdmng = wa_ordmats-bdmng * -1.
* ENDIF.
*
* READ TABLE i_pro_orders INTO wa_pro_orders
* WITH KEY aufnr = wa_reservations-aufnr.
**************MOD-003*************************************
* clear: l_qty.
**************MOD-003*************************************
* IF rb_prod IS INITIAL.
* l_qty = wa_pro_orders-lmnga. "confirmed qty
***************MOD-003************************************
* ELSEIF ( rb_prod is not initial ) and ( rb_actl is initial ).
* l_qty = wa_pro_orders-gamng.
* ELSEIF ( RB_PROD IS NOT INITIAL ) and
* ( RB_ACTL is not initial ).
* l_qty = wa_pro_orders-menge. "goods receipt qty
* ENDIF.
*
** Calculate the standard quantity
*******************MOD-003****************************
** IF NOT rb_actl IS INITIAL.
*******************MOD-003****************************
*
********************mod-007*****************************
* IF L_QTY IS INITIAL.
* SELECT aufnr rueck gmnga lmnga gmein meinh
* meilr stokz rueck_mst
* FROM afru INTO TABLE i_afru
* FOR ALL ENTRIES IN i_pro_orders
* WHERE rueck = i_pro_orders-rueck AND
* lmnga NE c_0.
*
* READ TABLE i_pro_orders INTO wa_pro_orders
* WITH KEY aufnr = wa_reservations-aufnr.
* IF SY-SUBRC = 0.
* READ table i_afvc into wa_afvc with key
* aufpl = wa_pro_orders-aufpl
* steus = 'YBN1'
* phflg = c_x binary search.
* IF SY-SUBRC = 0.
* READ TABLE I_AFVV into wa_afvv with key
* aufpl = wa_afvc-aufpl
* aplzl = wa_afvc-aplzl binary search.
* if sy-subrc = 0.
* SORT i_afru BY aufnr RUECK.
* LOOP AT i_afru INTO wa_afru
* WHERE AUFNR = WA_PRO_ORDERS-AUFNR AND
* RUECK = WA_AFVC-RUECK.
* IF sy-subrc = 0.
* l_QTY = l_QTY + wa_afru-lmnga.
* ENDIF.
* ENDLOOP.
* check wa_pro_orders-gamng ne 0.
* clear: wa_ordmats-stdqy.
* wa_ordmats-stdqy = ( l_qty / wa_pro_orders-gamng ) *
* wa_ordmats-bdmng.
* endif.
* ENDIF.
* ENDIF.
*********************************MOD-007*****************************
* ELSE.
* check wa_pro_orders-gamng ne 0.
* clear: wa_ordmats-stdqy.
* wa_ordmats-stdqy = ( l_qty / wa_pro_orders-gamng ) *
* wa_ordmats-bdmng.
* ENDIF.
*******************MOD-006***********************
*
** check wa_pro_orders-gamng ne 0.
** clear: wa_ordmats-stdqy.
** wa_ordmats-stdqy = ( l_qty / wa_pro_orders-gamng ) *
** wa_ordmats-bdmng.
*******************mod-006************************
** ELSE.
********MOD-002****************************************
*** check wa_pro_orders-menge ne 0.
*** wa_ordmats-stdqy = ( l_qty / wa_pro_orders-menge ) *
*** wa_ordmats-bdmng.
** check wa_pro_orders-gamng ne 0.
** wa_ordmats-stdqy = ( l_qty / wa_pro_orders-gamng ) *
** wa_ordmats-bdmng.
** ENDIF.
*******MOD-002*******************************************
*********************MOD-003*******************************
*
*
** gets the zero loss figure from the bom
*
**- Begin of MOD-001
*
** READ TABLE i_stpo INTO wa_stpo
** WITH KEY stlty = wa_reservations-stlty
** stlnr = wa_reservations-stlnr
** stlkn = wa_reservations-stlkn
** stpoz = wa_reservations-stpoz.
** IF sy-subrc = 0 AND NOT ( wa_stpo-ausch IS INITIAL ).
** l_per = ( wa_stpo-ausch / c_100 ) * wa_ordmats-stdqy.
** ELSE.
** READ TABLE i_marc INTO wa_marc
** WITH KEY matnr = wa_reservations-matnr
** werks = wa_reservations-werks.
** IF sy-subrc = 0 AND NOT ( wa_marc-kausf IS INITIAL ).
** l_per = ( wa_marc-kausf / c_100 ) * wa_ordmats-stdqy.
** ELSE.
** MOVE c_0 TO l_per.
** ENDIF.
** ENDIF.
*
** wa_ordmats-zloss = wa_ordmats-stdqy - l_per.
*
* CLEAR l_qty.
* IF rb_actl IS INITIAL.
* l_qty = wa_pro_orders-gamng.
* ELSEIF rb_pland IS INITIAL.
* l_qty = wa_pro_orders-menge.
* ENDIF.
*
* READ TABLE l_i_bom_header INTO l_wa_bom_header
* WITH KEY stlty = wa_pro_orders-stlty
* stlnr = wa_pro_orders-stlnr
* stlal = wa_pro_orders-stlal.
*
* IF sy-subrc IS INITIAL.
**************mod-002**************************************
* IF L_WA_BOM_HEADER-BMEIN NE WA_PRO_ORDERS-GMEIN.
* CALL FUNCTION 'MD_CONVERT_MATERIAL_UNIT'
* EXPORTING
* i_matnr = wa_pro_orders-PLNBEZ
* i_in_me = wa_pro_orders-gmein
* i_out_me = l_wa_bom_header-bmein
* i_menge = l_qty
* IMPORTING
* e_menge = v_menge
* EXCEPTIONS
* error_in_application = 1
* error = 2
* OTHERS = 3.
* IF sy-subrc = 0.
* l_qty = v_menge.
* ENDIF.
* ENDIF.
*
*
************mod-002*****************************************
* IF l_wa_bom_header-bmeng IS NOT INITIAL.
*
* READ TABLE i_stpo INTO wa_stpo
* WITH KEY stlty = wa_reservations-stlty
* stlnr = wa_reservations-stlnr
* stlkn = wa_reservations-stlkn
* stpoz = wa_reservations-stpoz.
*
* l_per = wa_stpo-menge *
* ( l_qty / l_wa_bom_header-bmeng ).
*
* wa_ordmats-zloss = l_per * wa_stpo-yyzero.
*
* ENDIF.
*
* ENDIF.
*
**- End of MOD-001
* READ TABLE i_mat_valuation INTO wa_mat_valuation
* WITH KEY matnr = wa_reservations-matnr
* bwkey = wa_reservations-werks.
* IF sy-subrc = 0.
* wa_ordmats-stprs = wa_mat_valuation-stprs.
* wa_ordmats-peinh = wa_mat_valuation-peinh.
* ENDIF.
*
** Adding material number to I_MATERIAL_NO internal table
* wa_material_no-matnr = wa_reservations-matnr.
*
* APPEND: wa_ordmats TO i_ordmats,
* wa_material_no TO i_material_no.
* CLEAR: wa_ordmats, l_qty, l_per, wa_stpo, wa_marc,
* wa_issued_mat, wa_pro_orders, wa_mat_valuation,
* wa_material_no, l_tabix, wa_reservations.
*
* ENDLOOP.
** Now we need to see if any of the materials issued to the order
** are not on the BOM (ie replacement materials)
** First summarise the data
* SORT i_ordmats BY aufnr matnr rsnum.
* LOOP AT i_issued_mat INTO wa_issued_mat.
* READ TABLE i_ordmats INTO wa_ordmats
* WITH KEY aufnr = wa_issued_mat-aufnr
* matnr = wa_issued_mat-matnr
* rsnum = wa_issued_mat-rsnum
* BINARY SEARCH.
* IF sy-subrc GE 4.
** material not on bom table so add it
* CLEAR: wa_ordmats.
** Get the standard price info for costing purposes in output
* READ TABLE i_mat_valuation INTO wa_mat_valuation
* WITH KEY matnr = wa_issued_mat-matnr
* bwkey = p_werks.
* wa_issued_mat-stprs = wa_mat_valuation-stprs.
* wa_issued_mat-peinh = wa_mat_valuation-peinh.
* MODIFY i_issued_mat FROM wa_issued_mat.
* wa_ordmats-stprs = wa_mat_valuation-stprs.
* wa_ordmats-peinh = wa_mat_valuation-peinh.
* MOVE: wa_issued_mat-aufnr TO wa_ordmats-aufnr,
* wa_issued_mat-matnr TO wa_ordmats-matnr,
* wa_issued_mat-menge TO wa_ordmats-menge,
* wa_issued_mat-meins TO wa_ordmats-meins,
* wa_issued_mat-meins TO wa_ordmats-amein.
* COLLECT wa_ordmats INTO i_ordmats.
*
* ELSE.
** material is on bom table so delete from sum_msegi
* DELETE i_issued_mat. " FROM wa_issued_mat.
* ENDIF.
* CLEAR : wa_issued_mat.
* ENDLOOP.
*
* CLEAR wa_issued_mat.
*
** Retrieve task list information of operations/activity from PLPO table
* SELECT * FROM plpo INTO TABLE i_plpo
* FOR ALL ENTRIES IN i_pro_orders
* WHERE plnty = i_pro_orders-plnty
* AND plnnr = i_pro_orders-plnnr
* AND plnkn = i_pro_orders-plnkn
* AND zaehl = i_pro_orders-zaehl.
*
* IF sy-subrc = 0.
**Not required to handle
**Task list - operation/activity information is optional
* ENDIF.
*
* SELECT rueck rmzhl ism01 ism02 ism03 ism04 ism05 ism06 stokz
* FROM afru INTO TABLE i_ord_conf
* FOR ALL ENTRIES IN i_pro_orders
* WHERE rueck = i_pro_orders-rueck.
*
*
* IF sy-subrc = 0.
**Not required to handle
**Order Confirmations information is not mandatiory
* ENDIF.
* ENDIF.
*
* IF NOT i_ordops[] IS INITIAL.
*
* SELECT * FROM plpo INTO TABLE i_plpo1
* FOR ALL ENTRIES IN i_ordops
* WHERE plnty = i_ordops-plnty
* AND plnnr = i_ordops-plnnr
* AND plnkn = i_ordops-plnkn
* AND zaehl = i_ordops-zaehl.
*
* IF sy-subrc = 0.
**Not required to handle
**operations information is optional.
* ENDIF.
*
* SELECT rueck rmzhl ism01 ism02 ism03 ism04 ism05 ism06 stokz
* FROM afru INTO TABLE i_ord_conf1
* FOR ALL ENTRIES IN i_ordops
* WHERE rueck = i_ordops-rueck.
*
* IF sy-subrc = 0.
**Not required to handle
**Order Confirmations information is not mandatiory
* ENDIF.
*
* ENDIF.
* ENDIF.
*ENDFORM. " get_bom_info
*
**&---------------------------------------------------------------------
**
**& Form output
**&---------------------------------------------------------------------
**
** text
**----------------------------------------------------------------------
**
**----------------------------------------------------------------------
**
*FORM output.
*
* MOVE 'Formatting Output'(027) TO v_output_text.
* PERFORM inform_user_of_progress.
*
** Selecting material descriptions
* SELECT matnr maktx
* FROM makt INTO TABLE i_material_des
* FOR ALL ENTRIES IN i_material_no
* WHERE spras = sy-langu
* AND matnr = i_material_no-matnr.
*
* IF sy-subrc = 0.
**Not required to handle
**Material desc is optinal
* ENDIF.
*
*
** Selecting Work centers descriptions
* SELECT objid ktext
* FROM crtx INTO TABLE i_wc_text
* FOR ALL ENTRIES IN i_pro_orders
* WHERE objty = c_objtyp
* AND objid = i_pro_orders-arbid
* AND spras = sy-langu.
*
* IF sy-subrc = 0.
**Not required to handle
**Work centers descriptions are optional
* ENDIF.
*
* CASE c_x.
* WHEN rb_detl.
* PERFORM display_detail_report.
* WHEN rb_summ.
* PERFORM display_summary_report.
* WHEN rb_phase.
* PERFORM display_phase_report.
* ENDCASE.
*
*
*ENDFORM. " output
*
**&---------------------------------------------------------------------
**
**& Form move_data2_ordops
**&---------------------------------------------------------------------
**
** text
**----------------------------------------------------------------------
**
**----------------------------------------------------------------------
**
*FORM move_data2_ordops.
*
* READ TABLE i_afvv INTO wa_afvv WITH KEY aufpl = wa_afvc-aufpl
* aplzl = wa_afvc-aplzl BINARY SEARCH.
* READ TABLE i_orders INTO wa_orders WITH KEY aufpl = wa_afvc-aufpl.
* " BINRAY SEARCH.
* IF sy-subrc = 0.
******************
*
*READ TABLE i_ordops INTO wa_ordops WITH KEY aufnr = wa_orders-aufnr.
******************
* IF sy-subrc <> 0.
* MOVE-CORRESPONDING wa_orders TO wa_pro_orders.
* wa_pro_orders-wdate = wa_afvv-ssavd.
* wa_pro_orders-zaehl = wa_afvc-zaehl.
* wa_pro_orders-arbpl = wa_crhd-arbpl.
* wa_pro_orders-arbid = wa_afvc-arbid.
* wa_pro_orders-plnnr = wa_afvc-plnnr.
* wa_pro_orders-plnkn = wa_afvc-plnkn.
********MOD-002*****************************
** wa_pro_orders-rueck = wa_afvc-rueck.
*******MOD-002*******************************
* IF wa_pro_orders-rueck IS INITIAL.
* wa_pro_orders-rueck = wa_afvc-rueck.
* ENDIF.
*
* wa_material_no-matnr = wa_orders-plnbez.
*
* APPEND: wa_pro_orders TO i_pro_orders,
* wa_material_no TO i_material_no.
* CLEAR: wa_pro_orders, wa_material_no.
* ENDIF.
*
* wa_ordops-aufnr = wa_orders-aufnr.
* wa_ordops-aufpl = wa_afvc-aufpl.
* wa_ordops-aplzl = wa_afvc-aplzl.
* wa_ordops-plnty = wa_afvc-plnty.
* wa_ordops-plnkn = wa_afvc-plnkn.
* wa_ordops-plnnr = wa_afvc-plnnr.
* wa_ordops-zaehl = wa_afvc-zaehl.
* wa_ordops-vornr = wa_afvc-vornr.
* wa_ordops-arbid = wa_afvc-arbid.
* wa_ordops-rueck = wa_afvc-rueck.
* wa_ordops-ssavd = wa_afvv-ssavd.
* wa_ordops-arbpl = wa_crhd-arbpl.
*
* APPEND wa_ordops TO i_ordops.
* CLEAR wa_ordops.
* ENDIF.
* CLEAR: wa_afvv, wa_orders.
*
*ENDFORM. " move_data2_ordops
**&---------------------------------------------------------------------
**
**& Form DISPLAY_DETAIL_REPORT
**&---------------------------------------------------------------------
**
** text
**----------------------------------------------------------------------
**
**----------------------------------------------------------------------
**
*FORM display_detail_report.
*
* DATA: l_date_low(10) TYPE c,
* l_date_high(10) TYPE c,
* l_diff TYPE menge_d,
* l_plan_effic TYPE char05, "MOD-001++
* l_plant_effic TYPE char05, "MOD-001++
* l_gamng TYPE menge_d,
* l_gamng1(20) TYPE c,
* l_qty TYPE menge_d,
* l_prdqty TYPE menge_d,
* l_conv TYPE menge_d,
* l_aqty TYPE menge_d,
* l_sqty TYPE menge_d,
* l_gmein TYPE meins,
*
* l_pcent(3) TYPE p DECIMALS 2,
* l_cost(8) TYPE p DECIMALS 2,
*
* l_act_total(8) TYPE p DECIMALS 2,
* l_std_total(8) TYPE p DECIMALS 2,
* l_var_total(8) TYPE p DECIMALS 2,
*
* l_act_gtot(8) TYPE p DECIMALS 2,
* l_std_gtot(8) TYPE p DECIMALS 2,
* l_var_gtot(8) TYPE p DECIMALS 2,
*
* l_fromuom TYPE meins.
**- Begin of MOD-001
* DATA: l_value TYPE char16,
* l_tmp TYPE lmnga,
* l_tmp1 TYPE lmnga,
* l_effic TYPE p DECIMALS 1,
* l_uom TYPE char03.
**- End of MOD-001
*
* PERFORM pfstatus.
* SET PF-STATUS 'MAIN' EXCLUDING i_fcode.
* SET TITLEBAR 'VARI' WITH text-066.
* MOVE 'Display Detail Report'(028) TO v_output_text.
* PERFORM inform_user_of_progress.
*
** Clearing local variables
* CLEAR: l_cost, l_pcent, l_qty, l_conv, l_aqty, l_sqty,
* l_diff, l_plan_effic, l_gamng, l_date_low,l_date_high,
* l_act_gtot, l_std_gtot, l_var_gtot.
* CLEAR wa_nodestab.
* REFRESH i_nodestab.
*
****Begin of MOD-001
* IF sy-ucomm = c_zero OR rb_zloss IS NOT INITIAL.
*
* v_ucomm = c_zero.
*
* ELSEIF sy-ucomm = c_std OR rb_stdpl IS NOT INITIAL.
*
* CLEAR : v_ucomm.
*
* ENDIF.
*
* IF sy-ucomm = c_fisc.
*
* v_ucomm1 = c_fisc.
*
* ELSEIF sy-ucomm = c_qty.
*
* v_ucomm1 = c_qty.
*
* ENDIF.
****End of MOD-001
*
* wa_nodestab-id = c_1_1.
* wa_nodestab-tlevel = c_1.
* wa_nodestab-text = 'Production Variances'(031).
* wa_nodestab-tlength = c_20.
* wa_nodestab-compress = c_x.
* APPEND wa_nodestab TO i_nodestab.
*
* LOOP AT i_pro_orders INTO wa_pro_orders.
*
* CLEAR: wa_nodestab, l_date_low, l_date_high, l_gamng,
* wa_material_des.
*
* l_gamng = wa_pro_orders-gamng.
*************MOD-002************************
* l_gmein = wa_pro_orders-gmein.
*************MOD-002***********************
* wa_nodestab-id = c_2_1.
* wa_nodestab-tlevel = c_2.
* wa_nodestab-parent = c_1_1.
*
** Order Number text
* wa_nodestab-text = 'Order Num:'(032).
* wa_nodestab-tlength = c_12.
* wa_nodestab-tcolor = c_1.
** Order number
* WRITE wa_pro_orders-aufnr TO wa_nodestab-text1 NO-ZERO.
* wa_nodestab-tlength1 = c_12.
* wa_nodestab-tcolor1 = c_1.
*
** Date Range
* WRITE wa_pro_orders-wdate TO l_date_low.
* WRITE wa_pro_orders-gltrp TO l_date_high.
* CONCATENATE l_date_low c_hyp l_date_high
* INTO wa_nodestab-text2 SEPARATED BY space.
* wa_nodestab-tlength2 = c_25.
* wa_nodestab-tcolor2 = c_1.
*
** Material Number
* WRITE wa_pro_orders-plnbez TO wa_nodestab-text3 NO-ZERO.
* wa_nodestab-tlength3 = c_18.
* wa_nodestab-tcolor3 = c_1.
*
** Material Description
* READ TABLE i_material_des INTO wa_material_des
* WITH KEY matnr = wa_pro_orders-plnbez.
* wa_nodestab-text4 = wa_material_des-maktx.
* wa_nodestab-tlength4 = c_33.
* wa_nodestab-tcolor4 = c_1.
*
** Get actual produced Quantity or Confirm Quantity
* IF NOT ( rb_prod IS INITIAL ).
* l_prdqty = wa_pro_orders-menge.
* l_fromuom = wa_pro_orders-gruom.
* ELSE.
**********MOD-002***************************************
* LOOP AT i_plpo1 INTO wa_plpo1
* WHERE plnty = wa_pro_orders-plnty
* AND plnnr = wa_pro_orders-plnnr
* AND steus = 'YBN1'.
* IF wa_plpo1-vgw02 IS NOT INITIAL.
************MOD-005****************************
** wa_plpo2 = wa_plpo1.
** append wa_plpo2 to i_plpo2.
** ENDIF.
** ENDLOOP.
************mod-005***************************
* CLEAR: wa_afvc, wa_afvv.
* READ TABLE i_afvc INTO wa_afvc
* WITH KEY plnty = wa_plpo1-plnty
* plnnr = wa_plpo1-plnnr
* plnkn = wa_plpo1-plnkn
* zaehl = wa_plpo1-zaehl
* aufpl = wa_pro_orders-aufpl.
*
*
* IF sy-subrc IS INITIAL.
* READ TABLE i_afvv INTO wa_afvv
* WITH KEY aufpl = wa_afvc-aufpl
* aplzl = wa_afvc-aplzl.
*
** READ table i_afvc into wa_afvc with key
** aufpl = wa_pro_orders-aufpl binary search.
** if sy-subrc = 0.
** READ TABLE I_AFVV into wa_afvv with key
** aufpl = wa_afvc-aufpl
** aplzl = wa_afvc-aplzl binary search.
* IF sy-subrc = 0.
* l_prdqty = wa_afvv-lmnga.
********************MOD-006**********************
* IF wa_pro_orders-cfuom IS INITIAL.
* SELECT aufnr rueck gmnga lmnga gmein meinh
* meilr stokz rueck_mst
* FROM afru INTO TABLE i_afru
* WHERE rueck = wa_afvc-rueck AND
* aufnr = wa_pro_orders-aufnr.
* IF NOT i_afru[] IS INITIAL.
* READ TABLE i_afru INTO wa_afru INDEX 1.
* IF sy-subrc = 0.
* l_fromuom = wa_afru-gmein.
* ENDIF.
* ENDIF.
* ELSE.
* l_fromuom = wa_pro_orders-cfuom.
* ENDIF.
*******************MOD-006***********************
* ENDIF.
* ENDIF.
**********MOD-002***************************************
** l_prdqty = wa_pro_orders-lmnga.
** l_fromuom = wa_pro_orders-cfuom.
* ENDIF.
* ENDLOOP.
* ENDIF.
*
************mod-003**********************
* IF NOT rb_pland IS INITIAL.
* IF rb_conf IS INITIAL.
* l_prdqty = wa_pro_orders-gamng.
* ELSE.
* l_prdqty = wa_afvv-lmnga.
* ENDIF.
* ENDIF.
***********mod-003***********************
* IF rb_kgm = c_x.
** do actual conversion
* PERFORM uom_convert USING wa_pro_orders-plnbez
* l_prdqty
* l_fromuom
* l_conv.
* l_prdqty = l_conv.
** do planned conversion
*********MOD-002*************************
** l_fromuom = wa_pro_orders-gmein.
* l_fromuom = 'KG'.
*
* PERFORM uom_convert USING wa_pro_orders-plnbez
* wa_pro_orders-gamng
* l_fromuom
* l_conv.
*
* l_gamng = l_conv.
* ENDIF.
*
** Produced Quantity / Confirmed Quantity
* MOVE l_prdqty TO wa_nodestab-text5(20).
* MOVE l_fromuom TO l_uom. "MOD-001++
** WRITE l_prdqty TO i_nodestab-text5(20).
*
* IF NOT ( rb_prod IS INITIAL ).
** CONCATENATE 'Prod Qty: '(033) wa_nodestab-text5 "MOD-001-
* CONCATENATE 'Prod Qty: '(033) wa_nodestab-text5 l_uom "MOD-001+
* INTO wa_nodestab-text5 SEPARATED BY space.
*
* ELSE.
** CONCATENATE 'Conf Qty: '(034) wa_nodestab-text5 "MOD-001-
* CONCATENATE 'Conf Qty: '(034) wa_nodestab-text5 l_uom "MOD-001+
* INTO wa_nodestab-text5 SEPARATED BY space.
* ENDIF.
*
*
** wa_nodestab-tlength5 = c_30. "MOD-001-
* wa_nodestab-tlength5 = c_35_1. "MOD-001+
* wa_nodestab-tcolor5 = c_1.
*
* APPEND wa_nodestab TO i_nodestab.
*
** Resource Information
* CLEAR wa_nodestab.
* wa_nodestab-id = c_2_2.
* wa_nodestab-tlevel = c_3.
* wa_nodestab-parent = c_1_1.
*
* CONCATENATE 'Resource:'(035) wa_pro_orders-arbpl
* INTO wa_nodestab-text SEPARATED BY space.
* wa_nodestab-tlength = c_25.
* wa_nodestab-tcolor = c_4.
*
* READ TABLE i_wc_text INTO wa_wc_text
* WITH KEY objid = wa_pro_orders-arbid.
* wa_nodestab-text1 = wa_wc_text-ktext.
* wa_nodestab-tlength1 = c_37.
* wa_nodestab-tcolor1 = c_4.
*
** Calculating Plan Effic value
**- Begin of MOD-001
** IF l_gamng GT 0.
** l_diff = l_gamng - l_prdqty.
** l_plan_effic = c_100 - c_100 * ( l_diff / l_gamng ).
** ELSE.
** CLEAR l_plan_effic.
** ENDIF.
*
**** Mod-002*********************
* CLEAR: wa_plpo1.
*****mOD-002*********************
* LOOP AT i_plpo1 INTO wa_plpo1
* WHERE plnty = wa_pro_orders-plnty
* AND plnnr = wa_pro_orders-plnnr
* AND steus = 'YBN1'.
* IF wa_plpo1-vgw02 IS NOT INITIAL.
* MOVE wa_plpo1-usr04 TO l_effic. "L_VALUE.
* WRITE l_effic TO l_plan_effic.
* wa_plpo2 = wa_plpo1.
* APPEND wa_plpo2 TO i_plpo2.
*
** L_PLAN_EFFIC = floor( L_VALUE )
**************MOD-002**************************
** ELSE.
** CLEAR l_plan_effic.
* ENDIF.
*************MOD-002***************************
* ENDLOOP.
*
*
** CONCATENATE 'Plan Effic:'(036) l_plan_effic c_perc "'%'
* CONCATENATE 'Exp. Line Eff.'(036) l_plan_effic c_perc "'%'
* INTO wa_nodestab-text2 SEPARATED BY space.
* wa_nodestab-tlength2 = c_25.
* wa_nodestab-tcolor2 = c_4.
*
* CLEAR l_effic.
*** Mod-002***************
*
*
** READ TABLE i_afvc INTO wa_afvc
** WITH KEY plnty = wa_plpo1-plnty
** plnnr = wa_plpo1-plnnr
** zaehl = wa_plpo1-zaehl.
*
***************MOD-008***********************
** LOOP AT I_ORDOPS INTO WA_ORDOPS.
** READ TABLE I_PRO_ORDERS INTO WA_PRO_ORDERS WITH KEY
** AUFNR = WA_ORDOPS-AUFNR
** BINARY SEARCH.
** IF SY-SUBRC = 0.
** READ table i_afvc1 into wa_afvc1 with key
** plnty = wa_ORDOPS-plnty
** plnnr = wa_ORDOPS-plnnr
** plnkn = wa_ORDOPS-plnkn
** zaehl = wa_ORDOPS-zaehl
** aufpl = wa_pro_orders-aufpl.
** IF SY-SUBRC = 0.
** READ TABLE I_AFVV1 into wa_afvv1 with key
** aufpl = wa_afvc1-aufpl
** aplzl = wa_afvc1-aplzl binary search.
** IF SY-SUBRC = 0.
** CHECK WA_AFVV1-VGW02 NE 0.
** l_tmp = wa_afvv1-bmsch * wa_afvv1-ism02.
** IF l_tmp IS NOT INITIAL.
**
** l_tmp1 = ( wa_afvv1-lmnga * wa_afvv1-vgw02 ) / l_tmp.
**
** l_tmp1 = l_tmp1 * 100.
**
** MOVE l_tmp1 TO l_effic.
**
** ENDIF.
** ENDIF.
** ENDIF.
** ENDIF.
** ENDLOOP.
*
**************MOD-008************************
* CLEAR: wa_afvc, wa_afvv.
* LOOP AT i_plpo2 INTO wa_plpo2.
* READ TABLE i_afvc INTO wa_afvc
* WITH KEY plnty = wa_plpo2-plnty
* plnnr = wa_plpo2-plnnr
* plnkn = wa_plpo2-plnkn
* zaehl = wa_plpo2-zaehl
* aufpl = wa_pro_orders-aufpl.
*
* IF sy-subrc IS INITIAL.
* READ TABLE i_afvv INTO wa_afvv
* WITH KEY aufpl = wa_afvc-aufpl
* aplzl = wa_afvc-aplzl.
*
* l_tmp = wa_afvv-bmsch * wa_afvv-ism02.
* IF l_tmp IS NOT INITIAL.
*
* l_tmp1 = ( wa_afvv-lmnga * wa_afvv-vgw02 ) / l_tmp.
*
* l_tmp1 = l_tmp1 * 100.
*
* MOVE l_tmp1 TO l_effic.
*
* ENDIF.
* ENDIF.
* ENDLOOP.
*
* WRITE l_effic TO l_plant_effic.
*
** CLEAR v_plant_effic.
** PERFORM plant_effic USING wa_pro_orders-plnty
** wa_pro_orders-plnnr
** wa_pro_orders-plnkn
** wa_pro_orders-zaehl
** CHANGING v_plant_effic.
*
** CONCATENATE 'Plant Effic:'(037) v_plant_effic c_perc "'%'
* CONCATENATE 'Act. Line Eff.'(037) l_plant_effic c_perc "'%'
* " MOD-001+
* INTO wa_nodestab-text3 SEPARATED BY space.
* wa_nodestab-tlength3 = c_25.
* wa_nodestab-tcolor3 = c_4.
**- End of MOD-001
*
* APPEND wa_nodestab TO i_nodestab.
*
** Phase Information
* CLEAR wa_nodestab.
* wa_nodestab-id = c_3_3.
* wa_nodestab-tlevel = c_3.
* wa_nodestab-parent = c_1_1.
*
* wa_nodestab-text = 'Phase'(038).
* wa_nodestab-tlength = c_10.
* wa_nodestab-tcolor = c_4.
*
* MOVE l_gamng TO l_gamng1.
* CONCATENATE 'Activity (Std Plan:'(039) l_gamng1 c_brac " ')'
* INTO wa_nodestab-text1 SEPARATED BY space.
* wa_nodestab-tlength1 = c_42.
* wa_nodestab-tcolor1 = c_4.
*
* IF rb_fiscl = c_x.
* CONCATENATE 'Actual Usage'(040) v_waers
* INTO wa_nodestab-text2 SEPARATED BY space.
* ELSE.
* wa_nodestab-text2 = 'Actual Usage'(040).
* ENDIF.
* wa_nodestab-tlength2 = c_20.
* wa_nodestab-tcolor2 = c_4.
*
* IF rb_fiscl = c_x.
* CONCATENATE 'Standard Usage'(041) v_waers
* INTO wa_nodestab-text3 SEPARATED BY space.
* ELSE.
* wa_nodestab-text3 = 'Standard Usage'(041).
* ENDIF.
* wa_nodestab-tlength3 = c_20.
* wa_nodestab-tcolor3 = c_4.
*
* IF rb_fiscl = c_x.
* CONCATENATE 'Activity Variance'(042) v_waers
* INTO wa_nodestab-text4 SEPARATED BY space.
* ELSE.
* wa_nodestab-text4 = 'Activity Variance'(042).
* ENDIF.
* wa_nodestab-tlength4 = c_35.
* wa_nodestab-tcolor4 = c_4.
*
* APPEND wa_nodestab TO i_nodestab.
*
** Display acitivity report
* CLEAR flg_color.
* LOOP AT i_ordops INTO wa_ordops
* WHERE aufnr = wa_pro_orders-aufnr.
* IF flg_color IS INITIAL.
* flg_color = c_x.
* ELSE.
* CLEAR flg_color.
* ENDIF.
* PERFORM activity_report USING l_prdqty l_gamng l_uom l_gmein.
* ENDLOOP.
*
** Material Information
* CLEAR wa_nodestab.
* wa_nodestab-id = c_3_4.
* wa_nodestab-tlevel = c_3.
* wa_nodestab-parent = c_1_1.
*
* PERFORM material_header.
*
* CLEAR: l_act_total, l_std_total, l_var_total.
** Individual material details
* LOOP AT i_ordmats INTO wa_ordmats
* WHERE aufnr = wa_pro_orders-aufnr.
*
*****************mod-003************************
* CLEAR: l_aqty, l_sqty, l_qty.
****************mod-003*************************
*
* CLEAR: wa_nodestab.
* wa_nodestab-id = c_4_1.
* wa_nodestab-tlevel = c_4.
* wa_nodestab-parent = c_3_2.
*
** Material Number
* WRITE wa_ordmats-matnr TO wa_nodestab-text NO-ZERO.
* wa_nodestab-tlength = c_18.
* wa_nodestab-tcolor = c_3.
*
** Material Description
* CLEAR wa_material_des.
* READ TABLE i_material_des INTO wa_material_des
* WITH KEY matnr = wa_ordmats-matnr.
* wa_nodestab-text1 = wa_material_des-maktx.
* wa_nodestab-tlength1 = c_30.
* wa_nodestab-tcolor1 = c_3.
*
** Standard planned or zero loss planned
*
* IF rb_zloss IS INITIAL.
* l_qty = wa_ordmats-stdqy.
***************MOD-004***********************
*
*************MOD-004************************
* ELSE.
* l_qty = wa_ordmats-zloss.
* ENDIF.
*
** Order uom or kgm
* IF rb_kgm IS INITIAL.
* l_aqty = wa_ordmats-menge.
* l_sqty = l_qty.
* ELSE.
** do actual conversion
* PERFORM uom_convert USING wa_ordmats-matnr
* wa_ordmats-menge
* wa_ordmats-amein
* l_aqty.
** do std/zloss conversion
* PERFORM uom_convert USING wa_ordmats-matnr
* wa_ordmats-stdqy
* wa_ordmats-meins
* l_sqty.
* ENDIF.
*******************MOD-003**********************************
* IF wa_ordmats-meins = 'EA' OR
* wa_ordmats-meins = 'CS'.
* l_sqty = CEIL( l_sqty ).
* ENDIF.
*******************MOD-003**********************************
*
* PERFORM std_percentage_calc USING l_aqty l_sqty l_pcent.
*
** Fiscal or quantity
* IF rb_fiscl IS INITIAL.
* MOVE l_aqty TO wa_nodestab-text2(20). " Actual Usage
* wa_nodestab-tlength2 = c_20.
* wa_nodestab-tcolor2 = c_3.
* MOVE l_sqty TO wa_nodestab-text3(20). " Standard Usage
* wa_nodestab-tlength3 = c_20.
* wa_nodestab-tcolor3 = c_3.
*
* ELSE.
* IF NOT wa_ordmats-peinh IS INITIAL.
* CLEAR l_cost.
* l_cost = ( wa_ordmats-stprs * wa_ordmats-menge )
* / wa_ordmats-peinh.
* MOVE l_cost TO wa_nodestab-text2(20). " Acutal Usage
* wa_nodestab-tlength2 = c_20.
* wa_nodestab-tcolor2 = c_3.
*
* l_act_total = l_act_total + l_cost. " Subtotal of actual
* l_act_gtot = l_act_gtot + l_cost. " Grand total
*
* ENDIF.
* IF NOT wa_ordmats-peinh IS INITIAL.
* CLEAR l_cost.
****Begin of MOD-001
* IF v_ucomm = c_zero.
***************************MOD-003*******************************
* IF wa_ordmats-meins = 'EA' OR
* wa_ordmats-meins = 'CS'.
* l_qty = CEIL( l_qty ).
* ENDIF.
***************************MOD-003*******************************
* l_cost = ( wa_ordmats-stprs * l_qty ) "wa_ordmats-stdqy )
* / wa_ordmats-peinh.
*
*
* ELSE.
***************************MOD-003*******************************
* IF wa_ordmats-meins = 'EA' OR
* wa_ordmats-meins = 'CS'.
* wa_ordmats-stdqy = CEIL( wa_ordmats-stdqy ).
* ENDIF.
***************************MOD-003*******************************
*
* l_cost = ( wa_ordmats-stprs * wa_ordmats-stdqy )
* / wa_ordmats-peinh.
*
*
* ENDIF.
****End of MOD-001
*
* MOVE l_cost TO wa_nodestab-text3(20). " Standard Usage
* wa_nodestab-tlength3 = c_20.
* wa_nodestab-tcolor3 = c_3.
*
* l_std_total = l_std_total + l_cost. " Subtotal of standard
* l_std_gtot = l_std_gtot + l_cost. " Grand Total
*
* ENDIF.
* ENDIF.
*
* MOVE l_pcent TO wa_nodestab-text4(17). " Variance Percentage
* CONCATENATE wa_nodestab-text4(17) c_perc "'%'
* INTO wa_nodestab-text4(19) SEPARATED BY space.
* wa_nodestab-tlength4 = c_19.
* wa_nodestab-tcolor4 = c_3.
* CLEAR: l_diff, l_cost.
*
******Begin of MOD-001
* IF ( v_ucomm = c_zero ).
*
* l_diff = wa_ordmats-menge - l_qty.
*
* ELSE.
*
* l_diff = wa_ordmats-menge - wa_ordmats-stdqy.
*
* ENDIF.
******End of MOD-001
*
* IF NOT wa_ordmats-peinh IS INITIAL.
* l_cost = ( wa_ordmats-stprs * l_diff ) / wa_ordmats-peinh.
* l_cost = l_cost * -1.
* ENDIF.
*
******Begin of MOD-001
** IF v_ucomm1 = c_qty.
**
** MOVE l_diff TO wa_nodestab-text5(15). " Variance
**
** ELSE.
*
* MOVE l_cost TO wa_nodestab-text5(15). " Variance
*
** ENDIF.
*******End of MOD-001
*
* wa_nodestab-tlength5 = c_15.
* wa_nodestab-tcolor5 = c_3.
*
* l_var_total = l_var_total + l_cost. " Subtotal of Variance
* l_var_gtot = l_var_gtot + l_cost. " Grand total
*
* APPEND wa_nodestab TO i_nodestab.
****************MOD-003*********************
* CLEAR: wa_ordmats.
***************mod-003**********************
*
* ENDLOOP.
*
** Displaying Subtotals
*
* CLEAR wa_nodestab.
* wa_nodestab-id = c_4_1.
* wa_nodestab-tlevel = c_4.
* wa_nodestab-parent = c_3_2.
*
* wa_nodestab-text = 'Material Totals'(043).
* wa_nodestab-tlength = c_18.
* wa_nodestab-tcolor = c_6.
*
* wa_nodestab-text1 = space.
* wa_nodestab-tlength1 = c_30.
* wa_nodestab-tcolor1 = c_6.
*
* MOVE l_act_total TO wa_nodestab-text2(20) .
* wa_nodestab-tlength2 = c_20.
* wa_nodestab-tcolor2 = c_6.
*
* MOVE l_std_total TO wa_nodestab-text3(20) .
* wa_nodestab-tlength3 = c_20.
* wa_nodestab-tcolor3 = c_6.
*
* wa_nodestab-text4 = space.
* wa_nodestab-tlength4 = c_19.
* wa_nodestab-tcolor4 = c_6.
*
* MOVE l_var_total TO wa_nodestab-text5(15) .
* wa_nodestab-tlength5 = c_15.
* wa_nodestab-tcolor5 = c_6.
*
* APPEND wa_nodestab TO i_nodestab.
* CLEAR : wa_pro_orders, wa_nodestab.
*
* ENDLOOP.
*
** Displaying Grand total
* CLEAR wa_nodestab.
* wa_nodestab-id = c_2_1.
* wa_nodestab-tlevel = c_2.
* wa_nodestab-parent = c_1_1.
*
* wa_nodestab-text = 'Process Order Totals'(044).
* wa_nodestab-tlength = c_26.
* wa_nodestab-tcolor = c_5.
*
* wa_nodestab-text1 = space.
* wa_nodestab-tlength1 = c_30.
* wa_nodestab-tcolor1 = c_5.
*
* MOVE l_act_gtot TO wa_nodestab-text2(20) .
* wa_nodestab-tlength2 = c_20.
* wa_nodestab-tcolor2 = c_5.
*
* MOVE l_std_gtot TO wa_nodestab-text3(20) .
* wa_nodestab-tlength3 = c_20.
* wa_nodestab-tcolor3 = c_5.
*
* wa_nodestab-text4 = space.
* wa_nodestab-tlength4 = c_19.
* wa_nodestab-tcolor4 = c_5.
*
* MOVE l_var_gtot TO wa_nodestab-text5(15) .
* wa_nodestab-tlength5 = c_15.
* wa_nodestab-tcolor5 = c_5 .
*
* APPEND wa_nodestab TO i_nodestab.
*
* CLEAR : wa_nodestab.
*
*ENDFORM. " DISPLAY_DETAIL_REPORT
**&---------------------------------------------------------------------
**
**& Form DISPLAY_SUMMARY_REPORT
**&---------------------------------------------------------------------
**
** text
**----------------------------------------------------------------------
**
**----------------------------------------------------------------------
**
*FORM display_summary_report.
* DATA: l_diff TYPE menge_d,
* l_gamng TYPE menge_d,
* l_gmein TYPE meins,
*
* l_ltext TYPE ktext,
*
* l_tot_orders TYPE i,
*
* l_effic TYPE p DECIMALS 1, " MOD-001++
* l_effic1 TYPE p DECIMALS 1, " MOD-001++
* l_plan_effic TYPE char05, " MOD-001++
* l_plant_effic TYPE char05, " MOD-001++
* l_sum_plan_effic TYPE p DECIMALS 1,
* l_sum_plant_effic TYPE p DECIMALS 1,
*
* l_qty TYPE menge_d,
* l_conv TYPE menge_d,
* l_aqty TYPE menge_d,
* l_sqty TYPE menge_d,
*
* l_prdqty TYPE menge_d,
* l_sum_prdqty TYPE menge_d,
*
* l_pcent(3) TYPE p DECIMALS 2,
* l_cost(8) TYPE p DECIMALS 2,
*
* l_act_total(8) TYPE p DECIMALS 2,
* l_std_total(8) TYPE p DECIMALS 2,
* l_var_total(8) TYPE p DECIMALS 2,
*
* l_fromuom TYPE meins.
*
**- Begin of MOD-001
* DATA: l_value TYPE char16,
* l_tmp TYPE lmnga,
* l_tmp1 TYPE lmnga.
**- End of MOD-001
*
* PERFORM pfstatus.
* SET PF-STATUS 'MAIN' EXCLUDING i_fcode.
* SET TITLEBAR 'VARI' WITH text-067.
*
* CLEAR wa_nodestab.
* REFRESH i_nodestab.
*
* MOVE 'Display summary Report'(029) TO v_output_text.
* PERFORM inform_user_of_progress.
*
* CLEAR wa_nodestab.
* wa_nodestab-id = c_1.
* wa_nodestab-tlevel = c_1.
* wa_nodestab-text = 'Production Variances (Summary Report)'(045).
* wa_nodestab-tlength = c_40.
* wa_nodestab-compress = c_x.
* APPEND wa_nodestab TO i_nodestab.
*
* CLEAR wa_nodestab.
* wa_nodestab-id = c_2_1.
* wa_nodestab-tlevel = c_2.
* wa_nodestab-parent = c_1_1.
*
* wa_nodestab-text = 'Summary of Orders for'(046).
* wa_nodestab-tlength = c_22.
* wa_nodestab-tcolor = c_1.
*
* CONCATENATE 'Plant:'(047) p_werks
* INTO wa_nodestab-text1 SEPARATED BY space.
* wa_nodestab-tlength1 = c_15.
* wa_nodestab-tcolor1 = c_1.
*
* CONCATENATE 'Phase Key:'(048) s_steus-low s_steus-high
* INTO wa_nodestab-text2 SEPARATED BY space.
* wa_nodestab-tlength2 = c_25.
* wa_nodestab-tcolor2 = c_1.
*
* IF s_arbpl[] IS INITIAL.
* wa_nodestab-text3 = 'Resources: All'(049).
* ELSE.
* CONCATENATE 'Resources:'(065) s_arbpl-low c_hyp s_arbpl-high
* INTO wa_nodestab-text3 SEPARATED BY space.
* ENDIF.
* wa_nodestab-tlength3 = c_20.
* wa_nodestab-tcolor3 = c_1.
*
* APPEND wa_nodestab TO i_nodestab.
*
*****Begin of MOD-001
* CLEAR: l_sum_plan_effic, i_sum_ordmats, i_sum_activity.
*****End of MOD-001
*
* LOOP AT i_pro_orders INTO wa_pro_orders.
*
* l_gamng = wa_pro_orders-gamng.
* l_gmein = wa_pro_orders-gmein.
*
** Get actual produced Quantity or Confirm Quantity
* IF NOT ( rb_prod IS INITIAL ).
* l_prdqty = wa_pro_orders-menge.
* l_fromuom = wa_pro_orders-gruom.
* ELSE.
* l_prdqty = wa_pro_orders-lmnga.
*
*************************MOD-006**********************
** l_fromuom = wa_pro_orders-cfuom.
* IF wa_pro_orders-cfuom IS INITIAL.
* SELECT aufnr rueck gmnga lmnga gmein meinh
* meilr stokz rueck_mst
* FROM afru INTO TABLE i_afru
* WHERE aufnr = wa_pro_orders-aufnr.
* IF NOT i_afru[] IS INITIAL.
* READ TABLE i_afru INTO wa_afru INDEX 1.
* IF sy-subrc = 0.
* l_fromuom = wa_afru-gmein.
* ENDIF.
* ENDIF.
* ELSE.
* l_fromuom = wa_pro_orders-cfuom.
* ENDIF.
*************************MOD-006*********************
* ENDIF.
* IF rb_kgm = c_x.
** do actual conversion
* PERFORM uom_convert USING wa_pro_orders-plnbez
* l_prdqty
* l_fromuom
* l_conv.
* l_prdqty = l_conv.
** do planned conversion
********MOD-002********************************
** l_fromuom = wa_pro_orders-gmein.
* l_fromuom = 'KG'.
********Mod-002********************************
* PERFORM uom_convert USING wa_pro_orders-plnbez
* wa_pro_orders-gamng
* l_fromuom
* l_conv.
* l_gamng = l_conv.
* ENDIF.
** Calculating Plan Effic value
* CLEAR l_plan_effic.
**- Begin of MOD-001
** IF l_gamng GT 0.
** l_diff = l_gamng - l_prdqty.
** l_plan_effic = 100 - 100 * ( l_diff / l_gamng ).
** ELSE.
** CLEAR l_plan_effic.
** ENDIF.
*
* LOOP AT i_plpo1 INTO wa_plpo1
* WHERE plnty = wa_pro_orders-plnty
* AND plnnr = wa_pro_orders-plnnr
* AND steus = 'YBN1'.
* IF wa_plpo1-vgw02 IS NOT INITIAL.
* MOVE wa_plpo1-usr04 TO l_effic. "L_VALUE.
* wa_plpo2 = wa_plpo1.
* APPEND wa_plpo2 TO i_plpo2.
*****************mod-002************************
** CONDENSE L_VALUE.
** write l_effic to l_plan_effic.
** L_PLAN_EFFIC = floor( L_VALUE ).
*****************mod-002************************
* ELSE.
* CLEAR l_plan_effic.
* ENDIF.
*
* ENDLOOP.
*
*********************MOD-008**************************************
** LOOP AT I_ORDOPS INTO WA_ORDOPS.
** READ TABLE I_PRO_ORDERS INTO WA_PRO_ORDERS WITH KEY
** AUFNR = WA_ORDOPS-AUFNR
** BINARY SEARCH.
** IF SY-SUBRC = 0.
** READ table i_afvc1 into wa_afvc1 with key
** plnty = wa_ORDOPS-plnty
** plnnr = wa_ORDOPS-plnnr
** plnkn = wa_ORDOPS-plnkn
** zaehl = wa_ORDOPS-zaehl
** aufpl = wa_pro_orders-aufpl.
** IF SY-SUBRC = 0.
** READ TABLE I_AFVV1 into wa_afvv1 with key
** aufpl = wa_afvc1-aufpl
** aplzl = wa_afvc1-aplzl binary search.
** IF SY-SUBRC = 0.
** CHECK WA_AFVV1-VGW02 NE 0.
** l_tmp = wa_afvv1-bmsch * wa_afvv1-ism02.
** IF l_tmp IS NOT INITIAL.
**
** l_tmp1 = ( wa_afvv1-lmnga * wa_afvv1-vgw02 ) / l_tmp.
**
** l_tmp1 = l_tmp1 * 100.
**
** MOVE l_tmp1 TO l_effic.
**
** ENDIF.
** ENDIF.
** ENDIF.
** ENDIF.
** ENDLOOP.
*******************MOD-008********************************************
*
******Mod-002*******************************
** READ TABLE i_afvc INTO wa_afvc
** WITH KEY plnty = wa_plpo1-plnty
** plnnr = wa_plpo1-plnnr
** zaehl = wa_plpo1-zaehl.
*
* LOOP AT i_plpo2 INTO wa_plpo2..
* CLEAR: wa_afvc, wa_afvv.
* READ TABLE i_afvc INTO wa_afvc
* WITH KEY plnty = wa_plpo2-plnty
* plnnr = wa_plpo2-plnnr
* plnkn = wa_plpo2-plnkn
* zaehl = wa_plpo2-zaehl
* aufpl = wa_pro_orders-aufpl.
*
**Mod-002*************************************
*
* IF sy-subrc IS INITIAL.
* READ TABLE i_afvv INTO wa_afvv
* WITH KEY aufpl = wa_afvc-aufpl
* aplzl = wa_afvc-aplzl.
*
* l_tmp = wa_afvv-bmsch * wa_afvv-ism02.
* IF l_tmp IS NOT INITIAL.
*
* l_tmp1 = ( wa_afvv-lmnga * wa_afvv-vgw02 ) / l_tmp.
*
* l_tmp1 = l_tmp1 * 100.
*
* MOVE l_tmp1 TO l_effic1.
*
* ENDIF.
*
* ENDIF.
* ENDLOOP.
*
** CLEAR v_plant_effic.
** PERFORM plant_effic USING wa_pro_orders-plnty
** wa_pro_orders-plnnr wa_pro_orders-plnkn
** wa_pro_orders-zaehl
** CHANGING v_plant_effic.
** l_sum_plan_effic = l_sum_plan_effic + l_plan_effic.
* l_sum_plan_effic = l_sum_plan_effic + l_effic.
** l_sum_plant_effic = l_sum_plant_effic + v_plant_effic.
* l_sum_plant_effic = l_sum_plant_effic + l_effic1.
**- End of MOD-001
* l_sum_prdqty = l_sum_prdqty + l_prdqty.
*
****Begin of MOD-001
** CLEAR: i_sum_activity. "l_prdqty
****End of MOD-001
* LOOP AT i_ordops INTO wa_ordops
* WHERE aufnr = wa_pro_orders-aufnr.
* PERFORM activity_report USING l_prdqty l_gamng l_fromuom l_gmein.
* CLEAR : wa_ordops.
* ENDLOOP.
*
*LOOP AT i_ordmats INTO wa_ordmats WHERE aufnr = wa_pro_orders-aufnr.
* PERFORM summary_materials.
* CLEAR : wa_ordmats.
* ENDLOOP.
* CLEAR : wa_pro_orders.
* ENDLOOP.
* CLEAR: l_plan_effic, v_plant_effic, l_prdqty, l_tot_orders.
*
** Passing summraised data to internal table for printing.
* DESCRIBE TABLE i_pro_orders LINES l_tot_orders.
* IF l_tot_orders > 0.
** l_plan_effic = l_sum_plan_effic / l_tot_orders. " MOD-001--
* l_effic = l_sum_plan_effic / l_tot_orders. " MOD-001++
** v_plant_effic = l_sum_plant_effic / l_tot_orders." MOD-001--
* l_effic1 = l_sum_plant_effic / l_tot_orders. " MOD-001++
* ENDIF.
* CLEAR wa_nodestab.
* wa_nodestab-id = c_2_2.
* wa_nodestab-tlevel = c_3.
* wa_nodestab-parent = c_1_1.
*
* IF NOT ( rb_prod IS INITIAL ).
* wa_nodestab-text = 'Produced Qty:'(050).
* ELSE.
* wa_nodestab-text = 'Confirmed Qty:'(051).
* ENDIF.
* wa_nodestab-tlength = c_15.
* wa_nodestab-tcolor = c_4.
*
* MOVE l_sum_prdqty TO wa_nodestab-text1(20).
* wa_nodestab-tlength1 = c_20.
* wa_nodestab-tcolor1 = c_4.
*
** CONCATENATE 'Plan Effic:'(036) l_plan_effic c_perc "'%'
* WRITE l_effic TO l_plan_effic.
* CONCATENATE 'Exp. Line Eff.'(036) l_plan_effic c_perc "'%'
* INTO wa_nodestab-text2 SEPARATED BY space.
* wa_nodestab-tlength2 = c_25.
* wa_nodestab-tcolor2 = c_4.
*
** CONCATENATE 'Plant Effic:'(037) v_plant_effic c_perc "'%'
* WRITE l_effic1 TO l_plant_effic.
* CONCATENATE 'Act. Line Eff.'(037) l_plant_effic c_perc "'%'
* INTO wa_nodestab-text3 SEPARATED BY space.
* wa_nodestab-tlength3 = c_25.
* wa_nodestab-tcolor3 = c_4.
*
* APPEND wa_nodestab TO i_nodestab.
*
** Summarised Phase Information
* CLEAR wa_nodestab.
* wa_nodestab-id = c_3_3.
* wa_nodestab-tlevel = c_3.
* wa_nodestab-parent = c_1_1.
*
* wa_nodestab-text = 'Activity'(052).
* wa_nodestab-tlength = c_40.
* wa_nodestab-tcolor = c_4.
*
* IF rb_fiscl = c_x.
* CONCATENATE 'Actual Usage'(040) v_waers
* INTO wa_nodestab-text1 SEPARATED BY space.
* ELSE.
* wa_nodestab-text1 = 'Actual Usage'(040).
* ENDIF.
* wa_nodestab-tlength1 = c_20.
* wa_nodestab-tcolor1 = c_4.
*
* IF rb_fiscl = c_x.
* CONCATENATE 'Standard Usage'(041) v_waers
* INTO wa_nodestab-text2 SEPARATED BY space.
* ELSE.
* wa_nodestab-text2 = 'Standard Usage'(041).
* ENDIF.
* wa_nodestab-tlength2 = c_20.
* wa_nodestab-tcolor2 = c_4.
*
* IF rb_fiscl = c_x.
* CONCATENATE 'Activity Variance'(042) v_waers
* INTO wa_nodestab-text3 SEPARATED BY space.
* ELSE.
* wa_nodestab-text3 = 'Activity Variance'(042).
* ENDIF.
* wa_nodestab-tlength3 = c_35.
* wa_nodestab-tcolor3 = c_4.
*
* APPEND wa_nodestab TO i_nodestab.
*
** Summarized activities
* CLEAR: l_act_total, l_std_total, l_var_total.
* SORT i_sum_activity BY lar.
* LOOP AT i_sum_activity INTO wa_sum_activity.
*
* SELECT ltext FROM cslt INTO l_ltext
* WHERE spras = sy-langu
* AND kokrs = p_kokrs
* AND lstar = wa_sum_activity-lar.
* ENDSELECT.
*
*
* IF sy-subrc = 0.
**Not required to handle
* ENDIF.
*
*
* CLEAR wa_nodestab.
* wa_nodestab-id = c_3_4.
* wa_nodestab-tlevel = c_4.
* wa_nodestab-parent = c_3_3.
*
* wa_nodestab-text1 = l_ltext.
* wa_nodestab-tlength1 = c_36.
* wa_nodestab-tcolor1 = c_3.
*
* IF rb_fiscl IS INITIAL.
* MOVE wa_sum_activity-afru_ism TO wa_nodestab-text2(20).
* wa_nodestab-tlength2 = c_20.
* wa_nodestab-tcolor2 = c_3.
*
* MOVE wa_sum_activity-ism_should TO wa_nodestab-text3(20).
* wa_nodestab-tlength3 = c_20.
* wa_nodestab-tcolor3 = c_3.
*
* MOVE wa_sum_activity-ism_var TO wa_nodestab-text4(20).
* wa_nodestab-tlength4 = c_20.
* wa_nodestab-tcolor4 = c_3.
*
* ELSE.
* MOVE wa_sum_activity-coact TO wa_nodestab-text2(20).
* wa_nodestab-tlength2 = c_20.
* wa_nodestab-tcolor2 = c_3.
*
* MOVE wa_sum_activity-costd TO wa_nodestab-text3(20).
* wa_nodestab-tlength3 = c_20.
* wa_nodestab-tcolor3 = c_3.
*
* MOVE wa_sum_activity-covar TO wa_nodestab-text4(20).
* wa_nodestab-tlength4 = c_20.
* wa_nodestab-tcolor4 = c_3.
*
* l_act_total = l_act_total + wa_sum_activity-coact.
* l_std_total = l_std_total + wa_sum_activity-costd.
* l_var_total = l_var_total + wa_sum_activity-covar.
* ENDIF.
* APPEND wa_nodestab TO i_nodestab.
* CLEAR : wa_nodestab, wa_sum_activity.
* ENDLOOP.
* IF NOT ( rb_fiscl IS INITIAL ).
*
** Display sub-total of Activities.
* CLEAR wa_nodestab.
* wa_nodestab-id = c_3_4.
* wa_nodestab-tlevel = c_4.
* wa_nodestab-parent = c_3_3.
*
* IF rb_fiscl = c_x.
* CONCATENATE 'Fiscal Activity Totals:'(053) v_waers
* INTO wa_nodestab-text1 SEPARATED BY space.
* ELSE.
* wa_nodestab-text1 = 'Fiscal Activity Totals:'(053).
* ENDIF.
* wa_nodestab-tlength1 = c_36.
* wa_nodestab-tcolor1 = c_2.
*
* MOVE l_act_total TO wa_nodestab-text2(20).
* wa_nodestab-tlength2 = c_20.
* wa_nodestab-tcolor2 = c_2.
*
* MOVE l_std_total TO wa_nodestab-text3(20).
* wa_nodestab-tlength3 = c_20.
* wa_nodestab-tcolor3 = c_2.
*
* MOVE l_var_total TO wa_nodestab-text4(20).
* wa_nodestab-tlength4 = c_20.
* wa_nodestab-tcolor4 = c_2.
*
* APPEND wa_nodestab TO i_nodestab.
* ENDIF.
** Summarized Material Information
* CLEAR wa_nodestab.
* wa_nodestab-id = c_6_1.
* wa_nodestab-tlevel = c_3.
* wa_nodestab-parent = c_2_2.
*
* PERFORM material_header.
*
* CLEAR: l_act_total, l_std_total, l_var_total.
* SORT i_sum_ordmats BY matnr.
* LOOP AT i_sum_ordmats INTO wa_sum_ordmats .
* CLEAR: wa_nodestab.
* wa_nodestab-id = c_4_1.
* wa_nodestab-tlevel = c_4.
* wa_nodestab-parent = c_3_2.
*
** Material Number
* WRITE wa_sum_ordmats-matnr TO wa_nodestab-text NO-ZERO.
* wa_nodestab-tlength = c_18.
* wa_nodestab-tcolor = c_3.
*
** Material Description
* CLEAR wa_material_des.
* READ TABLE i_material_des INTO wa_material_des
* WITH KEY matnr = wa_sum_ordmats-matnr.
* wa_nodestab-text1 = wa_material_des-maktx.
* wa_nodestab-tlength1 = c_30.
* wa_nodestab-tcolor1 = c_3.
*
** Standard planned or zero loss planned
*
* IF rb_zloss IS INITIAL.
* l_qty = wa_sum_ordmats-stdqy.
* ELSE.
* l_qty = wa_sum_ordmats-zloss.
* ENDIF.
*
** Order uom or kgm
* IF rb_kgm IS INITIAL.
* l_aqty = wa_sum_ordmats-menge.
* l_sqty = l_qty.
* ELSE.
** do actual conversion
* PERFORM uom_convert USING wa_sum_ordmats-matnr
* wa_sum_ordmats-menge
* wa_sum_ordmats-amein
* l_aqty.
** do std/zloss conversion
* PERFORM uom_convert USING wa_ordmats-matnr
* wa_ordmats-stdqy
* wa_ordmats-meins
* l_sqty.
* ENDIF.
*
* PERFORM std_percentage_calc USING l_aqty l_sqty l_pcent.
*
** Fiscal or quantity
* IF rb_fiscl IS INITIAL.
* MOVE l_aqty TO wa_nodestab-text2(20). " Actual Usage
* wa_nodestab-tlength2 = c_20.
* wa_nodestab-tcolor2 = c_3.
*
* MOVE l_sqty TO wa_nodestab-text3(20). " Standard Usage
* wa_nodestab-tlength3 = c_20.
* wa_nodestab-tcolor3 = c_3.
*
* ELSE.
* IF NOT wa_sum_ordmats-peinh IS INITIAL.
* CLEAR l_cost.
* l_cost = ( wa_sum_ordmats-stprs * wa_sum_ordmats-menge )
* / wa_sum_ordmats-peinh.
* MOVE l_cost TO wa_nodestab-text2(20). " Acutal Usage
* wa_nodestab-tlength2 = c_20.
* wa_nodestab-tcolor2 = c_3.
*
* l_act_total = l_act_total + l_cost. " Subtotal of actual
*
* ENDIF.
* IF NOT wa_sum_ordmats-peinh IS INITIAL.
* CLEAR l_cost.
* l_cost = ( wa_sum_ordmats-stprs * wa_sum_ordmats-stdqy )
* / wa_sum_ordmats-peinh.
* MOVE l_cost TO wa_nodestab-text3(20). " Standard Usage
* wa_nodestab-tlength3 = c_20.
* wa_nodestab-tcolor3 = c_3.
*
* l_std_total = l_std_total + l_cost. " Subtotal of standard
*
* ENDIF.
* ENDIF.
*
* MOVE l_pcent TO wa_nodestab-text4(18). " Variance Percentage
* CONCATENATE wa_nodestab-text4(18) c_perc "'%'
* INTO wa_nodestab-text4(20) SEPARATED BY space.
* wa_nodestab-tlength4 = c_20. "c_19.
* wa_nodestab-tcolor4 = c_3.
*
* CLEAR: l_diff, l_cost.
* l_diff = wa_sum_ordmats-menge - wa_sum_ordmats-stdqy.
* IF NOT wa_sum_ordmats-peinh IS INITIAL.
*l_cost = ( wa_sum_ordmats-stprs * l_diff ) / wa_sum_ordmats-peinh.
* l_cost = l_cost * -1.
* ENDIF.
*
* MOVE l_cost TO wa_nodestab-text5(20). " Variance "15
* wa_nodestab-tlength5 = c_20. "c_15
* wa_nodestab-tcolor5 = c_3.
*
* l_var_total = l_var_total + l_cost. " Subtotal of Variance
*
* APPEND wa_nodestab TO i_nodestab.
* CLEAR : wa_nodestab, wa_sum_ordmats.
* ENDLOOP.
** Displaying Subtotals
* IF NOT ( rb_fiscl IS INITIAL ).
*
* CLEAR wa_nodestab.
* wa_nodestab-id = c_4_1.
* wa_nodestab-tlevel = c_4.
* wa_nodestab-parent = c_3_2.
*
* IF rb_fiscl = c_x.
* CONCATENATE 'Fiscal quantity Totals:'(054) v_waers
* INTO wa_nodestab-text SEPARATED BY space.
* ELSE.
* wa_nodestab-text = 'Fiscal quantity Totals:'(054).
* ENDIF.
* wa_nodestab-tlength = c_30.
* wa_nodestab-tcolor = c_6.
*
* wa_nodestab-text1 = space.
* wa_nodestab-tlength1 = c_18.
* wa_nodestab-tcolor1 = c_6.
*
* MOVE l_act_total TO wa_nodestab-text2(20) .
* wa_nodestab-tlength2 = c_20.
* wa_nodestab-tcolor2 = c_6.
*
* MOVE l_std_total TO wa_nodestab-text3(20) .
* wa_nodestab-tlength3 = c_20.
* wa_nodestab-tcolor3 = c_6.
*
* wa_nodestab-text4 = space.
* wa_nodestab-tlength4 = c_19.
* wa_nodestab-tcolor4 = c_6.
*
* MOVE l_var_total TO wa_nodestab-text5(21) .
* wa_nodestab-tlength5 = c_21. "15.
* wa_nodestab-tcolor5 = c_6.
*
* APPEND wa_nodestab TO i_nodestab.
* ELSE.
* CLEAR wa_nodestab.
* wa_nodestab-id = c_4_1.
* wa_nodestab-tlevel = c_4.
* wa_nodestab-parent = c_3_2.
*
* IF rb_fiscl = c_x.
* CONCATENATE 'Variance Fiscal Total:'(055) v_waers
* INTO wa_nodestab-text SEPARATED BY space.
* ELSE.
* wa_nodestab-text = 'Variance Fiscal Total:'(055).
* ENDIF.
* wa_nodestab-tlength = c_29.
* wa_nodestab-tcolor = c_6.
*
* wa_nodestab-text1 = space.
* wa_nodestab-tlength1 = c_40.
* wa_nodestab-tcolor1 = c_6.
*
* wa_nodestab-text2 = space.
* wa_nodestab-tlength2 = '41'. "c_40.
* wa_nodestab-tcolor2 = c_6.
*
* MOVE l_var_total TO wa_nodestab-text3(20) .
* wa_nodestab-tlength3 = c_20. "c_15.
* wa_nodestab-tcolor3 = c_6.
*
* APPEND wa_nodestab TO i_nodestab.
* ENDIF.
*ENDFORM. " DISPLAY_SUMMARY_REPORT
**&---------------------------------------------------------------------
**
**& Form DISPLAY_PHASE_REPORT
**&---------------------------------------------------------------------
**
** text
**----------------------------------------------------------------------
**
**----------------------------------------------------------------------
**
*FORM display_phase_report.
*
* DATA: l_date_low(10) TYPE c,
* l_date_high(10) TYPE c,
* l_diff TYPE menge_d,
** l_plan_effic(3) TYPE c,
* l_plan_effic TYPE char05, "MOD-001++
* l_plant_effic TYPE char05, "MOD-001++
* l_gamng TYPE menge_d,
* l_gamng1(20) TYPE c,
* l_gmein TYPE meins,
*
* l_qty TYPE menge_d,
* l_prdqty TYPE menge_d,
* l_conv TYPE menge_d,
* l_aqty TYPE menge_d,
* l_sqty TYPE menge_d,
*
* l_pcent(3) TYPE p DECIMALS 2,
* l_cost(8) TYPE p DECIMALS 2,
*
* l_act_total(8) TYPE p DECIMALS 2,
* l_std_total(8) TYPE p DECIMALS 2,
* l_var_total(8) TYPE p DECIMALS 2,
*
* l_fromuom TYPE meins,
* l_cfuom TYPE meins,
*
* l_ph_bmsch TYPE i.
**- Begin of MOD-001
* DATA: l_value TYPE char16,
* l_tmp TYPE lmnga,
* l_tmp1 TYPE lmnga,
* l_effic TYPE p DECIMALS 1,
* l_uom TYPE char03.
**- End of MOD-001
*
*
* PERFORM pfstatus.
* SET PF-STATUS 'MAIN' EXCLUDING i_fcode.
* SET TITLEBAR 'VARI' WITH text-068.
*
* CLEAR wa_nodestab.
* REFRESH i_nodestab.
*
* MOVE 'Display Phase Report'(030) TO v_output_text.
* PERFORM inform_user_of_progress.
*
* CLEAR wa_nodestab.
* wa_nodestab-id = c_1_1.
* wa_nodestab-tlevel = c_1.
* wa_nodestab-text = 'Production Variances'(031).
* wa_nodestab-tlength = c_20.
* wa_nodestab-compress = c_x.
* APPEND wa_nodestab TO i_nodestab.
*
* LOOP AT i_pro_orders INTO wa_pro_orders.
*
* CLEAR: wa_nodestab, l_date_low, l_date_high, l_gamng,
* wa_material_des.
*
* l_gamng = wa_pro_orders-gamng.
* l_gmein = wa_pro_orders-gmein.
* wa_nodestab-id = c_2_1.
* wa_nodestab-tlevel = c_2.
* wa_nodestab-parent = c_1_1.
*
** Order Number text
* wa_nodestab-text = 'Order Num:'(032).
* wa_nodestab-tlength = c_12.
* wa_nodestab-tcolor = c_1.
** Order number
* WRITE wa_pro_orders-aufnr TO wa_nodestab-text1 NO-ZERO.
* wa_nodestab-tlength1 = c_12.
* wa_nodestab-tcolor1 = c_1.
* wa_nodestab-hotspot1 = c_x.
*
** Date Range
* WRITE wa_pro_orders-wdate TO l_date_low.
* WRITE wa_pro_orders-gltrp TO l_date_high.
* CONCATENATE l_date_low c_hyp l_date_high
* INTO wa_nodestab-text2 SEPARATED BY space.
* wa_nodestab-tlength2 = c_25.
* wa_nodestab-tcolor2 = c_1.
*
** Material Number
* WRITE wa_pro_orders-plnbez TO wa_nodestab-text3 NO-ZERO.
* wa_nodestab-tlength3 = c_18.
* wa_nodestab-tcolor3 = c_1.
*
** Material Description
* READ TABLE i_material_des INTO wa_material_des
* WITH KEY matnr = wa_pro_orders-plnbez.
* wa_nodestab-text4 = wa_material_des-maktx.
* wa_nodestab-tlength4 = c_33.
* wa_nodestab-tcolor4 = c_1.
*
* APPEND wa_nodestab TO i_nodestab.
*
* LOOP AT i_ordops INTO wa_ordops
* WHERE aufnr = wa_pro_orders-aufnr.
* PERFORM get_confirmation_qty USING wa_ordops-rueck
* l_prdqty l_cfuom.
* IF rb_kgm = c_x.
* IF rb_conf IS INITIAL.
* l_prdqty = wa_pro_orders-menge.
* l_fromuom = wa_pro_orders-gruom.
* ELSE.
* l_fromuom = l_cfuom.
* ENDIF.
** do gr/conf conversion
* PERFORM uom_convert USING wa_pro_orders-plnbez l_prdqty
* l_fromuom l_conv.
* l_prdqty = l_conv.
* l_qty = l_prdqty.
** do planned conversion
********mod-002*******************************
** l_fromuom = wa_pro_orders-gmein.
* l_fromuom = 'KG'.
*******MOD-002********************************
*
* PERFORM uom_convert USING wa_pro_orders-plnbez
* wa_pro_orders-gamng
* l_fromuom l_conv.
* l_gamng = l_conv.
* ELSE.
** Get Standard Numbers from the phase
* READ TABLE i_plpo INTO wa_plpo
* WITH KEY plnty = wa_pro_orders-plnty
* plnnr = wa_pro_orders-plnnr
* plnkn = wa_pro_orders-plnkn
* zaehl = wa_pro_orders-zaehl.
* PERFORM get_stds USING wa_ordops-plnty wa_ordops-plnnr
* wa_ordops-plnkn wa_ordops-zaehl.
** Factor in any differences in uoms (plpo selected in get_stds form)
* l_ph_bmsch = wa_plpo-bmsch / ( wa_plpo-umrez / wa_plpo-umren ).
** calculate planned phase qty as planned order qty / final phase std
*qty
** current phase std qty
* l_gamng = ( wa_pro_orders-gamng / wa_plpo-bmsch ) * l_ph_bmsch.
** Get actual produced Qty (from order) or use Confirm Qty (from phase)
* IF rb_conf IS INITIAL.
** Factor in any differences in uoms (plpo selected in plant_effic form)
* l_qty = ( wa_pro_orders-menge / wa_plpo-bmsch ) * l_ph_bmsch.
* l_prdqty = wa_pro_orders-menge.
* l_fromuom = wa_pro_orders-gruom.
* ELSE.
* l_qty = ( l_prdqty / wa_plpo-bmsch ) * l_ph_bmsch.
* l_fromuom = l_cfuom.
* ENDIF.
* ENDIF.
*
**- begin of MOD-001
** Calculate Plan effic.
** CLEAR l_plan_effic.
**
** IF l_gamng > 0.
** l_diff = ABS( l_gamng - l_qty ).
** l_plan_effic = c_100 - c_100 * ( l_diff / l_gamng ).
** ELSE.
** CLEAR l_plan_effic.
** ENDIF.
*
* LOOP AT i_plpo1 INTO wa_plpo1
* WHERE plnty = wa_pro_orders-plnty
* AND plnnr = wa_pro_orders-plnnr
* AND steus = 'YBN1'.
* IF wa_plpo1-vgw02 IS NOT INITIAL.
* MOVE wa_plpo1-usr04 TO l_effic. "L_VALUE.
* WRITE l_effic TO l_plan_effic.
* wa_plpo2 = wa_plpo1.
* APPEND wa_plpo2 TO i_plpo2.
**********MOD-002*******************************
** ELSE.
** CLEAR l_plan_effic.
* ENDIF.
*********MOD-002********************************
* ENDLOOP.
*
*
**- End of MOD-001
** Resource Information
* CLEAR wa_nodestab.
* wa_nodestab-id = c_2_2.
* wa_nodestab-tlevel = c_3.
* wa_nodestab-parent = c_1_1.
*
* CONCATENATE 'Resource:'(056) wa_pro_orders-arbpl
* INTO wa_nodestab-text SEPARATED BY space.
* wa_nodestab-tlength = c_25.
* wa_nodestab-tcolor = c_4.
*
* READ TABLE i_wc_text INTO wa_wc_text
* WITH KEY objid = wa_pro_orders-arbid.
* wa_nodestab-text1 = wa_wc_text-ktext.
* wa_nodestab-tlength1 = c_30.
* wa_nodestab-tcolor1 = c_4.
*
************MOD-002*********************************
* wa_nodestab-text2 = wa_ordops-vornr.
* wa_nodestab-tlength2 = c_4.
* wa_nodestab-tcolor2 = c_4.
*
*********mod-002************************************
*
** Produced Quantity / Confirmed Quantity
* MOVE l_prdqty TO wa_nodestab-text3(20).
* MOVE l_fromuom TO l_uom. " MOD-001++
* IF NOT ( rb_prod IS INITIAL ).
** CONCATENATE 'Prod Qty: '(033) wa_nodestab-text2 "MOD-001-
* CONCATENATE 'Prod Qty: '(033) wa_nodestab-text3 l_uom"MOD-001+
* INTO wa_nodestab-text3 SEPARATED BY space.
* ELSE.
** CONCATENATE 'Conf Qty: '(034) wa_nodestab-text2 "MOD-001-
* CONCATENATE 'Conf Qty: '(034) wa_nodestab-text3 l_uom"MOD-001+
* INTO wa_nodestab-text3 SEPARATED BY space.
* ENDIF.
*
** wa_nodestab-tlength2 = c_30. "MOD-001-
* wa_nodestab-tlength3 = c_35_1. "MOD-001+
* wa_nodestab-tcolor3 = c_1.
*
** CONCATENATE 'Plan Effic:'(036) l_plan_effic c_perc "'%'
* CONCATENATE 'Exp. Line Eff.'(036) l_plan_effic c_perc "'%'
* INTO wa_nodestab-text4 SEPARATED BY space.
* wa_nodestab-tlength4 = c_25.
* wa_nodestab-tcolor4 = c_4.
*
** CLEAR v_plant_effic.
** PERFORM plant_effic USING wa_ordops-plnty
** wa_ordops-plnnr
** wa_ordops-plnkn
** wa_ordops-zaehl
** CHANGING v_plant_effic.
* CLEAR l_effic.
**************mod-002**************************
** READ TABLE I_AFVC INTO WA_AFVC
** WITH KEY PLNTY = WA_PLPO1-PLNTY
** PLNNR = WA_PLPO1-PLNNR
** ZAEHL = WA_PLPO1-ZAEHL.
*** Mod-002***********************************
*
****************MOD-008************************
** LOOP AT I_ORDOPS INTO WA_ORDOPS.
** READ TABLE I_PRO_ORDERS INTO WA_PRO_ORDERS WITH KEY
** AUFNR = WA_ORDOPS-AUFNR
** BINARY SEARCH.
** IF SY-SUBRC = 0.
** READ table i_afvc1 into wa_afvc1 with key
** plnty = wa_ORDOPS-plnty
** plnnr = wa_ORDOPS-plnnr
** plnkn = wa_ORDOPS-plnkn
** zaehl = wa_ORDOPS-zaehl
** aufpl = wa_pro_orders-aufpl.
** IF SY-SUBRC = 0.
** READ TABLE I_AFVV1 into wa_afvv1 with key
** aufpl = wa_afvc1-aufpl
** aplzl = wa_afvc1-aplzl binary search.
** IF SY-SUBRC = 0.
** CHECK WA_AFVV1-VGW02 NE 0.
** l_tmp = wa_afvv1-bmsch * wa_afvv1-ism02.
** IF l_tmp IS NOT INITIAL.
**
** l_tmp1 = ( wa_afvv1-lmnga * wa_afvv1-vgw02 ) / l_tmp.
**
** l_tmp1 = l_tmp1 * 100.
**
** MOVE l_tmp1 TO l_effic.
**
** ENDIF.
** ENDIF.
** ENDIF.
** ENDIF.
** ENDLOOP.
**
**************MOD-008***************************
*
* LOOP AT i_plpo2 INTO wa_plpo2.
* READ TABLE i_afvc INTO wa_afvc
* WITH KEY plnty = wa_plpo2-plnty
* plnnr = wa_plpo2-plnnr
* plnkn = wa_plpo2-plnkn
* zaehl = wa_plpo2-zaehl
* aufpl = wa_pro_orders-aufpl.
*
*
*
*** Mod-002***********************************
*
* IF sy-subrc IS INITIAL.
* READ TABLE i_afvv INTO wa_afvv
* WITH KEY aufpl = wa_afvc-aufpl
* aplzl = wa_afvc-aplzl.
*
* l_tmp = wa_afvv-bmsch * wa_afvv-ism02.
* IF l_tmp IS NOT INITIAL.
*
* l_tmp1 = ( wa_afvv-lmnga * wa_afvv-vgw02 ) / l_tmp.
*
* l_tmp1 = l_tmp1 * 100.
*
* MOVE l_tmp1 TO l_effic.
*
* ENDIF.
*
* ENDIF.
* ENDLOOP.
*
* WRITE l_effic TO l_plant_effic.
*
** CONCATENATE 'Plant Effic:'(037) v_plant_effic c_perc "'%'
* CONCATENATE 'Act. Line Eff.'(037) l_plant_effic c_perc "'%'
* " MOD-001+
* INTO wa_nodestab-text5 SEPARATED BY space.
* wa_nodestab-tlength5 = c_25.
* wa_nodestab-tcolor5 = c_4.
*
* APPEND wa_nodestab TO i_nodestab.
*
** Phase Information
* CLEAR wa_nodestab.
* wa_nodestab-id = c_3_3.
* wa_nodestab-tlevel = c_3.
* wa_nodestab-parent = c_1_1.
*
* wa_nodestab-text = 'Phase'(038).
* wa_nodestab-tlength = c_10.
* wa_nodestab-tcolor = c_4.
*
* MOVE l_gamng TO l_gamng1.
* CONCATENATE 'Activity (Std Plan:'(039) l_gamng1 c_brac "')'
* INTO wa_nodestab-text1 SEPARATED BY space.
* wa_nodestab-tlength1 = c_42.
* wa_nodestab-tcolor1 = c_4.
*
* IF rb_fiscl = c_x.
* CONCATENATE 'Actual Usage'(040) v_waers
* INTO wa_nodestab-text2 SEPARATED BY space.
* ELSE.
* wa_nodestab-text2 = 'Actual Usage'(040).
* ENDIF.
* wa_nodestab-tlength2 = c_20.
* wa_nodestab-tcolor2 = c_4.
*
* IF rb_fiscl = c_x.
* CONCATENATE 'Standard Usage'(041) v_waers
* INTO wa_nodestab-text3 SEPARATED BY space.
* ELSE.
* wa_nodestab-text3 = 'Standard Usage'(041).
* ENDIF.
* wa_nodestab-tlength3 = c_20.
* wa_nodestab-tcolor3 = c_4.
*
* IF rb_fiscl = c_x.
* CONCATENATE 'Activity Variance'(042) v_waers
* INTO wa_nodestab-text4 SEPARATED BY space.
* ELSE.
* wa_nodestab-text4 = 'Activity Variance'(042).
* ENDIF.
* wa_nodestab-tlength4 = c_35.
* wa_nodestab-tcolor4 = c_4.
*
* APPEND wa_nodestab TO i_nodestab.
*
** Display acitivity report
* PERFORM activity_report USING l_prdqty l_gamng l_uom l_gmein.
*
** Material Information
* CLEAR: wa_nodestab, l_act_total, l_std_total, l_var_total.
* wa_nodestab-id = c_3_4.
* wa_nodestab-tlevel = c_3.
* wa_nodestab-parent = c_1_1.
*
* PERFORM material_header.
*
** Individual material details
* LOOP AT i_ordmats INTO wa_ordmats
* WHERE aufnr = wa_pro_orders-aufnr
* AND vornr = wa_ordops-vornr.
*
* CLEAR: wa_nodestab.
* wa_nodestab-id = c_4_1.
* wa_nodestab-tlevel = c_4.
* wa_nodestab-parent = c_3_2.
*
** Material Number
* WRITE wa_ordmats-matnr TO wa_nodestab-text NO-ZERO.
* wa_nodestab-tlength = c_18.
* wa_nodestab-tcolor = c_3.
*
** Material Description
* CLEAR wa_material_des.
* READ TABLE i_material_des INTO wa_material_des
* WITH KEY matnr = wa_ordmats-matnr.
* wa_nodestab-text1 = wa_material_des-maktx.
* wa_nodestab-tlength1 = c_30.
* wa_nodestab-tcolor1 = c_3.
*
** Standard planned or zero loss planned
*
* IF rb_zloss IS INITIAL.
* l_qty = wa_ordmats-stdqy.
* ELSE.
* l_qty = wa_ordmats-zloss.
* ENDIF.
*
** Order uom or kgm
* IF rb_kgm IS INITIAL.
* l_aqty = wa_ordmats-menge.
* l_sqty = l_qty.
* ELSE.
** do actual conversion
* PERFORM uom_convert USING wa_ordmats-matnr
* wa_ordmats-menge
* wa_ordmats-amein
* l_aqty.
** do std/zloss conversion
* PERFORM uom_convert USING wa_ordmats-matnr
* wa_ordmats-stdqy
* wa_ordmats-meins
* l_sqty.
* ENDIF.
*
* PERFORM std_percentage_calc USING l_aqty l_sqty l_pcent.
*
** Fiscal or quantity
* IF rb_fiscl IS INITIAL.
* MOVE l_aqty TO wa_nodestab-text2(20). " Actual Usage
* wa_nodestab-tlength2 = c_20.
* wa_nodestab-tcolor2 = c_3.
*
* MOVE l_sqty TO wa_nodestab-text3(20). " Standard Usage
* wa_nodestab-tlength3 = c_20.
* wa_nodestab-tcolor3 = c_3.
*
* ELSE.
* IF NOT wa_ordmats-peinh IS INITIAL.
* CLEAR l_cost.
* l_cost = ( wa_ordmats-stprs * wa_ordmats-menge )
* / wa_ordmats-peinh.
* MOVE l_cost TO wa_nodestab-text2(20). " Acutal Usage
* wa_nodestab-tlength2 = c_20.
* wa_nodestab-tcolor2 = c_3.
*
* l_act_total = l_act_total + l_cost. " Subtotal of actual
* ENDIF.
* IF NOT wa_ordmats-peinh IS INITIAL.
* CLEAR l_cost.
* l_cost = ( wa_ordmats-stprs * wa_ordmats-stdqy )
* / wa_ordmats-peinh.
* MOVE l_cost TO wa_nodestab-text3(20). " Standard Usage
* wa_nodestab-tlength3 = c_20.
* wa_nodestab-tcolor3 = c_3.
*
* l_std_total = l_std_total + l_cost. " Subtotal of standard
* ENDIF.
*
* ENDIF.
*
* MOVE l_pcent TO wa_nodestab-text4(17). " Variance Percentage
* CONCATENATE wa_nodestab-text4(17) c_perc "'%'
* INTO wa_nodestab-text4(19) SEPARATED BY space.
* wa_nodestab-tlength4 = 19.
* wa_nodestab-tcolor4 = c_3.
*
* CLEAR: l_diff, l_cost.
* l_diff = wa_ordmats-menge - wa_ordmats-stdqy.
* IF NOT wa_ordmats-peinh IS INITIAL.
* l_cost = ( wa_ordmats-stprs * l_diff ) / wa_ordmats-peinh.
* l_cost = l_cost * -1.
* ENDIF.
*
* MOVE l_cost TO wa_nodestab-text5(15). " Variance
* wa_nodestab-tlength5 = c_15.
* wa_nodestab-tcolor5 = c_3.
*
* l_var_total = l_var_total + l_cost. " Subtotal of Variance
*
* APPEND wa_nodestab TO i_nodestab.
*
* ENDLOOP.
*
** Displaying Subtotals
* CHECK sy-subrc IS INITIAL.
* CLEAR wa_nodestab.
* wa_nodestab-id = c_4_1.
* wa_nodestab-tlevel = c_4.
* wa_nodestab-parent = c_3_2.
*
* wa_nodestab-text = 'Material Totals'(043).
* wa_nodestab-tlength = c_18.
* wa_nodestab-tcolor = c_6.
*
* wa_nodestab-text1 = space.
* wa_nodestab-tlength1 = c_30.
* wa_nodestab-tcolor1 = c_6.
*
* MOVE l_act_total TO wa_nodestab-text2(20) .
* wa_nodestab-tlength2 = c_20.
* wa_nodestab-tcolor2 = c_6.
*
* MOVE l_std_total TO wa_nodestab-text3(20) .
* wa_nodestab-tlength3 = c_20.
* wa_nodestab-tcolor3 = c_6.
*
* wa_nodestab-text4 = space.
* wa_nodestab-tlength4 = c_19.
* wa_nodestab-tcolor4 = c_6.
*
* MOVE l_var_total TO wa_nodestab-text5(15) .
* wa_nodestab-tlength5 = c_15.
* wa_nodestab-tcolor5 = c_6.
*
* APPEND wa_nodestab TO i_nodestab.
*
* ENDLOOP.
** Output the materials which were issued to order but aren't on bom
* READ TABLE i_issued_mat INTO wa_issued_mat
* WITH KEY aufnr = wa_pro_orders-aufnr.
* IF sy-subrc = 0.
*
* CLEAR wa_nodestab.
* wa_nodestab-id = c_3_5.
* wa_nodestab-tlevel = c_3 .
* wa_nodestab-parent = c_1_1.
*
* wa_nodestab-text =
* 'Materials issued to order but not in Recipe'(057).
* wa_nodestab-tlength = c_45.
* wa_nodestab-tcolor = c_6.
*
* APPEND wa_nodestab TO i_nodestab.
*
** Material Information
* CLEAR wa_nodestab.
* wa_nodestab-id = c_3_6.
* wa_nodestab-tlevel = c_3.
* wa_nodestab-parent = c_3_5.
*
* PERFORM material_header.
** now write the components
*
* CLEAR: l_pcent, l_act_total, l_std_total, l_var_total.
*
* LOOP AT i_issued_mat INTO wa_issued_mat
* WHERE aufnr = wa_pro_orders-aufnr.
*
* CLEAR: wa_nodestab, l_aqty, l_sqty, l_cost, wa_material_des.
* wa_nodestab-id = c_6_1.
* wa_nodestab-tlevel = c_6.
* wa_nodestab-parent = c_3_6.
*
** Material Number
* WRITE wa_issued_mat-matnr TO wa_nodestab-text NO-ZERO.
* wa_nodestab-tlength = c_18.
* wa_nodestab-tcolor = c_3.
*
** Material Description
* READ TABLE i_material_des INTO wa_material_des
* WITH KEY matnr = wa_issued_mat-matnr.
* wa_nodestab-text1 = wa_material_des-maktx.
* wa_nodestab-tlength1 = c_30.
* wa_nodestab-tcolor1 = c_3.
*
* IF rb_fiscl IS INITIAL.
** Actual Usage
* l_aqty = wa_issued_mat-menge.
* MOVE l_aqty TO wa_nodestab-text2(20). " Actual Usage
* wa_nodestab-tlength2 = c_20.
* wa_nodestab-tcolor2 = c_3.
*
** Standard Usage
* MOVE l_sqty TO wa_nodestab-text3(20). " Standard Usage
* wa_nodestab-tlength3 = c_20.
* wa_nodestab-tcolor3 = c_3.
*
* ELSE.
* IF NOT wa_issued_mat-peinh IS INITIAL.
* l_cost = ( wa_issued_mat-stprs * wa_issued_mat-menge )
* / wa_issued_mat-peinh.
* ENDIF.
* l_act_total = l_act_total + l_cost. " Subtotal of actual
*
* MOVE l_cost TO wa_nodestab-text2(20). " Acutal Usage
* wa_nodestab-tlength2 = c_20.
* wa_nodestab-tcolor2 = c_3.
*
* CLEAR l_cost.
* MOVE l_cost TO wa_nodestab-text3(20). " Standard Usage
* wa_nodestab-tlength3 = c_20.
* wa_nodestab-tcolor3 = c_3.
*
* ENDIF.
** Variance percentage
* l_pcent = 100.
* MOVE l_pcent TO wa_nodestab-text4(17). " Variance Percentage
* CONCATENATE wa_nodestab-text4(17) c_perc "'%'
* INTO wa_nodestab-text4(19) SEPARATED BY space.
* wa_nodestab-tlength4 = c_19.
* wa_nodestab-tcolor4 = c_3.
** Variance
* CLEAR l_cost.
* IF NOT wa_issued_mat-peinh IS INITIAL.
* l_cost = ( wa_issued_mat-stprs * wa_issued_mat-menge )
* / wa_issued_mat-peinh.
* l_cost = l_cost * -1.
* ENDIF.
* l_var_total = l_var_total + l_cost. " Subtotal of Variance
*
* MOVE l_cost TO wa_nodestab-text5(15). " Variance
* wa_nodestab-tlength5 = c_15.
* wa_nodestab-tcolor5 = c_3.
*
* APPEND wa_nodestab TO i_nodestab.
*
* ENDLOOP.
*
** Displaying Subtotals of material recipe
*
* CLEAR wa_nodestab.
* wa_nodestab-id = c_6_1.
* wa_nodestab-tlevel = c_6.
* wa_nodestab-parent = c_3_5.
*
* wa_nodestab-text = 'Material Totals'(043).
* wa_nodestab-tlength = c_18.
* wa_nodestab-tcolor = c_6.
*
* wa_nodestab-text1 = space.
* wa_nodestab-tlength1 = c_30.
* wa_nodestab-tcolor1 = c_6.
*
* MOVE l_act_total TO wa_nodestab-text2(20) .
* wa_nodestab-tlength2 = c_20.
* wa_nodestab-tcolor2 = c_6.
*
* MOVE l_std_total TO wa_nodestab-text3(20) .
* wa_nodestab-tlength3 = c_20.
* wa_nodestab-tcolor3 = c_6.
*
* wa_nodestab-text4 = space.
* wa_nodestab-tlength4 = c_19.
* wa_nodestab-tcolor4 = c_6.
*
* MOVE l_var_total TO wa_nodestab-text5(15) .
* wa_nodestab-tlength5 = c_15.
* wa_nodestab-tcolor5 = c_6.
*
* APPEND wa_nodestab TO i_nodestab.
*
* ENDIF.
*
* ENDLOOP.
*
*ENDFORM. " DISPLAY_PHASE_REPORT
**&---------------------------------------------------------------------
**
**& Form ACTIVITY_REPORT
**&---------------------------------------------------------------------
**
** text
**----------------------------------------------------------------------
**
**----------------------------------------------------------------------
**
*FORM activity_report USING fp_l_prdqty TYPE menge_d
* fp_l_gamng TYPE menge_d
* fp_l_uom TYPE meins
* fp_l_gmein TYPE meins.
* DATA: l_value TYPE gamng,
* l_ism01_var TYPE ru_ismng,
* l_ism02_var TYPE ru_ismng,
* l_ism03_var TYPE ru_ismng,
* l_ism04_var TYPE ru_ismng,
* l_ism05_var TYPE ru_ismng,
* l_ism06_var TYPE ru_ismng.
* DATA: struct_afvgd TYPE afvgd.
* DATA: struct_mara TYPE mara,
* struct_marc TYPE marc.
* DATA: v_menge TYPE menge_d.
*
** Get Standard Numbers from the phase
* PERFORM get_stds USING wa_ordops-plnty wa_ordops-plnnr
* wa_ordops-plnkn wa_ordops-zaehl.
*
** Calculate Standard Labour/Fitter/Machine Hours.
* CLEAR struct_activity.
* MOVE-CORRESPONDING wa_plpo1 TO struct_afvgd. "#EC ENHOK
* MOVE: wa_ordops-arbid TO struct_afvgd-arbid,
* wa_ordops-ssavd TO struct_afvgd-ssavd.
* MOVE wa_plpo1-vge01 TO v_msehi.
*
* IF rb_actl IS INITIAL.
** Planned qty
* l_value = fp_l_gamng.
* ELSE.
** Actual qty
* l_value = fp_l_prdqty.
* ENDIF.
*
* CALL FUNCTION 'CO_R0_DET_TOTAL_ACTIVITY'
* EXPORTING
* act_afvgd = struct_afvgd
* act_quantity = l_value
* act_flg_consider_conf = space
* act_unit_of_time = v_msehi
* IMPORTING
* exp_activities = struct_activity.
*
** Now get the confirmed values
* PERFORM get_confirmation_details.
*
** Get Activity 1
* l_ism01_var = struct_activity-acti1 - wa_ord_conf1-ism01.
** Get Activity 2
* l_ism02_var = struct_activity-acti2 - wa_ord_conf1-ism02.
** Get Activity 3
* l_ism03_var = struct_activity-acti3 - wa_ord_conf1-ism03.
** Get Activity 4
* l_ism04_var = struct_activity-acti4 - wa_ord_conf1-ism04.
** Get Activity 5
* l_ism05_var = struct_activity-acti5 - wa_ord_conf1-ism05.
** Get Activity 6
* l_ism06_var = struct_activity-acti6 - wa_ord_conf1-ism06.
*
* IF rb_summ IS INITIAL.
** Now output the activities for each phase
* IF NOT ( wa_plpo1-lar01 IS INITIAL ).
* PERFORM activity_cost_report USING wa_plpo1-lar01
* wa_ord_conf1-ism01
* struct_activity-acti1
* l_ism01_var.
* ENDIF.
* IF NOT ( wa_plpo1-lar02 IS INITIAL ).
* PERFORM activity_cost_report USING wa_plpo1-lar02
* wa_ord_conf1-ism02
* struct_activity-acti2
* l_ism02_var.
* ENDIF.
* IF NOT ( wa_plpo1-lar03 IS INITIAL ).
* PERFORM activity_cost_report USING wa_plpo1-lar03
* wa_ord_conf1-ism03
* struct_activity-acti3
* l_ism03_var.
* ENDIF.
* IF NOT ( wa_plpo1-lar04 IS INITIAL ).
* PERFORM activity_cost_report USING wa_plpo1-lar04
* wa_ord_conf1-ism04
* struct_activity-acti4
* l_ism04_var.
* ENDIF.
* IF NOT ( wa_plpo1-lar05 IS INITIAL ).
* PERFORM activity_cost_report USING wa_plpo1-lar05
* wa_ord_conf1-ism05
* struct_activity-acti5
* l_ism05_var.
* ENDIF.
* IF NOT ( wa_plpo1-lar06 IS INITIAL ).
* PERFORM activity_cost_report USING wa_plpo1-lar06
* wa_ord_conf1-ism06
* struct_activity-acti6
* l_ism06_var.
* ENDIF.
* ELSEIF rb_summ = c_x.
* IF NOT ( wa_plpo1-lar01 IS INITIAL ).
* PERFORM sum_activity_costs USING wa_plpo1-lar01
* wa_ord_conf1-ism01
* struct_activity-acti1
* l_ism01_var.
* ENDIF.
* IF NOT ( wa_plpo1-lar02 IS INITIAL ).
* PERFORM sum_activity_costs USING wa_plpo1-lar02
* wa_ord_conf1-ism02
* struct_activity-acti2
* l_ism02_var.
* ENDIF.
* IF NOT ( wa_plpo1-lar03 IS INITIAL ).
* PERFORM sum_activity_costs USING wa_plpo1-lar03
* wa_ord_conf1-ism03
* struct_activity-acti3
* l_ism03_var.
* ENDIF.
* IF NOT ( wa_plpo1-lar04 IS INITIAL ).
* PERFORM sum_activity_costs USING wa_plpo1-lar04
* wa_ord_conf1-ism04
* struct_activity-acti4
* l_ism04_var.
* ENDIF.
* IF NOT ( wa_plpo1-lar05 IS INITIAL ).
* PERFORM sum_activity_costs USING wa_plpo1-lar05
* wa_ord_conf1-ism05
* struct_activity-acti5
* l_ism05_var.
* ENDIF.
* IF NOT ( wa_plpo1-lar06 IS INITIAL ).
* PERFORM sum_activity_costs USING wa_plpo1-lar06
* wa_ord_conf1-ism06
* struct_activity-acti6
* l_ism06_var.
* ENDIF.
*
* ENDIF.
*
*ENDFORM. " ACTIVITY_REPORT
**&---------------------------------------------------------------------
**
**& Form GET_STDS
**&---------------------------------------------------------------------
**
** text
**----------------------------------------------------------------------
**
** --> p1 text
** <-- p2 text
**----------------------------------------------------------------------
**
*FORM get_stds USING fp_p_plnty TYPE plnty
* fp_p_plnnr TYPE plnnr
* fp_p_plnkn TYPE plnkn
* fp_p_zaehl TYPE cim_count.
*
* TYPES: BEGIN OF ty_crco_info,
* objty TYPE cr_objty,
* objid TYPE cr_objid,
* laset TYPE cr_laset,
* endda TYPE enddatum,
* lanum TYPE cr_lanum,
* begda TYPE begdatum,
* lstar_ref TYPE ap_kzref,
* lstar TYPE lstar,
* END OF ty_crco_info.
*
* DATA : i_crco_info TYPE STANDARD TABLE OF ty_crco_info,
* wa_crco_info TYPE ty_crco_info.
*
*
* DATA: l_wcinfo TYPE c,
* l_datuv TYPE plpo-datuv,
* lc_objty TYPE plpo-objty VALUE 'A'.
*
* READ TABLE i_plpo1 INTO wa_plpo1 WITH KEY plnty = fp_p_plnty
* plnnr = fp_p_plnnr
* plnkn = fp_p_plnkn
* zaehl = fp_p_zaehl.
* IF sy-subrc = 0.
*
* IF ( wa_plpo1-lar01 IS INITIAL AND NOT ( wa_plpo1-vgw01 = 0 ) ) OR
* ( wa_plpo1-lar02 IS INITIAL AND NOT ( wa_plpo1-vgw02 = 0 ) ) OR
* ( wa_plpo1-lar03 IS INITIAL AND NOT ( wa_plpo1-vgw03 = 0 ) ) OR
* ( wa_plpo1-lar04 IS INITIAL AND NOT ( wa_plpo1-vgw04 = 0 ) ) OR
* ( wa_plpo1-lar05 IS INITIAL AND NOT ( wa_plpo1-vgw05 = 0 ) ) OR
* ( wa_plpo1-lar06 IS INITIAL AND NOT ( wa_plpo1-vgw06 = 0 ) ).
* REFRESH: i_crco_info.
** Check the work centre is on the phase, if not go to the operation
* IF wa_plpo1-arbid IS INITIAL.
* SELECT datuv arbid objty
* INTO (l_datuv,wa_plpo1-arbid,wa_plpo1-objty)
* FROM plpo
* WHERE plnty = wa_pro_orders-plnty
* AND plnnr = wa_pro_orders-plnnr
* AND plnkn = wa_plpo1-pvzkn
* AND datuv <= sy-datum
* ORDER BY datuv DESCENDING.
* EXIT.
* ENDSELECT.
* ENDIF.
** Default to work centre object if it's blank
* IF wa_plpo1-objty IS INITIAL.
* wa_plpo1-objty = lc_objty.
* ENDIF.
** Get the work centre activity info
* SELECT objty objid laset endda lanum begda lstar_ref lstar
* INTO TABLE i_crco_info
* FROM crco
* WHERE objty = wa_plpo1-objty
* AND objid = wa_plpo1-arbid
* AND laset = 1.
** order by primary key.
*
* IF sy-subrc = 0.
**Not required to handle
* ENDIF.
*
* l_wcinfo = c_y.
* ENDIF.
* IF l_wcinfo = c_y.
** Use work centre info.
* LOOP AT i_crco_info INTO wa_crco_info
* WHERE begda <= wa_plpo1-datuv AND
* endda >= wa_plpo1-datuv.
* CHECK NOT wa_crco_info-lstar_ref IS INITIAL.
* CASE wa_crco_info-lanum.
** Only put the activity type in if there is a std value entered
* WHEN 1.
* IF wa_plpo1-vgw01 NE 0.
* wa_plpo1-lar01 = wa_crco_info-lstar.
* ENDIF.
* WHEN 2.
* IF wa_plpo1-vgw02 NE 0.
* wa_plpo1-lar02 = wa_crco_info-lstar.
* ENDIF.
* WHEN 3.
* IF wa_plpo1-vgw03 NE 0.
* wa_plpo1-lar03 = wa_crco_info-lstar.
* ENDIF.
* WHEN 4.
* IF wa_plpo1-vgw04 NE 0.
* wa_plpo1-lar04 = wa_crco_info-lstar.
* ENDIF.
* WHEN 5.
* IF wa_plpo1-vgw05 NE 0.
* wa_plpo1-lar05 = wa_crco_info-lstar.
* ENDIF.
* WHEN 6.
* IF wa_plpo1-vgw06 NE 0.
* wa_plpo1-lar06 = wa_crco_info-lstar.
* ENDIF.
* ENDCASE.
* ENDLOOP.
* ENDIF.
*
* ENDIF.
*
*ENDFORM. " GET_STDS
**&---------------------------------------------------------------------
**
**& Form get_confirmation_details
**&---------------------------------------------------------------------
**
** text
**----------------------------------------------------------------------
**
**----------------------------------------------------------------------
**
*FORM get_confirmation_details.
*
* DATA: l_last_ism01 TYPE ru_ismng,
* l_last_ism02 TYPE ru_ismng,
* l_last_ism03 TYPE ru_ismng,
* l_last_ism04 TYPE ru_ismng,
* l_last_ism05 TYPE ru_ismng,
* l_last_ism06 TYPE ru_ismng.
*
* LOOP AT i_ord_conf1 INTO wa_ord_conf1
* WHERE rueck = wa_ordops-rueck.
* IF wa_ord_conf1-stokz IS INITIAL.
* l_last_ism01 = l_last_ism01 + wa_ord_conf1-ism01.
* l_last_ism02 = l_last_ism02 + wa_ord_conf1-ism02.
* l_last_ism03 = l_last_ism03 + wa_ord_conf1-ism03.
* l_last_ism04 = l_last_ism04 + wa_ord_conf1-ism04.
* l_last_ism05 = l_last_ism05 + wa_ord_conf1-ism05.
* l_last_ism06 = l_last_ism06 + wa_ord_conf1-ism06.
* ELSE.
* l_last_ism01 = l_last_ism01 - wa_ord_conf1-ism01.
* l_last_ism02 = l_last_ism02 - wa_ord_conf1-ism02.
* l_last_ism03 = l_last_ism03 - wa_ord_conf1-ism03.
* l_last_ism04 = l_last_ism04 - wa_ord_conf1-ism04.
* l_last_ism05 = l_last_ism05 - wa_ord_conf1-ism05.
* l_last_ism06 = l_last_ism06 - wa_ord_conf1-ism06.
* ENDIF.
* CLEAR : wa_ord_conf1.
* ENDLOOP.
*
* MOVE l_last_ism01 TO wa_ord_conf1-ism01.
* MOVE l_last_ism02 TO wa_ord_conf1-ism02.
* MOVE l_last_ism03 TO wa_ord_conf1-ism03.
* MOVE l_last_ism04 TO wa_ord_conf1-ism04.
* MOVE l_last_ism05 TO wa_ord_conf1-ism05.
* MOVE l_last_ism06 TO wa_ord_conf1-ism06.
*
*
*ENDFORM. " get_confirmation_details
**&---------------------------------------------------------------------
**
**& Form activity_cost_report
**&---------------------------------------------------------------------
**
** text
**----------------------------------------------------------------------
**
** -->P_I_PLPO1_LAR01 text
** -->P_I_ORD_CONF1_ISM01 text
** -->P_struct_activity_ACTI1 text
** -->P_ISM01_VAR text
**----------------------------------------------------------------------
**
*FORM activity_cost_report USING fp_p_i_plpo1_lar01 TYPE lstar
* fp_p_i_ord_conf1_ism01 TYPE ru_ismng
* fp_p_struct_activity_acti1 TYPE co_smng13
* fp_p_ism01_var TYPE ru_ismng.
* DATA: l_ltext TYPE ktext,
* l_kokrs TYPE kokrs,
* l_kostl TYPE kostl,
* l_objnr TYPE j_objnr,
* l_tkg001 TYPE tkgxxx,
* l_tke001 TYPE tkexxx,
* l_std(8) TYPE p DECIMALS 2,
* l_act(8) TYPE p DECIMALS 2,
* l_var(8) TYPE p DECIMALS 2.
*
* SELECT ltext FROM cslt INTO l_ltext
* WHERE spras = sy-langu
* AND kokrs = p_kokrs
* AND lstar = fp_p_i_plpo1_lar01.
* ENDSELECT.
*
* IF sy-subrc = 0.
**Not required to handle
* ENDIF.
*
* IF rb_fiscl IS INITIAL.
*
* CLEAR wa_nodestab.
* wa_nodestab-id = c_3_1.
* wa_nodestab-tlevel = c_4.
* wa_nodestab-parent = c_3_2.
*
* wa_nodestab-text = wa_ordops-vornr.
* wa_nodestab-tlength = c_4.
*
* wa_nodestab-text1 = l_ltext.
* wa_nodestab-tlength1 = c_44.
*
* MOVE fp_p_i_ord_conf1_ism01 TO wa_nodestab-text2(20).
* wa_nodestab-tlength2 = c_20.
*
* MOVE fp_p_struct_activity_acti1 TO wa_nodestab-text3(20).
* wa_nodestab-tlength3 = c_20.
*
* MOVE fp_p_ism01_var TO wa_nodestab-text4(20).
* wa_nodestab-tlength4 = c_20.
*
* ELSE.
*
* SELECT kokrs kostl
* FROM crco UP TO 1 ROWS
* INTO (l_kokrs, l_kostl)
* WHERE objty = c_a
* AND objid = wa_ordops-arbid
* AND lstar = fp_p_i_plpo1_lar01.
* ENDSELECT.
*
* IF sy-subrc = 0.
**Not required to handle
* ENDIF.
*
* SELECT SINGLE objnr INTO l_objnr
* FROM cssl
* WHERE kokrs = l_kokrs
* AND kostl = l_kostl
* AND lstar = fp_p_i_plpo1_lar01
* AND gjahr = sy-datum+0(4).
*
* IF sy-subrc = 0.
**Not required to handle
* ENDIF.
*
* SELECT tkg001 tke001 INTO (l_tkg001, l_tke001)
* FROM cost
* WHERE objnr = l_objnr
* AND gjahr = sy-datum+0(4)
* AND versn = c_000.
* ENDSELECT.
*
* IF sy-subrc = 0.
**Not required to handle
* ENDIF.
*
* CLEAR: l_act, l_std, l_var.
*** The following were changed to take into account the unit
*** price factor.
* l_act = ( fp_p_i_ord_conf1_ism01 * l_tkg001 ) / l_tke001.
* l_std = ( fp_p_struct_activity_acti1 * l_tkg001 ) / l_tke001.
* l_var = ( fp_p_ism01_var * l_tkg001 ) / l_tke001.
*
* CLEAR wa_nodestab.
* wa_nodestab-id = c_3_1.
* wa_nodestab-tlevel = c_4.
* wa_nodestab-parent = c_3_2.
*
* wa_nodestab-text = wa_ordops-vornr.
* wa_nodestab-tlength = c_4.
*
* wa_nodestab-text1 = l_ltext.
* wa_nodestab-tlength1 = c_44.
*
* MOVE l_act TO wa_nodestab-text2(20).
* wa_nodestab-tlength2 = c_20.
*
* MOVE l_std TO wa_nodestab-text3(20).
* wa_nodestab-tlength3 = c_20.
*
* MOVE l_var TO wa_nodestab-text4(20).
* wa_nodestab-tlength4 = c_20.
*
* ENDIF.
*
* IF flg_color = c_x.
* CLEAR flg_color.
* wa_nodestab-tcolor = c_3.
* wa_nodestab-tcolor1 = c_3.
* wa_nodestab-tcolor2 = c_3.
* wa_nodestab-tcolor3 = c_3.
* wa_nodestab-tcolor4 = c_3.
* ELSE.
* flg_color = c_x.
* wa_nodestab-tcolor = c_2.
* wa_nodestab-tcolor1 = c_2.
* wa_nodestab-tcolor2 = c_2.
* wa_nodestab-tcolor3 = c_2.
* wa_nodestab-tcolor4 = c_2.
* ENDIF.
*
* APPEND wa_nodestab TO i_nodestab.
*
*
*ENDFORM. " activity_cost_report
**&---------------------------------------------------------------------
**
**& Form uom_convert
**&---------------------------------------------------------------------
**
** text
**----------------------------------------------------------------------
**
** -->P_I_ORDMATS_MATNR text
** -->P_I_ORDMATS_MENGE text
** -->P_I_ORDMATS_AMEIN text
** -->P_L_AQTY text
**----------------------------------------------------------------------
**
*FORM uom_convert USING fp_p_i_ordmats_matnr TYPE matnr
* fp_p_i_ordmats_menge TYPE menge_d
* fp_p_i_ordmats_amein TYPE meins
* fp_p_l_aqty TYPE menge_d.
*
**Added for WIRR
* DATA : struct_mara TYPE mara,
* struct_t006 TYPE t006.
* DATA: v_menge TYPE menge_d.
*
* CONSTANTS : c_halb TYPE mtart VALUE 'HALB',
* c_fert TYPE mtart VALUE 'FERT',
* c_kgm TYPE msehi VALUE 'KGM'.
*
*****************************************
** Need some clarification on this form *
*****************************************
*
** If the material is type FERT or HALB then use the net weight field
** from the material master. Otherwise use the alt uom for KG.
* SELECT SINGLE * FROM mara
**Added for WIRR
* INTO struct_mara
**Added for WIRR
*
* WHERE matnr = fp_p_i_ordmats_matnr.
*
* IF ( struct_mara-mtart = c_fert
* OR struct_mara-mtart = c_halb )
* AND NOT ( struct_mara-ntgew IS INITIAL ).
**************MOD-002*************************************************
**
* CLEAR: v_menge.
* IF struct_mara-gewei NE 'KG'.
* IF struct_mara-gewei = 'G'.
* CALL FUNCTION 'MD_CONVERT_MATERIAL_UNIT'
* EXPORTING
* i_matnr = fp_p_i_ordmats_matnr
* i_in_me = fp_p_i_ordmats_amein
* i_out_me = struct_mara-meins
* i_menge = fp_p_i_ordmats_menge
* IMPORTING
* e_menge = v_menge
* EXCEPTIONS
* error_in_application = 1
* error = 2
* OTHERS = 3.
* IF sy-subrc = 0.
* fp_p_l_aqty =
* v_menge * ( struct_mara-ntgew / 1000 ).
* ENDIF.
* ENDIF.
* ELSE.
*************MOD-002**************************************************
**
*************MOD-003**************************************************
* IF struct_mara-meins NE fp_p_i_ordmats_amein.
* CALL FUNCTION 'MD_CONVERT_MATERIAL_UNIT'
* EXPORTING
* i_matnr = fp_p_i_ordmats_matnr
* i_in_me = fp_p_i_ordmats_amein
* i_out_me = struct_mara-meins
* i_menge = fp_p_i_ordmats_menge
* IMPORTING
* e_menge = fp_p_i_ordmats_menge
* EXCEPTIONS
* error_in_application = 1
* error = 2
* OTHERS = 3.
* IF sy-subrc = 0.
* fp_p_l_aqty = fp_p_i_ordmats_menge * struct_mara-ntgew.
* ENDIF.
* ELSE.
* fp_p_l_aqty = fp_p_i_ordmats_menge * struct_mara-ntgew.
* ENDIF.
************MOD-003***************************************************
* ENDIF.
* ELSE.
** Get the isocode for kgm
* SELECT SINGLE * FROM t006
* INTO struct_t006
* WHERE msehi = c_kgm.
*
* IF fp_p_i_ordmats_amein = struct_t006-msehi.
* MOVE fp_p_i_ordmats_menge TO fp_p_l_aqty.
* ELSE.
* CALL FUNCTION 'MATERIAL_UNIT_CONVERSION'
* EXPORTING
* kzmeinh = c_x
* input = fp_p_i_ordmats_menge
* matnr = fp_p_i_ordmats_matnr
* meinh = struct_t006-msehi
* IMPORTING
* output = fp_p_l_aqty
* EXCEPTIONS
* conversion_not_found = 1
* input_invalid = 2
* material_not_found = 3
* meinh_not_found = 4
* meins_missing = 5
* no_meinh = 6
* output_invalid = 7
* overflow = 8
* OTHERS = 9.
*
******************
* IF sy-subrc NE 0.
* fp_p_l_aqty = 0.
* ENDIF.
*
*
******************
* ENDIF.
* ENDIF.
*
*ENDFORM. " uom_convert
**&---------------------------------------------------------------------
**
**& Form STD_PERCENTAGE_CALC
**&---------------------------------------------------------------------
**
** text
**----------------------------------------------------------------------
**
** -->P_L_AQTY text
** -->P_L_SQTY text
** -->P_L_PCENT text
**----------------------------------------------------------------------
**
*FORM std_percentage_calc USING fp_l_aqty TYPE menge_d
* fp_l_sqty TYPE menge_d
* fp_l_pcent TYPE any.
*
* CONSTANTS: c_percent_p TYPE stprs VALUE '999.99',
* c_percent_n TYPE stprs VALUE '-999.99'.
*
* DATA: l_tcent(10) TYPE p DECIMALS 5,
* l_pecent(3) TYPE p DECIMALS 2.
*
* CLEAR: l_tcent, l_pecent.
* IF fp_l_aqty NE 0 AND fp_l_sqty NE 0.
* l_tcent = ( ( fp_l_sqty - fp_l_aqty ) / fp_l_sqty ) * c_100.
* ELSEIF fp_l_aqty EQ 0 AND fp_l_sqty EQ 0.
* l_tcent = 0.
* ELSE.
* MOVE c_100 TO l_tcent.
* ENDIF.
* IF l_tcent GT c_percent_p.
* MOVE c_percent_p TO l_pecent.
* ELSEIF l_tcent LT c_percent_n.
* MOVE c_percent_n TO l_pecent.
* ELSE.
* MOVE l_tcent TO l_pecent.
* ENDIF.
*** Add a calculation to convert by-product percentages to the correct
*** sign.
* IF fp_l_sqty < 0.
* l_pecent = l_pecent * -1.
* ENDIF.
* fp_l_pcent = l_pecent.
*
*ENDFORM. " STD_PERCENTAGE_CALC
*
**&---------------------------------------------------------------------
**
**& Form DISPLAY
**&---------------------------------------------------------------------
**
** text
**----------------------------------------------------------------------
**
**----------------------------------------------------------------------
**
*FORM display.
*
* CASE c_x.
* WHEN rb_summ.
* PERFORM display_summary_report.
* WHEN rb_detl.
* PERFORM display_detail_report.
* WHEN rb_phase.
* PERFORM display_phase_report.
* ENDCASE.
* PERFORM list_display.
*
*ENDFORM. " DISPLAY
**&---------------------------------------------------------------------
**
**& Form plant_effic
**&---------------------------------------------------------------------
**
** text
**----------------------------------------------------------------------
**
** -->P_I_PRO_ORDERS_RUECK text
** -->P_I_PRO_ORDERS_PLNTY text
** -->P_I_PRO_ORDERS_PLNNR text
** -->P_I_PRO_ORDERS_PLNKN text
** -->P_I_PRO_ORDERS_ZAEHL text
** <--P_V_plant_effic text
**----------------------------------------------------------------------
**
*FORM plant_effic USING fp_p_plnty TYPE plnty
* fp_p_plnnr TYPE plnnr
* fp_p_plnkn TYPE plnkn
* fp_p_zaehl TYPE cim_count
* CHANGING fp_v_plant_effic TYPE any.
*
* FIELD-SYMBOLS: <fs_ism> TYPE ANY,
* <fs_vgw> TYPE ANY.
*
* DATA: l_last_ism01 TYPE ru_ismng,
* l_last_ism02 TYPE ru_ismng,
* l_last_ism03 TYPE ru_ismng,
* l_last_ism04 TYPE ru_ismng,
* l_last_ism05 TYPE ru_ismng,
* l_last_ism06 TYPE ru_ismng,
* l_pqty TYPE menge_d,
* l_real_effic(8) TYPE p DECIMALS 4,
* l_should_effic(8) TYPE p DECIMALS 4.
*
* PERFORM get_stds_main USING fp_p_plnty fp_p_plnnr fp_p_plnkn
* fp_p_zaehl.
*
*
* LOOP AT i_ord_conf INTO wa_ord_conf
* WHERE rueck = wa_ordops-rueck.
* IF wa_ord_conf1-stokz IS INITIAL.
* l_last_ism01 = l_last_ism01 + wa_ord_conf-ism01.
* l_last_ism02 = l_last_ism02 + wa_ord_conf-ism02.
* l_last_ism03 = l_last_ism03 + wa_ord_conf-ism03.
* l_last_ism04 = l_last_ism04 + wa_ord_conf-ism04.
* l_last_ism05 = l_last_ism05 + wa_ord_conf-ism05.
* l_last_ism06 = l_last_ism06 + wa_ord_conf-ism06.
* ELSE.
* l_last_ism01 = l_last_ism01 - wa_ord_conf-ism01.
* l_last_ism02 = l_last_ism02 - wa_ord_conf-ism02.
* l_last_ism03 = l_last_ism03 - wa_ord_conf-ism03.
* l_last_ism04 = l_last_ism04 - wa_ord_conf-ism04.
* l_last_ism05 = l_last_ism05 - wa_ord_conf-ism05.
* l_last_ism06 = l_last_ism06 - wa_ord_conf-ism06.
* ENDIF.
*
* CLEAR : wa_ord_conf.
* ENDLOOP.
*
* MOVE l_last_ism01 TO wa_ord_conf-ism01.
* MOVE l_last_ism02 TO wa_ord_conf-ism02.
* MOVE l_last_ism03 TO wa_ord_conf-ism03.
* MOVE l_last_ism04 TO wa_ord_conf-ism04.
* MOVE l_last_ism05 TO wa_ord_conf-ism05.
* MOVE l_last_ism06 TO wa_ord_conf-ism06.
*
* ASSIGN c_0 TO <fs_ism>.
* ASSIGN c_0 TO <fs_vgw>.
*
* IF wa_plpo-lar01 EQ p_machs.
* ASSIGN wa_ord_conf-ism01 TO <fs_ism>.
* ASSIGN wa_plpo-vgw01 TO <fs_vgw>.
* ENDIF.
* IF wa_plpo-lar02 EQ p_machs.
* ASSIGN wa_ord_conf-ism02 TO <fs_ism>.
* ASSIGN wa_plpo-vgw02 TO <fs_vgw>.
* ENDIF.
* IF wa_plpo-lar03 EQ p_machs.
* ASSIGN wa_ord_conf-ism03 TO <fs_ism>.
* ASSIGN wa_plpo-vgw03 TO <fs_vgw>.
* ENDIF.
* IF wa_plpo-lar04 EQ p_machs.
* ASSIGN wa_ord_conf-ism04 TO <fs_ism>.
* ASSIGN wa_plpo-vgw04 TO <fs_vgw>.
* ENDIF.
* IF wa_plpo-lar05 EQ p_machs.
* ASSIGN wa_ord_conf-ism05 TO <fs_ism>.
* ASSIGN wa_plpo-vgw05 TO <fs_vgw>.
* ENDIF.
* IF wa_plpo-lar06 EQ p_machs.
* ASSIGN wa_ord_conf-ism06 TO <fs_ism>.
* ASSIGN wa_plpo-vgw06 TO <fs_vgw>.
* ENDIF.
*
* CLEAR l_pqty.
* IF NOT ( rb_prod IS INITIAL ).
* l_pqty = wa_pro_orders-menge.
* ELSE.
* l_pqty = wa_pro_orders-lmnga.
* ENDIF.
*
* IF <fs_ism> GT c_0.
** IF NOT <FS_ISM> IS INITIAL.
* l_real_effic = ( l_pqty / <fs_ism> ).
* ELSE.
* MOVE 0 TO l_real_effic.
* ENDIF.
* IF <fs_vgw> GT c_0.
** IF NOT <FS_VGW> IS INITIAL.
* l_should_effic = ( wa_plpo-bmsch / <fs_vgw> ).
* ELSE.
* MOVE 0 TO l_should_effic.
* ENDIF.
* IF l_should_effic GT c_0.
* v_plant_effic = ( l_real_effic / l_should_effic ) * c_100.
* ELSE.
* MOVE 0 TO fp_v_plant_effic.
* ENDIF.
*
*ENDFORM. " plant_effic
**&---------------------------------------------------------------------
**
**& Form get_stds_main
**&---------------------------------------------------------------------
**
** text
**----------------------------------------------------------------------
**
** -->P_PLNTY text
** -->P_PLNNR text
** -->P_PLNKN text
** -->P_ZAEHL text
**----------------------------------------------------------------------
**
*FORM get_stds_main USING fp_p_plnty TYPE plnty
* fp_p_plnnr TYPE plnnr
* fp_p_plnkn TYPE plnkn
* fp_p_zaehl TYPE cim_count.
* TYPES: BEGIN OF ty_crco_info,
* objty TYPE cr_objty,
* objid TYPE cr_objid,
* laset TYPE cr_laset,
* endda TYPE enddatum,
* lanum TYPE cr_lanum,
* begda TYPE begdatum,
* lstar_ref TYPE ap_kzref,
* lstar TYPE lstar,
* END OF ty_crco_info.
*
* DATA : i_crco_info TYPE STANDARD TABLE OF ty_crco_info,
* wa_crco_info TYPE ty_crco_info.
* DATA: l_wcinfo TYPE c,
* l_datuv TYPE plpo-datuv,
* lc_objty TYPE plpo-objty VALUE 'A'.
*
* READ TABLE i_plpo INTO wa_plpo WITH KEY plnty = fp_p_plnty
* plnnr = fp_p_plnnr
* plnkn = fp_p_plnkn
* zaehl = fp_p_zaehl.
* IF sy-subrc = 0.
*
* IF ( wa_plpo-lar01 IS INITIAL AND NOT ( wa_plpo-vgw01 = 0 ) ) OR
* ( wa_plpo-lar02 IS INITIAL AND NOT ( wa_plpo-vgw02 = 0 ) ) OR
* ( wa_plpo-lar03 IS INITIAL AND NOT ( wa_plpo-vgw03 = 0 ) ) OR
* ( wa_plpo-lar04 IS INITIAL AND NOT ( wa_plpo-vgw04 = 0 ) ) OR
* ( wa_plpo-lar05 IS INITIAL AND NOT ( wa_plpo-vgw05 = 0 ) ) OR
* ( wa_plpo-lar06 IS INITIAL AND NOT ( wa_plpo-vgw06 = 0 ) ).
* REFRESH: i_crco_info.
** Check the work centre is on the phase, if not go to the operation
* IF wa_plpo-arbid IS INITIAL.
* SELECT datuv arbid objty
* INTO (l_datuv,wa_plpo-arbid,wa_plpo-objty)
* FROM plpo
* WHERE plnty = fp_p_plnty
* AND plnnr = fp_p_plnnr
* AND plnkn = wa_plpo-pvzkn
* AND datuv <= sy-datum
* ORDER BY datuv DESCENDING.
* EXIT.
* ENDSELECT.
*
* IF sy-subrc = 0.
**Not required to handle
* ENDIF.
*
* ENDIF.
** Default to work centre object if it's blank
* IF wa_plpo-objty IS INITIAL.
* wa_plpo-objty = lc_objty.
* ENDIF.
** Get the work centre activity info
* SELECT objty objid laset endda lanum begda lstar_ref lstar
* INTO TABLE i_crco_info
* FROM crco
* WHERE objty = wa_plpo-objty
* AND objid = wa_plpo-arbid
* AND laset = 1.
** order by primary key.
*
* IF sy-subrc = 0.
**Not required to handle
* ENDIF.
*
* l_wcinfo = c_y.
* ENDIF.
* IF l_wcinfo = c_y.
** Use work centre info.
* LOOP AT i_crco_info INTO wa_crco_info
* WHERE begda <= wa_plpo-datuv AND
* endda >= wa_plpo-datuv.
* CHECK NOT wa_crco_info-lstar_ref IS INITIAL.
* CASE wa_crco_info-lanum.
** Only put the activity type in if there is a std value entered
* WHEN 1.
* IF wa_plpo-vgw01 NE 0.
* wa_plpo-lar01 = wa_crco_info-lstar.
* ENDIF.
* WHEN 2.
* IF wa_plpo-vgw02 NE 0.
* wa_plpo-lar02 = wa_crco_info-lstar.
* ENDIF.
* WHEN 3.
* IF wa_plpo-vgw03 NE 0.
* wa_plpo-lar03 = wa_crco_info-lstar.
* ENDIF.
* WHEN 4.
* IF wa_plpo-vgw04 NE 0.
* wa_plpo-lar04 = wa_crco_info-lstar.
* ENDIF.
* WHEN 5.
* IF wa_plpo-vgw05 NE 0.
* wa_plpo-lar05 = wa_crco_info-lstar.
* ENDIF.
* WHEN 6.
* IF wa_plpo-vgw06 NE 0.
* wa_plpo-lar06 = wa_crco_info-lstar.
* ENDIF.
* ENDCASE.
* ENDLOOP.
* ENDIF.
*
* ENDIF.
*
*ENDFORM. " get_stds_main
**&---------------------------------------------------------------------
**
**& Form get_confirmation_qty
**&---------------------------------------------------------------------
**
** text
**----------------------------------------------------------------------
**
** -->P_I_ORDOPS_RUECK text
** -->P_I_PRO_ORDERS_PLNBEZ text
** -->P_L_PRDQTY text
** -->P_L_CFUOM text
**----------------------------------------------------------------------
**
*FORM get_confirmation_qty USING fp_p_i_ordops_rueck TYPE co_rueck
* fp_p_l_prdqty TYPE menge_d
* fp_p_l_cfuom TYPE meins.
* DATA: l_lmnga TYPE ru_lmnga,
* l_gmnga TYPE ru_gmnga.
*
***********MOD-002**************************************
* SELECT aufnr rueck gmnga lmnga gmein meinh
* meilr stokz rueck_mst
* FROM afru INTO TABLE itab_afru
* FOR ALL ENTRIES IN i_pro_orders
* WHERE aufnr = i_pro_orders-aufnr.
*
* SORT itab_afru BY aufnr rueck .
***********MOD-002***************************************
* IF NOT itab_afru[] IS INITIAL.
* CLEAR: l_lmnga, l_gmnga.
* LOOP AT itab_afru INTO wa_afru WHERE rueck = fp_p_i_ordops_rueck.
** IF ( wa_afru-rueck_mst IS INITIAL ) AND
** ( wa_afru-lmnga NE 0 ) AND
** NOT ( wa_afru-meilr IS INITIAL ).
* IF wa_afru-stokz IS INITIAL.
* l_lmnga = l_lmnga + wa_afru-lmnga.
* l_gmnga = l_gmnga + wa_afru-gmnga.
* ELSE.
* l_lmnga = l_lmnga - wa_afru-lmnga.
* l_gmnga = l_gmnga - wa_afru-gmnga.
* ENDIF.
** ENDIF.
* ENDLOOP.
* IF wa_afru-meinh NE wa_afru-gmein.
* fp_p_l_prdqty = l_lmnga.
* fp_p_l_cfuom = wa_afru-gmein.
* ELSE.
* fp_p_l_prdqty = l_gmnga.
* fp_p_l_cfuom = wa_afru-meinh.
* ENDIF.
* ENDIF.
*ENDFORM. " get_confirmation_qty
**&---------------------------------------------------------------------
**
**& Form MATERIAL_HEADER
**&---------------------------------------------------------------------
**
** text
**----------------------------------------------------------------------
**
** --> p1 text
** <-- p2 text
**----------------------------------------------------------------------
**
*FORM material_header.
*
* wa_nodestab-text = 'Material'(058).
* wa_nodestab-tlength = c_22.
* wa_nodestab-tcolor = c_4.
* wa_nodestab-propfaw = c_x.
*
* wa_nodestab-text1 = 'Description'(059).
* wa_nodestab-tlength1 = c_30.
* wa_nodestab-tcolor1 = c_4.
*
* IF rb_fiscl = c_x.
* CONCATENATE 'Actual Usage'(040) v_waers
* INTO wa_nodestab-text2 SEPARATED BY space.
* ELSE.
* wa_nodestab-text2 = 'Actual Usage'(040).
* ENDIF.
* wa_nodestab-tlength2 = c_20.
* wa_nodestab-tcolor2 = c_4.
*
* IF rb_fiscl = c_x.
* CONCATENATE 'Standard Usage'(041) v_waers
* INTO wa_nodestab-text3 SEPARATED BY space.
* ELSE.
* wa_nodestab-text3 = 'Standard Usage'(041).
* ENDIF.
* wa_nodestab-tlength3 = c_20.
* wa_nodestab-tcolor3 = c_4.
*
* wa_nodestab-text4 = 'Var'(060).
* wa_nodestab-tlength4 = c_19.
* wa_nodestab-tcolor4 = c_4.
*
** IF rb_fiscl = c_x.
* CONCATENATE 'Variance'(061) v_waers
* INTO wa_nodestab-text5 SEPARATED BY space.
** ELSE.
** wa_nodestab-text5 = 'Variance'(061).
** ENDIF.
* wa_nodestab-tlength5 = c_15.
* wa_nodestab-tcolor5 = c_4.
*
* APPEND wa_nodestab TO i_nodestab.
* CLEAR : wa_nodestab.
*ENDFORM. " MATERIAL_HEADER
**&---------------------------------------------------------------------
**
**& Form sum_activity_costs
**&---------------------------------------------------------------------
**
** text
**----------------------------------------------------------------------
**
** -->P_I_PLPO1_LAR01 text
** -->P_I_ORD_CONF1_ISM01 text
** -->P_struct_activity_ACTI1 text
** -->P_ISM01_VAR text
**----------------------------------------------------------------------
**
*FORM sum_activity_costs USING fp_p_i_plpo1_lar01 TYPE lstar
* fp_p_i_ord_conf1_ism01 TYPE ru_ismng
*fp_p_struct_activity_acti1 TYPE co_smng13
*fp_p_ism01_var TYPE ru_ismng.
* DATA: l_kokrs TYPE kokrs,
* l_kostl TYPE kostl,
* l_objnr TYPE j_objnr,
* l_tkg001 TYPE tkgxxx,
* l_tke001 TYPE tkexxx,
* l_std(8) TYPE p DECIMALS 2,
* l_act(8) TYPE p DECIMALS 2,
* l_var(8) TYPE p DECIMALS 2.
*
* SELECT kokrs kostl
* FROM crco UP TO 1 ROWS
* INTO (l_kokrs, l_kostl)
* WHERE objty = c_objtyp
* AND objid = wa_ordops-arbid
* AND lstar = fp_p_i_plpo1_lar01.
* ENDSELECT.
*
* IF sy-subrc = 0.
**Not required to handle
* ENDIF.
*
* SELECT SINGLE objnr INTO l_objnr
* FROM cssl
* WHERE kokrs = l_kokrs
* AND kostl = l_kostl
* AND lstar = fp_p_i_plpo1_lar01
* AND gjahr = sy-datum+0(4).
*
* IF sy-subrc = 0.
**Not required to handle
* ENDIF.
*
* SELECT tkg001 tke001 INTO (l_tkg001, l_tke001)
* FROM cost
* WHERE objnr = l_objnr
* AND gjahr = sy-datum+0(4)
* AND versn = c_000.
* ENDSELECT.
*
* IF sy-subrc = 0.
**Not required to handle
* ENDIF.
*
* CLEAR: l_act, l_std, l_var.
* l_act = ( fp_p_i_ord_conf1_ism01 * l_tkg001 ) / l_tke001.
* l_std = ( fp_p_struct_activity_acti1 * l_tkg001 ) / l_tke001.
* l_var = ( fp_p_ism01_var * l_tkg001 ) / l_tke001.
*
* CLEAR wa_sum_activity.
*
* LOOP AT i_sum_activity INTO wa_sum_activity
* WHERE lar = fp_p_i_plpo1_lar01.
* wa_sum_activity-afru_ism = wa_sum_activity-afru_ism
* + fp_p_i_ord_conf1_ism01.
* wa_sum_activity-ism_should = wa_sum_activity-ism_should
* + fp_p_struct_activity_acti1.
* wa_sum_activity-ism_var = wa_sum_activity-ism_var
* + fp_p_ism01_var.
* wa_sum_activity-coact = wa_sum_activity-coact + l_act.
* wa_sum_activity-costd = wa_sum_activity-costd + l_std.
* wa_sum_activity-covar = wa_sum_activity-covar + l_var.
* MODIFY i_sum_activity FROM wa_sum_activity.
* CLEAR : wa_sum_activity.
* ENDLOOP.
*
* IF sy-subrc NE 0.
* MOVE fp_p_i_plpo1_lar01 TO wa_sum_activity-lar.
* MOVE fp_p_i_ord_conf1_ism01 TO wa_sum_activity-afru_ism.
* MOVE fp_p_struct_activity_acti1 TO wa_sum_activity-ism_should.
* MOVE fp_p_ism01_var TO wa_sum_activity-ism_var.
* wa_sum_activity-coact = l_act.
* wa_sum_activity-costd = l_std.
* wa_sum_activity-covar = l_var.
* APPEND wa_sum_activity TO i_sum_activity.
* CLEAR : wa_sum_activity.
* ENDIF.
*
*ENDFORM. " sum_activity_costs
**&---------------------------------------------------------------------
**
**& Form SUMMARY_MATERIALS
**&---------------------------------------------------------------------
**
** text
**----------------------------------------------------------------------
**
**----------------------------------------------------------------------
**
*FORM summary_materials.
*
** Sum Ingredient Tots
* CLEAR wa_sum_ordmats.
* LOOP AT i_sum_ordmats INTO wa_sum_ordmats
* WHERE matnr = wa_ordmats-matnr.
* wa_sum_ordmats-num = wa_sum_ordmats-num + c_1.
* wa_sum_ordmats-menge = wa_sum_ordmats-menge + wa_ordmats-menge.
* wa_sum_ordmats-stdqy = wa_sum_ordmats-stdqy + wa_ordmats-stdqy.
* wa_sum_ordmats-zloss = wa_sum_ordmats-zloss + wa_ordmats-zloss.
* wa_sum_ordmats-amein = wa_ordmats-amein.
* wa_sum_ordmats-meins = wa_ordmats-meins.
* wa_sum_ordmats-stprs = wa_ordmats-stprs.
* wa_sum_ordmats-peinh = wa_ordmats-peinh.
* MODIFY i_sum_ordmats FROM wa_sum_ordmats.
* CLEAR : wa_sum_ordmats.
* ENDLOOP.
* IF sy-subrc NE 0.
* MOVE wa_ordmats-matnr TO wa_sum_ordmats-matnr.
* MOVE 1 TO wa_sum_ordmats-num.
* MOVE wa_ordmats-menge TO wa_sum_ordmats-menge.
* MOVE wa_ordmats-stdqy TO wa_sum_ordmats-stdqy.
* MOVE wa_ordmats-zloss TO wa_sum_ordmats-zloss.
* wa_sum_ordmats-amein = wa_ordmats-amein.
* wa_sum_ordmats-meins = wa_ordmats-meins.
* wa_sum_ordmats-stprs = wa_ordmats-stprs.
* wa_sum_ordmats-peinh = wa_ordmats-peinh.
* APPEND wa_sum_ordmats TO i_sum_ordmats.
* CLEAR : wa_sum_ordmats.
* ENDIF.
*
*ENDFORM. " SUMMARY_MATERIALS
**&---------------------------------------------------------------------
**
**& Form get_confirmation_qty_new
**&---------------------------------------------------------------------
**
** text
**----------------------------------------------------------------------
**
** -->P_WA_PRO_ORDERS_RUECK text
** -->P_WA_PRO_ORDERS_PLNBEZ text
** -->P_WA_PRO_ORDERS_LMNGA text
** -->P_WA_PRO_ORDERS_CFUOM text
**----------------------------------------------------------------------
**
*FORM get_confirmation_qty_new USING p_lmnga TYPE ru_lmnga
* p_cfuom TYPE meins.
*
****************************************************
**USING
** P_RUECK TYPE CO_RUECK
** p_aufnr type aufnr
** P_LMNGA TYPE RU_LMNGA
** P_CFUOM TYPE MEINS
** p_aufpl type CO_AUFPL
** p_vornr type vornr
** p_aplzl type CO_APLZL.
****************************************************
* DATA: last_lmnga LIKE afru-lmnga,
* last_gmnga TYPE afru-gmnga.
*
* CLEAR: last_lmnga, last_gmnga.
* CLEAR:i_afru, wa_afru.
*
*
*
*
** Check this record. If there is no link to another confirmation and
** a quantity has been confirmed and it is a milestone confirmation
** then we want to select all of the confirmations for it.
* LOOP AT i_afru1 INTO wa_afru1.
** check WA_afru-rueck_mst is initial.
* CHECK wa_afru1-lmnga NE 0.
** check not ( WA_afru-meilr is initial ).
* IF wa_afru1-stokz IS INITIAL.
* last_lmnga = last_lmnga + wa_afru1-lmnga.
* last_gmnga = last_gmnga + wa_afru1-gmnga.
* ELSE.
* last_lmnga = last_lmnga - wa_afru1-lmnga.
* last_gmnga = last_gmnga - wa_afru1-gmnga.
* ENDIF.
* ENDLOOP.
*
** use order unit quantity if necessary
* IF wa_afru1-meinh NE wa_afru1-gmein.
** afru-gmein is order unit of measure
* MOVE last_gmnga TO p_lmnga.
* p_cfuom = wa_afru1-gmein.
* ELSE.
** use normal quantity
* MOVE last_lmnga TO p_lmnga.
* p_cfuom = wa_afru1-meinh.
* ENDIF.
*
*ENDFORM. " get_confirmation_qty_new
****
**** END OF MOD-101
****
*&---------------------------------------------------------------------*
*& Form USER_COMMNAD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM USER_COMMAND TABLES FP_I_NODESTAB STRUCTURE SNODETEXT  "#EC *
USING FP_L_UCOMM TYPE ANY
CHANGING FP_L_EXIT TYPE ANY
FP_L_LIST_REFRESH TYPE ANY.                                 "#EC *
  DATA : V_AUFNR TYPE AUFNR,
  L_ARBPL TYPE ARBPL,                                       "MOD-101+
  L_TXT(14) TYPE C.                                         "MOD-101+
  DATA: PROGNAME LIKE SY-REPID,
  SELECTED TYPE C,
  EXIT_SAV TYPE C,
  LIST_REFRESH_SAV TYPE C.
  FP_L_LIST_REFRESH = C_M.
  CASE FP_L_UCOMM.
***
*** BEGIN OF MOD-101
***
    WHEN C_TRPI.
      CLEAR : V_AUFNR , L_TXT.
      GET CURSOR FIELD FP_I_NODESTAB-TEXT1 VALUE L_TXT.
      IF FP_I_NODESTAB-TEXT1 = C_TEXT1 AND NOT L_TXT IS INITIAL.
        CASE FP_I_NODESTAB-TLEVEL.
          WHEN C_TLEVEL_2.
            V_AUFNR = L_TXT(12).
            SUBMIT ZPROCESSORD WITH S_AUFNR-LOW = V_AUFNR
            AND RETURN.
* SUBMIT zprocessord WITH p_aufnr = v_aufnr
* AND RETURN.
          WHEN C_TLEVEL_3.
            L_ARBPL = L_TXT(8).
            SET PARAMETER ID 'WRK' FIELD P_WERKS.
            SET PARAMETER ID 'AGR' FIELD L_ARBPL.
            CALL TRANSACTION 'CRC3' AND SKIP FIRST SCREEN.
          WHEN C_TLEVEL_4.
            L_ARBPL = L_TXT+6(8).
            SET PARAMETER ID 'WRK' FIELD P_WERKS.
            SET PARAMETER ID 'AGR' FIELD L_ARBPL.
            CALL TRANSACTION 'CRC3' AND SKIP FIRST SCREEN.
        ENDCASE.
      ELSEIF FP_I_NODESTAB-TEXT1 <> C_PLUS AND FP_I_NODESTAB-TEXT1 <>
      C_MINUS AND
      SY-TITLE <> 'Process Order Variance - Summary Report'(069).
*Please select order number!
        MESSAGE S063.
      ENDIF.
** TRSL
* CLEAR : v_aufnr , l_txt.
* GET CURSOR FIELD fp_i_nodestab-text1 VALUE l_txt.
* IF fp_i_nodestab-text1 = c_text1 AND NOT l_txt IS INITIAL.
* CASE fp_i_nodestab-tlevel.
* WHEN c_tlevel_2.
* v_aufnr = l_txt.
* call function 'RS_TREE_EXPAND'
* exporting
* node_id = nodelist-id
* list_scroll = 'X'
* exceptions
* others.
* WHEN c_tlevel_3.
* l_arbpl = l_txt(8).
* call function 'RS_TREE_EXPAND'
* exporting
* node_id = nodelist-id
* list_scroll = 'X'
* exceptions
* others.
*
* WHEN c_tlevel_4.
* l_arbpl = l_txt+5(8).
* call function 'RS_TREE_EXPAND'
* exporting
* node_id = nodelist-id
* list_scroll = 'X'
* exceptions
* others.
*
* ENDCASE.
*
** when 'NODE'.
** if selname = 'MINUS' or selname = 'MINUSLINE'.
** call function 'RS_TREE_COMPRESS'
** exporting
** node_id = nodelist-id
** exceptions
** others.
** elseif selname = 'PLUS' or selname = 'PLUSLINE'.
** call function 'RS_TREE_EXPAND'
** exporting
** node_id = nodelist-id
** list_scroll = 'X'
** exceptions
** others.
** else.
** perform uc_prepare_nodetab.
** perform uc_user_callback.
** if exit ne space.
** exit_from_screen.
** endif.
** endif.
** ENDCASE.
*
* ELSEIF fp_i_nodestab-text1 <> c_plus AND fp_i_nodestab-text1 <>
* c_minus AND
*sy-title <> 'Process Order Variance - Summary Report'(069).
**Please select order number!
* MESSAGE s063.
* ENDIF.
    WHEN C_TRDE.
      CLEAR : V_AUFNR , L_TXT.
      GET CURSOR FIELD FP_I_NODESTAB-TEXT1 VALUE L_TXT.
      IF FP_I_NODESTAB-TEXT1 = C_TEXT1 AND NOT L_TXT IS INITIAL.
        CASE FP_I_NODESTAB-TLEVEL.
          WHEN C_TLEVEL_2.
            V_AUFNR = L_TXT(12).
* SUBMIT zprocessord WITH p_aufnr = v_aufnr
* AND RETURN.
            SUBMIT ZPROCESSORD WITH S_AUFNR-LOW = V_AUFNR
            AND RETURN.
          WHEN C_TLEVEL_3.
            L_ARBPL = L_TXT(8).
            SET PARAMETER ID 'WRK' FIELD P_WERKS.
            SET PARAMETER ID 'AGR' FIELD L_ARBPL.
            CALL TRANSACTION 'CRC3' AND SKIP FIRST SCREEN.
          WHEN C_TLEVEL_4.
            L_ARBPL = L_TXT+5(8).
            SET PARAMETER ID 'WRK' FIELD P_WERKS.
            SET PARAMETER ID 'AGR' FIELD L_ARBPL.
            CALL TRANSACTION 'CRC3' AND SKIP FIRST SCREEN.
        ENDCASE.
      ELSEIF FP_I_NODESTAB-TEXT1 <> C_PLUS AND FP_I_NODESTAB-TEXT1 <>
      C_MINUS.
*Please select order number!
        MESSAGE S063.
      ENDIF.
* WHEN c_trpi.
* CLEAR : v_aufnr , l_txt.
* GET CURSOR FIELD fp_i_nodestab-text1 VALUE l_txt.
*
* CLEAR v_aufnr.
* GET CURSOR FIELD fp_i_nodestab-text1 VALUE v_aufnr.
*
* IF fp_i_nodestab-text1 = c_text1 "'NODELIST-TEXT1'
* AND NOT v_aufnr IS INITIAL
* AND fp_i_nodestab-tlevel = c_tlevel_2.
* SUBMIT /eur/rgbptr_order_vari_detail
* WITH p_aufnr = v_aufnr AND RETURN.
* ELSEIF fp_i_nodestab-text1 <> c_plus
* AND fp_i_nodestab-text1 <> c_minus
* AND sy-title <> 'Process Order Variance - Summary Report'(069).
**Please select order number!
* MESSAGE s063.
* ENDIF.
*
* WHEN c_trde.
* CLEAR v_aufnr.
* GET CURSOR FIELD fp_i_nodestab-text1 VALUE v_aufnr.
* IF fp_i_nodestab-text1 = c_text1 "'NODELIST-TEXT1'
* AND NOT v_aufnr IS INITIAL
* AND fp_i_nodestab-tlevel = c_tlevel_2.
* SUBMIT /eur/rgbptr_order_vari_detail
* WITH p_aufnr = v_aufnr AND RETURN.
* ELSEIF fp_i_nodestab-text1 <> c_plus
* AND fp_i_nodestab-text1 <> c_minus.
**Please select order number!
* MESSAGE s063.
* ENDIF.
    WHEN C_DETL.
      CLEAR: RB_SUMM, RB_PHASE.
      RB_DETL = C_X.
      PERFORM OUTPUT.
    WHEN C_PHAS.
      CLEAR: RB_DETL, RB_SUMM.
      RB_PHASE = C_X.
      PERFORM OUTPUT.
***
*** END OF MOD-101
***
    WHEN C_SUMS.
      CLEAR: RB_DETL, RB_PHASE.
      RB_SUMM = C_X.
* fp_l_exit = c_x. "MOD-101-
* PERFORM display. "MOD-101-
      PERFORM OUTPUT.                                       "MOD-101+
    WHEN C_QTY.
* Display quantities
      RB_QUANT = C_X.
      RB_FISCL = SPACE.
* fp_l_exit = c_x. "MOD-101-
* PERFORM display. "MOD-101-
      PERFORM OUTPUT.                                       "MOD-101+
    WHEN C_FISC.
* Display fiscal values
      RB_QUANT = SPACE.
      RB_FISCL = C_X.
* fp_l_exit = c_x. "MOD-101-
* PERFORM display. "MOD-101-
      PERFORM OUTPUT.                                       "MOD-101+
    WHEN C_KGM.
* Display in KGMs
      RB_ORDER = SPACE.
      RB_KGM = C_X.
* fp_l_exit = c_x. "MOD-101-
* PERFORM display. "MOD-101-
      PERFORM OUTPUT.                                       "MOD-101+
    WHEN C_ORDU.
* Display order units
      RB_KGM = SPACE.
      RB_ORDER = C_X.
* fp_l_exit = c_x. "MOD-101-
* PERFORM display. "MOD-101-
      PERFORM OUTPUT.                                       "MOD-101+
    WHEN C_ZERO.
* Display zero loss values
      RB_STDPL = SPACE.
      RB_ZLOSS = C_X.
* fp_l_exit = c_x. "MOD-101-
* PERFORM display. "MOD-101-
      PERFORM OUTPUT.                                       "MOD-101+
    WHEN C_STD.
* Display standard recipe values
      RB_ZLOSS = SPACE.
      RB_STDPL = C_X.
* fp_l_exit = c_x. "MOD-101-
* PERFORM display. "MOD-101-
      PERFORM OUTPUT.                                       "MOD-101+
    WHEN C_TREP.
      IF FP_I_NODESTAB-CHILD IS INITIAL.
*Invalid row selected!
        MESSAGE S064.
      ENDIF.
    WHEN C_TRCM.
      IF FP_I_NODESTAB-CHILD IS INITIAL.
*Invalid row selected!
        MESSAGE S064.
      ENDIF.
    WHEN 'AUAN'.
      SET PARAMETER ID 'ANR' FIELD S_AUFNR.
      CALL TRANSACTION 'COR3' AND SKIP FIRST SCREEN.
    WHEN 'AUAE'.
      SET PARAMETER ID 'ANR' FIELD S_AUFNR.
      CALL TRANSACTION 'COR2' AND SKIP FIRST SCREEN.
    WHEN C_EXIT.
      LEAVE PROGRAM.
  ENDCASE.
**"BEGIN OF MOD-101
* IF sy-ucomm = c_back AND fp_l_ucomm = c_sums.
* CLEAR: rb_summ, rb_phase.
* rb_detl = c_x.
* fp_l_list_refresh = c_m.
* PERFORM list_display.
* fp_l_exit = c_x.
* ENDIF.
**"END OF MOD-101
ENDFORM. "user_command
*&---------------------------------------------------------------------*
*& Form LIST_DISPLAY
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM LIST_DISPLAY.
*" >>> MOD-101-
  CALL FUNCTION 'RS_TREE_CONSTRUCT'
    TABLES
      NODETAB            = I_NODESTAB
    EXCEPTIONS
      TREE_FAILURE       = 1
      ID_NOT_FOUND       = 2
      WRONG_RELATIONSHIP = 3
      OTHERS             = 4.
  IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
*" <<< MOD-101-
  CALL FUNCTION 'RS_TREE_LIST_DISPLAY'
  EXPORTING
* callback_program = c_prog "MOD-101-
  CALLBACK_PROGRAM = SY-REPID                               "MOD-101+
  CALLBACK_USER_COMMAND = 'USER_COMMAND'.
ENDFORM. " LIST_DISPLAY
*&---------------------------------------------------------------------*
*& Form inform_user_of_progress
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM INFORM_USER_OF_PROGRESS.
* Update Gui
  CONDENSE V_OUTPUT_TEXT.
  CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
    EXPORTING
      TEXT = V_OUTPUT_TEXT.
ENDFORM. " inform_user_of_progress
*&---------------------------------------------------------------------*
*& Form pfstatus
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM PFSTATUS.
* Build table of excluded functions for buttons in report
  REFRESH I_FCODE.
* Not summary report
  IF NOT ( RB_SUMM IS INITIAL ).                            " MOD-101-
    MOVE C_TRDE TO WA_FCODE-FCODE.
    APPEND WA_FCODE TO I_FCODE. CLEAR WA_FCODE.
    MOVE C_SUMS TO WA_FCODE-FCODE.
    APPEND WA_FCODE TO I_FCODE.
    CLEAR WA_FCODE.
*** BEGIN OF MOD-101
  ELSEIF RB_DETL = C_X.
    MOVE C_TRDE TO WA_FCODE-FCODE.
    APPEND WA_FCODE TO I_FCODE. CLEAR WA_FCODE.
    MOVE C_DETL TO WA_FCODE-FCODE.
    APPEND WA_FCODE TO I_FCODE.
    CLEAR WA_FCODE.
  ELSEIF RB_PHASE = C_X.
    MOVE C_TRDE TO WA_FCODE-FCODE.
    APPEND WA_FCODE TO I_FCODE. CLEAR WA_FCODE.
    MOVE C_PHAS TO WA_FCODE-FCODE.
    APPEND WA_FCODE TO I_FCODE.
    CLEAR WA_FCODE.
*** END OF MOD-101
  ENDIF.
* Fiscal / quantity
  IF RB_FISCL IS INITIAL.
    MOVE C_QTY TO WA_FCODE-FCODE.
    APPEND WA_FCODE TO I_FCODE.
    CLEAR WA_FCODE.
  ELSE.
    MOVE C_FISC TO WA_FCODE-FCODE.
    APPEND WA_FCODE TO I_FCODE.
    CLEAR WA_FCODE.
****Begin of MOD-001
* MOVE c_ordu TO wa_fcode-fcode.
* APPEND wa_fcode TO i_fcode.
* CLEAR wa_fcode.
* MOVE c_kgm TO wa_fcode-fcode.
* APPEND wa_fcode TO i_fcode.
* CLEAR wa_fcode.
****End of MOD-001
  ENDIF.
* KGM / Order uom
  IF RB_KGM IS INITIAL.
    MOVE C_ORDU TO WA_FCODE-FCODE.
    APPEND WA_FCODE TO I_FCODE.
    CLEAR WA_FCODE.
  ELSE.
    MOVE C_KGM TO WA_FCODE-FCODE.
    APPEND WA_FCODE TO I_FCODE.
    CLEAR WA_FCODE.
  ENDIF.
* Zero loss / std values
  IF RB_ZLOSS IS INITIAL.
    MOVE C_STD TO WA_FCODE-FCODE.
    APPEND WA_FCODE TO I_FCODE.
    CLEAR WA_FCODE.
  ELSE.
    MOVE C_ZERO TO WA_FCODE-FCODE.
    APPEND WA_FCODE TO I_FCODE. CLEAR WA_FCODE.
  ENDIF.
ENDFORM. " pfstatus
*=========================================================*
*****BEGIN OF MOD-003.
*&---------------------------------------------------------------------*
*& Form validate_stlan
*&---------------------------------------------------------------------*
* subroutine to validate BOM usage
*----------------------------------------------------------------------*
FORM VALIDATE_STLAN .
  DATA: L_USAGE TYPE STLAN.
* IF p_usage IS INITIAL. "MOD-101-
* MESSAGE e030. "Plese enter BOM usage "MOD-101-
* ELSE. "MOD-101-
  SELECT STLAN INTO L_USAGE "get BOM usage
  FROM T416 UP TO 1 ROWS
  WHERE STLAN = P_USAGE.
  ENDSELECT.
  IF SY-SUBRC NE 0.
* MESSAGE e030. "BOM usage doesn't exist. "MOD-101-
    MESSAGE E030 WITH P_USAGE.                              "MOD-101+
  ENDIF.
* ENDIF. "MOD-101-
ENDFORM. " validate_stlan
*&---------------------------------------------------------------------*
*& Form validate_steus
*&---------------------------------------------------------------------*
* subroutine to validate control key
*----------------------------------------------------------------------*
FORM VALIDATE_STEUS .
*** BEGIN OF MOD-101
  R_STEUS = S_STEUS[].
*"Get control key from T430
  SELECT PLNAW
  STEUS
  KALKZ
  FROM T430
  INTO TABLE I_CKEY
  WHERE STEUS IN S_STEUS
  AND KALKZ EQ C_X.
  IF SY-SUBRC NE 0.
    MESSAGE E054. "enter valid control key.
  ENDIF.
**"Get control key from T430
* DATA: l_steus TYPE steus.
*
**"if control key is not entered
* IF s_steus[] IS INITIAL.
* MESSAGE e071. "Please enter control key.
* ELSE.
**"get control key
* SELECT steus INTO l_steus
* FROM t430
* UP TO 1 ROWS
* WHERE steus IN s_steus.
* ENDSELECT.
* IF sy-subrc NE 0.
* MESSAGE e054. "enter valid control key.
* ENDIF.
* ENDIF.
*** END OF MOD-101
ENDFORM. " validate_steus
*&---------------------------------------------------------------------*
*& Form validate_lstar
*&---------------------------------------------------------------------*
* subroutine to validate machine hours indicator
*----------------------------------------------------------------------*
*form validate_lstar .
*data:l_lstar tyep lstar.
*
*endform. " validate_lstar
*****END OF MOD-003.
*** BEGIN OF MOD-101
*&--------------------------------------------------------------------*
*& Form tree_rebuild
*&--------------------------------------------------------------------*
* build / rebuild tree
*---------------------------------------------------------------------*
FORM TREE_REBUILD.
  CALL FUNCTION 'RS_TREE_CONSTRUCT'
    TABLES
      NODETAB            = I_NODESTAB
    EXCEPTIONS
      TREE_FAILURE       = 1
      ID_NOT_FOUND       = 2
      WRONG_RELATIONSHIP = 3
      OTHERS             = 4.
  IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
ENDFORM. "tree_rebuild
*&--------------------------------------------------------------------*
*& Form conv_to_from_base
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM CONV_TO_FROM_BASE USING FP_KZMEINH
FP_MATNR
FP_INPUT
FP_MEINH
FP_MEINS
CHANGING FP_OUTPUT
FP_RC.
  CLEAR : FP_RC , FP_OUTPUT.
  CALL FUNCTION 'MATERIAL_UNIT_CONVERSION'
  EXPORTING
  INPUT = FP_INPUT
  KZMEINH = FP_KZMEINH
  MATNR = FP_MATNR
  MEINH = FP_MEINH
  MEINS = FP_MEINS
* CHARGE =
* WERKS =
  IMPORTING
  OUTPUT = FP_OUTPUT
* UMREN =
* UMREZ =
  EXCEPTIONS
  CONVERSION_NOT_FOUND = 1
  INPUT_INVALID = 2
  MATERIAL_NOT_FOUND = 3
  MEINH_NOT_FOUND = 4
  MEINS_MISSING = 5
  NO_MEINH = 6
  OUTPUT_INVALID = 7
  OVERFLOW = 8
  OTHERS = 9.
  IF SY-SUBRC <> 0.
    FP_RC = 'X'.
  ENDIF.
ENDFORM. "conv_to_from_base
*&--------------------------------------------------------------------*
*& Form convert_to_kg
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM CONVERT_TO_KG USING FP_MATNR TYPE MATNR
FP_BSUOM TYPE MEINS
FP_GEWEI TYPE GEWEI
FP_NTGEW TYPE NTGEW
FP_QTYIN TYPE MENGE_D
CHANGING FP_QTOUT TYPE MENGE_D
FP_RC.
  DATA : L_OUT TYPE MENGE_D.
  CLEAR : FP_RC , FP_QTOUT.
  L_OUT = FP_QTYIN * FP_NTGEW.
  IF FP_GEWEI <> 'KG'.
    CALL FUNCTION 'UNIT_CONVERSION_SIMPLE'
      EXPORTING
        INPUT                = L_OUT
        UNIT_IN              = FP_GEWEI
        UNIT_OUT             = 'KG'
      IMPORTING
        OUTPUT               = FP_QTOUT
      EXCEPTIONS
        CONVERSION_NOT_FOUND = 1
        DIVISION_BY_ZERO     = 2
        INPUT_INVALID        = 3
        OUTPUT_INVALID       = 4
        OVERFLOW             = 5
        TYPE_INVALID         = 6
        UNITS_MISSING        = 7
        UNIT_IN_NOT_FOUND    = 8
        UNIT_OUT_NOT_FOUND   = 9
        OTHERS               = 10.
    IF SY-SUBRC <> 0.
      FP_RC = 'X'.
    ENDIF.
  ELSE.
    FP_QTOUT = L_OUT.
  ENDIF.
ENDFORM. "convert_to_kg
*&--------------------------------------------------------------------*
*& Form do_mat_calc
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM DO_MAT_CALC CHANGING FP_H_MAT TYPE TY_HIER_MAT
FP_AQTY TYPE CHAR18
FP_MATUOM TYPE MEINS
FP_SQTY TYPE CHAR18
FP_STDUOM TYPE MEINS
FP_SVAR TYPE CHAR18
FP_VARUOM TYPE MEINS
FP_SVARP TYPE CHAR18
FP_AMENGE TYPE MENGE_D
FP_SMENGE TYPE MENGE_D
FP_ASTPRS TYPE TY_STPRS
FP_SSTPRS TYPE TY_STPRS.
  DATA : L_AQTY TYPE CHAR18,
  L_SQTY TYPE CHAR18,
  L_SVAR TYPE CHAR18,
  L_SVARP TYPE CHAR18,
  L_MATUOM TYPE MEINS,
  L_STDUOM TYPE MEINS,
  L_VARUOM TYPE MEINS,
  L_AMENGE TYPE MENGE_D,
  L_SMENGE TYPE MENGE_D,
  L_MENGE TYPE MENGE_D,
  L_MVAR TYPE MENGE_D,
  L_ASTPRS TYPE TY_STPRS,
  L_SSTPRS TYPE TY_STPRS,
  L_VSTPRS TYPE TY_STPRS,
  L_WA_H_MAT TYPE TY_HIER_MAT,
  L_FACT_A TYPE MENGE_D VALUE 1,
  L_FACT_S TYPE MENGE_D VALUE 1.
  CLEAR : L_SMENGE, L_AMENGE, L_ASTPRS, L_SSTPRS, L_STDUOM, L_MATUOM,
  L_VARUOM, L_AQTY , L_SQTY , L_SVAR , L_SVARP .
  L_WA_H_MAT = FP_H_MAT.
* Standard planned or zero loss planned
  IF RB_ZLOSS IS INITIAL.
    L_WA_H_MAT-STDUSG = L_WA_H_MAT-STDUSGS.
  ELSE.
    L_WA_H_MAT-STDUSG = L_WA_H_MAT-STDUSGZ.
  ENDIF.
  L_SMENGE = FP_SMENGE + L_WA_H_MAT-STDUSG.
  L_AMENGE = L_WA_H_MAT-ACTUSG.
  IF L_WA_H_MAT-BSUOM = 'EA' OR L_WA_H_MAT-BSUOM = 'CS'.
* Begin of MOD-002++
* l_smenge = CEIL( l_wa_h_mat-stdusg ).
* l_amenge = CEIL( l_wa_h_mat-actusg ).
* End of MOD-002++
    L_WA_H_MAT-STDUSG = L_SMENGE.
    L_WA_H_MAT-ACTUSG = L_AMENGE.
  ENDIF.
* Order UoM or KG
* IF rb_quant EQ c_x AND rb_kgm IS INITIAL.
  IF RB_KGM IS INITIAL.
    L_MATUOM = L_WA_H_MAT-GRUOM.
    L_STDUOM = L_WA_H_MAT-BOMUOM.
    IF L_WA_H_MAT-GRUOM <> L_WA_H_MAT-BSUOM.
      PERFORM CONV_TO_FROM_BASE USING ' '
      L_WA_H_MAT-MATNR
      L_AMENGE
      L_WA_H_MAT-GRUOM
      L_WA_H_MAT-BSUOM
      CHANGING L_MENGE
      V_CONV_RC.
      IF V_CONV_RC <> C_X.
        L_AMENGE = L_MENGE.
        PERFORM CONVERT_UNIT USING L_WA_H_MAT-MATNR
        1
        L_WA_H_MAT-GRUOM
        L_WA_H_MAT-BSUOM
        CHANGING L_FACT_A.
        IF L_FACT_A = 0.
          L_FACT_A = 1.
        ENDIF.
      ENDIF.
    ENDIF.
    IF L_WA_H_MAT-BSUOM <> L_WA_H_MAT-BOMUOM.
      PERFORM CONV_TO_FROM_BASE USING ' '
      L_WA_H_MAT-MATNR
      L_SMENGE
      L_WA_H_MAT-BOMUOM
      L_WA_H_MAT-BSUOM
      CHANGING L_MENGE
      V_CONV_RC.
      IF V_CONV_RC <> C_X.
        L_SMENGE = L_MENGE.
        PERFORM CONVERT_UNIT USING L_WA_H_MAT-MATNR
        1
        L_WA_H_MAT-BOMUOM
        L_WA_H_MAT-BSUOM
        CHANGING L_FACT_S.
        IF L_FACT_S = 0.
          L_FACT_S = 1.
        ENDIF.
      ENDIF.
    ENDIF.
  ELSE.
    L_MATUOM = L_WA_H_MAT-BSUOM.
    L_STDUOM = L_WA_H_MAT-BSUOM.
    IF L_WA_H_MAT-BSUOM <> 'KG'.
      PERFORM CONVERT_TO_KG USING L_WA_H_MAT-MATNR L_WA_H_MAT-BSUOM
      L_WA_H_MAT-GEWEI L_WA_H_MAT-NTGEW
      L_AMENGE
      CHANGING L_MENGE
      V_CONV_RC.
      IF V_CONV_RC = 'X'.
        CLEAR : L_AMENGE , L_MATUOM.
      ELSE.
        L_AMENGE = L_MENGE.
        L_MATUOM = 'KG'.
        PERFORM CONVERT_TO_KG USING L_WA_H_MAT-MATNR L_WA_H_MAT-BSUOM
        L_WA_H_MAT-GEWEI L_WA_H_MAT-NTGEW
        1
        CHANGING L_FACT_A
        V_CONV_RC.
        IF L_FACT_A = 0.
          L_FACT_A = 1.
        ENDIF.
        L_FACT_A = 1 / L_FACT_A.
      ENDIF.
      PERFORM CONVERT_TO_KG USING L_WA_H_MAT-MATNR L_WA_H_MAT-BSUOM
      L_WA_H_MAT-GEWEI L_WA_H_MAT-NTGEW
      L_SMENGE
      CHANGING L_MENGE
      V_CONV_RC.
      IF V_CONV_RC = 'X'.
        CLEAR : L_SMENGE , L_STDUOM.
      ELSE.
        L_SMENGE = L_MENGE.
        L_STDUOM = 'KG'.
        PERFORM CONVERT_TO_KG USING L_WA_H_MAT-MATNR L_WA_H_MAT-BSUOM
        L_WA_H_MAT-GEWEI L_WA_H_MAT-NTGEW
        1
        CHANGING L_FACT_S
        V_CONV_RC.
        IF L_FACT_S = 0.
          L_FACT_S = 1.
        ENDIF.
        L_FACT_S = 1 / L_FACT_S.
      ENDIF.
    ENDIF.
  ENDIF.
* Fiscal or quantity
  CLEAR : L_SQTY , L_AQTY, L_SVAR, L_SVARP, L_MVAR, L_VSTPRS.
  IF RB_QUANT EQ C_X.
    IF L_WA_H_MAT-BSUOM = 'EA' OR L_WA_H_MAT-BSUOM = 'CS'.
* Begin of MOD-002++
* l_smenge = CEIL( l_smenge ).
* l_amenge = CEIL( l_amenge ).
* End of MOD-002++
      IF L_WA_H_MAT-PEINH <> 0.
        L_ASTPRS = L_AMENGE * L_FACT_A *
        ( L_WA_H_MAT-STPRS / L_WA_H_MAT-PEINH ).
        L_SSTPRS = FP_SSTPRS + L_SMENGE * L_FACT_S *
        ( L_WA_H_MAT-STPRS / L_WA_H_MAT-PEINH ).
      ENDIF.
    ELSE.
      IF L_WA_H_MAT-PEINH <> 0.
        L_ASTPRS = L_WA_H_MAT-ACTUSG *
        ( L_WA_H_MAT-STPRS / L_WA_H_MAT-PEINH ).
        L_SSTPRS = FP_SSTPRS + L_WA_H_MAT-STDUSG *
        ( L_WA_H_MAT-STPRS / L_WA_H_MAT-PEINH ).
      ENDIF.
    ENDIF.
    L_VSTPRS = L_SSTPRS - L_ASTPRS.
    WRITE : L_AMENGE TO L_AQTY UNIT L_MATUOM NO-GROUPING.
    WRITE : L_SMENGE TO L_SQTY UNIT L_STDUOM NO-GROUPING.
    IF L_MATUOM IS INITIAL OR L_MATUOM EQ L_STDUOM.
      L_MVAR = L_SMENGE - L_AMENGE.
      IF L_SMENGE <> 0.
        L_WA_H_MAT-VARPER = ( L_MVAR / L_SMENGE ) * 100.
      ELSE.
        L_WA_H_MAT-VARPER = 0.
      ENDIF.
    ENDIF.
    WRITE : L_MVAR TO L_SVAR UNIT L_STDUOM NO-GROUPING.
    WRITE : L_WA_H_MAT-VARPER TO L_SVARP NO-GROUPING DECIMALS 2.
    L_VARUOM = L_STDUOM.
  ELSE.
    L_MATUOM = V_WAERS.
    L_STDUOM = V_WAERS.
    L_VARUOM = V_WAERS.
    IF L_WA_H_MAT-BSUOM = 'EA' OR L_WA_H_MAT-BSUOM = 'CS'.
* Begin of MOD-002++
* l_smenge = CEIL( l_smenge ).
* l_amenge = CEIL( l_amenge ).
* End of MOD-002++
      IF L_WA_H_MAT-PEINH <> 0.
        L_ASTPRS = L_AMENGE * L_FACT_A *
        ( L_WA_H_MAT-STPRS / L_WA_H_MAT-PEINH ).
        L_SSTPRS = FP_SSTPRS + L_SMENGE * L_FACT_S *
        ( L_WA_H_MAT-STPRS / L_WA_H_MAT-PEINH ).
      ENDIF.
    ELSE.
      IF L_WA_H_MAT-PEINH <> 0.
        L_ASTPRS = L_WA_H_MAT-ACTUSG *
        ( L_WA_H_MAT-STPRS / L_WA_H_MAT-PEINH ).
        L_SSTPRS = FP_SSTPRS + L_WA_H_MAT-STDUSG *
        ( L_WA_H_MAT-STPRS / L_WA_H_MAT-PEINH ).
      ENDIF.
    ENDIF.
    L_VSTPRS = L_SSTPRS - L_ASTPRS.
    IF L_SSTPRS <> 0.
      L_WA_H_MAT-VARPER = ( L_VSTPRS / L_SSTPRS ) * 100.
    ELSE.
      L_WA_H_MAT-VARPER = 0.
    ENDIF.
    V_PRS = L_ASTPRS.
    WRITE : V_PRS TO L_AQTY CURRENCY V_WAERS NO-GROUPING.
    V_PRS = L_SSTPRS.
    WRITE : V_PRS TO L_SQTY CURRENCY V_WAERS NO-GROUPING.
    V_PRS = L_VSTPRS.
    WRITE : V_PRS TO L_SVAR CURRENCY V_WAERS NO-GROUPING.
    WRITE : L_WA_H_MAT-VARPER TO L_SVARP NO-GROUPING DECIMALS 2.
  ENDIF.
  L_WA_H_MAT-STDVAR = L_MVAR.
  L_WA_H_MAT-VSTPRS = L_VSTPRS.
  FP_AQTY = L_AQTY.
  FP_MATUOM = L_MATUOM.
  FP_SQTY = L_SQTY.
  FP_STDUOM = L_STDUOM.
  FP_SVAR = L_SVAR.
  FP_VARUOM = L_VARUOM.
  FP_SVARP = L_SVARP.
  FP_AMENGE = L_AMENGE.
  FP_ASTPRS = L_ASTPRS.
  FP_SMENGE = L_SMENGE.
  FP_SSTPRS = L_SSTPRS.
  FP_H_MAT = L_WA_H_MAT.
ENDFORM. "do_mat_calc
*&---------------------------------------------------------------------*
*& Form convert_unit
*&---------------------------------------------------------------------*
* Convert UoM
*----------------------------------------------------------------------*
* -->fp_matnr Material
* -->fp_in_qty In Qty
* -->fp_in_uom In UoM
* -->fp_out_uom Out UoM
* <--fp_out_qty Out Qty
*----------------------------------------------------------------------*
FORM CONVERT_UNIT USING FP_MATNR TYPE MATNR
FP_IN_QTY TYPE BSTMG
FP_IN_UOM TYPE MEINS
FP_OUT_UOM TYPE MEINS
CHANGING FP_OUT_QTY TYPE BSTMG.
  IF FP_IN_UOM = FP_OUT_UOM.
    FP_OUT_QTY = FP_IN_QTY.
    EXIT.
  ENDIF.
  CALL FUNCTION 'MD_CONVERT_MATERIAL_UNIT'
    EXPORTING
      I_MATNR              = FP_MATNR
      I_IN_ME              = FP_IN_UOM
      I_OUT_ME             = FP_OUT_UOM
      I_MENGE              = FP_IN_QTY
    IMPORTING
      E_MENGE              = FP_OUT_QTY
    EXCEPTIONS
      ERROR_IN_APPLICATION = 1
      ERROR                = 2
      OTHERS               = 3.
  IF SY-SUBRC <> 0.
    FP_OUT_QTY = 0.
  ENDIF.
ENDFORM. " convert_unit
  • No labels