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

Uploading A PDF File To Application Server

Former Member
0 Likes
10,405

Hi All,

I have executed a job and converted the spool into a PDF file. Now I have to write a logic that would upload the pdf file to the application server. Is it possible, if yes kindly advise as to how to proceed on this?

Thanks in Advance...

Pablo

1 ACCEPTED SOLUTION
Read only

Former Member
3,164

using XML parser you can read the values from it and save as per your need.

Hi All,

I have executed a job and converted the spool into a PDF file. Now I have to write a logic that would upload the pdf file to the application server. Is it possible, if yes kindly advise as to how to proceed on this?

Thanks in Advance...

Pablo

8 REPLIES 8
Read only

Former Member
0 Likes
3,164

Hi,

hmm...Its not possible to upload a PDF to application server.

But rather, instead of converting the spool to PDF, convert it to text using func module: RSPO_RETURN_SPOOLJOB and upload it in app.server.

Hope this helps.

Regards,

Subramanian

Read only

0 Likes
3,164

hmm...Its not possible to upload a PDF to application server.

What makes you think that? A PDf is just a collection of binary data and it can be written to the app server in the normal manner...

Read only

0 Likes
3,164

Hi Subramanian PL,

this is an interesting statement:

"hmm...Its not possible to upload a PDF to application server."

We do it all the time using the BDS/GOS business document services(generic object services.

There is so much information available, i.e. see [Generic object services (GOS)|http://www.sdn.sap.com/irj/scn/weblogs;jsessionid=(J2EE3414900)ID0296261850DB11388102312450677412End?blog=/pub/wlg/3399#thread]

Kind regards,

Clemens

Read only

Former Member
3,165

using XML parser you can read the values from it and save as per your need.

Read only

0 Likes
3,164

Can you please let me know of the Steps involved? I am not aware of mechanism of uploading a PDF file on Application Server using XML Parser.

Thanks

Pablo

Read only

0 Likes
3,164

XML parsing will read the fields for you from the pdf data(after a gui_upload)

and then store these values in come variables and store these variables or tables to server.

please search in sdn. there are many posts on parsing pdf data

Read only

0 Likes
3,164

Hi,

This can be done directly by using OPEN DATASET in BINARY MODE. Check this sample



CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = gd_spool_nr
no_dialog = c_no
dst_device = c_device
IMPORTING
pdf_bytecount = gd_bytecount
TABLES
pdf = it_pdf_output
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.

data: filename(30) type c value '\user\temp\file.pdf'.      " Application server path

open dataset filename for output in binary mode.
if sy-subrc = o.
loop at it_pdf_output.
transfer it_pdf_output-tdformat to filename.
transfer it_pdf_output-tdline to filename.
endif.
endloop.

Regards,

Vikranth

Read only

venkat_o
Active Contributor
0 Likes
3,164

HI Pablo, Try this way. It works.Do not worry about what is there in i_pdf. Because it contains binary data.


  REPORT ZTEST_NOTEPAD.
  DATA:L_LAY    TYPE PRI_PARAMS-PAART,
     L_LINES    TYPE PRI_PARAMS-LINCT,
     L_COLS     TYPE PRI_PARAMS-LINSZ,
     L_VAL      TYPE C,
     LW_PRIPAR  TYPE PRI_PARAMS,
     LW_ARCPAR  TYPE ARC_PARAMS,
     SPOOLID LIKE  TSP01-RQIDENT.
     I_PDF TYPE STANDARD TABLE OF TLINE.
  PARAMETERS :P_FILE(60) TYPE C DEFAULT './pdfdata.pdf'.
  START-OF-SELECTION.
    L_LAY   = 'X_65_132'.
    L_LINES = 65.
    L_COLS  = 132.
    "Read, determine, change spool print parameters and archive parameters
    CALL FUNCTION 'GET_PRINT_PARAMETERS'
      EXPORTING
        IN_ARCHIVE_PARAMETERS  = LW_ARCPAR
        IN_PARAMETERS          = LW_PRIPAR
        LAYOUT                 = L_LAY
        LINE_COUNT             = L_LINES
        LINE_SIZE              = L_COLS
        NO_DIALOG              = 'X'
      IMPORTING
        OUT_ARCHIVE_PARAMETERS = LW_ARCPAR
        OUT_PARAMETERS         = LW_PRIPAR
        VALID                  = L_VAL.
    IF L_VAL  NE SPACE AND SY-SUBRC = 0.
      LW_PRIPAR-PRREL = SPACE.
      LW_PRIPAR-PRIMM = SPACE.
      NEW-PAGE PRINT ON
        NEW-SECTION
        PARAMETERS LW_PRIPAR
        ARCHIVE PARAMETERS LW_ARCPAR
        NO DIALOG.
    ENDIF.
    WRITE 'Output in spool'.
    NEW-PAGE PRINT OFF.
    CALL FUNCTION 'ABAP4_COMMIT_WORK'.
    DATA:TEXT TYPE STRING.
    CONCATENATE 'Spool' SY-SPONO 'is generated' INTO TEXT SEPARATED BY SPACE.
    MESSAGE TEXT  TYPE 'S'.
    SPOOLID = SY-SPONO.
    CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
      EXPORTING
        SRC_SPOOLID = SPOOLID
        NO_DIALOG   = SPACE
      TABLES
        PDF         = I_PDF.
    DATA: W_PDF LIKE LINE OF I_PDF.
    OPEN DATASET P_FILE FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
    IF SY-SUBRC = 0.
      LOOP AT I_PDF INTO W_PDF.
        TRANSFER W_PDF TO P_FILE.
      ENDLOOP.
    ENDIF.
    CLOSE DATASET P_FILE.
Thanks, Venkat.O