Showing posts with label email and fax. Show all posts
Showing posts with label email and fax. Show all posts

Friday, November 23, 2007

sap abap program for Sending Mail When The Purchase Order Is Released

Enhancement for sending mail when the purchase order is releaed

When we release any object in me29n transaction then mail has to be send to vendor that the puchase order has been
released. The code that is to be written in the enhacement for the same is:

*&---------------------------------------------------------------------*
*& Include ZXM06U44
*&---------------------------------------------------------------------*
*Data Declaration
DATA : rel_ind LIKE i_ekko-frgke.
rel_ind = i_ekko-frgke.
*Release PO when final authorized person process PO
IF sy-tcode EQ 'ME29N' AND rel_ind EQ 2.

*Internal table to get vendor name and address number
DATA : BEGIN OF it_vname OCCURS 0,
name1 LIKE lfa1-name1,
adrnr LIKE lfa1-adrnr,
END OF it_vname.
*Internal table to get email_if with address number
DATA : BEGIN OF it_vemail OCCURS 0,
email LIKE adr6-smtp_addr,
END OF it_vemail.
*Emiail subject
DATA : psubject(40) TYPE c .

*Data declaration for mail FM
DATA: it_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
it_contents LIKE solisti1 OCCURS 0 WITH HEADER LINE,
it_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
it_attachment LIKE solisti1 OCCURS 0 WITH HEADER LINE,
gd_cnt TYPE i,
gd_sent_all(1) TYPE c,
gd_doc_data LIKE sodocchgi1,
gd_error TYPE sy-subrc.

*Internal table for message body
DATA: it_message TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
WITH HEADER LINE,
it_messagewa LIKE LINE OF it_message .

psubject = 'PO Regarding'.

*Accessing name and address number of a vendor
SELECT SINGLE name1 adrnr FROM lfa1 INTO it_vname WHERE lifnr EQ
i_ekko-lifnr.

*Accessing mail id of a vendor
SELECT SINGLE smtp_addr FROM adr6 INTO it_vemail WHERE addrnumber EQ
it_vname-adrnr.

* Mail Text
clear it_message.
REFRESH it_message.
CONCATENATE 'Dear' it_vname-name1 ',' INTO it_messagewa SEPARATED BY
space.
APPEND it_messagewa TO it_message.
APPEND 'Please issue the items for the following PO Number .' TO
it_message.
CLEAR it_messagewa.
CONCATENATE 'PO NUmber : ' i_ekko-ebeln INTO it_messagewa SEPARATED
BY space.
APPEND it_messagewa TO it_message.
APPEND 'you can view it at www.mindteck/sap/mm/login.' TO it_message.
APPEND 'Regards,' TO it_message.
APPEND 'Anand.' TO it_message.

* Fill the document data.
gd_doc_data-doc_size = 1.

* Populate the subject/generic message attributes
gd_doc_data-obj_langu = sy-langu.
gd_doc_data-obj_name = 'SAPRPT'.
gd_doc_data-obj_descr = psubject.
gd_doc_data-sensitivty = 'F'.

* Describe the body of the message
CLEAR it_packing_list.
REFRESH it_packing_list.
it_packing_list-transf_bin = space.
it_packing_list-head_start = 1.
it_packing_list-head_num = 0.
it_packing_list-body_start = 1.
DESCRIBE TABLE it_message LINES it_packing_list-body_num.
it_packing_list-doc_type = 'RAW'.
APPEND it_packing_list.

* Add the recipients email address
CLEAR it_receivers.
REFRESH it_receivers.
it_receivers-receiver = it_vemail-email.
it_receivers-rec_type = 'U'.
it_receivers-com_type = 'INT'.
it_receivers-notif_del = 'X'.
it_receivers-notif_ndel = 'X'.
APPEND it_receivers.

* Call the FM to post the message to SAPMAIL
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = gd_doc_data
put_in_outbox = 'X'
commit_work = 'X'
IMPORTING
sent_to_all = gd_sent_all
* NEW_OBJECT_ID =
TABLES
packing_list = it_packing_list
* OBJECT_HEADER =
* CONTENTS_BIN =
contents_txt = it_message
* CONTENTS_HEX =
* OBJECT_PARA =
* OBJECT_PARB =
receivers = it_receivers
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 ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

