Registration

Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
http://scn.sap.com
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata

report zcp0203 message-id zc line-size 255 no standard page heading.************************************************************************

* Factory Production Report

* Aveek Ghose 2000

************************************************************************

* The report shows the planned and actual production from S917

* on the order level in a timetable clustered as "all days of a week"

* together with an absolute difference and an "Achievement percentage"

* measure

************************************************************************

* Standard Includeinclude zsi0009.************************************************************************

* Tables definition

************************************************************************tables : ZS917, "Production Orders

Zs918, "Production Order Operations

t001w, "Plant description

makt, "Material Descriptions

zc211, "SAPScript submitting structure (header)

zc212. "SAPScript submitting structure (line)************************************************************************

* Data definition

************************************************************************

************************************************** type definitiontypes: difftype type p decimals 3,

disptype type p decimals 0,

perctype type p decimals 0,

sqtytype(8) type c, "display quantities

sperctype(4) type c. "display perc.************************************************** constants partdata: spras_c type c value 'E', "language English, fixed

test type c value ' '. "for internal use only************************************************** variables partdata : auxdate like sy-datum, "auxiliary date for initialization

dayofweek like scal-indicator, "aux. day of week

sapprint type c value ' ', "printflag fpr SAPScript

firstpage type c, "indicator for the first page

disphead type c, "to control the top header

firstwc type c. "indicator for the first wc/week

*************************************************** internal table part

data : begin of allorderlist occurs 0,"all process orders from ZS917

werks like ZS917-werks,

spwoc like ZS917-spwoc,

arbpl like ZS918-arbpl,

gltrp like ZS917-gltrp,

matnr like ZS917-matnr,

mtart like ZS917-mtart,

bismt like ZS917-bismt,

aufnr like ZS917-aufnr,

gamng type disptype, "plan

wemng type disptype, "actual

diff type disptype, "difference

zprdif type disptype, "difference kgm

zprtgt type disptype, "plan kgm

zpract type disptype, "actual kgm

amein type meins , "Unit of measure in-house prod

nobvd type difftype, "number of bad values def unit

nobvo type difftype, "number of bad values order unit

wkday type c,

end of allorderlist.

data : begin of allwclist occurs 0, "work center from ZS918

matnr like ZS918-matnr,

mtart like ZS918-mtart,

werks like ZS918-werks,

spwoc like ZS917-spwoc,

arbpl like ZS918-arbpl,

aufnr like ZS918-aufnr,

vornr like ZS918-vornr,

end of allwclist.

data : begin of matdaylist occurs 0, "list of material per week,day,wc

spwoc like ZS917-spwoc,

arbpl like ZS918-arbpl,

matnr like ZS917-matnr,

bismt like ZS917-bismt,

mtart like ZS917-mtart,

gamng type disptype, "plan

wemng type disptype, "actual

diff type disptype, "difference

zprdif type disptype, "difference kgm

zprtgt type disptype, "plan kgm

zpract type disptype, "actual kgm

amein type meins, "Unit of measure in-house prod

nobvd type difftype, "number of bad values def unit

nobvo type difftype, "number of bad values order unit

wkday type c,

end of matdaylist.

data : begin of matsumlist occurs 0, "list of material per week and wc

spwoc like ZS917-spwoc,

arbpl like ZS918-arbpl,

matnr like ZS917-matnr,

bismt like ZS917-bismt,

mtart like ZS917-mtart,

gamng type disptype, "plan

wemng type disptype, "actual

diff type disptype, "difference

zprdif type disptype, "difference kgm

zprtgt type disptype, "plan kgm

zpract type disptype, "actual kgm

amein type meins, "Unit of measure in-house prod

nobvd type difftype, "number of bad values def unit

nobvo type difftype, "number of bad values order unit

end of matsumlist.

data : begin of wcdaylist occurs 0, "list of workcenter per week / day

spwoc like ZS917-spwoc,

arbpl like ZS918-arbpl,

gamng type disptype, "plan

wemng type disptype, "actual

diff type disptype, "difference

zprdif type disptype, "difference kgm

zprtgt type disptype, "plan kgm

zpract type disptype, "actual kgm

amein type meins, "Unit of measure in-house prod

nobvd type difftype, "number of bad values def unit

nobvo type difftype, "number of bad values order unit

wkday type c,

end of wcdaylist.

data : begin of wclist occurs 0, "list of workcenter per week

spwoc like ZS917-spwoc,

arbpl like ZS918-arbpl,

gamng type disptype, "plan

wemng type disptype, "actual

diff type disptype, "difference

zprdif type disptype, "difference kgm

zprtgt type disptype, "plan kgm

zpract type disptype, "actual kgm

amein type meins, "Unit of measure in-house prod

sperc type sperctype, "performance in %

nobvd type difftype, "number of bad values def unit

nobvo type difftype, "number of bad values order unit

end of wclist.

data : begin of weekdaylist occurs 0, "week list, collects all weeks

spwoc like ZS917-spwoc,

gamng type disptype, "plan

wemng type disptype, "actual

diff type disptype, "difference

zprdif type disptype, "difference kgm

zprtgt type disptype, "plan kgm

zpract type disptype, "actual kgm

amein type meins, "Unit of measure in-house prod

nobvd type difftype, "number of bad values def unit

nobvo type difftype, "number of bad values order unit

wkday type c,

end of weekdaylist.

data : begin of weeklist occurs 0, "week list, collects all weeks

