0% found this document useful (0 votes)
57 views16 pages

ZMIGO - Email Send With Attachment

This document contains code for an SAP report. The report contains data definitions and SQL statements to retrieve asset data from various SAP tables and populate internal tables. Field catalogs are defined to structure the output. The report will generate an output of asset data for selected material document numbers.

Uploaded by

bablu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views16 pages

ZMIGO - Email Send With Attachment

This document contains code for an SAP report. The report contains data definitions and SQL statements to retrieve asset data from various SAP tables and populate internal tables. Field catalogs are defined to structure the output. The report will generate an output of asset data for selected material document numbers.

Uploaded by

bablu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 16

*& Report ZMIGO

*& Developed by Shivaji Banerjee


*&---------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
*
*& SAP Certified Consultant
*& mjunction physical asset insurance inlcusion
*&---------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
*

REPORT ZMIGO.
TABLES: lfa1, mseg, adr6, mkpf, ekko, ekpo, zcont_dept_data, anla, ankt.
PARAMETERS : p_attach TYPE char200 OBLIGATORY, " Select the Folder on the
Desktop from F4 help
p_subj TYPE char50 NO-DISPLAY. " Subject of the Email

DATA : t_hextab TYPE TABLE OF string,


l_file TYPE string,
t_mailhex TYPE solix_tab,
lv_count TYPE i,
gv_email TYPE adr6-smtp_addr,
t_body TYPE TABLE OF solisti1,
gr_recipient1 TYPE REF TO if_recipient_bcs,
gr_recipient2 TYPE REF TO if_recipient_bcs,
gr_recipient3 TYPE REF TO if_recipient_bcs,
gr_recipient4 TYPE REF TO if_recipient_bcs.
DATA: gr_recipient5 TYPE REF TO if_recipient_bcs.
DATA: gr_recipient6 TYPE REF TO if_recipient_bcs.
DATA: gr_recipient7 TYPE REF TO if_recipient_bcs.
DATA: gr_recipient8 TYPE REF TO if_recipient_bcs.
DATA: gr_recipient9 TYPE REF TO if_recipient_bcs.
DATA: gr_recipient10 TYPE REF TO if_recipient_bcs.
DATA: gr_recipient11 TYPE REF TO if_recipient_bcs.
DATA: gr_recipient12 TYPE REF TO if_recipient_bcs.
DATA: gr_recipient13 TYPE REF TO if_recipient_bcs.
DATA: gr_recipient14 TYPE REF TO if_recipient_bcs.
DATA: gr_recipient15 TYPE REF TO if_recipient_bcs.
DATA: gr_recipient16 TYPE REF TO if_recipient_bcs.
DATA: gr_recipient17 TYPE REF TO if_recipient_bcs.
DATA: gr_recipient18 TYPE REF TO if_recipient_bcs.
DATA: gr_recipient19 TYPE REF TO if_recipient_bcs.

DATA : tl_textpool TYPE TABLE OF textpool,


wa_textpool LIKE LINE OF tl_textpool,
it_contents TYPE soli_tab,
lv_attach_name TYPE sood-objdes,
l_subject TYPE so_obj_des,
l_document TYPE REF TO cl_document_bcs,
w_document TYPE REF TO cl_bcs,
wa_contents LIKE LINE OF it_contents,
lv_filename TYPE string,
l_result TYPE os_boolean,
lv_string TYPE string.

DATA : file_table LIKE TABLE OF sdokpath WITH HEADER LINE .


DATA : dir_table LIKE TABLE OF sdokpath WITH HEADER LINE .
DATA : file_count TYPE i ,
dircount TYPE i .

DATA: send_request TYPE REF TO cl_bcs,


i_text TYPE bcsy_text, "report internal table
tl_textpool1 TYPE TABLE OF textpool,
wa_textpool1 LIKE LINE OF tl_textpool1,
tl_textpool2 TYPE TABLE OF textpool,
wa_textpool2 LIKE LINE OF tl_textpool2,
tl_textpool3 TYPE TABLE OF textpool,
wa_textpool3 LIKE LINE OF tl_textpool3,
tl_textpool4 TYPE TABLE OF textpool,
wa_textpool4 LIKE LINE OF tl_textpool4,
date_external TYPE char20.

TYPES: BEGIN OF t_emp_dat,