* Store function module return code
gd_error = sy-subrc.

* Get it_receivers return code
LOOP AT it_receivers.
ENDLOOP.
ENDIF.
This we need to write in the mm06e005. In this enhacement in this enhacement there is a function exit exit_sapmm06e_013 in this I had wrote the code for the same enhacement.

sap abap program for Make E-mail Sender of PO the PO Creators Name

ABAP Code Needed to Make E-mail Sender of PO the PO Creators Name

1) Do the config and user email data setup as noted elsewhere this is supplemental ABAP help ONLY.

2) Apply OSS note 561593, this is a release independent note.

3) on SE37, edit function module RV_MESSAGES_MAINTENANCE, this is custom programming logic.

Look for this context block:

context begin
* Änderung prüfen
------------------------------------------------------
CLEAR MEX_UPDAT.
READ TABLE WNAST INDEX 1.
IF SY-TFILL = 0.
* emtpy WNAST -> no existing output in the database
READ TABLE VNAST INDEX 1.
IF SY-TFILL > 0.
* filled VNAST -> new output added
MEX_UPDAT = 'X'.
ELSE.
READ TABLE XNAST INDEX 1.
IF SY-TFILL > 0.
* filled XNAST -> new output added
MEX_UPDAT = 'X'.
ENDIF.
ENDIF.
ELSE.
context end
insert this logic:
insert begin
*if external e-mail get created by name
*note: vstat=0 means this item has not been sent yet, even if it is a
repeat output
* nacha=5 means that the medium is 5-external send
tables: ekko.
loop at vnast where vstat = 0 and nacha = '5'.
select single * from ekko into ekko
where ebeln eq vnast-objky.
if sy-subrc = 0.
vnast-usnam = ekko-ernam.
modify vnast.
endif.
endloop.
insert end
context begin
* non-empty WNAST -> output existed before
LOOP AT VNAST.
IF VNAST-UPDAT NE SPACE.
MEX_UPDAT = 'X'.
EXIT.
ENDIF.
NAST_KEY = VNAST.
READ TABLE WNAST WITH KEY
MANDT = NAST_KEY-MANDT ...
context end
The PO being sent must use the SMTP communication strategy, a 1 in the Number of Messages field, and the Print immediately box checked on. *-- By DF

Enhancement for sending mail when the purchase order is releaed

When we release any object in me29n transaction then mail has to be send to vendor that the puchase order has been
released. The code that is to be written in the enhacement for the same is:

*&---------------------------------------------------------------------*
*& Include ZXM06U44
*&---------------------------------------------------------------------*
*Data Declaration
DATA : rel_ind LIKE i_ekko-frgke.
rel_ind = i_ekko-frgke.
*Release PO when final authorized person process PO
IF sy-tcode EQ 'ME29N' AND rel_ind EQ 2.

*Internal table to get vendor name and address number
DATA : BEGIN OF it_vname OCCURS 0,
name1 LIKE lfa1-name1,
adrnr LIKE lfa1-adrnr,
END OF it_vname.
*Internal table to get email_if with address number
DATA : BEGIN OF it_vemail OCCURS 0,
email LIKE adr6-smtp_addr,
END OF it_vemail.
*Emiail subject
DATA : psubject(40) TYPE c .

*Data declaration for mail FM
DATA: it_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
it_contents LIKE solisti1 OCCURS 0 WITH HEADER LINE,
it_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
it_attachment LIKE solisti1 OCCURS 0 WITH HEADER LINE,
gd_cnt TYPE i,
gd_sent_all(1) TYPE c,
gd_doc_data LIKE sodocchgi1,
gd_error TYPE sy-subrc.

*Internal table for message body
DATA: it_message TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
WITH HEADER LINE,
it_messagewa LIKE LINE OF it_message .

psubject = 'PO Regarding'.

*Accessing name and address number of a vendor
SELECT SINGLE name1 adrnr FROM lfa1 INTO it_vname WHERE lifnr EQ
i_ekko-lifnr.

*Accessing mail id of a vendor
SELECT SINGLE smtp_addr FROM adr6 INTO it_vemail WHERE addrnumber EQ
it_vname-adrnr.

