Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Mail With Table Abap

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 14

FUNCTION zmd11fm_mail.

*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(PLAF) TYPE PLAF
*"----------------------------------------------------------------------

DATA : doc_data TYPE sodocchgi1,


it_pack TYPE STANDARD TABLE OF sopcklsti1,
wa_pack TYPE sopcklsti1,
it_contents TYPE STANDARD TABLE OF solisti1,
wa_contents TYPE solisti1,
it_recv TYPE STANDARD TABLE OF somlreci1 WITH HEADER LINE,
wa_recv TYPE somlreci1,
tab_lines TYPE i.
DATA: subject(70).
* data: lt_final type table of zqm_supt.

* data: lv_final type zqm_supt ,


DATA: lv_vendor TYPE adrnr,
lv_mailid TYPE ad_smtpadr.
DATA : obj_key TYPE swotobjid-objkey,
cls_name TYPE bapibds01-classname.
DATA : lt_gos TYPE TABLE OF bdn_con,
wa_gos TYPE bdn_con.

DATA : gc_307 TYPE i VALUE '307',


gc_308 TYPE i VALUE '308',
gv_msg_no TYPE i.

CLEAR : lv_vendor, lv_mailid , it_contents[] .


CONSTANTS: lc_1 TYPE c VALUE '1',
lc_planned_order TYPE char25 VALUE 'PLANNED ORDER',
lc_2 TYPE c VALUE '2',
lc_material TYPE char25 VALUE 'MATERIAL',
lc_3 TYPE c VALUE '3',
lc_mat_des TYPE char25 VALUE 'MATERIAL DESCRIPTION',
lc_4 TYPE c VALUE '4',
lc_plan_plant TYPE char25 VALUE 'PLANNING PLANT',
lc_5 TYPE c VALUE '5',
lc_order_qty TYPE char25 VALUE 'ORDER QTY',
lc_6 TYPE c VALUE '6',
lc_unit TYPE char25 VALUE 'UNIT',
lc_7 TYPE c VALUE '7',
lc_wbs_element TYPE char25 VALUE 'WBS ELEMENT',
lc_8 TYPE c VALUE '8',
lc_remarks TYPE char25 VALUE 'REMARKS',
lc_9 TYPE c VALUE '9',
lc_dot TYPE c VALUE '.',
lc_user_name TYPE char25 VALUE 'USER NAME'.

SELECT SINGLE * FROM zmd11t_mail INTO @DATA(w_zmd11t_mail) WHERE werks = @plaf-


plwrk.

IF w_zmd11t_mail-to_mail IS NOT INITIAL.


wa_recv-receiver = w_zmd11t_mail-to_mail.
wa_recv-rec_type = 'U'.
APPEND wa_recv TO it_recv.
ENDIF.
IF w_zmd11t_mail-cc_mail1 IS NOT INITIAL.
* w_reclist-receiver = w_ZMD11T_MAIL-cc_mail1.
wa_recv-receiver = w_zmd11t_mail-cc_mail1.
wa_recv-rec_type = 'U'.
wa_recv-copy = 'X'.
APPEND wa_recv TO it_recv.
ENDIF.
IF w_zmd11t_mail-cc_mail2 IS NOT INITIAL.
wa_recv-receiver = w_zmd11t_mail-cc_mail2.
wa_recv-rec_type = 'U'.
wa_recv-copy = 'X'.
APPEND wa_recv TO it_recv.
ENDIF.
IF w_zmd11t_mail-cc_mail3 IS NOT INITIAL.
wa_recv-receiver = w_zmd11t_mail-cc_mail3.
wa_recv-rec_type = 'U'.
wa_recv-copy = 'X'.
APPEND wa_recv TO it_recv.
ENDIF.
IF w_zmd11t_mail-cc_mail4 IS NOT INITIAL.
wa_recv-receiver = w_zmd11t_mail-cc_mail4.
wa_recv-rec_type = 'U'.
wa_recv-copy = 'X'.
APPEND wa_recv TO it_recv.
ENDIF.
IF w_zmd11t_mail-cc_mail5 IS NOT INITIAL.
wa_recv-receiver = w_zmd11t_mail-cc_mail5.
wa_recv-rec_type = 'U'.
wa_recv-copy = 'X'.
wa_recv-blind_copy = 'X'.
APPEND wa_recv TO it_recv.
ENDIF.

DATA: w_plaf TYPE plaf.


DATA:text TYPE char100.
DATA:var1 TYPE char10.
DATA:var2 TYPE char25.

CONCATENATE 'Planned Order Details' '' INTO subject SEPARATED BY space.

doc_data-priority = 1.
doc_data-obj_descr = subject.

APPEND '<P>Dear Sir/Mam,</P>' TO it_contents.


APPEND '<P> </P> ' TO it_contents.
APPEND '<P>Kindly Find the Below details for Planned Order :</P>' TO it_contents.
***********************************************************************************
****
wa_contents-line = '<html> <body style="background-color:#FFFFFF;"> <basefont
face="arial, verdana, courier" size="2" >'.
APPEND wa_contents TO it_contents.
wa_contents-line = '<table border="1" style="width: 50%; font-family: Calibri;
font-size: 9pt;text-align:center;padding-left:3px;border-collapse: collapse;"> '.
* wa_contents-line = '<table border="1" style="width: 50%;font-family: Calibri;
font-size: 9pt;text-align:left;padding-left:3px;border-collapse: collapse;"> '.
* wa_contents-line = '<table style="border: thin solid blue; width: 650px;> '.
* wa_contents-line = '<table style="MARGIN: 10px" bordercolor="#050211" width =
"50%" border="1px"> '.
APPEND wa_contents TO it_contents.
* w_plaf-plnum = plaf-plnum.
* SHIFT w_plaf-plnum LEFT DELETING LEADING '0'.

* CONCATENATE '<tr><td width="30%"> S.no </td><td>' 'Details' INTO wa_contents.


* APPEND wa_contents TO it_contents.

CONCATENATE '<tr><td width="0.1%"><B>S.no </td>' '<td width="0.1%"><B>Description


</td>'
'<td width="0.1%"> <B>Details </td></tr>'INTO wa_contents.
APPEND wa_contents TO it_contents.

** CONCATENATE '<tr><td width="30%">S.no. Description</td><td>' 'Details' INTO


wa_contents.
** APPEND wa_contents TO it_contents.

w_plaf-plnum = plaf-plnum.
SHIFT w_plaf-plnum LEFT DELETING LEADING '0'.

CONCATENATE '<tr><td width="0.1%"> 1.</td>' '<td width="0.1%"> Planned


Order</td>'
'<td width="0.1%">' w_plaf-plnum '</td></tr>'INTO wa_contents.

APPEND wa_contents TO it_contents.

** CONCATENATE '<tr><td width="30%"> 1. Planned Order</td><td>' plaf-plnum INTO


wa_contents.
** APPEND wa_contents TO it_contents.

w_plaf-matnr = plaf-matnr.
SHIFT w_plaf-matnr LEFT DELETING LEADING '0'.
* CONCATENATE '<tr><td width="30%">'lc_2'Material</td><td>' ' ' INTO wa_contents.
** CONCATENATE '<tr><td width="30%">2 . Material</td><td>' w_plaf-matnr INTO
wa_contents.
** APPEND wa_contents TO it_contents.

CONCATENATE '<tr><td width="0.1%">2. </td>' '<td width="0.1%"> Material</td>'


'<td width="0.1%">'
w_plaf-matnr '</td></tr>' INTO wa_contents.
APPEND wa_contents TO it_contents.

w_plaf-matnr = plaf-matnr.
SELECT SINGLE maktx FROM makt INTO @DATA(gv_maktx)
WHERE matnr = @plaf-matnr
AND spras = @sy-langu.
** CONCATENATE '<tr><td width="30%">3 . Material Description </td><td>' gv_maktx
INTO wa_contents.
**
** APPEND wa_contents TO it_contents.

CONCATENATE '<tr><td width="0.1%">3 .</td>' '<td width="0.1%"> Material


Description </td>'
'<td width="0.1%">' gv_maktx' </td></tr>' INTO wa_contents.
APPEND wa_contents TO it_contents.

** CONCATENATE '<tr><td width="30%">4 .PLANNING PLANT</td><td>' plaf-plwrk INTO


wa_contents.
***CONCATENATE '<tr><td width="30%"> 4 </td><td>' 'Plant' ' / ' INTO wa_contents.
** APPEND wa_contents TO it_contents.
CONCATENATE '<tr><td width="0.1%">4 .</td>' '<td width="0.1%"> PLANNING PLANT
</td>'
'<td width="0.1%">' plaf-plwrk' </td></tr>' INTO wa_contents.
APPEND wa_contents TO it_contents.
*******************************************
*** CONCATENATE '<tr><td width="0.1%">4.</td>''<td width="0.1%">PLANNING
PLANT</td>'
*** '<td width="0.1%">' plaf-plwrk '</td></tr>' INTO wa_contents.
****CONCATENATE '<tr><td width="30%"> 4 </td><td>' 'Plant' ' / ' INTO wa_contents.
*** APPEND wa_contents TO it_contents.
*******************************************

