Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Transfer pdf file to application server

Former Member
0 Likes
3,415

Hi Experts,

I am converting smartforms into pdf and try to send to application server but file is corrupted and cannot open.

The code is as follows

CALL FUNCTION 'CONVERT_OTF'

EXPORTING

FORMAT = 'PDF'

MAX_LINEWIDTH = 132

  • ARCHIVE_INDEX = ' '
  • COPYNUMBER = 0
  • ASCII_BIDI_VIS2LOG = ' '
  • PDF_DELETE_OTFTAB = ' '

IMPORTING

BIN_FILESIZE = W_bin_filesize

BIN_FILE =  l_pdf_xstring

TABLES

otf = T_OTF

lines = T_pdf_tab

EXCEPTIONS

ERR_MAX_LINEWIDTH = 1

ERR_FORMAT = 2

ERR_CONV_NOT_POSSIBLE = 3

ERR_BAD_OTF = 4

OTHERS = 5

IF W_bin_filesize > 0.

     OPEN DATASET p_filein FOR OUTPUT IN BINARY MODE.

    

        transfer l_pdf_xstring to p_filein.

close dataset p_fielin.

endif.

Please advise how to get the correct file.

Thanks in advance.

Warm regards

Chandra

Hi Experts,

I am converting smartforms into pdf and try to send to application server but file is corrupted and cannot open.

The code is as follows

CALL FUNCTION 'CONVERT_OTF'

EXPORTING

FORMAT = 'PDF'

MAX_LINEWIDTH = 132

  • ARCHIVE_INDEX = ' '
  • COPYNUMBER = 0
  • ASCII_BIDI_VIS2LOG = ' '
  • PDF_DELETE_OTFTAB = ' '

IMPORTING

BIN_FILESIZE = W_bin_filesize

BIN_FILE =  l_pdf_xstring

TABLES

otf = T_OTF

lines = T_pdf_tab

EXCEPTIONS

ERR_MAX_LINEWIDTH = 1

ERR_FORMAT = 2

ERR_CONV_NOT_POSSIBLE = 3

ERR_BAD_OTF = 4

OTHERS = 5

IF W_bin_filesize > 0.

     OPEN DATASET p_filein FOR OUTPUT IN BINARY MODE.

    

        transfer l_pdf_xstring to p_filein.

close dataset p_fielin.

endif.

Please advise how to get the correct file.

Thanks in advance.

Warm regards

Chandra

8 REPLIES 8
Read only

Former Member
0 Likes
2,092

hi Chandra

You should use the internal table T_PDF_TAB not I_PDF_XSTRING.

loop at T_PDF_TAB.

transfer T_PDF_TAB-field to p_filein.

endloop.

regards,

Archer

Read only

0 Likes
2,092

Hi Archer,

Thanks for the quick update. Again error in opening the PDF file and message displayed the file is corrupted.

Please advise.

Warm regards

Chandra

Read only

0 Likes
2,092

Try this function SX_OBJECT_CONVERT_OTF_PDF, and you will get the PDF data in Binary Content in Changing parameter Content_bin.

BTW, you can sure T_OTF have data, right?

regards,

Archer

Read only

peng_wen
Product and Topic Expert
Product and Topic Expert
0 Likes
2,092

Hello,


note 1320163 might helpful.

Regards,
Wen Peng

Read only

Former Member
0 Likes
2,092

Hi Wen,

I looked at the note but no joy!.

Please advise.

Warm regards

Chandra

Read only

Former Member
0 Likes
2,092

Hello

You need to call Fucntion module convert_otf.

CALL FUNCTION 'CONVERT_OTF'
        EXPORTING
          format                = 'PDF'
          MAX_LINEWIDTH         = 132
        IMPORTING
          bin_filesize          = lv_bin_filesize
          bin_file              = lv_pdf

        TABLES
          otf                   = ls_otfdata-otfdata[]
          lines                 = lv_bin_tline
        EXCEPTIONS
          err_max_linewidth     = 1
          err_format            = 2
          err_conv_not_possible = 3
          err_bad_otf           = 4
          OTHERS                = 5.

After calling this FM call FM 'SX_OBJECT_CONVERT_OTF_PDF' which will convert into pdf file.

CALL FUNCTION 'SX_OBJECT_CONVERT_OTF_PDF'

  EXPORTING

    format_src            = 'OTF'

    format_dst            = 'PDF'

   DEVTYPE               = 'PRINTER'

  CHANGING

    transfer_bin          = t_transfer

    content_txt           = it_otf_data

    content_bin           = it_objhx

    objhead               = it_objhead

    len               = psize

EXCEPTIONS

   ERR_CONV_FAILED       = 1

    OTHERS                = 2 .

Please try with this.

Read only

0 Likes
2,092

Hi Neha,

Thanks for your response. Now getting  the contents in  binary format. The it_objhx which is of type solix_tab  needs to be transferred to server. But this must be  converted into internal table  and loop through to transfer to server.


Could you please advise how this it_objhx contents can be put into internal table.


Thanks in advance.


Warm regards

Chandra






Read only

0 Likes
2,092

Hi Chandra

You need to call fucntion module 'SO_SOLIXTAB_TO_SOLITAB' to convert the contents.

CALL FUNCTION 'SO_SOLIXTAB_TO_SOLITAB'

  EXPORTING

    ip_solixtab       = it_objhx

IMPORTING

   EP_SOLITAB        = lt_objcont .

Send lt_objcont to the swerver.

This will work for you.

Best Regards,

Neha