dmbtr TYPE mseg-dmbtr,
menge TYPE mseg-menge,
meins type mseg-meins,
mblnr TYPE mseg-mblnr,
werks TYPE mseg-werks,
xblnr TYPE mkpf-xblnr,
waers TYPE mseg-waers,
ebeln TYPE mseg-ebeln,
ebelp TYPE mseg-ebelp,
lfbnr TYPE mseg-lfbnr,
anln1 TYPE mseg-anln1,
zzdeptnr TYPE ekko-zzdeptnr,
AEDAT type ekko-AEDAT,
* ebelp type ekko-ebelp,
dept_name TYPE zcont_dept_data-dept_name,
sgtxt TYPE mseg-sgtxt,
anlkl TYPE anla-anlkl,
txt50 TYPE anla-txt50,
txk50 TYPE ankt-txk50,
END OF t_emp_dat.

DATA: w_emp_data TYPE t_emp_dat.


DATA: i_emp_dat TYPE STANDARD TABLE OF t_emp_dat.

DATA: l_version TYPE string, " Version


l_sent_to_all TYPE os_boolean,
l_contents_line TYPE xstring, "vac53733 10642
l_i TYPE sood-objlen,
l_file_type TYPE salv_bs_constant,
l_count TYPE so_obj_len," string length of email body
l_count1 TYPE i.

DATA: document TYPE REF TO cl_document_bcs.


DATA: sender TYPE REF TO cl_sapuser_bcs.

DATA: bcs_exception TYPE REF TO cx_bcs.


DATA: lo_result_data TYPE REF TO cl_salv_ex_result_data_table.
DATA: lo_data TYPE REF TO data.

DATA: i_fldcat TYPE STANDARD TABLE OF lvc_s_fcat INITIAL SIZE 0,


"Field catalog
i_binary_content TYPE solix_tab,
i_att_head TYPE soli_tab,
i_obj_bin TYPE solix_tab, "Binary Internal Table
l_text_line TYPE soli,
l_filename TYPE string.
DATA: i_emp_data TYPE STANDARD TABLE OF t_emp_dat INITIAL SIZE 0.

FIELD-SYMBOLS: <fs_fieldcat> TYPE lvc_s_fcat. "Field catalog

SELECTION-SCREEN BEGIN OF BLOCK a WITH FRAME TITLE text-001.


SELECT-OPTIONS: grn FOR mseg-mblnr OBLIGATORY NO INTERVALS.
SELECTION-SCREEN END OF BLOCK a.

SELECT
dmbtr
a~menge
a~meins
a~mblnr
werks
a~waers
a~ebeln
ebelp
lfbnr
a~anln1
sgtxt
b~xblnr
c~zzdeptnr
c~aedat
* ebelp
d~dept_name
e~anlkl
e~txt50
f~txk50
FROM mseg
AS a INNER JOIN mkpf AS b
ON a~mblnr = b~mblnr
INNER JOIN ekko AS c
ON a~ebeln = c~ebeln
INNER JOIN zcont_dept_data AS d
ON c~zzdeptnr = d~zdeptnr
INNER JOIN anla AS e
ON a~anln1 = e~anln1
INNER JOIN ankt AS f
ON e~anlkl = f~anlkl
INTO CORRESPONDING FIELDS OF TABLE i_emp_data "UP TO 500 ROWS
WHERE a~mblnr IN grn

* *added todat 21 july, 21 at 2.39 pm


AND f~ANLKL IN ('A500000','A500001','A500004','A500010').

if sy-subrc NE 0.
** Begin of modification by Bablu on 22.08.2022 after version comparision b/w
SND and QA.
*** Old Code
* MESSAGE 'Asset Code/s is/are not insurable through this process...' TYPE 'E'.
** New Code
message 'Sorry, Asset Code/s is/are not insurable through SAP.' type 'E'.
** End of modification by Bablu on 22.08.2022 after version comparision b/w SND
and QA.
endif.
**added todat 21 july, 21 at 2.39 pm
** Preare the fieldcat for output structure.
APPEND INITIAL LINE TO i_fldcat ASSIGNING <fs_fieldcat>.
<fs_fieldcat>-no_out = ''. "Hide
<fs_fieldcat>-fieldname = 'ANLN1'. "Fieldname
<fs_fieldcat>-outputlen = 10. "Output length
<fs_fieldcat>-dd_outlen = 10. "Input length
<fs_fieldcat>-reptext = 'Asset Code'. "Column text
<fs_fieldcat>-edit = 'X'. "Edit
*<fs_fieldcat>-datatype = 'NUMC'. "Numbering zero removals

