on 08-08-2008 6:52 AM
How can I automate that output of MY SMARTFORM in PDF file & sent thru mail to defined email address.
This should be without manual intervention.
Right answer will be highly awarded.
Thanks,
THANKS
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please check this code.
*some data
*please check which You need there is some thing that is not *usefull
data lv_string type string.
data main_text type bcsy_text.
data binary_content type solix_tab.
data size type so_obj_len.
* event handler for data retrieval
data: l_devtype type rspoptype,
l_function_module_name type rs38l_fnam.
data: ls_output_options type ssfcompop,
ls_control_parameters type ssfctrlop.
data: ls_output_data type ssfcrescl.
* generated result: HTML with embedded CSS
data: ls_xmloutput type ssfxmlout,
lt_html_raw type tsfixml.
data: l_xstring type xstring, "needed for HTTP response
l_xlength type i,
l_html_xstring type xstring.
data: l_pdf_xstring type xstring,
lt_lines type table of tline,
ls_line type tline,
l_pdf_len type i.
data:
solix TYPE solix,
soli type soli.
DATA send_request TYPE REF TO cl_bcs.
DATA text TYPE bcsy_text.
DATA document TYPE REF TO cl_document_bcs.
DATA recipient TYPE REF TO if_recipient_bcs.
DATA sent_to_all TYPE os_boolean.
DATA pdf_content TYPE solix_tab.
DATA lp_pdf_size TYPE so_obj_len.
*here we make the smartform and convert it to pdf
ls_control_parameters-no_dialog = 'X'.
ls_control_parameters-getotf = 'X'.
CALL FUNCTION 'SSF_GET_DEVICE_TYPE'
EXPORTING
i_language = sy-langu
* i_application = 'SAPDEFAULT'
IMPORTING
e_devtype = l_devtype
EXCEPTIONS
no_language = 1
language_not_installed = 2
no_devtype_found = 3
system_error = 4
others = 5.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid type sy-msgty number sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ls_output_options-tdprinter = l_devtype.
CALL FUNCTION l_function_module_name
EXPORTING
* archive_index =
* archive_parameters =
control_parameters = ls_control_parameters
* mail_appl_obj = APPL_OBJECT_ID
* mail_recipient = RECIPIENT_ID
* mail_sender = SENDER_ID
output_options = ls_output_options
user_settings = space
iv_werks = i_werks
iv_datum = i_date
IMPORTING
* document_output_info =
job_output_info = ls_output_data
* job_output_options =
TABLES
im_matnr = application->IT_MATERIAL
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
others = 5.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid type sy-msgty number sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
* MAX_LINEWIDTH = 132
* ARCHIVE_INDEX = ' '
* COPYNUMBER = 0
IMPORTING
bin_filesize = l_pdf_len
bin_file = l_pdf_xstring " binary file
TABLES
otf = ls_output_data-otfdata
lines = lt_lines
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 4
others = 5.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid type sy-msgty number sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
*and here we mail it
send_request = cl_bcs=>create_persistent( ).
lp_pdf_size = XSTRLEN( l_pdf_xstring ).
pdf_content = cl_document_bcs=>xstring_to_solix( ip_xstring = l_pdf_xstring ).
document = cl_document_bcs=>create_document( i_type = 'PDF'
i_hex = pdf_content
i_length = lp_pdf_size
i_subject = 'Test Message' ).
send_request->set_document( document ).
recipient = cl_cam_address_bcs=>create_internet_address(
i_address_string = 'YOUR-EMAIL-HERE' ).
send_request->add_recipient( i_recipient = recipient ).
sent_to_all = send_request->send( i_with_error_screen = 'X' ).
COMMIT WORK.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must first search code in the code gallery first before posting. This piece of code is from code gallery itself....
Internal Table declarations
DATA: I_OTF TYPE ITCOO OCCURS 0 WITH HEADER LINE,
I_TLINE TYPE TABLE OF TLINE WITH HEADER LINE,
I_RECEIVERS TYPE TABLE OF SOMLRECI1 WITH HEADER LINE,
I_RECORD LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
Objects to send mail.
I_OBJPACK LIKE SOPCKLSTI1 OCCURS 0 WITH HEADER LINE,
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
WA_OBJHEAD TYPE SOLI_TAB,
W_CTRLOP TYPE SSFCTRLOP,
W_COMPOP TYPE SSFCOMPOP,
W_RETURN TYPE SSFCRESCL,
WA_DOC_CHNG TYPE SODOCCHGI1,
W_DATA TYPE SODOCCHGI1,
WA_BUFFER TYPE STRING,u201DTo convert from 132 to 255
Variables declarations
V_FORM_NAME TYPE RS38L_FNAM,
V_LEN_IN LIKE SOOD-OBJLEN,
V_LEN_OUT LIKE SOOD-OBJLEN,
V_LEN_OUTN TYPE I,
V_LINES_TXT TYPE I,
V_LINES_BIN TYPE I.
CALL FUNCTION u2018SSF_FUNCTION_MODULE_NAMEu2019
EXPORTING
FORMNAME = u2018ZTESTu2019
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 = u2018Xu2019.
W_CTRLOP-NO_DIALOG = u2018Xu2019.
W_COMPOP-TDNOPREV = u2018Xu2019.
CALL FUNCTION V_FORM_NAME
EXPORTING
CONTROL_PARAMETERS = W_CTRLOP
OUTPUT_OPTIONS = W_COMPOP
USER_SETTINGS = u2018Xu2019
IMPORTING
JOB_OUTPUT_INFO = W_RETURN
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.
I_OTF[] = W_RETURN-OTFDATA[].
CALL FUNCTION u2018CONVERT_OTFu2019
EXPORTING
FORMAT = u2018PDFu2019
MAX_LINEWIDTH = 132
IMPORTING
BIN_FILESIZE = V_LEN_IN
TABLES
OTF = I_OTF
LINES = I_TLINE
EXCEPTIONS
ERR_MAX_LINEWIDTH = 1
ERR_FORMAT = 2
ERR_CONV_NOT_POSSIBLE = 3
OTHERS = 4.
Fehlerhandling
IF SY-SUBRC <> 0.
ENDIF.
LOOP AT I_TLINE.
TRANSLATE I_TLINE USING u2018~u2019.
CONCATENATE WA_BUFFER I_TLINE INTO WA_BUFFER.
ENDLOOP.
TRANSLATE WA_BUFFER USING u2018~u2019.
DO.
I_RECORD = WA_BUFFER.
APPEND I_RECORD.
SHIFT WA_BUFFER LEFT BY 255 PLACES.
IF WA_BUFFER IS INITIAL.
EXIT.
ENDIF.
ENDDO.
Attachment
REFRESH:
I_RECLIST,
I_OBJTXT,
I_OBJBIN,
I_OBJPACK.
CLEAR WA_OBJHEAD.
I_OBJBIN[] = I_RECORD[].
o
+
#
*
o
+ Create Message Body
1. Title and Description
I_OBJTXT = u2018test with pdf-Attachment!u2019.
APPEND I_OBJTXT.
DESCRIBE TABLE I_OBJTXT LINES V_LINES_TXT.
READ TABLE I_OBJTXT INDEX V_LINES_TXT.
WA_DOC_CHNG-OBJ_NAME = u2019smartformu2019.
WA_DOC_CHNG-EXPIRY_DAT = SY-DATUM + 10.
WA_DOC_CHNG-OBJ_DESCR = u2019smartformu2019.
WA_DOC_CHNG-SENSITIVTY = u2018Fu2019.
WA_DOC_CHNG-DOC_SIZE = V_LINES_TXT * 255.
1. Main Text
wa_doc_chng-doc_size = ( v_lines_txt - 1 ) * 255 + strlen( i_objtxt )
*.
CLEAR I_OBJPACK-TRANSF_BIN.
I_OBJPACK-HEAD_START = 1.
I_OBJPACK-HEAD_NUM = 0.
I_OBJPACK-BODY_START = 1.
I_OBJPACK-BODY_NUM = V_LINES_TXT.
I_OBJPACK-DOC_TYPE = u2018RAWu2019.
APPEND I_OBJPACK.
o
+
1. Attachment
(pdf-Attachment)
I_OBJPACK-TRANSF_BIN = u2018Xu2019.
I_OBJPACK-HEAD_START = 1.
I_OBJPACK-HEAD_NUM = 0.
I_OBJPACK-BODY_START = 1.
Länge des Attachment ermitteln
DESCRIBE TABLE I_OBJBIN LINES V_LINES_BIN.
READ TABLE I_OBJBIN INDEX V_LINES_BIN.
I_OBJPACK-DOC_SIZE = V_LINES_BIN * 255 .
I_OBJPACK-BODY_NUM = V_LINES_BIN.
I_OBJPACK-DOC_TYPE = u2018PDFu2019.
I_OBJPACK-OBJ_NAME = u2019smartu2019.
I_OBJPACK-OBJ_DESCR = u2018testu2019.
APPEND I_OBJPACK.
CLEAR I_RECLIST.
I_RECLIST-RECEIVER = u2018email idu2019.
I_RECLIST-REC_TYPE = u2018Uu2019.
APPEND I_RECLIST.
CALL FUNCTION u2018SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = WA_DOC_CHNG
PUT_IN_OUTBOX = u2018Xu2019
TABLES
PACKING_LIST = I_OBJPACK
OBJECT_HEADER = WA_OBJHEAD
CONTENTS_BIN = I_OBJBIN
CONTENTS_TXT = I_OBJTXT
RECEIVERS = I_RECLIST
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.
Another EXample
you may use the FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF' to convert the fom
into PDF.
But first to get the printed form from the spool, use FUNCTION
'RSPO_FIND_SPOOL_REQUESTS'.
Then you may send it to your PC, email, fax, etc by reading the record in
the lines of table IT_PDF_OUTPUT.
Note: You may also use program RSTXPDFT4 as a reference to get code
examples which uses different functions to perform the creation of PDFand
download the form to the PC,etc.
CALL FUNCTION 'RSPO_FIND_SPOOL_REQUESTS'
EXPORTING
RQOWNER = SY-UNAME
TABLES
SPOOLREQUESTS = SPOOL_REQUESTS.
READ TABLE SPOOL_REQUESTS INDEX 1.
GD_SPOOL_NR = SPOOL_REQUESTS-RQIDENT.
CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
EXPORTING
SRC_SPOOLID = GD_SPOOL_NR
NO_DIALOG = C_NO
IMPORTING
PDF_BYTECOUNT = GD_BYTECOUNT
PDF_SPOOLID = PDFSPOOLID
BTC_JOBNAME = JOBNAME
BTC_JOBCOUNT = JOBCOUNT
TABLES
PDF = IT_PDF_OUTPUT
EXCEPTIONS
ERR_NO_OTF_SPOOLJOB = 1
ERR_NO_SPOOLJOB = 2
ERR_NO_PERMISSION = 3
ERR_CONV_NOT_POSSIBLE = 4
ERR_BAD_DSTDEVICE = 5
USER_CANCELLED = 6
ERR_SPOOLERROR = 7
ERR_TEMSEERROR = 8
ERR_BTCJOB_OPEN_FAILED = 9
ERR_BTCJOB_SUBMIT_FAILED = 10
ERR_BTCJOB_CLOSE_FAILED = 11.
CHECK SY-SUBRC = 0.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Lalit
U can use FM "SO_DOCUMENT_SEND_API1"
Regards.
Raju Mummidi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.