Ver Mensaje Individual
  #4  
Viejo 11/03/08, 20:30:18
123porcristina 123porcristina is offline
Junior Member
 
Fecha de Ingreso: jul 2007
Mensajes: 14
hola a todos!!!

lo que pasa es que tengo el siguiente alv pero necesito adicionar el boton de exportar a excel como lo puedo hacer???

*&---------------------------------------------------------------------*
*& Report ZTRANPMR_REP_T352R
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT ZTRANPMR_REP_T352R.

*===================================================================*
* Autor: Maria Cristina Giraldo Vargas
* 11.03.08 -
*
*===================================================================*

*========================== Global definitions ====================*

**
* Data Types
**

type-pools: slis.



types: begin of tp_data,
mandt like t352r-mandt,
iwerk like t352r-iwerk,
revnr like t352r-revnr,
revbd like t352r-revbd,
revbz like t352r-revbz,
reved like t352r-reved,
revez like t352r-revez,
revtx like t352r-revtx,
revab like t352r-revab,
pm_objty like t352r-pm_objty,
gewrk like t352r-gewrk,
equnr like t352r-equnr,
pspel like t352r-pspel,
aufnr like t352r-aufnr,
aenam like t352r-aenam,
aedat like t352r-aedat,
ernam like t352r-ernam,
erdat like t352r-erdat,
objnr like t352r-objnr,
revty like t352r-revty,
objid like t352r-objid,
zzorig like t352r-zzorig,
zzclas like t352r-zzclas,
zzpernr like t352r-zzpernr,
zztcon like t352r-zztcon,
zzconsig like t352r-zzconsig,
zzrevbd like t352r-zzrevbd,
zzreved like t352r-zzreved,
zzrevbz like t352r-zzrevbz,
zzrevez like t352r-zzrevez,
zzmed like t352r-zzmed,
zzstat like t352r-zzstat,
zzequi like t352r-zzequi,
zzut like t352r-zzut,
zzatentado like t352r-zzatentado,
zzespejo like t352r-zzespejo,

end of tp_data,
tp_tbl_data type standard table of tp_data.

**
* Constants
**


**
* Data objects (variable declarations and definitions)
**

* Report data to be shown.
data: it_data type standard table of tp_data.

* Heading of the report.
*data: t_heading type slis_t_listheader.

*======================= Selection Screen ==========================*