APPEND INITIAL LINE TO i_fldcat ASSIGNING <fs_fieldcat>.


<fs_fieldcat>-no_out = ''. "Hide
<fs_fieldcat>-fieldname = 'DMBTR'. "Fieldname
<fs_fieldcat>-outputlen = 2. "Output length
<fs_fieldcat>-dd_outlen = 2. "Input length
<fs_fieldcat>-reptext = 'Amount (INR)'. "Column text
<fs_fieldcat>-edit = 'X'. "Edit
<fs_fieldcat>-do_sum = 'X'. "Sum

APPEND INITIAL LINE TO i_fldcat ASSIGNING <fs_fieldcat>.


<fs_fieldcat>-no_out = ''. "Hide
<fs_fieldcat>-fieldname = 'MENGE'. "Fieldname
<fs_fieldcat>-outputlen = 3. "Output length
<fs_fieldcat>-dd_outlen = 3. "Input length
<fs_fieldcat>-reptext = 'Qty'. "Column text
<fs_fieldcat>-edit = 'X'. "Edit

APPEND INITIAL LINE TO i_fldcat ASSIGNING <fs_fieldcat>.


<fs_fieldcat>-no_out = ''. "Hide
<fs_fieldcat>-fieldname = 'MEINS'. "Fieldname
<fs_fieldcat>-outputlen = 8. "Output length
<fs_fieldcat>-dd_outlen = 8. "Input length
<fs_fieldcat>-reptext = 'UoM'. "Column text
<fs_fieldcat>-edit = 'X'. "Edit

APPEND INITIAL LINE TO i_fldcat ASSIGNING <fs_fieldcat>.


<fs_fieldcat>-no_out = ''. "Hide
<fs_fieldcat>-fieldname = 'EBELN'. "Fieldname
<fs_fieldcat>-outputlen = 10. "Output length
<fs_fieldcat>-dd_outlen = 10. "Input length
<fs_fieldcat>-reptext = 'PO No.'. "Column text
<fs_fieldcat>-edit = 'X'. "Edit

APPEND INITIAL LINE TO i_fldcat ASSIGNING <fs_fieldcat>.


<fs_fieldcat>-no_out = ''. "Hide
<fs_fieldcat>-fieldname = 'EBELP'. "Fieldname
<fs_fieldcat>-outputlen = 10. "Output length
<fs_fieldcat>-dd_outlen = 10. "Input length
<fs_fieldcat>-reptext = 'PO Item'. "Column text
<fs_fieldcat>-edit = 'X'. "Edit

APPEND INITIAL LINE TO i_fldcat ASSIGNING <fs_fieldcat>.


<fs_fieldcat>-no_out = ''. "Hide
<fs_fieldcat>-fieldname = 'AEDAT'. "Fieldname
<fs_fieldcat>-outputlen = 50. "Output length
<fs_fieldcat>-dd_outlen = 50. "Input length
<fs_fieldcat>-reptext = 'PO Date'. "Column text
<fs_fieldcat>-edit = 'X'. "Edit

APPEND INITIAL LINE TO i_fldcat ASSIGNING <fs_fieldcat>.


<fs_fieldcat>-no_out = ''. "Hide
<fs_fieldcat>-fieldname = 'SGTXT'. "Fieldname
<fs_fieldcat>-outputlen = 30. "Output length
<fs_fieldcat>-dd_outlen = 30. "Input length
<fs_fieldcat>-reptext = 'Item Description'. "Column text
<fs_fieldcat>-edit = 'X'. "Edit

APPEND INITIAL LINE TO i_fldcat ASSIGNING <fs_fieldcat>.


<fs_fieldcat>-no_out = ''. "Hide
<fs_fieldcat>-fieldname = 'WERKS'. "Fieldname
<fs_fieldcat>-outputlen = 5. "Output length
<fs_fieldcat>-dd_outlen = 5. "Input length
<fs_fieldcat>-reptext = 'Location'. "Column text
<fs_fieldcat>-edit = 'X'. "Edit

APPEND INITIAL LINE TO i_fldcat ASSIGNING <fs_fieldcat>.


