Thursday, August 8, 2019

At Selection Screen on Block

When we create selection screen begin with block then this block can be handled by this event AT SELECTION SCREEN ON BLOCK. All the block elements are passed from the selection screen to the ABAP. In the following example we have created two blocks and apply this event on the first block. If the event is triggered with error message then the second block gets disabled.

TABLES ekpo.

INITIALIZATION.
  SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
  PARAMETERS p_bsart TYPE ekko-bsart.
  SELECT-OPTIONSs_ebeln FOR ekpo-ebeln,
                  s_ebelp FOR ekpo-ebelp.
  SELECTION-SCREEN END OF BLOCK b1.

  SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME.
  PARAMETERSr_alv RADIOBUTTON GROUP g1 DEFAULT 'X',
              r_cls RADIOBUTTON GROUP g1.
  SELECT-OPTIONS s_date FOR ekpo-abdat.
  SELECTION-SCREEN END OF BLOCK b2.

AT SELECTION-SCREEN ON BLOCK b1.
  IF p_bsart   IS INITIAL AND
     s_ebeln[] IS INITIAL.
    MESSAGE 'Enter PO or Type' TYPE 'E'.
  ENDIF.


At the first block it is mandatory to enter PO or PO type. Without entering this we have executed the program.

The first block is completely enabled whereas the second block is completely disabled.

No comments: