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

Regarding Radio button position

Former Member
0 Likes
1,666

Hi All,

I have a requirement in which i have 2 radio buttons and 1 push button and i have declared these three like this

PARAMETERS: r1 RADIOBUTTON GROUP g1,

r2 RADIOBUTTON GROUP g1.

SELECTION-SCREEN: BEGIN OF LINE.

SELECTION-SCREEN: PUSHBUTTON 30(30) pb01 USER-COMMAND onli

VISIBLE LENGTH 15.

SELECTION-SCREEN: END OF LINE.

If i select the first radio button and click on the push button ztable should be updated. i have written code for this but 2nd time when user clicks on the push button with out changing the radio button position, a pop up message should be displayed like 'Nothing has been changedu2019.

Please suggest me in this issue.

Thanks in advance.

Regards,

Samatha

Hi All,

I have a requirement in which i have 2 radio buttons and 1 push button and i have declared these three like this

PARAMETERS: r1 RADIOBUTTON GROUP g1,

r2 RADIOBUTTON GROUP g1.

SELECTION-SCREEN: BEGIN OF LINE.

SELECTION-SCREEN: PUSHBUTTON 30(30) pb01 USER-COMMAND onli

VISIBLE LENGTH 15.

SELECTION-SCREEN: END OF LINE.

If i select the first radio button and click on the push button ztable should be updated. i have written code for this but 2nd time when user clicks on the push button with out changing the radio button position, a pop up message should be displayed like 'Nothing has been changedu2019.

Please suggest me in this issue.

Thanks in advance.

Regards,

Samatha

17 REPLIES 17
Read only

Former Member
0 Likes
1,630

Example


SELECTION-SCREEN : BEGIN OF BLOCK rd1 WITH FRAME TITLE text-007.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: r6 RADIOBUTTON GROUP red3 .
SELECTION-SCREEN COMMENT 5(20) text-011.            
PARAMETERS: r7 RADIOBUTTON GROUP red3.
SELECTION-SCREEN COMMENT 30(16) text-012 .           
PARAMETERS: r3 RADIOBUTTON GROUP red3.           
SELECTION-SCREEN COMMENT 51(17) text-003.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN SKIP.


SELECTION-SCREEN : END OF BLOCK rd1.


Read only

Former Member
0 Likes
1,630

Hi!

AT SELECTION-SCREEN OUTPUT.

LOOP AT SCREEN.

MODIFY SCREEN.

ENDLOOP.

use your logic here.

Read only

0 Likes
1,630

Hi,

Declare an integer field and update it as '1' when the user clicks the push button for the first time.

And in the logic before updating in 'Z' table check this flag, if its value is '1' then display error message else proceed further.

Taj..

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,630

Hello Samatha,

a pop up message should be displayed like 'Nothing has been changedu2019.

May be if you can share with us where this message is being generated by the code it will be better to analyse ...

BR,

Suhas

Read only

Former Member
0 Likes
1,630

Hi Samantha,

Grand Welcome to SDN.

Lets say you have itab.

declare jtab like itab

now move itab contents to jtab.

data : first type c.
if first is initial. 
jtab[] = itab[]. " This happens only one time
first = 'X'.
endif.
if r1 = 'X'.
if sy-ucomm = 'PUSH'.
if not itab[] = jtab[].
" update the database.
else.
" Pop a message no data has been changed.
endif.
ENDIF.
ENDIF.

Cheerz

Ram

Read only

Former Member
0 Likes
1,630

Hello Samatha,

try this..

TABLES sscrfields.

PARAMETERS: r1 RADIOBUTTON GROUP g1 USER-COMMAND dumm,
r2 RADIOBUTTON GROUP g1.
SELECTION-SCREEN: BEGIN OF LINE.
SELECTION-SCREEN: PUSHBUTTON 30(30) pb01 USER-COMMAND onli
VISIBLE LENGTH 15.
SELECTION-SCREEN: END OF LINE.

DATA: rb_chgd TYPE c LENGTH 1 VALUE 'X',
      l_ucomm TYPE sscrfields-ucomm.