<fs_fieldcat>-no_out = ''. "Hide
<fs_fieldcat>-fieldname = 'DEPT_NAME'. "Fieldname
<fs_fieldcat>-outputlen = 20. "Output length
<fs_fieldcat>-dd_outlen = 20. "Input length
<fs_fieldcat>-reptext = 'Department'. "Column text
<fs_fieldcat>-edit = 'X'. "Edit

APPEND INITIAL LINE TO i_fldcat ASSIGNING <fs_fieldcat>.


<fs_fieldcat>-no_out = ''. "Hide
<fs_fieldcat>-fieldname = 'XBLNR'. "Fieldname
<fs_fieldcat>-outputlen = 30. "Output length
<fs_fieldcat>-dd_outlen = 30. "Input length
<fs_fieldcat>-reptext = 'Invoice'. "Column text
<fs_fieldcat>-edit = 'X'. "Edit

APPEND INITIAL LINE TO i_fldcat ASSIGNING <fs_fieldcat>.


<fs_fieldcat>-no_out = ''. "Hide
<fs_fieldcat>-fieldname = 'TXT50'. "Fieldname
<fs_fieldcat>-outputlen = 50. "Output length
<fs_fieldcat>-dd_outlen = 50. "Input length
<fs_fieldcat>-reptext = 'Asset Desc.'. "Column text
<fs_fieldcat>-edit = 'X'. "Edit

APPEND INITIAL LINE TO i_fldcat ASSIGNING <fs_fieldcat>.


<fs_fieldcat>-no_out = ''. "Hide
<fs_fieldcat>-fieldname = 'ANLKL'. "Fieldname
<fs_fieldcat>-outputlen = 50. "Output length
<fs_fieldcat>-dd_outlen = 50. "Input length
<fs_fieldcat>-reptext = 'Asset Class no.'. "Column text
<fs_fieldcat>-edit = 'X'. "Edit

APPEND INITIAL LINE TO i_fldcat ASSIGNING <fs_fieldcat>.


<fs_fieldcat>-no_out = ''. "Hide
<fs_fieldcat>-fieldname = 'TXK50'. "Fieldname
<fs_fieldcat>-outputlen = 50. "Output length
<fs_fieldcat>-dd_outlen = 50. "Input length
<fs_fieldcat>-reptext = 'Asset Class'. "Column text
<fs_fieldcat>-edit = 'X'. "Edit
CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL'
EXPORTING
date_internal = sy-datum
IMPORTING
date_external = date_external
EXCEPTIONS
date_internal_is_invalid = 1.

LOOP AT i_emp_data INTO w_emp_data.


ENDLOOP.

CONCATENATE 'mj Asset Insurance Inclusion PO no.:' w_emp_data-ebeln INTO p_subj


SEPARATED BY space.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_attach.


CALL METHOD cl_gui_frontend_services=>directory_browse
CHANGING
selected_folder = lv_string
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
OTHERS = 4.

IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-
msgv3 sy-msgv4.
ELSE.
p_attach = lv_string.
ENDIF.

START-OF-SELECTION.

** CHECK IF THE FOLDER PATH IS INITIAL, IF INITIAL LEAVE THE PROGRAM, ELSE COPY THE
SUBJECT. ---> IT ALL DEPENDS ON HOW YOU VALIDATE.
IF p_attach IS INITIAL.
LEAVE LIST-PROCESSING.
ELSE.
l_subject = p_subj.
ENDIF.

** GETS ALL THE FILES NAMES IN THE SELECTED FOLDER


CALL FUNCTION 'TMP_GUI_DIRECTORY_LIST_FILES'
EXPORTING
directory = p_attach
IMPORTING
file_count = file_count
dir_count = dircount
TABLES
file_table = file_table
dir_table = dir_table
EXCEPTIONS
cntl_error = 1
OTHERS = 2.
** TELL HOW MANY FIELDS EXISTS
WRITE:/ 'no of files in the folder is : '(005), file_count.
SKIP 1.
WRITE:/ sy-uline.
WRITE:/ sy-uline.

** PROCESS THE DATA TO SEND MAIL WITH ATTACHMENT.


LOOP AT file_table. "#EC CI_SEL_NESTED "ADD ON
23-06-2022 BY ZEBA ATC CORRECTED
lv_count = sy-tabix.
CONCATENATE p_attach '\' file_table INTO lv_filename.
MOVE lv_filename TO l_file.

