globalsap-smartforms

35
Este ejemplo es un formulario de impresión de una lista de participantes a un curso. Los datos del formulario ahora los pasas como parámetros de una función SAP(SE37)

Upload: pedro-rodriguez

Post on 03-Nov-2014

32 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: GLOBALSAP-smartforms

Este ejemplo es un formulario de impresión de una lista de participantes a un curso.

Los datos del formulario ahora los pasas como parámetros de una función SAP(SE37)

Page 2: GLOBALSAP-smartforms

si observas existen parámetros standares que son propios de los smartforms, donde seteas

una serie de parámetros de impresión. Estos parámetros se “llenan” en el programa de

impresión. Los otros parámetros son propios del usuario, de esta forma le indicas al

smartform los campos a imprimir.

También le puedes pasar una tabla como parámetro de entrada:

standares

Propios

del

usuario

Page 3: GLOBALSAP-smartforms

En este caso la tabla indica una lista de participantes al curso.

en datos globales puedes definir variables que te pueden ser de utilidad en el procesamiento

del smartform, tal cual tu defines variables en un programa ABAP, con la sentencia DATA.

Los smartforms tambien se constituyen por páginas, ventanas, párrafos, etc. En este caso :

En este caso existe un tipo de Página con 4 ventanas:

PAGINA, HEADER, TITULO, y MAIN.

Existe la opción de insertar un mono que en este caso es el logo de la empresa. Como

insertas ventanas?, fácil:

Page 4: GLOBALSAP-smartforms

O sea te colocas en la página, botón derecho y listo.

Para el logo seleccionas “función gráfica”,

el grafico lo subes con otra transacción(SE78) con tipo BMP.

Ahora para ver la disposición de las páginas presionas “Form Painter”

Page 5: GLOBALSAP-smartforms

Ahora, como paso los parámetros al smartform?, evidente, igual que en los formularios

Page 6: GLOBALSAP-smartforms

si te fijas acá en la ventana HEADER tu creas un texto (te paras en la ventana, botón

derecho, crear, crear texto). Y le colocas los datos a imprimir. Obviamente estaban

declarados en la parte de “Interface formulario”.

UNA DE LAS GRANDES ventajas que tiene el smartforms son la impresión de listas,

como el detalle de una factura, para ello se utiliza el objeto “TABLA”.

Si vemos la salida de este formulario

observas que hay una impresión de una lista, cuyo contenido lo pasamos en la parte de

“Interface formulario” como una tabla ¿te acuerdas?. Para ello usamos las tablas.

En este caso la tabla esta en la ventana MAIN, posicionas boton derecho, crear tabla,

Page 7: GLOBALSAP-smartforms

en los atributos especificas el ancho de la línea de la tabla. En tipo líneas colocas el tipo de

línea que va a tener la tabla y las columnas. En el 90% siempre hay un solo tipo de línea, en

este ejemplo hay mas porque la cantidad de columnas es dinámica. OJO que la suma de las

columnas debe ser igual al ancho de la tabla.

El loop de la tabla lo colocas en DATOS

columnas

Page 8: GLOBALSAP-smartforms

fijate que el contenido de la tabla lo pasa a la variable wa_course_partic, la cual la

definimos en “Definiciones globales”, se estila así pues.

En ambito de cabecera defines los textos de cabecera de la tabla. Por ejemplo

Page 9: GLOBALSAP-smartforms

por ejemplo esta cabecera es para colocar “N°”, ojo que tienes que especificar el tipo de

línea al que pertenece la cabecera.

Page 10: GLOBALSAP-smartforms

pero como te explique casi siempre es un tipo de linea. En resumen creas tantos objetos

como columnas tiene el tipo de línea. Ojo que salen en el orden que se ven en la pantalla.

Las lineas las especificas de la siguiente forma

Page 11: GLOBALSAP-smartforms

osea colocas la variable con el campo especifico, igual que en caso anterior especificas el

orden tal como se ven en la pantalla.

Los smartforms se llaman de programas ABAP como una función común y silvestre, en

