Você está na página 1de 7

Docking Container in ALV

*&---------------------------------------------------------------------*
*& REPORT ZCLASS_DOC
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT

ZCLASS_DOC.

TYPES: BEGIN OF TY_VBRK,


VBELN TYPE VBRK-VBELN,
FKTYP TYPE VBRK-FKTYP,
VBTYP TYPE VBRK-VBTYP,
VKORG TYPE VBRK-VKORG,
VTWEG TYPE VBRK-VTWEG,
KNUMV TYPE VBRK-KNUMV,
END OF TY_VBRK.
DATA IT_VBRK TYPE TABLE OF TY_VBRK.
DATA WA_VBRK TYPE TY_VBRK.
DATA: IT_FCAT TYPE LVC_T_FCAT,
WA_FCAT TYPE LVC_S_FCAT.
DATA: IT_FCAT1 TYPE LVC_T_FCAT,
WA_FCAT1 TYPE LVC_S_FCAT.
PARAMETERS P_VBELN TYPE VBRK-VBELN.
DATA:O_DOCK TYPE REF TO CL_GUI_DOCKING_CONTAINER.
CREATE OBJECT O_DOCK
EXPORTING
*
PARENT
REPID
DYNNR
SIDE
EXTENSION
*
STYLE
*
LIFETIME
*
CAPTION
*
METRIC
*
RATIO
*
NO_AUTODEF_PROGID_DYNNR
*
NAME

=
=
=
=
=

SY-REPID
'2000'
O_DOCK->DOCK_AT_LEFT
1500
=
= LIFETIME_DEFAULT
=
= 0
=
=
=

*
*
*
*
*
*
*

EXCEPTIONS
CNTL_ERROR
= 1
CNTL_SYSTEM_ERROR
= 2
CREATE_ERROR
= 3
LIFETIME_ERROR
= 4
LIFETIME_DYNPRO_DYNPRO_LINK = 5
OTHERS
= 6
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
DATA:O_SPLIT TYPE REF TO CL_GUI_SPLITTER_CONTAINER.
CREATE OBJECT O_SPLIT
EXPORTING
PARENT
ROWS
COLUMNS

= O_DOCK
= 1
= 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.
DATA:O_CUST TYPE REF TO CL_GUI_CONTAINER.
CALL METHOD O_SPLIT->GET_CONTAINER
EXPORTING
ROW
= 1
COLUMN
= 1
RECEIVING
CONTAINER = O_CUST.
DATA:O_CUST1 TYPE REF TO CL_GUI_CONTAINER.
CALL METHOD O_SPLIT->GET_CONTAINER
EXPORTING
ROW
= 1
COLUMN
= 2
RECEIVING
CONTAINER = O_CUST1.
CLASS LCL_EVENT_ALV DEFINITION.
PUBLIC SECTION.
METHODS:DB_CLICK FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID IMPORTING E_ROW

.
ENDCLASS.

CLASS LCL_EVENT_ALV IMPLEMENTATION.

METHOD DB_CLICK.
DATA IT_VBRK1 TYPE TABLE OF VBRK.
CLEAR wa_vbrk.
READ TABLE IT_VBRK INTO WA_VBRK INDEX E_ROW-INDEX.
CLEAR IT_VBRK1.
SELECT * FROM VBRK INTO CORRESPONDING FIELDS OF TABLE IT_VBRK1 WHERE VB
ELN = WA_VBRK-VBELN.
PERFORM FIELDCAT1 ."USING 'VBELN' 'VBRK' 1 20 'BILLING NUMBER' .
*
*

PERFORM FIELDCAT1 USING 'VBELN' 'VKORG' 2 20 'BILLING NUMBER'.


DATA:O_GRID1 TYPE REF TO CL_GUI_ALV_GRID.
CLEAR IT_MARA.
CREATE OBJECT O_GRID1
EXPORTING
I_PARENT

= O_CUST1

*
*

.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

CALL METHOD O_GRID1->SET_TABLE_FOR_FIRST_DISPLAY


CHANGING
IT_OUTTAB
IT_FIELDCATALOG

*
*

= IT_VBRK1
= IT_FCAT1

.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

ENDMETHOD.

ENDCLASS.
START-OF-SELECTION.

SELECT * FROM VBRK INTO CORRESPONDING FIELDS OF TABLE IT_VBRK." WHERE VBELN =
P_VBELN.
IF SY-SUBRC = 0.

PERFORM FIELDCAT USING 'VBELN' 'VBRK' 1 20 'BILLING NUMBER' .


PERFORM FIELDCAT USING 'VKORG' 'VBRK' 2 20 'DIST CHANNEL' .
DATA:O_GRID TYPE REF TO CL_GUI_ALV_GRID.
CREATE OBJECT O_GRID
EXPORTING
I_PARENT