spwoc like ZS917-spwoc,

gamng type disptype, "plan

wemng type disptype, "actual

diff type disptype, "difference

zprdif type disptype, "difference kgm

zprtgt type disptype, "plan kgm

zpract type disptype, "actual kgm

amein type meins, "Unit of measure in-house prod

nobvd type difftype, "number of bad values def unit

nobvo type difftype, "number of bad values order unit

end of weeklist.

data : begin of matdayunit occurs 0, "unit in material per week,day,wc

spwoc like ZS917-spwoc,

arbpl like ZS918-arbpl,

matnr like ZS917-matnr,

wkday type c,

amein type meins, "Unit of measure in-house prod

end of matdayunit.

data : begin of matsumunit occurs 0, "unit of material per week and wc

spwoc like ZS917-spwoc,

arbpl like ZS918-arbpl,

matnr like ZS917-matnr,

amein type meins, "Unit of measure in-house prod

end of matsumunit.

data : begin of wcdayunit occurs 0, "unit of workcenter per week / day

spwoc like ZS917-spwoc,

arbpl like ZS918-arbpl,

wkday type c,

amein type meins, "Unit of measure in-house prod

end of wcdayunit.

data : begin of wcunit occurs 0, "unit of workcenter per week

spwoc like ZS917-spwoc,

arbpl like ZS918-arbpl,

amein type meins, "Unit of measure in-house prod

end of wcunit.

data : begin of weekdayunit occurs 0, "week unit, collects all weeks

spwoc like ZS917-spwoc,

wkday type c,

amein type meins, "Unit of measure in-house prod

end of weekdayunit.

data : begin of weekunit occurs 0, "week unit, collects all weeks

spwoc like ZS917-spwoc,

amein type meins, "Unit of measure in-house prod

end of weekunit.

selection-screen begin of block a with frame title text-010.

************************************************************************

* Parameters definition

************************************************************************

parameters : selplant like ZS917-werks memory id wrk obligatory. "Plant

************************************************************************

* Select-options definition

************************************************************************

select-options : selwctr for ZS918-arbpl matchcode object cram.

"Work Center Range

parameters : startdat like sy-datum obligatory, "Start date

nofweeks(4) type c default 1. "Number of weeks

select-options : selpodat for ZS917-gltrp no-display, "DateRange

selmtart for ZS917-mtart, "PO Material Type

selmatnr for ZS917-matnr matchcode object mat1.

"Material

parameters:

postat(40) type c default ''.

selection-screen skip 1.

selection-screen comment 32(40) text-008.

selection-screen end of block a.

selection-screen skip 1.

selection-screen begin of block b with frame title text-020.

parameters: detail as checkbox default ' ',

defunit as checkbox default ' ',

dispmat as checkbox default 'X', "display mat info

displeg as checkbox default 'X'. " color legend

selection-screen end of block b.

************************************************************************

* Main process

************************************************************************

set pf-status 'MAIN'.

perform set_selection_range.

perform selectdata.

perform complete_data.

perform displaydatalist.

************************************************************************

initialization.

call function 'DATE_COMPUTE_DAY'

exporting

date = sy-datum

importing

day = dayofweek.

auxdate = sy-datum + 1 - dayofweek.

startdat = auxdate.

************************************************************************

top-of-page.

perform display_report_header.

set left scroll-boundary column 16.

************************************************************************

top-of-page during line-selection.

perform display_report_header.

set left scroll-boundary column 16.

************************************************************************

*end-of-page.

* coding. " comments

************************************************************************

*at line-selection.

* coding. " comments

************************************************************************

at user-command.

case sy-ucomm.

when 'DETA'. " Details

detail = 'X'.

perform displaydatalist.

when 'NODE'. " no Details

detail = ' '.

perform displaydatalist.

when 'DUNI'. "default unit

defunit = 'X'.

perform displaydatalist.

when 'OUNI'. "unit fron order

defunit = ' '.

perform displaydatalist.

when 'SOWC'. "sort wc name

sort wclist by arbpl.

perform displaydatalist.

when 'SOCA'. "sort wc performance

sort wclist by sperc.

perform displaydatalist.

when 'SOMN'. "sort mat number

sort matsumlist by matnr.

perform displaydatalist.

when 'SOMA'. "sort mat type

sort matsumlist by mtart.

perform displaydatalist.

when 'SOLC'. "sort mat line code

sort matsumlist by bismt.

perform displaydatalist.

when 'GRAF'. "Chart graph

perform display_chart.

perform displaydatalist.

when 'SCRP'. " Print Form via SAPScript

sapprint = 'X'.

perform displaydatalist.

sapprint = ' '.

perform displaydatalist.

when 'DBUG'.

break-point.

perform displaydatalist.

endcase.

************************************************************************

************************************************************************

*at pfn.

* coding. " comments

************************************************************************

* Forms definition

************************************************************************

************************************************************************

* Forms name : set_selection_range

* sets range for selection in selpodat

************************************************************************

form set_selection_range.

data sweek like allorderlist-spwoc.

* correct startdate to be monday same week

call function 'DATE_GET_WEEK'

exporting

date = startdat

importing

week = sweek.

call function 'WEEK_GET_FIRST_DAY'

exporting

week = sweek

importing

date = startdat.

selpodat-low = startdat.

selpodat-high = startdat + ( 7 * nofweeks ) - 1.

selpodat-sign = 'I'.

selpodat-option = 'BT'.

