2013 May 31 3:18 AM
Hi Gurus,
Please help know how to modify the selection screen block on click of the application toolbar push button. I want to hide block2 and block3 on click of button1 and so on. Below is my code but for some reason its not working, i tried several options like using 'AT SELECTION-SCREEN OUTPUT" event as well. However please find my code below and let me know how can i achieve this. I tried searching ABAP forum too.
TABLES:MARA,SSCRFIELDS.
SELECTION-SCREEN begin of BLOCK b1 with FRAME TITLE text-001.
SELECT-OPTIONS:s_option1 for mara-matnr MODIF ID M1,
s_option2 for mara-matnr MODIF ID M1.
SELECTION-SCREEN end of BLOCK b1.
SELECTION-SCREEN begin of BLOCK b2 with frame TITLE text-002.
select-OPTIONS:s_option3 for mara-matnr MODIF ID M2,
s_option4 for mara-matnr MODIF ID M2.
SELECTION-SCREEN end of block b2.
SELECTION-SCREEN begin of BLOCK b3 WITH FRAME TITLE text-003.
Select-OPTIONS:s_option5 for mara-matnr MODIF ID M3,
s_option6 for mara-matnr MODIF ID M3.
SELECTION-SCREEN end of BLOCK b3.
SELECTION-SCREEN: FUNCTION KEY 1,
FUNCTION KEY 2,
FUNCTION KEY 3,
FUNCTION KEY 4.
INITIALIZATION.
Move 'Button1' to SSCRFIELDS-FUNCTXT_01.
MOVE 'Button2' to SSCRFIELDS-FUNCTXT_02.
MOVE 'Button3' to SSCRFIELDS-FUNCTXT_03.
MOVE 'Button4' to SSCRFIELDS-FUNCTXT_04.
AT SELECTION-SCREEN.
CASE SSCRFIELDS-UCOMM.
WHEN 'FC01'.
LOOP AT SCREEN.
If screen-group1 = 'M1'.
screen-invisible = 0.
screen-active = 1.
ELSE.
screen-invisible = 1.
screen-active = 0.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
WHEN 'FC02'.
LOOP AT SCREEN.
If screen-group1 = 'M2'.
screen-invisible = 0.
screen-active = 1.
ELSE.
screen-invisible = 1.
screen-active = 0.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
WHEN 'FC03'.
LOOP AT SCREEN.
If screen-group1 = 'M3'.
screen-invisible = 0.
screen-active = 1.
ELSE.
screen-invisible = 1.
screen-active = 0.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
WHEN 'FC04'.
ENDCASE.
2013 May 31 6:31 AM
Oh dear... try reading your code - the logic is just wrong. Think about what each statement does and the logical flow. When you have this kind of problem, you should run in debug to see what was happening. It's a good idea to say EXACTLY what is happening, instead of "it's not working. If you follow these simple rules, then you may well fix problems yourself (rather than relying on others), and when you do have problems you can't fix, others can help you more easily.
You've got the MODIFY SCREEN before the ENDIF... it should go after, shouldn't it. Also, if the group isn't M1 (for FC01) you're making it invisible. Even if it isn't M2 or M3.
Try:
...
WHEN 'FC01'.
LOOP AT SCREEN.
CASE screen-group1.
WHEN 'M1'.
SCREEN-INVISIBLE = 0.
SCREEN-ACTION = 1.
WHEN 'M2' OR 'M3'.
SCREEN-INVISIBLE = 1.
SCREEN-ACTION = 0.
WHEN OTHERS.
CONTINUE. " No screen modification, just go to the next element.
ENDCASE.
MODIFY SCREEN.
ENDLOOP.
...
2013 May 31 6:47 AM
Hi,
We need to write the code for changing the selection screen under AT SELECTION-SCREEN OUTPUT event.
Please try writing the code below this event and check through debugging whether the screen structure is modifying for given conditions.
Hope, this helps you.
With Regards,
Gurulakshmi
2013 Jun 03 12:20 PM
The activation of the function code will occur in PAI : AT SELECTION-SCREEN.
The modification of screen attributes is reset before PBO and so must be done in PBO in AT SELECTION-SCREEN-OUTPUT.
So you have to store in a global variable,
In PAI
AT SELECTION-SCREEN.
CASE sscrfields-ucomm.
WHEN 'FC01'.
fc01_pressed = abap_true.
CLEAR: fc02_pressed, fc03_pressed, f04_pressed.
WHEN 'FC02'.
" etc.
ENDCASE.AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF screen-group1 = 'M1' AND fc01_pressed IS INITIAL.
screen-active = 0.
ELSEIF screen-group1 = 'M2' AND fc02_pressed IS INITIAL.
" etc/
ENDIF.
MODIFY SCREEN.
ENDLOOP.Regards,
Raymond
2013 Jun 04 10:30 AM
Correct answer is given by Raymond. I only checked.
REPORT z_test.
type-pools: abap.
TABLES: mara,
sscrfields.
DATA: tp_on type abap_bool.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_opt1 FOR mara-matnr MODIF ID m1,
s_opt2 FOR mara-matnr MODIF ID m1.
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
SELECT-OPTIONS: s_opt3 FOR mara-matnr MODIF ID m2,
s_opt4 FOR mara-matnr MODIF ID m2.
SELECTION-SCREEN END OF BLOCK b2.
SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-003.
SELECT-OPTIONS: s_opt5 FOR mara-matnr MODIF ID m3,
s_opt6 FOR mara-matnr MODIF ID m3.
SELECTION-SCREEN END OF BLOCK b3.
SELECTION-SCREEN: FUNCTION KEY 1,
FUNCTION KEY 2.
INITIALIZATION.
MOVE 'Switch ON' TO sscrfields-functxt_01.
MOVE 'Switch OFF' TO sscrfields-functxt_02.
AT SELECTION-SCREEN.
CASE sy-ucomm.
WHEN 'FC01'.
tp_on = abap_true.
WHEN 'FC02'.
tp_on = abap_false.
ENDCASE.
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
CASE screen-group1.
WHEN 'M2'.
IF tp_on = abap_true.
screen-active = '1'.
ELSE.
screen-active = '0'.
ENDIF.
MODIFY SCREEN.
ENDCASE.
ENDLOOP.
2013 Jun 06 7:57 AM
Thank you All for your valuable inputs, i have got it right now and also understood how these events work, thank you again