= O_CUST

.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL METHOD O_GRID->SET_TABLE_FOR_FIRST_DISPLAY
CHANGING
IT_OUTTAB
IT_FIELDCATALOG

= IT_VBRK
= IT_FCAT

.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

ENDIF.
DATA: O_EVENT TYPE REF TO LCL_EVENT_ALV.
CREATE OBJECT O_EVENT.
SET HANDLER O_EVENT->DB_CLICK FOR O_GRID.
CALL SCREEN 2000.
*&---------------------------------------------------------------------*
*&
FORM FIELDCAT
*&---------------------------------------------------------------------*
*
TEXT
*----------------------------------------------------------------------*
*
-->P_0292
TEXT
*
-->P_0293
TEXT
*
-->P_1
TEXT
*
-->P_20
TEXT
*
-->P_0296
TEXT
*----------------------------------------------------------------------*
FORM FIELDCAT USING &1 &2 &3 &4 &5.
WA_FCAT-FIELDNAME
WA_FCAT-TABNAME =
WA_FCAT-COL_POS =
WA_FCAT-OUTPUTLEN
WA_FCAT-SCRTEXT_M

= &1 .
&2 .
&3.
= &4.
= &5 .

APPEND WA_FCAT TO IT_FCAT .


CLEAR WA_FCAT.
*WA_FCAT-FIELDNAME = 'VBELN' .
* WA_FCAT-TABNAME = 'VBRK' .
* WA_FCAT-COL_POS = 1.
* WA_FCAT-OUTPUTLEN = '20'.
* WA_FCAT-SCRTEXT_M = 'BILLING NUM' .
*
* APPEND WA_FCAT TO IT_FCAT .
* CLEAR WA_FCAT.
*
* WA_FCAT-FIELDNAME = 'VKORG' .
* WA_FCAT-TABNAME = 'VBRK' .
* WA_FCAT-COL_POS = 2.
* WA_FCAT-OUTPUTLEN = '20'.
* WA_FCAT-SCRTEXT_M = 'DIST CHANNEL' .
*
* APPEND WA_FCAT TO IT_FCAT .
* CLEAR WA_FCAT.

ENDFORM.
" FIELDCAT
*&---------------------------------------------------------------------*

*&
FORM FIELDCAT1
*&---------------------------------------------------------------------*
*
TEXT
*----------------------------------------------------------------------*
*
-->P_0377
TEXT
*
-->P_0378
TEXT
*
-->P_1
TEXT
*
-->P_20
TEXT
*
-->P_0381
TEXT
*----------------------------------------------------------------------*
FORM FIELDCAT1 ."USING &1 &2 &3 &4 &5.
* WA_FCAT1-FIELDNAME = &1 .
* WA_FCAT1-TABNAME = &2 .
* WA_FCAT1-COL_POS = &3.
* WA_FCAT1-OUTPUTLEN = &4.
* WA_FCAT1-SCRTEXT_M = &5 .
*
* APPEND WA_FCAT1 TO IT_FCAT1 .
* CLEAR WA_FCAT1.
CLEAR IT_FCAT1.
WA_FCAT1-FIELDNAME = 'VBELN' .
WA_FCAT1-TABNAME = 'VBRK' .
WA_FCAT1-COL_POS = 1.
WA_FCAT1-OUTPUTLEN = '20'.
WA_FCAT1-SCRTEXT_M = 'BILLING NUMBER' .
APPEND WA_FCAT1 TO IT_FCAT1 .
CLEAR WA_FCAT1.
WA_FCAT1-FIELDNAME = 'KNUMV' .
WA_FCAT1-TABNAME = 'VBRK' .
WA_FCAT1-COL_POS = 2.
WA_FCAT1-OUTPUTLEN = '20'.
WA_FCAT1-SCRTEXT_M = 'DOC CONDITION' .
APPEND WA_FCAT1 TO IT_FCAT1 .
CLEAR WA_FCAT1.
WA_FCAT1-FIELDNAME
WA_FCAT1-TABNAME =
WA_FCAT1-COL_POS =
WA_FCAT1-OUTPUTLEN
WA_FCAT1-SCRTEXT_M

= 'VTWEG' .
'VBRK' .
3.
= '20'.
= 'DIST CHANNEL' .

APPEND WA_FCAT1 TO IT_FCAT1 .


CLEAR WA_FCAT1.
ENDFORM.
" FIELDCAT1
*&---------------------------------------------------------------------*

*&
Module STATUS_2000 OUTPUT
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
MODULE STATUS_2000 OUTPUT.
SET PF-STATUS 'ZSTATUS'.
* SET TITLEBAR 'xxx'.
IF SY-UCOMM = 'BACK'.
LEAVE PROGRAM.
ENDIF.
ENDMODULE.
" STATUS_2000 OUTPUT