cancel
Showing results for 
Search instead for 
Did you mean: 

How to call a Smartform in webdynpro?

aliimran_uppal
Participant
0 Kudos
268

I am trying to print pdf in web dynpro application.

method ONACTIONPRINT .


DATA FM_NAME TYPE RS38L_FNAM.

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

EXPORTING

FORMNAME = 'ZTEST_WD'

IMPORTING

FM_NAME = FM_NAME

.

IF SY-SUBRC <> 0.

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

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

ENDIF.

DATA: JOB_OUPUT TYPE SSFCRESCL,

LT_OTFDATA TYPE TABLE OF ITCOO.

DATA: LA_CTRL_FORM TYPE SSFCTRLOP,

LA_OUTPUT_OPT TYPE SSFCOMPOP.

** Spool Parameters

LA_OUTPUT_OPT-TDIMMED = 'X'.

LA_OUTPUT_OPT-TDDELETE = 'X'.

LA_OUTPUT_OPT-TDLIFETIME = 'X'.

LA_OUTPUT_OPT-TDDEST = 'LOCL'.

*****************************************************************************

* Parameters passes to get the output in PDF format

****************************************************************************

LA_CTRL_FORM-NO_DIALOG = 'X'.

LA_CTRL_FORM-PREVIEW = 'X'.

LA_CTRL_FORM-GETOTF = 'X'.

LA_CTRL_FORM-LANGU = 'EN'.

LA_CTRL_FORM-DEVICE = 'PRINTER'.

CALL FUNCTION FM_NAME

EXPORTING

CONTROL_PARAMETERS = LA_CTRL_FORM

OUTPUT_OPTIONS = LA_OUTPUT_OPT

IMPORTING

JOB_OUTPUT_INFO = JOB_OUPUT

EXCEPTIONS

FORMATTING_ERROR = 1

INTERNAL_ERROR = 2

SEND_ERROR = 3

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

REFRESH LT_OTFDATA.

LT_OTFDATA[] = JOB_OUPUT-OTFDATA[].

CALL FUNCTION 'SSFCOMP_PDF_PREVIEW'

EXPORTING

I_OTF = LT_OTFDATA

EXCEPTIONS

CONVERT_OTF_TO_PDF_ERROR = 1

CNTL_ERROR = 2

OTHERS = 3.

IF SY-SUBRC <> 0.

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

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

ENDIF.

DATA: L_DUMMY TYPE STANDARD TABLE OF TLINE,

PDF_DATA TYPE XSTRING,

PDF_SIZE TYPE I.

CLEAR: PDF_DATA, PDF_SIZE.

* convert otf to pdf.

CALL FUNCTION 'CONVERT_OTF'

EXPORTING

FORMAT = 'PDF'

MAX_LINEWIDTH = 255

IMPORTING

BIN_FILESIZE = PDF_SIZE

BIN_FILE = PDF_DATA

TABLES

OTF = LT_OTFDATA[]

LINES = L_DUMMY

EXCEPTIONS

ERR_MAX_LINEWIDTH = 1

ERR_FORMAT = 2

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

WDR_TASK=>CLIENT_WINDOW->CLIENT->ATTACH_FILE_TO_RESPONSE(

* *path to the word file

I_FILENAME = 'WDA_SMARTFORMS.pdf'

* String Variable

I_CONTENT = PDF_DATA

* File Type

I_MIME_TYPE = 'PDF' ).


endmethod.

But it is showing the error when i click on print button during testing the web dynpro application.

Accepted Solutions (1)

Accepted Solutions (1)

pokrakam
Active Contributor

Please format code so it's readable.

From the error it seems your function module parameters are incorrect. You should not be executing application logic inside a view anyway, so place the code inside a method where you can also test it independent of Web Dynpro. There will also be a dump visible in ST22 which should give you more information.

aliimran_uppal
Participant
0 Kudos

Thanks Mike,

Issue has been resolved. Functional Module parameters were incorrect.

Answers (0)