Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Smartforms urgent

Former Member
0 Likes
330

Hello experts!

i did the small program which is converting smartform output into PDF format and sent PDF attachment to the email.

But when i execute the print program,it takes long time to get this in my inbox.

some times it is taking 2 r 3 days.

Is there any option/function module to overcome this problem.

Can any one solve this.

Following is my code.

TABLES: MARA.

DATA: ITAB LIKE MARA OCCURS 0 WITH HEADER LINE.

SELECT * FROM MARA INTO TABLE ITAB.

  • Internal Table declarations

DATA: i_otf like itcoo OCCURS 0 WITH HEADER LINE,

i_tline like tline occurs 1 WITH HEADER LINE, "SAPscript: Text Lines

i_receivers TYPE TABLE OF somlreci1 WITH HEADER LINE, "SAPoffice: Structure of the API Recipient list

i_record LIKE solisti1 OCCURS 0 WITH HEADER LINE, "SAPoffice: Single List with Column Length 255

  • Objects to send mail.

i_objpack LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE, "SAPoffice: Description of Imported Object Components

i_objtxt LIKE solisti1 OCCURS 0 WITH HEADER LINE,

i_objbin LIKE solisti1 OCCURS 0 WITH HEADER LINE,

i_reclist LIKE somlreci1 OCCURS 0 WITH HEADER LINE,

  • Work Area declarations

w_objhead TYPE soli_tab, "Objcont and Objhead as Table Type

w_ctrlop TYPE ssfctrlop,

w_compop TYPE ssfcompop,

w_return TYPE ssfcrescl, "Smart Forms: Return value at end of form printing

w_doc_chng typE sodocchgi1, "Data of an object which can be changed

w_data TYPE sodocchgi1,

w_buffer TYPE string, "To convert from 132 to 255

  • Variables declarations

v_form_name TYPE rs38l_fnam,

v_len_in LIKE sood-objlen, "SOOD = SAPoffice: Object definition

v_len_out LIKE sood-objlen, "OBJLEN = Size of Document Content

v_len_outn TYPE i,

v_lines_txt TYPE i,

v_lines_bin TYPE i.

DATA WA_SOLI TYPE SOLI.

DATA WA_SOLIX TYPE SOLIX.

DATA LT_SOLIX LIKE SOLIX OCCURS 0 WITH HEADER LINE.

DATA DOC_SIZE(12) TYPE C.

DATA LD_BINFILE TYPE XSTRING.

DATA: I TYPE I, N TYPE I.

FIELD-SYMBOLS: <PTR_HEX> TYPE SOLIX.

call function 'SSF_FUNCTION_MODULE_NAME'

exporting

formname = 'ZCS_FORM8'

importing

fm_name = v_form_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.

w_ctrlop-getotf = 'X'.

w_ctrlop-no_dialog = 'X'.

w_compop-tdnoprev = 'X'.

CALL FUNCTION v_form_name " '/1BCDWB/SF00000706'

EXPORTING

  • ARCHIVE_INDEX =

  • ARCHIVE_INDEX_TAB =

  • ARCHIVE_PARAMETERS =

CONTROL_PARAMETERS = w_ctrlop

  • MAIL_APPL_OBJ =

  • MAIL_RECIPIENT =

  • MAIL_SENDER =

OUTPUT_OPTIONS = w_compop

USER_SETTINGS = 'X'

IMPORTING

  • DOCUMENT_OUTPUT_INFO =

JOB_OUTPUT_INFO = w_return

  • JOB_OUTPUT_OPTIONS =

TABLES

ITAB9 = ITAB

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.

  • Prepare Content

REFRESH : i_otf, LT_SOLIX, i_OBJBIN.

LOOP AT w_return-otfdata INTO I_OTF.

APPEND I_OTF.

ENDLOOP.

CALL FUNCTION 'CONVERT_OTF'

EXPORTING

format = 'PDF' "Target format for LINES table

  • max_linewidth = 132 "For ASCII format: Number of lines in LINES-TDLINE

IMPORTING

BIN_FILE = LD_BINFILE

bin_filesize = DOC_SIZE "For binary format: Number of bytes in LINES

TABLES

otf = i_otf "Input table with OTF format

lines = i_tline "Output table with target format

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.

I = 0.

N = XSTRLEN( LD_BINFILE ).

WHILE I < N.

LT_SOLIX-LINE = LD_BINFILE+I.

APPEND LT_SOLIX.

I = I + 255.

ENDWHILE.

LOOP AT LT_SOLIX INTO WA_SOLIX.

CLEAR WA_SOLI.

ASSIGN WA_SOLI TO <PTR_HEX> CASTING.

MOVE WA_SOLIX TO <PTR_HEX>.

APPEND WA_SOLI TO i_OBJBIN.

ENDLOOP.

DESCRIBE TABLE i_objbin LINES v_lines_bin.

i_OBJPACK-TRANSF_BIN = 'X'.

i_OBJPACK-HEAD_START = 1.

i_OBJPACK-HEAD_NUM = 1.

i_OBJPACK-BODY_START = 1.

i_OBJPACK-BODY_NUM = v_lines_bin.

i_OBJPACK-DOC_TYPE = 'PDF'.

i_OBJPACK-OBJ_NAME = 'ATTACHMENT'.

i_OBJPACK-OBJ_DESCR = 'Attached Document'.

i_OBJPACK-DOC_SIZE = v_lines_bin * 255.

append i_objpack.

  • e-mail receivers.

i_reclist-receiver = 'chandrasekhar.valluri@eds.com'. "SAPoffice: Name of the recipient of a document (also ext.)

i_reclist-rec_type = 'U'. "Specification of recipient type

  • U = INTERNET ADDRESS,

  • B = SAP USER,

  • P = PRIVATE DISTRIBUTION LIST,

  • O = SAPOFFICE USER,

  • R = SAP user in another SAP System

  • X = X400 ADDRESS

  • C = SHARED DISTRIBUTION LIST

APPEND i_reclist.

i_reclist-receiver = SY-UNAME. "SAPoffice: Name of the recipient of a document (also ext.)

i_reclist-rec_type = 'B'. "Specification of recipient type

APPEND i_reclist.

  • Create Message Body

  • Title and Description

w_doc_chng-obj_name = 'TEST_ALI'.

w_doc_chng-obj_descr = 'Test including PDF Attachment'.

  • Object with main text of the mail.

i_objtxt = 'Find attached the output of the smart form.'.

APPEND i_objtxt.

i_objtxt = 'Regards,'.

APPEND i_objtxt.

i_objtxt = 'Chandu'.

APPEND i_objtxt.

  • Sending mail.

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = w_doc_chng "Attributes of new document

put_in_outbox = 'X' "Flag: Move document to outbox after send

COMMIT_WORK = 'X'

TABLES

packing_list = i_objpack "Information about structure of data tables

  • object_header = w_objhead "Header data for document (spec.header)

contents_bin = i_objbin "Binary contents of object and attachments

contents_txt = i_objtxt "ASCII contents of object and attachments

receivers = i_reclist "Document recipients with send attributes

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:/ 'THE ATTACHMENT IS SUCCEFULLY SENT TO RECEIVERS'.

ENDIF.

Points wl be given.

Thanks in advance.

1 REPLY 1
Read only

sreeramkumar_madisetty
Active Contributor
0 Likes
305

Hi

Are u converting spool to pdf or otf to pdf?

If you are doing first one try to do otf to pdf.

after that try to call FM: qce1_convert which will give pdf compatible by using otf.

Regards,

Sree