Sunteți pe pagina 1din 16

*----------------------------------------------------------------------*

Program FP_TEST_00

*----------------------------------------------------------------------*
PROGRAM fp_test_00.

INCLUDE fp_utilities.

SELECTION-SCREEN BEGIN OF BLOCK s_form WITH FRAME TITLE text-100.


PARAMETER: p_form TYPE fpwbformname DEFAULT 'FP_TEST_00',
p_langu TYPE spras

OBLIGATORY DEFAULT 'D',

p_countr TYPE land1

DEFAULT 'DE',

p_pages TYPE fppagecount DEFAULT 2,


p_loop TYPE i

DEFAULT 1.

SELECTION-SCREEN END OF BLOCK s_form.


SELECTION-SCREEN BEGIN OF BLOCK s_conn WITH FRAME TITLE text-101.
PARAMETER p_conn TYPE rfcdest

OBLIGATORY.

SELECTION-SCREEN END OF BLOCK s_conn.

DATA: fm_name

TYPE rs38l_fnam,

fp_docparams

TYPE sfpdocparams,

fp_outputparams TYPE sfpoutputparams,


itf
itf_line

TYPE tsftext,
TYPE tline,

itf_line_pattern1 TYPE tdline VALUE 'Line % on page #',"#EC NOTEXT


itf_line_pattern2 TYPE tdline,
page_nr

TYPE string,

line_nr

TYPE string,

result

TYPE sfpjoboutput,

l_spoolid

TYPE rspoid.

INITIALIZATION.
MOVE cl_fp=>get_ads_connection( ) TO p_conn.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_conn.


PERFORM value_help_for_destination USING 'P_CONN'.

START-OF-SELECTION.

* prepare test data


DO p_pages TIMES.
page_nr = sy-index.
itf_line_pattern2 = itf_line_pattern1.
REPLACE '#' IN itf_line_pattern2 WITH page_nr IN CHARACTER MODE.
DO 15 TIMES.
line_nr = sy-index.
itf_line-tdline = itf_line_pattern2.
REPLACE '%' IN itf_line-tdline WITH line_nr IN CHARACTER MODE.
APPEND itf_line TO itf.
ENDDO.
ENDDO.

* print data
CALL FUNCTION 'FP_FUNCTION_MODULE_NAME'
EXPORTING
i_name

= p_form

IMPORTING
e_funcname = fm_name.

* now call the generated function module


fp_outputparams-connection = p_conn.

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.

DO p_loop TIMES.

fp_docparams-langu = p_langu.
fp_docparams-country = p_countr.
CALL FUNCTION fm_name
EXPORTING
/1bcdwb/docparams = fp_docparams
textlines

= itf.

ENDDO.

CALL FUNCTION 'FP_JOB_CLOSE'


IMPORTING
e_result

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

* Check the result.


IF result-userexit IS INITIAL.
IF result-spoolids IS INITIAL.
MESSAGE ID 'PO' TYPE 'E' NUMBER '475'.
ELSE.
READ TABLE result-spoolids INDEX 1 INTO l_spoolid.
MESSAGE ID 'PO' TYPE 'S' NUMBER '622' WITH l_spoolid.
ENDIF.
ENDIF.

PROGRAM fp_pdf_test_00.
* Get and display version information of the ADS.
* This program can be used for a simple connection test.

INCLUDE fp_utilities.

"#EC INCL_OK

PARAMETERS p_dest TYPE rfcdest OBLIGATORY.

DATA gv_version TYPE string.


DATA gx_fpex

TYPE REF TO cx_fp_runtime.

INITIALIZATION.
p_dest = cl_fp=>get_ads_connection( ).

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_dest.


PERFORM value_help_for_destination USING 'P_DEST'.

START-OF-SELECTION.
TRY.
*

Get version information.


gv_version = cl_fp=>get_reference(
)->create_pdf_object( connection = p_dest
)->get_version_info( ).

Output result.
IF gv_version IS INITIAL.
MESSAGE 'Keine Versioninformationen verfgbar'(002) TYPE 'W'.
ELSE.
MESSAGE ID 'AD' TYPE 'I' NUMBER '010'
WITH 'Versionsinformationen:'(001) gv_version.
ENDIF.

