24/02/2010

Gerar PDF Apartir de um SMARTFORM


REPORT ZRR_SAMPLE.

*--------------------------------------------------------------------------
* | S.T.A.N.D.A.R.D S.T.R.U.C.T.U.R.E.S D.E.F.I.N.I.T.I.O.N
*--------------------------------------------------------------------------

TABLES: sflight, vdarl.

*--------------------------------------------------------------------------
* | V.A.R.I.A.B.L.E.S D.E.C.L.A.R.A.T.I.O.N.S
*--------------------------------------------------------------------------

DATA : ls_control_param TYPE ssfctrlop,
ls_composer_param TYPE ssfcompop,
ws_fname TYPE rs38l_fnam.

DATA : l_document_output_info TYPE ssfcrespd,
l_job_output_info TYPE ssfcrescl,
l_job_output_options TYPE ssfcresop.

*--------------------------------------------------------------------------
* | C.U.S.T.O.M T.Y.P.E.S D.E.F.I.N.I.T.I.O.N
*--------------------------------------------------------------------------

TYPES : ty_sflight_tab TYPE STANDARD TABLE OF sflight.

*--------------------------------------------------------------------------
* | I.N.T.E.R.N.A.L T.A.B.L.E.S D.E.F.I.N.I.T.I.O.N.S
*--------------------------------------------------------------------------

DATA : it_sflight TYPE ty_sflight_tab.

*--------------------------------------------------------------------------
* | E.L.E.M.E.N.T.S O.F S.C.R.E.E.N D.E.F.I.N.I.T.I.O.N
*--------------------------------------------------------------------------

SELECTION-SCREEN BEGIN OF BLOCK b WITH FRAME TITLE text-001 .
SELECT-OPTIONS s_carrid FOR sflight-carrid NO-EXTENSION NO INTERVALS .
SELECTION-SCREEN END OF BLOCK b.

*--------------------------------------------------------------------------
* | S.T.A.R.T O.F S.E.L.E.C.T.I.O.N
*--------------------------------------------------------------------------

START-OF-SELECTION.

* |-> D.E.F.I.N.E I.N.I.T.I.A.L V.A.L.U.E.S F.O.R
* LS_CONTROL_PARAM S.T.R.U.C.T.U.R.E

ls_control_param-device = space.
ls_control_param-getotf = 'X'.
ls_control_param-no_dialog = 'X'.

* |-> C.A.L.L F.U.N.C.T.I.O.N P.A.R.A R.E.C.U.P.A.R
* N.O.M.E D.A F.U.N.Ç.Ã.O G.E.R.A.D.A Q.U.A.N.D.O
* O S.M.A.R.T.F.O.R.M É A.T.I.V.A.D.O

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'Z_TESTE_SMARTF'
IMPORTING
fm_name = ws_fname
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.

* |-> B.I.N.D I.N.T.E.R.N.A.L T.A.B.L.E

SELECT *
FROM sflight
INTO TABLE it_sflight
WHERE carrid IN s_carrid.

* |-> C.A.L.L S.M.A.R.T.F.O.R.M F.U.N.C.T.I.O.N N.A.M.E

* |-> O.B.S: PARA CADA FUNÇÃO OS PARAMETROS SÃO DIFERENTES
* DEFINA DE ACORDO COM A INTERFACE DO SEU SMARTFORM

CALL FUNCTION ws_fname
EXPORTING
control_parameters = ls_control_param
IMPORTING
document_output_info = l_document_output_info
job_output_info = l_job_output_info
job_output_options = l_job_output_options
TABLES
it_sflight = it_sflight
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.

IF sy-subrc NE 0.

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

ENDIF.

* |-> C.A.L.L F.U.N.C.T.I.O.N F.O.R P.R.E.V.I.E.W PDF

CALL FUNCTION 'SSFCOMP_PDF_PREVIEW'
EXPORTING
i_otf = l_job_output_info-otfdata
EXCEPTIONS
convert_otf_to_pdf_error = 1
cntl_error = 2
OTHERS = 3.

Nenhum comentário:

Postar um comentário