cancel
Showing results for 
Search instead for 
Did you mean: 

how to print smartform from a report

Former Member
0 Kudos

Im displaying a report, which contains several documents, whereby which ewch document is connected to a smartform.

The page displaying the report contains a button 'Print'

When clicking on the Print button, all the documents in the report should be printed.

But my program is creating a spool file of the report, which will be printed further - its not what I want

I want the program to print the smartforms of each documents on the report directly.

heres my code and I dont know what I should do to be able to print the smartforms directly

  • Get the function module name of the smartform.

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

EXPORTING

formname = '/EU000/FI_PRINT_DEBIT_NOTE'

IMPORTING

fm_name = g_fm_name.

gw_options-tdnoprev = ' '.

gw_options-tddest = 'LOCL'.

gw_options-tdprinter = 'LOCL'.

gw_options-tdnewid = 'X'.

gw_options-tdimmed = 'X'.

gw_control-preview = ' '.

gw_control-no_dialog = 'X'.

write: text-006,' ', text-007, ' ', text-008.

write:/.

  • For all the documents

LOOP AT gi_all_data INTO gw_all_data.

write: gw_all_data-gjahr(4), ' ',gw_all_data-belnr,' ', gw_all_data-belnr.

write:/.

CASE SY-UCOMM.

WHEN 'PRINT'.

  • Call the smarform

CALL FUNCTION g_fm_name

EXPORTING

gw_all_data = gw_all_data

user_settings = ' '

output_options = gw_options

control_parameters = gw_control.

WHEN 'BACK'.

LEAVE SCREEN.

ENDCASE.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

DATA: x_control_parameters TYPE ssfctrlop,

x_output_options TYPE ssfcompop.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

PARAMETERS: p_prin LIKE usr01-spld.

SELECTION-SCREEN BEGIN OF LINE.

INITIALIZATION.

SELECT spld

FROM usr01

INTO p_prin UP TO 1 ROWS

WHERE bname = sy-uname.

ENDSELECT.

START-OF-SELECTION.

x_output_options-tdimmed = c_x.

x_output_options-tddest = p_prin.

x_output_options-tdnewid = c_x.

x_output_options-tdreceiver = sy-uname.

x_output_options-tdcopies = '001'.

x_control_parameters-device = 'PRINTER'.

x_control_parameters-no_dialog = c_x.

x_control_parameters-langu = sy-langu.

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

EXPORTING

formname = 'Z_SMARTFORM'

  • VARIANT = ' '

  • DIRECT_CALL = ' '

IMPORTING

fm_name = f_name1

EXCEPTIONS

no_form = 1

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

IF P_PRI = 'X'.

CALL FUNCTION F_NAME1

EXPORTING

  • ARCHIVE_INDEX =

  • ARCHIVE_INDEX_TAB =

  • ARCHIVE_PARAMETERS =

CONTROL_PARAMETERS = X_CONTROL_PARAMETERS

  • MAIL_APPL_OBJ =

  • MAIL_RECIPIENT =

  • MAIL_SENDER =

OUTPUT_OPTIONS = X_OUTPUT_OPTIONS

  • USER_SETTINGS = 'X'

wa_header = wa_zmexh51

  • IMPORTING

  • DOCUMENT_OUTPUT_INFO =

  • JOB_OUTPUT_INFO =

  • JOB_OUTPUT_OPTIONS =

TABLES

tab_item = TAB_ZMEXD51

tab_item1 = TAB_ZMEXS51

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

ELSEIF P_PRE = 'X'.

CALL FUNCTION F_NAME1

EXPORTING

  • ARCHIVE_INDEX =

  • ARCHIVE_INDEX_TAB =

  • ARCHIVE_PARAMETERS =

  • CONTROL_PARAMETERS = X_CONTROL_PARAMETERS

  • MAIL_APPL_OBJ =

  • MAIL_RECIPIENT =

  • MAIL_SENDER =

  • OUTPUT_OPTIONS = X_OUTPUT_OPTIONS

  • USER_SETTINGS = 'X'

wa_header = wa_zmexh51

  • IMPORTING

  • DOCUMENT_OUTPUT_INFO =

  • JOB_OUTPUT_INFO =

  • JOB_OUTPUT_OPTIONS =

TABLES

tab_item = TAB_ZMEXD51

tab_item1 = TAB_ZMEXS51

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

ENDIF.

Check the above code its just similar requirement it may helpful to you.

Thanks,

Phani.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

It is by using SSF_FUNCTIONMODULE_NAME function module.

It captures the FM released by smart form.

In the below coadind menction ur smart form name.

if any parameters to be passed to smartform from report then usse 2nd FM i.e lf_name which is of type rs38l_fnam.

in the below example i am passing a value of p_ebeln to gv_ebeln . gv_ebeln is declared in smartform -> form interface->import parameters

Coding

report zmm_1060_purchase_order.

data: lf_name type rs38l_fnam.

parameters: p_ebeln type ebeln .

call function 'SSF_FUNCTION_MODULE_NAME'

exporting

formname = 'SMART FORM NAME'

VARIANT = ' '

DIRECT_CALL = ' '

importing

fm_name = lf_name

exceptions

no_form = 1

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

else.

Execute the Smartform name

call function lf_name

exporting

gv_ebeln = p_ebeln

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.

endif.

Regards,

vijetha.