Documente Academic
Documente Profesional
Documente Cultură
Los datos del formulario ahora los pasas como parámetros de una función SAP(SE37)
standares
Propios
del
usuario
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.
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 :
Existe la opción de insertar un mono que en este caso es el logo de la empresa. Como
insertas ventanas?, fácil:
O sea te colocas en la página, botón derecho y listo.
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”.
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,
columnas
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.
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
*
*---------------------------------------------------------------------*
infotypes: 0002 mode n,
0001 mode n,
0008 mode n.
INCLUDE ZESC_PPE_ATTEN_LIST_TOP.
*INCLUDE zESC_PPE_ATTEN_QUALI_UPD_TOP.
initialization.
* Default the user's printer on the selection screen
SELECT SINGLE spld INTO pa_prnt FROM usr01
WHERE bname EQ sy-uname.
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.
add 1 to cont.
clear tb_aux.
tb_aux-pernr = course_partic-parid.
perform read_personal_infotype_0002 tables p0002
using course_schedule-begda
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.
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.
add 1 to cont.
while cont <= max_lin.
clear course_partic.
course_partic-plvar = cont.
append course_partic.
add 1 to cont.
endwhile.
course_days-stext = 'de'(100).
concatenate course_days-stext 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.
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.
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.
sortcat_ln-spos = spos.
sortcat_ln-fieldname = fieldname .
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.
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.
*&---------------------------------------------------------------------*
*& Form display_atten
*&---------------------------------------------------------------------*
* call ALV function to display list
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form display_atten.
refresh sortcat.
refresh eventcat.
*------------------------------------------------------------------
* FORM TOP_OF_PAGE
*------------------------------------------------------------------
form top_of_page.
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.
*---------------------------------------------------------------------*
* 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
rs_selfield type slis_selfield.
tb_aux2[] = tb_atten[].
data f type i.
endform.
*&---------------------------------------------------------------------*
*& Form data_no_out
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_TBL text
*----------------------------------------------------------------------*
FORM data_no_out USING P_TBL.
*---------------------------------------------------------------------*
* FORM set_field_names *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
form set_field_names using tbl.
endform.
*---------------------------------------------------------------------*
* FORM list_footer *
*---------------------------------------------------------------------*
* 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.
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'.
output_options-tddelete = 'X'.
* control_parameters-no_open = space.
* control_parameters-no_close = ''.
endform.
Fíjate que en este último form se imprime el formulario, o sea, analiza solo esta parte,
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:
Solución:
1.
Interface
form.
3. Def. Tabla
USUARIOS
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.
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.
1. Lista de
campos
2. Lista de campos
3. variable de
sistema DATE
Creamos tabla:
Vamos a details
1. Details
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.
Volvamos a la tabla
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
Entonces creamos
“Entrada en tabla, y
definimos el tipo de
linea
Fijate que en cada
columna(CELL),
ponemos un campo de la
work area y eso es todo
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 = ' '.
* 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 Ojo que un smartform es
EXCEPTIONS una función(SE37),
no_form = 1
no_function_module = 2
entonces aca le pasas el
OTHERS = 3. nombre del smartform y
te pasa el nombre de la
funcion. El nombre es
* call the generated function module of the form del estilo
CALL FUNCTION func_module_name
EXPORTING
control_parameters = control_parameters
/1BCDWB/SF00000172
output_options = output_options
user_settings = space
TABLES
usuarios = user_name_address_tab
EXCEPTIONS
formatting_error = 1 Aca ejecutamos la llamada al
internal_error = 2 smartform como una función, le
send_error = 3
user_canceled = 4 pasamos los parámetros de
my_exception = 5 impresión y la tabla USUARIOS
OTHERS = 6. para imprimir
endform. "print_data
REPORT YTEST_SMART.
start-of-selection.
perform get_users.
perform print_data.
*&---------------------------------------------------------------------*
*& Form get_users
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
form get_users.
endform. "get_users
*&---------------------------------------------------------------------*
*& 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 = ' '.
* 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.
endform. "print_data