NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

METHOD zfsif_email~blotter.
*&----------------------------------------------------------------------*
* Class Name : ZFS_CL_EMAIL *
* Technical consultant : Aatif Shaikh *
* Functional Consultant : *
* Date of Creation : 03.05.2023 *
* Transport Request No : ECDK9A0DEC *
* FS Document Number : *
* TS Document Number : *
* Description : FX email *
*&----------------------------------------------------------------------*
*&----------------------------------------------------------------------*

* Constants
CONSTANTS: c_ottk(5) TYPE c VALUE 'NOP',
c_u TYPE c VALUE '_'.
CONSTANTS: c_02(2) VALUE '02',
c_m VALUE 'M',
c_i VALUE 'I',
c_na(3) VALUE 'N.A',
c_04(2) VALUE '01',
c_e001(4) VALUE 'E001',
c_es(10) VALUE 'Email Sent',
c_htm(3) VALUE 'HTM',
c_dd(17) VALUE 'Deliverable Deals',
c_ndd(21) VALUE 'Non Deliverable Deals'.

* Internal table
TYPES: BEGIN OF ty_mail_id,
send TYPE adr6-smtp_addr,
END OF ty_mail_id.

FIELD-SYMBOLS: <fs_data> TYPE STANDARD TABLE.

DATA: gt_fcat TYPE lvc_t_fcat,
gs_fcat TYPE lvc_s_fcat.

* Declaration
DATA: send_request TYPE REF TO cl_bcs,
text TYPE bcsy_text,
ftext TYPE bcsy_text, "" to store the fieldcatalog text
dtext TYPE bcsy_text, "" to store the internal text
body_text TYPE so_text255,
document TYPE REF TO cl_document_bcs,
sender TYPE REF TO cl_sapuser_bcs,
recipient TYPE REF TO if_recipient_bcs,
bcs_exception TYPE REF TO cx_bcs,
sent_to_all TYPE os_boolean,
lv_sub TYPE char50.


* Declaration for the Dynamic Values in text
DATA: lv_amt TYPE c LENGTH 25,
lv_amount TYPE tb_limit_amount,
lv_lines TYPE i,
lv_so_obj_len TYPE so_obj_len,
lv_subject TYPE string.

* Other e-mail technique to do the declarations
DATA : it_message TYPE STANDARD TABLE OF solisti1,
wa_message TYPE solisti1,
lt_mfcat TYPE STANDARD TABLE OF solisti1, "" to store the fieldcatalog structure in html header
lt_mdata TYPE STANDARD TABLE OF solisti1, "" to store the internal table data in html body
it_attach TYPE STANDARD TABLE OF solisti1,
wa_attach TYPE solisti1,
t_receivers TYPE STANDARD TABLE OF somlreci1,
wa_receivers TYPE somlreci1,
w_doc_data TYPE sodocchgi1.

DATA: lt_to TYPE TABLE OF ty_mail_id,
lt_cc TYPE TABLE OF ty_mail_id.

DATA: v_waers TYPE waers VALUE 'USD',
flag(1) TYPE c.

DATA: new_line TYPE REF TO data.

**----------------------------------------------------------------------------------------*
** Send an e-mail to a e-mail ID on settlemnt execution
**----------------------------------------------------------------------------------------*
*
**--------------------------------------------------------------------*
** Start of data selection
**--------------------------------------------------------------------*

ASSIGN it_data TO <fs_data>.

gt_fcat = CORRESPONDING #( it_fcat MAPPING fieldname = fieldname
scrtext_m = scrtext_m ).


DELETE gt_fcat WHERE fieldname = 'TYPE'.
DELETE gt_fcat WHERE fieldname = 'COLOR'.

" Email details
SELECT SINGLE zcat,
zecode,
ztemp_id,
zto1,
zcc1
FROM zfs_frx_emlbd
INTO @DATA(ls_emlbd)
WHERE zcat EQ @c_04
AND zecode EQ @c_e001.

* Preparing TO-CC List
CLEAR lt_to .
SPLIT ls_emlbd-zto1 AT ';' INTO TABLE lt_to .
CLEAR lt_cc .
SPLIT ls_emlbd-zcc1 AT ';' INTO TABLE lt_cc .