append selpodat.

endform. " set_selection_range

************************************************************************

* Forms name : selectdata

* selects data from tables ZS917, ZS918

* using select-options and parameters

************************************************************************

form selectdata. "main selection

data i_vornr like ZS918-vornr.

data status(40).

clear allorderlist. refresh allorderlist.

clear allwclist. refresh allwclist.

concatenate '%' postat(38) '%' into status.

if not selwctr is initial.

* establish list of all orders that touch this resource

select * into corresponding fields of table allwclist

from ZS918

where vrsio = '000'

and werks = selplant

and arbpl in selwctr.

endif.

select * from ZS917

where vrsio = '000'

and gltrp in selpodat

and matnr in selmatnr

and zstat_txt like status

and werks = selplant

and mtart in selmtart.

clear allorderlist.

if ZS917-zprtgt = '**' or ZS917-zpract = '**'.

ZS917-zprtgt = '0'.

ZS917-zpract = '0'.

allorderlist-nobvd = 1.

endif.

move-corresponding ZS917 to allorderlist.

* Calculate the differences

allorderlist-diff = abs( allorderlist-gamng - allorderlist-wemng ).

allorderlist-zprdif = abs( allorderlist-zprtgt -

allorderlist-zpract ).

call function 'DATE_COMPUTE_DAY'

exporting

date = allorderlist-gltrp

importing

day = allorderlist-wkday.

call function 'DATE_GET_WEEK'

exporting

date = allorderlist-gltrp

importing

week = allorderlist-spwoc.

if not selwctr is initial.

read table allwclist with key aufnr = allorderlist-aufnr.

check sy-subrc = 0.

endif.

select max( vornr ) into i_vornr from ZS918

where aufnr = ZS917-aufnr.

check i_vornr > 0.

select single arbpl into allorderlist-arbpl

from ZS918

where aufnr = ZS917-aufnr

and vrsio = '000'

and vornr = i_vornr.

append allorderlist.

endselect.

endform.

************************************************************************

* Forms name : complete_data

* completes orderlist with workcenter, fills weeklist

************************************************************************

form complete_data.

data: found type c.

clear: matdaylist, matsumlist, wcdaylist, wclist, weekdaylist,

weeklist, matdayunit, matsumunit, wcdayunit, wcunit,

weekdayunit, weekunit.

refresh: matdaylist, matsumlist, wcdaylist, wclist, weekdaylist,

weeklist, matdayunit, matsumunit, wcdayunit, wcunit,

weekdayunit, weekunit.

sort allorderlist by matnr arbpl spwoc.

loop at allorderlist.

move-corresponding allorderlist to matdayunit.

collect matdayunit.

move-corresponding allorderlist to matsumunit.

collect matsumunit.

move-corresponding allorderlist to wcdayunit.

collect wcdayunit.

move-corresponding allorderlist to wcunit.

collect wcunit.

move-corresponding allorderlist to weekdayunit.

collect weekdayunit.

move-corresponding allorderlist to weekunit.

collect weekunit.

move-corresponding allorderlist to matdaylist.

matdaylist-amein = space.

collect matdaylist.

move-corresponding matdaylist to matsumlist.

collect matsumlist.

move-corresponding matdaylist to wcdaylist.

collect wcdaylist.

move-corresponding wcdaylist to wclist.

collect wclist.

move-corresponding wcdaylist to weekdaylist.

collect weekdaylist.

move-corresponding weekdaylist to weeklist.

collect weeklist.

endloop. "allorderlist

perform complete_unit.

sort weeklist by spwoc.

sort wclist by spwoc arbpl.

sort matsumlist by spwoc arbpl matnr.

sort allorderlist by spwoc arbpl matnr aufnr.

endform.

************************************************************************

* Forms name : complete_unit

* checks order unit and fills *** if essential

************************************************************************

form complete_unit.

data: z1 type i.

loop at weeklist. "***************************************** weeklist

z1 = -1.

loop at weekunit where spwoc = weeklist-spwoc.

z1 = z1 + 1. weeklist-amein = weekunit-amein.

endloop. " weekunit.

if z1 > 0. weeklist-amein = '***'. endif.

modify weeklist.

endloop. "weeklist

loop at weekdaylist. "*********************************** weekdaylist

z1 = -1.

loop at weekdayunit where spwoc = weekdaylist-spwoc

and wkday = weekdaylist-wkday.

z1 = z1 + 1. weekdaylist-amein = weekdayunit-amein.

endloop. " weekdayunit.

if z1 > 0. weekdaylist-amein = '***'. endif.

modify weekdaylist.

endloop. "weekdaylist

loop at wclist. "******************************************** wclist

z1 = -1.

loop at wcunit where spwoc = wclist-spwoc

and arbpl = wclist-arbpl.

z1 = z1 + 1. wclist-amein = wcunit-amein.

endloop. " wcunit.

if z1 > 0. wclist-amein = '***'. endif.

modify wclist.

endloop. "wclist

loop at wcdaylist. "************************************** wcdaylist

z1 = -1.

loop at wcdayunit where spwoc = wcdaylist-spwoc

and wkday = wcdaylist-wkday

and arbpl = wcdaylist-arbpl.

z1 = z1 + 1. wcdaylist-amein = wcdayunit-amein.

endloop. " wcdayunit.

if z1 > 0. wcdaylist-amein = '***'. endif.

modify wcdaylist.

endloop. "wcdaylist

