Documentos de Académico
Documentos de Profesional
Documentos de Cultura
GLOBALSAP Smartforms PDF
GLOBALSAP Smartforms PDF
Los datos del formulario ahora los pasas como parmetros de una funcin SAP(SE37)
standares
Propios
del
usuario
si observas existen parmetros standares que son propios de los smartforms, donde seteas
una serie de parmetros de impresin. Estos parmetros se llenan en el programa de
impresin. Los otros parmetros son propios del usuario, de esta forma le indicas al
smartform los campos a imprimir.
Tambin le puedes pasar una tabla como parmetro de entrada:
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 pginas, ventanas, prrafos, etc. En este caso :
Ahora, como paso los parmetros al smartform?, evidente, igual que en los formularios
observas que hay una impresin 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 lnea de la tabla. En tipo lneas colocas el tipo de
lnea que va a tener la tabla y las columnas. En el 90% siempre hay un solo tipo de lnea, en
este ejemplo hay mas porque la cantidad de columnas es dinmica. OJO que la suma de las
columnas debe ser igual al ancho de la tabla.
El loop de la tabla lo colocas en DATOS
por ejemplo esta cabecera es para colocar N, ojo que tienes que especificar el tipo de
lnea al que pertenece la cabecera.
pero como te explique casi siempre es un tipo de linea. En resumen creas tantos objetos
como columnas tiene el tipo de lnea. Ojo que salen en el orden que se ven en la pantalla.
Las lineas las especificas de la siguiente forma
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 funcin comn 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.
data
data
data
data
data
num_attendes type i.
cdays(2) type n.
aux_nhours type ATTHR.
delete_all type i.
tb_days like p0041.
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
tb_aux-name2
tb_aux-vorna
tb_aux-zzzcrut
tb_aux-midnm
append tb_aux.
=
=
=
=
=
p0002-nachn.
P0002-NAME2.
P0002-VORNA.
p0002-zzzcrut.
p0002-midnm.
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.
caux_date(10) type c.
caux_hour(8) type c.
aux_date type d.
char(1) type c.
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
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
=
eventcat-form
=
append eventcat.
eventcat-name
=
eventcat-form
=
append eventcat.
'TOP_OF_PAGE'.
'TOP_OF_PAGE'.
'END_OF_LIST'.
'LIST_FOOTER'.
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 .
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.
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
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 = ' '.
*
*
*
endform.
" display_atten
" 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
*&---------------------------------------------------------------------*
*&
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
change_fieldcat ddictxt
endform.
p_field
p_field
p_text
'M'
p_table.
p_table.
*---------------------------------------------------------------------*
*
FORM set_field_names
*
*---------------------------------------------------------------------*
*
........
*
*---------------------------------------------------------------------*
form set_field_names using tbl.
endform.
*---------------------------------------------------------------------*
*
FORM list_footer
*
*---------------------------------------------------------------------*
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'.
output_options-tddelete = 'X'.
*
*
control_parameters-no_open = space.
control_parameters-no_close = ''.
Fjate
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 ms notables son en la definicin 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:
Codigo Usuario
JVASQUEZ
CRUIZ
GGONZALEZ
PTAPIA
Nombre
Jaime Vazquez
Cristian Ruiz
German Gonzalez
Pablo Tapia
Solucin:
Vamos a la transaccin SMARTFORM, creamos el smartform y definimos la tabla de
entrada usuarios
2.
TABLAS
1.
Interface
form.
3. Def. Tabla
USUARIOS
En este ejemplo usaremos la ventana MAIN que se crea por defecto, acurdense 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.
Crear texto,
HEADER
Fjate en el botn 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, fjate que esto es drag & drop , que bonito no.
1. Lista de
campos
2. Lista de campos
3. variable de
sistema DATE
Vamos a details
1. Details
1. Datos
globales
Volvamos a la tabla
Entonces creamos
Entrada en tabla, y
definimos el tipo de
linea
Para que esto tengo sentido, hay que crear el programa ABAP de impresin, 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
Ojo que un smartform es
fm_name
= func_module_name
EXCEPTIONS
una funcin(SE37),
no_form
= 1
entonces aca le pasas el
no_function_module = 2
nombre del smartform y
OTHERS
= 3.
"print_data
te pasa el nombre de la
funcion. El nombre es
del estilo
/1BCDWB/SF00000172
*&---------------------------------------------------------------------*
*& Report YTEST_SMART
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT
YTEST_SMART.
data
data
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.
"print_data