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: 

how to store pdf files in application layer

Former Member
0 Kudos

Hi friends,

Can any body tell me how to this.when ever we give a print a spool number will be created.we can give this spool number to rstxpdft4 program and we can convert it into pdf.

how to put this pdf into application layer as a unix file.is it possible to do that.

Regards,

Sasi

17 REPLIES 17

former_member188685
Active Contributor
0 Kudos

Hi,

if you convert OTF to PDF then you will have the PDF data in the Itab, then loop that itab and write it to application server using open dataset, transfer , close dataset.

Regards

vijay

0 Kudos

hi

when i use the opendata set,,the data is gettig corrupted once it is uploaded.

any solution for this.i wnat to upload the file in pdf format only to application server.

is it possible.

Regards,

Sasi

0 Kudos

No , nothing will happen to it , until unless you change any thing to it. it will be in PDF format only. if you want to check just create small PDF data and then transfer it, and then download it using read data set and then down load it to PC.

or else simple test is upload it using open dataset, transfer, close dataset to application server.

then use CG3Z transaction and download it to PC.

this confirms nothing is corrupted.

Regards

vijay

0 Kudos

I don't think the data is actually corrupted. Try running this code. It will upload a pdf file from the PC, download it to the app server and then upload it back to the PC. You should be able to read the uploaded pdf file with no problem:


REPORT zrob_up_down .

DATA: BEGIN OF itab OCCURS 0,
        field(256),
      END   OF itab.
DATA: dsn(100) VALUE '/usr/sap/xfr/FIS/testpdf',
      length  LIKE sy-tabix,
      lengthn LIKE sy-tabix.

CALL FUNCTION 'GUI_UPLOAD'
     EXPORTING
          filename   = 'c:temptest.pdf'
          filetype   = 'BIN'
     IMPORTING
          filelength = length
     TABLES
          data_tab   = itab.

OPEN DATASET dsn FOR OUTPUT IN BINARY MODE.

LOOP AT itab.
  TRANSFER itab-field TO dsn.
ENDLOOP.

CLOSE DATASET dsn.
CLEAR   itab.
REFRESH itab.

OPEN DATASET dsn FOR INPUT IN BINARY MODE.

DO.
  READ DATASET dsn INTO itab-field.
  IF sy-subrc = 0.
    APPEND itab.
  ELSE.
    EXIT.
  ENDIF.
ENDDO.

CALL FUNCTION 'GUI_DOWNLOAD'
     EXPORTING
          filename     = 'c:temptestn.pdf'
          filetype     = 'BIN'
          bin_filesize = length
     IMPORTING
          filelength   = lengthn
     TABLES
          data_tab     = itab.

Rob

0 Kudos

cz3a is to upload from presentation server to application server but i want the reverse one

0 Kudos

Hi,

<b>CG3Y</b> try this..

from applc server to pC

Regards

vijay

0 Kudos

hi,

i tried both the above program and this transaction it says that file is corrupted

bye

sasi

0 Kudos

Hi,

Ideally it never give any problem , thats how we stroe.

what pdf file you uploaded and downloaded.

Regards

vijay

0 Kudos

hi can u give me ur mail id i will send that pdf file to u

0 Kudos

send me amil on y_sasidhar@yahoo.com

0 Kudos

I think the problem may be with the original pdf file. I've run this program and am able to read the second file with no problem.

How are you trying to read the unix file?

Rob

0 Kudos

Hi Sasidhar,

you are uploading the PDF file, but what i mean to say is upload the PDF data directly to application server.and then download. but here you are doing direct pdf upload and then downloading.

Regards

vijay

0 Kudos

Hi,

iF POSSIBLE CAN U GIVE ME SOME CODE HOW TO UPLAD THE DATA OF PDF FILE.ACTUALLY MY DATA WILL BE COMING TO A SPOOL.FROM THIS SPOOL I HAVE TO STORE IT AS PDF IN THE APPLICATION LAYER.

PLEASE HELP ME

REGARDS,

Sasidhar

0 Kudos

Complete code right from spool request :

FORM convert_spool_to_pdf.

IF is_otf IS INITIAL .

      • List to PDF

CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'

EXPORTING

src_spoolid = p_spool

  • dst_device = 'LOCL'

IMPORTING

pdf_bytecount = bytes

pdf_spoolid = pdf_spool

list_pagecount = pages

btc_jobname = job_pdf

btc_jobcount = jobcount_pdf

TABLES

pdf = i_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.

ELSE .

      • OTF ( SAPSCRIPT ) To PDF

CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'

EXPORTING

src_spoolid = p_spool

no_dialog = ' '

IMPORTING

pdf_bytecount = bytes

pdf_spoolid = pdf_spool

otf_pagecount = pages

btc_jobname = job_pdf

btc_jobcount = jobcount_pdf

TABLES

pdf = i_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.

ENDIF .

IF sy-subrc <> 0 OR

i_pdf[] IS INITIAL .

      • Error creating PDF File .

Message e000.

ELSE .

        • Got PDF Structure . Now transfer to App. Server.

ENDIF .

ENDFORM. " convert_spool_to_pdf

FORM send_spool_app.

OPEN DATASET p_fname FOR OUTPUT IN BINARY MODE .

IF sy-subrc = 0.

LOOP AT i_pdf .

TRANSFER i_pdf TO p_fname.

ENDLOOP.

CLOSE DATASET p_fname .

MESSAGE s000 WITH p_fname.

ELSE.

MESSAGE e502(0u) WITH p_fname .

ENDIF.

endform.

This is a working code as we are using the same concept.

Hope it helped.

0 Kudos

Hi ,

But in script usually we will have logos right.

then when iam uplaoding the same using ur code.it is uploading and downloading

but when i try to open the downloaded file it says it is corrupted.

because in scriopts usually we will have lines.

Regards,

Sasidhar

0 Kudos

what we have to give in p_fname.

is it /temp/test.pdf

0 Kudos

Yes. P_FNAME shall be the complete Unix path.

When you say, in script, u'd have logos, what script you are talking about?

If it helped, please award some points