CALL FUNCTION 'GUI_UPLOAD'


EXPORTING
filename = l_file
filetype = 'BIN'
TABLES
data_tab = t_mailhex
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.

IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-
msgv3 sy-msgv4.
ENDIF.

* -------- create persistent send request ------------------------


send_request = cl_bcs=>create_persistent( ).

APPEND 'To,'(a01) TO i_text.


lv_count = 255.
APPEND ' '(a01) TO i_text.
lv_count = 255.
APPEND 'Salasar Services (Insurance Brokers) Pvt. Ltd.'(a01) TO i_text.
lv_count = 255.
APPEND ' '(a01) TO i_text.
lv_count = 255.
APPEND 'Dear Sir/ Madam,'(a01) TO i_text.
lv_count = 255.
APPEND ' '(a01) TO i_text.
lv_count = 255.
APPEND 'We request you to consider the inclusion of the Asset/Assets of
mjunction as per the policy.'(a01) TO i_text.
lv_count = 255.
APPEND 'Asset details mentioned in the attachment.'(a01) TO i_text.
lv_count = 255.
APPEND ' '(a01) TO i_text.
lv_count = 255.
APPEND 'For any query please contact Ms. Nitu Kedia ([email protected] )/
9163348248 and [email protected] '(a01) TO i_text.
lv_count = 255.
APPEND ' '(a01) TO i_text.
lv_count = 255.
APPEND ' '(a01) TO i_text.
lv_count = 255.
APPEND ' '(a01) TO i_text.
lv_count = 255.
APPEND 'Yours faithfully,'(a01) TO i_text.
lv_count = 255.
APPEND 'mjunction services limited'(a01) TO i_text.
lv_count = 255.
APPEND 'Phone: 033 6610 6480'(a01) TO i_text.
lv_count = 255.

* * CREATE THE DOCUMENT WITH CONTENTS


CREATE OBJECT l_document.
l_document = cl_document_bcs=>create_document( "#EC CI_IMUD_NESTED
i_type = 'RAW'
i_subject = l_subject
i_length = '1000'
i_language = sy-langu
i_importance = '1'
i_text = i_text ).

** Create data object reference.


GET REFERENCE OF i_emp_data INTO lo_data.
CLEAR: lo_result_data.
lo_result_data =
cl_salv_ex_util=>factory_result_data_table(
r_data = lo_data " internal table data reference
t_fieldcatalog = i_fldcat ).

** get the version from Abstract Super Class for All Transformations
CLEAR: l_version.
l_version = cl_salv_bs_a_xml_base=>get_version( ).

** Get the file Type * value 10 for XLSX file type


CLEAR: l_file_type.
l_file_type = if_salv_bs_xml=>c_type_xlsx.

** Transformation of data to XSTRING


CLEAR: l_contents_line.
CALL METHOD cl_salv_bs_tt_util=>if_salv_bs_tt_util~transform
EXPORTING
xml_type = l_file_type
xml_version = l_version
r_result_data = lo_result_data
* xml_flavour = l_flavour
gui_type = if_salv_bs_xml=>c_gui_type_gui
IMPORTING
xml = l_contents_line.

** Converting the table contents from xstring to binary


CLEAR i_obj_bin.
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = l_contents_line
IMPORTING
output_length = l_count1
TABLES
binary_tab = i_obj_bin.
APPEND LINES OF i_obj_bin TO i_binary_content.

** Four character file extension '.XLSX' is set


l_filename = 'MJ_ASSET_DETAILS.XLSX'. " provide the extension in file name

* You can set a file name with a freely selectable file name extension separately
from the document description. For this, use the header table
* of the document or the attachment with the key word '&SO_FILENAME='.
CONCATENATE '&SO_FILENAME=' l_filename INTO l_text_line.
APPEND l_text_line TO i_att_head.

**Calculate the xstring length


l_i = xstrlen( l_contents_line ).

** Create the attachment reference.


CALL METHOD l_document->add_attachment "#EC CI_IMUD_NESTED "ADD ON 23-06-
2022 BY ZEBA ATC CORRECTED
EXPORTING
i_attachment_type = 'BIN' " type of data
i_attachment_subject = 'MJASSET'
i_attachment_size = l_i " XTRING length of l_contents_line
i_att_content_hex = i_binary_content
i_attachment_header = i_att_head. "file details