loop at matsumlist. "************************************* matsumlist

z1 = -1.

loop at matsumunit where spwoc = matsumlist-spwoc

and arbpl = matsumlist-arbpl

and matnr = matsumlist-matnr.

z1 = z1 + 1. matsumlist-amein = matsumunit-amein.

endloop. " matsumunit.

if z1 > 0. matsumlist-amein = '***'. endif.

modify matsumlist.

endloop. "matsumlist

loop at matdaylist. "************************************* matdaylist

z1 = -1.

loop at matdayunit where spwoc = matdaylist-spwoc

and arbpl = matdaylist-arbpl

and matnr = matdaylist-matnr

and wkday = matdaylist-wkday.

z1 = z1 + 1. matdaylist-amein = matdayunit-amein.

endloop. " matdayunit.

if z1 > 0. matdaylist-amein = '***'. endif.

modify matdaylist.

endloop. "matdaylist

endform. "complete_unit

************************************************************************

* Forms name : calculate_percentage

* calculates differences and percentage

************************************************************************

form calculate_percentage using p_tgt like ZS917-zprtgt

p_act like ZS917-zpract

p_diff type disptype

changing p_stgt type sqtytype

p_sact type sqtytype

p_sdiff type sqtytype

p_sperc type sperctype.

data: i_diff type disptype,

i_perc type perctype.

if ( p_tgt = '**' ) or ( p_act = '**' ).

p_stgt = ' ***'.

p_sact = ' ***'.

p_sdiff = ' ***'.

p_sperc = ' n/a'.

else.

* Change type of target

i_diff = p_tgt.

p_stgt = i_diff.

* Change type of actual

i_diff = p_act.

p_sact = i_diff.

p_sdiff = p_diff.

if p_tgt > 0. "calc perc.

* Calculation changed 06/01

i_perc = ( 1 - ( p_diff / p_tgt ) ) * 100.

* i_perc = 100 - 100 * p_diff / p_tgt.

p_sperc = i_perc.

else.

p_sperc = ' n/a'.

endif.

endif.

endform.

************************************************************************

* Forms name : display_chart

* displays chart graphics

************************************************************************

form display_chart.

data: begin of dat occurs 1,

text(20) type c,

plan type p,

act type p,

diff type p,

perc type p,

end of dat.

data: i_tgt like ZS917-zprtgt,

i_act like ZS917-zpract,

i_diff type disptype,

i_stgt type sqtytype,

i_sact type sqtytype,

i_sdiff type sqtytype,

i_sperc type sperctype,

i_datum like sy-datum.

clear dat. refresh dat.

loop at weekdaylist.

if defunit = 'X'.

if weekdaylist-nobvd = 0.

i_tgt = weekdaylist-zprtgt.

i_act = weekdaylist-zpract.

i_diff = weekdaylist-zprdif.

endif.

else.

i_tgt = weekdaylist-gamng.

i_act = weekdaylist-wemng.

i_diff = weekdaylist-diff.

endif.

perform calculate_percentage using i_tgt i_act i_diff

changing i_stgt i_sact i_sdiff i_sperc.

call function 'WEEK_GET_FIRST_DAY'

exporting

week = weekdaylist-spwoc

importing

date = i_datum.

i_datum = i_datum + weekdaylist-wkday - 1.

if weekdaylist-nobvd = 0 or defunit = ' '.

write i_datum to dat-text dd/mm/yyyy.

dat-plan = i_stgt.

dat-act = i_sact.

dat-diff = i_sdiff.

if i_tgt > 0.

dat-perc = i_sperc.

else.

dat-perc = 0.

endif.

append dat.

endif.

endloop.

call function 'GRAPH_3D'

exporting

titl = 'Factory Production Performance'

tables

data = dat.

endform.

************************************************************************

* Forms name : displaydatalist

* writes result of first selection to screen

************************************************************************

form displaydatalist.

sy-lsind = 0.

disphead = 'X'.

if sapprint = 'X'.

firstpage = 'X'.

call function 'OPEN_FORM'

exporting

form = 'Z_C_FPP'.

perform fill_report_header.

endif.

* perform display_report_header.

loop at weeklist.

perform display_week_header.

loop at wclist where spwoc = weeklist-spwoc and arbpl <> space.

perform display_workcenter_header.

loop at matsumlist where spwoc = weeklist-spwoc

and arbpl = wclist-arbpl.

if dispmat = 'X'.

perform display_material_header.

endif.

if detail = 'X'.

loop at allorderlist where spwoc = weeklist-spwoc

and arbpl = wclist-arbpl

and matnr = matsumlist-matnr.

perform display_order_quantity.

endloop. " allorderlist

endif.

perform display_material_sum.

endloop. " matsumlist

perform display_workcenter_sum.

endloop. "wclist

perform display_week_sum.

endloop. "weeklist

perform display_report_footer.

set left scroll-boundary column 18.

endform. "displaydatalist

************************************************************************

* FORM GET_MATERIAL_TEXT *

************************************************************************

* get material short text to matnr *

* --> MATNR *

* <-- MATTEXT *

************************************************************************

form get_material_text using matn changing mattext.

concatenate '#_' matn into mattext.

select * from makt where matnr = matn and spras = spras_c.

mattext = makt-maktx.

endselect.

endform.

************************************************************************

* FORM GET_WORKCENTER_NAME *

************************************************************************

* get name of workcenter *

* --> arbpl *