**--------------------------------------------------------------------*
** End of selection
**--------------------------------------------------------------------*
*
TRY.
* -------- create persistent send request ------------------------
send_request = cl_bcs=>create_persistent( ).
** -------- create and set document -------------------------------
*
**--------------------------------------------------------------------*
** Start the Mail Body
**--------------------------------------------------------------------*

CLEAR: body_text, wa_message.
CONCATENATE body_text
'<html><style>*{font-family: Calibri;}table,td{border-collapse:collapse;height: 20px;border: 1px solid #000;border-color: black;font-size:16px;white-space: nowrap}'
INTO body_text.
APPEND body_text TO text.
wa_message-line = body_text.
APPEND wa_message TO it_message.

CLEAR: body_text, wa_message.
CONCATENATE body_text
'body{padding: 25px 10px 75px 10px;}.Grey{background-color:#d8d8d8;font-size:10px;font-weight : bold;}</style><meta name="generator" content="HTML Tidy for HTML5 for ABAP version 5.6.0">'
INTO body_text.
APPEND body_text TO text.
wa_message-line = body_text.
APPEND wa_message TO it_message.

CLEAR: body_text, wa_message.
CONCATENATE body_text
'<body><p>Dear User,</p>'
INTO body_text SEPARATED BY space .
APPEND body_text TO text.
wa_message-line = body_text.
APPEND wa_message TO it_message.

SELECT SINGLE butxt FROM t001 INTO @DATA(c_name) WHERE bukrs = @p_bukrs.
CASE p_tcode.
WHEN 'ZFS_FRX001'.
CONCATENATE 'Exposure Creation Small Projects' p_bukrs c_name INTO lv_sub SEPARATED BY space.

CLEAR : body_text, wa_message.
CASE p_type.
WHEN 'EXC-BL'.
CONCATENATE body_text
' <p> Create BL - ' p_bukrs '</p><p> Exposure Category - ' exp_cat '</p><p> Date :' p_date+6(2) '.' p_date+4(2) '.' p_date+0(4) '</p><br><br /><table><thead class = "Grey">'
INTO body_text SEPARATED BY space .
WHEN 'EXC-LC'.
CONCATENATE body_text
' <p> Create LC - ' p_bukrs '</p><p> Exposure Category - ' exp_cat '</p><p> Date :' p_date+6(2) '.' p_date+4(2) '.' p_date+0(4) '</p><br><br /><table><thead class = "Grey">'
INTO body_text SEPARATED BY space .
WHEN 'EXC-PO'.
CONCATENATE body_text
' <p> Create PO - ' p_bukrs '</p><p> Exposure Category - ' exp_cat '</p><p> Date :' p_date+6(2) '.' p_date+4(2) '.' p_date+0(4) '</p><br><br /><table><thead class = "Grey">'
INTO body_text SEPARATED BY space .
WHEN 'UPDATE-BL'.
CONCATENATE body_text
' <p> Update BL - ' p_bukrs '</p><p> Exposure Category - ' exp_cat '</p><p> Date :' p_date+6(2) '.' p_date+4(2) '.' p_date+0(4) '</p><br><br /><table><thead class = "Grey">'
INTO body_text SEPARATED BY space .
WHEN 'UPDATE-LC'.
CONCATENATE body_text
' <p> Update LC - ' p_bukrs '</p><p> Exposure Category - ' exp_cat '</p><p> Date :' p_date+6(2) '.' p_date+4(2) '.' p_date+0(4) '</p><br><br /><table><thead class = "Grey">'
INTO body_text SEPARATED BY space .
WHEN 'UPDATE-PO'.
CONCATENATE body_text
' <p> Update PO - ' p_bukrs '</p><p> Exposure Category - ' exp_cat '</p><p> Date :' p_date+6(2) '.' p_date+4(2) '.' p_date+0(4) '</p><br><br /><table><thead class = "Grey">'
INTO body_text SEPARATED BY space .
ENDCASE.
APPEND body_text TO text.
wa_message-line = body_text.