selection-screen: begin of block b1 with frame title text-t01.
DATA: w_aux_iwerk like t352r-iwerk.
SELECT-OPTIONS s_iwerk for w_aux_iwerk .
DATA: w_aux_revnr like t352r-revnr.
SELECT-OPTIONS s_revnr for w_aux_revnr .
DATA: w_aux_revbd like t352r-revbd.
SELECT-OPTIONS s_revbd for w_aux_revbd .
DATA: w_aux_revbz like t352r-revbz.
SELECT-OPTIONS s_revbz for w_aux_revbz .
DATA: w_aux_reved like t352r-reved.
SELECT-OPTIONS s_reved for w_aux_reved .
DATA: w_aux_revez like t352r-revez.
SELECT-OPTIONS s_revez for w_aux_revez .
DATA: w_aux_revtx like t352r-revtx.
SELECT-OPTIONS s_revtx for w_aux_revtx .
DATA: w_aux_revab like t352r-revab.
SELECT-OPTIONS s_revab for w_aux_revab .
DATA: w_aux_pm_objty like t352r-pm_objty.
SELECT-OPTIONS s_pm_o09 for w_aux_pm_objty .
DATA: w_aux_gewrk like t352r-gewrk.
SELECT-OPTIONS s_gewrk for w_aux_gewrk .
DATA: w_aux_equnr like t352r-equnr.
SELECT-OPTIONS s_equnr for w_aux_equnr .
DATA: w_aux_tplnr like t352r-tplnr.
SELECT-OPTIONS s_tplnr for w_aux_tplnr .
DATA: w_aux_pspel like t352r-pspel.
SELECT-OPTIONS s_pspel for w_aux_pspel .
DATA: w_aux_aufnr like t352r-aufnr.
SELECT-OPTIONS s_aufnr for w_aux_aufnr .
DATA: w_aux_aenam like t352r-aenam.
SELECT-OPTIONS s_aenam for w_aux_aenam .
DATA: w_aux_aedat like t352r-aedat.
SELECT-OPTIONS s_aedat for w_aux_aedat .
DATA: w_aux_ernam like t352r-ernam.
SELECT-OPTIONS s_ernam for w_aux_ernam .
DATA: w_aux_erdat like t352r-erdat.
SELECT-OPTIONS s_erdat for w_aux_erdat .
DATA: w_aux_objnr like t352r-objnr.
SELECT-OPTIONS s_objnr for w_aux_objnr .
DATA: w_aux_revty like t352r-revty.
SELECT-OPTIONS s_revty for w_aux_revty .
DATA: w_aux_objid like t352r-objid.
SELECT-OPTIONS s_objid for w_aux_objid .
DATA: w_aux_zzorig like t352r-zzorig.
SELECT-OPTIONS s_zzorig for w_aux_zzorig .
DATA: w_aux_zzclas like t352r-zzclas.
SELECT-OPTIONS s_zzclas for w_aux_zzclas .
DATA: w_aux_zzpernr like t352r-zzpernr.
SELECT-OPTIONS s_zzpe24 for w_aux_zzpernr .
DATA: w_aux_zztcon like t352r-zztcon.
SELECT-OPTIONS s_zztcon for w_aux_zztcon .
DATA: w_aux_zzconsig like t352r-zzconsig.
SELECT-OPTIONS s_zzco26 for w_aux_zzconsig .
DATA: w_aux_zzrevbd like t352r-zzrevbd.
SELECT-OPTIONS s_zzre27 for w_aux_zzrevbd .
DATA: w_aux_zzreved like t352r-zzreved.
SELECT-OPTIONS s_zzre28 for w_aux_zzreved .
DATA: w_aux_zzrevbz like t352r-zzrevbz.
SELECT-OPTIONS s_zzre29 for w_aux_zzrevbz .
DATA: w_aux_zzrevez like t352r-zzrevez.
SELECT-OPTIONS s_zzre30 for w_aux_zzrevez .
DATA: w_aux_zzmed like t352r-zzmed.
SELECT-OPTIONS s_zzmed for w_aux_zzmed .
DATA: w_aux_zzstat like t352r-zzstat.
SELECT-OPTIONS s_zzstat for w_aux_zzstat .
DATA: w_aux_zzequi like t352r-zzequi.
SELECT-OPTIONS s_zzequi for w_aux_zzequi .
DATA: w_aux_zzut like t352r-zzut.
SELECT-OPTIONS s_zzut for w_aux_zzut .
DATA: w_aux_zzatentado like t352r-zzatentado.
SELECT-OPTIONS s_zzat35 for w_aux_zzatentado .
DATA: w_aux_zzespejo like t352r-zzespejo.
SELECT-OPTIONS s_zzes36 for w_aux_zzespejo .
selection-screen: end of block b1.

*======================== Event Blocks =============================*
at selection-screen.

start-of-selection.
perform get_data using it_data.

end-of-selection.
perform build_alv using it_data ."t_heading.

*======================== Subroutines ==============================*

*&------------------------------------------------------------------*
*& Form get_data
*&------------------------------------------------------------------*
* Gets the information to be shown in the report.
*-------------------------------------------------------------------*
form get_data using t_data type tp_tbl_data.

SELECT t352r~mandt
t352r~iwerk
t352r~revnr
t352r~revbd
t352r~revbz
t352r~reved
t352r~revez
t352r~revtx
t352r~revab
t352r~pm_objty
t352r~gewrk
t352r~equnr
t352r~pspel
t352r~tplnr
t352r~aufnr
t352r~aenam
t352r~aedat
t352r~ernam
t352r~erdat
t352r~objnr
t352r~revty
t352r~objid
t352r~zzorig
t352r~zzclas
t352r~zzpernr
t352r~zztcon
t352r~zzconsig
t352r~zzrevbd
t352r~zzreved
t352r~zzrevbz
t352r~zzrevez
t352r~zzmed
t352r~zzstat
t352r~zzequi
t352r~zzut
t352r~zzatentado
t352r~zzespejo
INTO CORRESPONDING FIELDS OF TABLE t_data
FROM t352r as t352r
WHERE t352r~iwerk in s_iwerk
AND t352r~revnr in s_revnr
AND t352r~revbd in s_revbd
AND t352r~revbz in s_revbz
AND t352r~reved in s_reved
AND t352r~revez in s_revez
AND t352r~revtx in s_revtx
AND t352r~revab in s_revab
AND t352r~pm_objty in s_pm_o09
AND t352r~gewrk in s_gewrk
AND t352r~equnr in s_equnr
AND t352r~tplnr in s_tplnr
AND t352r~pspel in s_pspel
AND t352r~aufnr in s_aufnr
AND t352r~aenam in s_aenam
AND t352r~aedat in s_aedat
AND t352r~ernam in s_ernam
AND t352r~erdat in s_erdat
AND t352r~objnr in s_objnr
AND t352r~revty in s_revty
AND t352r~objid in s_objid
AND t352r~zzorig in s_zzorig
AND t352r~zzclas in s_zzclas
AND t352r~zzpernr in s_zzpe24
AND t352r~zztcon in s_zztcon
AND t352r~zzconsig in s_zzco26
AND t352r~zzrevbd in s_zzre27
AND t352r~zzreved in s_zzre28
AND t352r~zzrevbz in s_zzre29
AND t352r~zzrevez in s_zzre30
AND t352r~zzmed in s_zzmed
AND t352r~zzstat in s_zzstat
AND t352r~zzequi in s_zzequi
AND t352r~zzut in s_zzut
AND t352r~zzatentado in s_zzat35
AND t352r~zzespejo in s_zzes36
.