este caso el programa a utilizar es el siguiente:

REPORT ZESC_PPE_ATTEN_LIST MESSAGE-ID pv. *********************************************************************** * PROGRAM # * * LEVEL # 4.6C * * VERSION # 1.0 * * DATE WRITTEN # March 2003 * * SYSTEM # P - PE Training and Event Management * TYPE # ONLINE * * AUTHOR # TAPIPA9 * * TITLE # Print Atten List * PURPOSE # * * * COPIED FROM # n/a * * * * ASSOCIATED PROG # ZESC_PPE_TRAINING_REPORT_EMP * * * RESTRICTIONS # * * * * DESCRIPTION # Print Attendance List * * * * AMENDMENTS # * *---------------------------------------------------------------------* * VER DATE LEVEL CHANGE# CHANGE DESC WHO * *---------------------------------------------------------------------* * 0001 01/04/03 46C GHDK987620 new program TAPIPA9 *

Page 12: GLOBALSAP-smartforms

*---------------------------------------------------------------------* infotypes: 0002 mode n, 0001 mode n, 0008 mode n. INCLUDE ZESC_PPE_ATTEN_LIST_TOP. *INCLUDE zESC_PPE_ATTEN_QUALI_UPD_TOP. data num_attendes type i. data cdays(2) type n. data aux_nhours type ATTHR. data delete_all type i. data tb_days like p0041. parameters: pa_plvar like plog-plvar default '01' no-display, pa_event LIKE plog-objid obligatory, pa_kmaco LIKE pchdy-seark no-display, pa_prnt like usr01-spld no-display. AT SELECTION-SCREEN ON VALUE-REQUEST For pa_event. PERFORM objid_request USING pa_plvar 'E' CHANGING pa_kmaco pa_event. initialization. * Default the user's printer on the selection screen SELECT SINGLE spld INTO pa_prnt FROM usr01 WHERE bname EQ sy-uname. * If the select fails, then default it to the local printer IF sy-subrc <> 0 OR pa_prnt IS INITIAL. pa_prnt = 'LOCL'. ENDIF. start-of-selection. perform get_data. end-of-selection. perform header. * Invoke the ALV to display the eligble employees perform display_atten. *---------------------------------------------------------------------* * FORM get_data * *---------------------------------------------------------------------* * ........ * *---------------------------------------------------------------------* form get_data. data cont(2) type n. perform get_course_data tables course_schedule course_partic course_text course_price using event_type organizer location pa_plvar pa_event. clear num_attendes. sort course_partic by partx. loop at course_partic where eveid = pa_event and evbeg = course_schedule-begda and evend = course_schedule-endda and PATYP = 'P'. add 1 to cont. clear tb_aux. tb_aux-pernr = course_partic-parid. perform read_personal_infotype_0002 tables p0002 using course_schedule-begda

Page 13: GLOBALSAP-smartforms

course_schedule-endda tb_aux-pernr. course_partic-plvar = cont. write p0002-zzzcrut to course_partic-kosht. clear course_partic-kostl. clear course_partic-partx. concatenate p0002-nachn P0002-NAME2 P0002-VORNA into course_partic-partx separated by space. modify course_partic. tb_aux-nachn = p0002-nachn. tb_aux-name2 = P0002-NAME2. tb_aux-vorna = P0002-VORNA. tb_aux-zzzcrut = p0002-zzzcrut. tb_aux-midnm = p0002-midnm. append tb_aux. endloop. data num type i. num = cont div max_lin. num = num + 1. max_lin = max_lin * num. add 1 to cont. while cont <= max_lin. clear course_partic. course_partic-plvar = cont. append course_partic. add 1 to cont. endwhile. sort course_partic by plvar. append lines of tb_aux to tb_atten. data caux_date(10) type c. data caux_hour(8) type c. data aux_date type d. data char(1) type c. write course_schedule-begda to caux_date. course_days-stext = 'de'(100). concatenate course_days-stext caux_date into course_days-stext separated by space. write course_schedule-endda to caux_date. concatenate course_days-stext 'a'(101) caux_date into course_days-stext separated by space. field-symbols <f>. data campo(13) value 'tb_days-dat01'. cont = 1. loop at course_schedule. if aux_date <> course_schedule-evdat. campo+11(2) = cont. assign (campo) to <f>. <f> = course_schedule-evdat. add 1 to cont. endif. aux_date = course_schedule-evdat. char = ','. endloop. read table course_schedule index 1. aux_date = course_schedule-evdat. char = ' '.