* <-- arbpltxt *

************************************************************************

form get_workcenter_name using wctr werks changing wcttext.

data:begin of akt_drilldown occurs 1.

include structure mcddown.

data:end of akt_drilldown.

data: oe_flg_hier.

akt_drilldown-domname = 'WERKS'.

akt_drilldown-object = werks.

akt_drilldown-rollname = 'WERKS'.

append akt_drilldown.

akt_drilldown-domname = 'ARBPL'.

akt_drilldown-object = wctr.

akt_drilldown-rollname = 'ARBPL'.

append akt_drilldown.

perform text_search_dom(rmcstext) tables akt_drilldown

using 'ARBPL'

'ARBPL' "oe_rollname

wctr "oe_objekt

sy-repid "progname

changing oe_flg_hier

wcttext.

endform.

************************************************************************

* FORM GET_FACTORY_NAME *

************************************************************************

* get name of factory *

* --> werks *

* <-- werktxt *

************************************************************************

form get_factory_name using werk changing werktxt.

concatenate '#_' werk into werktxt.

select * from t001w where werks = werk and spras = spras_c.

werktxt = t001w-name1.

endselect.

endform.

************************************************************************

* FORM Fill_REPORT_HEADER *

************************************************************************

* fills zc211 with header data *

************************************************************************

form fill_report_header.

data: werktxt like t001w-name1,

dtext(20) type c,

utext(20) type c.

perform get_factory_name using selplant changing werktxt.

move-corresponding syst to zc211.

zc211-cprog = syst-repid.

zc211-werks = selplant.

zc211-werktxt = werktxt.

zc211-fromdat = selpodat-low.

zc211-todat = selpodat-high.

if defunit = 'X'. utext = 'Def.Unit'. else. utext = 'Ord.Unit'. endif.

if detail = 'X'. dtext = 'Detail'. else. dtext = 'Summary'. endif.

concatenate utext '/' dtext into zc211-stext separated by space.

endform.

************************************************************************

* FORM DISPLAY_REPORT_HEADER *

************************************************************************

* prints header of the report *

************************************************************************

form display_report_header.

data: werktxt like t001w-name1,

dtext(20) type c,

utext(20) type c.

check disphead = 'X'.

data: sik_zc211 like zc211.

sik_zc211 = zc211.

perform fill_report_header.

format color col_background.

write: 'Printed',

10(15) zc211-datum,

50 zc211-title.

write: /

'Report',

10 zc211-cprog.

skip.

write: / 'From:',

10 zc211-fromdat,

24(6) 'To:',

zc211-todat,

50 zc211-werks,

zc211-werktxt.

write: / zc211-stext.

if displeg = 'X'.

write:

50 'Colours:',

(12) 'Week' color col_key,

(12) 'Resource' color col_group,

(12) 'Material' color col_positive,

(12) 'Total' color col_total,

(12) 'Order' color col_normal.

endif.

zc211 = sik_zc211.

endform.

************************************************************************

* FORM DISPLAY_REPORT_FOOTER *

************************************************************************

* prints footer of the report *

************************************************************************

form display_report_footer.

if sapprint = 'X'.

call function 'CLOSE_FORM'.

else.

skip.

format color col_background.

write: /

'** end of report **'.

if test = ' '.

clear disphead.

include zsi0010.

endif.

endif.

endform.

************************************************************************

* FORM DISPLAY_WEEK_HEADER *

************************************************************************

* prints week header *

* uses actual entry in weeklist *

************************************************************************

form display_week_header.

data: monday like ZS917-sptag,

sunday like ZS917-sptag.

if sapprint = 'X'.

if firstpage = ' '.

call function 'WRITE_FORM'

exporting

element = 'NEWPAGE'

window = 'MAIN'.

endif.

firstpage = ' '.

endif. "sapprint

firstwc = 'X'.

call function 'WEEK_GET_FIRST_DAY'

exporting

week = weeklist-spwoc

importing

date = monday.

sunday = monday + 6.

if monday < selpodat-low. monday = selpodat-low. endif.

if sunday > selpodat-high. sunday = selpodat-high. endif.

zc211-zweek = weeklist-spwoc.

zc211-fromdat = monday. zc211-todat = sunday.

if sapprint = ' '.

format color col_key.

skip.

write: /

'Week: ',

(15) zc211-zweek,

'From:',

(15) zc211-fromdat,

'To:'.

if detail = 'X'.

write:(204) zc211-todat.

else.

write:(140) zc211-todat.

endif. "detail

endif. "sapprint

endform.

************************************************************************

* FORM DISPLAY_WORKCENTER_HEADER *

************************************************************************

* prints workcenter header *

* uses actual entry in wclist *

************************************************************************

form display_workcenter_header.

data: mday like ZS917-sptag.

data: fmday like ZS917-sptag.

call function 'WEEK_GET_FIRST_DAY'

exporting

week = weeklist-spwoc

importing

date = mday.

fmday = mday.

zc211-arbpl = wclist-arbpl.

perform get_workcenter_name using zc211-arbpl selplant

changing zc211-text1.

if sapprint = 'X'.

call function 'WRITE_FORM'

exporting

element = 'WCHEADER'

window = 'MAIN'.

else. "sapprint

if firstwc = ' '. skip. endif.

firstwc = ' '.

format color col_group.

write: / 'Resource: '.

if detail = 'X'.

write:(10) zc211-arbpl, (228) zc211-text1.

else.

