sábado, 3 de mayo de 2014

¿Como creamos pantallas de selección en un ALV?


En este post vamos a ver como se definen los diferente elementos dentro de una pantalla de selección desde el código ABAP.
 
Con el siguiente código definimos un bloque donde podemos meter todos los controles que queramos.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
 
***************************************************************************

SELECTION-SCREEN END OF BLOCK b1.

Salto de linea.

SELECTION-SCREEN SKIP 1.

Definición de radio-button:

PARAMETERS: p_mpd RADIOBUTTON GROUP g1 USER-COMMAND pmpd default 'X'.

PARAMETERS: p_mp RADIOBUTTON GROUP g1.
 


Definicion de CheckBox:

SELECTION-SCREEN:  BEGIN OF BLOCK b3 WITH FRAME TITLE text-003.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(11) text-005.
PARAMETERS : p_avio AS CHECKBOX DEFAULT ' '.
SELECTION-SCREEN COMMENT 21(16) text-032.
PARAMETERS : p_comp AS CHECKBOX DEFAULT ' '.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN:  END OF BLOCK b3.



 

Definición de botones:

SELECTION-SCREEN SKIP 2.
SELECTION-SCREEN PUSHBUTTON 1(50) boton USER-COMMAND selec.
SELECTION-SCREEN SKIP 2.
SELECTION-SCREEN PUSHBUTTON 1(50) boton3 USER-COMMAND carac.
 

 
Para poner el icono y el texto al botón:
 
CONCATENATE icon_history text-008 INTO boton.
 
Definición de entrada de fichero:
 
SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME.
SELECTION-SCREEN SKIP 1.
parameters: p_fichop like dxfields-longpath.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN: END OF BLOCK b1.
 

 
 



Para hacer que nos salga la ventana de selección de fichero podemos hacer lo siguiente:

*-----------------------------------------------------------------------
*     AT SELECTION-SCREEN ON VALUE-REQUEST
*-----------------------------------------------------------------------
* Fichero de entrada
at selection-screen on value-request for p_fichop.
  perform tomar_fichero using 'P' changing p_fichop.

Donde el Form:

*&---------------------------------------------------------------------*
*&      Form  tomar_fichero
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
form tomar_fichero using loc  changing file.

  call function 'F4_DXFILENAME_TOPRECURSION'
   exporting
     i_location_flag       = loc
     i_server              = SPACE
     filemask              = 'Z*.*'
     fileoperation         = 'R'
   importing
     o_path                = file
   exceptions
     rfc_error             = 1
     error_with_gui        = 2
     others                = 3.

  if sy-subrc <> 0.
   clear file.
  endif.
endform.


 
 
Report con Pestañas: Para poder hacer un bloque con varias pestañas.
SELECTION-SCREEN BEGIN OF SCREEN 100 AS SUBSCREEN.
PARAMETERS: p1 TYPE c LENGTH 10,
p2 TYPE c LENGTH 10,
p3 TYPE c LENGTH 10.
SELECTION-SCREEN END OF SCREEN 100.
SELECTION-SCREEN BEGIN OF SCREEN 200 AS SUBSCREEN.
PARAMETERS: q1 TYPE c LENGTH 10,
q2 TYPE c LENGTH 10,
q3 TYPE c LENGTH 10.
SELECTION-SCREEN END OF SCREEN 200.
SELECTION-SCREEN: BEGIN OF TABBED BLOCK mytab FOR 10 LINES,
TAB (20) button1 USER-COMMAND push1 DEFAULT SCREEN 100,
TAB (20) button2 USER-COMMAND push2 DEFAULT SCREEN 200,
END OF BLOCK mytab.
INITIALIZATION.
button1 = 'Selection Screen 1'.
button2 = 'Selection Screen 2'.
 

 
 
Para finalizar un ejemplo completo de una pantalla de selección.
 
************************************************************************
*Definición de pantalla de selección
************************************************************************
SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS:     p_dok LIKE draw-doknr,
                              p_doar LIKE draw-dokar DEFAULT 'Z',
                             p_dotl LIKE draw-doktl DEFAULT '000',
                            p_dovr LIKE draw-dokvr.     
SELECT-OPTIONS s_tplnr FOR viqmel-tplnr.
SELECTION-SCREEN: END OF BLOCK b1.
SELECTION-SCREEN: BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
PARAMETERS:     p_matnr LIKE mara-matnr.
SELECTION-SCREEN: END OF BLOCK b2.
SELECTION-SCREEN: BEGIN OF BLOCK b3 WITH FRAME TITLE text-003.
PARAMETERS: p_vari LIKE ltdx-variant.
SELECTION-SCREEN: END OF BLOCK b3.
SELECTION-SCREEN: BEGIN OF BLOCK b4 WITH FRAME TITLE text-004.
PARAMETERS: p_ptbo AS CHECKBOX DEFAULT ' ',
            p_na AS CHECKBOX DEFAULT ' ',
            p_z  AS CHECKBOX DEFAULT ' '.
SELECTION-SCREEN: END OF BLOCK b4.
* Ejecucion on-line o batch
SELECTION-SCREEN: BEGIN OF BLOCK b5 WITH FRAME TITLE text-005.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: p_online RADIOBUTTON GROUP r1.
SELECTION-SCREEN COMMENT 5(30) text-006.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: p_batch RADIOBUTTON GROUP r1.
SELECTION-SCREEN: COMMENT 5(15) text-007,
                  PUSHBUTTON 25(30) boton USER-COMMAND jobs.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN: END OF BLOCK b5.
 

 
 
En el siguiente post mostraremos como añadir algunos eventos a la pantalla de selección. Cualquier comentario, sugerencia o duda porfavor hacermela llegar.
 
 











 

No hay comentarios:

Publicar un comentario