Sei sulla pagina 1di 6

************************************************************************

* Reporte de Clientes Directos e Indirectos por distribuidoras propias*


* e independientes
*
* Visualizacin en pantalla con opcin de impresin
*
*
*
************************************************************************
********** ------------------------***************
*
TABLAS
*
********** ------------------------***************
REPORT ZSDR_CLI_DIR_IND_DIS.
TABLES:TVKO, TVTW, TSPA, KNA1, KNVP, KNVV.
type-pools: slis.
"ALV Declaracion
********--------------------------------***********
*
Declaracion de los parametros de Seleccion *
********--------------------------------***********
PARAMETERS: Distrib(4)
Canal(2)
Sector(2)
Cliente(10)
Tipo_C(4)
DATA distrbuidoras.

TYPE
TYPE
TYPE
TYPE
TYPE

C
C
C
C
C

MATCHCODE
MATCHCODE
MATCHCODE
MATCHCODE
MATCHCODE

OBJECT
OBJECT
OBJECT
OBJECT
OBJECT

C_VKORG,
Z_AYUDA_CANAL,
Z_AYUDA_SECTOR,
Z_AYUDA_CLIENTE,
Z_AYUDA_TCLIENTE.

SELECTION-SCREEN BEGIN OF BLOCK SEL WITH FRAME TITLE TEXT-001.


********--------------------------------***********
*
Declaracion de la Data
*
********--------------------------------***********
TYPES: BEGIN OF T_KNA1,
KUNNR TYPE KNA1-KUNNR,
NAME1 TYPE KNA1-NAME1,
NAME2 TYPE KNA1-NAME2,
PARVW TYPE KNVP-PARVW,
VKORG TYPE TVKO-VKORG,
VTWEG TYPE KNVP-VTWEG,
SPART TYPE KNVP-SPART,
KDGRP TYPE KNVV-KDGRP,
*VTEXT TYPE TVKO-VTEXT,
END OF T_KNA1.
DATA: TI_KNA1 TYPE STANDARD TABLE OF T_KNA1 INITIAL SIZE 0,
WA_KNA1 TYPE T_KNA1.
*SELECTION-SCREEN END OF BLOCK SEL.
********--------------------------------***********
*
ALV declaracion de data
*
********--------------------------------***********
data: fieldcatalog type slis_t_fieldcat_alv with header line,
gd_tab_group type slis_t_sp_group_alv,
gd_layout
type slis_layout_alv,
gd_repid
like sy-repid,
gt_events
type slis_t_event,
gd_prntparams type slis_print_alv.

********--------------------------------***********
*
Start-of-selection.
*
********--------------------------------***********
SELECTION-SCREEN END OF BLOCK SEL.
START-OF-SELECTION.

END-OF-SELECTION.
perform data_retrieval.
perform build_fieldcatalog.
perform build_layout.
perform build_events.
perform build_print_params.
perform display_alv_report.
********--------------------------------***********
*&
Form BUILD_EVENTS
*
********--------------------------------***********
*
la tabla de eventos
*
********--------------------------------***********
form build_events.
data: ls_event type slis_alv_event.
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0
importing
et_events = gt_events[].
read table gt_events with key name = slis_ev_end_of_page
into ls_event.
if sy-subrc = 0.
move 'END_OF_PAGE' to ls_event-form.
append ls_event to gt_events.
endif.
read table gt_events with key name = slis_ev_end_of_list
into ls_event.
if sy-subrc = 0.
move 'END_OF_LIST' to ls_event-form.
append ls_event to gt_events.
endif.
ENDFORM.
" BUILD_EVENTS
********--------------------------------***********
*&
Form BUILD_LAYOUT
********--------------------------------***********
*
Diseo para crear ALV grid
********--------------------------------***********
form build_layout.
gd_layout-no_input
= 'X'.
gd_layout-colwidth_optimize = 'X'.
gd_layout-totals_text
= 'Totals'(201).
ENDFORM.

" BUILD_LAYOUT

********--------------------------------***********
*&
Form DISPLAY_ALV_REPORT
********--------------------------------***********
*
Presentacin del ALV grid
********--------------------------------***********
FORM display_alv_report.
gd_repid = sy-repid.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program
= gd_repid
i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM
i_callback_user_command = 'USER_COMMAND'
is_layout
it_fieldcat

= gd_layout
= fieldcatalog[]

it_events
is_print
i_save

= gt_events
= gd_prntparams
= 'X'

tables
t_outtab
exceptions
program_error
others
if sy-subrc <> 0.
ENDIF.
ENDFORM.

= TI_KNA1
= 1
= 2.

" DISPLAY_ALV_REPORT