APPEND wa_message TO it_message.
WHEN 'ZFS_FRX004'.
CONCATENATE 'Exposure Creation Large Projects' p_bukrs c_name INTO lv_sub SEPARATED BY space.
CLEAR: body_text, wa_message.
CASE p_type.
WHEN 'CREATE'.
CONCATENATE body_text
' <p> Create BID - ' p_bukrs '</p><p> Exposure Category - ' exp_cat '</p><p> Date :' p_date+6(2) '.' p_date+4(2) '.' p_date+0(4) '</p><br><br /><table><thead class = "Grey">'
INTO body_text SEPARATED BY space .
WHEN 'UPD'.
CONCATENATE body_text
' <p> Change BID - ' p_bukrs '</p><p> Exposure Category - ' exp_cat '</p><p> Date :' p_date+6(2) '.' p_date+4(2) '.' p_date+0(4) '</p><br><br /><table><thead class = "Grey">'
INTO body_text SEPARATED BY space .
WHEN 'SAVE'.
CONCATENATE body_text
' <p> Cashflow Created - ' p_bukrs '</p><p> Exposure Category - ' exp_cat '</p><p> Date :' p_date+6(2) '.' p_date+4(2) '.' p_date+0(4) '</p><br><br /><table><thead class = "Grey">'
INTO body_text SEPARATED BY space .
WHEN 'UPDATE'.
CONCATENATE body_text
' <p> Cashflow Updated - ' p_bukrs '</p><p> Exposure Category - ' exp_cat '</p><p> Date :' p_date+6(2) '.' p_date+4(2) '.' p_date+0(4) '</p><br><br /><table><thead class = "Grey">'
INTO body_text SEPARATED BY space .
WHEN 'LOA Received'.
CONCATENATE body_text
' <p> LOA Recieved - ' p_bukrs '</p><p> Exposure Category - ' exp_cat '</p><p> Date :' p_date+6(2) '.' p_date+4(2) '.' p_date+0(4) '</p><br><br /><table><thead class = "Grey">'
INTO body_text SEPARATED BY space .
WHEN 'Project Cancelled'.
CONCATENATE body_text
' <p> LOA Project Cancelled - ' p_bukrs '</p><p> Exposure Category - ' exp_cat '</p><p> Date :' p_date+6(2) '.' p_date+4(2) '.' p_date+0(4) '</p><br><br /><table><thead class = "Grey">'
INTO body_text SEPARATED BY space .
WHEN 'UPD LOA'.
CONCATENATE body_text
' <p> LOA Updated - ' p_bukrs '</p><p> Exposure Category - ' exp_cat '</p><p> Date :' p_date+6(2) '.' p_date+4(2) '.' p_date+0(4) '</p><br><br /><table><thead class = "Grey">'
INTO body_text SEPARATED BY space .
ENDCASE.
APPEND body_text TO text.
wa_message-line = body_text.
APPEND wa_message TO it_message. .
WHEN 'ZFS_FRX002'.
CONCATENATE 'Forward Blotter' p_bukrs c_name INTO lv_sub SEPARATED BY space.
CLEAR: body_text, wa_message.
CASE p_type.
WHEN 'CREATE'.
CONCATENATE body_text
' <p> Create Forward - ' p_bukrs '</p><p> Date :' p_date+6(2) '.' p_date+4(2) '.' p_date+0(4) '</p><br><br /><table><thead class = "Grey">'
INTO body_text SEPARATED BY space .
WHEN 'SAVE'.
CONCATENATE body_text
' <p> Change Forward - ' p_bukrs '</p><p> Date :' p_date+6(2) '.' p_date+4(2) '.' p_date+0(4) '</p><br><br /><table><thead class = "Grey">'
INTO body_text SEPARATED BY space .
WHEN 'EXP'.
CONCATENATE body_text
' <p> Forward Exposure Linkage - ' p_bukrs '</p><p> Date :' p_date+6(2) '.' p_date+4(2) '.' p_date+0(4) '</p><br><br /><table><thead class = "Grey">'
INTO body_text SEPARATED BY space .
ENDCASE.
APPEND body_text TO text.
wa_message-line = body_text.
APPEND wa_message TO it_message. .
WHEN 'ZFS_FRX012'.
CONCATENATE 'Option Blotter' p_bukrs c_name INTO lv_sub SEPARATED BY space.
CLEAR: body_text, wa_message.
CASE p_type.
WHEN 'CREATE'.
CONCATENATE body_text
' <p> Create Forward - ' p_bukrs '</p><p> Date :' p_date+6(2) '.' p_date+4(2) '.' p_date+0(4) '</p><br><br /><table><thead class = "Grey">'
INTO body_text SEPARATED BY space .
WHEN 'SAVE'.
CONCATENATE body_text
' <p> Change Forward - ' p_bukrs '</p><p> Date :' p_date+6(2) '.' p_date+4(2) '.' p_date+0(4) '</p><br><br /><table><thead class = "Grey">'
INTO body_text SEPARATED BY space .
WHEN 'EXP'.
CONCATENATE body_text
' <p> Option Exposure Linkage - ' p_bukrs '</p><p> Date :' p_date+6(2) '.' p_date+4(2) '.' p_date+0(4) '</p><br><br /><table><thead class = "Grey">'
INTO body_text SEPARATED BY space .
ENDCASE.
APPEND body_text TO text.
wa_message-line = body_text.
APPEND wa_message TO it_message. .
WHEN OTHERS.
ENDCASE.