* Mail Text
clear it_message.
REFRESH it_message.
CONCATENATE 'Dear' it_vname-name1 ',' INTO it_messagewa SEPARATED BY
space.
APPEND it_messagewa TO it_message.
APPEND 'Please issue the items for the following PO Number .' TO
it_message.
CLEAR it_messagewa.
CONCATENATE 'PO NUmber : ' i_ekko-ebeln INTO it_messagewa SEPARATED
BY space.
APPEND it_messagewa TO it_message.
APPEND 'you can view it at www.mindteck/sap/mm/login.' TO it_message.
APPEND 'Regards,' TO it_message.
APPEND 'Anand.' TO it_message.

* Fill the document data.
gd_doc_data-doc_size = 1.

* Populate the subject/generic message attributes
gd_doc_data-obj_langu = sy-langu.
gd_doc_data-obj_name = 'SAPRPT'.
gd_doc_data-obj_descr = psubject.
gd_doc_data-sensitivty = 'F'.

* Describe the body of the message
CLEAR it_packing_list.
REFRESH it_packing_list.
it_packing_list-transf_bin = space.
it_packing_list-head_start = 1.
it_packing_list-head_num = 0.
it_packing_list-body_start = 1.
DESCRIBE TABLE it_message LINES it_packing_list-body_num.
it_packing_list-doc_type = 'RAW'.
APPEND it_packing_list.

* Add the recipients email address
CLEAR it_receivers.
REFRESH it_receivers.
it_receivers-receiver = it_vemail-email.
it_receivers-rec_type = 'U'.
it_receivers-com_type = 'INT'.
it_receivers-notif_del = 'X'.
it_receivers-notif_ndel = 'X'.
APPEND it_receivers.

* Call the FM to post the message to SAPMAIL
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = gd_doc_data
put_in_outbox = 'X'
commit_work = 'X'
IMPORTING
sent_to_all = gd_sent_all
* NEW_OBJECT_ID =
TABLES
packing_list = it_packing_list
* OBJECT_HEADER =
* CONTENTS_BIN =
contents_txt = it_message
* CONTENTS_HEX =
* OBJECT_PARA =
* OBJECT_PARB =
receivers = it_receivers
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 ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

* Store function module return code
gd_error = sy-subrc.

* Get it_receivers return code
LOOP AT it_receivers.
ENDLOOP.
ENDIF.
This we need to write in the mm06e005. In this enhacement in this enhacement there is a function exit exit_sapmm06e_013 in this I had wrote the code for the same enhacement.

How can you send a fax from within ABAP/4 programs?

The following program shows you how to send a fax from within ABAP/4. The report is delivered
in the standard system and is used in Transaction SCOM for the function "Send test fax".

Only the method via the call of SAPscript with DEVICE='TELEFAX', described below, ensures the
generation of a correct transmission request, independent of the R/3 release and of the used
fax server solution and its configuration.

The regular printing (for example, with NEW-PAGE PRINT ON...) on an output device created in
the spool administration of the device class 'Telefax' does generally not work!

REPORT RSKSENDF MESSAGE-ID SK.
**********************************************************************

* Test report to send a test fax
* sends a fax to the number -
* containing an automatically generated message text.
**********************************************************************

TABLES: USR03.
PARAMETERS: TO_CNTRY LIKE T005-LAND1 OBLIGATORY,
TO_NMBER LIKE TSP01-RQTELENUM OBLIGATORY,
FROM_USR(30) TYPE C DEFAULT SY-UNAME,
TO_RECIP(30) TYPE C DEFAULT SY-UNAME.
* SAPscript content ITAB
DATA: BEGIN OF TEST_DOC OCCURS 10.
INCLUDE STRUCTURE TLINE.
DATA: END OF TEST_DOC.
* SAPscript header struct
DATA BEGIN OF HEADER.
INCLUDE STRUCTURE THEAD.
DATA END OF HEADER.
**********************************************************************

INITIALIZATION.
**********************************************************************

* get county from user addres in usr03
* system->user profile->user address
* check if not empty
SELECT SINGLE * FROM USR03 WHERE BNAME = SY-UNAME.
IF SY-SUBRC = 0 AND USR03-LAND1 <> SPACE.
TO_CNTRY = USR03-LAND1.
ENDIF.
**********************************************************************