Page 14: GLOBALSAP-smartforms

loop at course_schedule. if aux_date = course_schedule-evdat. write course_schedule-beguz to caux_hour. concatenate course_hour-stext caux_hour+0(5) into course_hour-stext separated by char. write course_schedule-enduz to caux_hour. concatenate course_hour-stext caux_hour+0(5) into course_hour-stext separated by '-'. char = '/'. else. exit. endif. aux_date = course_schedule-evdat. endloop. endform. *---------------------------------------------------------------------* * FORM get_course_data * *---------------------------------------------------------------------* * get data from the course, in this case the participant and the * schedule data of the course, and put into itables course_partic and * course_schedule *---------------------------------------------------------------------* * --> PLVAR : Plan variant * * --> OBJID : Id of the course * *---------------------------------------------------------------------* form get_course_data tables course_schedule structure hrvsched course_partic structure hrvpartic course_text structure p1000 course_price structure p1021 using p_event_type structure objec p_organizer structure objec p_location structure objec p_plvar p_objid. clear: course_schedule, course_partic, course_text, course_price. refresh: course_schedule, course_partic, course_text, course_price. call function 'RH_GET_EVENT_DATA' exporting planversion = p_plvar eventid = p_objid * with_schedule = 'X' * with_participants = 'X' ** with_cancellation = 'X' WITH_TEXT = 'X' WITH_CAPACITY = ' ' WITH_OCCUPATION = ' ' WITH_DESCRIPTION = ' ' WITH_PRICE = 'X' WITH_EXTRAS = ' ' WITH_SCHEDULE = 'X' WITH_URL = ' ' WITH_KNOWLEDGE = ' ' WITH_RESOURCES = ' ' WITH_PARTICIPANTS = 'X' WITH_ORGANIZER = 'X' WITH_EVENTTYPE = 'X' WITH_LOCATION = 'X' WITH_CANCELLATION = ' ' WITH_QUALIFICATIONS = ' ' WITH_REQUIREMENTS = ' ' WITH_TARGETGROUP = ' ' WITH_OTHER_INFTYS = ' ' IMPORTING EVENTTYPE = p_event_type organizer = p_organizer location = p_location tables price = course_price schedule = course_schedule participants = course_partic text = course_text exceptions

Page 15: GLOBALSAP-smartforms

no_infty_found = 1 others = 2 . IF SY-SUBRC <> 0. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF. endform. *---------------------------------------------------------------------* * FORM read_personal_infotype_0002 *---------------------------------------------------------------------* * read personal infotype 0002( Personal Data) * for personal PERNR *---------------------------------------------------------------------* * --> BEGDA : start of period * --> ENDDA : end of period * --> PERNR : employee number *---------------------------------------------------------------------* form read_personal_infotype_0002 tables p0002 structure p0002 using begda like p0002-begda endda like p0002-endda pernr like p0002-pernr. clear p0002. refresh p0002. call function 'HR_READ_INFOTYPE' exporting tclas = 'A' pernr = pernr infty = '0002' begda = begda endda = endda bypass_buffer = ' ' * IMPORTING * SUBRC = tables infty_tab = p0002 exceptions infty_not_found = 1 others = 2 . endform. *&---------------------------------------------------------------------* * Create event catalog table for ALV *----------------------------------------------------------------------* form create_eventcat. eventcat-name = 'TOP_OF_PAGE'. eventcat-form = 'TOP_OF_PAGE'. append eventcat. eventcat-name = 'END_OF_LIST'. eventcat-form = 'LIST_FOOTER'. append eventcat. eventcat-name = 'DATA_CHANGED'. eventcat-form = 'DATA_CHANGED2'. append eventcat. endform. " create_eventcat *---------------------------------------------------------------------* * FORM BUILD_SORTCAT * *---------------------------------------------------------------------* * Fill the ALV structure sorcat * *---------------------------------------------------------------------* * --> SPOS * * --> FIELDNAME * * --> UP * * --> SUBTOT * *---------------------------------------------------------------------* form build_sortcat using spos fieldname up subtot. data sortcat_ln like sortcat. sortcat_ln-spos = spos. sortcat_ln-fieldname = fieldname .

