cancel
Showing results for 
Search instead for 
Did you mean: 

Generating and displaying PDF forms within the SAP GUI

Former Member
0 Kudos

Hi,

I want to generate PDF files and display them as a part of an ABAP program.

Now, I know how to generate files for printing(FP_JOB_OPEN), and how to display PDF files with CL_GUI_PDFVIEWER, but how can I display a PDF generated by code?

Thanks.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Try this coding,

REPORT ZSA_CALL_ADOB.

DATA: form TYPE fpwbformname,

fm_name TYPE rs38l_fnam,

interface_type TYPE fpinterfacetype.

DATA: fp_outputparams TYPE sfpoutputparams.

DATA : fp_docparams TYPE sfpdocparams,

fp_result TYPE fpformoutput .

Data : bookings type table of sbook .

select * from sbook into table bookings up to 5 rows where

carrid = 'LH' .

CALL FUNCTION 'FP_FUNCTION_MODULE_NAME'

EXPORTING

i_name = 'ZSATEST'

IMPORTING

E_FUNCNAME = fm_name

E_INTERFACE_TYPE = interface_type

.

CALL FUNCTION 'FP_JOB_OPEN'

CHANGING

ie_outputparams = fp_outputparams

EXCEPTIONS

CANCEL = 1

USAGE_ERROR = 2

SYSTEM_ERROR = 3

INTERNAL_ERROR = 4

OTHERS = 5

.

IF sy-subrc <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

fp_docparams-langu = 'E'.

CALL FUNCTION fm_name

EXPORTING

/1BCDWB/DOCPARAMS = fp_docparams

BOOKING = bookings

IMPORTING

/1BCDWB/FORMOUTPUT = fp_result

  • EXCEPTIONS

  • USAGE_ERROR = 1

  • SYSTEM_ERROR = 2

  • INTERNAL_ERROR = 3

  • OTHERS = 4

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CALL FUNCTION fm_name

EXPORTING

/1BCDWB/DOCPARAMS = fp_docparams

PAR1 = 'SR'

IMPORTING

/1BCDWB/FORMOUTPUT = fp_result

EXCEPTIONS

USAGE_ERROR = 1

SYSTEM_ERROR = 2

INTERNAL_ERROR = 3

OTHERS = 4

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CALL FUNCTION 'FP_JOB_CLOSE'

  • IMPORTING

  • E_RESULT =

  • EXCEPTIONS

  • USAGE_ERROR = 1

  • SYSTEM_ERROR = 2

  • INTERNAL_ERROR = 3

  • OTHERS = 4

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

Former Member
0 Kudos

Thanks for the answer,

I tried it and it doesn't seem to do anything; what should it do?

What is the second function call for? And what's the PAR1 parameter?

Former Member
0 Kudos

Hi,

There's 2 way for this .

First you made a print preview of your form when it's generated . For this set output parameters like this :

  • Optional: Set output parameters

gs_outputparams-nodialog = space.

gs_outputparams-preview = ’X’.

gs_outputparams-dest = pa_prnt. "You can define your default printer here.

Then call FM FP_JOB_OPEN .

Otherwise you retrieve the PDF file form after been created for this set parameters like this :

gs_outputparams-nodialog = space.

gs_outputparams-getpdf = 'X'.

then in the unfction module corresponding to the form you will retrieve the PDF in attribute /1bcdwb/formoutput .

Afterwards, you can display it directly or saved it and display .

Hope this help you .

Regards