TYPES:BEGIN OF lty_users,
uname TYPE xubname,END OF lty_users,
BEGIN OF lty_tusers,
agr_name TYPE agr_name,
uname TYPE xubname,
END OF lty_tusers,
BEGIN OF lty_reject_note,
usmd_ncreated_at TYPE timestamp,
usmd_note TYPE usmd_note,
END OF lty_reject_note,
BEGIN OF lty_mdg_emails,
notif_email TYPE znotif_email,
pers_notif TYPE znotif_flag,
END OF lty_mdg_emails,
BEGIN OF ty_url,
line(132) TYPE c,
END OF ty_url.
* Type declaration
TYPES : BEGIN OF lty_bp,
bp_header TYPE bu_businesspartner,
END OF lty_bp.
TYPES : BEGIN OF ty_mdgsmart,
mandt TYPE mandt,
ktopl TYPE ktopl,
usmdz1_account TYPE usmdz1_account,
zdestination TYPE char10,
zvalid_from TYPE datum,
zvalid_to TYPE datum,
usmd_edition_number TYPE usmd_edition_number,
usmd_active TYPE usmd_active,
usmd_obsolete TYPE usmd_obsolete,
zsmart_acccount TYPE char10,
END OF ty_mdgsmart.
DATA: ls_user_data TYPE bapiaddr3,
lt_return TYPE bapirettab,
lt_return1 TYPE TABLE OF bapiret2,
lv_mail_address TYPE string,
lo_send_request TYPE REF TO cl_bcs,
lo_sender TYPE REF TO cl_sapuser_bcs,
lo_recipient TYPE REF TO if_recipient_bcs,
ls_address TYPE bapiaddr3,
ls_address1 TYPE bapiaddr3,
lv_sender TYPE adr6-smtp_addr,
lv_recipient TYPE ad_smtpadr,
gv_subject TYPE char50,
ls_data TYPE tline,
lt_body TYPE bcsy_text,
ls_body TYPE soli,
lo_document TYPE REF TO cl_document_bcs,
ls_header TYPE thead,
lv_endline TYPE sy-tabix,
gv_sent_to_all TYPE os_boolean,
lo_bcs_exception TYPE REF TO cx_bcs,
lv_crno TYPE usmd_crequest,
lv_active TYPE usmd_flg,
lt_agents TYPE usmd_t_user_agent,
lt_users TYPE TABLE OF lty_users,
lt_tusers TYPE TABLE OF lty_tusers,
lt_usr05 TYPE STANDARD TABLE OF usr05,
lv_parid TYPE usr05-parid,
lv_parid_in TYPE smen_buff-text,
lv_parid_out TYPE smen_buff-text,
lt_lines TYPE TABLE OF tline,
lo_crequest TYPE REF TO if_usmd_crequest_api,
ls_crequest TYPE usmd_s_crequest,
lv_type TYPE char20,
lv_type1 TYPE char20,
lv_st_name TYPE thead-tdname,
lv_url TYPE string,
lv_url_t TYPE string,
lv_url3 TYPE string,
lv_url4 TYPE string,
lv_url1 TYPE soli-line,
lv_note TYPE soli-line,
lv_address TYPE soli-line,
lv_data TYPE REF TO data,
lt_data_entity TYPE usmd_ts_data_entity,
lt_data_central TYPE usmd_ts_data_entity,
lo_model TYPE REF TO if_usmd_model_ext,
lo_wf_service TYPE REF TO cl_usmd_wf_service,
lt_data TYPE REF TO data,
lt_central TYPE REF TO data,
lv_name1 TYPE char70,
lv_key TYPE bu_businesspartner,
lv_legalunit TYPE char6,
lv_zrep_unit TYPE char6,
lv_zdilitrust TYPE char6,
lv_zlegal_na TYPE char70,
lv_first_name TYPE char70,
lv_last_name TYPE char70,
lv_city TYPE ad_mc_city,
lv_street TYPE ad_mc_strt,
lv_country TYPE land1,
lt_sel TYPE usmd_ts_sel,
lt_message TYPE usmd_t_message,
lv_mode TYPE usmd_readmode_ext,
lv_taxcat TYPE bptaxtype,
lv_taxnum TYPE bptaxnum,
lv_bpnum TYPE bu_partner,
lv_postalcode TYPE ad_pstcd1,
lv_house_no TYPE ad_hsnm1,
lt_reject_note TYPE TABLE OF lty_reject_note,
lv_reject_note TYPE soli-line,
lv_tax_cat_num TYPE char25,
lv_tax_detail TYPE soli-line,
ls_user_table TYPE usmd_s_user_agent,
lt_user_table TYPE STANDARD TABLE OF usmd_s_user_agent,
ls_cr_stat_usr TYPE zmdg_cr_stat_usr,
ls_user TYPE lty_users,
ls_usr05 TYPE usr05,
lv_parent_id TYPE usmd2400-top_wi_id,
lv_role TYPE agr_users-agr_name,
lv_text TYPE char30,
lv_user TYPE sy-uname,
lv_approve_popup TYPE char1,
lv_reject_popup TYPE char1,
lv_validator_t TYPE sww_aagent,
lv_email_ma_ds_flag TYPE char1,
* lt_mdg_emails TYPE TABLE OF lty_mdg_emails,
lv_cr_step_tmp TYPE char2,
lo_changelist TYPE REF TO if_usmd_cr_changelist,
lv_bp TYPE bu_businesspartner,
lv_lname1 TYPE name1_gp,
lv_lname2 TYPE name2_gp,
lv_name_org1 TYPE bu_nameor1,
lv_partner TYPE bu_partner,
* lv_zrep TYPE zrep_unit,
ls_ret TYPE bapiret2,
lv_name_org2 TYPE bu_nameor2,
lv_name_last TYPE bu_namep_l,
lv_name_first TYPE bu_namep_f,
lt_entity_data TYPE usmd_ts_entity_data_all,
lt_changelist_object TYPE if_usmd_cr_changelist=>gtt_changelist_object,
lo_cr_changelist_object TYPE REF TO if_usmd_cr_changelist_object,
lo_data TYPE REF TO data,
lt_ret TYPE TABLE OF bapiret2,
lv_techkey TYPE usmd_tech_key,
lv_name1c TYPE name1_gp,
lv_name2c TYPE name1_gp,
lo_api TYPE REF TO if_usmd_gov_api.
DATA : lv_step TYPE usmd_crequest_appstep,
ls_attributes TYPE bapi_str_bupa_fs_treasury,
ls_attributesx TYPE bapi_str_bupa_fs_treasury2_x,
lv_step_type TYPE usmd_crequest_as_type,
ls_input TYPE ty_url,
lt_input TYPE TABLE OF ty_url,
lt_output TYPE TABLE OF ty_url,
ls_output TYPE ty_url,
ls_outlines TYPE tline,
lt_outlines TYPE TABLE OF tline,
lv_former_versions TYPE usmd_flg,
lv_sid TYPE usmd_flg,
lt_emessage TYPE usmd_t_message,
lt_log_phys_name TYPE if_usmd_model_gen_adapter=>t_log_phys_name,
ls_log_phys_name TYPE if_usmd_model_gen_adapter=>s_log_phys_name,
ls_log_phys_name1 TYPE if_usmd_model_gen_adapter=>s_log_phys_name,
ls_log_phys_typ TYPE if_usmd_model_gen_adapter=>s_log_phys_name,
ls_mdgsmart TYPE ty_mdgsmart,
lt_mdgsmart TYPE TABLE OF ty_mdgsmart,
lv_gl_table TYPE fieldname,
lv_gl_table1 TYPE fieldname,
lv_gl_tabletyp TYPE fieldname,
ls_but000 TYPE but000,
lo_model_gen_adapter1 TYPE REF TO if_usmd_model_gen_adapter.
FIELD-SYMBOLS:<lt_data> TYPE ANY TABLE,
<lt_central> TYPE ANY TABLE,
<lt_data1> TYPE ANY TABLE,
<lt_data2> TYPE ANY TABLE,
<lt_bp_centrl> TYPE ANY TABLE,
<ls_key> TYPE any,
<lt_user_table> TYPE usmd_t_user_agent,
<lfs_user_agent_group> TYPE usmd_s_user_agent_group.
CONSTANTS : lc_wi_type TYPE swwwihead-wi_type VALUE 'W',
lc_wi_stat TYPE swwwihead-wi_stat VALUE 'COMPLETED',
lc_vald_status TYPE usmd_crequest_status VALUE 'Z6',
lc_tec_status TYPE usmd_crequest_status VALUE 'Z7',
lc_vendor TYPE char20 VALUE 'Vendor',
lc_customer TYPE char20 VALUE 'Customer',
lc_zmdg_debug_process TYPE rvari_vnam VALUE 'ZMDG_DEBUG_PROCESS',
lc_bpnum TYPE char10 VALUE 'BU_PARTNER',
lc_guid TYPE char32 VALUE 'BU_GUID',
lc_p TYPE char1 VALUE 'P',
lc_x TYPE char1 VALUE 'X',
gc_raw TYPE char03 VALUE 'RAW',
lc_kattr TYPE usmd_struct VALUE 'KATTR',
lc_bp_header TYPE char10 VALUE 'BP_HEADER',
lc_/1md/bpmcname1 TYPE char14 VALUE '/1MD/BPMCNAME1',
lc_/1md/bpmcname2 TYPE char14 VALUE '/1MD/BPMCNAME2',
lc_/1md/bpname_org1 TYPE char16 VALUE '/1MD/BPNAME_ORG1',
lc_/1md/bpname_org2 TYPE char16 VALUE '/1MD/BPNAME_ORG2',
lc_cr_id TYPE char6 VALUE 'CR_ID',
lc_sign TYPE char1 VALUE 'I',
lc_option TYPE char2 VALUE 'EQ',
"Change Request Types
lc_zsupcre TYPE usmd_crequest_type VALUE 'ZSUPCRE',
lc_zsupchg TYPE usmd_crequest_type VALUE 'ZSUPCHG',
lc_zsupdel TYPE usmd_crequest_type VALUE 'ZSUPDEL',
lc_zsupblk TYPE usmd_crequest_type VALUE 'ZSUPBLK',
"Service Name
lc_zmdgs_notify_req TYPE usmd_service_name VALUE 'ZMDGS_NOTIFY_REQ',
lc_zmdgs_notify_r_req TYPE usmd_service_name VALUE 'ZMDGS_NOTIFY_R_REQ',
lc_zmdgs_notify_r_spec TYPE usmd_service_name VALUE 'ZMDGS_NOTIFY_R_SPEC',
lc_zmdgs_notify_spec TYPE usmd_service_name VALUE 'ZMDGS_NOTIFY_SPEC',
lc_zmdgs_notify_spec_ch TYPE usmd_service_name VALUE 'ZMDGS_NOTIFY_SPEC_CH',
lc_zmdgs_notify_stew TYPE usmd_service_name VALUE 'ZMDGS_NOTIFY_STEW ',
lc_zmdgs_notify_req_ch TYPE usmd_service_name VALUE 'ZMDGS_NOTIFY_REQ_CH',
"Service Name
lc_zmdgs_notify_r_req_ch TYPE usmd_service_name VALUE 'ZMDGS_NOTIFY_R_REQ_CH',
lc_zmdgs_notify_r_spec_ch TYPE usmd_service_name VALUE 'ZMDGS_NOTIFY_R_SPEC_CH',
lc_zmdgs_notify_spec_ch_ch TYPE usmd_service_name VALUE 'ZMDGS_NOTIFY_SPEC_CH',
lc_zmdgs_notify_stew_ch TYPE usmd_service_name VALUE 'ZMDGS_NOTIFY_STEW_CH ',
lc_zmdgs_notify_req_ch_ch TYPE usmd_service_name VALUE 'ZMDGS_NOTIFY_REQ_CH',
"Service Name Mark for Deletion
lc_zmdgs_notify_req_del TYPE usmd_service_name VALUE 'ZMDGS_NOTIFY_REQ_DEL',
lc_zmdgs_notify_r_req_del TYPE usmd_service_name VALUE 'ZMDGS_NOTIFY_R_REQ_DEL',
lc_zmdgs_notify_r_spec_del TYPE usmd_service_name VALUE 'ZMDGS_NOTIFY_R_SPEC_DEL',
lc_zmdgs_notify_spec_del TYPE usmd_service_name VALUE 'ZMDGS_NOTIFY_SPEC_DEL',
lc_zmdgs_notify_stew_del TYPE usmd_service_name VALUE 'ZMDGS_NOTIFY_STEW_DEL',
"Service Name Block and Unblock
lc_zmdgs_notify_req_blk TYPE usmd_service_name VALUE 'ZMDGS_NOTIFY_REQ_BLK',
lc_zmdgs_notify_r_req_blk TYPE usmd_service_name VALUE 'ZMDGS_NOTIFY_R_REQ_BLK',
lc_zmdgs_notify_r_spec_blk TYPE usmd_service_name VALUE 'ZMDGS_NOTIFY_R_SPEC_BLK',
lc_zmdgs_notify_spec_blk TYPE usmd_service_name VALUE 'ZMDGS_NOTIFY_SPEC_BLK',
lc_zmdgs_notify_stew_blk TYPE usmd_service_name VALUE 'ZMDGS_NOTIFY_STEW_BLK',
"Texts- Email body
lc_zmdg_s_req_confirmation TYPE thead-tdname VALUE 'ZMDG_S_REQ_CONFIRMATION',
lc_zmdg_s_stew_rejection TYPE thead-tdname VALUE 'ZMDG_S_STEW_REJECTION',
lc_zmdg_s_stew_confirmation TYPE thead-tdname VALUE 'ZMDG_S_STEW_CONFIRMATION',
lc_zmdg_s_created TYPE thead-tdname VALUE 'ZMDG_S_CREATED',
lc_zmdg_s_stew_rej TYPE thead-tdname VALUE 'ZMDG_S_STEW_REJ',
"Texts- Email body - ZSUPCHG
lc_zmdg_s_req_confirmation_ch TYPE thead-tdname VALUE 'ZMDG_S_REQ_CONFIRMATION_CH',
lc_zmdg_s_stew_rejection_ch TYPE thead-tdname VALUE 'ZMDG_S_STEW_REJECTION_CH',
lc_zmdg_s_stew_confirma_ch TYPE thead-tdname VALUE 'ZMDG_S_STEW_CONFIRMATION_CH',
lc_zmdg_s_changed TYPE thead-tdname VALUE 'ZMDG_S_CHANGED',
lc_zmdg_s_stew_rej_ch TYPE thead-tdname VALUE 'ZMDG_S_STEW_REJ_CH',
"Texts- Email body - ZSUPDEL
lc_zmdg_s_req_confirmat_del TYPE thead-tdname VALUE 'ZMDG_S_REQ_CONFIRMATION_DEL',
lc_zmdg_s_stew_rejection_del TYPE thead-tdname VALUE 'ZMDG_S_STEW_REJECTION_DEL',
lc_zmdg_s_stew_confirma_del TYPE thead-tdname VALUE 'ZMDG_S_STEW_CONFIRMATION_DEL',
lc_zmdg_s_deleted TYPE thead-tdname VALUE 'ZMDG_S_DELETED',
lc_zmdg_s_stew_rej_del TYPE thead-tdname VALUE 'ZMDG_S_STEW_REJ_DEL',
"Texts- Email body - ZSUPBLK
lc_zmdg_s_req_confirmat_blk TYPE thead-tdname VALUE 'ZMDG_S_REQ_CONFIRMATION_BLK',
lc_zmdg_s_stew_rejection_blk TYPE thead-tdname VALUE 'ZMDG_S_STEW_REJECTION_BLK',
lc_zmdg_s_stew_confirma_blk TYPE thead-tdname VALUE 'ZMDG_S_STEW_CONFIRMATION_BLK',
lc_zmdg_s_blocked TYPE thead-tdname VALUE 'ZMDG_S_BLOCKED',
lc_zmdg_s_stew_rej_blk TYPE thead-tdname VALUE 'ZMDG_S_STEW_REJ_BLK',
lc_zmdg_bp_req_confirm TYPE thead-tdname VALUE 'ZMDG_BP_REQ_CONFIRM',
lc_zmdg_bp_req_rej TYPE thead-tdname VALUE 'ZMDGBP_NOTIFY_R_REQ_CH',
lc_zmdg_bp_smart_rej TYPE thead-tdname VALUE 'ZMDG_BP_SMART_REJ',
lc_zmdg_bp_smart_conf TYPE thead-tdname VALUE 'ZMDG_BP_SMART_CONF',
lc_zmdg_bp_modified TYPE thead-tdname VALUE 'ZMDG_BP_MODIFIED',
lc_zmdg_bp_data_stew_rej TYPE thead-tdname VALUE 'ZMDG_BP_DATA_STEW_REJ',
lc_bp TYPE char2 VALUE 'BP',
lc_c TYPE c VALUE 'C',
lc_o TYPE c VALUE 'O',
lc_bp_header1 TYPE usmd_fieldname VALUE 'BP_HEADER',
lc_bp_header2 TYPE usmd_entity VALUE 'BP_HEADER',
lc_bp_bp001 TYPE usmd_entity_cont VALUE 'FS_BP001',
lc_bp_centrl TYPE usmd_entity_cont VALUE 'BP_CENTRL',
lc_ad_postal TYPE usmd_entity_cont VALUE 'AD_POSTAL',
lc_bp_taxnum TYPE usmd_entity_cont VALUE 'BP_TAXNUM',
lc_name_org1 TYPE char9 VALUE 'NAME_ORG1',
lc_bp_num TYPE char9 VALUE 'BP_HEADER',
lc_dilitrust TYPE char9 VALUE 'ZDTRUST_I',
lc_repunit TYPE char9 VALUE 'ZREP_UNIT',
lc_legalna TYPE char9 VALUE 'ZLEGAL_NA',
lc_nam_first TYPE char9 VALUE 'NAM_FIRST',
lc_name_last TYPE char9 VALUE 'NAME_LAST',
lc_mc_city1 TYPE char8 VALUE 'MC_CITY1',
lc_mc_street TYPE char9 VALUE 'MC_STREET',
lc_ref_posta TYPE char9 VALUE 'REF_POSTA',
lc_post_cod1 TYPE char9 VALUE 'POST_COD1',
lc_house_nr1 TYPE char9 VALUE 'HOUSE_NR1',
lc_bp_tx_typ TYPE char9 VALUE 'BP_TX_TYP',
lc_taxnum TYPE char6 VALUE 'TAXNUM',
lc_taxnumxl TYPE char8 VALUE 'TAXNUMXL',
lc_bar TYPE char1 VALUE '-',
lc_uscore TYPE char1 VALUE '_',
lc_st TYPE thead-tdid VALUE 'ST',
lc_e TYPE char1 VALUE 'E',
lc_us TYPE char2 VALUE 'US',
lc_4 TYPE char1 VALUE '4',
lc_text TYPE thead-tdobject VALUE 'TEXT',
lc_lv_req_first_name TYPE char19 VALUE '&lv_req_first_name&',
lc_lv_req_last_name TYPE char18 VALUE '&lv_req_last_name&',
lc_lv_vald_first_name TYPE char20 VALUE '&lv_vald_first_name&',
lc_lv_vald_last_name TYPE char19 VALUE '&lv_vald_last_name&',
lc_lv_note TYPE char9 VALUE '&lv_note&',
lc_lv_note1 TYPE char8 VALUE 'lv_note',
lc_lv_cr_no TYPE char10 VALUE '&lv_cr&',
lc_lv_bp TYPE char10 VALUE '&lv_bp&',
lc_lv_name2 TYPE char10 VALUE '&lv_name2&',
lc_lv_desc TYPE char9 VALUE '&lv_desc&',
lc_lv_unit TYPE char9 VALUE '&lv_unit&',
lc_lv_name TYPE char9 VALUE '&lv_name&',
lc_na TYPE char2 VALUE 'NA',
lc_fiori_theme TYPE char21 VALUE '&sap-theme=sap_belize',
lc_lv_name1 TYPE char10 VALUE '&lv_name1&',
lc_lv_address TYPE char12 VALUE '&lv_address&',
lc_lv_tax TYPE char8 VALUE '&lv_tax&',
lc_lv_tax1 TYPE char6 VALUE 'lv_tax',
lc_lv_first_name TYPE char15 VALUE '&lv_first_name&',
lc_lv_last_name TYPE char14 VALUE '&lv_last_name&',
lc_lv_name_borg1 TYPE char14 VALUE '&lv_name_org1&',
lc_lv_name_borg2 TYPE char14 VALUE '&lv_name_org2&',
lc_lv_name_bfirst TYPE char15 VALUE '&lv_name_first&',
lc_lv_name_blast TYPE char14 VALUE '&lv_name_last&',
lc_lv_type TYPE char9 VALUE '&lv_type&',
lc_lv_type1 TYPE char10 VALUE '&lv_type1&',
lc_lv_url TYPE char8 VALUE '&lv_url&',
lc_lv_url_1 TYPE char6 VALUE 'lv_url',
lc_lv_url1 TYPE char9 VALUE '&lv_url1&',
lc_lv_url_t TYPE char8 VALUE 'lv_url_t',
lc_lv_bp_no TYPE char10 VALUE '&lv_bp_no&',
lc_percent TYPE char1 VALUE '%',
lc_20p TYPE char3 VALUE '%20',
lc_02 TYPE char2 VALUE '02',
lc_03 TYPE char2 VALUE '03',
lc_fslash TYPE char1 VALUE '/',
lc_n TYPE char1 VALUE 'N',
lc_zmdg_ TYPE char5 VALUE 'ZMDG_',
lc_zmdg_all TYPE char8 VALUE 'ZMDG_ALL',
lc_zmdg_acc_all TYPE char11 VALUE 'ZMDG_ACC_ALL',
lc_lv_req_name TYPE char13 VALUE '&lv_req_name&',
lc_manager TYPE char7 VALUE 'Manager',
lc_zmdg_cr_stat_usr TYPE rstable-tabname VALUE 'ZMDG_CR_STAT_USR',
lc_z6 TYPE char2 VALUE 'Z6',
lc_z7 TYPE char2 VALUE 'Z7',
lc_cr TYPE char3 VALUE 'CR:'.
* Get and read CR and launch E-Mail notification
CLEAR : ls_crequest, lv_approve_popup, lv_reject_popup.
CALL METHOD cl_usmd_crequest_api=>get_instance
EXPORTING
iv_crequest = iv_cr_number
IMPORTING
re_inst_crequest_api = lo_crequest.
CALL METHOD lo_crequest->read_crequest
IMPORTING
es_crequest = ls_crequest.
*- Check Inscope CR types for Supplier and Customer.
IF ls_crequest-usmd_creq_type = lc_zsupcre OR
ls_crequest-usmd_creq_type = lc_zsupchg OR
ls_crequest-usmd_creq_type = lc_zsupdel OR
ls_crequest-usmd_creq_type = lc_zsupblk .
FREE MEMORY ID 'ZPANIN'.
FREE MEMORY ID 'ZPAN_IND'.
TRY.
*Initiate Object
lo_send_request = cl_bcs=>create_persistent( ).
**
*Get the RFC user
CALL METHOD get_rfc_user
IMPORTING
ev_rfc_user = lv_user.
*Sender Email
lo_sender = cl_sapuser_bcs=>create( lv_user ).
CALL METHOD lo_send_request->set_sender
EXPORTING
i_sender = lo_sender.
*Conversion exit
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
input = iv_cr_number
IMPORTING
output = lv_crno.
CLEAR:lv_type,lv_type1.
"Email Subject
IF ls_crequest-usmd_creq_type = lc_zsupcre.
CONCATENATE TEXT-001 lv_crno TEXT-002 INTO gv_subject SEPARATED BY space.
ELSEIF ls_crequest-usmd_creq_type = lc_zsupchg.
CONCATENATE TEXT-001 lv_crno TEXT-003 INTO gv_subject SEPARATED BY space.
ELSEIF ls_crequest-usmd_creq_type = lc_zsupdel.
CONCATENATE TEXT-001 lv_crno TEXT-004 INTO gv_subject SEPARATED BY space.
ELSEIF ls_crequest-usmd_creq_type = lc_zsupblk.
CONCATENATE TEXT-001 lv_crno TEXT-005 INTO gv_subject SEPARATED BY space.
ENDIF.
CLEAR lv_st_name.
CASE iv_service_name.
WHEN lc_zmdgs_notify_spec.
lv_st_name = lc_zmdg_s_req_confirmation.
WHEN lc_zmdgs_notify_r_req.
lv_st_name = lc_zmdg_s_stew_rejection.
WHEN lc_zmdgs_notify_stew.
lv_st_name = lc_zmdg_s_stew_confirmation.
WHEN lc_zmdgs_notify_req.
lv_st_name = lc_zmdg_s_created.
WHEN lc_zmdgs_notify_r_spec.
lv_st_name = lc_zmdg_s_stew_rej.
* WHEN lc_zmdgbp_notify_spec_ch.
* lv_st_name = lc_zmdg_bp_req_confirm.
* WHEN lc_ZMDGBP_NOTIFY_STEW_CH.
* lv_st_name = lc_zmdg_bp_smart_conf.
* WHEN lc_zmdgbp_notify_req_ch.
* lv_st_name = lc_zmdg_bp_modified.
WHEN lc_zmdgs_notify_spec_ch.
lv_st_name = lc_zmdg_s_req_confirmation_ch.
WHEN lc_zmdgs_notify_r_req_ch.
lv_st_name = lc_zmdg_s_stew_rejection_ch.
WHEN lc_zmdgs_notify_stew_ch.
lv_st_name = lc_zmdg_s_stew_confirma_ch.
WHEN lc_zmdgs_notify_req_ch.
lv_st_name = lc_zmdg_s_changed.
WHEN lc_zmdgs_notify_r_spec_ch.
lv_st_name = lc_zmdg_s_stew_rej_ch.
" Mark for Deletion
WHEN lc_zmdgs_notify_spec_del.
lv_st_name = lc_zmdg_s_req_confirmat_del.
WHEN lc_zmdgs_notify_r_req_del.
lv_st_name = lc_zmdg_s_stew_rejection_del.
WHEN lc_zmdgs_notify_stew_del.
lv_st_name = lc_zmdg_s_stew_confirma_del.
WHEN lc_zmdgs_notify_req_del.
lv_st_name = lc_zmdg_s_deleted.
WHEN lc_zmdgs_notify_r_spec_del.
lv_st_name = lc_zmdg_s_stew_rej_del.
" Block and Unblock
WHEN lc_zmdgs_notify_spec_blk.
lv_st_name = lc_zmdg_s_req_confirmat_blk.
WHEN lc_zmdgs_notify_r_req_blk.
lv_st_name = lc_zmdg_s_stew_rejection_blk.
WHEN lc_zmdgs_notify_stew_blk.
lv_st_name = lc_zmdg_s_stew_confirma_blk.
WHEN lc_zmdgs_notify_req_blk.
lv_st_name = lc_zmdg_s_blocked.
WHEN lc_zmdgs_notify_r_spec_blk.
lv_st_name = lc_zmdg_s_stew_rej_blk.
ENDCASE.
"Get the User Role
CASE iv_service_name.
WHEN lc_zmdgs_notify_req. " OR lc_ZMDGBP_NOTIFY_REQ_CH OR lc_zmdgbp_notify_stew_ch
"OR lc_zmdgbp_notify_stew . "All requester
IF cv_new_cr_status = '04'.
SELECT agr_name
uname
FROM agr_users
INTO TABLE lt_tusers
WHERE agr_name = 'Z_MDGS_SPEC_07'.
ELSEIF cv_new_cr_status = '05'.
SELECT agr_name
uname
FROM agr_users
INTO TABLE lt_tusers
WHERE agr_name = 'Z_MDGS_STEW_07'.
ELSEIF ls_crequest-usmd_creq_status = '04'.
SELECT agr_name
uname
FROM agr_users
INTO TABLE lt_tusers
WHERE agr_name = 'Z_MDGS_SPEC_07'.
ELSE.
SELECT agr_name
uname
FROM agr_users
INTO TABLE lt_tusers
WHERE agr_name = 'Z_MDGS_SPEC_07'.
ENDIF.
WHEN lc_zmdgs_notify_req_ch.
IF cv_new_cr_status = '05'.
SELECT agr_name
uname
FROM agr_users
INTO TABLE lt_tusers
WHERE agr_name = 'Z_MDGS_REQ_07'.
ENDIF.
WHEN lc_zmdgs_notify_req_del.
IF cv_new_cr_status = '05'.
SELECT agr_name
uname
FROM agr_users
INTO TABLE lt_tusers
WHERE agr_name = 'Z_MDGS_REQ_07'.
ENDIF.
WHEN lc_zmdgs_notify_req_blk.
IF cv_new_cr_status = '05'.
SELECT agr_name
uname
FROM agr_users
INTO TABLE lt_tusers
WHERE agr_name = 'Z_MDGS_REQ_07'.
ENDIF.
ENDCASE.
IF lt_tusers IS NOT INITIAL.
SORT lt_tusers BY uname.
DELETE ADJACENT DUPLICATES FROM lt_tusers COMPARING uname.
LOOP AT lt_tusers INTO DATA(ls_tusers).
CLEAR:lt_return,ls_user_data,lv_mail_address.
CALL FUNCTION 'BAPI_USER_GET_DETAIL'
EXPORTING
username = ls_tusers-uname
cache_results = space
IMPORTING
address = ls_user_data
TABLES
return = lt_return.
IF ls_user_data-e_mail IS NOT INITIAL.
lv_recipient = ls_user_data-e_mail.
lo_recipient = cl_cam_address_bcs=>create_internet_address( lv_recipient ).
CALL METHOD lo_send_request->add_recipient
EXPORTING
i_recipient = lo_recipient
i_express = lc_x.
ENDIF.
ENDLOOP.
ENDIF.
READ TABLE ct_user_agent_group INTO DATA(ls_user_agent_group) INDEX 1.
IF sy-subrc IS INITIAL AND ls_user_agent_group IS NOT INITIAL.
lt_agents[] = ls_user_agent_group-user_agent[].
IF NOT lt_agents IS INITIAL.
READ TABLE lt_agents INTO DATA(ls_agents) INDEX 1.
IF sy-subrc IS INITIAL AND ls_agents IS NOT INITIAL.
CLEAR lv_role.
CONCATENATE ls_agents-user_value+0(30) lc_percent INTO lv_role.
SELECT uname
INTO TABLE lt_users
FROM agr_users "#EC CI_GENBUFF
WHERE agr_name LIKE lv_role.
IF sy-subrc IS INITIAL AND lt_users IS NOT INITIAL.
SORT lt_users BY uname.
DELETE ADJACENT DUPLICATES FROM lt_users.
CONCATENATE lc_zmdg_ ls_crequest-usmd_reason INTO lv_parid.
LOOP AT lt_users INTO DATA(ls_tusers1)."ls_usr05.
CLEAR:lt_return,ls_user_data,lv_mail_address.
CALL FUNCTION 'BAPI_USER_GET_DETAIL'
EXPORTING
username = ls_tusers1-uname
cache_results = space
IMPORTING
address = ls_user_data
TABLES
return = lt_return.
IF ls_user_data-e_mail IS NOT INITIAL.
lv_recipient = ls_user_data-e_mail.
lo_recipient = cl_cam_address_bcs=>create_internet_address( lv_recipient ).
CALL METHOD lo_send_request->add_recipient
EXPORTING
i_recipient = lo_recipient
i_express = lc_x.
ENDIF.
ENDLOOP.
* ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
*!--Start of code to remove special character from Name 1 and Name 2
CLEAR: lv_key,lv_techkey ,lv_gl_table1.
CALL METHOD cl_usmd_model_ext=>get_instance
EXPORTING
i_usmd_model = lc_bp
IMPORTING
eo_instance = lo_model.
CALL METHOD lo_model->read_entity_data_all
EXPORTING
i_fieldname = lc_bp_header1
if_active = lv_active
i_crequest = iv_cr_number
IMPORTING
et_data_entity = lt_data_entity.
IF lt_data_entity[] IS NOT INITIAL.
READ TABLE lt_data_entity INTO DATA(ls_data_entity) WITH KEY usmd_entity = lc_bp_header2
" usmd_entity_cont = lc_bp_centrl
struct = lc_kattr.
IF sy-subrc IS INITIAL.
CLEAR lt_data.
MOVE ls_data_entity-r_t_data TO lt_data.
ASSIGN lt_data->* TO <lt_data>.
LOOP AT <lt_data> ASSIGNING FIELD-SYMBOL(<ls_data>).
IF <ls_data> IS ASSIGNED AND <ls_data> IS NOT INITIAL.
ASSIGN COMPONENT lc_bp_num OF STRUCTURE <ls_data> TO FIELD-SYMBOL(<lv_key>).
IF <lv_key> IS ASSIGNED AND <lv_key> IS NOT INITIAL.
lv_key = <lv_key>.
ENDIF.
ENDIF.
ENDLOOP.
ENDIF.
ENDIF.
IF lv_key IS NOT INITIAL.
*!-- To get MDG table name
REFRESH: lt_emessage,lt_log_phys_name.
CALL METHOD cl_usmd_adapter_provider=>get_model_generation_adapter " To get MDG table ZSMART
EXPORTING
i_usmd_model = lc_bp
IMPORTING
eo_model_gen_adapter = lo_model_gen_adapter1
et_message = lt_emessage.
CALL METHOD lo_model_gen_adapter1->get_generated_objects
EXPORTING
if_former_versions = lv_former_versions
if_sid_tab = lv_sid
IMPORTING
et_message = lt_emessage
et_log_phys_name = lt_log_phys_name.
IF lt_log_phys_name IS NOT INITIAL.
CLEAR : ls_log_phys_name , ls_log_phys_typ, lv_gl_tabletyp .
CLEAR : lv_gl_table.
READ TABLE lt_log_phys_name INTO ls_log_phys_name WITH KEY sub_kind = lc_c
entity = lc_bp_header1.
IF sy-subrc IS INITIAL AND ls_log_phys_name IS NOT INITIAL.
lv_gl_table = ls_log_phys_name-phys_name. " MDG Table
IF lv_gl_table IS NOT INITIAL .
SELECT SINGLE usmdkbpbp_header
FROM (lv_gl_table)
INTO @lv_techkey
WHERE /1md/bpbp_header EQ @lv_key.
IF lv_techkey IS NOT INITIAL.
READ TABLE lt_log_phys_name INTO ls_log_phys_name1 WITH KEY sub_kind = lc_o
entity_cont = 'BP_CENTRL'
entity = lc_bp_header1.
IF ls_log_phys_name1 IS NOT INITIAL.
lv_gl_table1 = ls_log_phys_name1-phys_name. " MDG Table
DATA: r_table TYPE REF TO data.
FIELD-SYMBOLS: <tab> TYPE STANDARD TABLE.
FIELD-SYMBOLS: <wa_tab> TYPE data.
CREATE DATA r_table TYPE TABLE OF (lv_gl_table1).
ASSIGN r_table->* TO <tab>.
CREATE DATA r_table LIKE LINE OF <tab>.
ASSIGN r_table->* TO <wa_tab>.
SELECT SINGLE * FROM (lv_gl_table1)
INTO @<wa_tab> WHERE usmdkbpbp_header EQ @lv_techkey.
IF <wa_tab> IS NOT INITIAL AND <wa_tab> IS ASSIGNED.
ASSIGN COMPONENT lc_/1md/bpmcname1 OF STRUCTURE <wa_tab> TO FIELD-SYMBOL(<lfv_name1>).
IF <lfv_name1> IS ASSIGNED AND <lfv_name1> IS NOT INITIAL.
CLEAR: lv_name1c.
lv_name1c = <lfv_name1>.
CLEAR: <lfv_name1>.
CALL FUNCTION 'ZCMMV_DELETE_SPECIAL_NAME'
EXPORTING
i_text = lv_name1c
IMPORTING
e_text = lv_name1c.
<lfv_name1> = lv_name1c.
ENDIF.
ASSIGN COMPONENT lc_/1md/bpmcname2 OF STRUCTURE <wa_tab> TO FIELD-SYMBOL(<lfv_name2>).
IF <lfv_name2> IS ASSIGNED AND <lfv_name2> IS NOT INITIAL.
CLEAR:lv_name2c.
lv_name2c = <lfv_name2>.
CALL FUNCTION 'ZCMMV_DELETE_SPECIAL_NAME'
EXPORTING
i_text = lv_name2c
IMPORTING
e_text = lv_name2c.
CLEAR <lfv_name2>.
<lfv_name2> = lv_name2c.
ENDIF.
ASSIGN COMPONENT lc_/1md/bpname_org1 OF STRUCTURE <wa_tab> TO FIELD-SYMBOL(<lfv_org1>).
IF <lfv_org1> IS ASSIGNED AND <lfv_org1> IS NOT INITIAL.
CALL FUNCTION 'ZCMMV_DELETE_SPECIAL_CHAR'
EXPORTING
i_text = <lfv_org1>
IMPORTING
e_text = <lfv_org1>.
ENDIF.
ASSIGN COMPONENT lc_/1md/bpname_org2 OF STRUCTURE <wa_tab> TO FIELD-SYMBOL(<lfv_org2>).
IF <lfv_org2> IS ASSIGNED AND <lfv_org2> IS NOT INITIAL.
CALL FUNCTION 'ZCMMV_DELETE_SPECIAL_CHAR'
EXPORTING
i_text = <lfv_org2>
IMPORTING
e_text = <lfv_org2>.
ENDIF.
MODIFY (lv_gl_table1) FROM <wa_tab>.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
*Email Body
CALL FUNCTION 'READ_TEXT'
EXPORTING
id = lc_st
language = sy-langu
name = lv_st_name
object = lc_text
IMPORTING
header = ls_header
TABLES
lines = lt_lines.
*If Standard text is not available for system language then take english standard text
IF ls_header IS INITIAL.
CALL FUNCTION 'READ_TEXT'
EXPORTING
id = lc_st
language = lc_e
name = lv_st_name
object = lc_text
IMPORTING
header = ls_header
TABLES
lines = lt_lines.
ENDIF.
IF ls_header IS NOT INITIAL.
**Requester Name
CALL FUNCTION 'BAPI_USER_GET_DETAIL'
EXPORTING
username = ls_crequest-usmd_created_by
IMPORTING
address = ls_address
TABLES
return = lt_return1.
CALL FUNCTION 'SET_TEXTSYMBOL'
EXPORTING
header = ls_header
name = lc_lv_req_first_name
value = ls_address-firstname
replace = lc_x.
CALL FUNCTION 'SET_TEXTSYMBOL'
EXPORTING
header = ls_header
name = lc_lv_req_last_name
value = ls_address-lastname
replace = lc_x.
**Reqestor confirmation
CLEAR:ls_address,lt_return1.
CALL FUNCTION 'BAPI_USER_GET_DETAIL'
EXPORTING
username = ls_crequest-usmd_changed_by
IMPORTING
address = ls_address
TABLES
return = lt_return1.
CALL FUNCTION 'SET_TEXTSYMBOL'
EXPORTING
header = ls_header
name = lc_lv_vald_first_name
value = ls_address-firstname
replace = lc_x.
CALL FUNCTION 'SET_TEXTSYMBOL'
EXPORTING
header = ls_header
name = lc_lv_vald_last_name
value = ls_address-lastname
replace = lc_x.
*Rejection note
IF lv_st_name = lc_zmdg_s_stew_rejection.
CLEAR lt_reject_note.
SELECT usmd_ncreated_at
usmd_note
INTO TABLE lt_reject_note
FROM usmd1210
WHERE usmd_crequest EQ iv_cr_number.
IF sy-subrc IS INITIAL AND lt_reject_note IS NOT INITIAL.
SORT lt_reject_note BY usmd_ncreated_at.
CLEAR lv_reject_note.
LOOP AT lt_reject_note INTO DATA(ls_reject_note).
CONCATENATE ls_reject_note-usmd_note lv_reject_note INTO lv_reject_note
SEPARATED BY cl_abap_char_utilities=>cr_lf.
ENDLOOP.
CALL FUNCTION 'SET_TEXTSYMBOL'
EXPORTING
header = ls_header
name = lc_lv_note
value = lv_reject_note
replace = lc_x.
ENDIF.
ENDIF.
*CR number
CALL FUNCTION 'SET_TEXTSYMBOL'
EXPORTING
header = ls_header
name = lc_lv_cr_no
value = lv_crno
replace = lc_x.
.
"BP number
CALL FUNCTION 'SET_TEXTSYMBOL'
EXPORTING
header = ls_header
name = lc_lv_bp
value = lv_bp
replace = lc_x.
"Name1
CALL FUNCTION 'SET_TEXTSYMBOL'
EXPORTING
header = ls_header
name = lc_lv_name1
value = lv_lname1
replace = lc_x.
"Name2
CALL FUNCTION 'SET_TEXTSYMBOL'
EXPORTING
header = ls_header
name = lc_lv_name2
value = lv_lname2
replace = lc_x.
"Name First
CALL FUNCTION 'SET_TEXTSYMBOL'
EXPORTING
header = ls_header
name = lc_lv_name_bfirst
value = lv_name_first
replace = lc_x.
"Name Last
CALL FUNCTION 'SET_TEXTSYMBOL'
EXPORTING
header = ls_header
name = lc_lv_name_blast
value = lv_name_last
replace = lc_x.
"Name Org1
CALL FUNCTION 'SET_TEXTSYMBOL'
EXPORTING
header = ls_header
name = lc_lv_name_borg1
value = lv_name_org1
replace = lc_x.
"Name Org2
CALL FUNCTION 'SET_TEXTSYMBOL'
EXPORTING
header = ls_header
name = lc_lv_name_borg2
value = lv_name_org2
replace = lc_x.
*CR description
CALL FUNCTION 'SET_TEXTSYMBOL'
EXPORTING
header = ls_header
name = lc_lv_desc
value = ls_crequest-usmd_creq_text
replace = lc_x.
*Legal Name
CALL FUNCTION 'SET_TEXTSYMBOL'
EXPORTING
header = ls_header
name = lc_lv_name
value = lv_zlegal_na
replace = lc_x.
*Reporting Unit
CALL FUNCTION 'SET_TEXTSYMBOL'
EXPORTING
header = ls_header
name = lc_lv_unit
value = lv_zrep_unit
replace = lc_x.
CALL FUNCTION 'SET_TEXTSYMBOL'
EXPORTING
header = ls_header
name = lc_lv_bp_no
value = lv_bp "lv_bpnum
replace = lc_x.
IF lv_st_name EQ lc_zmdg_s_req_confirmation
OR lv_st_name EQ lc_zmdg_s_stew_rej.
CALL FUNCTION 'SET_TEXTSYMBOL'
EXPORTING
header = ls_header
name = lc_lv_bp_no
value = lv_bpnum
replace = lc_x.
ENDIF.
"Setup Body
CALL FUNCTION 'REPLACE_TEXTSYMBOL'
EXPORTING
endline = lv_endline
formatwidth = 132
linewidth = 132
startline = 1
TABLES
lines = lt_lines.
DATA(lv_text2) = 'Link to NWBC for manager'.
DATA(lv_text1) = 'Lien vers demande de creation/modification NWBC'.
IF lt_lines IS NOT INITIAL.
LOOP AT lt_lines INTO ls_data.
CLEAR lv_url1.
IF ls_data-tdline EQ lv_url.
lv_url1 = lv_url.
lt_body = VALUE #( BASE lt_body ( line = lv_url1 ) ).
ELSEIF ls_data-tdline EQ lv_url_t.
CLEAR lv_url1.
lv_url1 = lv_url_t.
lt_body = VALUE #( BASE lt_body ( line = lv_url1 ) ).
ELSEIF ls_data-tdline EQ lv_text1 OR ls_data-tdline EQ lv_text2.
lt_body = VALUE #( BASE lt_body ( line = ls_data-tdline ) ).
CONCATENATE '<A HREF="' lv_url '">' '</A>' INTO lv_url3. "lv_url2 '</A>' INTO lv_url3.
lt_body = VALUE #( BASE lt_body ( line = lv_url3 ) ).
ELSEIF ls_data-tdline EQ lc_lv_note1.
lt_body = VALUE #( BASE lt_body ( line = lv_reject_note ) ).
ELSEIF ls_data-tdline EQ lc_lv_tax1.
lt_body = VALUE #( BASE lt_body ( line = lv_tax_detail ) ).
ELSE.
lt_body = VALUE #( BASE lt_body ( line = ls_data-tdline ) ).
ENDIF.
ENDLOOP.
ENDIF.
ENDIF.
"Add Email Body and Subject
lo_document = cl_document_bcs=>create_document( i_type = gc_raw
i_text = lt_body
i_subject = gv_subject ).
"Add document to send request
CALL METHOD lo_send_request->set_document( lo_document ).
"Send Immediately
CALL METHOD lo_send_request->set_send_immediately
EXPORTING
i_send_immediately = lc_x.
"Send email
CALL METHOD lo_send_request->send(
EXPORTING
i_with_error_screen = lc_x
RECEIVING
result = gv_sent_to_all ).
IF gv_sent_to_all = lc_x.
*- Update table ZMDG_CR_STAT_USR with USER_ID of Manager who is approving the CR
IF iv_service_name EQ lc_zmdgs_notify_spec OR iv_service_name EQ lc_zmdgs_notify_stew.
CLEAR lv_parent_id.
SELECT SINGLE top_wi_id "#EC CI_NOFIELD
FROM usmd2400
INTO @lv_parent_id
WHERE usmd_crequest = @iv_cr_number.
IF sy-subrc IS INITIAL AND lv_parent_id IS NOT INITIAL.
SELECT wi_id, wi_type, wi_stat, wi_aagent, parent_wi "#EC CI_NOFIELD
FROM swwwihead
INTO TABLE @DATA(lt_wi_table)
WHERE wi_type = @lc_wi_type
AND wi_stat = @lc_wi_stat
AND parent_wi = @lv_parent_id.
IF sy-subrc IS INITIAL AND lt_wi_table IS NOT INITIAL.
LOOP AT lt_wi_table INTO DATA(ls_wi_table).
IF ls_wi_table-wi_aagent IS NOT INITIAL.
ls_cr_stat_usr-zapprover_id = ls_wi_table-wi_aagent.
ls_cr_stat_usr-usmd_crequest = iv_cr_number.
ls_cr_stat_usr-usmd_creq_status = lc_z6.
ENDIF.
ENDLOOP.
ENDIF.
ENDIF.
CALL FUNCTION 'ENQUEUE_E_TABLE'
EXPORTING
tabname = lc_zmdg_cr_stat_usr
EXCEPTIONS
foreign_lock = 1
system_failure = 2
OTHERS = 3.
IF sy-subrc IS INITIAL AND ls_cr_stat_usr IS NOT INITIAL.
*- Update table ZMDG_CR_STAT_USR with USER_ID of Manager who is approving the CR
MODIFY zmdg_cr_stat_usr FROM ls_cr_stat_usr.
ENDIF.
CALL FUNCTION 'DEQUEUE_E_TABLE'
EXPORTING
tabname = lc_zmdg_cr_stat_usr.
ELSEIF iv_service_name EQ lc_zmdgs_notify_stew OR iv_service_name EQ lc_zmdgs_notify_r_req
OR iv_service_name EQ lc_zmdgs_notify_r_spec OR iv_service_name EQ lc_zmdgs_notify_spec.
DELETE FROM zmdg_cr_stat_usr WHERE usmd_crequest = iv_cr_number.
ENDIF.
COMMIT WORK.
ENDIF.
"Exception handling
CATCH cx_bcs INTO lo_bcs_exception.
APPEND lo_bcs_exception->error_type TO et_message.
ENDTRY.
ENDIF.
CALL FUNCTION 'READ_TEXT'
EXPORTING
id = lc_st
language = sy-langu
name = lv_st_name
object = lc_text
IMPORTING
header = ls_header
TABLES
lines = lt_lines.
*If Standard text is not available for system language then take english standard text
IF ls_header IS INITIAL.
CALL FUNCTION 'READ_TEXT'
EXPORTING
id = lc_st
language = lc_e
name = lv_st_name
object = lc_text
IMPORTING
header = ls_header
TABLES
lines = lt_lines.
ENDIF.
IF ls_header IS NOT INITIAL.
**Requester Name
CALL FUNCTION 'BAPI_USER_GET_DETAIL'
EXPORTING
username = ls_crequest-usmd_created_by
IMPORTING
address = ls_address
TABLES
return = lt_return1.
CALL FUNCTION 'SET_TEXTSYMBOL'
EXPORTING
header = ls_header
name = lc_lv_req_first_name
value = ls_address-firstname
replace = lc_x.
CALL FUNCTION 'SET_TEXTSYMBOL'
EXPORTING
header = ls_header
name = lc_lv_req_last_name
value = ls_address-lastname
replace = lc_x.
**Reqestor confirmation
CLEAR:ls_address,lt_return1.
CALL FUNCTION 'BAPI_USER_GET_DETAIL'
EXPORTING
username = ls_crequest-usmd_changed_by
IMPORTING
address = ls_address
TABLES
return = lt_return1.
CALL FUNCTION 'SET_TEXTSYMBOL'
EXPORTING
header = ls_header
name = lc_lv_vald_first_name
value = ls_address-firstname
replace = lc_x.
CALL FUNCTION 'SET_TEXTSYMBOL'
EXPORTING
header = ls_header
name = lc_lv_vald_last_name
value = ls_address-lastname
replace = lc_x.
*Rejection note
IF lv_st_name = lc_zmdg_s_stew_rejection.
CLEAR lt_reject_note.
SELECT usmd_ncreated_at
usmd_note
INTO TABLE lt_reject_note
FROM usmd1210
WHERE usmd_crequest EQ iv_cr_number.
IF sy-subrc IS INITIAL AND lt_reject_note IS NOT INITIAL.
SORT lt_reject_note BY usmd_ncreated_at.
CLEAR lv_reject_note.
LOOP AT lt_reject_note INTO DATA(ls_reject_note).
CONCATENATE ls_reject_note-usmd_note lv_reject_note INTO lv_reject_note
SEPARATED BY cl_abap_char_utilities=>cr_lf.
ENDLOOP.
CALL FUNCTION 'SET_TEXTSYMBOL'
EXPORTING
header = ls_header
name = lc_lv_note
value = lv_reject_note
replace = lc_x.
ENDIF.
ENDIF.
*CR number
CALL FUNCTION 'SET_TEXTSYMBOL'
EXPORTING
header = ls_header
name = lc_lv_cr_no
value = lv_crno
replace = lc_x.
.
"BP number
CALL FUNCTION 'SET_TEXTSYMBOL'
EXPORTING
header = ls_header
name = lc_lv_bp
value = lv_bp
replace = lc_x.
"Name1
CALL FUNCTION 'SET_TEXTSYMBOL'
EXPORTING
header = ls_header
name = lc_lv_name1
value = lv_lname1
replace = lc_x.
"Name2
CALL FUNCTION 'SET_TEXTSYMBOL'
EXPORTING
header = ls_header
name = lc_lv_name2
value = lv_lname2
replace = lc_x.
"Name First
CALL FUNCTION 'SET_TEXTSYMBOL'
EXPORTING
header = ls_header
name = lc_lv_name_bfirst
value = lv_name_first
replace = lc_x.
"Name Last
CALL FUNCTION 'SET_TEXTSYMBOL'
EXPORTING
header = ls_header
name = lc_lv_name_blast
value = lv_name_last
replace = lc_x.
"Name Org1
CALL FUNCTION 'SET_TEXTSYMBOL'
EXPORTING
header = ls_header
name = lc_lv_name_borg1
value = lv_name_org1
replace = lc_x.
"Name Org2
CALL FUNCTION 'SET_TEXTSYMBOL'
EXPORTING
header = ls_header
name = lc_lv_name_borg2
value = lv_name_org2
replace = lc_x.
*CR description
CALL FUNCTION 'SET_TEXTSYMBOL'
EXPORTING
header = ls_header
name = lc_lv_desc
value = ls_crequest-usmd_creq_text
replace = lc_x.
*Legal Name
CALL FUNCTION 'SET_TEXTSYMBOL'
EXPORTING
header = ls_header
name = lc_lv_name
value = lv_zlegal_na
replace = lc_x.
*Reporting Unit
CALL FUNCTION 'SET_TEXTSYMBOL'
EXPORTING
header = ls_header
name = lc_lv_unit
value = lv_zrep_unit
replace = lc_x.
CALL FUNCTION 'SET_TEXTSYMBOL'
EXPORTING
header = ls_header
name = lc_lv_bp_no
value = lv_bp "lv_bpnum
replace = lc_x.
IF lv_st_name EQ lc_zmdg_s_req_confirmation
OR lv_st_name EQ lc_zmdg_s_stew_rej.
CALL FUNCTION 'SET_TEXTSYMBOL'
EXPORTING
header = ls_header
name = lc_lv_bp_no
value = lv_bpnum
replace = lc_x.
ENDIF.
"Setup Body
CALL FUNCTION 'REPLACE_TEXTSYMBOL'
EXPORTING
endline = lv_endline
formatwidth = 132
linewidth = 132
startline = 1
TABLES
lines = lt_lines.
DATA(lv_text2) = 'Link to NWBC for manager'.
DATA(lv_text1) = 'Lien vers demande de creation/modification NWBC'.
IF lt_lines IS NOT INITIAL.
LOOP AT lt_lines INTO ls_data.
CLEAR lv_url1.
IF ls_data-tdline EQ lv_url.
lv_url1 = lv_url.
lt_body = VALUE #( BASE lt_body ( line = lv_url1 ) ).
ELSEIF ls_data-tdline EQ lv_url_t.
CLEAR lv_url1.
lv_url1 = lv_url_t.
lt_body = VALUE #( BASE lt_body ( line = lv_url1 ) ).
ELSEIF ls_data-tdline EQ lv_text1 OR ls_data-tdline EQ lv_text2.
lt_body = VALUE #( BASE lt_body ( line = ls_data-tdline ) ).
CONCATENATE '<A HREF="' lv_url '">' '</A>' INTO lv_url3. "lv_url2 '</A>' INTO lv_url3.
lt_body = VALUE #( BASE lt_body ( line = lv_url3 ) ).
ELSEIF ls_data-tdline EQ lc_lv_note1.
lt_body = VALUE #( BASE lt_body ( line = lv_reject_note ) ).
ELSEIF ls_data-tdline EQ lc_lv_tax1.
lt_body = VALUE #( BASE lt_body ( line = lv_tax_detail ) ).
ELSE.
lt_body = VALUE #( BASE lt_body ( line = ls_data-tdline ) ).
ENDIF.
ENDLOOP.
ENDIF.
ENDIF.
"Add Email Body and Subject
lo_document = cl_document_bcs=>create_document( i_type = gc_raw
i_text = lt_body
i_subject = gv_subject ).
"Add document to send request
CALL METHOD lo_send_request->set_document( lo_document ).
"Send Immediately
CALL METHOD lo_send_request->set_send_immediately
EXPORTING
i_send_immediately = lc_x.
"Send email
CALL METHOD lo_send_request->send(
EXPORTING
i_with_error_screen = lc_x
RECEIVING
result = gv_sent_to_all ).
IF gv_sent_to_all = lc_x.
*- Update table ZMDG_CR_STAT_USR with USER_ID of Manager who is approving the CR
IF iv_service_name EQ lc_zmdgs_notify_spec OR iv_service_name EQ lc_zmdgs_notify_stew.
CLEAR lv_parent_id.
SELECT SINGLE top_wi_id "#EC CI_NOFIELD
FROM usmd2400
INTO @lv_parent_id
WHERE usmd_crequest = @iv_cr_number.
IF sy-subrc IS INITIAL AND lv_parent_id IS NOT INITIAL.
SELECT wi_id, wi_type, wi_stat, wi_aagent, parent_wi "#EC CI_NOFIELD
FROM swwwihead
INTO TABLE @DATA(lt_wi_table)
WHERE wi_type = @lc_wi_type
AND wi_stat = @lc_wi_stat
AND parent_wi = @lv_parent_id.
IF sy-subrc IS INITIAL AND lt_wi_table IS NOT INITIAL.
LOOP AT lt_wi_table INTO DATA(ls_wi_table).
IF ls_wi_table-wi_aagent IS NOT INITIAL.
ls_cr_stat_usr-zapprover_id = ls_wi_table-wi_aagent.
ls_cr_stat_usr-usmd_crequest = iv_cr_number.
ls_cr_stat_usr-usmd_creq_status = lc_z6.
ENDIF.
ENDLOOP.
ENDIF.
ENDIF.
CALL FUNCTION 'ENQUEUE_E_TABLE'
EXPORTING
tabname = lc_zmdg_cr_stat_usr
EXCEPTIONS
foreign_lock = 1
system_failure = 2
OTHERS = 3.
IF sy-subrc IS INITIAL AND ls_cr_stat_usr IS NOT INITIAL.
*- Update table ZMDG_CR_STAT_USR with USER_ID of Manager who is approving the CR
MODIFY zmdg_cr_stat_usr FROM ls_cr_stat_usr.
ENDIF.
CALL FUNCTION 'DEQUEUE_E_TABLE'
EXPORTING
tabname = lc_zmdg_cr_stat_usr.
ELSEIF iv_service_name EQ lc_zmdgs_notify_stew OR iv_service_name EQ lc_zmdgs_notify_r_req
OR iv_service_name EQ lc_zmdgs_notify_r_spec OR iv_service_name EQ lc_zmdgs_notify_spec.
DELETE FROM zmdg_cr_stat_usr WHERE usmd_crequest = iv_cr_number.
ENDIF.
COMMIT WORK.
ENDIF.
"Exception handling
CATCH cx_bcs INTO lo_bcs_exception.
APPEND lo_bcs_exception->error_type TO et_message.
ENDTRY.
ENDIF.
ReplyDeletemclean intelligent workforce is any best job recommend company in the town we give best services to over customers miw standard service
Nice Article this one is good and useful to us, So thanks to this site. I have a News for you tech lovers a new website i found for you in google so go and checkout this Asus TUF Gaming F15.
ReplyDelete