write:(10) zc211-arbpl, (164) zc211-text1.

endif.

format color col_heading.

write: /(15)'', sy-vline.

if detail = 'X'.

write: (12) 'Monday', (13) mday, sy-vline. mday = mday + 1.

write: (12) 'Tuesday', (13) mday, sy-vline. mday = mday + 1.

write: (12) 'Wednesday', (13) mday, sy-vline. mday = mday + 1.

write: (12) 'Thursday', (13) mday, sy-vline. mday = mday + 1.

write: (12) 'Friday', (13) mday, sy-vline. mday = mday + 1.

write: (12) 'Saturday', (13) mday, sy-vline. mday = mday + 1.

write: (12) 'Sunday', (13) mday, sy-vline.

write: (26) 'Total', sy-vline, (3) ''.

else.

write: (7) ' Mon', (10) mday, sy-vline. mday = mday + 1.

write: (7) ' Tue', (10) mday, sy-vline. mday = mday + 1.

write: (7) ' Wed', (10) mday, sy-vline. mday = mday + 1.

write: (7) ' Thu', (10) mday, sy-vline. mday = mday + 1.

write: (7) ' Fri', (10) mday, sy-vline. mday = mday + 1.

write: (7) ' Sat', (10) mday, sy-vline. mday = mday + 1.

write: (7) ' Sun', (10) mday, sy-vline.

write: (18) 'Total', sy-vline, (3) ''.

endif.

if detail = 'X'.

write: /(15)'Material/Order'.

else.

write: /(15)'Material'.

endif.

do 8 times.

if detail = 'X'.

write: sy-vline, 'Plan Actual Diff % '.

else.

write: sy-vline, 'Plan Actual % '.

endif.

enddo.

write: sy-vline no-gap, (4) ' UOM'.

endif. "sapprint

endform.

************************************************************************

* FORM DISPLAY_MATERIAL_HEADER *

************************************************************************

* prints material header *

* uses actual entry in matsumlist *

************************************************************************

form display_material_header.

perform get_material_text using matsumlist-matnr changing zc211-text1.

zc211-bismt = matsumlist-bismt.

zc211-mtart = matsumlist-mtart.

zc211-matnr = matsumlist-matnr.

if sapprint = 'X'.

call function 'WRITE_FORM'

exporting

element = 'MATHEADER'

window = 'MAIN'.

else. "sapprint

format color col_positive.

write:/(17) zc211-matnr, (10) zc211-mtart, zc211-bismt.

if detail = ' '.

write: (135) zc211-text1.

else.

write: (199) zc211-text1.

endif.

write: sy-vline no-gap, (4) ''.

endif. " sapprint

endform.

************************************************************************

* FORM DISPLAY_MATERIAL_SUM *

************************************************************************

* prints material name and totals *

* uses actual entry in matsumlist *

************************************************************************

form display_material_sum.

data: i_mattext(20) type c.

clear zc212.

* get values for material per day

loop at matdaylist where spwoc = wclist-spwoc

and arbpl = wclist-arbpl

and matnr = matsumlist-matnr.

perform day_disp_values using matdaylist-zprtgt matdaylist-zpract

matdaylist-zprdif matdaylist-gamng

matdaylist-wemng matdaylist-diff

matdaylist-wkday matdaylist-nobvd.

endloop.

perform get_material_text using matsumlist-matnr changing i_mattext.

zc212-matnr = i_mattext.

zc212-matnr = 'Material total'.

if defunit = 'X'.

zc212-amein = 'KGM'.

else.

zc212-amein = matsumlist-amein.

endif.

* total values per material

perform sum_disp_values using matsumlist-zprtgt matsumlist-zpract

matsumlist-zprdif matsumlist-gamng

matsumlist-wemng matsumlist-diff

matsumlist-nobvd.

if sapprint = 'X'.

call function 'WRITE_FORM'

exporting

element = 'MATLINE'

window = 'MAIN'.

if detail = 'X'.

call function 'WRITE_FORM'

exporting

element = 'ULINEDOT'

window = 'MAIN'.

endif.

else.

format color col_positive.

perform display_order_head.

format color col_total.

perform display_order_line.

endif.

endform. "display_material_sum

************************************************************************

* FORM DISPLAY_WEEK_SUM *

************************************************************************

* prints week sum and totals *

* uses actual entry in weeklist and weekdaylist *

************************************************************************

form display_week_sum.

clear zc212.

* get values for workcenter per day

loop at weekdaylist where spwoc = weeklist-spwoc.

perform day_disp_values using weekdaylist-zprtgt weekdaylist-zpract

weekdaylist-zprdif weekdaylist-gamng

weekdaylist-wemng weekdaylist-diff

weekdaylist-wkday weekdaylist-nobvd.

endloop.

* get values for week-totals

perform sum_disp_values using weeklist-zprtgt weeklist-zpract

weeklist-zprdif weeklist-gamng

weeklist-wemng weeklist-diff

weeklist-nobvd.

zc212-matnr = 'week'.

zc212-matnr+5 = weeklist-spwoc+4.

zc212-matnr+8 = 'total'.

if defunit = 'X'.

zc212-amein = 'KGM'.

else.

zc212-amein = weeklist-amein.

endif.

if sapprint = 'X'.

call function 'WRITE_FORM'

exporting

element = 'WEEKLINE'

window = 'MAIN'.

else.

format color col_key.

perform display_order_head.

format color col_key.

perform display_order_line.

