Skip to Content
-1

convert PDF data to OTF

Sep 05, 2017 at 10:50 AM

587

avatar image
Former Member

Hello Friends,

I have requirement that file need to be stored in SAP directory (Application server - AL11) in PDF format. Then this PDF file need to be converted into OTF format.

Please help on this requirement.

Regards,

Pranali

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Sandra Rossi Sep 06, 2017 at 05:44 AM
0

SAP provides only a converter from OTF to PDF.

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Feb 22 at 03:35 PM
0
  • Install SAPPDFPRINT 32-bit together with SAPGUI on your work center computers. SAP GUI automatically recognizes if SAPPDFPRINT is installed and prints interactive forms on the selected printer.
  • In the SAP system, create output devices with the device type PDF1 or PDFUC and access method 'G'. With access method 'F', the output via SAPPDFPRINT works only if you have implemented the corrections contained in SAP Note 2028598.
  • At present, only a 32-bit version of SAP GUI is available. Therefore, for front-end printing, you must also install the 32-bit version of SAPPDFPRINT. If a 64-bit version of SAP GUI become available in the future, the information provided in relation to server-based printing will apply.

If you previously used output devices with SAPWIN device types, you can use the report RSPO0022 to assign device type SAPWIN to XDC acrobat6. Make sure that you have imported the new version of RSPO0022 from SAP Note 1672781. When you print interactive forms, the system then generates a PDF data stream if you print using a printer with the device type SAPWIN.

***************** Test Report

REPORT ztest_pdf2spool.

INCLUDE fp_utilities. "#EC INCL_OK

DATA gv_cust_id TYPE s_customer.
DATA: content TYPE fpcontent.
DATA gs_outputparams TYPE sfpoutputparams.
DATA: total_pages TYPE fppagecount.

PARAMETERS: fpages TYPE i MODIF ID upl.

INITIALIZATION.

START-OF-SELECTION.


PERFORM upload_data.

PERFORM set_outpars.
PERFORM send_pdf_to_spool.

FORM send_pdf_to_spool.

DATA: size TYPE i.
DATA: total_size TYPE i.
DATA: spoolid TYPE rspoid.
DATA: copies TYPE rspocopies.
DATA: lifetime.

size = xstrlen( content ).
ADD size TO total_size.

copies = gs_outputparams-copies.
lifetime = gs_outputparams-lifetime.

CALL FUNCTION 'ADS_CREATE_PDF_SPOOLJOB'
EXPORTING
dest = gs_outputparams-dest
pages = total_pages
pdf_data = content
name = gs_outputparams-dataset
suffix1 = gs_outputparams-suffix1
suffix2 = gs_outputparams-suffix2
copies = copies
immediate_print = gs_outputparams-reqimm
auto_delete = gs_outputparams-reqdel
titleline = gs_outputparams-covtitle
receiver = gs_outputparams-receiver
division = gs_outputparams-division
authority = gs_outputparams-authority
lifetime = lifetime
IMPORTING
spoolid = spoolid
EXCEPTIONS
no_data = 1
not_pdf = 2
wrong_devtype = 3
operation_failed = 4
cannot_write_file = 5
device_missing = 6
no_such_device = 7
OTHERS = 8.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.

MESSAGE s060(ssfcomposer) WITH spoolid.


ENDFORM. " SEND_PDF_To_SPOOL


FORM upload_data.

INCLUDE fp_spool_constants.

DATA: name TYPE string,
filetype TYPE char10,
filetable TYPE filetable,
rc TYPE i,
guiobj TYPE REF TO cl_gui_frontend_services,
uact TYPE i.
DATA: datatab TYPE TABLE OF ssfdata.
DATA: extension TYPE string.
DATA: bin_filesize TYPE i.
DATA: buffer TYPE xstring.

extension = c_file_ext_pdf.
filetype = 'BIN'.
CONCATENATE '*' extension INTO name.
CREATE OBJECT guiobj.

CALL METHOD guiobj->file_open_dialog
EXPORTING
default_filename = name
CHANGING
file_table = filetable
rc = rc
user_action = uact
EXCEPTIONS
file_open_dialog_failed = 1
cntl_error = 2
error_no_gui = 3.
IF uact = guiobj->action_cancel.
LEAVE PROGRAM.
ENDIF.

READ TABLE filetable INDEX 1 INTO name.
CHECK sy-subrc = 0.

CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = name
filetype = filetype
IMPORTING
filelength = bin_filesize
TABLES
data_tab = datatab
EXCEPTIONS
file_open_error = 1
file_read_error = 2
invalid_type = 3
no_batch = 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.
LEAVE PROGRAM.
ENDIF. "#EC *

CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
EXPORTING
input_length = bin_filesize
IMPORTING
buffer = buffer
TABLES
binary_tab = datatab
EXCEPTIONS
failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
LEAVE PROGRAM.
ENDIF.

content = buffer.
total_pages = fpages.

ENDFORM.

FORM set_outpars .

DATA: ls_outpars TYPE sfpoutpar.

CALL FUNCTION 'FPCOMP_SHOW_DIALOG'
CHANGING
ie_outpar = ls_outpars
EXCEPTIONS
cancel = 1
usage_error = 2
system_error = 3
internal_error = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
LEAVE PROGRAM.
ELSE.
MOVE-CORRESPONDING ls_outpars TO gs_outputparams.
ENDIF.

ENDFORM.

Share
10 |10000 characters needed characters left characters exceeded
Michelle Crapo Feb 22 at 06:42 PM
0

A different answer - what I have done. in the past:

1. Upload the PDF

I've used function module GUI_UPLOAD with type BIN. Keep in mind there objects for this now. Do a search. I'm on an older version of SAP.

2. If you want to display it.

  CALL METHOD pdf_html_control->load_data
    EXPORTING
      url          = 'smart.pdf'
      size         = pdf_size
      type         = 'text'
      subtype      = 'pdf'
    IMPORTING
      assigned_url = l_url
    CHANGING
      data_table   = l_pdf_data[]
    EXCEPTIONS
      OTHERS = 1.
  IF sy-subrc <> 0.
    message = 'Internal IT error'.
  ENDIF.
 * show data
  CALL METHOD pdf_html_control->show_data
    EXPORTING
      url = l_url
    EXCEPTIONS
      OTHERS = 1.
  IF sy-subrc <> 0.
    message = 'Internal IT error'.
  ENDIF.

3. Use Open dataset for input / close dataset. to save to your A11 ":directory". Make sure you have a directory with authority for an SAP user to write to it. If needed, map your directory in configure of al11. See below for the open/close. (I check for the directory and then create a new one if it isn't there)

  OPEN DATASET file_name FOR OUTPUT IN BINARY MODE.
  IF sy-subrc <> 0.
    message = 'System failed to store the file onto the server'.
    EXIT.
  ENDIF.


  LOOP AT pdf.
    TRANSFER pdf TO file_name.
  ENDLOOP.


  CLOSE DATASET file_name.

4. To retrieve PDF

  OPEN DATASET p_file_name FOR INPUT IN BINARY MODE.
  IF sy-subrc <> 0.
    CONCATENATE 'Could not open file' p_file_name
        INTO p_message SEPARATED BY space.
    EXIT.
  ENDIF.


  CLEAR p_pdf.
  REFRESH p_pdf.
  DO.
    READ DATASET p_file_name INTO p_pdf.
    IF sy-subrc <> 0.
      EXIT.
    ENDIF.
    APPEND p_pdf.
  ENDDO.

5. Create the PDF from inside SAP. Use a Smartform. Once you have your smartform created and filled run the following - this will save the PDF as as string. Read documentation on the function modules.

    CLEAR message.
    pdf_cp-getotf = 'X'.
    pdf_cp-no_dialog = 'X'.
 
CALL FUNCTION fm_name
         EXPORTING
              control_parameters = pdf_cp
              user_settings      = ' '
              mdesc              = matdesc
              mqty               = mqty
              muom               = tuom
              mdol               = mdol
              unitprice          = munitprice
              mstartdate         = mstartdate
              menddate           = menddate
              vbdka              = tvbdka
              tvko               = tvko
              addrname1          = addrname1
              addrstras          = addrstras
              addrort01          = addrort01
              addrregion         = addrregion
              addrpstlz          = addrpstlz
              phoneco            = phoneco
              faxco              = faxco
              prttelefax         = prttelefax
              prttele            = prttele
              prtfax             = prtfax
         IMPORTING
              job_output_info    = pdf_joi
         TABLES
              addr               = addr
         EXCEPTIONS
              formatting_error   = 1
              internal_error     = 2
              send_error         = 3
              user_canceled      = 4
              OTHERS             = 5.


    IF pdf_joi-otfdata[] IS INITIAL.
      EXIT.
    ENDIF.




* convert the OTF data into a PDF format
    CALL FUNCTION 'CONVERT_OTF_2_PDF'
         EXPORTING
              archive_index         = archive_index
         IMPORTING
              bin_filesize          = bin_filesize
         TABLES
              otf                   = pdf_joi-otfdata
              lines                 = lines
              doctab_archive        = doctab
         EXCEPTIONS
              err_conv_not_possible = 1.


    IF sy-subrc <> 0 OR lines[] IS INITIAL.
      EXIT.
    ENDIF.


Share
10 |10000 characters needed characters left characters exceeded