Quantcast
Channel: SCN : All Content - All Communities
Viewing all articles
Browse latest Browse all 9262

how to convert raw data into pdf ?

$
0
0

Hi everyone,

 

I have a requirement where I have to print the document present in application server.

I used below code to do this


* Open the file in binary mode

   OPEN DATASET gv_filepath FOR INPUT IN TEXT MODE ENCODING DEFAULT IGNORING CONVERSION ERRORS.

   DO.

     TRY.

* Since the file is opened in Binary mode, the entire contents of the

* file is read in one go!

         READ DATASET gv_filepath INTO gv_filedata.

         IF sy-subrc <> 0.

           EXIT.

         ENDIF.

       CATCH cx_sy_conversion_codepage.

     ENDTRY.

     APPEND gv_filedata TO gt_file_table.

     CLEAR gv_filedata.

   ENDDO.

   CLOSE DATASET gv_filepath.


DESCRIBE TABLE gt_file_table LINES lv_lines.

  lv_pages = lv_lines.

  lv_dest = 'LP01'.

  lv_spoolname = 'LOCW'.

 

  CALL FUNCTION 'RSPO_SX_OUTPUT_TEXTDATA'

    EXPORTING

*     NAME           = lv_spoolname

      DEST           = lv_dest

      ROWS           = lv_lines

      STARTROW       = 1

      PAGES          = 99

      RQTITLE        = 'Print Spool'

      RQCOPIES       = 1

      RQOWNER        = sy-uname

      IMMEDIATELY    = ' '

    IMPORTING

      RQID           = lv_spoolid

    TABLES

      TEXT_DATA      = gt_file_table

    EXCEPTIONS

      NAME_MISSING   = 1

      NAME_TWICE     = 2

      NOT_FOUND      = 3

      ILLEGAL_LAYOUT = 4

      INTERNAL_ERROR = 5

      SIZE_MISMATCH  = 6

      OTHERS         = 7.

  IF SY-SUBRC <> 0.

* Implement suitable error handling here

  ENDIF.


Passed the spool id generated to below FM but it is not converting into pdf

 

CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'

    EXPORTING

      SRC_SPOOLID                    = lv_spoolid

     NO_DIALOG                      = ' '

     DST_DEVICE                     = 'LOCW'

     PDF_DESTINATION                = 'X'

*     NO_BACKGROUND                  =

*     GET_SIZE_FROM_FORMAT           =

*     USE_CASCADING                  = ' '

*   IMPORTING

*     PDF_BYTECOUNT                  = lv_bytecount

*     PDF_SPOOLID                    = lv_pdf1

*     LIST_PAGECOUNT                 =

*     BTC_JOBNAME                    =

*     BTC_JOBCOUNT                   =

*     BIN_FILE                       = lv_pdf

   TABLES

     PDF                            = lt_pdf

   EXCEPTIONS

     ERR_NO_ABAP_SPOOLJOB           = 1

     ERR_NO_SPOOLJOB                = 2

     ERR_NO_PERMISSION              = 3

     ERR_CONV_NOT_POSSIBLE          = 4

     ERR_BAD_DESTDEVICE             = 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 <> 0.

* Implement suitable error handling here

  ENDIF.


When I go to SP01 and check the spool generated it is in raw document type.

How can I convert this raw document to pdf type ??

Please help me to resolve this.


Regards,

Krishna


Viewing all articles
Browse latest Browse all 9262

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>