Application Development 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: 

Conversion FAQ

RKSK
Participant
0 Kudos

Hi SAPGURUS

I want to convert a text file to pdf file for this i am creating a internal table and then fill it from the input file (this i do by GUI_UPLOAD FM). After that i download the data in another file and then i now want to convert the downloaded file into pdf file for this i am using the FM CONVERT_OTF_2_PDF.

But this is not working and giving me dumb when executed.

could anyone provide me a simple program so that i can understand the use of thr CONVERT_OTF_2_PDF FM.

Please reply as soon as possible.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Refer thread

DATA: lt_pdfdata LIKE TABLE OF tline WITH HEADER LINE.
DATA: lt_otf TYPE STANDARD TABLE OF itcoo WITH HEADER LINE,
lt_doctab TYPE STANDARD TABLE OF docs WITH HEADER LINE,
lt_otfdata TYPE STANDARD TABLE OF itcoo WITH HEADER LINE.

*-- Convert the OTF data to PDF data
CALL FUNCTION 'CONVERT_OTF_2_PDF'
EXPORTING
use_otf_mc_cmd = 'X'
IMPORTING
bin_filesize = v_bin
TABLES
otf = lt_otf
doctab_archive = it_doctab
lines = lt_pdfdata
EXCEPTIONS
err_conv_not_possible = 1
err_otf_mc_noendmarker = 2
OTHERS = 3.

This is an alternative SX_OBJECT_CONVERT_OTF_PDF

3 REPLIES 3

former_member583013
Active Contributor
0 Kudos

You can use this custom FM...You must convert your text file to a spool request and call the FM -:)


*"----------------------------------------------------------
*"*"Interfase local
*"  IMPORTING
*"     REFERENCE(FILENAME) TYPE  STRING
*"----------------------------------------------------------

    SELECT RQIDENT
    INTO (T_TSP01-RQIDENT)
    FROM TSP01
    WHERE RQOWNER EQ SY-UNAME
      AND RQCLIENT EQ SY-MANDT.
    APPEND T_TSP01.
    ENDSELECT.

    SORT T_TSP01 DESCENDING.

    CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
         EXPORTING
              SRC_SPOOLID              = T_TSP01-RQIDENT
              NO_DIALOG                = ''
         IMPORTING
              PDF_BYTECOUNT            = NUMBYTES
              PDF_SPOOLID              = PDFSPOOLID
              BTC_JOBNAME              = JOBNAME
              BTC_JOBCOUNT             = JOBCOUNT
         TABLES
              PDF                      = PDF
         EXCEPTIONS
              ERR_NO_OTF_SPOOLJOB      = 1
              ERR_NO_SPOOLJOB          = 2
              ERR_NO_PERMISSION        = 3
              ERR_CONV_NOT_POSSIBLE    = 4
              ERR_BAD_DSTDEVICE        = 5
              USER_CANCELLED           = 6
              ERR_SPOOLERROR           = 7
              ERR_TEMSEERROR           = 8
              ERR_BTCJOB_OPEN_FAILED   = 9
              ERR_BTCJOB_SUBMIT_FAILED = 10
              ERR_BTCJOB_CLOSE_FAILED  = 11
              OTHERS                   = 12.

    IF SY-SUBRC EQ 0.

      CALL FUNCTION 'GUI_DOWNLOAD'
           EXPORTING
                BIN_FILESIZE            = NUMBYTES
                FILENAME                = FILENAME
                FILETYPE                = 'BIN'
           TABLES
                DATA_TAB                = PDF
           EXCEPTIONS
                FILE_WRITE_ERROR        = 1
                NO_BATCH                = 2
                GUI_REFUSE_FILETRANSFER = 3
                INVALID_TYPE            = 4
                NO_AUTHORITY            = 5
                UNKNOWN_ERROR           = 6.

      IF SY-SUBRC EQ 0.
        DELETE FROM TSP01 WHERE RQIDENT EQ T_TSP01-RQIDENT.
      ENDIF.

    ENDIF.

  ENDFUNCTION.

Greetings,

Blag.

Former Member
0 Kudos

Hi,

Refer thread

DATA: lt_pdfdata LIKE TABLE OF tline WITH HEADER LINE.
DATA: lt_otf TYPE STANDARD TABLE OF itcoo WITH HEADER LINE,
lt_doctab TYPE STANDARD TABLE OF docs WITH HEADER LINE,
lt_otfdata TYPE STANDARD TABLE OF itcoo WITH HEADER LINE.

*-- Convert the OTF data to PDF data
CALL FUNCTION 'CONVERT_OTF_2_PDF'
EXPORTING
use_otf_mc_cmd = 'X'
IMPORTING
bin_filesize = v_bin
TABLES
otf = lt_otf
doctab_archive = it_doctab
lines = lt_pdfdata
EXCEPTIONS
err_conv_not_possible = 1
err_otf_mc_noendmarker = 2
OTHERS = 3.

This is an alternative SX_OBJECT_CONVERT_OTF_PDF

0 Kudos

Hi,

first of all thanks for your help but could you please explain why we use:-

DATA: lt_pdfdata LIKE TABLE OF tline WITH HEADER LINE.

DATA: lt_otf TYPE STANDARD TABLE OF itcoo WITH HEADER LINE,

lt_doctab TYPE STANDARD TABLE OF docs WITH HEADER LINE,

lt_otfdata TYPE STANDARD TABLE OF itcoo WITH HEADER LINE.

and what is the use of <b>tline</b>.

Right now i have taken an internal table and then fill it using GUI_UPLOAD FM.

After this i m using this internal table and passing it to function 'CONVERT_OTF_2_PDF'.

IS my approch right please help me i am not able to understand the concept of how to use this FM.