2007 Mar 12 4:18 PM
these are my programs that demonstrate radio button. there are 2 versions and they have the same output and they are all working fine. I am just wondering why on version 1 (I got this pattern from a tutorial) I have to create sy-ucomm many times. On version 2, it looks more simple. I just want to know if version 1 has advantage/disadvantage over version 2 and vice versa. newbie here. <b>Thanks for the help. </b>
====================================
Code version 1
====================================
data: rb1(1), rb2(1), rb3(1), field1(10).
data: ok_code type sy-ucomm,
save_ok type sy-ucomm.
initialization.
save_ok = ok_code.
clear ok_code.
start-of-selection.
set screen 0100.
module pai input.
case save_ok.
when 'RADIO'.
if RB1 = 'X'.
field1 = 'option 1'.
elseif RB2 = 'X'.
field1 = 'option 2'.
else.
field1 = 'option 3'.
endif.
endcase.
case sy-ucomm.
when 'BTNEXIT'.
leave program.
endcase.
endmodule.
====================================
Code version 2
====================================
data: rb1(1), rb2(1), rb3(1), field1(10).
start-of-selection.
set screen 0100.
module pai input.
case sy-ucomm.
when 'BTNEXIT'.
leave program.
when 'RADIO'.
if RB1 = 'X'.
field1 = 'option 1'.
elseif RB2 = 'X'.
field1 = 'option 2'.
else.
field1 = 'option 3'.
endif.
endcase.
endmodule.
2007 Mar 12 4:24 PM
Hi Dawson,
In effect there is no difference between the two code samples:
In the first code,
we are storing the SY_UCOMM value to a varible and then using tthis variable to track the user actions (it is a recommended way in SAP, so that we can track the value of SY_UCOMM using this variable even in the PBO.)
But in the code sample, both are used, which is a little strange...
<b>underlying FACT...If there are N people coding for one requirement, the code can be of N different ways..........</b>
Hope this helps,
Sajan Joseph.
2007 Mar 12 4:24 PM
Hi,
Both options are fine and nothing wrong.
But I prefer the second option which is simple and easy to read/follow thru the logic.
Regards,
Ferry Lianto
2007 Mar 12 4:24 PM
Hi Dawson,
In effect there is no difference between the two code samples:
In the first code,
we are storing the SY_UCOMM value to a varible and then using tthis variable to track the user actions (it is a recommended way in SAP, so that we can track the value of SY_UCOMM using this variable even in the PBO.)
But in the code sample, both are used, which is a little strange...
<b>underlying FACT...If there are N people coding for one requirement, the code can be of N different ways..........</b>
Hope this helps,
Sajan Joseph.
2007 Mar 12 4:47 PM
Hello Mr. Dawson,
The code u have written is will work fine in both versions but I will prefer the first one because both the check are satisfied with a sigle CASE.. ENDCASE statement.
So U can ahead with the second version.
Regards,
Vasanth