on 06-13-2013 3:26 PM
Hello,
when user changes the amount for existing charge line or during save or press the button calculate charges, badi /SCMTMS/IF_TCC_ENGINE_BADI~PROCESS_CALCULATION_SHEETS will be triggered. Regarding to Badi description it should allow to create
new charge lines automatically. I have my coding below and it doesnt work.
data MO_SM Type Ref To /BOBF/IF_TRA_SERVICE_MANAGER.
data bus_data_obj type ref to /SCMTMS/IF_TCC_BUS_DATA_ACC.
FIELD-SYMBOLS <lfs_proc_calc_sheet> like line of CT_PROC_CALC_SHEET.
FIELD-SYMBOLS <lft_charge_elem> type /SCMTMS/T_TCC_TRCHRG_ELMNT_COM.
FIELD-SYMBOLS <lft_charges> type /SCMTMS/S_TCC_DO_CHARGES_COM.
FIELD-SYMBOLS <lfs_charge_elem> type /SCMTMS/S_TCC_TRCHRG_ELMNT_COM.
bus_data_obj ?= IS_REQUEST-BUS_DATA_ACCESS.
mo_sm = /bobf/cl_tra_serv_mgr_factory=>get_service_manager( iv_bo_key = bus_data_obj->MV_BO_KEY ).
READ TABLE CT_PROC_CALC_SHEET ASSIGNING <lfs_proc_calc_sheet> index 1.
assign <lfs_proc_calc_sheet>-charges to <lft_charges>.
ASSIGN <lft_charges>-chargeelements to <lft_charge_elem>.
insert INITIAL LINE INTO <lft_charge_elem> ASSIGNING <lfs_charge_elem> INDEX 6.
READ TABLE <lft_charge_elem> into ls_charge_elem index 5.
<lfs_charge_elem> = ls_charge_elem.
<lfs_charge_elem>-node_id = mo_sm->get_new_key( ).
<lfs_charge_elem>-linenr = 5.
<lfs_charge_elem>-MY_TCE_ID = <lfs_charge_elem>-node_id.
<lfs_charge_elem>-MY_TCE_LINENR = 5.
<lfs_charge_elem>-INVOICED_AMT = 1.
<lfs_charge_elem>-AMOUNT = 1.
<lfs_charge_elem>-AMOUNTLCL = 1.
<lfs_charge_elem>-MANUAL_ENTRY = space.
<lfs_charge_elem>-MANUAL_change = space.
Regards
Beserithan Malabakan
Hi Beserithan,
Firstly, can you tell the TM version you are using? Also can you tell how many entries are you getting in it_res_calc_sheet paremeter when BADI is triggered?
Your approach of reading with "INDEX" may be a possible problem because system can have multiple responses coming back and you should make sure to add it in the right one.
You also have to be very sure about the MY_TCE_LINENR, system can't accept duplicates for this.
Thanks & Regards,
Tarun Kumar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Tarun,
thx for your response. I have only one record in it_res_calc_sheet paremeter. Index is not problem cause i have only 4 records in chargeelements table.
Coding posted by me is only for test purposes. MY_TCE_LINENR is also correct.
This is the new coding and it is not working too;-))
data MO_SM Type Ref To /BOBF/IF_TRA_SERVICE_MANAGER.
data bus_data_obj type ref to /SCMTMS/IF_TCC_BUS_DATA_ACC.
data ls_proc_calc_sheet like line of CT_PROC_CALC_SHEET.
data ls_request_key type TY_REQUEST_KEY.
data lt_key type /BOBF/T_FRW_KEY.
data ls_key type /BOBF/S_FRW_KEY.
data lt_chrg_el TYPE /scmtms/t_tcc_trchrg_element_k.
data ls_chrg_el TYPE /SCMTMS/S_TCC_TRCHRG_ELEMENT_K.
data lt_cfir_root_data type /SCMTMS/T_CFIR_ROOT_NODE_K.
data lt_root TYPE /scmtms/t_trq_root_k.
data lt_failed_key TYPE /bobf/t_frw_key.
data lt_item TYPE /scmtms/t_trq_item_k.
data lo_message TYPE REF TO /bobf/if_frw_message.
data ls_charges type /SCMTMS/S_TCC_DO_CHARGES_COM.
data lt_charge_elem type /SCMTMS/T_TCC_TRCHRG_ELMNT_COM.
data lv_lines type i.
data ls_charge_elem type /SCMTMS/S_TCC_TRCHRG_ELMNT_COM.
FIELD-SYMBOLS <lfs_proc_calc_sheet> like line of CT_PROC_CALC_SHEET.
FIELD-SYMBOLS <lft_charge_elem> type /SCMTMS/T_TCC_TRCHRG_ELMNT_COM.
FIELD-SYMBOLS <lft_charges> type /SCMTMS/S_TCC_DO_CHARGES_COM.
FIELD-SYMBOLS <lfs_charge_elem> type /SCMTMS/S_TCC_TRCHRG_ELMNT_COM.
FIELD-SYMBOLS <lfs_ratedetails_tab> type /SCMTMS/T_TCC_PRICERATEDTL_COM.
FIELD-SYMBOLS <lfs_ratedetails> type /SCMTMS/S_TCC_PRICERATEDTL_COM.
FIELD-SYMBOLS <lfs_amount_tab> type /SCMTMS/T_TCC_AMT_W_ROLE_COM.
FIELD-SYMBOLS <lfs_amount> type /SCMTMS/S_TCC_AMT_W_ROLE_COM.
data lo_tra TYPE REF TO /bobf/if_tra_transaction_mgr.
data lv_rejected TYPE abap_bool.
data lo_chg TYPE REF TO /bobf/if_tra_change.
data lt_rej_bo_key TYPE /bobf/t_frw_key2.
bus_data_obj ?= IS_REQUEST-BUS_DATA_ACCESS.
mo_sm = /bobf/cl_tra_serv_mgr_factory=>get_service_manager( iv_bo_key = bus_data_obj->MV_BO_KEY ).
READ TABLE CT_PROC_CALC_SHEET ASSIGNING <lfs_proc_calc_sheet> index 1.
assign <lfs_proc_calc_sheet>-charges to <lft_charges>.
ASSIGN <lft_charges>-chargeelements to <lft_charge_elem>.
DESCRIBE TABLE <lft_charge_elem> lines lv_lines.
READ TABLE <lft_charge_elem> into ls_charge_elem index lv_lines.
add 1 to lv_lines.
insert INITIAL LINE INTO <lft_charge_elem> ASSIGNING <lfs_charge_elem> INDEX lv_lines.
SUBTRACT 1 from lv_lines.
<lfs_charge_elem> = ls_charge_elem.
<lfs_charge_elem>-node_id = mo_sm->get_new_key( ).
<lfs_charge_elem>-linenr = lv_lines.
<lfs_charge_elem>-MY_TCE_ID = <lfs_charge_elem>-node_id.
<lfs_charge_elem>-MY_TCE_LINENR = lv_lines.
<lfs_charge_elem>-INVOICED_AMT = '0.000100'.
<lfs_charge_elem>-AMOUNT = '0.000100'.
<lfs_charge_elem>-AMOUNTLCL = '0.000100'.
* <lfs_charge_elem>-MANUAL_ENTRY = space.
* <lfs_charge_elem>-MANUAL_change = space.
ASSIGN <lfs_charge_elem>-ratedetails to <lfs_ratedetails_tab>.
READ TABLE <lfs_ratedetails_tab> ASSIGNING <lfs_ratedetails> index 1.
<lfs_ratedetails>-node_id = mo_sm->get_new_key( ).
ASSIGN <lfs_charge_elem>-AMOUNTS to <lfs_amount_tab>.
loop at <lfs_amount_tab> ASSIGNING <lfs_amount>.
if sy-tabix > 4.
exit.
endif.
<lfs_amount>-node_id = mo_sm->get_new_key( ).
endloop.
READ TABLE <lft_charge_elem> ASSIGNING <lfs_charge_elem> with key TCCALCRESINS040 = 'SUM'.
add '0.000100' to <lfs_charge_elem>-AMOUNT.
<lfs_charge_elem>-AMOUNTLCL = <lfs_charge_elem>-AMOUNT.
<lfs_charge_elem>-INVOICED_AMT = <lfs_charge_elem>-AMOUNT.
clear <lfs_amount_tab>.
ASSIGN <lfs_charge_elem>-AMOUNTS to <lfs_amount_tab>.
READ TABLE <lfs_amount_tab> ASSIGNING <lfs_amount> index lv_lines.
<lfs_amount>-node_id = mo_sm->get_new_key( ).
loop at <lfs_amount_tab> ASSIGNING <lfs_amount>.
<lfs_amount>-amount = <lfs_charge_elem>-AMOUNT.
endloop.
Regards
Beserithan Malabakan
User | Count |
---|---|
8 | |
4 | |
3 | |
2 | |
2 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.