Page 16: GLOBALSAP-smartforms

sortcat_ln-up = up. sortcat_ln-down = space. sortcat_ln-subtot = subtot. append sortcat_ln to sortcat. endform. *&---------------------------------------------------------------------* *& Form create_fieldcat_runtbl *&---------------------------------------------------------------------* *& Create Table with names of all fields which are to be displayed *& on the list, this fieldcat is modified in form modify_fieldcat *&---------------------------------------------------------------------* form create_fieldcat_runtbl. data tbl(30) value 'TB_ATTEN'. refresh fieldcat. repid = sy-repid. * function to create field catalog for display call function 'REUSE_ALV_FIELDCATALOG_MERGE' EXPORTING i_program_name = repid i_inclname = repid i_internal_tabname = tbl i_bypassing_buffer = 'X' CHANGING ct_fieldcat = fieldcat[] EXCEPTIONS inconsistent_interface = 1 program_error = 2 others = 3. *perFORM set_edit_cols USING TBL. perform data_no_out using tbl. perform set_field_names using tbl. change_fieldcat edit 'RATE_0001' 'X' tbl. perform build_sortcat using '00' 'NACHN' 'X' ' '. "'X' suma perform build_sortcat using '00' 'NAME2' 'X' ' '. "'X' suma perform build_sortcat using '00' 'VORNA' 'X' ' '. "'X' suma perform build_sortcat using '00' 'ZZZCRUT' 'X' ' '. "'X' suma endform. " create_fieldcat_runtbl *&---------------------------------------------------------------------* *& Form display_atten *&---------------------------------------------------------------------* * call ALV function to display list *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* form display_atten. refresh sortcat. refresh eventcat. * Create the Event Catagories for ALV8 perform create_eventcat. * Create the field catalog for ALV perform create_fieldcat_runtbl. * Adjust the layout information

Page 17: GLOBALSAP-smartforms

layout-box_fieldname = 'BOX'. * layout-group_change_edit = space. "user can format sort criteria * layout-detail_initial_lines = 'X'. "show initial values in detail * layout-min_linesize = 132. layout-colwidth_optimize = 'X'. layout-edit = 'X'. * layout-edit_mode = 'A'. layout-zebra = 'X'. * layout-detail_popup = 'X'. layout-GROUP_BUTTONS = 'X'. * adjust print parameters print_param-prnt_info = 'X'. print_param-no_print_listinfos = ' '. * ALV function for display call function 'REUSE_ALV_GRID_DISPLAY' EXPORTING i_callback_program = repid i_callback_pf_status_set = 'SET_STATUS' i_callback_user_command = 'USER_COMMAND' * it_special_groups = ht_alv_special_groups * it_special_groups = ht_alv_special_groups is_layout = layout it_fieldcat = fieldcat[] it_sort = sortcat[] it_events = eventcat[] i_default = 'X' i_save = 'A' is_print = print_param TABLES t_outtab = tb_atten EXCEPTIONS program_error = 1 others = 2. endform. " display_atten *------------------------------------------------------------------ * FORM TOP_OF_PAGE *------------------------------------------------------------------ form top_of_page. * Write the header information to the output call function 'REUSE_ALV_COMMENTARY_WRITE' EXPORTING it_list_commentary = header_alv. endform. *&---------------------------------------------------------------------* *& Form SET_STATUS *&---------------------------------------------------------------------* * Performed from ALV function - set GUI status *----------------------------------------------------------------------* form set_status using extab type slis_t_extab. data status(5) type c. * Set the screen GUI case company . when 'ESC'. status = 'LIST1'. when others. status = 'LIST1'. endcase. set pf-status status. endform. " SET_STATUS *---------------------------------------------------------------------* * FORM USER_COMMAND *---------------------------------------------------------------------* * USER-COMMANDS are handled in this routine *---------------------------------------------------------------------* * --> R_UCOMM : User-command from list screen * * --> RS_SELFIELD : selected field * *---------------------------------------------------------------------* form user_command using r_ucomm LIKE SY-UCOMM

