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: 

writing spool to pdf file on server

Former Member
0 Kudos

I am trying to convert a spool dataset (otf) into pdf format and write it to the server disk.

There is a report, called RSTXPDFT4 which downloads the file to the workstation.

I have managed to do the pdf-conversion with calling:

CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'

EXPORTING

SRC_SPOOLID = i_sp01-rqident

NO_DIALOG = ' '

  • DST_DEVICE =

  • PDF_DESTINATION =

IMPORTING

PDF_BYTECOUNT = numbytes

PDF_SPOOLID = pdfspoolid

  • OTF_PAGECOUNT =

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.

but I have no clue how to write the returned pdf data in the internal table PDF to the disk.

I have tried

OPEN DATASET name_x FOR OUTPUT IN BINARY MODE.

PDF_KOMPLETT = ''.

LOOP AT PDF.

TRANSFER PDF-tdformat TO name_x.

TRANSFER PDF-tdline TO name_x.

ENDLOOP.

CLOSE DATASET name_x.

but that adds bytes at the end because it always writes complete lines...

Anyone have this problem before?

I cannot remember if there is a function to write the contents of an internal table to the server harddisk.

Thanks

Alex

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Raja,

this is helpful for some,

yet I am using SAP R/3 4.6C and I am sorry I didn't mention this.

I thought there might be a FM for writing a pdf to the server harddisk.

I could also use a FM which writes the contents (first numbytes Bytes of) internal table PDF to the harddisk.

I have found this post

to be very helpful and I used it like this:

DATA PDF LIKE TLINE OCCURS 0 WITH HEADER LINE.

DATA PDFLINE LIKE TLINE.

DATA PDF_KOMPLETT TYPE XSTRING.

PDF_KOMPLETT = ''.

LOOP AT PDF INTO PDFLINE .

TRANSLATE PDFLINE USING ' ~'.

CONCATENATE PDF_KOMPLETT PDFLINE

INTO PDF_KOMPLETT.

  • IN CHARACTER MODE.

ENDLOOP.

TRANSLATE PDF_KOMPLETT USING '~ ' .

The option "IN CHARACTER MODE" is not valid on 4.6C, but it works. It is a working solution, but since we will use this for 10.000 files per day, I would like to find a better (optimized) solution.

Thanks.

Alex

3 REPLIES 3

athavanraja
Active Contributor
0 Kudos

If you are on WAS 6.4 you can add

"NO END OF LINE" command to transfer.

<i><b>TRANSFER dobj TO dset [LENGTH len]

[NO END OF LINE].</b></i>

below given is the explanation and sample from ABAP key word documentation.

... NO END OF LINE

Effect

This addition has the effect that no end of line separator is appended to the data transferred in text files or legacy text files.

Example

The binary data from database table SPFLI is transferred to a binary file flights.dat. The structure of the table rows transferred contains both character-type and numerical fields. Since the type-specific storage of mixed structures in files is not possible, the binary content of the structure is directly accessed using a typed field symbol . To attain the same result, you can directly transfer the structure wa, the recommended procedure is to use the field symbol, however, because it explicitly transfers a binary data type to a binary file. This type of storage is only recommended for short-term storage within the same system, because the byte-type content depends on the byte sequence and the current system code page. For long-term storage or for exchanging between systems, the data should be converted to character-type containers and stored as a text file.


DATA: file TYPE string VALUE `flights.dat`, 
      wa TYPE spfli. 

FIELD-SYMBOLS TYPE x. 

OPEN DATASET file FOR OUTPUT IN BINARY MODE. 

SELECT * 
       FROM spfli 
       INTO wa. 
  ASSIGN wa TO CASTING. 
  TRANSFER TO file. 
ENDSELECT. 

CLOSE DATASET file. 

Regards

Raja

Former Member
0 Kudos

Hi Raja,

this is helpful for some,

yet I am using SAP R/3 4.6C and I am sorry I didn't mention this.

I thought there might be a FM for writing a pdf to the server harddisk.

I could also use a FM which writes the contents (first numbytes Bytes of) internal table PDF to the harddisk.

I have found this post

to be very helpful and I used it like this:

DATA PDF LIKE TLINE OCCURS 0 WITH HEADER LINE.

DATA PDFLINE LIKE TLINE.

DATA PDF_KOMPLETT TYPE XSTRING.

PDF_KOMPLETT = ''.

LOOP AT PDF INTO PDFLINE .

TRANSLATE PDFLINE USING ' ~'.

CONCATENATE PDF_KOMPLETT PDFLINE

INTO PDF_KOMPLETT.

  • IN CHARACTER MODE.

ENDLOOP.

TRANSLATE PDF_KOMPLETT USING '~ ' .

The option "IN CHARACTER MODE" is not valid on 4.6C, but it works. It is a working solution, but since we will use this for 10.000 files per day, I would like to find a better (optimized) solution.

Thanks.

Alex

0 Kudos

Hi Alex,

Good you found that post, i have forgotten about that post.(check it out, the solution was from me).

As far a better method, if i come across anthing i will update.

Regards

Raja

If the issue is resolved, kindly close the thread and mark it as answered.