2010 Sep 17 8:09 AM
Hello!
I've got a problem with the conversion of pdf documents in the business workflow.
I wrote a program where the user can choose a pdf document from his computer.
In another parameter he write the sap username of somebody. The program sends the sapmail to this written user.
The Parameter p_trans is only for the information in the text of the mail.
But the documents could not be opened...i think it's a problem with the conversion.
Or are there any settings in the sap i have to do?
Because a friend i know, can open pdf's documents with my programm.
But i have no idea where my fault is.
I do it with
open_file_dialog
gui_upload
and BCS
Maybe somebody can help me!
Thank you!
Greetings
Marcel
2010 Sep 17 4:29 PM
This could be 'anything'. You are not providing any relevant information one can use to help you.
1. Is there an error message when opening? If so, what error message?
2. Are you able to sent it to an external mail address and open it?
3. etc.
I do agree, that is probably has something to do with conversion. But since not even an extract of your coding is provided, we won't be able to help you.
This could be 'anything'. You are not providing any relevant information one can use to help you.
1. Is there an error message when opening? If so, what error message?
2. Are you able to sent it to an external mail address and open it?
3. etc.
I do agree, that is probably has something to do with conversion. But since not even an extract of your coding is provided, we won't be able to help you.
2010 Sep 17 4:29 PM
This could be 'anything'. You are not providing any relevant information one can use to help you.
1. Is there an error message when opening? If so, what error message?
2. Are you able to sent it to an external mail address and open it?
3. etc.
I do agree, that is probably has something to do with conversion. But since not even an extract of your coding is provided, we won't be able to help you.
2010 Sep 17 6:49 PM
Hey..
yes i know.
that's my first time here. i'm sorry.
There is no error! Everthing works.
But when i want to open the pdf document, acrobat reader says that it cannot open it.
And it's the same problem when i send the mail with the attachment to an external mail.
Everything is fine, but i can not open the pdf file.
Here are extracts of my code.
TYPES: t_file TYPE c LENGTH 1024.
TYPES: tt_file_content TYPE soli_tab.
DATA: gt_file_content TYPE tt_file_content.
PARAMETERS: p_file TYPE t_file OBLIGATORY LOWER CASE.
PARAMETERS: p_recpt TYPE uname.
PARAMETERS: p_trans(15) TYPE c OBLIGATORY.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
PERFORM select_file CHANGING p_file.
START-OF-SELECTION.
PERFORM get_file USING p_file
CHANGING gt_file_content.
PERFORM send_mail USING gt_file_content
p_file
p_recpt.
COMMIT WORK.
FORM select_file CHANGING p_file TYPE t_file.
DATA: l_rc TYPE sy-subrc,
lt_file TYPE filetable.
Choose the file:
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
window_title = 'Datei auswählen'
* default_extension =
default_filename = '*.pdf'
* file_filter =
* with_encoding =
* initial_directory =
* multiselection =
CHANGING
file_table = lt_file
rc = l_rc
* user_action =
* file_encoding =
EXCEPTIONS
file_open_dialog_failed = 1
cntl_error = 2
error_no_gui = 3
not_supported_by_gui = 4
OTHERS .
IF sy-subrc <> 0.
MESSAGE 'Fehler bei der Dateiauswahl' TYPE 'W'.
ELSE.
READ TABLE lt_file INTO p_file INDEX 1.
ENDIF.The Upload:
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = l_file
filetype = 'BIN'
has_field_separator = space
header_length = 0
read_by_line = 'X'
dat_mode = space
codepage = space
ignore_cerr = abap_true
replacement = '#'
* virus_scan_profile =
* IMPORTING
* filelength =
* header =
CHANGING
data_tab = pt_file_content.TRY.
lr_send_request = cl_bcs=>create_persistent( ).
CATCH cx_send_req_bcs INTO lr_cx_send_req_bcs.
MESSAGE 'document_creat_error' TYPE 'E'.
ENDTRY.
TRY.
lr_document = cl_document_bcs=>create_document(
i_type = 'RAW' " SAP Dokument
i_text = lt_mailtext[]
i_subject = l_subject ).
CATCH cx_document_bcs INTO lr_cx_document_bcs.
MESSAGE 'document_error' TYPE 'E'.
ENDTRY.
TRY.
* Splitten des Pfades
SPLIT p_file AT '' INTO TABLE lt_split.
l_index = LINES( lt_split ).
READ TABLE lt_split INTO l_subject INDEX l_index.
CLEAR lt_split.
SPLIT l_subject AT '.' INTO TABLE lt_split.
READ TABLE lt_split INTO l_attachment_subject INDEX 1.
READ TABLE lt_split INTO l_attachment_type INDEX 2.
CALL METHOD lr_document->add_attachment
EXPORTING
i_attachment_type = l_attachment_type
i_attachment_subject = l_attachment_subject
i_att_content_text = pt_file_content.
CATCH cx_document_bcs .
MESSAGE 'add_attachment' TYPE 'E'.
ENDTRY.
The text in the mail i only append like this here:
APPEND text-001 TO lt_mailtext.
APPEND text-002 TO lt_mailtext.
In the other parts i say...that it has to send the mail to the sap user, and it has to be an express mail.
In the end is send everything with:
TRY.
CALL METHOD lr_send_request->send
RECEIVING
result = l_sent_to_all.
CATCH cx_send_req_bcs INTO lr_cx_send_req_bcs.
MESSAGE 'Senden fehlgeschlagen' TYPE 'E'.
ENDTRY.
I didn't post the declarations and parameters.
Maybe you need one, for sure i will post it.
But i think, the post will be to big with declarations.
Thanks!
Marcel
2010 Sep 17 7:15 PM
The PDF file contents are in binary format so you need to use the binary attachment option - it looks like you are using the text format:
DATA: LT_PDFBIN TYPE SOLIX_TAB.
...
LR_DOCUMENT->ADD_ATTACHMENT( I_ATTACHMENT_TYPE = 'PDF'
I_ATTACHMENT_SUBJECT = FILENAME
I_ATT_CONTENT_HEX = LT_PDFBIN ).
2010 Sep 17 10:48 PM
I will check it on Monday.
Maybe that's the solution, i hope
Thanks and i will know you if that was my fault.
2010 Sep 20 6:47 AM
IT WORKS!
Another question, it's not so important, but do you know what i've to do, that i can upload also word or excel documents?
Thanks a lot Brad!!
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |