24/02/2010

ALV LIST Hierarquico Utilizando a Classe CL_SALV_HIERSEQ_TABLE


REPORT ZRR_SAMPLE.

*--------------------------------------------------------------------------
* | C.U.S.T.O.M T.Y.P.E.S D.E.F.I.N.I.T.I.O.N
*--------------------------------------------------------------------------

TYPES : BEGIN OF ty_ekko_line,
ebeln TYPE ekko-ebeln,
bukrs TYPE ekko-bukrs,
bstyp TYPE ekko-bstyp,
bsart TYPE ekko-bsart,
lponr TYPE ekko-lponr,
END OF ty_ekko_line.

TYPES : BEGIN OF ty_ekpo_line,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
matnr TYPE ekpo-matnr,
txz01 TYPE ekpo-txz01,
END OF ty_ekpo_line.

*--------------------------------------------------------------------------
* | C.U.S.T.O.M I.N.T.E.R.N.A.L T.A.B.L.E T.Y.P.E.S D.E.F.I.N.I.T.I.O.N
*--------------------------------------------------------------------------

TYPES : ty_ekko_tab TYPE STANDARD TABLE OF ty_ekko_line,
ty_ekpo_tab TYPE STANDARD TABLE OF ty_ekpo_line.

*--------------------------------------------------------------------------
* | V.A.R.I.A.B.L.E.S D.E.C.L.A.R.A.T.I.O.N.S.
*--------------------------------------------------------------------------

DATA: it_hierseq TYPE REF TO cl_salv_hierseq_table,
it_ekko TYPE ty_ekko_tab,
it_ekpo TYPE ty_ekpo_tab,
it_levels TYPE salv_t_hierseq_binding,
wa_levels TYPE salv_s_hierseq_binding.

*--------------------------------------------------------------------------
* | S.T.A.R.T O.F S.E.L.E.C.T.I.O.N
*--------------------------------------------------------------------------

START-OF-SELECTION.

* |-> B.I.N.D I.N.T.E.R.N.A.L T.A.B.L.E.S

SELECT ebeln
bukrs
bstyp
bsart
lponr
INTO TABLE it_ekko FROM ekko.

SELECT ebeln
ebelp
matnr
txz01
INTO TABLE it_ekpo FROM ekpo
FOR ALL ENTRIES IN it_ekko
WHERE ebeln = it_ekko-ebeln.

* |-> D.E.F.I.N.E L.E.V.E.L K.E.Y.S

wa_levels-master = 'EBELN'.
wa_levels-slave = 'EBELN'.

APPEND wa_levels TO it_levels.

* |-> C.R.E.A.T.E A.L.V O.B.J.E.C.T U.S.I.N.G F.A.C.T.O.R.Y M.E.T.H.O.D

cl_salv_hierseq_table=>factory( EXPORTING t_binding_level1_level2 = it_levels
IMPORTING r_hierseq = it_hierseq
CHANGING t_table_level1 = it_ekko t_table_level2 = it_ekpo
).

* |-> D.I.S.P.L.A.Y A.L.V O.U.T.P.U.T L.I.S.T

it_hierseq->display( ).

* |-> U.N.B.I.N.D I.N.T.E.R.N.A.L T.A.B.L.E.S

FREE : it_ekko[],
it_ekpo[].

Nenhum comentário:

Postar um comentário