PDF to Binary
Hi,
I create a Adobe Interactive Form, I need to display this PDF in SAP portal, then I need to develop a RFC to return this PDF file, I read in other post that the way is to convert de PDF to binary file a return this binary file like a paremeter in the RFC.
Someone have an example about this?
Regards
Eduardo Campos
This works for me, it copies an excel file into another excel file.
You can keep the binary information as long as you want and later download the file to another place.
You can try it to see if it works for you.
Remember to keep the file lenght.
types: stringa(4096).
data: tabla type standard table of stringa.
DATA: FILE TYPE STRING.
DATA: LENGHT TYPE I.
fILE = 'C:\DOCUMENTS AND SETTINGS\myuser\MY DOCUMENTS\BOOK1.XLS'.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = FILE
FILETYPE = 'BIN'
* HAS_FIELD_SEPARATOR = ' '
* HEADER_LENGTH = 0
* READ_BY_LINE = 'X'
* DAT_MODE = ' '
IMPORTING
FILELENGTH = LENGHT
* HEADER =
TABLES
DATA_TAB = tabla.
BREAK RJESCISL.
fILE = 'C:\DOCUMENTS AND SETTINGS\myuser\MY DOCUMENTS\BOOK2.XLS'.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE = LENGHT
FILENAME = file
FILETYPE = 'BIN'
* APPEND = ' '
* WRITE_FIELD_SEPARATOR = ' '
* HEADER = '00'
* TRUNC_TRAILING_BLANKS = ' '
* WRITE_LF = 'X'
* COL_SELECT = ' '
* COL_SELECT_MASK = ' '
* DAT_MODE = ' '
* IMPORTING
* FILELENGTH =
TABLES
DATA_TAB = TABLA
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.
Edit: Sorry, didn't read the question right.
Well, is almost the same way, just use Open dataset dsn in binary mode. That way you'll get your file in binary mode.
I was supossing you were usen a local file but now I see you want it in the application server
Edited by: Ramiro Escamilla on Feb 29, 2008 10:11 PM
Similar Messages
-
hi all,
how to convert pdf to binary .
regards,
sheetalrefer this -
http://www.geocities.com/rmtiwari/main.html?http://www.geocities.com/rmtiwari/Resources/MySolutions/Dev/Codes/Report/Z_RMTIWARI_XSTRING_TEXT_CONVER.html -
Decode Base64(Pdf) to binary
Hi all,
I have a WS - PI - File scenario.
So I get a base64 coded PDF-File and have to create a decoded binary file.
First I used an UDF. But the created document is invalid and not to open by Acrobat. After reading the forum the conclusion is, it is impossible to convert data in mapping step, is'nt it.
But what are the other possibilities?
Regards
MathiasYou can do this in the mapping using Base64.decode() method from SAP standard API (com.sap.aii.utilxi.base64.api.*)
Check my WIKI section for ref: [Sending Binary Data to Inbound Plain HTTP Adapter in XI and PI |http://wiki.sdn.sap.com/wiki/display/XI/SendingBinaryDatatoInboundPlainHTTPAdapterinXIand+PI] where i used encode method in HTTP client code.
You can check decode method code in the java snippet "Java Mapping - Base64 Decryption and Unzipping Code "
Edited by: Praveen Gujjeti on Jul 16, 2010 4:59 PM -
How To formate PDF Data(Binary) to HTML Formate
Hi All,
I am using PDFs in my application. Once the user has submitted his project in formation through pdf, it stores in BAPI. When i tried to retrive the data from back end to display in a view. it shows me all the information is in single line because of PDf binary data. Can any one knows about how to display pdf data in a view (html) with multiple lines.
Thanks
Regards
Ravi.GollaHi Ravi,
See this thread...It might be useful for u..
/people/mark.finnern/blog/2003/09/23/bsp-programming-handling-of-non-html-documents
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/4fd2d690-0201-0010-de83-b4fa0c93e1a9
Urs GS -
PDF to binary: Scenario R/3 to MQSeries
The JMS adapter transfers the message payload from and to the MQSeries whithout any change.
I am not sure, what you want to have as result, when you mention "binary".
Any file is binary, even an XML file
The next question is: When you read a PDF, what do you want with it?
The easiest thing is, sending the PDF through PI to MQSeries without any change. Then you receive just the original PDF.
Regards
StefanHi
check this thread
spool to pdf conversion
It looks like you are missing translate in you processing of the table t_pdf. Something like the following line is missing:
TRANSLATE gd_buffer USING '~ '.
Loo at the standard program RSTXPDFT4 as well. It converts spool to PDF and then you can download it to your desktop. -
Convert filled PDF into binary and store in R3 table
Hi .. Is there any way to save my entire pdf form into r/3 either in presentation level or ztable as binary upon user submit .. ?
Edited by: nyap kah wai on Aug 6, 2009 4:27 AMHi,
Below is the code which may help you out.
***Retrieve your Pdf source in Onclick event of submti button.
DATA lo_el_context TYPE REF TO if_wd_context_element.
DATA ls_context TYPE wd_this->element_context.
DATA lv_pdfsource LIKE ls_context-pdfsource.
* get element via lead selection
lo_el_context = wd_context->get_element( ).
* get single attribute
lo_el_context->get_attribute(
EXPORTING
name = `PDFSOURCE`
IMPORTING
value = lv_pdfsource ).
Convert to Binary using below code..
DATA: p_image TYPE sdokcntbins.
DATA: p_image_len TYPE i.
CLEAR: p_image_len.
REFRESH p_image[].
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = lv_pdfsource
* APPEND_TO_TABLE = ' '
IMPORTING
output_length = p_image_len
TABLES
binary_tab = p_image[].
Now you can use this binary tab to update your custom table..
Rgds
Vara -
Map binary data (PDF) to XML not possible due to non-printable chars
Hi XI Gurus,
we have the following issue.
We send a PDF as binary data (as a hex string '25255044462D3' ) along with some other information from ERP within one RFC to XI , doing a message split 1:n for those two kind of messages (1. the PDF, 2. the XML) an send the split messages to file/ftp receiver adapter.
The message split and sending of the messages is working well, but we encounter some problems with non-printable chars (hex code below 0x20) in the pdf binary. The PDF data and the dynamic file name is mapped into an XML. But the non printable characters are converted into '#' when mapped into the XML target field.
(Due to the 1:n multi mapping, we cannot put the filename into dynamic configuration, so we have to map the pdf and the filename into an XML and extract the content with variable substitution in receiver file adapter....)
My question is: how can binary data with non-printable chars be sent through XI and can be mapped into an XML without beeing replaced by '#' ?
Any help will be greatly appreciated.
Thanks and regards
HolgerMaybe I didn´t explained it clearly enough.
We do not have the issue that the RFC puts the '#' into the string. We got from the RFC a hex string containing the pdf as visible hex values like:
As you can see we have the pdf as hex string. During message mapping XI replaces some non-printable chars like '0x04' or '0x19' with '#'.
My question is: how can we avoid those char replacement ?
BTW: I grabbed a pdf with sender file adapter, routed through XI without any mapping and send it with ftp in binary mode. But the pdf contains more chars as the origional file and the pdf content is not visible when opening with a pdf reader like Acrobat. I guess the file adpter has problems with carriage return and linefeed chars. Some CR and LF are replaced inserted somehow.
Best regards,
Holger -
Adobe Forms, XML(PDF format) to PDF binary
Hi experts!
I'm working with Interactive Adobe Forms and the form function return the PDF in a XML format (xstring) through the parameter FPFORMOUTPUT-XML.
I need to save the PDF file (binary) without geting it through the "getpdf" parameter FPFORMOUTPUT-PDF.
Because the "getpdf" don't permit to show the user dialog print options.
How could I transform the XML(PDF) returned in binary PDF file?
Thank you all!Hello Evaristo
You can make use of CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' and CALL METHOD cl_gui_frontend_services=>gui_download to achieve this requirement.
Regards
Sandy
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = ls_params->es_output-s_form_output-xml
IMPORTING
output_length = lv_pdf_len
TABLES
binary_tab = lt_pdf.
lv_file_name = p_xml.
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
bin_filesize = lv_pdf_len
filename = lv_file_name
filetype = 'BIN'
CHANGING
data_tab = lt_pdf
EXCEPTIONS
OTHERS = 1. -
PdfSource of InteractiveForm UI element should be populated with pdf binary
Hey Guys...
I need some help here...
I have a Web Dynpro Java Application that retrieves data from R/3 and I want to (only) display that data using Adobe. I've set the "mode" property of the UI Element as "usePdf" and I have bound the pdfSource property to a binary type in the context, but as I'm about to display the PDF I get the following exception: (the important part of it)
Caused by: com.sap.tc.webdynpro.services.exceptions.WDRuntimeException: pdfSource of InteractiveForm UI element should be populated with pdf binary content in USE_PDF mode
Do you have any idea of what is going on?. Is it the right scenario?
Should I use generatePdf instead? if that's the case then get Credentials for that?. Would this have any additional cost?
Thank you
David.
Edited by: duztariz on Mar 20, 2009 11:24 PM
Edited by: duztariz on Mar 20, 2009 11:26 PMIn your szenario you have to give the PDF as binary content into this content variable. You can do that for example by reading a PDF File as a binary stream and store it into this content variable.
Then you can use the Interactive Form UI Element to show this PDF.
But from what I understand, its not exactly what you want? You want to show some data that you read from R/3 and display it in an interactive form?
What you have to do is, to edit your Interactive form, create the Bindings etc. (see tutorials) and set the mode to "modify PDF". Then the PDF will show the read data for you. -
PDF binary in backend, show in WDJ interactive form
Hello,
I have a backend system, supplying a PDF in binary format "Xstring".
I want to show it in Web Dynpro Java, using an Interactive Form.
I'm trying to bind the binary, to the pdfSource, but a error comes up.
What is the problem?
Best Regardscom.sap.tc.webdynpro.clientserver.adobe.pdfdocument.base.core.PDFDocumentRuntimeException: Failed to USEPDF
at com.sap.tc.webdynpro.clientserver.uielib.adobe.impl.InteractiveForm.afterHandleActionEvent(InteractiveForm.java:418)
at com.sap.tc.webdynpro.clientserver.cal.ClientApplication.afterApplicationModification(ClientApplication.java:1132)
at com.sap.tc.webdynpro.clientserver.cal.ClientComponent.afterApplicationModification(ClientComponent.java:895)
at com.sap.tc.webdynpro.clientserver.window.WindowPhaseModel.doRespond(WindowPhaseModel.java:573)
at com.sap.tc.webdynpro.clientserver.window.WindowPhaseModel.processRequest(WindowPhaseModel.java:152)
at com.sap.tc.webdynpro.clientserver.window.WebDynproWindow.processRequest(WebDynproWindow.java:335)
at com.sap.tc.webdynpro.clientserver.cal.AbstractClient.executeTasks(AbstractClient.java:143)
at com.sap.tc.webdynpro.clientserver.session.ApplicationSession.doProcessing(ApplicationSession.java:319)
at com.sap.tc.webdynpro.clientserver.session.ClientSession.doApplicationProcessingStandalone(ClientSession.java:713)
at com.sap.tc.webdynpro.clientserver.session.ClientSession.doApplicationProcessing(ClientSession.java:666)
at com.sap.tc.webdynpro.clientserver.session.ClientSession.doProcessing(ClientSession.java:250)
at com.sap.tc.webdynpro.clientserver.session.RequestManager.doProcessing(RequestManager.java:149)
at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doContent(DispatcherServlet.java:62)
at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doGet(DispatcherServlet.java:46)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:401)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:266)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:386)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:364)
at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:1039)
at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:265)
at com.sap.engine.services.httpserver.server.Client.handle(Client.java:95)
at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:175)
at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
at java.security.AccessController.doPrivileged(Native Method)
at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:102)
at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:172)
Caused by: java.lang.IllegalArgumentException
at com.sap.dictionary.runtime.DdTypeBinary.format(DdTypeBinary.java:63)
at com.sap.dictionary.runtime.DdTypeBinary.toString(DdTypeBinary.java:67)
at com.sap.tc.webdynpro.clientserver.data.DataContainer.doFormat(DataContainer.java:1405)
at com.sap.tc.webdynpro.clientserver.data.DataContainer.getAndFormat(DataContainer.java:1098)
at com.sap.tc.webdynpro.clientimpl.xdp.renderer.data.XfdRenderer.renderAttributes(XfdRenderer.java:370)
at com.sap.tc.webdynpro.clientimpl.xdp.renderer.data.XfdRenderer.renderElement(XfdRenderer.java:221)
at com.sap.tc.webdynpro.clientimpl.xdp.renderer.data.XfdRenderer.renderLeadSelectedElement(XfdRenderer.java:183)
at com.sap.tc.webdynpro.clientimpl.xdp.renderer.data.XfdRenderer.render(XfdRenderer.java:79)
at com.sap.tc.webdynpro.clientserver.renderer.AbstractRenderManager.render(AbstractRenderManager.java:62)
at com.sap.tc.webdynpro.clientserver.uielib.adobe.impl.AdobeFormHelper.getDataStream(AdobeFormHelper.java:537)
at com.sap.tc.webdynpro.clientserver.uielib.adobe.impl.AdobeFormHelper.getDataStream(AdobeFormHelper.java:1047)
at com.sap.tc.webdynpro.clientserver.uielib.adobe.impl.AdobeFormHelper.getDocumentContextForXMLExchange(AdobeFormHelper.java:907)
at com.sap.tc.webdynpro.clientserver.uielib.adobe.impl.InteractiveForm.afterHandleActionEvent(InteractiveForm.java:365)
... 29 more
wdContext.currentContextElement().setPdfbinary(); (type binary)
the backend data, is byte[], and starts with 25 50 ... (it's ok, confirmed in a HEX editor)
Regars
Edited by: Joao.Ferreira on Aug 19, 2010 5:02 PM -
How to show custom header in pdf generated from report
Hi,
I have created a report that is used to display Leave record of employees in an organization. After which it creates a pdf file and send it to respective HOD.
In this case I am trimming generated output and sendinf only required fields to the pdf.
When pdf is getting generated it shows program name as Title of that report.
I want to change this header to my own header along with some variable but not sure how I can do so.
I have also tried TOP-OF_PAGE but problem in this case is that I am still getting program name along with it.
To generate pdf I have used function :
call function 'CONVERT_ABAPSPOOLJOB_2_PDF'
exporting
src_spoolid = spoolid
no_dialog = ' '
importing
pdf_bytecount = l_no_of_bytes
pdf_spoolid = l_pdf_spoolid
btc_jobname = l_jobname
btc_jobcount = l_jobcount
tables
pdf = l_pdfdata.
Then I had converted this pdf to Binary
call function 'QCE1_CONVERT'
tables
t_source_tab = l_pdfdata
t_target_tab = lit_record
exceptions
convert_not_possible = 1
others = 2.
Then I had created subject matter and used FM : SO_NEW_DOCUMENT_ATT_SEND_API1: to send mail to respective HODs.
I tried dubbing it but couldn't get any variable which is holding program name.
Sorry for putting in wrong forum.
so Closing it from this forum and raising the same in ABAp-General forum.
How to change header of pdf in generated report
Edited by: gaur.yagyesh on Apr 16, 2010 4:03 PMTo make it more clear to my question.
I am using sun one webserver 6.0 sp6.
I need to enable custom header on the webserver so that any request having a custom http header coming to webserver should be captured by the webserver.
Thanks, -
Merge Different Spools containing a Single PDF page into a Single PDF file.
Greetings,
I am developing a custom object where in i need to read PDF file from many different Spools(Range given on Input Screen), where each spool has a single PDF page in it. I need to combine all these PDF Pages into a single PDF file & either create a new Spool or save it on an Application Server.
At present i have developed the code where in i am able to read the PDF files from different spools & convert them into Binary but i am not able to generate it back to PDF file.
Kindly find my code for your reference.
CODE:-
START-OF-SELECTION.
PERFORM f_get_spool_1000 .
PERFORM g_conv_pdf_to_bin_2000 .
*& Form F_GET_SPOOL_1000
text
FORM f_get_spool_1000 .
SELECT * FROM tsp01
INTO TABLE gt_tsp01
WHERE rqident IN s_spool
ORDER BY rqcretime DESCENDING.
IF sy-subrc = 0.
SORT gt_tsp01 BY rqident .
ENDIF.
ENDFORM.
*& Form G_CONV_PDF_TO_OTF_2000
text
DATA: lv_filename_out TYPE string,
lv_len TYPE i,
lt_tab TYPE tsfixml .
DATA: lwa_print_parms LIKE pri_params,
lv_valid(1) TYPE c .
DATA: lv_linsz LIKE sy-linsz VALUE 132, " Line size
lv_paart LIKE sy-paart VALUE 'X_65_132'. " Paper Format
DATA : lt_tsp01 TYPE STANDARD TABLE OF tsp01 ,
lwa_tsp01 TYPE tsp01 .
CLEAR : gv_pdf, gwa_tsp01, gv_renderpagecount .
LOOP AT gt_tsp01 INTO gwa_tsp01.
CALL FUNCTION 'FPCOMP_CREATE_PDF_FROM_SPOOL'
EXPORTING
i_spoolid = gwa_tsp01-rqident
i_partnum = 1
IMPORTING
e_pdf = gv_pdf
e_renderpagecount = gv_renderpagecount
e_pdf_file = gv_pdf_file
EXCEPTIONS
ads_error = 1
usage_error = 2
system_error = 3
internal_error = 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.
CLEAR lv_len .
REFRESH gt_bin .
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = gv_pdf
IMPORTING
output_length = lv_len
TABLES
binary_tab = gt_bin.
CLEAR gwa_bin .
LOOP AT gt_bin INTO gwa_bin.
APPEND gwa_bin TO gt_listout.
CLEAR gwa_bin .
ENDLOOP.
ENDLOOP.
Get FP reference
DATA: lo_fp TYPE REF TO if_fp VALUE IS INITIAL,
lo_pdfobj TYPE REF TO if_fp_pdf_object VALUE IS INITIAL,
lo_exc TYPE REF TO cx_root,
lv_xslt_message TYPE string .
lo_fp = cl_fp=>get_reference( ).
For handling exceptions
DATA: lo_fpex TYPE REF TO cx_fp_runtime VALUE IS INITIAL.
TRY.
lo_pdfobj = lo_fp->create_pdf_object( connection = 'ADS' ).
Set document
lo_pdfobj->set_document(
EXPORTING
pdfdata = gt_listout ).
Tell PDF object to extract data
lo_pdfobj->set_extractdata( ).
Execute the call to ADS
lo_pdfobj->execute( ).
CATCH cx_root INTO lo_exc.
lv_xslt_message = lo_exc->get_text( ).
ENDTRY.
Your quick reply would be of great help.
Regards.Thank Your for your concern, there are many replies & posts but all of them points only to Try what they have said. As being said that trying to convert PDF to binary & appending many PDF similarly would not let you generate a single PDF again.
Your Kind guidance would be really appreciable.
Regards. -
Attach an xml to a pdf using ADS
Hi all,
I have a scenario where we are sending a Base64 encoded PDF (a bill) and the corresponding xml data from SAP backend on level 4.6C to PI 7.1. In PI we should attach the xml data to the PDF. I have already succeeded to do this using iText but we have a requirement to do this with ADS instead. In Netweaver Developer Studio I created an example project where I am reading a PDF as a byte array, also reading an XML file and try to attach the XML to the PDF using the ADS api. The project successfully built in NWDS but when I am running the project it failes.
I am using standard code to attach the xml stream to the pdf, the error message is thrown when the following line is executed:
IWDPDFDocument document = context.execute();
Exception in thread "main" java.lang.ExceptionInInitializerError
at com.sap.tc.webdynpro.clientserver.adobe.pdfdocument.impl.PDFDocumentAccessibleContextWDImpl.execute(PDFDocumentAccessibleContextWDImpl.java:99)
at com.eon.xi.dijnet.base64.PdfWithAttachment.addAttachmentWithSap(PdfWithAttachment.java:129)
at com.eon.xi.dijnet.base64.PdfWithAttachment.main(PdfWithAttachment.java:218)
Caused by: java.lang.NullPointerException
at com.sap.tc.webdynpro.services.sal.deployment.core.DeployableObjectInternal.getSystemDeployableObjectName(DeployableObjectInternal.java:53)
at com.sap.tc.webdynpro.clientserver.uielib.adobe.impl.AdobeFormHelper.<clinit>(AdobeFormHelper.java:115)
... 3 more
Is it the problem with the PDF that it is not an Interactive Form?
Or the problem is simply that I am trying to run the project on my local machine where ADS is not available?
Thanks for your help.
Pal
Edited by: Pal Somogyi on Oct 17, 2010 10:30 PM
Edited by: Pal Somogyi on Oct 18, 2010 11:44 AMHi Pal,
There is a requirement to generate an Adobe Form using SAP Interactive forms, and then, send this PDF to a non-SAP system using Base-64 encoding. The receiving system will decode this file and re-generate a PDF.
I have heard that this could be done in the PI layer, using the Conversion Agent.
Another approach which I can think of is convert PDF to binary and then use the cl_http_utility=>encode_base64 to convert binary to base64.
You have mentioned that you have had to send a base 64 encoded pdf. Could you pelase guide me through the process?
Thanks,
Preethi. -
How to open a pdf file using OPEN DATASET
Im trying to convert a pdf into binary format. So im trying to read the contents of the pdf into a XSTRING. Using the FM 'SCMS_XSTRING_TO_BINARY' i can convert the XSTRING to binary format.
How to open a pdf file using OPEN DATASET and transfer its contents in a XSTRING variable.
What i've tried is....
DATA: f_name type string value 'C:\rep_output_pdf.pdf',
x1 type xstring,
LT_DATA TYPE STANDARD TABLE OF X255.
OPEN DATASET f_name FOR input IN BINARY MODE.
READ DATASET f_name INTO x1.
CLOSE DATASET f_name.
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
BUFFER = x1
TABLES
BINARY_TAB = LT_DATA.
Im getting a short dump .
Short text: The file is not open.
Plz help me out.Hello Rajesh,
You are trying to do use OPEN DATASET with a local file. NOT POSSIBLE
You have to have the file in the app server to use OPEN DATASET.
BR,
Suhas -
How to attach a PDF to a mail with document-add_attachment
Hello,
I don't know how to pass the PDF to binary, in order to be able to pass the parameter to the method add_attachment.
Exist any FM? How to make compatible this new binary file with the parameter of the method?
document->add_attachment(
i_attachment_type = 'PDF'
i_attachment_subject = 'attachment'
i_att_content_hex = ???? ).
Thank you,
ManelHi,
Follow example here.
DATA: l_doland1 TYPE char255,
l_doland2 TYPE char255.
Preparing body of the Mail
MOVE 'Please Find the Attached Packlist' TO l_text.
APPEND l_text TO i_content.
Preparing contents of attachment with Change Log
PERFORM prepare_attachment.
Creates persistent send request
TRY.
l_send_request = cl_bcs=>create_persistent( ).
Creating Mail Subject
CONCATENATE '(' 'DO#' vbpla-vbeln INTO l_doland1.
CONCATENATE vbpla-land1 ')' '-' 'Packlist' INTO l_doland2.
CONCATENATE 'PreAlert from ATSG' l_doland1 'TO' l_doland2
INTO l_subject separated by space.
MOVE l_subject TO i_subjec.
Creating Document
l_document = cl_document_bcs=>create_document(
i_type = 'RAW'
i_text = i_content[]
i_subject = i_subjec ).
Size of PDF Document
l_size = l_byte_count.
Adding Attachment
CALL METHOD l_document->add_attachment
EXPORTING
i_attachment_type = c_ext
i_attachment_size = l_size
i_attachment_subject = 'Packing List'
i_att_content_hex = i_attachx[].
Add document to send request
CALL METHOD l_send_request->set_document( l_document ).
Get Sender Object
l_uname = sy-uname.
l_sender = cl_sapuser_bcs=>create( l_uname ).
CALL METHOD l_send_request->set_sender
EXPORTING
i_sender = l_sender.
E-Mail
SELECT * FROM zsdshpalertlist INTO TABLE email_list
WHERE kunnr = vbpla-kunwe.
LOOP AT email_list.
CHECK NOT email_list-email IS INITIAL.
ld_email = email_list-email.
l_recipient = cl_cam_address_bcs=>create_internet_address( ld_email ).
CALL METHOD l_send_request->add_recipient
EXPORTING
i_recipient = l_recipient
i_express = 'U'
i_copy = ' '
i_blind_copy = ' '
i_no_forward = ' '.
ENDLOOP.
*Trigger E-Mail immediately
l_send_request->set_send_immediately( 'X' ).
CALL METHOD l_send_request->send( ).
COMMIT WORK.
CATCH cx_document_bcs INTO l_bcs_exception.
CATCH cx_send_req_bcs INTO l_send_exception.
CATCH cx_address_bcs INTO l_addr_exception.
ENDTRY.
FORM prepare_attachment .
DATA: wa_pdf TYPE tline,
wa_attachx TYPE solix,
l_pdf_len TYPE i,
l_con_len TYPE i,
l_pdf_pos TYPE i,
l_con_pos TYPE i,
l_spool_size TYPE sood-objlen.
FIELD-SYMBOLS: <fs_con> TYPE x.
l_con_pos = 0.
DESCRIBE FIELD wa_pdf LENGTH l_pdf_len IN BYTE MODE.
DESCRIBE FIELD wa_attachx LENGTH l_con_len IN BYTE MODE.
LOOP AT i_pdf INTO wa_pdf.
ASSIGN wa_pdf TO <fs_con> CASTING.
CHECK sy-subrc EQ 0.
DO l_pdf_len TIMES.
l_pdf_pos = sy-index - 1.
IF l_con_pos = l_con_len.
APPEND wa_attachx TO i_attachx.
FREE wa_attachx.
l_con_pos = 0.
ENDIF.
MOVE <fs_con>l_pdf_pos(1) TO wa_attachx-linel_con_pos(1).
ADD 1 TO l_con_pos.
ENDDO.
ENDLOOP.
IF l_con_pos > 0.
APPEND wa_attachx TO i_attachx.
ENDIF.
ENDFORM.
Maybe you are looking for
-
Expried and Open Quotations.
Dear SAPFriends, I would like to ask a question. Every quotation has a validity period and after that it is expired. The status of the quotation is open or complete depending the customizing and usually if the qty has been referenced. When the quotat
-
When starting the computer, it stops at a gray screen and doesn't go any further. I have ran the hardware disc utility multiple times. When I click the verify disk it says that 1 volume needs to be repaired. When I click repair disk, it says that the
-
UIX: MessageList : How to add empty option?
Hi everyone, I've got this MessageList code: <messageList model="${bindings.IdUnidadOrg1}" prompt="Father" required="no"> <contents childData="${bindings.IdUnidadOrg1.displayData}"> <option model="${uix.current}"/> </contents> </messageList> The data
-
Hi, Seem to be having trouble getting the audio to encode during export. First, using the exact same settings as before with a prior and successful audio export, I exported the video and audio. I played the video back in Premiere and you can clearl
-
G/ account in material master
hi gurus, wheen ever u have to maintain account assignment catagery in material master record, there u need not to give any material. but there we have to post to cost center, that is the reason we have to give account assignment catagory 'k'. but