var1 = plaf-gsmng.
** CONCATENATE '<tr><td width="05%">5 .ORDER QTY</td><td>' var1 '.'
** '.' '</td></tr>' INTO wa_contents.
** APPEND wa_contents TO it_contents.

CONCATENATE '<tr><td width="0.1%">5 .</td>' '<td width="0.1%">ORDER QTY</td>'


'<td width="0.1%">' var1 '</td></tr>'
INTO wa_contents.
APPEND wa_contents TO it_contents.

CALL FUNCTION 'CONVERSION_EXIT_ABPSP_OUTPUT'


EXPORTING
input = plaf-pspel
IMPORTING
output = var2.

** CONCATENATE '<tr><td width="30%">6 .UNIT</td><td>' plaf-meins INTO


wa_contents.
** APPEND wa_contents TO it_contents.

CONCATENATE '<tr><td width="0.1%">6 .</td>' '<td width="0.1%"> UNIT </td>'


'<td width="0.1%">' plaf-meins' </td></tr>' INTO wa_contents.
APPEND wa_contents TO it_contents.

*****************************************************************
*** CONCATENATE '<tr><td width="0.1%">6.</td>''<td width="0.1%">UNIT</td>'
*** '<td width="0.1%">' plaf-meins '</td></tr>' INTO wa_contents.
*** APPEND wa_contents TO it_contents.
*********************************************************************

** CONCATENATE '<tr><td width="30%">7 .WBS ELEMENT</td><td>' var2 INTO


wa_contents.
** APPEND wa_contents TO it_contents.

CONCATENATE '<tr><td width="0.1%">7 .</td>' '<td width="0.1%"> WBS ELEMENT </td>'


'<td width="0.1%">' var2' </td></tr>' INTO wa_contents.
APPEND wa_contents TO it_contents.

************************************************************************
*** CONCATENATE '<tr><td width="0.1%">7.</td>''<td width="0.1%">WBS ELEMENT</td>'
*** '<td width="0.1%">' var2 '</td></tr>' INTO wa_contents.
*** APPEND wa_contents TO it_contents.
**************************************************************************

** CONCATENATE '<tr><td width="30%">8 .REMARKS</td><td>' plaf-ptext INTO


wa_contents.
** APPEND wa_contents TO it_contents.

CONCATENATE '<tr><td width="0.1%">8 .</td>' '<td width="0.1%"> REMARKS</td>'


'<td width="0.1%">' plaf-ptext '</td></tr>' INTO wa_contents.
APPEND wa_contents TO it_contents.

** CONCATENATE '<tr><td width="30%">9 .USER NAME</td><td>' plaf-puser INTO


wa_contents.
** APPEND wa_contents TO it_contents.

wa_contents-line = '</table> '.


APPEND wa_contents TO it_contents.

wa_contents-line = '</body></html>'.
APPEND wa_contents TO it_contents.

APPEND '<P> </P> ' TO it_contents.

wa_contents-line = '<P>With Regards,</P>'.


APPEND wa_contents TO it_contents.

DATA: user_address LIKE addr3_val.

CALL FUNCTION 'SUSR_USER_ADDRESS_READ'


EXPORTING
user_name = sy-uname
* READ_DB_DIRECTLY = ' '
* CACHE_RESULTS = 'X'
IMPORTING
user_address = user_address
* USER_USR03 =
* USER_USR21 =
* EV_USER_WITHOUT_ADDRESS =
EXCEPTIONS
user_address_not_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.

wa_contents-line = user_address-name_text.
* APPEND plaf-puser TO .
APPEND wa_contents TO it_contents.

DESCRIBE TABLE it_contents LINES tab_lines.


******* packlist
wa_pack-head_start = 1.
wa_pack-head_num = 0.
wa_pack-body_start = 1.
wa_pack-body_num = tab_lines.
wa_pack-doc_type = 'HTM'.
APPEND wa_pack TO it_pack.

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'