endform. " get_data


*&------------------------------------------------------------------*
*& Form build_alv
*&------------------------------------------------------------------*
* Builds and display the ALV Grid.
*-------------------------------------------------------------------*
form build_alv using t_data type tp_tbl_data.

* ALV required data objects.
data: w_title type lvc_title,
w_repid type syrepid,
w_comm type slis_formname,
w_status type slis_formname,
x_layout type slis_layout_alv,
t_event type slis_t_event,
t_fieldcat type slis_t_fieldcat_alv,
t_sort type slis_t_sortinfo_alv.



refresh t_fieldcat.
refresh t_event.
refresh t_sort.
clear x_layout.
clear w_title.

* Field Catalog
perform set_fieldcat2 using:
1 'MANDT' 'MANDT' 'T352R' space space 'Mandante' 'Mandante' 'Mandante' 'Mandante' space space space space space space t_fieldcat ,
2 'IWERK' 'IWERK' 'T352R' space space 'CePl' 'CePl' 'CePl' 'CePl' space space space space space space t_fieldcat ,
3 'REVNR' 'REVNR' 'T352R' space space 'Revisión' 'Revisión' 'Revisión' 'Revisión' space space space space space space t_fieldcat ,
4 'REVBD' 'REVBD' 'T352R' space space 'Fe.Inic.rev' 'Fe.Inic.rev' 'Fe.Inic.rev' 'Fe.Inic.rev' space space space space space space t_fieldcat ,
5 'REVBZ' 'REVBZ' 'T352R' space space 'Hora inic.revis' 'Hora inic.revis' 'Hora inic.revis' 'Hora inic.revis' space space space space space space t_fieldcat ,
6 'REVED' 'REVED' 'T352R' space space 'Fecha fin.revis' 'Fecha fin.revis' 'Fecha fin.revis' 'Fecha fin.revis' space space space space space space t_fieldcat ,
7 'REVEZ' 'REVEZ' 'T352R' space space 'Hora fin revis.' 'Hora fin revis.' 'Hora fin revis.' 'Hora fin revis.' space space space space space space t_fieldcat ,
8 'REVTX' 'REVTX' 'T352R' space space 'Denom.revisión' 'Denom.revisión' 'Denom.revisión' 'Denom.revisión' space space space space space space t_fieldcat ,
9 'REVAB' 'REVAB' 'T352R' space space 'Rev. concluida' 'Rev. concluida' 'Rev. concluida' 'Rev. concluida' space space space space space space t_fieldcat ,
10 'PM_OBJTY' 'PM_OBJTY' 'T352R' space space 'Tipo de objeto' 'Tipo de objeto' 'Tipo de objeto' 'Tipo de objeto' space space space space space space t_fieldcat ,
11 'GEWRK' 'GEWRK' 'T352R' space space 'Pto.tbjo.resp.' 'Pto.tbjo.resp.' 'Pto.tbjo.resp.' 'Pto.tbjo.resp.' space space space space space space t_fieldcat ,
12 'EQUNR' 'EQUNR' 'T352R' space space 'Equipo' 'Equipo' 'Equipo' 'Equipo' space space space space space space t_fieldcat ,
13 'TPLNR' 'TPLNR' 'T352R' space space 'Ubicación técn.' 'Ubicación técn.' 'Ubicación técn.' 'Ubicación técn.' space space space space space space t_fieldcat ,
14 'PSPEL' 'PSPEL' 'T352R' space space 'Elemento PEP' 'Elemento PEP' 'Elemento PEP' 'Elemento PEP' space space space space space space t_fieldcat ,
15 'AUFNR' 'AUFNR' 'T352R' space space 'Grafo' 'Grafo' 'Grafo' 'Grafo' space space space space space space t_fieldcat ,
16 'AENAM' 'AENAM' 'T352R' space space 'Modificado por' 'Modificado por' 'Modificado por' 'Modificado por' space space space space space space t_fieldcat ,
17 'AEDAT' 'AEDAT' 'T352R' space space 'Modificado el' 'Modificado el' 'Modificado el' 'Modificado el' space space space space space space t_fieldcat ,
18 'ERNAM' 'ERNAM' 'T352R' space space 'Creado por' 'Creado por' 'Creado por' 'Creado por' space space space space space space t_fieldcat ,
19 'ERDAT' 'ERDAT' 'T352R' space space ' Creado el' ' Creado el' ' Creado el' ' Creado el' space space space space space space t_fieldcat ,
20 'OBJNR' 'OBJNR' 'T352R' space space 'Nº objeto ' 'Nº objeto ' 'Nº objeto ' 'Nº objeto ' space space space space space space t_fieldcat ,
21 'REVTY' 'REVTY' 'T352R' space space 'Cl.revisión' 'Cl.revisión' 'Cl.revisión' 'Cl.revisión' space space space space space space t_fieldcat ,
22 'OBJID' 'OBJID' 'T352R' space space ' PtoTbjo ' ' PtoTbjo ' ' PtoTbjo ' ' PtoTbjo ' space space space space space space t_fieldcat ,
23 'ZZORIG' 'ZZORIG' 'T352R' space space 'Origen Solicitud' 'Origen Solicitud' 'Origen Solicitud' 'Origen Solicitud' space space space space space space t_fieldcat ,
24 'ZZCLAS' 'ZZCLAS' 'T352R' space space 'Clasificación' 'Clasificación' 'Clasificación' 'Clasificación' space space space space space space t_fieldcat ,
25 'ZZPERNR' 'ZZPERNR' 'T352R' space space ' Nº personal' ' Nº personal' ' Nº personal' ' Nº personal' space space space space space space t_fieldcat ,
26 'ZZTCON' 'ZZTCON' 'T352R' space space 'Tipo Consignación' 'Tipo Consignación' 'Tipo Consignación' 'Tipo Consignación' space space space space space space t_fieldcat ,
27 'ZZCONSIG' 'ZZCONSIG' 'T352R' space space 'Núm.Consignación' 'Núm.Consignación' 'Núm.Consignación' 'Núm.Consignación' space space space space space space t_fieldcat ,
28 'ZZREVBD' 'ZZREVBD' 'T352R' space space 'Fecha Inicio Real' 'Fecha Inicio Real' 'Fecha Inicio Real' 'Fecha Inicio Real' space space space space space space t_fieldcat ,
29 'ZZREVED' 'ZZREVED' 'T352R' space space ' Fecha fin Real Rev.' ' Fecha fin Real Rev.' ' Fecha fin Real Rev.' ' Fecha fin Real Rev.' space space space space space space t_fieldcat ,
30 'ZZREVBZ' 'ZZREVBZ' 'T352R' space space 'Hr.Inicio Real Rev.' 'Hr.Inicio Real Rev.' 'Hr.Inicio Real Rev.' 'Hr.Inicio Real Rev.' space space space space space space t_fieldcat ,
31 'ZZREVEZ' 'ZZREVEZ' 'T352R' space space 'Hr.Fin Real Revisión' 'Hr.Fin Real Revisión' 'Hr.Fin Real Revisión' 'Hr.Fin Real Revisión' space space space space space space t_fieldcat ,
32 'ZZMED' 'ZZMED' 'T352R' space space 'Medida de Seguridad' 'Medida de Seguridad' 'Medida de Seguridad' 'Medida de Seguridad' space space space space space space t_fieldcat ,
33 'ZZSTAT' 'ZZSTAT' 'T352R' space space 'Status Revisión' 'Status Revisión' 'Status Revisión' 'Status Revisión' space space space space space space t_fieldcat ,
34 'ZZEQUI' 'ZZEQUI' 'T352R' space space 'Equipos' 'Equipos' 'Equipos' 'Equipos' space space space space space space t_fieldcat ,
35 'ZZUT' 'ZZUT' 'T352R' space space 'Ubicaciones Técnicas' 'Ubicaciones Técnicas' 'Ubicaciones Técnicas' 'Ubicaciones Técnicas' space space space space space space t_fieldcat ,
36 'ZZATENTADO' 'ZZATENTADO' 'T352R' space space 'Código de Atentado' 'Código de Atentado' 'Código de Atentado' 'Código de Atentado' space space space space space space t_fieldcat ,
37 'ZZESPEJO' 'ZZESPEJO' 'T352R' space space 'Revisión Espejo' 'Revisión Espejo' 'Revisión Espejo' 'Revisión Espejo' space space space space space space t_fieldcat .
* Layout
x_layout-zebra = 'X'.

