on 09-28-2022 6:11 AM
I have 2 radio button options..... But if i click SD Invoice number i will show SD Update..... and same shld be for MM Invoice number...... But when i select MM it still shows SD update....... How to dynamically change it? pls help me with this issue...
Pls refer this code.....
SELECTION-SCREEN : BEGIN OF BLOCK c1.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS : r1 RADIOBUTTON GROUP rad1 USER-COMMAND u1 DEFAULT 'X'.
SELECTION-SCREEN COMMENT 3(25) text-015 FOR FIELD r1.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS : r2 RADIOBUTTON GROUP rad1.
SELECTION-SCREEN COMMENT 3(25) text-016 FOR FIELD r2 .
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN : END OF BLOCK c1.
SELECTION-SCREEN BEGIN OF BLOCK a1 WITH FRAME TITLE text-001.
SELECT-OPTIONS : s_invnum FOR zsd_vf01-vbeln MODIF ID a OBLIGATORY.
PARAMETERS : rem_upd(100) TYPE c MODIF ID a OBLIGATORY.
SELECTION-SCREEN END OF BLOCK a1.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-002.
SELECT-OPTIONS : s_inv1 FOR zmm_vf01-vbeln MODIF ID b OBLIGATORY.
PARAMETERS : rem_upd1(100) TYPE c MODIF ID b OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b1.
*AT SELECTION-SCREEN ON VALUE-REQUEST FOR
AT SELECTION-SCREEN OUTPUT.
IF r1 = 'X'.
LOOP AT SCREEN.
IF screen-group1 = 'A'.
screen-active = '1'.
ENDIF.
MODIFY SCREEN.
ENDLOOP.
LOOP AT SCREEN.
IF screen-group1 = 'B'.
screen-active = '0'.
ENDIF.
MODIFY SCREEN.
ENDLOOP.
ENDIF.
IF r2 = 'X'.
LOOP AT SCREEN.
if screen-group1 = 'B'.
screen-active = '1'.
ENDIF.
MODIFY SCREEN.
ENDLOOP.
LOOP AT SCREEN.
IF screen-group1 = 'A'.
screen-input = '0'.
ENDIF.
MODIFY SCREEN.
ENDLOOP.
ENDIF.
START-OF-SELECTION.
Hi,
following adapted code works in my case:
IF r1 = 'X'.
LOOP AT SCREEN.
IF screen-group1 = 'A'.
screen-active = '1'.
screen-invisible = '0'.
ENDIF.
MODIFY SCREEN.
ENDLOOP.
LOOP AT SCREEN.
IF screen-group1 = 'B'.
screen-active = '0'.
screen-invisible = '1'.
ENDIF.
MODIFY SCREEN.
ENDLOOP.
ENDIF.
IF r2 = 'X'.
LOOP AT SCREEN.
if screen-group1 = 'B'.
screen-active = '1'.
screen-invisible = '0'.
ENDIF.
MODIFY SCREEN.
ENDLOOP.
LOOP AT SCREEN.
IF screen-group1 = 'A'.
screen-input = '0'.
screen-invisible = '1'.
ENDIF.
MODIFY SCREEN.
ENDLOOP.
ENDIF.
I just added the invisible-flag additionally. But from my point of view you have to disable the obligatory-flag for the fields in the blocks as otherwise SAP does not allow to change the screen when using a radio-button without entering some data in the obligatory fields. I would suggest to check in START-OF-SELECTION if the user has entered some data in the selection parameter and if not raise an error, so you can avoid the obligatory-flag.
I hope this helps you 🙂
Kind regards
Jens
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
thank you jzaehringer it worked......
AT SELECTION-SCREEN OUTPUT.
IF r1 = 'X'.
LOOP AT SCREEN.
screen-active = cond #( when screen-group1 eq 'A'
then '1'
when screen-group1 eq 'B'
then '0' ).
MODIFY SCREEN.
ENDLOOP.
else.
LOOP AT SCREEN.
screen-active = cond #( when screen-group1 eq 'B'
then '1'
when screen-group1 eq 'A'
then '0' ).
MODIFY SCREEN.
ENDLOOP.
ENDIF.
do it simple
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Or simpler... - use switch. 😉
If you ask me, this new abap syntax is not simpler than this:
AT SELECTION-SCREEN OUTPUT.
IF r1 = abap_true.
LOOP AT SCREEN.
CASE screen-group1.
WHEN 'A'.
screen-active = '1'.
screen-invisible = '0'.
MODIFY SCREEN.
WHEN 'B'.
screen-input = '0'.
screen-invisible = '1'.
MODIFY SCREEN.
ENDCASE.
ENDLOOP.
ENDIF.
IF r2 = abap_true.
LOOP AT SCREEN.
CASE screen-group1.
WHEN 'A'.
screen-active = '0'.
screen-invisible = '1'.
MODIFY SCREEN.
WHEN 'B'.
screen-input = '1'.
screen-invisible = '0'.
MODIFY SCREEN.
ENDCASE.
ENDLOOP.
ENDIF.
From my point of view it just complicates things that were already fine before.
This is subjective, obviously.
But, if you avoid the problem of learning new statement (this is sometimes really difficult, I still have problem with the FOR, LET, REDUCE, ...), I really think, less statement you have better is the code.
When you need to correct a program made by a colleague, and you see 15.000 lines of code, I am pretty sure, you are not so happy 😉
OBLIGATORY is not possible in combination with radio-button groups.
You need to do it like that:
DATA:
gv_vbeln TYPE vbeln.
SELECTION-SCREEN BEGIN OF BLOCK c1.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: r1 RADIOBUTTON GROUP rad1 USER-COMMAND u1 DEFAULT 'X'.
SELECTION-SCREEN COMMENT 3(25) TEXT-015 FOR FIELD r1.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: r2 RADIOBUTTON GROUP rad1.
SELECTION-SCREEN COMMENT 3(25) TEXT-016 FOR FIELD r2 .
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK c1.
SELECTION-SCREEN BEGIN OF BLOCK a1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: s_inv1 FOR gv_vbeln MODIF ID a.
PARAMETERS: rem_upd(100) TYPE c MODIF ID a.
SELECTION-SCREEN END OF BLOCK a1.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-002.
SELECT-OPTIONS: s_inv2 FOR gv_vbeln MODIF ID b.
PARAMETERS: rem_upd1(100) TYPE c MODIF ID b.
SELECTION-SCREEN END OF BLOCK b1.
AT SELECTION-SCREEN OUTPUT.
IF r1 = abap_true.
LOOP AT SCREEN.
CASE screen-group1.
WHEN 'A'.
screen-active = '1'.
screen-invisible = '0'.
MODIFY SCREEN.
WHEN 'B'.
screen-input = '0'.
screen-invisible = '1'.
MODIFY SCREEN.
ENDCASE.
ENDLOOP.
ENDIF.
IF r2 = abap_true.
LOOP AT SCREEN.
CASE screen-group1.
WHEN 'A'.
screen-active = '0'.
screen-invisible = '1'.
MODIFY SCREEN.
WHEN 'B'.
screen-input = '1'.
screen-invisible = '0'.
MODIFY SCREEN.
ENDCASE.
ENDLOOP.
ENDIF.
START-OF-SELECTION.
IF r1 = abap_true.
IF s_inv1 IS INITIAL.
MESSAGE 'Field Invoice number is mandatory' TYPE 'I' DISPLAY LIKE 'E'.
ENDIF.
ENDIF.
IF r2 = abap_true.
IF s_inv2 IS INITIAL.
MESSAGE 'Field Invoice number is mandatory' TYPE 'I' DISPLAY LIKE 'E'.
ENDIF.
ENDIF.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi aswin_0921,
Try Below Code,
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF r1 = abap_true AND screen-group1 = 'A'.
screen-active = 1.
MODIFY SCREEN.
CONTINUE.
ELSEIF r2 = abap_true AND screen-group1 = 'B'.
screen-active = 1.
MODIFY SCREEN.
CONTINUE.
ELSEIF r1 = abap_false AND screen-group1 = 'A'.
screen-active = 0.
MODIFY SCREEN.
CONTINUE.
ELSEIF r2 = abap_false AND screen-group1 = 'B'.
screen-active = 0.
MODIFY SCREEN.
CONTINUE.
ENDIF.
ENDLOOP.
Plus you need to remove Obligatory to achieve the result. Comment if any doughts.
Thanks & Regards,
Aditya.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can't hide a field if it's obligatory. Instead of marking it obligatory, add some validation in at selection-screen event.
IF ( r1 = abap_true and s_invnum is initial ) or ( r2 = abap_true and s_inv1 is initial ).
message 'Invoice number is obligatory' type 'E'.
ENDIF.
User | Count |
---|---|
101 | |
9 | |
7 | |
6 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.