CATCH cx_fp_runtime INTO gx_fpex.


PERFORM error USING gx_fpex.

ENDTRY.

*----------------------------------------------------------------------*
*

Report FP_TEST_03

*----------------------------------------------------------------------*
*

Printing of documents using PDF based forms

*----------------------------------------------------------------------*
PROGRAM fp_test_03.

INCLUDE fp_utilities.

"#EC INCL_OK

DATA carr_id TYPE sbook-carrid.

*--------------------------------------------------------------------------------*
* SELECTION SCREEN

*--------------------------------------------------------------------------------*

SELECTION-SCREEN BEGIN OF BLOCK s_data WITH FRAME TITLE text-100.


PARAMETER

p_custid TYPE scustom-id DEFAULT 12.

SELECT-OPTIONS s_carrid FOR carr_id

DEFAULT 'AA' TO 'ZZ'.

SELECTION-SCREEN END OF BLOCK s_data.

SELECTION-SCREEN BEGIN OF BLOCK s_form WITH FRAME TITLE text-101.


PARAMETER:

p_form TYPE fpwbformname DEFAULT 'FP_TEST_03_TABLE',

p_langu TYPE spras

DEFAULT 'D',

p_countr TYPE land1

DEFAULT 'DE' MATCHCODE OBJECT h_t005_land,

p_ia

TYPE fpinteractive,

p_norm TYPE fppdfnorm


VISIBLE LENGTH 10 MODIF ID nrm.

DEFAULT if_fp_pdf_norm=>default AS LISTBOX

SELECTION-SCREEN END OF BLOCK s_form.

SELECTION-SCREEN BEGIN OF BLOCK s_jobp WITH FRAME TITLE text-103.


PARAMETER

p_jobp TYPE fpjobprofile MODIF ID jpr.

SELECTION-SCREEN END OF BLOCK s_jobp.

SELECTION-SCREEN BEGIN OF BLOCK s_conn WITH FRAME TITLE text-102.


PARAMETER

p_conn TYPE rfcdest

OBLIGATORY.

SELECTION-SCREEN END OF BLOCK s_conn.


*--------------------------------------------------------------------------------*
* DATA DECLARATIONS
*--------------------------------------------------------------------------------*
DATA go_fp

TYPE REF TO if_fp.

DATA go_pdf_obj TYPE REF TO if_fp_pdf_object.


DATA gx_fpex

TYPE REF TO cx_fp_runtime.

DATA gt_profiles TYPE tfpjobprofile.


DATA: customer
bookings

TYPE scustom,
TYPE ty_bookings,

connections

TYPE ty_connections,

fm_name

TYPE rs38l_fnam,

fp_docparams

TYPE sfpdocparams,

fp_outputparams TYPE sfpoutputparams,


error_string

TYPE string.

*--------------------------------------------------------------------------------*
INITIALIZATION.
MOVE cl_fp=>get_ads_connection( ) TO p_conn.
*--------------------------------------------------------------------------------*
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF screen-group1 = 'JPR'.

TRY.
IF cl_fp_feature_test=>is_available(
iv_connection = p_conn
iv_feature

= cl_fp_feature_test=>gc_job_profiles )

= abap_true.
CONTINUE.
ENDIF.
CATCH cx_fp_runtime_internal
cx_fp_runtime_system
cx_fp_runtime_usage.

"#EC NO_HANDLER

ENDTRY.
screen-active = 0.
MODIFY SCREEN.
CLEAR p_jobp.
ENDIF.
IF screen-group1 = 'NRM'.
TRY.
IF cl_fp_feature_test=>is_available(
iv_connection = p_conn
iv_feature

= cl_fp_feature_test=>gc_render_pdfa1 )

= abap_true.
CONTINUE.
ENDIF.
CATCH cx_fp_runtime_internal
cx_fp_runtime_system
cx_fp_runtime_usage.
ENDTRY.
screen-active = 0.
MODIFY SCREEN.
CLEAR p_norm.

"#EC NO_HANDLER

ENDIF.
ENDLOOP.
*--------------------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_jobp.
TRY.
IF cl_fp_feature_test=>is_available(
iv_connection = p_conn
iv_feature

= cl_fp_feature_test=>gc_job_profiles )