* Events
perform set_events using t_event.

* GUI Status
w_status = ''.
w_repid = sy-repid.


* User commands
w_comm = 'USER_COMMAND'.

* Displays the ALV grid
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = w_repid
it_fieldcat = t_fieldcat
is_layout = x_layout
it_sort = t_sort
i_callback_pf_status_set = w_status
i_callback_user_command = w_comm
i_save = 'X'
it_events = t_event
i_grid_title = w_title
tables
t_outtab = t_data
exceptions
program_error = 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. " build_alv.

*&------------------------------------------------------------------*
*& Form set_events
*&------------------------------------------------------------------*
* Sets the events for ALV.
* The TOP_OF_PAGE event is alredy being registered in
* the set_top_page_heading subroutine.
*-------------------------------------------------------------------*
form set_events using t_events type slis_t_event.
data: x_event type line of slis_t_event.
endform.

*&------------------------------------------------------------------*
*& Form set_order
*&------------------------------------------------------------------*
* Adds an entry to the order table.
*-------------------------------------------------------------------*
FORM set_order USING p_fieldname p_tabname p_up p_down p_subtot
t_sort TYPE slis_t_sortinfo_alv.

DATA: x_sort TYPE slis_sortinfo_alv.

CLEAR x_sort.
x_sort-fieldname = p_fieldname.
x_sort-tabname = p_tabname.
x_sort-up = p_up.
x_sort-down = p_down.
x_sort-subtot = p_subtot.
APPEND x_sort TO t_sort.


