cancel
Showing results for 
Search instead for 
Did you mean: 

Getting a PDF in an xstring format in the ABAP environment

Former Member
0 Kudos

I am trying to create a PDF in ABAP reusing the ADS/SFP functionality that I can send to XI without saving the pdf first to a file (i.e. Getting the PDF in an xstring format or similar that can be put into an XML structure).

I've gone as far as to see that the class CL_FP_PDF_OBJECT appears to support returning an xstring; but does anyone have an example of how to work directly with this class or if there is a higher level class that can assist in this manner?

Note - My aim is to be able to generate reports online plus using the same form, be able to send the file through XI to be stored in Documentum (file store).

Regards,

Matt

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Okay - It was easy.

Basically without being clear, from your own program, you set up the print type parameters using

FP_CREATE_COMPOSER_INPUT with USER_SETTINGS = 'X' and CONTROL_PARAMETERS having no_dialog set to 'X'.

Then taking the output of this function, set getpdf = 'X' and call function FPCOMP_JOB_OPEN with the previous output (sets up the internal output for when you call the pdf creation step).

Now get your Adobe Form function and call it. The pdf xstring is returned in the formoutput variable.

Now you can send this xstring to XI, or use the function SCMS_XSTRING_TO_BINARY to get a binary table, and then you can do what you want with it like send through a BSP or save as a file.

If you want a better description, please reply to this message. my code is not worth posting at this stage as I'm just trying to prove it will work for some other developers.

markus_meisl
Active Contributor
0 Kudos

Hi Matt,

some input from SAP development:

Your steps work, but don't seem to be necessary. If you use the standard forms API (FP_JOB_OPEN, FP_JOB_CLOSE), the generated function module representing the form will return the PDF, if GETPDF is set.

To see what the PDF Object can do, have a look in your App Server at the programs called FP_PDF_TEST_*, which are samples of what the PDF Object can do. These programs are constantly being updated and enhanced, even in SPSs.

Best regards,

Markus Meisl

SAP NetWeaver Product Management

Former Member
0 Kudos

Thanks Markus.

The test programs make things much clearer. And for anyone else you can go to

http://help.sap.com/saphelp_nw04/helpdata/en/60/f8123e9c6c498084f9f2bafab32671/content.htm

to see the code to do this (adding the line to set getpdf to true first of course).

Former Member
0 Kudos

Hi Matt,

From the interface of the generated function module, the only output I see is in the exporting parameter JOB_OUTPUT_INFO in the OTFDATA component. We are having difficulty trimming this down as we cannot obtain the binary length of this blob.

Where did you get the xstring from that you mention?

Thanks,

Martin

Former Member
0 Kudos

Hi Matt,

I just noticed that the link you give to the help is for NW 2004. I wonder if there is some difference in 2004s, because the generated interface of the function module looks different. I have the following EXPORTING parameters:

*" VALUE(DOCUMENT_OUTPUT_INFO) TYPE SSFCRESPD

*" VALUE(JOB_OUTPUT_INFO) TYPE SSFCRESCL

*" VALUE(JOB_OUTPUT_OPTIONS) TYPE SSFCRESOP

As mentioned above, I get the binary output of the PDF back in the table component OTFDATA of JOB_OUTPUT_INFO - in binary form though! I am struggling to get this into a usable format or determine the length of the binary blob, as it seems to be doing some Unicode conversion internally on the binary data.

Thanks,

Martin

Former Member
0 Kudos

OK, I found the problem. It has to do with Interface Type that you specify on the Interface defined for the form. If it is set to "ABAP Dictionary-Based Interface", then the generated function module passes back the PDF in RAW format, instead of that Unicoded, formatted table without a size specification. We had it set to "Smart Forms-Compatible Interface".

Former Member
0 Kudos

Hi All,

excuse me if I send you a new request, but I'm developing an interface by XI in order to create a XML with a TAG <spool> containing a PDF file of an invoice printform. I create a proxy that is called after the printform creation (by a standard smartforms) using the OTF data released from FORM_CLOSE w/o the spool generation (get_otf parameters set to 'X'). after I create a message mapping that compose the final XML and send it to receivers.

My problem is related to the data type of my tag <spool>. my XSD schema output needs a xsd:based64Binary type. when I generated the proxy the system send a warning message ("The XSD type base64Binary does not exactly correspond to the ABAP type RAWSTRING Message no. SPRX067). When the data is passed from proxy to XI, every 77 characters, system inserts a CR/LF.

It's correct use a proxy?

in order to convert the OTF data to the based64 string I used:

CALL FUNCTION 'CONVERT_OTF_2_PDF'

IMPORTING

bin_filesize = lv_numbytes

TABLES

otf = i_otfdata

doctab_archive = ls_doctab_archive

lines = lt_line

...

  • Funzione per codifica in base64

CALL FUNCTION 'SSFC_BASE64_CODE'

EXPORTING

decode = ' '

io_spec = 'T'

ostr_input_data_l = lv_numbytes

TABLES

ostr_input_data = lt_line

ostr_digested_data = pdf_based64

EXCEPTIONS

....

thank you in advance,

Mauro