cancel
Showing results for 
Search instead for 
Did you mean: 

how to send smartform output through mail in PDF Format

former_member241401
Discoverer
0 Kudos

Can some one provide me the sample code

Edited by: Revankar Satej on Feb 22, 2008 1:22 PM

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi,

try this code,HOPE usefull to u, Reaward points

&----


*& Report ZTEST_SMARTFORM

*&

&----


*&

*&

&----


REPORT ztest_smartform.

DATA: formname TYPE tdsfname,

fm_name TYPE rs38l_fnam,

control_parameters TYPE ssfctrlop,

job_output_info TYPE ssfcrescl,

otf_data TYPE tsfotf,

bin_filesize TYPE i,

otf TYPE TABLE OF itcoo WITH HEADER LINE,

doctab_archive TYPE TABLE OF docs WITH HEADER LINE,

lines TYPE TABLE OF tline WITH HEADER LINE.

INITIALIZATION.

formname = 'UR SMART FORM'.

START-OF-SELECTION.

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

EXPORTING

formname = formname

  • VARIANT = ' '

  • DIRECT_CALL = ' '

IMPORTING

fm_name = fm_name

EXCEPTIONS

no_form = 1

no_function_module = 2

OTHERS = 3

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

control_parameters-no_dialog = 'X'.

  • control_parameters-preview = ''.

control_parameters-getotf = 'X'.

CALL FUNCTION fm_name

EXPORTING

  • ARCHIVE_INDEX = ARCHIVE_INDEX

  • ARCHIVE_INDEX_TAB = ARCHIVE_INDEX_TAB

  • ARCHIVE_PARAMETERS = ARCHIVE_PARAMETERS

control_parameters = control_parameters

  • MAIL_APPL_OBJ = MAIL_APPL_OBJ

  • MAIL_RECIPIENT = MAIL_RECIPIENT

  • MAIL_SENDER = MAIL_SENDER

  • OUTPUT_OPTIONS = OUTPUT_OPTIONS

  • USER_SETTINGS = 'X'

IMPORTING

  • DOCUMENT_OUTPUT_INFO = DOCUMENT_OUTPUT_INFO

job_output_info = job_output_info

  • JOB_OUTPUT_OPTIONS = JOB_OUTPUT_OPTIONS

EXCEPTIONS

formatting_error = 1

internal_error = 2

send_error = 3

user_canceled = 4

OTHERS = 5

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

otf_data[] = job_output_info-otfdata[].

CALL FUNCTION 'CONVERT_OTF_2_PDF'

  • EXPORTING

  • USE_OTF_MC_CMD = 'X'

  • ARCHIVE_INDEX = ARCHIVE_INDEX

IMPORTING

bin_filesize = bin_filesize

TABLES

otf = otf_data[]

doctab_archive = doctab_archive[]

lines = lines

EXCEPTIONS

ERR_CONV_NOT_POSSIBLE = 1

ERR_OTF_MC_NOENDMARKER = 2

OTHERS = 3

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

DATA: filename TYPE string.

filename = 'c:\test\smart.pdf'.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

bin_filesize = bin_filesize

filename = filename

filetype = 'BIN'

  • APPEND = ' '

  • WRITE_FIELD_SEPARATOR = ' '

  • HEADER = '00'

  • TRUNC_TRAILING_BLANKS = ' '

  • WRITE_LF = 'X'

  • COL_SELECT = ' '

  • COL_SELECT_MASK = ' '

  • DAT_MODE = ' '

  • CONFIRM_OVERWRITE = ' '

  • NO_AUTH_CHECK = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • WRITE_BOM = ' '

  • TRUNC_TRAILING_BLANKS_EOL = 'X'

  • WK1_N_FORMAT = ' '

  • WK1_N_SIZE = ' '

  • WK1_T_FORMAT = ' '

  • WK1_T_SIZE = ' '

  • IMPORTING

  • FILELENGTH = FILELENGTH

TABLES

data_tab = lines[]

  • FIELDNAMES = FIELDNAMES

EXCEPTIONS

file_write_error = 1

no_batch = 2

gui_refuse_filetransfer = 3

invalid_type = 4

no_authority = 5

unknown_error = 6

header_not_allowed = 7

separator_not_allowed = 8

filesize_not_allowed = 9

header_too_long = 10

dp_error_create = 11

dp_error_send = 12

dp_error_write = 13

unknown_dp_error = 14

access_denied = 15

dp_out_of_memory = 16

disk_full = 17

dp_timeout = 18

file_not_found = 19

dataprovider_exception = 20

control_flush_error = 21

OTHERS = 22

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

DATA: document_data LIKE sodocchgi1 ,

contents_txt TYPE TABLE OF solisti1 WITH HEADER LINE,

contents_bin TYPE TABLE OF solisti1 WITH HEADER LINE,

tab_lines TYPE i,

packing_list TYPE TABLE OF sopcklsti1 WITH HEADER LINE,

OBJECT_HEADER type table of SOLISTI1 with header line,

RECEIVERS TYPE TABLE OF SOMLRECI1 WITH HEADER LINE,

l_str(255) ,

v1 TYPE i,

v2 TYPE i,

v3 type i.

CONSTANTS: c_raw TYPE so_obj_tp VALUE 'RAW',

c_pdf TYPE so_obj_tp VALUE 'PDF',