Page 18: GLOBALSAP-smartforms

rs_selfield type slis_selfield. data tb_aux2 like tb_atten occurs 10 with header line. tb_aux2[] = tb_atten[]. * loop at tb_atten where pos <> 1. * aux_tabix = sy-tabix. * read table tb_aux2 with key pos = 1 * pernr = tb_atten-pernr. * tb_atten-rate = tb_aux2-rate. * tb_atten-atten_% = tb_aux2-atten_%. * tb_atten-bonus_pay = tb_aux2-bonus_pay. * modify tb_atten index aux_tabix. * endloop. data f type i. * Process User Commands case r_ucomm. when 'EXIT'. "Exit rs_selfield-exit = 'X'. when 'PRINT'. perform proc_smartform. when others. endcase. endform. *&---------------------------------------------------------------------* *& Form data_no_out *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->P_TBL text *----------------------------------------------------------------------* FORM data_no_out USING P_TBL. change_fieldcat tech 'BOX' 'X' p_tbl. ENDFORM. " data_no_out *---------------------------------------------------------------------* * FORM fieldcat_seltext_m * *---------------------------------------------------------------------* * ........ * *---------------------------------------------------------------------* * --> P_FIELD * * --> P_TEXT * * --> P_TABLE * *---------------------------------------------------------------------* form fieldcat_seltext_m using p_field p_text p_table. change_fieldcat seltext_m p_field p_text p_table. change_fieldcat ddictxt p_field 'M' p_table. endform. *---------------------------------------------------------------------* * FORM set_field_names * *---------------------------------------------------------------------* * ........ * *---------------------------------------------------------------------* form set_field_names using tbl. endform. *---------------------------------------------------------------------* * FORM list_footer * *---------------------------------------------------------------------*

Page 19: GLOBALSAP-smartforms

* Print the stadistic data in the footer of the report * *---------------------------------------------------------------------* form list_footer. DATA: IT_LIST_HEADER TYPE SLIS_T_LISTHEADER, IT_LIST_HEADER_LINE TYPE SLIS_LISTHEADER. DATA: WS_NUMBER(8). endform. *---------------------------------------------------------------------* * FORM header * *---------------------------------------------------------------------* * ........ * *---------------------------------------------------------------------* form header. data aux_text(50) type c. data cdate(10). ************************************************************************ * Display the table tb_pbo in ALV format *********************************************************************** clear header_alv_wa. header_alv_wa-typ = 'H'. header_alv_wa-info = sy-title. append header_alv_wa to header_alv. concatenate course_text-objid course_text-stext into aux_text separated by space. clear header_alv_wa. header_alv_wa-typ = 'S'. header_alv_wa-info = aux_text. header_alv_wa-key = text-001. append header_alv_wa to header_alv. write course_schedule-begda DD/MM/YYYY to cdate. clear header_alv_wa. header_alv_wa-typ = 'S'. header_alv_wa-key = text-003. header_alv_wa-info = cdate. append header_alv_wa to header_alv. write course_schedule-endda DD/MM/YYYY to cdate. clear header_alv_wa. header_alv_wa-typ = 'S'. header_alv_wa-key = text-004. header_alv_wa-info = cdate. append header_alv_wa to header_alv. clear header_alv_wa. header_alv_wa-typ = 'A'. append header_alv_wa to header_alv. endform. *---------------------------------------------------------------------* * FORM proc_smartform * *---------------------------------------------------------------------* * ........ * *---------------------------------------------------------------------* form proc_smartform. data: pa_form LIKE ssfscreen-fname . pa_form = 'ZESC_ATTENDANCE_LIST'. * determine the name of the generated function module for the SMartform CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME' EXPORTING formname = pa_form IMPORTING fm_name = func_module_name EXCEPTIONS no_form = 1 no_function_module = 2 OTHERS = 3. * Default printer options output_options-tddest = pa_prnt. output_options-tdnewid = 'X'. output_options-tdimmed = 'X'.

