* & Program name: zfi_rp032
* & Title: fuel cost factor analysis table (current month)
* & Module name: fi
* & Sub-module:
* & Author: Jason Zhang
Report zfi_rp032 no standard page heading
Line-size 400
Line-count 200 (0)
Message-ID zfimeg.
*----------------------------------------------------------------------*
* Declare the referenced data table
*----------------------------------------------------------------------*
Tables: t001, cosr, COEP.
*----------------------------------------------------------------------*
* Macro definition
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
* Variable definition
*----------------------------------------------------------------------*
Data: Begin of gt_ys occurs 0,
Bukrs like t001-bukrs, "company Code
Ysgdl like cosr-sme001, "Budget Power Supply
Ysgdmh like cosr-sme001, "coal consumption for Budget Power Supply
Ysgdbml like cosr-sme001, "budget power supply standard coal volume
Yssrl like cosr-sme001, "budget for sale
Ysgrmh like cosr-sme001, "budget Heating Coal Consumption
Ysgrbml like cosr-sme001, "budget heating standard coal volume
Ysbmlzj like cosr-sme001, "total estimated coal volume
Ysbmdj like cosr-sme001, "budget bidding price
Ysrlf like cosr-sme001, "budget fuel fee
End of gt_ys.
* Final result table
Data: Begin of gt_table occurs 0,
XH (2), "no.
Bukrs like t001-bukrs,
Butxt like t001-butxt, "company description
Ysgdl like cosr-sme001, "Budget Power Supply
Ysgdmh like cosr-sme001, "coal consumption for Budget Power Supply
Ysgdbml like cosr-sme001, "budget power supply standard coal volume
Yssrl like cosr-sme001, "budget for sale
Ysgrmh like cosr-sme001, "budget Heating Coal Consumption
Ysgrbml like cosr-sme001, "budget heating standard coal volume
Ysbmlzj like cosr-sme001, "total estimated coal volume
Ysbmdj like cosr-sme001, "budget bidding price
Ysrlf like cosr-sme001, "budget fuel fee
Sjgdl like cosr-sme001, "actual power supply
Sjgdmh like cosr-sme001, "actual coal consumption for Power Supply
Sjgdbml like cosr-sme001, "actual coal volume
Sjsrl like cosr-sme001, "actual sale of heat
Sjgrmh like cosr-sme001, "actual coal consumption for Heating
Sjgrbml like cosr-sme001, "actual coal volume for Heat Supply
Sjbmlzj like cosr-sme001, "total actual coal volume
Sjbmdj like cosr-sme001, "actual unit price of standard coal
Sjrlf like cosr-sme001, "actual fuel fee
Gdzb_gdlce like cosr-sme001, "power supply indicator Power Supply difference
Gdzb_gdmh like cosr-sme001, "power supply indicator Coal Consumption
Gdzb_gdbml like cosr-sme001, "power supply index coal volume
Gdzb_yxrlf like cosr-sme001, "power supply index affects fuel fee
Gdzb_sjgdl like cosr-sme001, "actual power supply indicators
Gdzb_gdmhce like cosr-sme001, "coal consumption difference of Power Supply Index
Gdzb_yxgdbml like cosr-sme001, "power supply index influences power supply standard coal volume
Gdzb_yxrlf2 like cosr-sme001, "power supply index affects fuel fee 2
Grzb_xslce like cosr-sme001, "Heating index sales Heat Balance
Grzb_grmh like cosr-sme001, "Heating index Heating Coal Consumption
Grzb_yxgrbml like cosr-sme001, "Heating index affects the volume of coal
Grzb_yxrlf like cosr-sme001, "Heating index affects fuel fee
Grzb_sjsrl like cosr-sme001, "Heating index actual sale heat
Grzb_grmhce like cosr-sme001, "Heating index heating coal consumption difference
Grzb_grbml like cosr-sme001, "Heating index affects the coal supply volume
Grzb_yxrlf2 like cosr-sme001, "Heating index affects fuel fee 2
Bmdj_sjzhbml like cosr-sme001, "actual unit price of standard coal
Bmdj_bmdjce like cosr-sme001, "standard coal unit price difference
Bmdj_yxrlf like cosr-sme001, "the unit price of standard coal affects fuel fee
Gxyshjyx_yxrlf like cosr-sme001, "Total influence of various factors-Impact on fuel fees
Gxyshjyxcy_yxrlf like cosr-sme001, "total impact of various factors-Impact on fuel fees
End of gt_table.
*----------------------------------------------------------------------*
* Screen query condition definition
*----------------------------------------------------------------------*
Selection-screen begin of block blk1 with frame title text-001.
Select-options: p_bukrs for bkpf-bukrs obligatory.
* Parameters: p_bukrs like bkpf-bukrs obligatory,
Parameters: p_gjahr like bkpf-gjahr obligatory default sy-datum + 0 (4 ),
P_monat like bkpf-Monat obligatory default sy-datum + 4 (2 ).
Selection-screen end of block blk1.
Selection-screen begin of screen 0500 title text-002 as window.
Parameters: p_file like rlgrap-filename obligatory.
Selection-screen end of screen 0500.
* Parameters: r1 radiobutton group r default 'x ',
* R2 radiobutton group R.
At selection-screen.
* Permission check
Perform bukrs_auth_check using p_bukrs '03 '.
If sy-subrc Ne 0.
Message i008 with p_bukrs.
Stop.
Endif.
Initialization.
Concatenate path 'zfi _ rp032 \ zfi_rp032.xls 'into p_file.
Start-of-selection.
Perform main.
* Master Program
Form main.
Perform get_data.
Perform down_to_excel.
Endform. "Main
*&---------------------------------------------------------------------*
* & Form get_data
*&---------------------------------------------------------------------*
* Text
*----------------------------------------------------------------------*
* --> P1 text
* <-- P2 text
*----------------------------------------------------------------------*
Form get_data.
* Define variables and pointers
Data: n_point like sy-index.
Data: n_point_2 like sy-index.
Field-Symbols: <dyn_field> type any.
* Actual cosr count
Data: Begin of gt_temp occurs 0,
Objnr like cosr-objnr,
Stagr like cosr-stagr,
Sme001 like cosr-sme001,
Sme002 like cosr-sme002,
Sme003 like cosr-sme003,
Sme004 like cosr-sme004,
Sme005 like cosr-sme005,
Sme006 like cosr-sme006,
Sme007 like cosr-sme007,
Sme008 like cosr-sme008,
Sme009 like cosr-sme009,
Sme010 like cosr-sme010,
Sme011 like cosr-sme011,
Sme012 like cosr-sme012,
Sme013 like cosr-sme013,
Sme014 like cosr-sme014,
Sme015 like cosr-sme015,
Sme016 like cosr-sme016,
End of gt_temp.
Data: Begin of gt_temp2 occurs 0.
Include structure gt_temp.
Data: End of gt_temp2.
* Fuel fee internal table
Data: Begin of gt_faglflext occurs 0,
Rbukrs like faglflext-rbukrs,
Hsl01 like faglflext-hsl01,
Hsl02 like faglflext-hsl02,
Hsl03 like faglflext-hsl03,
Hsl04 like faglflext-hsl04,
Hsl05 like faglflext-hsl05,
Hsl06 like faglflext-hsl06,
Hsl07 like faglflext-hsl07,
Hsl08 like faglflext-hsl08,
Hsl09 like faglflext-hsl09,
Hsl10 like faglflext-hsl10,
Hsl11 like faglflext-hsl11,
Hsl12 like faglflext-hsl12,
Hsl13 like faglflext-hsl13,
Hsl14 like faglflext-hsl14,
Hsl15 like faglflext-hsl15,
Hsl16 like faglflext-hsl16,
End of gt_faglflext.
* Power generation and production indicators: Power Supply
Select objnr stagr
Sme001 sme002 sme003 sme004 sme005 sme006 sme007
Sme008 sme009 sme010 sme011 sme012 sme013 sme014
Sme015 sme016
From cosr
Into corresponding fields of table gt_temp
Where wrttp = '04 'and
Objnr like 'ksnupc00% 'and
Stagr in ('sd0003', 'sd0010', 'sr0002', 'sr0003') and
Gjahr = p_gjahr.
* Actual fuel fee:
Select rbukrs hsl01 hsl02 hsl03 hsl04 hsl05 hsl06 hsl07 hsl08
Hsl09 hsl10 hsl11 hsl12 hsl13 hsl14 hsl15 hsl16
From faglflext
Into corresponding fields of gt_faglflext
Where ryear = p_gjahr and
Racct in ('20160301', '20160301', '20160301') and
Rbukrs in p_bukrs.
Collect gt_faglflext.
Endselect.
* Power generation and production indicators: the power supply is * 9101-* 9199
Loop at gt_temp where objnr + 14 (2) = '00' or objnr + 12 (2) <> '91 '.
If sy-subrc = 0.
Delete gt_temp.
Endif.
Endloop.
* Truncation accumulation:
Sort gt_temp by objnr.
Loop at gt_temp.
Gt_temp2-objnr = gt_temp-objnr + 0 (12 ).
Gt_temp2-stagr = gt_temp-stagr.
Gt_temp2-sme001 = gt_temp-sme001.
Gt_temp2-sme002 = gt_temp-sme002.
Gt_temp2-sme003 = gt_temp-sme003.
Gt_temp2-sme004 = gt_temp-sme004.
Gt_temp2-sme005 = gt_temp-sme005.
Gt_temp2-sme006 = gt_temp-sme006.
Gt_temp2-sme007 = gt_temp-sme007.
Gt_temp2-sme008 = gt_temp-sme008.
Gt_temp2-sme009 = gt_temp-sme009.
Gt_temp2-sme010 = gt_temp-sme010.
Gt_temp2-sme011 = gt_temp-sme011.
Gt_temp2-sme012 = gt_temp-sme012.
Gt_temp2-sme013 = gt_temp-sme013.
Gt_temp2-sme014 = gt_temp-sme014.
Gt_temp2-sme015 = gt_temp-sme015.
Gt_temp2-sme016 = gt_temp-sme016.
Collect gt_temp2.
Endloop.
* Select data for the input company code
Loop at gt_temp2.
If gt_temp2-objnr + 8 (4) not in p_bukrs.
Delete gt_temp2.
Endif.
Endloop.
* ************ Import the result of temp2 to the final internal table of gt_table to check whether the project of this row exists in gt_table. If modify exists, append is recorded.
N_point = p_monat + 2.
Loop at gt_temp2.
Assign component n_point of structure gt_temp2 to <dyn_field>.
Read Table gt_table with key bukrs = gt_temp2-objnr + 8 (4 ).
If sy-subrc = 0.
If gt_temp2-stagr = 'sd0003 '.
Move <dyn_field> to gt_table-sjgdl.
Elseif gt_temp2-stagr = 'sd0010 '.
Move <dyn_field> to gt_table-sjgdbml.
Elseif gt_temp2-stagr = 'sr0002 '.
Move <dyn_field> to gt_table-sjsrl.
Elseif gt_temp2-stagr = 'sr0003 '.
Move <dyn_field> to gt_table-sjgrbml.
Endif.
Modify gt_table index sy-tabix.
Else.
If gt_temp2-stagr = 'sd0003 '.
Move <dyn_field> to gt_table-sjgdl.
Elseif gt_temp2-stagr = 'sd0010 '.
Move <dyn_field> to gt_table-sjgdbml.
Elseif gt_temp2-stagr = 'sr0002 '.
Move <dyn_field> to gt_table-sjsrl.
Elseif gt_temp2-stagr = 'sr0003 '.
Move <dyn_field> to gt_table-sjgrbml.
Endif.
Gt_table-bukrs = gt_temp2-objnr + 8 (4 ).
Append gt_table.
Endif.
Endloop.
* Fill in the line number and company code with the Company Name Description field
Loop at gt_table.
Gt_table-xh = sy-tabix.
Select single butxt from t001 into gt_table-butxt where bukrs = gt_table-bukrs.
Modify gt_table.
Endloop.
* Import gt_faglflext to gt_table
N_point_2 = p_monat + 1.
Loop at gt_faglflext.
Assign component n_point_2 of structure gt_faglflext to <dyn_field>.
Read Table gt_table with key bukrs = gt_faglflext-rbukrs.
If sy-subrc = 0.
Move <dyn_field> to gt_table-sjrlf.
Modify gt_table index sy-tabix.
Endif.
Endloop.
* Calculated based on each formula:
Loop at gt_table.
Gt_table-sjgdmh = gt_table-sjgdbml/gt_table-sjgdl * 1000.
Gt_table-sjgrmh = gt_table-sjgrbml/gt_table-sjsrl * 1000.
Gt_table-sjbmlzj = gt_table-sjgdbml + gt_table-sjgrbml.
Gt_table-sjbmdj = gt_table-sjrlf/gt_table-sjbmlzj.
Gt_table-gdzb_gdlce = gt_table-sjgdl-gt_table-ysgdl.
Gt_table-gdzb_gdmh = gt_table-ysgdmh.
Gt_table-gdzb_gdbml = gt_table-gdzb_gdlce * gt_table-gdzb_gdmh/1000.
Gt_table-gdzb_yxrlf = gt_table-gdzb_gdbml * gt_table-ysbmdj/1000.
Gt_table-gdzb_sjgdl = gt_table-sjgdl.
Gt_table-gdzb_gdmhce = gt_table-sjgdmh-gt_table-ysgdmh.
Gt_table-gdzb_yxgdbml = gt_table-gdzb_sjgdl * gt_table-gdzb_gdmhce/1000.
Gt_table-gdzb_yxrlf2 = gt_table-ysbmdj * gt_table-gdzb_yxgdbml/1000.
Gt_table-grzb_xslce = gt_table-sjsrl-gt_table-yssrl.
Gt_table-grzb_grmh = gt_table-ysgrmh.
Gt_table-grzb_yxgrbml = gt_table-grzb_xslce * gt_table-grzb_grmh/1000.
Gt_table-grzb_yxrlf = gt_table-grzb_yxgrbml * gt_table-ysbmdj/1000.
Gt_table-grzb_sjsrl = gt_table-sjsrl.
Gt_table-grzb_grmhce = gt_table-sjgrmh-gt_table-ysgrmh.
Gt_table-grzb_grbml = gt_table-grzb_sjsrl * gt_table-grzb_grmhce/1000.
Gt_table-grzb_yxrlf2 = gt_table-grzb_grbml * gt_table-ysbmdj/1000.
Gt_table-bmdj_sjzhbml = gt_table-sjbmlzj.
Gt_table-bmdj_bmdjce = gt_table-sjbmdj-gt_table-ysbmdj.
Gt_table-bmdj_yxrlf = gt_table-bmdj_sjzhbml * gt_table-bmdj_bmdjce/1000.
Gt_table-gxyshjyx_yxrlf = gt_table-gdzb_yxrlf + gt_table-gdzb_yxrlf2 + gt_table-grzb_yxrlf + gt_table-grzb_yxrlf2 + gt_table-bmdj_yxrlf.
* Gxyshjyxcy_yxrlf
Modify gt_table.
Endloop.
Endform. "get_data