** * ATTACH THE FILE, THE ATTACHMENT TYPE SHOULD BE BIN TO ACCEPT ANY KIND OF
ATTACHMENT, INCLUDING VIDEOS, AUDIO FILES ETC...
lv_attach_name = file_table.
CALL METHOD l_document->add_attachment "#EC CI_IMUD_NESTED "ADD ON
23-06-2022 BY ZEBA ATC CORRECTED
EXPORTING
i_attachment_type = 'BIN'
i_attachment_subject = lv_attach_name
i_att_content_hex = t_mailhex.

* * CREATING PERSISTENT OBJECT WILL ALLOW YOU TO SET THE DOCUMENT IN THE MAIL
w_document = cl_bcs=>create_persistent( ).
CALL METHOD w_document->set_document( l_document ). "#EC
CI_IMUD_NESTED "ADD ON 23-06-2022 BY ZEBA ATC CORRECTED

* * EMAIL AS GIVEN IN THE SELECTION SCREEN.


if w_emp_data-zzdeptnr = '001'. "If Department is Technology

gr_recipient1 =
cl_cam_address_bcs=>create_internet_address( '[email protected]' ).
"Add recipient to send request
call method w_document->add_recipient
exporting
i_recipient = gr_recipient1
i_express = 'X'
i_copy = 'X'.

gr_recipient2 =
cl_cam_address_bcs=>create_internet_address( '[email protected]' ).
"Add recipient to send request
call method w_document->add_recipient
exporting
i_recipient = gr_recipient2
i_express = 'X'
i_copy = 'X'.

gr_recipient3 =
cl_cam_address_bcs=>create_internet_address( '[email protected]' ).
"Add recipient to send request
call method w_document->add_recipient
exporting
i_recipient = gr_recipient3
i_express = 'X'
i_copy = 'X'.

gr_recipient4 =
cl_cam_address_bcs=>create_internet_address( '[email protected]' ).
"Add recipient to send request
call method w_document->add_recipient
exporting
i_recipient = gr_recipient4
i_express = 'X'
i_copy = 'X'.

gr_recipient5 =
cl_cam_address_bcs=>create_internet_address( '[email protected]' ).
"Add recipient to send request
call method w_document->add_recipient
exporting
i_recipient = gr_recipient5
i_express = 'X'
i_copy = 'X'.

gr_recipient6 =
cl_cam_address_bcs=>create_internet_address( '[email protected]' ).
"Add recipient to send request
call method w_document->add_recipient
exporting
i_recipient = gr_recipient6
i_express = 'X'
i_copy = 'X'.
gr_recipient7 =
cl_cam_address_bcs=>create_internet_address( '[email protected]' ).
"Add recipient to send request
call method w_document->add_recipient
exporting
i_recipient = gr_recipient7
i_express = 'X'
i_copy = 'X'.

gr_recipient8 =
cl_cam_address_bcs=>create_internet_address( '[email protected]' ).
"Add recipient to send request
call method w_document->add_recipient
exporting
i_recipient = gr_recipient8
i_express = 'X'
i_copy = 'X'.

gr_recipient9 =
cl_cam_address_bcs=>create_internet_address( '[email protected]' ).
"Add recipient to send request
call method w_document->add_recipient
exporting
i_recipient = gr_recipient9
i_express = 'X'
i_copy = 'X'.

gr_recipient10 =
cl_cam_address_bcs=>create_internet_address( '[email protected]' ).
"Add recipient to send request
call method w_document->add_recipient
exporting
i_recipient = gr_recipient10
i_express = 'X'
i_copy = 'X'.

gr_recipient11 =
cl_cam_address_bcs=>create_internet_address( '[email protected]' ).
"Add recipient to send request
call method w_document->add_recipient
exporting
i_recipient = gr_recipient11
i_express = 'X'
i_copy = 'X'.

gr_recipient16 =
cl_cam_address_bcs=>create_internet_address( '[email protected]' ).
"Add recipient to send request
call method w_document->add_recipient
exporting
i_recipient = gr_recipient16
i_express = 'X'
i_copy = 'X'.

gr_recipient17 =
cl_cam_address_bcs=>create_internet_address( '[email protected]' ).
"Add recipient to send request
call method w_document->add_recipient
exporting
i_recipient = gr_recipient17
i_express = 'X'
i_copy = 'X'.

