* Opa pessoal, hoje vou mostrar pra vocês como dividir uma tela em
* varios containers e trabalhar com ele de forma separadas, o legal é que
* está tudo na mesma tela, a mágica disso é CL_GUI_SPLITTER_CONTAINER,
* Esse programa que estou usando como exemplo terá continuidade, onde
* a idéia final é fazer que cada container, conforme as ações do user,
* se comuniquem, nesse post estarei mostrando como dividir a tela e
* referenciar duas dessas divisões, vamo que aqui aprendemos executando.
* No proximo Post colocarei ação em cada container, e no terceiro post
* será surpresa ( será surpresa porque eu nunca fiz, será surpresa pra mim
* também, rsrs .... Espero que funcione )
*&---------------------------------------------------------------------*
REPORT zcl_gui_splitter_container.
*Tipos
*&---------------------------------------------------------------------*
TYPES :
BEGIN OF ty_spfli,
carrid TYPE scarr-carrid,
carrname TYPE scarr-carrname,
connid TYPE spfli-connid,
cityfrom TYPE spfli-cityfrom,
cityto TYPE spfli-cityto,
END OF ty_spfli
.
* Tabelas internas
*&---------------------------------------------------------------------*
DATA :
t_spfli TYPE TABLE OF ty_spfli,
t_fcat_spfli TYPE TABLE OF lvc_s_fcat,
t_sflight TYPE TABLE OF sflight,
t_fcat_sflight TYPE TABLE OF lvc_s_fcat.
* Objetos
*&---------------------------------------------------------------------*
DATA :
o_docking TYPE REF TO cl_gui_docking_container,
o_splitter TYPE REF TO cl_gui_splitter_container
.
DATA :
o_container_spfli TYPE REF TO cl_gui_container,
o_container_sflight TYPE REF TO cl_gui_container,
o_alv_spfli TYPE REF TO cl_gui_alv_grid,
o_alv_sflight TYPE REF TO cl_gui_alv_grid
.
* Inicio do processo
START-OF-SELECTION.
PERFORM f_selects.
CALL SCREEN 9001.
* varios containers e trabalhar com ele de forma separadas, o legal é que
* está tudo na mesma tela, a mágica disso é CL_GUI_SPLITTER_CONTAINER,
* Esse programa que estou usando como exemplo terá continuidade, onde
* a idéia final é fazer que cada container, conforme as ações do user,
* se comuniquem, nesse post estarei mostrando como dividir a tela e
* referenciar duas dessas divisões, vamo que aqui aprendemos executando.
* No proximo Post colocarei ação em cada container, e no terceiro post
* será surpresa ( será surpresa porque eu nunca fiz, será surpresa pra mim
* também, rsrs .... Espero que funcione )
*&---------------------------------------------------------------------*
REPORT zcl_gui_splitter_container.
*Tipos
*&---------------------------------------------------------------------*
TYPES :
BEGIN OF ty_spfli,
carrid TYPE scarr-carrid,
carrname TYPE scarr-carrname,
connid TYPE spfli-connid,
cityfrom TYPE spfli-cityfrom,
cityto TYPE spfli-cityto,
END OF ty_spfli
.
* Tabelas internas
*&---------------------------------------------------------------------*
DATA :
t_spfli TYPE TABLE OF ty_spfli,
t_fcat_spfli TYPE TABLE OF lvc_s_fcat,
t_sflight TYPE TABLE OF sflight,
t_fcat_sflight TYPE TABLE OF lvc_s_fcat.
* Objetos
*&---------------------------------------------------------------------*
DATA :
o_docking TYPE REF TO cl_gui_docking_container,
o_splitter TYPE REF TO cl_gui_splitter_container
.
DATA :
o_container_spfli TYPE REF TO cl_gui_container,
o_container_sflight TYPE REF TO cl_gui_container,
o_alv_spfli TYPE REF TO cl_gui_alv_grid,
o_alv_sflight TYPE REF TO cl_gui_alv_grid
.
* Inicio do processo
START-OF-SELECTION.
PERFORM f_selects.
CALL SCREEN 9001.
* Modules da tela 9001 acima
*&---------------------------------------------------------------------*
*PROCESS BEFORE OUTPUT.
* MODULE status_9001.
* MODULE inicialization_9001.
*
*PROCESS AFTER INPUT.
*MODULE user_command_9001 AT EXIT-COMMAND.
** MODULE USER_COMMAND_9001.
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Module STATUS_9001 OUTPUT
*&---------------------------------------------------------------------*
MODULE status_9001 OUTPUT.
SET PF-STATUS 'ST_9001'.
ENDMODULE. " STATUS_9001 OUTPUT
*&---------------------------------------------------------------------*
*& Module INICIALIZATION_9001 OUTPUT
*&---------------------------------------------------------------------*
MODULE inicialization_9001 OUTPUT.
IF o_docking IS NOT BOUND.
* Criação de do Objeto docking que vai a tela chamada como referencia.
CREATE OBJECT o_docking
EXPORTING
* parent = " Parent container
repid = sy-repid
" Report to Which This Docking Control is Linked
dynnr = sy-dynnr
" Screen to Which This Docking Control is Linked
extension = 9999 " Control Extension
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
OTHERS = 6
.
* Aqui está o segredo, esse objeto usa o Docking criado acima como referencia
* e já divide o mesmo em duas linhas e duas colunas ( 4 partições ).
BREAK-POINT.
*&---------------------------------------------------------------------*
CREATE OBJECT o_splitter
EXPORTING
* link_dynnr = " Screen Number
* link_repid = " Report Name
* shellstyle = " Window Style
* left = " Left-aligned
* top = " top
* width = " NPlWidth
* height = " Hght
* metric = CNTL_METRIC_DYNPRO " Metric
* align = 15 " Alignment
parent = o_docking " Parent Container
rows = 2 " Number of Rows to be displayed
columns = 2 " Number of Columns to be Displayed
* no_autodef_progid_dynnr = " Don't Autodefined Progid and Dynnr?
* name = " Name
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3
.
ENDIF.
* Definição das medidas dos containers
PERFORM f_define_container_extension
* Row column Height Width
USING '1' '1' '70' '40'.
* Eu tentei criar esses processo de forma generica porque existem varias
* partições e todos tem o processo similar.
*&---------------------------------------------------------------------*
* Container Header ( 1,1 )
*&---------------------------------------------------------------------*
PERFORM f_create_container
* Row Column Container
USING '1' '1' o_container_spfli.
PERFORM f_define_container_header.
*&---------------------------------------------------------------------*
* Container Item ( 1,2 )
*&---------------------------------------------------------------------*
PERFORM f_create_container
* Row Column Container
USING '1' '2' o_container_sflight.
PERFORM f_define_container_item.
ENDMODULE. " INICIALIZATION_9001 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_9001 INPUT
*&---------------------------------------------------------------------*
MODULE user_command_9001 INPUT.
CASE sy-ucomm.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
WHEN 'CANCEL' OR 'EXIT'.
LEAVE PROGRAM.
WHEN OTHERS.
ENDCASE.
ENDMODULE. " USER_COMMAND_9001 INPUT
*&---------------------------------------------------------------------*
*& Form F_CREATE_CONTAINER
*&---------------------------------------------------------------------*
FORM f_create_container USING row TYPE i
col TYPE i
container TYPE REF TO cl_gui_container.
* Aqui é feito a criação do container com referencia a uma das partições.
o_splitter->get_container(
EXPORTING
row = row
column = col
RECEIVING
container = container
).
ENDFORM. " F_CREATE_CONTAINER
*&---------------------------------------------------------------------*
*& Form F_DEFINE_CONTAINER_EXTENSION
*&---------------------------------------------------------------------*
FORM f_define_container_extension USING row TYPE i
column TYPE i
height TYPE i
width TYPE i.
* Altura
IF row IS NOT INITIAL
AND height IS NOT INITIAL.
o_splitter->set_row_height(
EXPORTING
id = row
height = height
).
ENDIF.
* Largura
IF column IS NOT INITIAL
AND width IS NOT INITIAL.
o_splitter->set_column_width(
EXPORTING
id = column
width = width
).
ENDIF.
ENDFORM. " F_DEFINE_CONTAINER_EXTENSION
*&---------------------------------------------------------------------*
*& Form F_DEFINE_CONTAINER_HEADER
*&---------------------------------------------------------------------*
FORM f_define_container_header .
DATA:
lst_layout TYPE lvc_s_layo.
IF o_docking IS BOUND
AND o_alv_spfli IS NOT BOUND.
* Cria o ALV OO
CREATE OBJECT o_alv_spfli
EXPORTING
i_parent = o_container_spfli " Parent Container
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
OTHERS = 5.
PERFORM f_fieldcat
TABLES t_fcat_spfli
USING : 'CARRID' 'T_SPFLI' 'CARRID' 'SCARR',
'CARRNAME' 'T_SPFLI' 'CARRNAME' 'SCARR',
'CONNID' 'T_SPFLI' 'CONNID' 'SPFLI',
'CITYFROM' 'T_SPFLI' 'CITYFROM' 'SPFLI',
'CITYTO' 'T_SPFLI' 'CITYTO' 'SPFLI'.
lst_layout-zebra = 'X'.
lst_layout-cwidth_opt = 'X'.
* Exibe o ALV OO
o_alv_spfli->set_table_for_first_display(
EXPORTING
is_layout = lst_layout " Layout
CHANGING
it_outtab = t_spfli " Output Table
it_fieldcatalog = t_fcat_spfli " Field Catalog
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4
).
ELSE.
* Atualiza o ALV OO
o_alv_spfli->refresh_table_display(
EXCEPTIONS
finished = 1
OTHERS = 2
).
ENDIF.
ENDFORM. " F_DEFINE_CONTAINER_HEADER
*&---------------------------------------------------------------------*
*& Form F_SELECTS
*&---------------------------------------------------------------------*
FORM f_selects .
* Seleção para da alv Principal.
SELECT a~carrid a~carrname
b~connid b~cityfrom b~cityto
INTO TABLE t_spfli
FROM scarr AS a
INNER JOIN spfli AS b
ON a~carrid = b~carrid.
ENDFORM. " F_SELECTS
*&---------------------------------------------------------------------*
*& Form F_FIELDCAT
*&---------------------------------------------------------------------*
FORM f_fieldcat TABLES fieldcat
USING fieldname tabname ref_field ref_table .
* Criação do Fieldcat
DATA :
s_fcat TYPE lvc_s_fcat.
s_fcat-fieldname = fieldname.
s_fcat-tabname = tabname.
s_fcat-ref_field = ref_field.
s_fcat-ref_table = ref_table.
APPEND s_fcat TO fieldcat.
ENDFORM. " F_FIELDCAT
*&---------------------------------------------------------------------*
*& Form F_DEFINE_CONTAINER_ITEM
*&---------------------------------------------------------------------*
FORM f_define_container_item .
DATA:
lst_layout TYPE lvc_s_layo.
IF o_docking IS BOUND
AND o_alv_sflight IS NOT BOUND.
CREATE OBJECT o_alv_sflight
EXPORTING
i_parent = o_container_sflight " Parent Container
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
OTHERS = 5.
PERFORM f_fieldcat
TABLES t_fcat_sflight
USING : 'CARRID' 'T_SFLIGHT' 'CARRID' 'SFLIGHT',
'CONNID' 'T_SFLIGHT' 'CONNID' 'SFLIGHT',
'FLDATE' 'T_SFLIGHT' 'FLDATE' 'SFLIGHT',
'PRICE' 'T_SFLIGHT' 'PRICE' 'SFLIGHT',
'CURRENCY' 'T_SFLIGHT' 'CURRENCY' 'SFLIGHT',
'PLANETYPE' 'T_SFLIGHT' 'PLANETYPE' 'SFLIGHT',
'PAYMENTSUM' 'T_SFLIGHT' 'PAYMENTSUM' 'SFLIGHT'
.
lst_layout-zebra = 'X'.
lst_layout-cwidth_opt = 'X'.
o_alv_sflight->set_table_for_first_display(
EXPORTING
is_layout = lst_layout " Layout
CHANGING
it_outtab = t_sflight " Output Table
it_fieldcatalog = t_fcat_sflight " Field Catalog
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4
).
ELSE.
o_alv_sflight->refresh_table_display(
EXCEPTIONS
finished = 1
OTHERS = 2
).
ENDIF.
ENDFORM. " F_DEFINE_CONTAINER_ITEM