Buenas tardes Foro.
Quisiera saber si es posible controlar el tamaño de un Alv Usando la clase CL_GUI_ALV_GRID
dentro de la Dynpro, algo así
CALL SCREEN 101 STARTING AT 40 5
ENDING AT 110 13.
Muchas Gracias.
Buenas tardes Foro.
Quisiera saber si es posible controlar el tamaño de un Alv Usando la clase CL_GUI_ALV_GRID
dentro de la Dynpro, algo así
CALL SCREEN 101 STARTING AT 40 5
ENDING AT 110 13.
Muchas Gracias.
Hola,
Se puede controlar pero no de esa manera. Si no que el tamaño lo va a tomar del custom container creado en la dynpro. Te paso un codigo de ejemplo en donde hay dos ALVs en una misma dynpro, y podes cambiar a tu antojo el tamaño de los mismos simplemente modificando el custom container.
REPORT ztest.
TYPE-POOLS: icon.
DATA: ok_code LIKE sy-ucomm.
DATA gs_variant TYPE disvariant.
DATA: gt_fieldcat TYPE lvc_t_fcat.
DATA: gs_layout TYPE lvc_s_layo.
DATA: gs_fieldcat TYPE lvc_s_fcat.
DATA: BEGIN OF gt_sflight OCCURS 0.
INCLUDE STRUCTURE sflight.
DATA: carrname LIKE scarr-carrname,
cell TYPE lvc_t_styl,
END OF gt_sflight.
DATA: BEGIN OF it_sflight OCCURS 0.
INCLUDE STRUCTURE sflight.
DATA: END OF it_sflight.
DATA: BEGIN OF gt_sflight1 OCCURS 0.
INCLUDE STRUCTURE sflight.
DATA: carrname LIKE scarr-carrname,
END OF gt_sflight1,
* g_container TYPE scrfname VALUE 'BCALV_GRID_DEMO_0100_CONT1',
g_container TYPE scrfname VALUE 'CONTEINER1',
g_container2 TYPE scrfname VALUE 'CONTEINER2',
grid1 TYPE REF TO cl_gui_alv_grid,
grid2 TYPE REF TO cl_gui_alv_grid,
g_custom_container TYPE REF TO cl_gui_custom_container,
g_custom_container2 TYPE REF TO cl_gui_custom_container.
CLASS lcl_event_receiver DEFINITION DEFERRED.
DATA: o_event_receiver TYPE REF TO lcl_event_receiver.
*---------------------------------------------------------------------*
* CLASS lcl_event_receiver DEFINITION
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS:
handle_toolbar FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING
e_object e_interactive,
handle_user_command FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING e_ucomm.
ENDCLASS. "lcl_event_receiver DEFINITION
*---------------------------------------------------------------------*
* class lcl_event_receiver implementation
*---------------------------------------------------------------------*
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_toolbar.
* manejador del evento para el evento toolbar
CONSTANTS:
* constantes de botón
c_button_normal TYPE i VALUE 0,
c_menu_and_default_button TYPE i VALUE 1,
c_menu TYPE i VALUE 2,
c_separator TYPE i VALUE 3,
c_radio_button TYPE i VALUE 4,
c_checkbox TYPE i VALUE 5,
c_menu_entry TYPE i VALUE 6.
DATA:
ls_toolbar TYPE stb_button.
* añade un separador
CLEAR ls_toolbar.
MOVE c_separator TO ls_toolbar-butn_type..
APPEND ls_toolbar TO e_object->mt_toolbar.
* append a new button that to the toolbar. use e_object of
* event toolbar.e_object is of type cl_alv_event_toolbar_set.
* this class has one attribute mt_toolbar which is of table type
* ttb_button.
* the structure is stb_button
*******Borrado de Botones Estandar:
DELETE e_object->mt_toolbar WHERE ( function EQ '&MB_SUM'
OR function EQ '&MB_SUBTOT'
OR function EQ '&GRAPH'
OR function EQ '&&SEP07'
OR function EQ '&INFO' ).
********
CLEAR ls_toolbar.
MOVE 'LOG' TO ls_toolbar-function.
MOVE icon_error_protocol TO ls_toolbar-icon.
MOVE 'Log Errores' TO ls_toolbar-quickinfo.
MOVE 'Log' TO ls_toolbar-text.
MOVE ' ' TO ls_toolbar-disabled.
APPEND ls_toolbar TO e_object->mt_toolbar.
ENDMETHOD. "handle_toolbar
METHOD handle_user_command.
* handle own functions defined in the toolbar
CASE e_ucomm.
WHEN 'CHANGE'.
LEAVE TO SCREEN 0.
WHEN 'LOG'.
CALL TRANSACTION 'SM35'.
ENDCASE.
ENDMETHOD. "handle_user_command
ENDCLASS. "lcl_event_receiver IMPLEMENTATION
*---------------------------------------------------------------------*
* MAIN *
*---------------------------------------------------------------------*
START-OF-SELECTION.
DATA: wa_sflight LIKE gt_sflight.
DATA: flag1(1), flag2(1).
DATA: seatsocc LIKE gt_sflight-seatsocc.
DATA: planetype LIKE gt_sflight-planetype.
SELECT * INTO CORRESPONDING FIELDS OF TABLE it_sflight FROM sflight.
LOOP AT it_sflight.
MOVE-CORRESPONDING it_sflight TO gt_sflight.
APPEND gt_sflight.
ENDLOOP.
SORT gt_sflight BY planetype.
* SEATSMAX
*PLANETYPE
LOOP AT gt_sflight INTO wa_sflight.
IF seatsocc NE wa_sflight-seatsocc
AND planetype NE wa_sflight-planetype.
CLEAR wa_sflight-seatsmax.
MOVE '1' TO wa_sflight-seatsmax.
MODIFY gt_sflight FROM wa_sflight.
MOVE: wa_sflight-seatsocc TO seatsocc,
wa_sflight-planetype TO planetype.
ELSEIF seatsocc EQ wa_sflight-seatsocc
AND planetype NE wa_sflight-planetype.
CLEAR wa_sflight-seatsmax.
MOVE '1' TO wa_sflight-seatsmax.
MODIFY gt_sflight FROM wa_sflight.
MOVE: wa_sflight-seatsocc TO seatsocc,
wa_sflight-planetype TO planetype.
ELSEIF seatsocc NE wa_sflight-seatsocc
AND planetype EQ wa_sflight-planetype.
CLEAR wa_sflight-seatsmax.
MOVE '1' TO wa_sflight-seatsmax.
MODIFY gt_sflight FROM wa_sflight.
MOVE: wa_sflight-seatsocc TO seatsocc,
wa_sflight-planetype TO planetype.
ELSE.
MOVE: wa_sflight-seatsocc TO seatsocc,
wa_sflight-planetype TO planetype.
CLEAR wa_sflight-seatsmax.
MOVE '0' TO wa_sflight-seatsmax.
MODIFY gt_sflight FROM wa_sflight.
ENDIF.
ENDLOOP.
CLEAR gs_fieldcat.
gs_fieldcat-fieldname = 'CARRID'.
gs_fieldcat-ref_table = 'SFLIGHT'.
gs_fieldcat-outputlen = '5'.
gs_fieldcat-key = 'X'.
* gs_fieldcat-edit = 'X'.
gs_fieldcat-auto_value = 'X'.
APPEND gs_fieldcat TO gt_fieldcat.
CLEAR gs_fieldcat.
gs_fieldcat-fieldname = 'CARRNAME'.
gs_fieldcat-ref_table = 'SCARR'.
gs_fieldcat-outputlen = '12'.
gs_fieldcat-key = 'X'.
gs_fieldcat-auto_value = 'X'.
APPEND gs_fieldcat TO gt_fieldcat.
CLEAR gs_fieldcat.
gs_fieldcat-fieldname = 'CONNID'.
gs_fieldcat-ref_table = 'SFLIGHT'.
gs_fieldcat-key = 'X'.
* gs_fieldcat-edit = 'X'.
gs_fieldcat-auto_value = 'X'.
APPEND gs_fieldcat TO gt_fieldcat.
CLEAR gs_fieldcat.
gs_fieldcat-fieldname = 'FLDATE'.
gs_fieldcat-ref_table = 'SFLIGHT'.
* gs_fieldcat-edit = 'X'.
gs_fieldcat-key = 'X'.
APPEND gs_fieldcat TO gt_fieldcat.
CLEAR gs_fieldcat.
gs_fieldcat-fieldname = 'SEATSOCC'.
gs_fieldcat-ref_table = 'SFLIGHT'.
* gs_fieldcat-edit = 'X'.
APPEND gs_fieldcat TO gt_fieldcat.
CLEAR gs_fieldcat.
gs_fieldcat-fieldname = 'PLANETYPE'.
gs_fieldcat-ref_table = 'SFLIGHT'.
* gs_fieldcat-edit = 'X'.
APPEND gs_fieldcat TO gt_fieldcat.
CLEAR gs_fieldcat.
gs_fieldcat-fieldname = 'SEATSMAX'.
gs_fieldcat-ref_table = 'SFLIGHT'.
APPEND gs_fieldcat TO gt_fieldcat.
CLEAR gs_fieldcat.
gs_fieldcat-fieldname = 'PAYMENTSUM'.
gs_fieldcat-datatype = 'CURR'.
gs_fieldcat-coltext = text-004.
gs_fieldcat-cfieldname = 'CURRENCY'.
* gs_fieldcat-edit = 'X'.
APPEND gs_fieldcat TO gt_fieldcat.
CLEAR gs_fieldcat.
gs_fieldcat-fieldname = 'PRICE'.
gs_fieldcat-ref_table = 'SFLIGHT'.
gs_fieldcat-cfieldname = 'CURRENCY'.
* gs_fieldcat-edit = 'X'.
APPEND gs_fieldcat TO gt_fieldcat.
CLEAR gs_fieldcat.
gs_fieldcat-fieldname = 'CURRENCY'.
gs_fieldcat-ref_table = 'SFLIGHT'.
* gs_fieldcat-edit = 'X'.
gs_fieldcat-checktable = '!'.
gs_fieldcat-auto_value = 'X'.
APPEND gs_fieldcat TO gt_fieldcat.
gs_variant-report = sy-repid.
* CALL SCREEN 100.
CALL SCREEN 0001.
*---------------------------------------------------------------------*
* MODULE PBO OUTPUT *
*---------------------------------------------------------------------*
MODULE pbo OUTPUT.
PERFORM pbo_output.
ENDMODULE. "pbo OUTPUT
*---------------------------------------------------------------------*
* MODULE PAI INPUT *
*---------------------------------------------------------------------*
MODULE pai INPUT.
PERFORM pai_input.
ENDMODULE. " F4
*&---------------------------------------------------------------------*
*& Form pbo_output
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM pbo_output.
SET PF-STATUS 'MAIN100'.
* SET PF-STATUS 'MAIN0001'.
SET TITLEBAR '001'.
IF g_custom_container IS INITIAL.
IF sy-batch IS INITIAL.
CREATE OBJECT g_custom_container
EXPORTING
container_name = g_container.
ENDIF.
CREATE OBJECT grid1
EXPORTING
i_parent = g_custom_container.
CREATE OBJECT o_event_receiver.
SET HANDLER o_event_receiver->handle_user_command FOR grid1.
SET HANDLER o_event_receiver->handle_toolbar FOR grid1.
gs_layout-stylefname = 'CELL'.
gs_layout-no_toolbar = ' '.
gs_layout-grid_title = 'Facturas Contabilizadas en SAP'.
CALL METHOD grid1->set_table_for_first_display
EXPORTING
i_save = 'A'
is_layout = gs_layout
CHANGING
it_fieldcatalog = gt_fieldcat
it_outtab = gt_sflight[].
CALL METHOD grid1->set_toolbar_interactive.
ENDIF.
IF g_custom_container2 IS INITIAL.
IF sy-batch IS INITIAL.
CREATE OBJECT g_custom_container2
EXPORTING
container_name = g_container2.
ENDIF.
CREATE OBJECT grid2
EXPORTING
i_parent = g_custom_container2.
* CREATE OBJECT o_event_receiver.
SET HANDLER o_event_receiver->handle_user_command FOR grid2.
SET HANDLER o_event_receiver->handle_toolbar FOR grid2.
gs_layout-stylefname = 'CELL'.
gs_layout-grid_title = 'Facturas Anuladas en SAP'.
CALL METHOD grid2->set_table_for_first_display
EXPORTING
i_save = 'A'
is_layout = gs_layout
CHANGING
it_fieldcatalog = gt_fieldcat
it_outtab = gt_sflight[].
CALL METHOD grid2->set_toolbar_interactive.
ENDIF.
ENDFORM. " pbo_output
*&---------------------------------------------------------------------*
*& Form pai_input
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM pai_input.
DATA: l_valid(1) TYPE c.
ok_code = sy-ucomm.
CASE ok_code.
WHEN 'SAVE'.
CALL METHOD grid1->check_changed_data
IMPORTING
e_valid = l_valid.
IF l_valid = 'X'.
MESSAGE i000(0k) WITH text-009.
ELSE.
MESSAGE i000(0k) WITH text-010.
ENDIF.
WHEN 'CHANGE'.
IF grid1->is_ready_for_input( ) = 0.
CALL METHOD grid1->set_ready_for_input
EXPORTING
i_ready_for_input = 1.
ELSE.
CALL METHOD grid1->check_changed_data
IMPORTING
e_valid = l_valid.
IF l_valid = 'X'.
CALL METHOD grid1->set_ready_for_input
EXPORTING
i_ready_for_input = 0.
ENDIF.
ENDIF.
WHEN 'EXIT'.
SET SCREEN 0.
LEAVE SCREEN.
ENDCASE.
CLEAR ok_code.
ENDFORM. " pai_input
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
* SET PF-STATUS 'xxxxxxxx'.
* SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_0100 OUTPUT
Adicionalmente crea la dynpro y dentro de la misma pon este codigo
PROCESS BEFORE OUTPUT.
MODULE status_0100.
MODULE pbo.
*
PROCESS AFTER INPUT.
MODULE pai.
Y por ultimo create dos custom container, tamaño que prefieras, que se llamen CONTEINER1 y CONTEINER2.
Espero que te sirva!
Saludos.