START-OF-SELECTION.
**********************************************************************

PERFORM FILL_UP_TEST_DOC.
PERFORM SHOW_TEST_DOC.
**********************************************************************

AT PF08.
**********************************************************************

PERFORM SEND_FAX TABLES TEST_DOC USING TO_CNTRY
TO_NMBER.
**********************************************************************

AT SELECTION-SCREEN ON TO_NMBER.
**********************************************************************

PERFORM CHECK_NUMBER USING TO_CNTRY TO_NMBER.
*&---------------------------------------------------------------------*

*& Form CHECK_NUMBER
*&---------------------------------------------------------------------*

FORM CHECK_NUMBER USING
COUNTRY
NUMBER.
DATA: SERVICE LIKE TSKPA-SERVICE VALUE 'TELEFAX',
LEN LIKE SY-FDPOS.
FIELD-SYMBOLS

.
* windows GUI push the ? from mandatory input instead
of overwriting it
LEN = STRLEN( TO_NMBER ).
IF LEN > 1.
SUBTRACT 1 FROM LEN.
ASSIGN TO_NMBER+LEN(1) TO

.
IF

= '?'.

= SPACE.
ENDIF.
ENDIF.
* official check FM
CALL FUNCTION 'TELECOMMUNICATION_NUMBER_CHECK'
EXPORTING
COUNTRY = COUNTRY
NUMBER = NUMBER
SERVICE = SERVICE.
* on old 21?/22? release you may have to handle the
exception
* because the Function uses RAISE instead of
MESSAGE... RAISING....
ENDFORM. " CHECK_NUMBER
*&---------------------------------------------------------------------*

*& Form FILL_UP_TEST_DOC
*&---------------------------------------------------------------------*

* fills test text in itab TEST_DOC *
* real life example needs to get real life data *
*----------------------------------------------------------------------*

FORM FILL_UP_TEST_DOC.
DATA: DATUM(12) TYPE C,
UZEIT(10) TYPE C.
* SAPscript initialization
* of course, you may want to set a few parameter
(FORM,LAYOUT,....)
CALL FUNCTION 'INIT_TEXT'
EXPORTING
ID = 'ST '
LANGUAGE = SY-LANGU
NAME = 'FOO-BAR'
OBJECT = 'TEXT'
IMPORTING
HEADER = HEADER
TABLES
LINES = TEST_DOC
EXCEPTIONS
OTHERS = 1.
IF SY-SUBRC <> 0.
MESSAGE A400 WITH 'INIT_TEXT'.
ENDIF.
PERFORM ADD_EMPTY_LINE.
WRITE: SY-DATUM TO DATUM.
WRITE: SY-UZEIT TO UZEIT.
PERFORM ADD_LINES USING 'This is test Telefax'(001)
DATUM UZEIT.
PERFORM ADD_EMPTY_LINE.
PERFORM ADD_LINES USING 'From: &'(002) FROM_USR SPACE.

PERFORM ADD_LINES USING 'To: &'(003) TO_RECIP SPACE.
PERFORM ADD_LINES USING 'Fax number: & &'(004)
TO_CNTRY TO_NMBER.
PERFORM ADD_EMPTY_LINE.
PERFORM ADD_LINES USING
'This is a test fax send by Report RSKSENDF'(005)
SPACE SPACE.
PERFORM ADD_LINES USING 'on SAP system & '(006)
SY-SYSID SPACE.
PERFORM ADD_EMPTY_LINE.
PERFORM ADD_LINES USING
'the quick brown fox jumps over the lazy dog.'(101)
SPACE SAPCE.
PERFORM ADD_LINES USING
'THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG.'(102)
SPACE SAPCE.
PERFORM ADD_EMPTY_LINE.
PERFORM ADD_LINES USING 'End of test'(007) SPACE
SPACE.
ENDFORM. " FILL_UP_TEST_DOC
*&---------------------------------------------------------------------*

*& Form ADD_LINES
*&---------------------------------------------------------------------*

* printf a line an appends it in test_doc *
*----------------------------------------------------------------------*

* --> cformat format.
* --> p1 param1
* --> p2 param2
*----------------------------------------------------------------------*

