control a smartform called from inside a loop

4
Calling a smartform from a report layout. You trigger form printing by calling only two function modules. The first module uses the name of the form to determine the name of the generated function module. Then you call this module. 1. In the smartform click on the menu Environment  function module  Name You will get the name of the generated function module. Copy the name of this function module. 2. In the data driver progr am def ine a var iable of type rs281_fnam for the name of the generated function module data p_fmname type rs38l_fnam. !. Call function mo du le SSF_FUNCTION_MODULE_NAME  . It returns the name of the generated function module CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'  E!O"TIN#

Upload: roys-palnati-s

Post on 19-Oct-2015

5 views

Category:

Documents


0 download

DESCRIPTION

smart forms

TRANSCRIPT

Calling a smartform from a report layout

Calling a smartform from a report layout.

You trigger form printing by calling only two function modules. The first module uses the name of the form to determine the name of the generated function module. Then you call this module.

1. In the smartform click on the menu Environment ( function module Name

You will get the name of the generated function module. Copy the name of this function module.

2. In the data driver program define a variable of type rs281_fnam for the name of the generated function module: data p_fmname type rs38l_fnam.3. Call function module SSF_FUNCTION_MODULE_NAME . It returns the name of the generated function module: CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'EXPORTINGFORMNAME= ''IMPORTINGFM_NAME= p_fmnameEXCEPTIONSNO_FORM= 1NO_FUNCTION_MODULE= 2OTHERS= 3.

IF SY-SUBRC 0.ENDIF.

4. Call the generated function module. To do this, click on the pattern button for CALL FUNCTION in the ABAP Editor and use the name you copied in step 1. Then replace the function module name with the variable p_fmname defined in step 2. CALL FUNCTION p_fmnameEXPORTING*ARCHIVE_INDEX =*ARCHIVE_PARAMETERS = CONTROL_PARAMETERS = X_CONTROL_PARAMETERS

*MAIL_APPL_OBJ =*MAIL_RECIPIENT =*MAIL_SENDER =*OUTPUT_OPTIONS = USER_SETTINGS = X

V_SPRAS = G_SPRAS

IS_AR_DATA = P_ADR_DATA

EXCEPTIONS

FORMATTING_ERROR = 1

INTERNAL_ERROR = 2

SEND_ERROR = 3

USER_CANCELED = 4

OTHERS = 5.

IF SY-SUBRC 0.ENDIF.If in some cases we need to call this function module (p_fmname) inside a loop then we need to control the print parameters pop-up or for every loop pass print parameters pop-up will come. So if we want that pop-up should come only once then we need to control the structure CONTROL_PARAMETERS.

Count the number of records in that internal table.

DESCRIBE TABLE itab LINES g_lines.

Populate structure X_CONTROL_PARAMETERS.

Set a counter count.

Loop at itab.

Count = count + 1.

If count = 1.

x_control_parameters-no_close = X.

Else.

x_control_parameters-no_open = 'X'.

x_control_parameters-no_close = 'X'.

Endif.

If Count = g_lines.

CLEAR x_control_parameters-no_close.

Endif.

CALL FUNCTION p_fmnameEXPORTING*ARCHIVE_INDEX =*ARCHIVE_PARAMETERS = CONTROL_PARAMETERS = X_CONTROL_PARAMETERS

*MAIL_APPL_OBJ =*MAIL_RECIPIENT =*MAIL_SENDER =*OUTPUT_OPTIONS = USER_SETTINGS = X

V_SPRAS = G_SPRAS

IS_AR_DATA = P_ADR_DATA

EXCEPTIONS

FORMATTING_ERROR = 1

INTERNAL_ERROR = 2

SEND_ERROR = 3

USER_CANCELED = 4

OTHERS = 5.

IF SY-SUBRC 0.ENDIF.Endloop.