c_255 TYPE i VALUE 255,

c_134 TYPE i VALUE 134,

C_X TYPE C VALUE 'X',

C_U TYPE C VALUE 'U'.

document_data-obj_name = 'EMAIL'.

document_data-obj_descr = 'subject'.

contents_txt = 'THIS IS first line DATA'.

APPEND contents_txt.

CLEAR contents_txt.

contents_txt = 'THIS IS second line DATA'.

APPEND contents_txt.

CLEAR contents_txt.

APPEND contents_txt.

APPEND contents_txt.

DESCRIBE TABLE contents_txt LINES tab_lines.

READ TABLE contents_txt INDEX tab_lines.

  • document_data-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( contents_txt ).

document_data-doc_size = tab_lines .

CLEAR packing_list-transf_bin.

packing_list-head_start = 1.

packing_list-head_num = 0.

packing_list-body_start = 1.

packing_list-body_num = tab_lines.

packing_list-doc_type = c_raw.

packing_list-doc_size = document_data-doc_size.

APPEND packing_list.

LOOP AT lines.

CLEAR l_str.

l_str+0(2) = lines-tdformat.

l_str+2(132) = lines-tdline.

v2 = v1 + c_134.

IF v2 LE c_255.

contents_bin-line+v1(c_134) = l_str. v1 = v2.

ELSE.

v3 = v2 - c_255.

v2 = c_255 - v1.

IF NOT v2 IS INITIAL.

contents_bin-linev1(v2) = l_str0(v2).

ENDIF.

APPEND contents_bin.

CLEAR contents_bin.

v1 = v3.

v3 = 134 - v1.

IF NOT v1 IS INITIAL.

contents_bin-line0(v1) = l_strv3(v1).

ENDIF.

ENDIF.

ENDLOOP.

APPEND contents_bin.

CLEAR contents_bin.

DESCRIBE TABLE contents_bin LINES tab_lines.

READ TABLE contents_bin INDEX tab_lines.

OBJECT_HEADER = 'objhead'.

APPEND OBJECT_HEADER.

packing_list-transf_bin = c_x.

packing_list-head_start = 1.

packing_list-head_num = 1.

packing_list-body_start = 1.

packing_list-body_num = tab_lines.

packing_list-doc_type = c_pdf.

packing_list-obj_name = 'text1'.

packing_list-obj_descr = 'filename'.

packing_list-doc_size = tab_lines * 255 + STRLEN( contents_bin ).

APPEND packing_list.

RECEIVERS-receiver = 'UR EMAIL ADDRESS IN CAPS'.

RECEIVERS-rec_type = c_u.

APPEND RECEIVERS.

CLEAR RECEIVERS.

CALL FUNCTION 'SO_DOCUMENT_SEND_API1'

EXPORTING

document_data = document_data

PUT_IN_OUTBOX = 'X'

  • SENDER_ADDRESS = SY-UNAME

  • SENDER_ADDRESS_TYPE = 'B'

COMMIT_WORK = 'X'

  • IMPORTING

  • SENT_TO_ALL =

  • NEW_OBJECT_ID = NEW_OBJECT_ID

  • SENDER_ID = SENDER_ID

TABLES

packing_list = packing_list

OBJECT_HEADER = OBJECT_HEADER

CONTENTS_BIN = CONTENTS_BIN

CONTENTS_TXT = CONTENTS_TXT

  • CONTENTS_HEX = CONTENTS_HEX

  • OBJECT_PARA = OBJECT_PARA

  • OBJECT_PARB = OBJECT_PARB

receivers = 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.

Regards

SFT

Former Member
0 Kudos

Hi,

If u want to send PO details as PDF, follow the steps given below:

In NACE tcode, select Application Type as EF( for Purcahse Order) type and click Output types button on application toolbar. Then select NEu output type and double click Processing Routines under Dialog structure in left side of the screen. The select medium as external send and for Partner types under Dialog Structure select external send, function as VN and name as Vendor.

Then in PO creation after enetring all details, from menu GOTO->MESSAGES , in that screen select output type as NEU and choose external send, give partner number and click Further data button on application toolbar and Select send immediately from drop down list and finally save.

Then execute program RSCONN01 for sending mails outside SAP.

If email address is existing for partner number ( This is done in XK01 tcode), then automatically mail is sent to the email address.

Former Member
0 Kudos

HI

There is a way to download smartform in PDF format.

Please do the following:

1. Print the smartform to the spool.

2. Note the spool number.

3. Download a PDF file (Acrobat Reader) version of the spool by running Program RSTXPDFT4 and entering the

noted spool number.

Former Member
0 Kudos

hi

first convert to OTF to PDF format:

CALL FUNCTION 'CONVERT_OTF'

EXPORTING

format = 'PDF'

IMPORTING

bin_filesize = wrk_filesiz

TABLES

otf = st_prnout_info-otfdata[]

lines = it_lines

EXCEPTIONS

err_max_linewidth = 1

err_format = 2

err_conv_not_possible = 3

OTHERS = 4.

IF sy-subrc 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

then download it to pc and then upload and send email using any of the

FM available in SAP

regards,

sreelakshmi.

former_member241401
Discoverer
0 Kudos

user cant Download each and every output to mail their user

Former Member
0 Kudos

Hi,

i will send u the document with screen shots give me mail id

Regards