Nos puedes interesar guardar unos valores en BD con la posibilidad de informar su denominación en función del idioma. Para ello se deberá crear dos tablas y enlazarlas. Como ejemplo pondremos una tabla de colores:
*ESTRUCTURA
TABLA1: ID_COLOR
TABLA2: ID_COLOR, IDIOMA, DESCRIPCIÓN
*VALORES EJEMPLO
TABLA1 TABLA2
1 1, ES, Azul
1, EN, Blue
2 2, CAT, Vermell........
Aquí parte interesantes es asignar la tabla de descripciones (tabla2) a la tabla de valores (tabla1) para que cuando se visualice la tabla de valores (tabla1) el sistema recupere automáticamente las descripciones (accediendo a la tabla2). Para realizar esta parte se debe modificar la tabla de descripciones y insertar la clave:
jueves, abril 14, 2011
ALV Objetos - Añadir botón nuevo
**********************************************************************************
1) Definir capturador para el evento TOOLBAR y USER_COMMAND:
**********************************************************************************
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
CLASS-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.
**********************************************************************************
2) Definir implementación de los eventos (llama a una rutina)
**********************************************************************************
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_toolbar.
PERFORM handle_toolbar USING e_object.
ENDMETHOD. "handle_toolbar
METHOD handle_user_command.
PERFORM user_command USING e_ucomm.
ENDMETHOD. "handle_user_command
ENDCLASS.
**********************************************************************************
3) Definir rutinas: añadir botón y tratar acción del botón
**********************************************************************************
FORM handle_toolbar USING p_object TYPE REF TO cl_alv_event_toolbar_set.
DATA: ls_toolbar TYPE stb_button.
CLEAR ls_toolbar.
MOVE 'PER' TO ls_toolbar-function. "#EC NOTEXT
MOVE icon_display_text TO ls_toolbar-icon.
MOVE 'Passenger Info'(201) TO ls_toolbar-quickinfo.
MOVE 'Passenger Info'(201) TO ls_toolbar-text.
MOVE ' ' TO ls_toolbar-disabled. "#EC NOTEXT
APPEND ls_toolbar TO p_object->mt_toolbar.
ENDFORM. " HANDLE_TOOLBAR
FORM user_command USING p_ucomm TYPE syucomm.
CASE p_ucomm.
WHEN 'PER'.
PERFORM sel_selected_rows_ims.
LEAVE SCREEN.
ENDCASE.
ENDFORM. " USER_COMMAND
**********************************************************************************
4) Registrar Eventos en el PBO
**********************************************************************************
SET HANDLER: lcl_event_receiver=>handle_user_command FOR obj_alv_ims,
lcl_event_receiver=>handle_toolbar FOR obj_alv_ims.
1) Definir capturador para el evento TOOLBAR y USER_COMMAND:
**********************************************************************************
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
CLASS-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.
**********************************************************************************
2) Definir implementación de los eventos (llama a una rutina)
**********************************************************************************
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_toolbar.
PERFORM handle_toolbar USING e_object.
ENDMETHOD. "handle_toolbar
METHOD handle_user_command.
PERFORM user_command USING e_ucomm.
ENDMETHOD. "handle_user_command
ENDCLASS.
**********************************************************************************
3) Definir rutinas: añadir botón y tratar acción del botón
**********************************************************************************
FORM handle_toolbar USING p_object TYPE REF TO cl_alv_event_toolbar_set.
DATA: ls_toolbar TYPE stb_button.
CLEAR ls_toolbar.
MOVE 'PER' TO ls_toolbar-function. "#EC NOTEXT
MOVE icon_display_text TO ls_toolbar-icon.
MOVE 'Passenger Info'(201) TO ls_toolbar-quickinfo.
MOVE 'Passenger Info'(201) TO ls_toolbar-text.
MOVE ' ' TO ls_toolbar-disabled. "#EC NOTEXT
APPEND ls_toolbar TO p_object->mt_toolbar.
ENDFORM. " HANDLE_TOOLBAR
FORM user_command USING p_ucomm TYPE syucomm.
CASE p_ucomm.
WHEN 'PER'.
PERFORM sel_selected_rows_ims.
LEAVE SCREEN.
ENDCASE.
ENDFORM. " USER_COMMAND
**********************************************************************************
4) Registrar Eventos en el PBO
**********************************************************************************
SET HANDLER: lcl_event_receiver=>handle_user_command FOR obj_alv_ims,
lcl_event_receiver=>handle_toolbar FOR obj_alv_ims.
ALV Objetos - Mostrar las opciones de seleccionar y guardar variantes ALV
Se debe informar el parámetro IS_VARIANT del método SET_TABLE_FOR_FIRST_DISPLAY:
MOVE sy-repid TO gs_variant-report.
NOTA: Las disposiciones se guardan en una tabla en la cual el nombre del programa es parte de la clave. Si se trabaja con subscreens y varios listados ALV en el mismo programa, hay la posibilidad de diferenciar las disposiciones informando campo:
gs_variant-handle = 'ID_que_queremos'.
MOVE sy-repid TO gs_variant-report.
NOTA: Las disposiciones se guardan en una tabla en la cual el nombre del programa es parte de la clave. Si se trabaja con subscreens y varios listados ALV en el mismo programa, hay la posibilidad de diferenciar las disposiciones informando campo:
gs_variant-handle = 'ID_que_queremos'.
ALV Objetos - Ocultar barra de herramientas
Se informa una campo de la variable de layout:
po_layout-no_toolbar = 'X'.
po_layout-no_toolbar = 'X'.
ALV Objetos - Redefinir botón stándard
Para redefinir botón standard del la barra de herramientas de un ALV OO:
***********************************************************************************
1) Definir capturador para el evento BEFORE_USER_COMMAND y generar otro evento:
***********************************************************************************
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
handle_before_user_command
FOR EVENT before_user_command OF cl_gui_alv_grid
IMPORTING e_ucomm.
handle_user_command
FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING e_ucomm,
ENDCLASS. "lcl_event_receiver DEFINITION
***********************************************************************************
2) Definir implemetación de los eventos (llama a una rutina)
***********************************************************************************
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_before_user_command.
PERFORM handle_before_user_command USING e_ucomm.
ENDMETHOD. "handle_before_user_command
METHOD handle_user_command.
PERFORM user_command USING e_ucomm.
ENDMETHOD. "handle_user_command
ENDCLASS.
***********************************************************************************
3) Definir rutinas: recuperar el código del botón estándard y llama a otro.
***********************************************************************************
FORM handle_before_user_command USING p_ucomm TYPE syucomm.
CASE p_ucomm .
WHEN '&DETAIL'.
CALL METHOD obj_alv_ims->set_user_command
EXPORTING
i_ucomm = 'SEL_DETAIL_IMS'.
ENDCASE .
ENDFORM. " HANDLE_BEFORE_USER_COMMAND
FORM user_command USING p_ucomm TYPE syucomm.
CASE p_ucomm.
WHEN 'SEL_DETAIL_IMS'.
PERFORM sel_selected_rows_ims.
LEAVE SCREEN.
ENDCASE.
ENDFORM. " USER_COMMAND
***********************************************************************************
4) Registrar Eventos en el PBO
***********************************************************************************
SET HANDLER: lcl_event_receiver=>handle_before_user_command FOR obj_alv_ims.
SET HANDLER: lcl_event_receiver=>handle_user_command FOR obj_alv_ims.
***********************************************************************************
NOTA:
***********************************************************************************
- Para forzar PBO del dynpro LEAVE SCREEN.
***********************************************************************************
1) Definir capturador para el evento BEFORE_USER_COMMAND y generar otro evento:
***********************************************************************************
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
handle_before_user_command
FOR EVENT before_user_command OF cl_gui_alv_grid
IMPORTING e_ucomm.
handle_user_command
FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING e_ucomm,
ENDCLASS. "lcl_event_receiver DEFINITION
***********************************************************************************
2) Definir implemetación de los eventos (llama a una rutina)
***********************************************************************************
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_before_user_command.
PERFORM handle_before_user_command USING e_ucomm.
ENDMETHOD. "handle_before_user_command
METHOD handle_user_command.
PERFORM user_command USING e_ucomm.
ENDMETHOD. "handle_user_command
ENDCLASS.
***********************************************************************************
3) Definir rutinas: recuperar el código del botón estándard y llama a otro.
***********************************************************************************
FORM handle_before_user_command USING p_ucomm TYPE syucomm.
CASE p_ucomm .
WHEN '&DETAIL'.
CALL METHOD obj_alv_ims->set_user_command
EXPORTING
i_ucomm = 'SEL_DETAIL_IMS'.
ENDCASE .
ENDFORM. " HANDLE_BEFORE_USER_COMMAND
FORM user_command USING p_ucomm TYPE syucomm.
CASE p_ucomm.
WHEN 'SEL_DETAIL_IMS'.
PERFORM sel_selected_rows_ims.
LEAVE SCREEN.
ENDCASE.
ENDFORM. " USER_COMMAND
***********************************************************************************
4) Registrar Eventos en el PBO
***********************************************************************************
SET HANDLER: lcl_event_receiver=>handle_before_user_command FOR obj_alv_ims.
SET HANDLER: lcl_event_receiver=>handle_user_command FOR obj_alv_ims.
***********************************************************************************
NOTA:
***********************************************************************************
- Para forzar PBO del dynpro LEAVE SCREEN.
Suscribirse a:
Entradas (Atom)