skip.

endif.

endform. " display_week_sum

************************************************************************

* FORM DISPLAY_WORKCENTER_SUM *

************************************************************************

* prints material name and totals *

* uses actual entry in matsumlist *

************************************************************************

form display_workcenter_sum.

clear zc212.

* get values for workcenter per day

loop at wcdaylist where spwoc = wclist-spwoc and arbpl = wclist-arbpl.

perform day_disp_values using wcdaylist-zprtgt wcdaylist-zpract

wcdaylist-zprdif wcdaylist-gamng

wcdaylist-wemng wcdaylist-diff

wcdaylist-wkday wcdaylist-nobvd.

endloop.

* get values for workcenter-totals

perform sum_disp_values using wclist-zprtgt wclist-zpract

wclist-zprdif wclist-gamng

wclist-wemng wclist-diff

wclist-nobvd.

* wclist-sperc = i_sperc.

* modify wclist.

zc212-matnr = wclist-arbpl.

zc212-matnr = 'Resource total'.

if defunit = 'X'.

zc212-amein = 'KGM'.

else.

zc212-amein = wclist-amein.

endif.

if sapprint = 'X'.

call function 'WRITE_FORM'

exporting

element = 'WRKLINE'

window = 'MAIN'.

call function 'WRITE_FORM'

exporting

element = 'ULINEBOLD'

window = 'MAIN'.

else.

format color col_group.

perform display_order_head.

format color col_total.

perform display_order_line.

endif.

endform. " display_workcenter_sum

************************************************************************

* FORM ASSIGN_DISPLAYDATA *

************************************************************************

* assigns display data per day to structure zc212 *

************************************************************************

form assign_displaydata

using p_wkday p_stgt p_sact p_sdiff p_sperc.

case p_wkday.

when '1'. "monday

zc212-p1qty = p_stgt.

zc212-a1qty = p_sact.

zc212-d1qty = p_sdiff.

zc212-perc1 = p_sperc.

when '2'. "tuesday

zc212-p2qty = p_stgt.

zc212-a2qty = p_sact.

zc212-d2qty = p_sdiff.

zc212-perc2 = p_sperc.

when '3'. "wednesday

zc212-p3qty = p_stgt.

zc212-a3qty = p_sact.

zc212-d3qty = p_sdiff.

zc212-perc3 = p_sperc.

when '4'. "thursday

zc212-p4qty = p_stgt.

zc212-a4qty = p_sact.

zc212-d4qty = p_sdiff.

zc212-perc4 = p_sperc.

when '5'. "friday

zc212-p5qty = p_stgt.

zc212-a5qty = p_sact.

zc212-d5qty = p_sdiff.

zc212-perc5 = p_sperc.

when '6'. "saturday

zc212-p6qty = p_stgt.

zc212-a6qty = p_sact.

zc212-d6qty = p_sdiff.

zc212-perc6 = p_sperc.

when '7'. "sunday

zc212-p7qty = p_stgt.

zc212-a7qty = p_sact.

zc212-d7qty = p_sdiff.

zc212-perc7 = p_sperc.

endcase.

endform.

************************************************************************

* FORM DISPLAY_ORDER_QUANTITY *

************************************************************************

* prints order quantities per order *

* uses actual entry in allorderlist *

************************************************************************

form display_order_quantity.

clear zc212.

* get values

perform day_disp_values using allorderlist-zprtgt allorderlist-zpract

allorderlist-zprdif allorderlist-gamng

allorderlist-wemng allorderlist-diff

allorderlist-wkday allorderlist-nobvd.

zc212-matnr = allorderlist-aufnr.

* write allorderlist-aufnr to zc212-matnr.

if defunit = 'X'.

zc212-amein = 'KGM'.

else.

zc212-amein = allorderlist-amein.

endif.

if sapprint = 'X'.

call function 'WRITE_FORM'

exporting

element = 'ORDERLINE'

window = 'MAIN'.

else.

format color col_normal.

perform display_order_head.

format color col_normal.

perform display_order_line.

endif.

endform.

************************************************************************

* FORM DISPLAY_ORDER_HEAD *

************************************************************************

* prints order head *

* uses actual entry in zc212 *

************************************************************************

form display_order_head.

write: /(15)

zc212-matnr,

sy-vline no-gap.

endform.

************************************************************************

* FORM DISPLAY_ORDER_LINE *

************************************************************************

* prints order line *

* uses actual entry in zc212 *

************************************************************************

form display_order_line.

if detail = 'X'.

write:

zc212-p1qty intensified off no-gap, "monday

zc212-a1qty intensified on no-gap,

zc212-d1qty intensified off no-gap,

zc212-perc1 intensified on no-gap,

sy-vline no-gap,

zc212-p2qty intensified off no-gap, "tuesday

zc212-a2qty intensified on no-gap,

zc212-d2qty intensified off no-gap,

zc212-perc2 intensified on no-gap,

sy-vline no-gap,

zc212-p3qty intensified off no-gap, "wednesday

zc212-a3qty intensified on no-gap,

zc212-d3qty intensified off no-gap,

zc212-perc3 intensified on no-gap,

sy-vline no-gap,

zc212-p4qty intensified off no-gap, "thursday

zc212-a4qty intensified on no-gap,

zc212-d4qty intensified off no-gap,

zc212-perc4 intensified on no-gap,

sy-vline no-gap,

zc212-p5qty intensified off no-gap, "friday