ENDFORM. "set_order

FORM set_fieldcat2 USING
p_colpos p_fieldname p_ref_fieldname p_ref_tabname
p_outputlen p_noout
p_seltext_m p_seltext_l p_seltext_s p_reptext_ddic p_ddictxt
p_hotspot p_showasicon p_checkbox p_edit
p_dosum
t_fieldcat TYPE slis_t_fieldcat_alv.

DATA: wa_fieldcat TYPE slis_fieldcat_alv.

CLEAR wa_fieldcat.

* General settings
wa_fieldcat-fieldname = p_fieldname.
wa_fieldcat-col_pos = p_colpos.
wa_fieldcat-no_out = p_noout.
wa_fieldcat-hotspot = p_hotspot.
wa_fieldcat-checkbox = p_checkbox.
wa_fieldcat-icon = p_showasicon.
wa_fieldcat-do_sum = p_dosum.

*
IF p_ref_tabname IS INITIAL.
wa_fieldcat-rollname = p_ref_fieldname.
ELSE.
wa_fieldcat-ref_tabname = p_ref_tabname.
IF p_ref_fieldname EQ space.
wa_fieldcat-ref_fieldname = wa_fieldcat-fieldname.
ELSE.
wa_fieldcat-ref_fieldname = p_ref_fieldname.
ENDIF.
ENDIF.

* Set output length.
IF NOT p_outputlen IS INITIAL.
wa_fieldcat-outputlen = p_outputlen.
ENDIF.

* Set text headers.
IF NOT p_seltext_m IS INITIAL.
wa_fieldcat-seltext_m = p_seltext_m.
ENDIF.

IF NOT p_seltext_l IS INITIAL.
wa_fieldcat-seltext_l = p_seltext_l.
ENDIF.

IF NOT p_seltext_s IS INITIAL.
wa_fieldcat-seltext_s = p_seltext_s.
ENDIF.

IF NOT p_reptext_ddic IS INITIAL.
wa_fieldcat-reptext_ddic = p_reptext_ddic.
ENDIF.

IF NOT p_ddictxt IS INITIAL.
wa_fieldcat-ddictxt = p_ddictxt.
ENDIF.

* Set as editable or not.
IF NOT p_edit IS INITIAL.
wa_fieldcat-input = 'X'.
wa_fieldcat-edit = 'X'.
ENDIF.

APPEND wa_fieldcat TO t_fieldcat.

ENDFORM. "set_fieldcat2

*======================== Subroutines called by ALV ================*


*&------------------------------------------------------------------*
*& Form user_command
*&------------------------------------------------------------------*
* Called on user_command ALV event.
* Executes custom commands.
*-------------------------------------------------------------------*
form user_command using r_ucomm like sy-ucomm
rs_selfield type slis_selfield.

endform. "user_command
Responder Con Cita