Using BAdI BNK BADI FILE ERROR ALRT EN V 1.0
Using BAdI BNK BADI FILE ERROR ALRT EN V 1.0
You want to use alerting mechanism in Bank Communication Management with BAdI
BNK_BADI_FILE_ERROR_ALRT. In this document is described how to define additional fields to be
included into generated e-mail.
- From menu choose option Edit → Enhancement Operations → Show Implicit Enhancement
Options
- Select the very first implicit enhancement at the beginning of method
IF_EX_BNK_FILE_ALRT~CREATE_ALERT and click on button Create Enhancement
Implementation ... (Ctrl+Shift+F8)
- Use package valid for your local transports in layer HOME, which could be transported within
your landscape, in our example we are using local package $TMP, as we are not going to
transport Customer BAdI Enhancement. Press Save button (Enter)
- Type in code RETURN. and activate your changes by pressing button Activate Enhancements
(Ctrl+F3)
- SAP default implementation in BAdI BNK_BADI_FILE_ERROR_ALERT will not be executed
Customer BAdI Implantation BNK_BADI_FILE_ERROR_ALRT
- Use the same package as before, in our example local package $TMP
- Press Save button (Enter)
Implementing Class
Now you have the Customer BAdI implementation and you can create the class to enable processing
of pain.002.001.02 in CPON Service incoming files
- Double-click in button Implementing Class
METHOD if_ex_bnk_file_alrt~create_alert.
* "nte1389302 Populate Container for File Error
CONSTANTS: con_file_cr_error TYPE j_vorgang VALUE 'BFE'.
DATA: l_alert_id TYPE salrtextid,
li_container TYPE REF TO if_swf_cnt_container,
l_str_pay_alrt TYPE bnk_str_pay_stat,
l_laufd TYPE laufd, "nte1389302
l_laufi TYPE laufi,
l_srtf3 TYPE srtf1_fpm,
l_str_reguhm TYPE reguhm,
l_rest(28).
SELECT SINGLE *
FROM bnk_batch_header
INTO l_str_bnk_batch_header
WHERE batch_no EQ i_batch_no. "#EC CI_NOFIELD
IF sy-subrc EQ 0.
MOVE-CORRESPONDING l_str_bnk_batch_header TO l_str_pay_alrt.
ASSIGN COMPONENT:
con_field_paym_sum OF STRUCTURE l_str_pay_alrt TO <fs_paym_sum>,
con_field_maxpayamt OF STRUCTURE l_str_pay_alrt TO <fs_maxpayamt>,
con_field_item_cnt OF STRUCTURE l_str_pay_alrt TO <fs_item_cnt>,
con_field_paym_curr OF STRUCTURE l_str_pay_alrt TO <fs_paym_curr>.
SELECT *
FROM bnk_batch_item
INTO l_str_bnk_batch_item
WHERE batch_no EQ i_batch_no.
* Number of Payments
IF <fs_item_cnt> IS ASSIGNED.
ADD 1 TO <fs_item_cnt>.
ENDIF.
ENDSELECT.
FIELD-SYMBOLS:
<fs_spool> TYPE any.
FREE: l_tab_list_str.
l_rqident = l_str_tbtcp-listident.
CALL FUNCTION 'RSPO_RETURN_SPOOLJOB_DAT'
EXPORTING
rqident = l_rqident
IMPORTING
buffer_dat = l_tab_list_str[]
EXCEPTIONS
no_such_job = 1
not_abap_list = 2
job_contains_no_data = 3
selection_empty = 4
no_permission = 5
can_not_access = 6
read_error = 7
OTHERS = 8.
IF sy-subrc EQ 0.
LOOP AT l_tab_list_str INTO l_line_string.
IF l_index EQ 99.
* Only first 99 lines are displayed
EXIT.
ENDIF.
ADD 1 TO l_index.
CONCATENATE con_field_spool l_index INTO l_field_name.
l_str_pay_alrt-batch_no = i_batch_no.
l_str_pay_alrt-zbukr = l_str_reguhm-zbukr.
l_str_pay_alrt-hbkid = l_str_reguhm-hbkid.
l_str_pay_alrt-sys_stat = con_file_cr_error.
* Rule Id "nte1389302
IF l_str_reguhm-laufi+5(1) = 'B'.
l_laufi = l_str_reguhm-laufi.
l_laufd = l_str_reguhm-laufd.
ELSE.
l_laufi = l_str_reguhm-laufi_m.
l_laufd = l_str_reguhm-laufd_m.
ENDIF.
SELECT SINGLE srtf3 FROM reguh INTO l_srtf3
WHERE laufd = l_laufd
AND laufi = l_laufi
AND xvorl = space
AND zbukr = l_str_reguhm-zbukr
AND lifnr = l_str_reguhm-lifnr
AND kunnr = l_str_reguhm-kunnr
AND empfg = l_str_reguhm-empfg
AND vblnr = l_str_reguhm-vblnr.
IF l_srtf3 CS cl_bnk_constants=>con_seperator.
SPLIT l_srtf3 AT cl_bnk_constants=>con_seperator INTO
l_str_pay_alrt-rule_id l_rest.
ELSE.
l_str_pay_alrt-rule_id = l_srtf3.
ENDIF.
TRY.
li_container->element_set(
name = 'BNK_STR_PAY_STAT'
value = l_str_pay_alrt ).
CATCH cx_swf_cnt_cont_access_denied
cx_swf_cnt_elem_not_found
cx_swf_cnt_elem_access_denied
cx_swf_cnt_elem_type_conflict
cx_swf_cnt_unit_type_conflict
cx_swf_cnt_elem_def_invalid
cx_swf_cnt_invalid_qname
cx_swf_cnt_container .
c_alert_rc = 99.
ENDTRY.
c_alert_rc = sy-subrc.
c_alert_id = l_alert_id.
ENDMETHOD.
- Activate all objects related to the Customer BAdI Implementation
- Press button Activate (Ctrl+F3)
At this moment you should be able to influence alerting mechanism in case of status Payment
Medium Creation Error. To be sure navigate back to Customer BAdI Implementation:
- You can see, that the Implementation is Active and will be called
(Optional) Disabling the feature
If you want to disable this feature, please, in change mode uncheck the option "Implementation is
active" and activate the Customer BAdI Implementation, please keep in mind, that with implicit
enhancement in class CL_BNK_BADI_FIL_ERR_ALRT_IMPL, nothing might be called:
- Start transaction SE11, select radio button next to Data type and field BNK_STR_PAY_STAT
- Press button Display (F7)
- For adding values from spool list, we will add Built-In Types fields
- You can add fields from SPOOL_LN01 to SPOOL_LN99
Once new BAdI implementation is active, we need to append new fields to the structure
BNK_STR_PAY_STAT.
- With detail
- Short Text
Bank file Alert Company &BNK_STR_PAY_STAT.ZBUKR& Bank &BNK_STR_PAY_STAT.HBKID& Doc
&BNK_STR_PAY_STAT.GRP_FIELD1_VALUE&
- Long Text
Error in Payment Bank File with following Details:
Company &BNK_STR_PAY_STAT.ZBUKR&
House bank &BNK_STR_PAY_STAT.HBKID&
Batch Number &BNK_STR_PAY_STAT.BATCH_NO&
----------------------------------------------------------------------
Amount Paid &BNK_STR_PAY_STAT.PAYM_SUM& &BNK_STR_PAY_STAT.PAYM_CURR&
Maximum &BNK_STR_PAY_STAT.MAXPAYAMT_RULECU&
&BNK_STR_PAY_STAT.PAYM_CURR&
Payment Items &BNK_STR_PAY_STAT.ITEM_CNT&
----------------------------------------------------------------------
Create User &BNK_STR_PAY_STAT.CRUSR&
Change Date &BNK_STR_PAY_STAT.CHDATE&
KZ Payment DOC &BNK_STR_PAY_STAT.GRP_FIELD1_VALUE&
----------------------------------------------------------------------
Message & Message Text
&BNK_STR_PAY_STAT.SPOOL_LN01&
&BNK_STR_PAY_STAT.SPOOL_LN02&
&BNK_STR_PAY_STAT.SPOOL_LN03&
- Save your changes by pressing button Save (Ctrl+S)