Table Used:
COST - CO Object: Price Totals
CSSL - Cost Center/Activity Type
Tcode Used:
OKKS - set Controlling Area.
KBK6 - Cost Center Manual Actual Price Change
* DESCRIPTION : Post Actual Activity by period and Year Wise in KBK6 Tcode.
************************************************************************
report zco_actual_activity_rates.
types: begin of gty_error,
row type i,
ind type char2,
mes type string,
end of gty_error.
data:lt_cost type table of cost,
ls_cost type cost,
lt_cssl type table of cssl,
ls_cssl type cssl.
data: l_mstring(480).
data: bdcdata like bdcdata occurs 0 with header line.
data: messtab like bdcmsgcoll occurs 0 with header line.
data: gs_error type gty_error,
gt_error type standard table of gty_error.
data : gv_row type i.
*----------------------------------------------------------------------*
* Selection Screen *
*----------------------------------------------------------------------*
selection-screen : begin of block b1 with frame title text-001.
parameters : p_period type perbl obligatory,
p_year type cost-gjahr obligatory,
p_cost TYPE cssl-kostl.
selection-screen : end of block b1.
*----------------------------------------------------------------------*
start-of-selection.
**********To Get CO Object: Price Totals
case p_period.
when '001'.
select * from cost into table lt_cost where gjahr eq p_year and tarkz eq '005' and tkg001 eq '0'. "#EC CI_NOFIRST
if sy-subrc = 0.
sort lt_cost .
endif.
when '002'.
select * from cost into table lt_cost where gjahr eq p_year and tarkz eq '005' and tkg002 eq '0'. "#EC CI_NOFIRST
if sy-subrc = 0.
sort lt_cost .
endif.
when '003'.
select * from cost into table lt_cost where gjahr eq p_year and tarkz eq '005' and tkg003 eq '0'. "#EC CI_NOFIRST
if sy-subrc = 0.
sort lt_cost .
endif.
when '004'.
select * from cost into table lt_cost where gjahr eq p_year and tarkz eq '005' and tkg004 eq '0'. "#EC CI_NOFIRST
if sy-subrc = 0.
sort lt_cost .
endif.
when '005'.
select * from cost into table lt_cost where gjahr eq p_year and tarkz eq '005' and tkg005 eq '0'. "#EC CI_NOFIRST
if sy-subrc = 0.
sort lt_cost .
endif.
when '006'.
select * from cost into table lt_cost where gjahr eq p_year and tarkz eq '005' and tkg006 eq '0'. "#EC CI_NOFIRST
if sy-subrc = 0.
sort lt_cost .
endif.
when '007'.
select * from cost into table lt_cost where gjahr eq p_year and tarkz eq '005' and tkg007 eq '0'. "#EC CI_NOFIRST
if sy-subrc = 0.
sort lt_cost .
endif.
when '008'.
select * from cost into table lt_cost where gjahr eq p_year and tarkz eq '005' and tkg008 eq '0'. "#EC CI_NOFIRST
if sy-subrc = 0.
sort lt_cost .
endif.
when '009'.
select * from cost into table lt_cost where gjahr eq p_year and tarkz eq '005' and tkg009 eq '0'. "#EC CI_NOFIRST
if sy-subrc = 0.
sort lt_cost .
endif.
when '010'.
select * from cost into table lt_cost where gjahr eq p_year and tarkz eq '005' and tkg010 eq '0'. "#EC CI_NOFIRST
if sy-subrc = 0.
sort lt_cost .
endif.
when '011'.
select * from cost into table lt_cost where gjahr eq p_year and tarkz eq '005' and tkg011 eq '0'. "#EC CI_NOFIRST
if sy-subrc = 0.
sort lt_cost .
endif.
when '012'.
select * from cost into table lt_cost where gjahr eq p_year and tarkz eq '005' and tkg012 eq '0'. "#EC CI_NOFIRST
if sy-subrc = 0.
sort lt_cost .
endif.
endcase.
if lt_cost is not initial.
************ to Get all Cost Center/Activity Type
select * from cssl into table lt_cssl for all entries in lt_cost where objnr = lt_cost-objnr and gjahr eq p_year.
if sy-subrc = 0.
sort lt_cssl.
endif.
if p_cost IS NOT INITIAL .
DELETE lt_cssl where kostl ne p_cost.
endif.
* endif.
**BREAK-POINT.
* if lt_cssl is not initial .
loop at lt_cssl into ls_cssl.
* if lv_sno eq 1.
perform bdc_dynpro using 'SAPLSPO4' '0300'.
perform bdc_field using 'BDC_CURSOR'
'SVALD-VALUE(01)'.
perform bdc_field using 'BDC_OKCODE'
'=FURT'.
perform bdc_field using 'SVALD-VALUE(01)'
ls_cssl-kokrs." '1000'.
perform bdc_transaction using 'OKKS'.
* perform bdc_dynpro using 'SAPLSPO4' '0300'.
* perform bdc_field using 'BDC_CURSOR'
* 'SVALD-VALUE(01)'.
* perform bdc_field using 'BDC_OKCODE'
* '=FURT'.
* perform bdc_field using 'SVALD-VALUE(01)'
* ls_cssl-kokrs."'ctml'.
* endif.
perform bdc_dynpro using 'SAPLKPP0' '1000'.
perform bdc_field using 'BDC_CURSOR'
'KPP0B-VALUE(08)'.
perform bdc_field using 'BDC_OKCODE'
'=CSPB'.
perform bdc_field using 'KPP1B-ONLY'
'X'.
perform bdc_field using 'KPP0B-VALUE(01)'
p_period."'1'. "Period
perform bdc_field using 'KPP0B-VALUE(02)'
p_period."'1'. "Period
perform bdc_field using 'KPP0B-VALUE(03)'
p_year."'2017'. "Year
perform bdc_field using 'KPP0B-VALUE(05)'
ls_cssl-kostl."'ASNAIN10'.""CostCenter
perform bdc_field using 'KPP0B-VALUE(07)'
''. "Cost Group
perform bdc_field using 'KPP0B-VALUE(08)'
ls_cssl-lstar."'1001'."Activity Type
perform bdc_field using 'KPP0B-VALUE(10)'
''. "Activity Group.
perform bdc_dynpro using 'SAPLKPP2' '0110'.
perform bdc_field using 'BDC_CURSOR'
'Z-BDC06(01)'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'Z-BDC03(01)'
'0.01'.
perform bdc_field using 'Z-BDC06(01)'
' 10000'.
perform bdc_dynpro using 'SAPLKPP2' '0110'.
perform bdc_field using 'BDC_CURSOR'
'Z-BDC06(01)'.
perform bdc_field using 'BDC_OKCODE'
'=CBUC'.
perform bdc_transaction using 'KBK6'.
clear:ls_cssl.
endloop.
else.
message text-003 type 'S'.
endif.
end-of-selection.
if gt_error is not initial.
perform display.
endif.
refresh:messtab,bdcdata,gt_error.
clear:p_year,p_period.
form bdc_transaction using tcode.
data : ls_ctu type ctu_params.
ls_ctu-dismode = 'N'.
ls_ctu-updmode = 'S'.
ls_ctu-defsize = 'X'.
clear : messtab[].
if tcode eq 'OKKS'.
call transaction tcode using bdcdata
options from ls_ctu
messages into messtab.
else.
call transaction tcode using bdcdata
options from ls_ctu
messages into messtab.
commit work.
gv_row = gv_row + 1.
if messtab[] is not initial.
loop at messtab.
message id messtab-msgid
type messtab-msgtyp
number messtab-msgnr
into l_mstring
with messtab-msgv1
messtab-msgv2
messtab-msgv3
messtab-msgv4.
gs_error-row = gv_row.
gs_error-ind = messtab-msgtyp.
gs_error-mes = l_mstring.
append gs_error to gt_error.
endloop.
else.
gs_error-row = gv_row.
gs_error-ind = 'S'.
gs_error-mes = 'Successfuly Posted'.
append gs_error to gt_error.
endif.
endif.
clear : bdcdata, bdcdata[].
endform. " BDC_TRANSACTION
*&---------------------------------------------------------------------*
*& Form DISPLAY
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form display .
data : lo_alv type ref to cl_salv_table,
lo_functions type ref to cl_salv_functions,
lo_columns type ref to cl_salv_columns_table,
lo_column type ref to cl_salv_column_table.
try.
call method cl_salv_table=>factory
importing
r_salv_table = lo_alv
changing
t_table = gt_error.
catch cx_salv_msg.
endtry.
lo_functions = lo_alv->get_functions( ).
lo_functions->set_all( abap_true ).
call method lo_alv->get_columns
receiving
value = lo_columns.
*to change the name of the column in ALV.
try.
lo_column ?= lo_columns->get_column( 'ROW' ).
catch cx_salv_not_found.
endtry.
lo_column->set_long_text( 'Row ID' ).
lo_column->set_medium_text( 'Row ID' ).
lo_column->set_short_text( 'Row ID' ).
try.
lo_column ?= lo_columns->get_column( 'IND' ).
catch cx_salv_not_found.
endtry.
lo_column->set_long_text( 'Indicator' ).
lo_column->set_medium_text( 'Indicator' ).
lo_column->set_short_text( 'Indicator' ).
try.
lo_column ?= lo_columns->get_column( 'MES' ).
catch cx_salv_not_found.
endtry.
lo_column->set_long_text( 'Message' ).
lo_column->set_medium_text( 'Message' ).
lo_column->set_short_text( 'Message' ).
call method lo_alv->display.
endform.
*----------------------------------------------------------------------*
* Start new screen *
**----------------------------------------------------------------------*
form bdc_dynpro using program dynpro.
clear bdcdata.
bdcdata-program = program.
bdcdata-dynpro = dynpro.
bdcdata-dynbegin = 'X'.
append bdcdata.
endform.
*----------------------------------------------------------------------*
* Insert field *
*----------------------------------------------------------------------*
form bdc_field using fnam fval.
* IF FVAL <> NODATA.
clear bdcdata.
bdcdata-fnam = fnam.
bdcdata-fval = fval.
append bdcdata.
* ENDIF.
endform.
No comments:
Post a Comment