gr_recipient19 =
cl_cam_address_bcs=>create_internet_address( '[email protected]' ).
"Add recipient to send request
call method w_document->add_recipient
exporting
i_recipient = gr_recipient19
i_express = 'X'
i_copy = 'X'.

* gr_recipient12 =
cl_cam_address_bcs=>create_internet_address( '[email protected]'
)."(-)
gr_recipient12 =
cl_cam_address_bcs=>create_internet_address( '[email protected]' )."(+)
Added by Bablu on 29.09.2022
"Add recipient to send request
call method w_document->add_recipient
exporting
i_recipient = gr_recipient12
i_express = 'X'
i_copy = 'X'.

* gr_recipient13 =
cl_cam_address_bcs=>create_internet_address( '[email protected]'
)."(-)
gr_recipient13 =
cl_cam_address_bcs=>create_internet_address( '[email protected]' )
."(+) Added by Bablu on 29.09.2022
"Add recipient to send request
call method w_document->add_recipient
exporting
i_recipient = gr_recipient13
i_express = 'X'
i_copy = 'X'.

* gr_recipient14 =
cl_cam_address_bcs=>create_internet_address( '[email protected]' )."(-)
gr_recipient14 =
cl_cam_address_bcs=>create_internet_address( '[email protected]' )."(+)
Added by Bablu on 29.09.2022
"Add recipient to send request
call method w_document->add_recipient
exporting
i_recipient = gr_recipient14
i_express = 'X'.

* gr_recipient15 =
cl_cam_address_bcs=>create_internet_address( '[email protected]' )."(-)
gr_recipient15 =
cl_cam_address_bcs=>create_internet_address( '[email protected]' )."(+)
Added by Bablu on 29.09.2022
"Add recipient to send request
call method w_document->add_recipient
exporting
i_recipient = gr_recipient15
i_express = 'X'.

gr_recipient18 =
cl_cam_address_bcs=>create_internet_address( '[email protected]' )."(+) Added by
Bablu on 29.09.2022
"Add recipient to send request
call method w_document->add_recipient
exporting
i_recipient = gr_recipient15
i_express = 'X'.

endif.

* " If Department is except Technology


gr_recipient1 =
cl_cam_address_bcs=>create_internet_address( '[email protected]' ).
"Add recipient to send request
call method w_document->add_recipient
exporting
i_recipient = gr_recipient1
i_express = 'X'
i_copy = 'X'.

* gr_recipient2 =
cl_cam_address_bcs=>create_internet_address( '[email protected]' ).
* "Add recipient to send request
* CALL METHOD w_document->add_recipient
* EXPORTING
* i_recipient = gr_recipient2
* i_express = 'X'
* i_copy = 'X'.

gr_recipient3 =
cl_cam_address_bcs=>create_internet_address( '[email protected]' ).
"Add recipient to send request
call method w_document->add_recipient
exporting
i_recipient = gr_recipient3
i_express = 'X'
i_copy = 'X'.

gr_recipient4 =
cl_cam_address_bcs=>create_internet_address( '[email protected]' ).
"Add recipient to send request
call method w_document->add_recipient
exporting
i_recipient = gr_recipient4
i_express = 'X'
i_copy = 'X'.

gr_recipient5 =
cl_cam_address_bcs=>create_internet_address( '[email protected]' ).
"Add recipient to send request
call method w_document->add_recipient
exporting
i_recipient = gr_recipient5
i_express = 'X'
i_copy = 'X'.

gr_recipient6 =
cl_cam_address_bcs=>create_internet_address( '[email protected]' ).
"Add recipient to send request
call method w_document->add_recipient
exporting
i_recipient = gr_recipient6
i_express = 'X'
i_copy = 'X'.

gr_recipient7 =
cl_cam_address_bcs=>create_internet_address( '[email protected]' ).
"Add recipient to send request
call method w_document->add_recipient
exporting
i_recipient = gr_recipient7
i_express = 'X'
i_copy = 'X'.

gr_recipient8 =
cl_cam_address_bcs=>create_internet_address( '[email protected]' ).
"Add recipient to send request
call method w_document->add_recipient
exporting
i_recipient = gr_recipient8
i_express = 'X'
i_copy = 'X'.

