PDF aus Smartforms via Mail mit CL_BCS
Posted:
Tue Aug 25, 2015 3:25 pm
by Pauline4260
Hallo,
ich versuche verzweifelt, ein mit Smartforms erstelltes Formular über die CL_BCS-Klasse als PDF zu senden.
Meine Schritte:
1) Aufruf des Smartform-Formulars mit Rückgabe des OTF
2) CALL FUNCTION 'CONVERT_OTF_2_PDF'...
3) Aufbau der Mail über CL_BCS.
Aus dem CONVERT_OTF_2_PDF bekomme ich eine Tabelle mit "TDFORMAT und TDLINE". Damit kann eine "SOLI_TAB" oder "SOLIX_TAB" natürlich nichts anfangen.
Es scheitert also daran, die "ADD_ATTACHMENT" richtig zu befüllen.
Ich habe versucht, die TDFORMAT/TDLINE-Tabelle zu concatenaten in eine SOLI_TAB, aber der Mail-Anhang der erzeugt wird, kann nicht geöffnet werden.
Ich hoffe, jemand kann mir sagen, wie es nach dem CONVERT_OTF_2_PDF weiter geht.
Danke und Gruß
Dirk
Re: PDF aus Smartforms via Mail mit CL_BCS
Posted:
Wed Aug 26, 2015 7:42 pm
by Tron
Moin Dirk.
so sollte es funktionieren :
- Code: [Select all] [Expand/Collapse] [Download] (Untitled.txt)
*&---------------------------------------------------------------------*
*& Report YBC_SF_GENPDF
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
data FORMNAME
TYPE TDSFNAME
value 'ZTEST_ZEBRA'. data FM_NAME
TYPE RS38L_FNAM
. data OTF_output
type SSFCRESCL
.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = FORMNAME
IMPORTING
fm_name = FM_NAME
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
data ls_cp
TYPE SSFCTRLOP
.
ls_cp-NO_DIALOG = ' '.
ls_cp-GETOTF = 'X'.
*CALL FUNCTION '/1BCDWB/SF00000002'
CALL FUNCTION FM_NAME
EXPORTING
CONTROL_PARAMETERS = ls_cp
IMPORTING
JOB_OUTPUT_INFO = OTF_output
EXCEPTIONS
FORMATTING_ERROR = 1
INTERNAL_ERROR = 2
SEND_ERROR = 3
USER_CANCELED = 4
OTHERS = 5.
DATA: BEGIN OF lt_pdf
OCCURS 0, t(134),
END OF lt_pdf.
data DTAB
type table of DOCS
.
CALL FUNCTION 'CONVERT_OTF_2_PDF'
IMPORTING
BIN_FILESIZE = lv_len
OTF = OTF_output-OTFDATA[]
DOCTAB_ARCHIVE = DTAB
LINES = lt_pdf[]
EXCEPTIONS
ERR_CONV_NOT_POSSIBLE = 1
ERR_OTF_MC_NOENDMARKER = 2
OTHERS = 3.
* Implement suitable error handling here
data pdf_xstring
type xstring. CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
EXPORTING
INPUT_LENGTH = lv_len
IMPORTING
BUFFER = pdf_xstring
BINARY_TAB = lt_pdf[]
EXCEPTIONS
FAILED = 1
OTHERS = 2.
* Implement suitable error handling here
* -------- convert document -------------------------------
data pdf_content
TYPE table of solix
. pdf_content = cl_document_bcs=>xstring_to_solix( pdf_xstring ).
* TEST TEST
data fnam
type RLGRAP
-FILENAME
value 'c:\temp\000.pdf'.
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
BIN_FILESIZE = lv_len
FILENAME = fnam
FILETYPE = 'BIN'
DATA_TAB = pdf_content[]
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_WRITE_ERROR = 2
INVALID_FILESIZE = 3
INVALID_TYPE = 4
NO_BATCH = 5
UNKNOWN_ERROR = 6
INVALID_TABLE_WIDTH = 7
GUI_REFUSE_FILETRANSFER = 8
CUSTOMER_ERROR = 9
NO_AUTHORITY = 10
OTHERS = 11.
* Implement suitable error handling here
- GeSHi ©
Besser noch mit
CONVERT_OTF (liefert sofort Xstring in
bin_file ):
- Code: [Select all] [Expand/Collapse] [Download] (Untitled.txt)
*&---------------------------------------------------------------------*
*& Report YBC_CONVERT_OTF_PDF
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
DATA formname
TYPE tdsfname
VALUE 'ZTEST_ZEBRA'. DATA fm_name
TYPE rs38l_fnam
. DATA otf_output
TYPE ssfcrescl
.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = formname
IMPORTING
fm_name = fm_name
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
DATA ls_cp
TYPE ssfctrlop
.
ls_cp-no_dialog = ' '.
ls_cp-getotf = 'X'.
*CALL FUNCTION '/1BCDWB/SF00000002'
CALL FUNCTION fm_name
EXPORTING
control_parameters = ls_cp
IMPORTING
job_output_info = otf_output
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
DATA pdf_xstring
TYPE xstring. DATA lt_lines
TYPE TABLE OF tline
. " ist muss Parameter
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
pdf_delete_otftab = 'X'
IMPORTING
bin_filesize = lv_len
bin_file = pdf_xstring
otf = otf_output-otfdata[]
lines = lt_lines
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 4
OTHERS = 5
.
* Implement suitable error handling here
* -------- convert document -------------------------------
DATA pdf_content
TYPE TABLE OF solix
. pdf_content = cl_document_bcs=>xstring_to_solix( pdf_xstring ).
* TEST TEST
DATA fnam
TYPE rlgrap
-filename
VALUE 'c:\temp\000.pdf'.
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
bin_filesize = lv_len
filename = fnam
filetype = 'BIN'
data_tab = pdf_content[]
EXCEPTIONS
file_open_error = 1
file_write_error = 2
invalid_filesize = 3
invalid_type = 4
no_batch = 5
unknown_error = 6
invalid_table_width = 7
gui_refuse_filetransfer = 8
customer_error = 9
no_authority = 10
OTHERS = 11.
* Implement suitable error handling here
- GeSHi ©
lg Jens
Re: PDF aus Smartforms via Mail mit CL_BCS
Posted:
Thu Aug 27, 2015 6:55 am
by Pauline4260
Hallo Jens,
vielen Dank für deine Antwort, aber es geht mir nicht um das Sichern via WS_DOWNLOAD, sondern ich möchte das PDF mailen über die Methoden der Klasse CL_BCS.
Danke und Gruß
Dirk
Re: PDF aus Smartforms via Mail mit CL_BCS
Posted:
Mon Aug 31, 2015 9:58 am
by Pauline4260
Hallo,
es ging mir nicht um das Sichern des PDF, sondern um das mailen über die BCS-Klasse!
Danke und Gruß
Dirk
Re: PDF aus Smartforms via Mail mit CL_BCS
Posted:
Sat Sep 05, 2015 7:23 pm
by Tron
Moin.
es ging mir nicht um das Sichern des PDF, sondern um das mailen über die BCS-Klasse!
Das war mir bewusst. Ich nahm an, das Du lediglich die Wandlung des PDFs in SOLIX_TAB
suchst. (Der Download war nur ein Test)
- Code: [Select all] [Expand/Collapse] [Download] (Untitled.txt)
*&---------------------------------------------------------------------*
*& Report YBC_CONVERT_OTF_PDF
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
DATA formname
TYPE tdsfname
VALUE 'ZTEST_ZEBRA'. DATA fm_name
TYPE rs38l_fnam
. DATA otf_output
TYPE ssfcrescl
.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = formname
IMPORTING
fm_name = fm_name
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
DATA ls_cp
TYPE ssfctrlop
.
ls_cp-no_dialog = ' '.
ls_cp-getotf = 'X'.
*CALL FUNCTION '/1BCDWB/SF00000002'
CALL FUNCTION fm_name
EXPORTING
control_parameters = ls_cp
IMPORTING
job_output_info = otf_output
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
DATA pdf_xstring
TYPE xstring. DATA lt_lines
TYPE TABLE OF tline
. " ist muss Parameter
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
pdf_delete_otftab = 'X'
IMPORTING
bin_filesize = lv_len
bin_file = pdf_xstring
otf = otf_output-otfdata[]
lines = lt_lines
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 4
OTHERS = 5
.
* Implement suitable error handling here
* -------- convert document -------------------------------
DATA pdf_content
TYPE TABLE OF solix
. pdf_content = cl_document_bcs=>xstring_to_solix( pdf_xstring ).
* For Email contents
DATA lv_internetadr
TYPE adr6
-smtp_addr
. DATA lv_subject
TYPE so_obj_des
. DATA lv_attname
TYPE sood
-objdes
.
DATA send_request
TYPE REF TO cl_bcs
. DATA lt_text
TYPE bcsy_text
. DATA document
TYPE REF TO cl_document_bcs
. DATA recipient
TYPE REF TO if_recipient_bcs
. DATA bcs_exception
TYPE REF TO cx_bcs
. DATA sent_to_all
TYPE os_boolean
. DATA sender
TYPE REF TO if_sender_bcs
. DATA l_sendadr
TYPE adr6
-smtp_addr
.
* Email content
ls_SOLI-LINE = 'Dear Cusomer.'.
ls_SOLI-LINE = 'Thank you for your order.'.
* create the send request
send_request = cl_bcs=>create_persistent( ).
* Email subject
lv_subject = 'Test-Email mit Anhang'.
document = cl_document_bcs=>create_document(
i_type = 'RAW'
i_text = lt_text
i_subject = lv_subject ).
* add list attachment to document
document->add_attachment( i_attachment_type = 'PDF'
i_attachment_subject = lv_attname
i_att_content_hex = pdf_content ).
*=============== Prep Send
* add document to send request
send_request->set_document( document ).
* create recipient and add to send request
recipient = cl_cam_address_bcs=>create_internet_address( 'Deine@Email.de' ).
send_request->add_recipient( i_recipient = recipient ).
* create sender and add to send request
CONCATENATE 'Noreply@' sy
-sysid
'-' sy
-mandt
'.de' INTO l_sendadr
. sender = cl_cam_address_bcs=>create_internet_address( l_sendadr ).
send_request->set_sender( EXPORTING i_sender = sender ).
* send
send_request->set_send_immediately( i_send_immediately = 'X' ).
sent_to_all = send_request->send( i_with_error_screen = 'X' ).
CATCH cx_bcs
INTO bcs_exception
. MESSAGE e865
(so
) WITH bcs_exception
->error_type.
commit work and wait.
- GeSHi ©
lg Jens