Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

sy-ucomm (ok_code) is empty - ABAP

Former Member
0 Likes
2,816

Hi Experts!

I don't know why the sy-ucomm system variable is empty. Here is my sample codeSELECTION-SCREEN 100
DATA: so_inv TYPE inv.

SELECTION-SCREEN BEGIN OF SCREEN 100.

SELECTION-SCREEN BEGIN OF BLOCK mdat WITH FRAME TITLE TEXT-001.
PARAMETERS: p_mdc   TYPE mdc,
            p_date TYPE dats.
SELECTION-SCREEN END OF BLOCK mdc.

SELECTION-SCREEN BEGIN OF BLOCK inv WITH FRAME TITLE TEXT-002.
SELECT-OPTIONS: s_inv FOR so_inv.
SELECTION-SCREEN END OF BLOCK inv.

SELECTION-SCREEN END OF SCREEN 100.

START-OF-SELECTION

START-OF-SELECTION.
  PERFORM set_toolbar.
  PERFORM set_status.
  WRITE: 'test'.


FORM set_status.
  SET PF-STATUS 'PF1'.
ENDFORM.

FORM set_toolbar.
  CALL SELECTION-SCREEN 100.

  DATA: ok_code TYPE sy-ucomm.
  CASE ok_code.
    WHEN 'BACK'.
      LEAVE PROGRAM.
    WHEN 'EXIT'.
      LEAVE TO SCREEN 0.
    WHEN 'CANCEL'.
      LEAVE SCREEN.
*    WHEN OTHERS.
*      CALL SELECTION-SCREEN 100.
  ENDCASE.
ENDFORM.

PF-STATUS

Thus, if I debug the program, I see that the variable ok_code is empty, but I don't know why this is the case.Does anyone know what i did wrong?Thanks 😛
1 REPLY 1
Read only

Sandra_Rossi
Active Contributor
0 Likes
1,726

Generally speaking, your logic is wrong, you should do the processing of the function code in the PAI of the screen, not outside. Moreover, for selection screens, you should use sscrfields-ucomm, not sy-ucomm:

TABLES sscrfields.
...

AT SELECTION-SCREEN.
  CASE sscrfields-ucomm.
    ...
  ENDCASE.