zc212-a5qty intensified on no-gap,

zc212-d5qty intensified off no-gap,

zc212-perc5 intensified on no-gap,

sy-vline no-gap,

zc212-p6qty intensified off no-gap, "saturday

zc212-a6qty intensified on no-gap,

zc212-d6qty intensified off no-gap,

zc212-perc6 intensified on no-gap,

sy-vline no-gap,

zc212-p7qty intensified off no-gap, "sunday

zc212-a7qty intensified on no-gap,

zc212-d7qty intensified off no-gap,

zc212-perc7 intensified on no-gap,

sy-vline no-gap,

zc212-ptqty intensified off no-gap, "total

zc212-atqty intensified on no-gap,

zc212-dtqty intensified off no-gap,

zc212-perct intensified on no-gap.

else.

write: " Summary, no detail

zc212-p1qty intensified off no-gap, "monday

zc212-a1qty intensified on no-gap,

zc212-perc1 intensified off no-gap,

sy-vline no-gap,

zc212-p2qty intensified off no-gap, "tuesday

zc212-a2qty intensified on no-gap,

zc212-perc2 intensified off no-gap,

sy-vline no-gap,

zc212-p3qty intensified off no-gap, "wednesday

zc212-a3qty intensified on no-gap,

zc212-perc3 intensified off no-gap,

sy-vline no-gap,

zc212-p4qty intensified off no-gap, "thursday

zc212-a4qty intensified on no-gap,

zc212-perc4 intensified off no-gap,

sy-vline no-gap,

zc212-p5qty intensified off no-gap, "friday

zc212-a5qty intensified on no-gap,

zc212-perc5 intensified off no-gap,

sy-vline no-gap,

zc212-p6qty intensified off no-gap, "saturday

zc212-a6qty intensified on no-gap,

zc212-perc6 intensified off no-gap,

sy-vline no-gap,

zc212-p7qty intensified off no-gap, "sunday

zc212-a7qty intensified on no-gap,

zc212-perc7 intensified off no-gap,

sy-vline no-gap,

zc212-ptqty intensified off no-gap, "total

zc212-atqty intensified on no-gap,

zc212-perct intensified off no-gap.

endif.

write: sy-vline, zc212-amein.

endform.

*&---------------------------------------------------------------------*

*& Form day_disp_values

*&---------------------------------------------------------------------*

* Form to do day caluclations used by all levels of report

* NS 06/01

*----------------------------------------------------------------------*

* -->P_ZPRTGT KGM target

* -->P_ZPRACT KGM actual

* -->P_ZPRDIF KGM difference

* -->P_GAMNG base uom target

* -->P_WEMNG base uom actual

* -->P_DIFF base uom difference

* -->P_WKDAY weekday

* -->P_NOBVD no KGM conversion

*----------------------------------------------------------------------*

form day_disp_values using p_zprtgt

p_zpract

p_zprdif

p_gamng

p_wemng

p_diff

p_wkday

p_nobvd.

data: i_tgt like ZS917-zprtgt,

i_act like ZS917-zpract,

i_diff type disptype,

i_stgt type sqtytype,

i_sact type sqtytype,

i_sdiff type sqtytype,

i_sperc type sperctype.

* Get the right values to pass to the calculation form

if defunit = 'X'.

if p_nobvd > 0.

i_tgt = '***'.

i_act = '***'.

else.

i_tgt = p_zprtgt.

i_act = p_zpract.

i_diff = p_zprdif.

endif.

else.

i_tgt = p_gamng.

i_act = p_wemng.

i_diff = p_diff.

endif.

perform calculate_percentage using i_tgt i_act i_diff

changing i_stgt i_sact i_sdiff i_sperc.

* Put the values into the correct display variables

perform assign_displaydata

using p_wkday i_stgt i_sact i_sdiff i_sperc.

endform. " day_disp_values

*&---------------------------------------------------------------------*

*& Form sum_disp_values

*&---------------------------------------------------------------------*

* Form to do sum caluclations used by all levels of report

* NS 06/01

*----------------------------------------------------------------------*

* -->P_ZPRTGT KGM target

* -->P_ZPRACT KGM actual

* -->P_ZPRDIF KGM difference

* -->P_GAMNG base uom target

* -->P_WEMNG base uom actual

* -->P_DIFF base uom difference

* -->P_NOBVD no KGM conversion

*----------------------------------------------------------------------*

form sum_disp_values using p_zprtgt

p_zpract

p_zprdif

p_gamng

p_wemng

p_diff

p_nobvd.

data: i_tgt like ZS917-zprtgt,

i_act like ZS917-zpract,

i_diff type disptype,

i_stgt type sqtytype,

i_sact type sqtytype,

i_sdiff type sqtytype,

i_sperc type sperctype.

* Get the correct values before doing calculation

if defunit = 'X'.

if p_nobvd > 0.

i_tgt = '***'.

i_act = '***'.

else.

i_tgt = p_zprtgt.

i_act = p_zpract.

i_diff = p_zprdif.

endif.

else.

i_tgt = p_gamng.

i_act = p_wemng.

i_diff = p_diff.

endif.

perform calculate_percentage using i_tgt i_act i_diff

changing i_stgt i_sact i_sdiff i_sperc.

zc212-ptqty = i_stgt.

zc212-atqty = i_sact.

zc212-dtqty = i_sdiff.

zc212-perct = i_sperc.

endform. " sum_disp_values

  • No labels