Professional Documents
Culture Documents
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. Va entendiendo el matita?.
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.
Tal como el perro conoce los smartforms tambien se constituyen por pginas, ventanas,
prrafos, etc. En este caso :
Existe la opcin de insertar un mono que en este caso es el logo de la empresa. Como
insertas ventanas?, fcil:
osea te colocas en la pgina, botn derecho y listo.
UNA DE LAS GRANDES ventajas que tiene el smartforms son la impresin de listas,
como el detalle de una factura, para ello se utiliza el objeto TABLA.
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.
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.
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.
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.
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.
* 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 = ' '.
*------------------------------------------------------------------
* 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.
Fjate que en este ltimo form se imprime el formulario, o sea, analiza solo esta parte, lo dems es paja.