EXPORTING
document_data = doc_data
put_in_outbox = 'X'
commit_work = 'X'
TABLES
packing_list = it_pack
* OBJECT_HEADER =
* CONTENTS_BIN =
contents_txt = it_contents
* CONTENTS_HEX =
* OBJECT_PARA =
* OBJECT_PARB =
receivers = it_recv
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
OTHERS = 8.
IF sy-subrc <> 0.
MESSAGE 'ERROR WHILE SENDING MAIL' TYPE 'E'.
ENDIF.
* DATA: send_request TYPE REF TO cl_bcs,
* mailsubject TYPE so_obj_des,
** mailtext TYPE bcsy_text,
* mailtext TYPE TABLE OF solisti1,
* w_objtxt TYPE solisti1,
* document TYPE REF TO cl_document_bcs,
* sender TYPE REF TO cl_cam_address_bcs,
* recipient_to TYPE REF TO cl_cam_address_bcs,
* recipient_cc TYPE REF TO cl_cam_address_bcs,
* recipient_cc1 TYPE REF TO cl_cam_address_bcs,
* recipient_cc2 TYPE REF TO cl_cam_address_bcs,
* recipient_cc3 TYPE REF TO cl_cam_address_bcs,
* recipient_bcc TYPE REF TO cl_cam_address_bcs,
* bcs_exception TYPE REF TO cx_bcs.
* DATA:text TYPE char100.
* DATA:var1 TYPE char10.
* DATA:var2 TYPE char25.
* DATA: w_plaf TYPE plaf.
** DATA: w_objtxt TYPE solisti1.
* CONSTANTS: lc_1 TYPE c VALUE '1',
* lc_planned_order TYPE char25 VALUE 'PLANNED ORDER',
* lc_2 TYPE c VALUE '2',
* lc_material TYPE char25 VALUE 'MATERIAL',
* lc_3 TYPE c VALUE '3',
* lc_mat_des TYPE char25 VALUE 'MATERIAL DESCRIPTION',
* lc_4 TYPE c VALUE '4',
* lc_Plan_plant TYPE char25 VALUE 'PLANNING PLANT',
* lc_5 TYPE c VALUE '5',
* lc_Order_qty TYPE char25 VALUE 'ORDER QTY',
* lc_6 TYPE c VALUE '6',
* lc_unit TYPE char25 VALUE 'UNIT',
* lc_7 TYPE c VALUE '7',
* lc_wbs_element TYPE char25 VALUE 'WBS ELEMENT',
* lc_8 TYPE c VALUE '8',
* lc_remarks TYPE char25 VALUE 'REMARKS',
* lc_9 TYPE c VALUE '9',
* lc_user_name TYPE char25 VALUE 'USER NAME'.
* TRY.
* CLEAR w_plaf.
* send_request = cl_bcs=>create_persistent( ).
*
* mailsubject = 'Planned Order Details'.
* APPEND '<html>' TO mailtext.
* APPEND '<head>' TO mailtext.
* APPEND '<title>' TO mailtext.
* APPEND '</title>' TO mailtext.
* APPEND '</head>' TO mailtext.
* APPEND '<body>' TO mailtext.
*
*
* APPEND '<P>Dear Sir/Mam,</P>' TO mailtext.
* APPEND '<P> </P> ' TO mailtext.
* APPEND '<P>Kindly Find the Below details for Planned Order :</P>' TO
mailtext.
* w_plaf-plnum = plaf-plnum.
* SHIFT w_plaf-plnum LEFT DELETING LEADING '0'.
*
* w_objtxt-line = '<TABLE width= "75%" "border= "2">'.
* APPEND w_objtxt TO mailtext.
* CLEAR w_objtxt.
* CONCATENATE '<TR ><td align = "LEFT">'
* '<FONT><B>S_No</B> </FONT>'
* '</td>' INTO w_objtxt-line.
* APPEND w_objtxt TO mailtext.
* CLEAR w_objtxt.
*
* CONCATENATE '<td align = "LEFT">'
* '<FONT> <B>Details</B> </FONT>'
* '</td>' INTO w_objtxt-line.
* APPEND w_objtxt TO mailtext.
* CLEAR w_objtxt.
* CONCATENATE '<td align = "LEFT">'
* '<FONT> <B>Description</B> </FONT>'
* '</td></tr>' INTO w_objtxt-line.
* APPEND w_objtxt TO mailtext.
* CLEAR w_objtxt.
*
* CONCATENATE '<TR ><td align = "LEFT">'
* '<FONT>'lc_1'</FONT>'
* '</td>' INTO w_objtxt-line.
* APPEND w_objtxt TO mailtext.
* CLEAR w_objtxt.
* CONCATENATE '<td align = "LEFT">'
* '<FONT>' lc_Planned_Order '</FONT>'
* '</td>' INTO w_objtxt-line.
* APPEND w_objtxt TO mailtext.
* CLEAR w_objtxt.
* CONCATENATE '<td align = "LEFT">'
* '<FONT>'plaf-plnum'</FONT>'
* '</td></tr>' INTO w_objtxt-line.
* APPEND w_objtxt TO mailtext.
* CLEAR w_objtxt.
*
* CONCATENATE '<TR ><td align = "LEFT">'
* '<FONT>'lc_2'</FONT>'
* '</td>' INTO w_objtxt-line.
* APPEND w_objtxt TO mailtext.
* CLEAR w_objtxt.
* CONCATENATE '<td align = "LEFT">'
* '<FONT>' lc_Material '</FONT>'
* '</td>' INTO w_objtxt-line.
* APPEND w_objtxt TO mailtext.
* CLEAR w_objtxt.
* w_plaf-matnr = plaf-matnr.
* SHIFT w_plaf-matnr LEFT DELETING LEADING '0'.
** CONCATENATE 'Material Code :' w_plaf-matnr INTO text SEPARATED BY space.
"Material Code
* CONCATENATE '<td align = "LEFT">'
* '<FONT>'w_plaf-matnr'</FONT>'
* '</td></tr>' INTO w_objtxt-line.
* APPEND w_objtxt TO mailtext.
* CLEAR w_objtxt.
*
*
** *******Material Desc
*
* CONCATENATE '<TR ><td align = "LEFT">'
* '<FONT>'lc_3'</FONT>'
* '</td>' INTO w_objtxt-line.
* APPEND w_objtxt TO mailtext.
* CLEAR w_objtxt.
* CONCATENATE '<td align = "LEFT">'
* '<FONT>' lc_mat_des '</FONT>'
* '</td>' INTO w_objtxt-line.
* APPEND w_objtxt TO mailtext.
* CLEAR w_objtxt.
* w_plaf-matnr = plaf-matnr.
* SELECT SINGLE maktx FROM makt INTO @DATA(gv_maktx)
* WHERE matnr = @plaf-matnr
* AND spras = @sy-langu.
** CONCATENATE 'Material Code :' w_plaf-matnr INTO text SEPARATED BY space.
"Material Code
* CONCATENATE '<td align = "LEFT">'
* '<FONT>'gv_maktx'</FONT>'
* '</td></tr>' INTO w_objtxt-line.
* APPEND w_objtxt TO mailtext.
* CLEAR w_objtxt.
******Planplant
* CONCATENATE '<TR ><td align = "LEFT">'
* '<FONT>'lc_4'</FONT>'
* '</td>' INTO w_objtxt-line.
* APPEND w_objtxt TO mailtext.
* CLEAR w_objtxt.
* CONCATENATE '<td align = "LEFT">'
* '<FONT>' lc_Plan_plant '</FONT>'
* '</td>' INTO w_objtxt-line.
* APPEND w_objtxt TO mailtext.
* CLEAR w_objtxt.
* CONCATENATE '<td align = "LEFT">'
* '<FONT>'plaf-plwrk '</FONT>'
* '</td></tr>' INTO w_objtxt-line.
* APPEND w_objtxt TO mailtext.
* CLEAR w_objtxt.
*
* CONCATENATE '<TR ><td align = "LEFT">'
* '<FONT>'lc_5'</FONT>'
* '</td>' INTO w_objtxt-line.
* APPEND w_objtxt TO mailtext.
* CLEAR w_objtxt.
* CONCATENATE '<td align = "LEFT">'
* '<FONT>' lc_Order_qty '</FONT>'
* '</td>' INTO w_objtxt-line.
* APPEND w_objtxt TO mailtext.
* CLEAR w_objtxt.
* var1 = plaf-gsmng.
* CONCATENATE '<td align = "LEFT">'
* '<FONT>'var1'</FONT>'
* '</td></tr>' INTO w_objtxt-line.
* APPEND w_objtxt TO mailtext.
* CLEAR w_objtxt.
*
** **unit
* CONCATENATE '<TR ><td align = "LEFT">'
* '<FONT>'lc_6'</FONT>'
* '</td>' INTO w_objtxt-line.
* APPEND w_objtxt TO mailtext.
* CLEAR w_objtxt.
* CONCATENATE '<td align = "LEFT">'
* '<FONT>' lc_Unit '</FONT>'
* '</td>' INTO w_objtxt-line.
* APPEND w_objtxt TO mailtext.
* CLEAR w_objtxt.
* CALL FUNCTION 'CONVERSION_EXIT_ABPSP_OUTPUT'
* EXPORTING
* input = plaf-pspel
* IMPORTING
* output = var2.
* CONCATENATE '<td align = "LEFT">'
* '<FONT>'plaf-meins '</FONT>'
* '</td></tr>' INTO w_objtxt-line.
* APPEND w_objtxt TO mailtext.
* CLEAR w_objtxt.
*
*
** * **WBS
* CONCATENATE '<TR ><td align = "LEFT">'
* '<FONT>'lc_7'</FONT>'
* '</td>' INTO w_objtxt-line.
* APPEND w_objtxt TO mailtext.
* CLEAR w_objtxt.
* CONCATENATE '<td align = "LEFT">'
* '<FONT>' lc_WBS_element '</FONT>'
* '</td>' INTO w_objtxt-line.
* APPEND w_objtxt TO mailtext.
* CLEAR w_objtxt.
** CALL FUNCTION 'CONVERSION_EXIT_ABPSP_OUTPUT'
** EXPORTING
** input = plaf-pspel
** IMPORTING
** output = var2.
* CONCATENATE '<td align = "LEFT">'
* '<FONT>'var2'</FONT>'
* '</td></tr>' INTO w_objtxt-line.
* APPEND w_objtxt TO mailtext.
* CLEAR w_objtxt.
*
*
*
** * **Remarks
* CONCATENATE '<TR ><td align = "LEFT">'
* '<FONT>'lc_8'</FONT>'
* '</td>' INTO w_objtxt-line.
* APPEND w_objtxt TO mailtext.
* CLEAR w_objtxt.
* CONCATENATE '<td align = "LEFT">'
* '<FONT>' lc_remarks'</FONT>'
* '</td>' INTO w_objtxt-line.
* APPEND w_objtxt TO mailtext.
* CLEAR w_objtxt.
** CALL FUNCTION 'CONVERSION_EXIT_ABPSP_OUTPUT'
** EXPORTING
** input = plaf-pspel
** IMPORTING
** output = var2.
* CONCATENATE '<td align = "LEFT">'
* '<FONT>' plaf-ptext '</FONT>'
* '</td></tr>' INTO w_objtxt-line.
* APPEND w_objtxt TO mailtext.
* CLEAR w_objtxt.
*
*
*
*
** * **User name
* CONCATENATE '<TR ><td align = "LEFT">'
* '<FONT>'lc_9'</FONT>'
* '</td>' INTO w_objtxt-line.
* APPEND w_objtxt TO mailtext.
* CLEAR w_objtxt.
* CONCATENATE '<td align = "LEFT">'
* '<FONT>' lc_user_name '</FONT>'
* '</td>' INTO w_objtxt-line.
* APPEND w_objtxt TO mailtext.
* CLEAR w_objtxt.
** CALL FUNCTION 'CONVERSION_EXIT_ABPSP_OUTPUT'
** EXPORTING
** input = plaf-pspel
** IMPORTING
** output = var2.
* CONCATENATE '<td align = "LEFT">'
* '<FONT>' plaf-puser '</FONT>'
* '</td></tr>' INTO w_objtxt-line.
* APPEND w_objtxt TO mailtext.
* CLEAR w_objtxt.
*
* APPEND '<P> <br> </P>' TO mailtext .
** w_objtxt-line = '</TABLE width= "75%" "border="2">'.
* APPEND w_objtxt TO mailtext.
* CLEAR w_objtxt.
*
*
** CLEAR : lfl_info.
* APPEND '</body>' TO mailtext.
* APPEND '</html>' TO mailtext.
*
** CONCATENATE 'Planned Order No. :' w_plaf-plnum INTO text SEPARATED BY
space. "Planned Order No.
**
*** CONCATENATE 'Planned Order No. :' plaf-plnum INTO text SEPARATED BY space.
"Planned Order No.
** APPEND text TO mailtext.
** CLEAR:text.
** w_plaf-matnr = plaf-matnr.
** SHIFT w_plaf-matnr LEFT DELETING LEADING '0'.
** CONCATENATE 'Material Code :' w_plaf-matnr INTO text SEPARATED BY space.
"Material Code
*
** CONCATENATE 'Material Code :' plaf-matnr INTO text SEPARATED BY space.
"Material Code
** APPEND text TO mailtext.
** CLEAR:text.
** SELECT SINGLE maktx FROM makt INTO @DATA(gv_maktx)
** WHERE matnr = @plaf-matnr
** AND spras = @sy-langu.
** CONCATENATE 'Material Description :' gv_maktx INTO text SEPARATED BY space.
"Material Description
** APPEND text TO mailtext.
** CLEAR:text.
** CONCATENATE 'Planning Plant :' plaf-plwrk INTO text SEPARATED BY space.
"Planning Plant
** APPEND text TO mailtext.
** CLEAR:text.
** CONCATENATE 'Production Plant :' plaf-pwwrk INTO text SEPARATED BY space.
"Production Plant
** APPEND text TO mailtext.
** CLEAR:text.
** var1 = plaf-gsmng.
** CONCATENATE 'Order Qty. :' var1 INTO text SEPARATED BY space. "Order Qty.
** APPEND text TO mailtext.
** CLEAR:text.
** CALL FUNCTION 'CONVERSION_EXIT_ABPSP_OUTPUT'
** EXPORTING
** input = plaf-pspel
** IMPORTING
** output = var2.
** CONCATENATE 'Unit :' plaf-meins INTO text SEPARATED BY space. "Unit
** APPEND text TO mailtext.
** CLEAR:text.
** CONCATENATE 'WBS Element :' var2 INTO text SEPARATED BY space. "WBS
Element
*** CONCATENATE 'WBS Element :' plaf-pspel INTO text SEPARATED BY space. "WBS
Element
** APPEND text TO mailtext.
** CLEAR:text.
** CONCATENATE 'Remarks :' plaf-ptext INTO text SEPARATED BY space. "Remarks
** APPEND text TO mailtext.
** CLEAR:text.
** CONCATENATE 'User Name :' plaf-puser INTO text SEPARATED BY space. "PUser
Name
** APPEND text TO mailtext.
** CLEAR:text.
** APPEND ' ' TO mailtext.
* APPEND '<P> </P> ' TO mailtext.
* APPEND 'With Regards,' TO mailtext.
* APPEND plaf-puser TO mailtext.
*
* DATA:i_reclist TYPE TABLE OF somlreci1,
* wa_doc_chng TYPE sodocchgi1,
* i_objpack TYPE TABLE OF sopcklsti1,
* w_objpack TYPE sopcklsti1,
* wa_objhead TYPE soli_tab,
* i_objtxt TYPE TABLE OF solisti1,
* v_lines_txt TYPE i,
** w_objtxt TYPE solisti1,
* w_reclist type somlreci1.
** SELECT * FROM zps_mail INTO TABLE @DATA(lt_email)." i_reclist."w_reclist-
receiver WHERE user_id = sy-uname.
** IF sy-subrc = 0.
** LOOP AT lt_email INTO DATA(wa_email).
** w_reclist-receiver = wa_email-email_id.
** w_reclist-rec_type = 'U'.
** APPEND w_reclist TO i_reclist.
** ENDLOOP.
*** w_reclist-rec_type = 'U'.
*** APPEND w_reclist TO i_reclist.
** ENDIF.
*
* DESCRIBE TABLE mailtext LINES v_lines_txt.
* READ TABLE mailtext INTO w_objtxt INDEX v_lines_txt.
* wa_doc_chng-obj_name = 'Planned Order'.
* wa_doc_chng-expiry_dat = sy-datum + 10.
* wa_doc_chng-obj_descr = 'Planned Order Details'.
"subject of Mail
* wa_doc_chng-sensitivty = 'F'.
* wa_doc_chng-doc_size = v_lines_txt * 255.
*
* CLEAR w_objpack-transf_bin.
* w_objpack-head_start = 1.
* w_objpack-head_num = 0.
* w_objpack-body_start = 1.
* w_objpack-body_num = v_lines_txt.
* w_objpack-doc_type = 'HTML'.
* APPEND w_objpack TO i_objpack.
*
*
* SELECT SINGLE * FROM zmd11t_mail INTO @DATA(w_ZMD11T_MAIL) WHERE werks =
@plaf-plwrk.
*
** IF w_ZMD11T_MAIL-sender_mail IS NOT INITIAL.
** w_reclist-receiver = w_ZMD11T_MAIL-sender_mail.
** w_reclist-rec_type = 'U'.
** APPEND w_reclist TO i_reclist.
** ENDIF.
* IF w_ZMD11T_MAIL-to_mail IS NOT INITIAL.
* w_reclist-receiver = w_ZMD11T_MAIL-to_mail.
* w_reclist-rec_type = 'U'.
* APPEND w_reclist TO i_reclist.
* ENDIF.
* IF w_ZMD11T_MAIL-cc_mail1 IS NOT INITIAL.
* w_reclist-receiver = w_ZMD11T_MAIL-cc_mail1.
* w_reclist-rec_type = 'U'.
* w_reclist-copy = 'X'.
* APPEND w_reclist TO i_reclist.
* ENDIF.
* IF w_ZMD11T_MAIL-cc_mail2 IS NOT INITIAL.
* w_reclist-receiver = w_ZMD11T_MAIL-cc_mail2.
* w_reclist-rec_type = 'U'.
* w_reclist-copy = 'X'.
* APPEND w_reclist TO i_reclist.
* ENDIF.
* IF w_ZMD11T_MAIL-cc_mail3 IS NOT INITIAL.
* w_reclist-receiver = w_ZMD11T_MAIL-cc_mail3.
* w_reclist-rec_type = 'U'.
* w_reclist-copy = 'X'.
* APPEND w_reclist TO i_reclist.
* ENDIF.
* IF w_ZMD11T_MAIL-cc_mail4 IS NOT INITIAL.
* w_reclist-receiver = w_ZMD11T_MAIL-cc_mail4.
* w_reclist-rec_type = 'U'.
* w_reclist-copy = 'X'.
* APPEND w_reclist TO i_reclist.
* ENDIF.
* IF w_ZMD11T_MAIL-cc_mail5 IS NOT INITIAL.
* w_reclist-receiver = w_ZMD11T_MAIL-cc_mail5.
* w_reclist-rec_type = 'U'.
* w_reclist-copy = 'X'.
* w_reclist-blind_copy = 'X'.
* APPEND w_reclist TO i_reclist.
* ENDIF.
*
* CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
* EXPORTING
* document_data = wa_doc_chng
* put_in_outbox = 'X'
** commit_work = 'X'
* TABLES
* packing_list = i_objpack
* object_header = wa_objhead
** contents_bin = i_objbin
* contents_txt = mailtext "i_objtxt
* receivers = i_reclist
* EXCEPTIONS
* too_many_receivers = 1
* document_not_sent = 2
* document_type_not_exist = 3
* operation_no_authorization = 4
* parameter_error = 5
* x_error = 6
* enqueue_error = 7
* OTHERS = 8.
* IF sy-subrc <> 0.
** WRITE:/ 'Error When Sending the File', sy-subrc.
* ENDIF.
* ENDIF.
* ENDIF.
* document = cl_document_bcs=>create_document(
* i_type = 'HTM'
* i_text = mailtext
* i_subject = mailsubject ).
* send_request->set_document( document ).
*
* SELECT SINGLE * FROM zmd11t_mail INTO @DATA(w_ZMD11T_MAIL) WHERE werks =
@plaf-plwrk.
*
* IF w_ZMD11T_MAIL-sender_mail IS NOT INITIAL.
* sender = cl_cam_address_bcs=>create_internet_address( w_ZMD11T_MAIL-
sender_mail ).
* send_request->set_sender( sender ).
* ENDIF.
* IF w_ZMD11T_MAIL-to_mail IS NOT INITIAL.
* recipient_to = cl_cam_address_bcs=>create_internet_address( w_ZMD11T_MAIL-
to_mail ).
* send_request->add_recipient( i_recipient = recipient_to ).
* ENDIF.
* IF w_ZMD11T_MAIL-cc_mail1 IS NOT INITIAL.
* recipient_cc = cl_cam_address_bcs=>create_internet_address( w_ZMD11T_MAIL-
cc_mail1 ).
* send_request->add_recipient( i_recipient = recipient_cc
* i_copy = 'X' ).
* ENDIF.
* IF w_ZMD11T_MAIL-cc_mail2 IS NOT INITIAL.
* recipient_cc1 =
cl_cam_address_bcs=>create_internet_address( w_ZMD11T_MAIL-cc_mail2 ).
* send_request->add_recipient( i_recipient = recipient_cc1
* i_copy = 'X' ).
* ENDIF.
* IF w_ZMD11T_MAIL-cc_mail3 IS NOT INITIAL.
* recipient_cc2 =
cl_cam_address_bcs=>create_internet_address( w_ZMD11T_MAIL-cc_mail3 ).
* send_request->add_recipient( i_recipient = recipient_cc2
* i_copy = 'X' ).
* ENDIF.
* IF w_ZMD11T_MAIL-cc_mail4 IS NOT INITIAL.
* recipient_cc3 =
cl_cam_address_bcs=>create_internet_address( w_ZMD11T_MAIL-cc_mail4 ).
* send_request->add_recipient( i_recipient = recipient_cc3
* i_copy = 'X' ).
* ENDIF.
* IF w_ZMD11T_MAIL-cc_mail5 IS NOT INITIAL.
* recipient_bcc =
cl_cam_address_bcs=>create_internet_address( w_ZMD11T_MAIL-cc_mail5 ).
* send_request->add_recipient( i_recipient = recipient_bcc
* i_blind_copy = 'X' ).
* ENDIF.
* DATA(lv_sent_to_all) = send_request->send( ).
* COMMIT WORK.
*
* CATCH cx_bcs INTO bcs_exception.
*
* ENDTRY.

ENDFUNCTION.

You might also like