gr_recipient9 =
cl_cam_address_bcs=>create_internet_address( '[email protected]' ).
"Add recipient to send request
call method w_document->add_recipient
exporting
i_recipient = gr_recipient9
i_express = 'X'
i_copy = 'X'.

gr_recipient10 =
cl_cam_address_bcs=>create_internet_address( '[email protected]' ).
"Add recipient to send request
call method w_document->add_recipient
exporting
i_recipient = gr_recipient10
i_express = 'X'
i_copy = 'X'.

* gr_recipient11 =
cl_cam_address_bcs=>create_internet_address( '[email protected]' ).
* "Add recipient to send request
* CALL METHOD w_document->add_recipient
* EXPORTING
* i_recipient = gr_recipient11
* i_express = 'X'
* i_copy = 'X'.
gr_recipient16 =
cl_cam_address_bcs=>create_internet_address( '[email protected]' ).
"Add recipient to send request
call method w_document->add_recipient
exporting
i_recipient = gr_recipient16
i_express = 'X'
i_copy = 'X'.

gr_recipient17 =
cl_cam_address_bcs=>create_internet_address( '[email protected]' ).
"Add recipient to send request
call method w_document->add_recipient
exporting
i_recipient = gr_recipient17
i_express = 'X'
i_copy = 'X'.

gr_recipient19 =
cl_cam_address_bcs=>create_internet_address( '[email protected]' ).
"Add recipient to send request
call method w_document->add_recipient
exporting
i_recipient = gr_recipient19
i_express = 'X'
i_copy = 'X'.

* gr_recipient12 =
cl_cam_address_bcs=>create_internet_address( '[email protected]'
)."(-)
gr_recipient12 =
cl_cam_address_bcs=>create_internet_address( '[email protected]' )."(+)Chan
ged the emial ID as per business requirements
"Add recipient to send request
call method w_document->add_recipient
exporting
i_recipient = gr_recipient12
i_express = 'X'
i_copy = 'X'.

* gr_recipient13 =
cl_cam_address_bcs=>create_internet_address( '[email protected]'
)."(-)Changed the emial ID as per business requirements
gr_recipient13 =
cl_cam_address_bcs=>create_internet_address( '[email protected]' )
."(+)Changed the emial ID as per business requirements
"Add recipient to send request
call method w_document->add_recipient
exporting
i_recipient = gr_recipient13
i_express = 'X'
i_copy = 'X'.

* gr_recipient14 =
cl_cam_address_bcs=>create_internet_address( '[email protected]' )."(-)Ch
anged the emial ID as per business requirements
gr_recipient14 =
cl_cam_address_bcs=>create_internet_address( '[email protected]' )."(+)
Changed the emial ID as per business requirements
"Add recipient to send request
call method w_document->add_recipient
exporting
i_recipient = gr_recipient14
i_express = 'X'.

* gr_recipient15 =
cl_cam_address_bcs=>create_internet_address( '[email protected]' )."(-)Chan
ged the emial ID as per business requirements
gr_recipient15 =
cl_cam_address_bcs=>create_internet_address( '[email protected]' )."(+)Ch
anged the emial ID as per business requirements
"Add recipient to send request
call method w_document->add_recipient
exporting
i_recipient = gr_recipient15
i_express = 'X'.

gr_recipient11 =
cl_cam_address_bcs=>create_internet_address( '[email protected]' )."(+) Added
email id as per business requirement.
"Add recipient to send request
CALL METHOD w_document->add_recipient
EXPORTING
i_recipient = gr_recipient11
i_express = 'X'
i_copy = 'X'.

** SEND THE MAIL


CALL METHOD w_document->send(
EXPORTING
i_with_error_screen = 'X'
RECEIVING
result = l_result ).

** YOU CAN VERIFY THE STATUS IN THE LIST, YOU CAN ALSO SUBMIT THIS AS A BACKGROUND
JOB.
IF l_result = 'X'.
WRITE :/ , 1(9) lv_count, 10(55) file_table-pathname.
WRITE : 56(1) '-', 58(20) 'mail sent for insurance'(003).
COMMIT WORK.
ELSE.
WRITE :/ , 1(9) lv_count, 10(55) file_table-pathname.
WRITE : 56(1) '-', 58(30) 'Error in sending mail'(004).
ROLLBACK WORK.
ENDIF.
REFRESH it_contents[].
ENDLOOP.

You might also like