AT SELECTION-SCREEN OUTPUT.
  IF l_ucomm <> 'DUMM'.
    CLEAR rb_chgd.
  ENDIF.


AT SELECTION-SCREEN.
  l_ucomm = sscrfields-ucomm.
  CASE l_ucomm.
    WHEN 'DUMM'.
      rb_chgd = 'X'.
    WHEN 'ONLI'.
      IF rb_chgd <> space.
        MESSAGE 'Perform Action' TYPE 'I'.
*        your code here..
      ELSE.
        MESSAGE 'Nothing has changed' TYPE 'I'.
      ENDIF.
  ENDCASE.

Read only

0 Likes
1,630

Hi Arun,

Thanks for the reply.

I have tried with the code you have provided. But 1st time when we select the 1st radio button the table should be update.2nd time if we don't change the position to 2nd radio button means still we are in the 1st radio button only that time the pop up should display an information message.

Regards,

Samatha

Read only

0 Likes
1,630

Nice catch Samantha,

Here is my answer..

TABLES sscrfields.

PARAMETERS: r1 RADIOBUTTON GROUP g1 USER-COMMAND dumm,
r2 RADIOBUTTON GROUP g1.
SELECTION-SCREEN: BEGIN OF LINE.
SELECTION-SCREEN: PUSHBUTTON 30(30) pb01 USER-COMMAND onli
VISIBLE LENGTH 15.
SELECTION-SCREEN: END OF LINE.

DATA: rb_chgd TYPE c LENGTH 1 VALUE 'X',
      l_ucomm TYPE sscrfields-ucomm.

AT SELECTION-SCREEN OUTPUT.
  IF r1 IS INITIAL AND r2 IS INITIAL.
*  we can use this condition to check whether it is first time.
    rb_chgd = 'X'.
  ELSEIF l_ucomm <> 'DUMM'.
    CLEAR rb_chgd.
  ENDIF.

AT SELECTION-SCREEN.
  l_ucomm = sscrfields-ucomm.
  CASE l_ucomm.
    WHEN 'DUMM'.
      rb_chgd = 'X'.
    WHEN 'ONLI'.
      IF rb_chgd <> space.
        MESSAGE 'Perform Action' TYPE 'I'.
*        your code here..
      ELSE.
        MESSAGE 'Nothing has changed' TYPE 'I'.
      ENDIF.
  ENDCASE.

Read only

0 Likes
1,630

Hi Arun,

Its Fine but when am clicking the 1st radio button for the 1st time also its showing nothing has been changed. but its not like that 1st time it should update the ztable if we dont change the postion to 2nd radio button then it sholud display a pop up.

Please suggest me.

Regards,

Samatha

Read only

0 Likes
1,630

Hi Samantha, <li>Remove USER-COMMAND dumm portion in the below statement.


PARAMETERS: r1 RADIOBUTTON GROUP g1 USER-COMMAND dumm.
change to

PARAMETERS: r1 RADIOBUTTON GROUP g1. 
Thanks Venkat.O

Read only

0 Likes
1,630

Samatha,

Did you try to execute the program that I gave? It does not give 'Nothing has changed' the first time.. Or are you trying to embed this in some other logic? In that case, please let me know your entire program. Only then I'll be able to help you.

Read only

0 Likes
1,630

Venkat,

That line is required for finding whether the other Radio Button has been clicked or not. Please try to execute the program before commenting..

Read only

0 Likes
1,630

Samatha, please copy this program in an abap editor (as a fresh new program) and then execute..

TABLES sscrfields.

PARAMETERS: r1 RADIOBUTTON GROUP g1 USER-COMMAND dumm,
r2 RADIOBUTTON GROUP g1.
SELECTION-SCREEN: BEGIN OF LINE.
SELECTION-SCREEN: PUSHBUTTON 30(30) pb01 USER-COMMAND onli
VISIBLE LENGTH 15.
SELECTION-SCREEN: END OF LINE.