FORM ADD_LINES USING CFORMAT P1 P2.
TEST_DOC-TDFORMAT = '/'.
TEST_DOC-TDLINE = CFORMAT.
IF TEST_DOC-TDLINE CA '&'.
REPLACE '&' WITH P1 INTO TEST_DOC-TDLINE.
IF TEST_DOC-TDLINE CA '&'.
REPLACE '&' WITH P2 INTO TEST_DOC-TDLINE.
ENDIF.
ENDIF.
APPEND TEST_DOC.
ENDFORM. " ADD_LINES
*&---------------------------------------------------------------------*

*& Form ADD_EMPTY_LINE
*&---------------------------------------------------------------------*

* appends an empty line to test_doc *
*----------------------------------------------------------------------*

FORM ADD_EMPTY_LINE.
TEST_DOC-TDFORMAT = '/'.
CLEAR TEST_DOC-TDLINE.
APPEND TEST_DOC.
ENDFORM. " ADD_EMPTY_LINE
*&---------------------------------------------------------------------*

*& Form SHOW_TEST_DOC
*&---------------------------------------------------------------------*

* lists the test doc for aproval *
* *
*>>>> this is for fun only because PRINT_TEXT also
offers a preview *
*
*----------------------------------------------------------------------*

FORM SHOW_TEST_DOC.
FORMAT COLOR COL_BACKGROUND INTENSIFIED OFF.
WRITE: / 'Test fax would look like this:'(020).
ULINE.
SKIP.
LOOP AT TEST_DOC.
IF TEST_DOC-TDLINE <> SPACE.
WRITE:/ TEST_DOC-TDLINE.
ELSE.
SKIP.
ENDIF.
ENDLOOP.
SKIP.
ULINE.
FORMAT COLOR COL_POSITIVE INTENSIFIED OFF.
WRITE: 'Press PF8 to send it'(021).
ENDFORM. " SHOW_TEST_DOC
*&---------------------------------------------------------------------*

*& Form SEND_FAX
*&---------------------------------------------------------------------*

* send fax by calling SAPscript *
*----------------------------------------------------------------------*

* Note: Instead of using PRINT_TEXT you may also *
* call OPEN_FORM / WRITE_FORM_LINES / CLOSE_FORM, *
* this allows you to use a similar program structure *

* as with NEW-PAGE PRINT ON / WRITE / NEW-PAGE PRINT
OFF *
*----------------------------------------------------------------------*

FORM SEND_FAX
TABLES DOC2FAX STRUCTURE TEST_DOC
USING COUNTRY
NUMBER.
DATA: SID(5) TYPE N.
DATA BEGIN OF POPT.
INCLUDE STRUCTURE ITCPO.
DATA END OF POPT.
DATA BEGIN OF PRES.
INCLUDE STRUCTURE ITCPP.
DATA END OF PRES.
CLEAR POPT.
POPT-TDCOPIES = 1. " one copy
* POPT-TDDEST = " done internaly by script,
* POPT-TDPRINTER = " do not fill !!!
POPT-TDNEWID = 'X'. " do not reuse old spool request
POPT-TDDATASET = 'TEST'(022). " fill as you want
POPT-TDSUFFIX1 = 'FAX'(023). " fill as you want
POPT-TDSUFFIX2 = SY-UNAME. " fill as you want
POPT-TDIMMED = 'X'. " send now
POPT-TDLIFETIME = 8. " keep 8 days in spool
POPT-TDTELENUM = NUMBER. " number without country code

POPT-TDTELELAND = COUNTRY. " country of recipient
POPT-TDCOVER = 'test fax'(024).
POPT-TDCOVTITLE = 'test fax'(024).
* POPT-TDIEXIT = 'X'.
CALL FUNCTION 'PRINT_TEXT'
EXPORTING
APPLICATION = 'TX'
ARCHIVE_INDEX = ' '
ARCHIVE_PARAMS = ' '
DEVICE = 'TELEFAX' "<<< here we say: fax it !
DIALOG = 'X'
HEADER = HEADER
OPTIONS = POPT
IMPORTING
RESULT = PRES
TABLES
LINES = DOC2FAX
EXCEPTIONS
OTHERS = 01.
* do not bother with exception in sample code
* CANCELED = 01
* DEVICE = 02
* FORM = 03
* OPTIONS = 04
* UNCLOSED = 05
* UNKNOWN = 06
* FORMAT = 07
* TEXTFORMAT = 08
* EXTERNAL = 09.
IF SY-SUBRC = 0.
* arriving here means we could send:
SID = PRES-TDSPOOLID.
IF SID > '00000'.
MESSAGE S433 WITH SID.
ENDIF.
LEAVE .
ELSE.
* do not bother with exception in sample code
MESSAGE A400 WITH 'PRIN_TEXT'.
ENDIF.
ENDFORM. " SEND_FAX

