on ‎2018 Jul 22 11:07 AM
Dear Expert.
I have issue when implementing BAdI UJJ_CALCULATE_AMOUNT. Error occur when I save journal with some field is blank.

After that, I Trace checking condition for BAdI. I found Error have been raise in Class CL_UJJ_JRN_MGR method CHECK_CALCULATED_AMOUNTS in this line:

Intuitively I tried to make sure output of BAdI doesn't have empty dimension. so I change every dimension with value is blank to '#'. After I change all of it, journal can be saved. however, new problem is appeared when journal is post.

right now, I doesn't have any idea why this happen.
this is my BAdI code :
method IF_UJJ_CALCULATED_AMOUNT~CALCULATE_AMOUNTS.
constants:
dim_acct type uj_dim_name value 'ZGRPACCNO',
dim_flow type uj_dim_name value 'ZFLOW',
closing_flow type uj_dim_name value 'F_999',
increase_flow type uj_dim_name value 'F_410',
decrease_flow type uj_dim_name value 'F_420',
net_income_cy_acct type uj_dim_name value '0035000004',
re_up_acct type uj_dim_name value '0035000003'.
data:
ls_journal_amounts type ujj_s_badi_ca_journal_amounts,
ls_journal_amounts2 type ujj_s_badi_ca_journal_amounts,
l_dim_member type uj_dim_member,
l_is_leaf_of_1 type abap_bool,
l_tabkey type tabkey,
l_is_leaf_of_2 type abap_bool,
l_is_leaf_of_f_tot type abap_bool,
l_acct_property type uj_value,
ls_amount_details type ujj_s_badi_ca_amount,
ls_amount type ujj_s_badi_ca_amount,
ls_amount2 type ujj_s_badi_ca_amount,
lo_exception type ref to cx_root,
lo_static_check type ref to cx_static_check,
l_acct_value type uj_value,
l_flow_value type uj_value,
l_flow_is_available type abap_bool,
l_acct_is_available type abap_bool,
member_temp type ujj_s_keymem.
field-symbols:
<fs_member> type ujj_s_keymem,
<fs_member_flow> type ujj_s_keymem,
<fs_member_acct> type ujj_s_keymem,
<fs_member_value> type uj_value,
<fs_amount> type ujj_s_badi_ca_amount,
<fs_jrn> type ujj_s_badi_ca_journal.
* forever loop debug
* data flag_debug type abap_bool VALUE abap_true.
* WHILE flag_debug = abap_true.
* ENDWHILE.
try.
* loop through all journals
loop at it_journals assigning <fs_jrn>.
clear ls_journal_amounts.
ls_journal_amounts-journal_id = <fs_jrn>-jrn_id.
* loop every line of journal
loop at <fs_jrn>-amounts assigning <fs_amount>.
* get GL account
l_tabkey = dim_acct.
read table <fs_amount>-members assigning <fs_member> with key tabkey = l_tabkey.
if sy-subrc EQ 0.
l_acct_value = <fs_member>-member.
endif.
* get Flow
l_tabkey = dim_flow.
read table <fs_amount>-members assigning <fs_member> with key tabkey = l_tabkey.
if sy-subrc EQ 0.
l_flow_value = <fs_member>-member.
endif.
ls_amount = <fs_amount>.
clear ls_amount-members.
loop at <fs_amount>-members assigning <fs_member>.
if <fs_member>-is_hdr_fld eq abap_false.
MOVE-CORRESPONDING <fs_member> TO member_temp.
IF member_temp-member = ''.
member_temp-member = '#'.
ENDIF.
append member_temp to ls_amount-members.
endif.
endloop.
* get field symbol of GL account
l_tabkey = dim_acct.
read table ls_amount-members assigning <fs_member_acct> with key tabkey = l_tabkey.
if sy-subrc EQ 0.
l_acct_is_available = abap_true.
endif.
* get field symbol of Flow
l_tabkey = dim_flow.
read table ls_amount-members assigning <fs_member_flow> with key tabkey = l_tabkey.
if sy-subrc EQ 0.
l_flow_is_available = abap_true.
endif.
* check if both member flow and account is present
if l_flow_is_available EQ abap_true and l_acct_is_available EQ abap_true.
* if Group Account is Balance Sheet
if l_acct_value >= '0010000000' and l_acct_value <= '0039999999'.
* create closing balance
if l_flow_value <> closing_flow.
<fs_member_flow>-member = closing_flow.
append ls_amount to ls_journal_amounts-amounts.
endif.
* if Group Account is Profit and Lost
elseif l_acct_value >= '0040000000' and l_acct_value <= '0089999999'.
* copy "profit and lost" data to profit and lost current year with flow is F_300
<fs_member_flow>-member = 'F_300'.
<fs_member_acct>-member = net_income_cy_acct.
append ls_amount to ls_journal_amounts-amounts.
* copy "profit and lost" data to profit and lost current year with flow is closing
<fs_member_flow>-member = closing_flow.
<fs_member_acct>-member = net_income_cy_acct.
append ls_amount to ls_journal_amounts-amounts.
elseif l_acct_value >= '0090000000' and l_acct_value <= '0099999999'.
if l_acct_value = '0091100001'.
<fs_member_flow>-member = 'F_308'.
<fs_member_acct>-member = '0034000001'.
append ls_amount to ls_journal_amounts-amounts.
<fs_member_flow>-member = closing_flow.
append ls_amount to ls_journal_amounts-amounts.
elseif l_acct_value = '0091100002'.
<fs_member_flow>-member = 'F_309'.
<fs_member_acct>-member = '0034000002'.
append ls_amount to ls_journal_amounts-amounts.
<fs_member_flow>-member = closing_flow.
append ls_amount to ls_journal_amounts-amounts.
elseif l_acct_value = '0091100003'.
<fs_member_flow>-member = 'F_315'.
<fs_member_acct>-member = '0034000006'.
append ls_amount to ls_journal_amounts-amounts.
<fs_member_flow>-member = closing_flow.
append ls_amount to ls_journal_amounts-amounts.
elseif l_acct_value = '0091100004'.
<fs_member_flow>-member = 'F_314'.
<fs_member_acct>-member = '0034000005'.
append ls_amount to ls_journal_amounts-amounts.
<fs_member_flow>-member = closing_flow.
append ls_amount to ls_journal_amounts-amounts.
elseif l_acct_value = '0091199998'.
<fs_member_flow>-member = 'F_310'.
<fs_member_acct>-member = '0034000004'.
append ls_amount to ls_journal_amounts-amounts.
<fs_member_flow>-member = closing_flow.
append ls_amount to ls_journal_amounts-amounts.
elseif l_acct_value = '0091105001'.
<fs_member_flow>-member = 'F_318'.
<fs_member_acct>-member = '0034100001'.
append ls_amount to ls_journal_amounts-amounts.
<fs_member_flow>-member = closing_flow.
append ls_amount to ls_journal_amounts-amounts.
elseif l_acct_value = '0091105002'.
<fs_member_flow>-member = 'F_317'.
<fs_member_acct>-member = '0034100002'.
append ls_amount to ls_journal_amounts-amounts.
<fs_member_flow>-member = closing_flow.
append ls_amount to ls_journal_amounts-amounts.
elseif l_acct_value = '0091200001'.
<fs_member_flow>-member = 'F_316'.
<fs_member_acct>-member = '0034000007'.
append ls_amount to ls_journal_amounts-amounts.
<fs_member_flow>-member = closing_flow.
append ls_amount to ls_journal_amounts-amounts.
endif.
endif.
endif.
endloop.
if lines( ls_journal_amounts-amounts ) > 0.
append ls_journal_amounts to et_calculated_amounts.
endif.
endloop.
catch cx_root into lo_exception.
raise exception type cx_ujj_exception
exporting
previous = lo_exception
textid = cx_ujj_exception=>ex_badi_exception.
endtry.
endmethod.
note:
this is my system specification:
SAP NETWEAVER 7.5

Kind Regard,
Chandra .M.P
Request clarification before answering.
Asking question about badi and nor providing badi code? Strange approach!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 15 | |
| 11 | |
| 11 | |
| 4 | |
| 2 | |
| 2 | |
| 2 | |
| 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.