Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member

The Problem:

How many times has this happened to you: you’re sitting at your desk, quietly banging away at the keyboard, pumping out simple, elegant ABAP code, when you user sends you an e-mail saying “and oh, by the way, those two radio-buttons on the new screen – both should be de-selected.” The request, although unusual, is reasonable. Users must be forced to make decision about which option to choose. There should be no default button selected.

Never? Well, OK, it doesn’t happen very often, but I got a request like this a while ago, and it turned out not to be so simple.

INITIALizing both of them to blank didn’t work. The first radio-button was still selected.

I tried using three radio-buttons, selecting and hiding the first one. Still no luck – the first one was still selected.

Finally, I searched SCN, and found a few discussions about this, suggesting the same things that I had tried but found that didn’t work.

What to do?

The Solution:

This is the code that I came up with:

REPORT ztest.

DATAold_no,
      old_yes
.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN POSITION 1.
SELECTION-SCREEN COMMENT 1(21) text-001.           “ Pick one

SELECTION-SCREEN POSITION 23.
PARAMETERS: p_no AS CHECKBOX USER-COMMAND ucom1.
SELECTION-SCREEN COMMENT 25(2) text-002.           “ Yes

SELECTION-SCREEN POSITION 30.
PARAMETERS  p_yes AS CHECKBOX USER-COMMAND ucom2.
SELECTION-SCREEN COMMENT 32(3) text-003.           “ No

SELECTION-SCREEN END   OF LINE.

AT SELECTION-SCREEN.

     
IF sy-ucomm = 'UCOM1'.
          
IF p_no IS INITIAL.
               
IF old_no IS INITIAL.
                     p_yes  
= 'X'.
                     old_yes
= 'X'.
                     old_no 
= ' '.
               
ELSE.
                     p_no 
= 'X'.
                     p_yes
= ' '.
               
ENDIF.
          
ELSE.
                p_yes  
= ' '.
                old_yes
= ' '.
                old_no 
= 'X'.
          
ENDIF.
     
ELSEIF sy-ucomm = 'UCOM2'.
          
IF p_yes IS INITIAL.
               
IF old_yes IS INITIAL.
                     p_no   
= 'X'.
                     old_no 
= 'X'.
                     old_yes
= ' '.
               
ELSE.
                     p_yes
= 'X'.
                     p_no 
= ' '.
               
ENDIF.
          
ELSE.
               p_no   
= ' '.
               old_no 
= ' '.
               old_yes
= 'X'.
          
ENDIF.
     
ENDIF
.

A couple of caveats:

The code was developed for a module pool screen; this is a report.

This code can be modified to handle multiple check-boxes.

8 Comments