Archivo

Posts Tagged ‘select-option’

Listbox en SELECT-OPTION

Caso: Se desea poner un listobox o campo de selección en un SELECT-OPTION.

Solución: Utilizamos el siguiente código.

REPORT  zprueba_abap.
TYPE-POOLS: vrm .
 
DATA: g_lista   TYPE vrm_values,
      g_name   TYPE vrm_id,
      g_value  LIKE LINE OF g_lista.
 
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS    :   s_lista TYPE c LENGTH 30 AS LISTBOX VISIBLE LENGTH 30.
SELECTION-SCREEN END OF BLOCK b1.
 
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_lista.
  PERFORM armar_listbox.
 
*&---------------------------------------------------------------------*
*&      Form  armar_listbox
*&---------------------------------------------------------------------*
FORM armar_listbox.
  REFRESH g_lista.
  g_name = 'S_LISTA'.
  g_value-key = '1'. g_value-text = 'Santiago'.
  APPEND g_value TO g_lista.
  g_value-key = '2'. g_value-text = 'Viña del Mar'.
  APPEND g_value TO g_lista.
  g_value-key = '3'. g_value-text = 'Valparaíso'.
  APPEND g_value TO g_lista.
  g_value-key = '4'. g_value-text = 'San Felipe'.
  APPEND g_value TO g_lista.
  g_value-key = '5'. g_value-text = 'Con Con'.
  APPEND g_value TO g_lista.
  g_value-key = '6'. g_value-text = 'San Javier'.
  APPEND g_value TO g_lista.
 
  CALL FUNCTION 'VRM_SET_VALUES'
    EXPORTING
      id     = g_name
      values = g_lista.
 
ENDFORM.                    "armar_listbox

Screenshot_1

Anuncios
Categorías:ABAP/4 Etiquetas: , ,

COMMENT en pantalla selección

Caso: se busca mostrar la descripción de un campo en la pantalla de selección.

REPORT zprueba_descripcion.
TABLES kna1.

DATA: gv_kunnr TYPE kna1-kunnr.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
SELECTION-SCREEN BEGIN OF LINE.
SELECT-OPTIONS: s_kunnr FOR kna1-kunnr NO-EXTENSION NO INTERVALS.
SELECTION-SCREEN COMMENT 48(35) gv_name1.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK b1.

AT SELECTION-SCREEN ON s_kunnr.
CLEAR gv_name1.

SELECT SINGLE kunnr name1
INTO (gv_kunnr, gv_name1)
FROM kna1
WHERE kunnr IN s_kunnr.

IF sy-subrc NE 0.
MESSAGE s899(mm) WITH ‘Cliente inexistente’ DISPLAY LIKE ‘E’.
ENDIF.