********--------------------------------***********
*&
Form DATA_RETRIEVAL
********--------------------------------***********
* Recuperar los datos del formulario y llenar la tabla interna TI_KNA1*
********--------------------------------***********
FORM data_retrieval.
*************************************************************************
*
*
SELECT KNA1~KUNNR KNA1~NAME1 KNA1~NAME2 KNVP~PARVW KNVV~KDGRP
INTO CORRESPONDING FIELDS OF TABLE TI_KNA1 FROM KNA1
INNER JOIN KNVV ON KNA1~KUNNR = KNVV~KUNNR
INNER JOIN TVTW ON KNVV~VTWEG = TVTW~VTWEG
INNER JOIN TSPA ON KNVV~SPART = TSPA~SPART
INNER JOIN KNVP ON KNA1~KUNNR = KNVP~KUNNR
INNER JOIN TVKO ON KNVP~VKORG = TVKO~VKORG
WHERE KNVV~KUNNR = KNVP~KUNNR AND KNVP~VKORG = KNVV~VKORG
AND KNVP~SPART = KNVV~SPART AND KNVP~VTWEG = KNVV~VTWEG
*AND TVKO~VKORG = KNVV~VKORG.
AND TVKO~VKORG = KNVV~VKORG AND BRSCH ='0001'.
*SELECT * INTO CORRESPONDING FIELDS OF TABLE TI_KNA1 FROM TVKO.
ENDFORM.

" DATA_RETRIEVAL

*
*
*************************************************************************
********--------------------------------***********
* Form TOP-OF-PAGE
*
********--------------------------------***********
*
ALV Encabezado
*
********--------------------------------***********
Form top-of-page.
*ALV Header declarations
data: t_header type slis_t_listheader,
wa_header type slis_listheader,
t_line like wa_header-info,
ld_lines type i,
ld_linesc(10) type c,
distribuidoras(10) type c.
* Titulo
wa_header-typ = 'H'.
wa_header-info = 'Reporte de Clientes Directos e Indirectos por distribuidoras
propias e independientes'.
append wa_header to t_header.
clear wa_header.
* Fecha
wa_header-typ = 'S'.
wa_header-key = 'Fecha: '.
CONCATENATE sy-datum+6(2) '.'
sy-datum+4(2) '.'
sy-datum(4) INTO wa_header-info.
append wa_header to t_header.
clear: wa_header.

"fecha de hoy

* Nombre de Distrbuidora
wa_header-typ = 'S'.
wa_header-key = 'Distribuidora: '.
wa_header-info = Distrib.
append wa_header to t_header.
clear: wa_header.
* Total No. de registros seleccionados
describe table TI_KNA1 lines ld_lines.
ld_linesc = ld_lines.
concatenate 'Total No. de registros seleccionados: ' ld_linesc
into t_line separated by space.
wa_header-typ = 'A'.
wa_header-info = t_line.
append wa_header to t_header.
clear: wa_header, t_line.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = t_header.
ENDFORM.
********--------------------------------***********

*&
Form BUILD_FIELDCATALOG
********--------------------------------***********
*
catlogo de campo para el ALV
********--------------------------------***********
form build_fieldcatalog.

fieldcatalog-fieldname
fieldcatalog-seltext_m
fieldcatalog-col_pos
fieldcatalog-outputlen
fieldcatalog-emphasize
fieldcatalog-key

=
=
=
=
=
=

'KUNNR'.
'Territorio'.
0.
10.
'X'.
'X'.

append fieldcatalog to fieldcatalog.


clear fieldcatalog.
fieldcatalog-fieldname = 'NAME1'.
fieldcatalog-seltext_m = 'Cliente Activos'.
fieldcatalog-col_pos
= 12.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'NAME2'.
fieldcatalog-seltext_m = 'NAME2'.
fieldcatalog-col_pos
= 13.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'PARVW'.
fieldcatalog-seltext_m = 'PARVW'.
fieldcatalog-col_pos
= 10.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'KDGRP'.
fieldcatalog-seltext_m = 'Panaderia'.
fieldcatalog-col_pos
= 14.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
ENDFORM.

" BUILD_FIELDCATALOG

********--------------------------------***********
*&
Form BUILD_PRINT_PARAMS
*
********--------------------------------***********
*Parmetros de configuracin para imprimir los datos
********--------------------------------***********
form build_print_params.
gd_prntparams-reserve_lines = '3'. "Lines reserved for footer
gd_prntparams-no_coverpage = 'X'.
ENDFORM.
" BUILD_PRINT_PARAMS
********--------------------------------***********

*&
Form END_OF_PAGE
*
********--------------------------------***********
form END_OF_PAGE.
data: listwidth type i,
ld_pagepos(10) type c,
ld_page(10)
type c.
write: sy-uline(50).
skip.
write:/40 'Page:', sy-pagno .
ENDFORM.
********--------------------------------***********
*&
Form END_OF_LIST
*
********--------------------------------***********
form END_OF_LIST.
data: listwidth type i,
ld_pagepos(10) type c,
ld_page(10)
type c.
skip.
write:/40 'Page:', sy-pagno .
ENDFORM.

Potrebbero piacerti anche