Page 20: GLOBALSAP-smartforms

output_options-tddelete = 'X'. * control_parameters-no_open = space. * control_parameters-no_close = ''. * call the generated function module of the form CALL FUNCTION func_module_name EXPORTING control_parameters = control_parameters output_options = output_options user_settings = space COURSE_SCHEDULE = course_schedule COURSE_TEXT = course_text course_days = course_days course_hour = course_hour location = location days = tb_days TABLES course_partic = course_partic EXCEPTIONS formatting_error = 1 internal_error = 2 send_error = 3 user_canceled = 4 my_exception = 5 OTHERS = 6. . endform.

Fíjate que en este último form se imprime el formulario, o sea, analiza solo esta parte,

Page 21: GLOBALSAP-smartforms

NOTA IMPORTANTE: el ejemplo siguiente se realizo en sap >= 4.7, el tutorial anterior es

de la 46C, los cambios más notables son en la definición de las tablas ojo con eso

Ejercicio N° 1.

El jefe quiere el listado de los usuarios que hay en Sap y quiere imprimir la siguiente carta:

Santiago, 23 de Enero del 2006

LISTADO DE USUARIOS SAP

Empresa GlobalSap consulting, tiene los siguientes usuarios registrados en SAP

Codigo Usuario Nombre

JVASQUEZ Jaime Vazquez

CRUIZ Cristian Ruiz

GGONZALEZ German Gonzalez

PTAPIA Pablo Tapia

Solución:

Vamos a la transacción SMARTFORM, creamos el smartform y definimos la tabla de

entrada usuarios

Page 22: GLOBALSAP-smartforms

En este ejemplo usaremos la ventana MAIN que se crea por defecto, acuérdense que el

concepto de MAIN es el mismo que en el de los SAPSCRIPT.

A la ventana main le definiremos un texto llamado HEADER para colocar el texto de

cabecera de la tabla.

1.

Interface

form.

2.

TABLAS

3. Def. Tabla

USUARIOS

Page 23: GLOBALSAP-smartforms

Fíjate en el botón Lista de campos, ahí en el extremo inferior izquierdo, salen todos los

campos visibles para programa smartform, para poner la fecha utilizaremos la variable de

sistema DATE, fíjate que esto es drag & drop , que bonito no.

Crear texto,

HEADER

Page 24: GLOBALSAP-smartforms

De ahí simplemente le colocas el texto tal cual como en un editor.

1. Lista de

campos

2. Lista de campos

3. variable de

sistema DATE

4. drag & drop

Page 25: GLOBALSAP-smartforms

Ahora hay que definir la tabla para la impresión de los usuarios:

Creamos tabla:

Lo que hay que definir es lo siguiente, la cantidad de columnas que tendrá,

Vamos a details

Page 26: GLOBALSAP-smartforms

1. Details

Page 27: GLOBALSAP-smartforms

Ojo con esto

Definimos las columnas, en

este caso son 2, una para

usuario y otra para nombre,

ojo con los largos que tiene

que ser igual al ancho de tabla.

Page 28: GLOBALSAP-smartforms

Para trabajar con la

tabla tenemos que

definir un work area,

que definimos en

definiciones globales

Page 29: GLOBALSAP-smartforms

Volvamos a la tabla

Work area para la tabla

1. Datos

globales

Page 30: GLOBALSAP-smartforms

Fíjate que las tablas tienen

áreas para

Cabecera: típico que aquí

definimos el nombre de las