= abap_true.
*

Get job-profiles list from the ADS.


go_fp = cl_fp=>get_reference( ).
go_pdf_obj = go_fp->create_pdf_object( connection = p_conn ).
gt_profiles = go_pdf_obj->get_job_profiles( ).

Show the value-help popup.


CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield
dynpprog
dynpnr

= 'NAME'
= sy-cprog
= sy-dynnr

dynprofield = 'P_JOBP'
value_org = 'S'
TABLES
value_tab = gt_profiles.
ENDIF.
CATCH cx_fp_runtime_internal
cx_fp_runtime_system
cx_fp_runtime_usage.

"#EC NO_HANDLER

ENDTRY.
*--------------------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_conn.

PERFORM value_help_for_destination USING 'P_CONN'.

*--------------------------------------------------------------------------------*
START-OF-SELECTION.
* Get data.
SELECT SINGLE * FROM scustom INTO customer WHERE id = p_custid.
IF customer IS INITIAL.
MESSAGE ID 'AD' TYPE 'E' NUMBER '718' WITH 'SCUSTOM'.
ENDIF.
SELECT * FROM sbook INTO TABLE bookings
WHERE customid = p_custid
AND carrid IN s_carrid
ORDER BY PRIMARY KEY.
IF bookings[] IS NOT INITIAL.
SELECT * FROM spfli INTO TABLE connections FOR ALL ENTRIES IN bookings
WHERE carrid = bookings-carrid
AND connid = bookings-connid
ORDER BY PRIMARY KEY.
ENDIF.

* Print data:

* First get name of the generated function module.


TRY.
CALL FUNCTION 'FP_FUNCTION_MODULE_NAME'
EXPORTING
i_name

= p_form

IMPORTING
e_funcname = fm_name.
CATCH cx_fp_api_repository cx_fp_api_usage cx_fp_api_internal.

MESSAGE ID 'FPAPIGENERIC' TYPE 'E' NUMBER '000' WITH p_form.


ENDTRY.

* Set output parameters and open spool job.


fp_outputparams-preview

= abap_true.

fp_outputparams-connection = p_conn.
fp_outputparams-pdfnorm

= p_norm.

IF p_jobp IS NOT INITIAL.


TRY.
IF cl_fp_feature_test=>is_available(
iv_connection = p_conn
iv_feature

= cl_fp_feature_test=>gc_job_profiles )

= abap_true.
fp_outputparams-job_profile = p_jobp.
ENDIF.
CATCH cx_fp_runtime_internal
cx_fp_runtime_system
cx_fp_runtime_usage INTO gx_fpex.
PERFORM error USING gx_fpex.
ENDTRY.
ENDIF.
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 IS NOT INITIAL.


MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.

* Set form language and country (->form locale).


fp_docparams-langu

= p_langu.

fp_docparams-country = p_countr.
fp_docparams-fillable = p_ia.

* Now call the generated function module.


CALL FUNCTION fm_name
EXPORTING
/1bcdwb/docparams = fp_docparams
customer

= customer

bookings

= bookings

connections
**
**

= connections

IMPORTING
/1bcdwb/formoutput =
EXCEPTIONS
usage_error

=1

system_error

=2

internal_error

=3

OTHERS

= 4.

IF sy-subrc IS NOT INITIAL.


CALL FUNCTION 'FP_GET_LAST_ADS_ERRSTR'
IMPORTING
e_adserrstr = error_string.
IF error_string IS NOT INITIAL.
*

We received a detailed error description.

MESSAGE error_string TYPE 'E'.


ELSE.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.

* Close spool job.


CALL FUNCTION 'FP_JOB_CLOSE'
**

IMPORTING

**

e_result

EXCEPTIONS
usage_error

=1

system_error = 2
internal_error = 3
OTHERS

= 4.

IF sy-subrc IS NOT INITIAL.


MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.

Inbound Handler for Interactive PDF Forms


Class that is responsible for the inbound handling of interactive PDF forms

Use
This class is called by inbound processing and cannot communicate with the front end.
The PDF form and the form data (in XML form) are passed to the methodHANDLE_PDF.

Dependencies
This class must implement the interface IF_FP_OFFLINE.

S-ar putea să vă placă și