CLEAR: body_text, wa_message.
CONCATENATE body_text
'<tr>'
INTO body_text.
APPEND body_text TO text.
wa_message-line = body_text.
APPEND wa_message TO it_message.

CLEAR: body_text, wa_message.
CONCATENATE body_text
'<tbody>'
INTO body_text.
APPEND body_text TO dtext.
wa_message-line = body_text.
APPEND wa_message TO lt_mdata.

LOOP AT <fs_data> ASSIGNING FIELD-SYMBOL(<fs_temp>).

* ASSIGN COMPONENT 'PAIR' OF STRUCTURE <fs_temp> TO FIELD-SYMBOL(<fs_pair>).
* IF sy-subrc = 0.
* IF <fs_pair> = c_dd OR <fs_pair> = c_ndd. "" for coloring the Deliverable and Non Deliverable Deals
CLEAR: body_text, wa_message.
CONCATENATE body_text
'<tr bgcolor="yellow">'
INTO body_text.
APPEND body_text TO dtext.
wa_message-line = body_text.
APPEND wa_message TO lt_mdata.
* ELSE.
* CLEAR: body_text, wa_message.
* CONCATENATE body_text
* '<tr>'
* INTO body_text.
* APPEND body_text TO dtext.
* wa_message-line = body_text.
* APPEND wa_message TO lt_mdata.
* ENDIF.

lv_lines = lv_lines + 1.
LOOP AT gt_fcat ASSIGNING FIELD-SYMBOL(<fs_fcat>).

ASSIGN COMPONENT <fs_fcat>-fieldname OF STRUCTURE <fs_temp> TO FIELD-SYMBOL(<f_1>).
* IF <fs_pair> IS INITIAL.
* lv_amount = <f_1>.
* WRITE lv_amount TO lv_amt
* CURRENCY v_waers.
* CONDENSE: lv_amt.
* ELSE.
WRITE <f_1> TO lv_amt.
* CURRENCY v_waers.
CONDENSE: lv_amt.
** ENDIF.
* IF lv_amt = '0.00' OR lv_amt = '0'.
* CLEAR lv_amt.
* ENDIF.

CLEAR: body_text, wa_message.
CONCATENATE body_text
'<td>' lv_amt '</td>'
INTO body_text.
APPEND body_text TO dtext.
wa_message-line = body_text.
APPEND wa_message TO lt_mdata.

IF lv_lines = 1.
CLEAR: body_text, wa_message.
CONCATENATE body_text
'<td>' <fs_fcat>-scrtext_m '</td>'
INTO body_text.
APPEND body_text TO ftext.
wa_message-line = body_text.
APPEND wa_message TO lt_mfcat.
ENDIF.

ENDLOOP.
* ENDIF.

CLEAR: body_text, wa_message.
CONCATENATE body_text
'</tr>'
INTO body_text.
APPEND body_text TO dtext.
wa_message-line = body_text.
APPEND wa_message TO lt_mdata.

ENDLOOP.

APPEND LINES OF ftext TO text.
APPEND LINES OF lt_mfcat TO it_message.

