‎2010 Jul 27 2:53 PM
Hi,
I am from basis and not a champion in ABAP.
I am writing a small ABAP program to enable-disable upon clicking a radio button.
The program is as follows -
************************
REPORT ZTEST1.
DATA : loopchk2 type i.
selection-screen begin of block ready with frame title text-113.
parameter obj type c default 'X' as checkbox USER-COMMAND b.
parameter obj1 default 'X' radiobutton group and3 MODIF ID two.
parameter obj2 radiobutton group and3 MODIF ID two.
selection-screen end of block ready.
INITIALIZATION.
loopchk2 = 1.
AT SELECTION-SCREEN .
IF sy-ucomm = 'B'.
IF obj = 'X'.
loopchk2 = 1.
ELSE.
loopchk2 = 0.
endif.
ENDIF.
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF screen-group1 = 'TWO'.
screen-input = loopchk2.
MODIFY SCREEN.
endif.
ENDLOOP.
START-OF-SELECTION.
perform objwrite.
form objwrite.
write: / 'Please select at least one check box for report to run.'.
endform.
******************************
The issue is when I uncheck the checkbox "obj" and run the report, it prints the result, which is fine but then I choose a back button then i can see that the checkbox is unchecked but two radio buttons are enabled again. The screen initializes again. The screen should not change. I debug it and found that the it changess the value of obj checkbox to X but the screen does not show it. It shows as unchecked.
Please help me.
I will appreciate your help.
Thank you,
SC
‎2010 Jul 27 3:44 PM
Hello Sume,
When you press F3 button,
events INITIALIZATION and AT SELECTION-SCREEN OUTPUT.will be triggered again respectively.
Since you set variable loopchk2 = 1. in the INITIALIZATION event
you see screen elements editable again.
You don't need to use INITIALIZATION and AT SELECTION-SCREEN events for this,
Just use this code :
REPORT ztest1.
*DATA : loopchk2 TYPE i.
SELECTION-SCREEN BEGIN OF BLOCK ready WITH FRAME TITLE text-113.
PARAMETER obj TYPE c DEFAULT 'X' AS CHECKBOX USER-COMMAND b.
PARAMETER obj1 DEFAULT 'X' RADIOBUTTON GROUP and3 MODIF ID two.
PARAMETER obj2 RADIOBUTTON GROUP and3 MODIF ID two.
SELECTION-SCREEN END OF BLOCK ready.
*INITIALIZATION.
loopchk2 = 1.
*AT SELECTION-SCREEN .
IF sy-ucomm = 'B'.
IF obj = 'X'.
loopchk2 = 1.
ELSE.
loopchk2 = 0.
ENDIF.
ENDIF.
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF screen-group1 = 'TWO'.
IF obj = 'X'. <--- Use directly the parameter obj here, no need to other event and variables
screen-input = 1.
ELSE.
screen-input = 0.
ENDIF.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
START-OF-SELECTION.
PERFORM objwrite.
&----
*& Form objwrite
&----
text
----
FORM objwrite.
WRITE: / 'Please select at least one check box for report to run.'.
ENDFORM. "objwrite
I hope it helps.
Bulent
Edited by: Bulent Balci on Jul 27, 2010 4:45 PM
‎2010 Jul 27 3:44 PM
Hello Sume,
When you press F3 button,
events INITIALIZATION and AT SELECTION-SCREEN OUTPUT.will be triggered again respectively.
Since you set variable loopchk2 = 1. in the INITIALIZATION event
you see screen elements editable again.
You don't need to use INITIALIZATION and AT SELECTION-SCREEN events for this,
Just use this code :
REPORT ztest1.
*DATA : loopchk2 TYPE i.
SELECTION-SCREEN BEGIN OF BLOCK ready WITH FRAME TITLE text-113.
PARAMETER obj TYPE c DEFAULT 'X' AS CHECKBOX USER-COMMAND b.
PARAMETER obj1 DEFAULT 'X' RADIOBUTTON GROUP and3 MODIF ID two.
PARAMETER obj2 RADIOBUTTON GROUP and3 MODIF ID two.
SELECTION-SCREEN END OF BLOCK ready.
*INITIALIZATION.
loopchk2 = 1.
*AT SELECTION-SCREEN .
IF sy-ucomm = 'B'.
IF obj = 'X'.
loopchk2 = 1.
ELSE.
loopchk2 = 0.
ENDIF.
ENDIF.
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF screen-group1 = 'TWO'.
IF obj = 'X'. <--- Use directly the parameter obj here, no need to other event and variables
screen-input = 1.
ELSE.
screen-input = 0.
ENDIF.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
START-OF-SELECTION.
PERFORM objwrite.
&----
*& Form objwrite
&----
text
----
FORM objwrite.
WRITE: / 'Please select at least one check box for report to run.'.
ENDFORM. "objwrite
I hope it helps.
Bulent
Edited by: Bulent Balci on Jul 27, 2010 4:45 PM
‎2010 Jul 28 3:04 PM