Posted: Wed Jan 23, 2008 10:31 am Post subject: Отправка по почте результатов отчета в сжатом виде.
Программа иллюстрирует получение листа, сформированного другим отчетом в памяти, получение листа из памяти, сжатие и отправку на e-mail по таблице получателей.
Code:
*&---------------------------------------------------------------------*
*& Report ZSSO_DOCUMENT_SEND_API1
*&
*&---------------------------------------------------------------------*
*& Send document with OTF/ALI attachment from spool to external reci-
*& pient. OTF/ALI document is converted to PDF/HTML format during the
*& SAPconnect send process.
*&
*&---------------------------------------------------------------------*
*** Data Declaration ***
* Mail recepient's table
TABLES ZESAPUSERS.
DATA: BEGIN OF WA_ZESAPUSERS OCCURS 10,
USNAME LIKE ZESAPUSERS-USNAME,
BUKRS LIKE ZESAPUSERS-BUKRS,
END OF WA_ZESAPUSERS.
DATA: docdata LIKE sodocchgi1,
objpack LIKE sopcklsti1 occurs 1 with header line,
objhead LIKE solisti1 occurs 1 with header line,
objtxt LIKE solisti1 occurs 10 with header line,
objbin LIKE solisti1 occurs 10 with header line,
reclist LIKE somlreci1 occurs 1 with header line.
DATA:
listobject LIKE abaplist occurs 1 with header line.
DATA:
tab_lines TYPE i,
doc_size TYPE i,
att_type LIKE SOODK-OBJTP.
DATA: begin of X occurs 0.
include structure VKDFS.
DATA: end of X.
* NOTE: Create ALI/OTF Document in Spool
* ALI Document can be created by displaying a list and selecting
* menue System -> List -> Print (only put to Spool).
* OTF Document can be created running report SF_EXAMPLE_01 in system.
*
* Example used here:
*&---------------------------------------------------------------------*
* create list in memory
SUBMIT Z_REPORT_NAME
exporting list to memory
and return.
* and read list from memory into table
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = listobject
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
message ID '61' TYPE 'E' NUMBER '731'
with 'LIST_FROM_MEMORY'.
ENDIF.
* Because listobject is of size RAW(1000)
* and objbin is of size CHAR(255) we make this table copy
CALL FUNCTION 'TABLE_COMPRESS'
TABLES
IN = listobject
OUT = objbin
EXCEPTIONS
OTHERS = 1.
if sy-subrc <> 0.
message ID '61' TYPE 'E' NUMBER '731'
with 'TABLE_COMPRESS'.
endif.
* NOTE: Creation of attachment is finished yet.
* For your report, the attachment should be placed into table
* objtxt for plain text or
* objbin for binary content.
* Now create the message and send the document.
* Create Message Body
* Title and Description
docdata-obj_name = 'TEST_ALI'(M01).
docdata-obj_descr =
'Message including invoice list in ALI Attachment'(M02).
objtxt = 'Invoice list.'(M03).
append objtxt.
objtxt = 'You will find an ALI attachment in this message.'(M04).
append objtxt.
objtxt = 'Have a nice day.'(M05).
append objtxt.
* Write Packing List (Main)
describe table objtxt lines tab_lines.
read table objtxt index tab_lines.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.