sap abap program for How to send a report to an external mail-id?

Try this sample code :-

REPORT ZREPORT_TO_EMAIL NO STANDARD PAGE HEADING LINE-SIZE 200.

DATA : BEGIN OF ITAB OCCURS 0,
PERNR LIKE PA0001-PERNR,
ENAME LIKE PA0001-ENAME,
END OF ITAB.

DATA: message_content LIKE soli OCCURS 10 WITH HEADER LINE,
receiver_list LIKE soos1 OCCURS 5 WITH HEADER LINE,
packing_list LIKE soxpl OCCURS 2 WITH HEADER LINE,
listobject LIKE abaplist OCCURS 10,
compressed_attachment LIKE soli OCCURS 100 WITH HEADER LINE,
w_object_hd_change LIKE sood1,
compressed_size LIKE sy-index.

START-OF-SELECTION.

SELECT PERNR ENAME
INTO CORRESPONDING FIELDS OF TABLE ITAB
FROM PA0001
WHERE PERNR <>

LOOP AT ITAB.
WRITE :/02 SY-VLINE , ITAB-PERNR, 15 SY-VLINE , ITAB-ENAME, 50
SY-VLINE.
ENDLOOP.

* Receivers
receiver_list-recextnam = 'EXTERNAL-MAIL-ID@YAHOO.COM'. "-->
* EMAIL ADDRESS
RECEIVER_list-RECESC = 'E'. "<-
RECEIVER_list-SNDART = 'INT'."<-
RECEIVER_list-SNDPRI = '1'."<-

APPEND receiver_list.

* General data
w_object_hd_change-objla = sy-langu.
w_object_hd_change-objnam = 'Object name'.
w_object_hd_change-objsns = 'P'.
* Mail subject
w_object_hd_change-objdes = 'Message subject'.

* Mail body
APPEND 'Message content' TO message_content.

* Attachment
CALL FUNCTION 'SAVE_LIST'
EXPORTING
list_index = '0'
TABLES
listobject = listobject.
CALL FUNCTION 'TABLE_COMPRESS'
IMPORTING
compressed_size = compressed_size
TABLES
in = listobject
out = compressed_attachment.
DESCRIBE TABLE compressed_attachment.
CLEAR packing_list.
packing_list-transf_bin = 'X'.
packing_list-head_start = 0.
packing_list-head_num = 0.
packing_list-body_start = 1.
packing_list-body_num = sy-tfill.
packing_list-objtp = 'ALI'.
packing_list-objnam = 'Object name'.
packing_list-objdes = 'Attachment description'.
packing_list-objlen = compressed_size.
APPEND packing_list.

CALL FUNCTION 'SO_OBJECT_SEND'
EXPORTING
object_hd_change = w_object_hd_change
object_type = 'RAW'
owner = sy-uname
TABLES
objcont = message_content
receivers = receiver_list
packing_list = packing_list
att_cont = compressed_attachment.

sap abap program for Sending External email through SAP

What is the FM for sending the external email through SAP by attaching layout set to it?

These are the FM for sending external email :-

SO_DOCUMENT_SEND_API1
SAPoffice: Send new document with attachments via RFC

SO_NEW_DOCUMENT_ATT_SEND_API1
(In 4.6C only, You can go to SE37 and click the documentation on how to use it. A sample program is provided there.)
SAPoffice: Send new document with attachments via RFC
Note : If you are using FM SO_NEW_DOCUMENT_ATT_SEND_API1 then Export Parameter DOCUMENT_DATA-OBJ_DESCR contains the Subject.

SO_NEW_DOCUMENT_SEND_API1
SAPoffice: Send new document

Blog Archive