DATA: rb_chgd TYPE c LENGTH 1 VALUE 'X',
      l_ucomm TYPE sscrfields-ucomm.

AT SELECTION-SCREEN OUTPUT.
  IF r1 IS INITIAL AND r2 IS INITIAL.
*  we can use the above condition to check whether it is first time.
    rb_chgd = 'X'.
  ELSEIF l_ucomm NE 'DUMM'.
    CLEAR rb_chgd.
  ENDIF.

AT SELECTION-SCREEN.
  l_ucomm = sscrfields-ucomm.
  CASE l_ucomm.
    WHEN 'DUMM'.
      rb_chgd = 'X'.
    WHEN 'ONLI'.
      IF rb_chgd <> space.
        MESSAGE 'Perform Action' TYPE 'I'.
*        your code here..
      ELSE.
        MESSAGE 'Nothing has changed' TYPE 'I'.
      ENDIF.
  ENDCASE.

This is just to let you know the logic to do this..

Read only

0 Likes
1,630

Hi Arun,

Thanks Alot.

One more i have 2 differnt conditions for 2 radio buttons. For the first one it sholud set some flag in ztable as X and for the 2nd it should set flag as Blank. With this code am getting flag as x for the 2 radio buttons.

Please suggest.

Regards,

Samatha

Read only

Former Member
0 Likes
1,630

Hello,

Please try the following code.


PARAMETERS: r1 RADIOBUTTON GROUP g1 ,
            r2 RADIOBUTTON GROUP g1.
SELECTION-SCREEN: BEGIN OF LINE.
SELECTION-SCREEN: PUSHBUTTON 30(30) pb01 USER-COMMAND onli
VISIBLE LENGTH 15.
SELECTION-SCREEN: END OF LINE.
DATA rb.

AT SELECTION-SCREEN.
  CLEAR rb.
  IF r1 = 'X'.
    IMPORT rb FROM MEMORY ID 'RB'.
    IF rb IS INITIAL.
*       perform update.
      rb = 'X'.
      EXPORT rb TO MEMORY ID 'RB'.
    ELSE.
      MESSAGE 'Select other radio button' TYPE 'I'.
    ENDIF.
  ELSEIF r2 = 'X'.
    FREE MEMORY ID 'RB'.
  ENDIF.

hope this helps in resolving your issue.

Regards,

Sachin

Read only

Former Member
0 Likes
1,630

text 001 :Selection screen sample

tex t002 : List

text 003: Alv

text 004: None


CONSTANTS : rbSelected TYPE c LENGTH 1 VALUE 'X'.

DATA : p_txt type c LENGTH 100.

SELECTION-SCREEN BEGIN OF BLOCK frame1 WITH FRAME TITLE text-001.
  SELECTION-SCREEN ULINE /10(40).

  SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN POSITION 15.
    PARAMETERS: rb1 RADIOBUTTON GROUP rb.
    SELECTION-SCREEN COMMENT 20(30) text-002.
  SELECTION-SCREEN END OF LINE.

  SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN POSITION 15.
    PARAMETERS: rb2 RADIOBUTTON GROUP rb.
    SELECTION-SCREEN COMMENT 20(30) text-003.
  SELECTION-SCREEN END OF LINE.

  SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN POSITION 15.
    PARAMETERS: rb3 RADIOBUTTON GROUP rb.
    SELECTION-SCREEN COMMENT 20(30) text-004.
  SELECTION-SCREEN END OF LINE.

  SELECTION-SCREEN ULINE /10(40).
SELECTION-SCREEN END OF BLOCK frame1.

IF rb1 = rbSelected.
  CONCATENATE 'You selected' text-002 INTO p_txt SEPARATED BY space.
ELSEIF rb2 = rbSelected.
  CONCATENATE 'You selected' text-003 INTO p_txt SEPARATED BY space.
ELSEIF rb3 = rbSelected.
  CONCATENATE 'You selected' text-004 INTO p_txt SEPARATED BY space.
ENDIF.

WRITE / p_txt.

Read only

Former Member
0 Likes
1,630

solved my problem