CLEAR: body_text, wa_message.
CONCATENATE body_text
'</tr></thead>'
INTO body_text.
APPEND body_text TO text.
wa_message-line = body_text.
APPEND wa_message TO it_message.

CLEAR: body_text, wa_message.
CONCATENATE body_text
'</tr></tbody>'
INTO body_text.
APPEND body_text TO dtext.
wa_message-line = body_text.
APPEND wa_message TO lt_mdata.

APPEND LINES OF dtext TO text.
APPEND LINES OF lt_mdata TO it_message.

CLEAR: body_text, wa_message.
CONCATENATE body_text
'</table> <p>Regards,</p></body></html>'
INTO body_text.
APPEND body_text TO text.
wa_message-line = body_text.
APPEND wa_message TO it_message."}


**--------------------------------------------------------------------*
** End of HTML Code Body
**--------------------------------------------------------------------*
*
* Calculate the Document Size
CLEAR: lv_lines, lv_so_obj_len.
DESCRIBE TABLE it_message LINES lv_lines.
TRY .
lv_so_obj_len = 255 * lv_lines.
CATCH cx_sy_arithmetic_overflow.
ENDTRY."}

* Create the Document
document = cl_document_bcs=>create_document(
i_type = c_htm
i_text = text
i_length = lv_so_obj_len
i_subject = lv_sub ).

MOVE lv_sub TO lv_subject.

CALL METHOD send_request->set_message_subject
EXPORTING
ip_subject = lv_subject.

* Add document to send request
CALL METHOD send_request->set_document( document ).
** --------- set sender -------------------------------------------
** note: this is necessary only if you want to set the sender
** different from actual user (SY-UNAME). Otherwise sender is
** set automatically with actual user.
sender = cl_sapuser_bcs=>create( sy-uname ).
CALL METHOD send_request->set_sender
EXPORTING
i_sender = sender.
** --------- Add recipient (e-mail address) -----------------------
*
* Set Email Receiver(s) (TO)
LOOP AT lt_to ASSIGNING FIELD-SYMBOL(<fs_to>).
TRY. recipient = cl_cam_address_bcs=>create_internet_address( <fs_to>-send ). CATCH cx_address_bcs. ENDTRY.
TRY. send_request->add_recipient( EXPORTING i_recipient = recipient i_express = 'X'). CATCH cx_send_req_bcs . ENDTRY.
ENDLOOP.

* Set Email Receiver(s) (CC)
LOOP AT lt_cc ASSIGNING FIELD-SYMBOL(<fs_cc>).
TRY. recipient = cl_cam_address_bcs=>create_internet_address( <fs_cc>-send ). CATCH cx_address_bcs. ENDTRY.
TRY. send_request->add_recipient( EXPORTING i_recipient = recipient i_express = 'X' i_copy = 'X' ). CATCH cx_send_req_bcs . ENDTRY.
ENDLOOP.

* Add recipient with its respective attributes to send request
CALL METHOD send_request->add_recipient
EXPORTING
i_recipient = recipient
i_express = 'X'.

* ---------- Send document ---------------------------------------
TRY.
send_request->set_send_immediately( 'X' ).
CALL METHOD send_request->send(
EXPORTING
i_with_error_screen = 'X'
RECEIVING
result = sent_to_all ).
CATCH cx_send_req_bcs.
CATCH cx_address_bcs.
CATCH cx_sy_no_handler.
CATCH cx_sy_ref_is_initial.
ENDTRY.

COMMIT WORK AND WAIT.

* MESSAGE c_es TYPE c_i.

* ENDIF.
*
** -----------------------------------------------------------
** * exception handling
** -----------------------------------------------------------
CATCH cx_bcs INTO bcs_exception.
ENDTRY.

ENDMETHOD.





Field name
ZCAT
ZECODE
ZSUBJECT
ZDESC
ZNOTE
ZTEMP_ID
ZTO1
ZCC1
ZOID
ZNID
ZFNAME
ZNORNG

Data element

MANDT
CHAR2
CHAR10
CHAR50
CHAR100
CHAR100
CHAR30
ZFSDM_TO_LIST
ZFSDM_CC_LIST
CHAR40
CHAR255
CHAR30
CHAR10




     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.