columnas.

Principal: las líneas se

imprimen aquí.

Pie: Ejemplo, impresión de

los totales

Page 31: GLOBALSAP-smartforms

Entonces creamos

“Entrada en tabla, y

definimos el tipo de

linea

Page 32: GLOBALSAP-smartforms

Para que esto tengo sentido, hay que crear el programa ABAP de impresión, en este caso el

YTEST_SMART, en la rutina siguiente se imprime:

*&---------------------------------------------------------------------* *& Form print_data *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* form print_data. data: *smartforms related func_module_name type rs38l_fnam, control_parameters type ssfctrlop, output_options type ssfcompop. data: pa_form LIKE ssfscreen-fname . pa_form = 'YTEST_SMART'. output_options-tdnewid = 'X'. output_options-tdimmed = 'X'. output_options-tddelete = 'X'. control_parameters-no_dialog = ' '.

Fijate que en cada

columna(CELL),

ponemos un campo de la

work area y eso es todo

Page 33: GLOBALSAP-smartforms

* determine the name of the generated function module for the SMartform CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME' EXPORTING formname = pa_form IMPORTING fm_name = func_module_name EXCEPTIONS no_form = 1 no_function_module = 2 OTHERS = 3. * call the generated function module of the form CALL FUNCTION func_module_name EXPORTING control_parameters = control_parameters output_options = output_options user_settings = space TABLES usuarios = user_name_address_tab EXCEPTIONS formatting_error = 1 internal_error = 2 send_error = 3 user_canceled = 4 my_exception = 5 OTHERS = 6. endform. "print_data

Lo ejecutamos y tah tan que bonito!!!!!!!!!!!!

Ojo que un smartform es

una función(SE37),

entonces aca le pasas el

nombre del smartform y

te pasa el nombre de la

funcion. El nombre es

del estilo

/1BCDWB/SF00000172

Aca ejecutamos la llamada al

smartform como una función, le

pasamos los parámetros de

impresión y la tabla USUARIOS

para imprimir

Page 34: GLOBALSAP-smartforms

*&---------------------------------------------------------------------* *& Report YTEST_SMART *& *&---------------------------------------------------------------------* *& *& *&---------------------------------------------------------------------* REPORT YTEST_SMART. data USER_NAME_TAB like standard table of USUSERS. data USER_NAME_ADDRESS_TAB like standard table of USADDR3. start-of-selection. perform get_users. perform print_data. *&---------------------------------------------------------------------* *& Form get_users *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* form get_users. CALL FUNCTION 'SUSR_USER_ADDRESS_READ_ARRAY' EXPORTING ALL_USERS = 'X' * IMPORTING * RETURNCODE = TABLES USER_NAME_TAB = user_name_tab * USER_ADDRESS_TAB = USER_NAME_ADDRESS_TAB = user_name_address_tab * EXCEPTIONS * INTERNAL_ERROR = 1 * USER_NAME_TAB_IS_EMPTY = 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. endform. "get_users *&---------------------------------------------------------------------* *& Form print_data *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* form print_data. data: *smartforms related func_module_name type rs38l_fnam, control_parameters type ssfctrlop,

Page 35: GLOBALSAP-smartforms

output_options type ssfcompop. data: pa_form LIKE ssfscreen-fname . pa_form = 'YTEST_SMART'. output_options-tdnewid = 'X'. output_options-tdimmed = 'X'. output_options-tddelete = 'X'. control_parameters-no_dialog = ' '. * determine the name of the generated function module for the SMartform CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME' EXPORTING formname = pa_form IMPORTING fm_name = func_module_name EXCEPTIONS no_form = 1 no_function_module = 2 OTHERS = 3. * call the generated function module of the form CALL FUNCTION func_module_name EXPORTING control_parameters = control_parameters output_options = output_options user_settings = space TABLES usuarios = user_name_address_tab EXCEPTIONS formatting_error = 1 internal_error = 2 send_error = 3 user_canceled = 4 my_exception = 5 OTHERS = 6. endform. "print_data