0% found this document useful (0 votes)
80 views

Tables Data Begin of Occurs Include Structure Data End Of: Zrs - Practice Tline Int - Tline1 Tline Int - Tline1

This document describes generating a PDF file from an OTF file and sending it as an email attachment. It calls functions to open and write to an OTF form, then convert the OTF to PDF and binary data. It collects the PDF data and header information into internal tables, which are then passed to a function to send an email with the PDF as an attachment.

Uploaded by

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

Tables Data Begin of Occurs Include Structure Data End Of: Zrs - Practice Tline Int - Tline1 Tline Int - Tline1

This document describes generating a PDF file from an OTF file and sending it as an email attachment. It calls functions to open and write to an OTF form, then convert the OTF to PDF and binary data. It collects the PDF data and header information into internal tables, which are then passed to a function to send an email with the PDF as an attachment.

Uploaded by

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

REPORT ZRS_PRACTICE.

TABLES: TLINE.
DATA: BEGIN OF INT_TLINE1 OCCURS 100.
INCLUDE STRUCTURE TLINE.
DATA: END OF INT_TLINE1.

CALL FUNCTION 'OPEN_FORM'


EXPORTING
FORM = 'ZPRACTICE'
LANGUAGE = SY-LANGU
DEVICE = 'OTF_MEM'.

CALL FUNCTION 'WRITE_FORM'


EXPORTING
ELEMENT = 'MAIN'
WINDOW = 'MAIN'.

CALL FUNCTION 'WRITE_FORM'


EXPORTING
ELEMENT = 'ADRS'
WINDOW = 'ADRESS'.

CALL FUNCTION 'WRITE_FORM'


EXPORTING
ELEMENT = 'LOGO'
WINDOW = 'LOGO'.

CALL FUNCTION 'CLOSE_FORM'.

CALL FUNCTION ‘CLOSE_FORM’


IMPORTING
RESULT = RESULT
tables
otfdata = lt_otf
EXCEPTIONS
OTHERS = 1.
************************************************************************************
** Convert the OTF File Obtained in a PDF File
************************************************************************************
data: lv_binstr type XSTRING.
CALL FUNCTION ‘CONVERT_OTF’
EXPORTING
FORMAT = ‘PDF’
MAX_LINEWIDTH = 132
PDF_DELETE_OTFTAB =‘‘
IMPORTING
bin_filesize = lv_file_size
bin_file = lv_binstr
TABLES
otf = lt_otf
lines = lt_pdf
.
************************************************************************************
** Convert the Xstring To BINARY
************************************************************************************
CALL FUNCTION ‘SCMS_XSTRING_TO_BINARY’
EXPORTING
buffer = lv_binstr
TABLES
binary_tab = lt_binary_tab.

CALL FUNCTION ‘SO_NEW_DOCUMENT_ATT_SEND_API1’


EXPORTING
document_data = ls_gd_doc_data
PUT_IN_OUTBOX = ‘X’
COMMIT_WORK = ‘X’
tables
packing_list = lt_packing_list
OBJECT_HEADER = lt_mail_head
CONTENTS_BIN = lt_mail_bin
CONTENTS_TXT = lt_mailtext
contents_hex = lt_binary_tab
receivers = lt_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
.
ENDFORM. ” ZSEND_MAIL
LEAR: ls_mail_bin, ls_mail_head, ls_packing_list.
DESCRIBE TABLE lt_mailtext LINES TAB_LINES.
READ TABLE lt_mailtext Into ls_mailtext INDEX TAB_LINES.
ls_gd_doc_data–DOC_SIZE = ( TAB_LINES – 1 ) * 255 + STRLEN( ls_mailtext ).
*# Creation of the entry for the compressed document CLEAR MAILPACK-TRANSF_BIN.
ls_packing_list–HEAD_START = 1.
ls_packing_list–HEAD_NUM = 0.
ls_packing_list–BODY_START = 1.
ls_packing_list–BODY_NUM = TAB_LINES.
ls_packing_list–DOC_TYPE = ‘RAW’.
APPEND ls_packing_list to lt_packing_list.
CLEAR ls_packing_list.
***********************************************************************************
** To Get the OTF
***********************************************************************************
*PERFORM get_otf.
LOOP AT lt_SOLISTI1 INTO ls_SOLISTI1.
MOVE-CORRESPONDING ls_SOLISTI1 TO lt_mail_bin.
APPEND ls_mail_bin to lt_mail_bin.
CLEAR ls_mail_bin.
ENDLOOP.
DESCRIBE TABLE lt_mail_bin LINES TAB_LINES.
ls_mail_head = ‘TEST.OTF’.
APPEND ls_mail_head to lt_mail_head.
CLEAR ls_mail_head.
* Creation of the entry for the compressed attachment
ls_packing_list–TRANSF_BIN = ‘X’.
ls_packing_list–HEAD_START = 1.
ls_packing_list–HEAD_NUM = 1.
ls_packing_list–BODY_START = 1.
ls_packing_list–BODY_NUM = TAB_LINES.
ls_packing_list–DOC_TYPE = ‘OTF’.
ls_packing_list–OBJ_NAME = ‘TEST’.
ls_packing_list–OBJ_DESCR = ‘Subject’.
*MAILPACK-DOC_SIZE = TAB_LINES * 255.
APPEND ls_packing_list to lt_packing_list.
CLEAR ls_packing_list.
endform

You might also like