Last post, we learn the amazing of access CHATGPT for SAP ABAP develop of a SQL demo.
Chatgpt will code ABAP source quickly. Today we learn BADI:ADDRESS_UPDATE to check CRM field communication address.
Purpose:
对于角色为服务商的员工在保存时,如果状态变为“启用中”,则需要检查通讯方式中的数据是否填写了。如果检查到没有填写,则不能保存。
When to trigger:
创建或者修改CRM服务商员工主数据上的“通讯数据”
保存CRM员工主数据时触发
How to do enhancement
T-code: SE19
BADI:ADDRESS_UPDATE
实施:ZSV_ADDRESS_UPDATE
实施类:ZCL_IM_SV_ADDRESS_UPDATE
方法:ADDRESS2_SAVEDT
示例代码Sample Code
METHOD if_ex_address_update~address2_saved.
*———————————————————————————–*
*”———————————————————————————-*
* 增强:服务商主数据必输校验
*”———————————————————————————-*
*———————————————————————————–*
DATA: lt_but000_new TYPE STANDARD TABLE OF but000,
lr_but000_new TYPE but000.
DATA: lt_but000_old TYPE STANDARD TABLE OF but000,
lr_but000_old TYPE but000.
* new address
DATA: lr_adrc TYPE LINE OF adrc_tab.
DATA: lr_adr2 TYPE LINE OF adr2_tab.
DATA: lr_adr3 TYPE LINE OF adr3_tab.
DATA: lv_country TYPE ad_county.
DATA: lv_street TYPE ad_street.
DATA: lv_post_code1 TYPE ad_pstcd1.
DATA: lv_city1 TYPE ad_city1.
DATA: lv_region TYPE regio.
DATA: lv_tel_phone TYPE ad_tlnmbr.
DATA: lv_mobile_phone TYPE ad_tlnmbr.
DATA: lv_fax_number TYPE ad_fxnmbr.
*定义参考的消息类
DATA: l_result TYPE int4,
lr_core TYPE REF TO cl_crm_bol_core,
lr_message_service TYPE REF TO cl_bsp_wd_message_service,
lr_global_messages TYPE REF TO cl_crm_genil_global_mess_cont.
lr_core = cl_crm_bol_core=>get_instance( ).
lr_global_messages = lr_core->get_global_message_cont( ).
CLEAR: lv_country,lv_street,lv_post_code1,lv_city1,lv_region,lv_tel_phone,lv_mobile_phone,lv_fax_number.
CLEAR:lt_but000_new,lr_but000_new,lt_but000_old,lr_but000_old.
* fetch 基本信息
CALL FUNCTION ‘BUPA_GENERAL_CALLBACK’ “从缓存中读取基本数据WWW.HOT583.COM
TABLES
et_but000_new = lt_but000_new
et_but000_old = lt_but000_old.
* check 服务商 BU_group = Z008 zzfwzt = 7 * 启用中 = 7
READ TABLE lt_but000_new INTO lr_but000_new WITH KEY bu_group = zcl_common_object=>bu_group_z010.” ‘Z008’
IF sy–subrc EQ 0.
IF lr_but000_new–zzfwzt EQ zcl_common_object=>empl_enable_status. ” 启用中 = 7WWW.HOT583.COM
* address
*———————————————————————————-
READ TABLE im_t_xadrc INTO lr_adrc INDEX 1.
IF sy–subrc EQ 0.
lv_country = lr_adrc–country.
lv_city1 = lr_adrc–city1.
lv_post_code1 = lr_adrc–post_code1.
lv_street = lr_adrc–street.
lv_region = lr_adrc–region.
ENDIF.
* communication address
*———————————————————————————–
LOOP AT im_t_xadr2 INTO lr_adr2 WHERE r3_user EQ ‘1’.” 固话
lv_tel_phone = lr_adr2–tel_number.
ENDLOOP.
LOOP AT im_t_xadr2 INTO lr_adr2 WHERE r3_user EQ ‘3’ OR r3_user EQ ‘2’.
lv_mobile_phone = lr_adr2–tel_number.
ENDLOOP.
READ TABLE im_t_xadr3 INTO lr_adr3 INDEX 1.
IF sy–subrc EQ 0.
lv_fax_number = lr_adr3–fax_number.
ENDIF.
* return message
*————————————————————————————
* 国家
IF lv_country EQ ”.
lr_global_messages->add_message( iv_msg_type = ‘E’
iv_msg_id = ‘ZCRM_MSG’
iv_msg_number = ‘057’
iv_show_only_once = abap_true ).
ENDIF.
* 区域
IF lv_region EQ ”.
lr_global_messages->add_message( iv_msg_type = ‘E’
iv_msg_id = ‘ZCRM_MSG’
iv_msg_number = ‘058’
iv_show_only_once = abap_true ).
ENDIF.
* 城市
IF lv_city1 EQ ”.
lr_global_messages->add_message( iv_msg_type = ‘E’
iv_msg_id = ‘ZCRM_MSG’
iv_msg_number = ‘059’
iv_show_only_once = abap_true ).
ENDIF.
* 街道
IF lv_street EQ ”.
lr_global_messages->add_message( iv_msg_type = ‘E’
iv_msg_id = ‘ZCRM_MSG’
iv_msg_number = ‘060’
iv_show_only_once = abap_true ).
ENDIF.
* 邮政
IF lv_post_code1 EQ ”.
lr_global_messages->add_message( iv_msg_type = ‘E’
iv_msg_id = ‘ZCRM_MSG’
iv_msg_number = ‘061’
iv_show_only_once = abap_true ).
ENDIF.
* 电话号码
IF lv_tel_phone EQ ” OR lv_mobile_phone EQ ”.
lr_global_messages->add_message( iv_msg_type = ‘E’
iv_msg_id = ‘ZCRM_MSG’
iv_msg_number = ‘062’
iv_show_only_once = abap_true ).
ENDIF.
* 传真
IF lv_fax_number EQ ”.
lr_global_messages->add_message( iv_msg_type = ‘E’ “WWW.HOT583.COM
iv_msg_id = ‘ZCRM_MSG’
iv_msg_number = ‘063’
iv_show_only_once = abap_true ).
ENDIF.
ENDIF.
ENDIF.
ENDMETHOD.
我的微信公众号【 hot583 】 或者在这个链接联系我
本文为作者原创,如果这篇文章对您有用,欢迎转载,
转载请务必注明来源《今日热点在看》http://www.hot583.com/
微信原文《全文完》