‎2007 Jan 08 9:46 AM
I have a requirement where in when user selects a file using file open dialog, the appropriate
radio button should be selected programatically based on file type. For ex. if user selects '.csv' file the
radio button 'CSV' should be selected automatically & the screen should get refreshed. Now I need to know how the screen should be repainted.
‎2007 Jan 08 11:44 AM
hi ,
Execute the code and see if this is working for u .
parameters : fname like rlgrap-filename." memory id m01.
DATA : filename TYPE string.
DATA : table1 TYPE filetable,
rc TYPE i.
PARAMETERS : R1 RADIOBUTTON GROUP RG user-command r modif id abc
DEFAULT
'X'.
PARAMETERS : R2 RADIOBUTTON GROUP RG modif id def.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR fname.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
default_filename = '*.*'
CHANGING
file_table = table1
rc = rc.
IF sy-subrc <> 0.
MESSAGE e000(zXXX) WITH 'Error'.
ENDIF.
LOOP AT table1 INTO fname.
ENDLOOP.
at selection-screen output.
IF fname cs '.CSV'.
LOOP AT SCREEN.
IF screen-group1 = 'ABC'.
r1 = 'X'.
r2 = ' '.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
elseif fname cs '.DOC'.
LOOP AT SCREEN.
IF screen-group1 = 'DEF'.
r2 = 'X'.
r1 = ' '.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ENDIF.make the f4 select .CSV or .DOC and the radio button is taking the position based on the input.
hope this helps
regards,
vijay
‎2007 Jan 08 10:00 AM
Hi Gopinath ,
You will have to get the file type , may be from the extension of the file and then use the at selection-screen output event for the same.
here is a sample program which works when you enter file as 'CSV' or 'DOC'
PARAMETERS : FILE(10),
RB1 RADIOBUTTON GROUP G1 USER-COMMAND RB ,
RB2 RADIOBUTTON GROUP G1.
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF FILE = 'CSV'.
IF SCREEN-NAME = 'RB2'.
SCREEN-ACTIVE = 0.
MODIFY SCREEN.
ENDIF.
ELSEIF FILE = 'DOC'.
IF SCREEN-NAME = 'RB1'.
SCREEN-ACTIVE = 0.
MODIFY SCREEN.
ENDIF.
ENDIF .
ENDLOOP.This code will hide the other radio button ,
Do fell free to revert back if you have any issues ,
Regards
Arun
‎2007 Jan 08 10:24 AM
Arun, Thx for the reply
am using selection screens.
At selection-screen output will trigger only once. but in my case whenever the user selects a file for the first text field, in the same screen the radio buttons below should be automatically selected based on file type.
‎2007 Jan 08 10:27 AM
Hi Gopinath ,
Seelction screen output is triggered each time an event is executed , so it goes this way any event is triggered it goes to AT SELECTION-SCREEN , if it is there ,else at selection-screen output is executed
Could you please past your code for selection screen so that we can provide a better solution.
Regards
ARUN
‎2007 Jan 08 10:27 AM
hi Arun,
you shouldn't take the things said by others and post-edit your reply inserting what others said.
‎2007 Jan 08 11:01 AM
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_upload.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
EXPORTING
WINDOW_TITLE = 'Select the file'
DEFAULT_EXTENSION =
DEFAULT_FILENAME =
FILE_FILTER = filter
INITIAL_DIRECTORY =
MULTISELECTION = ' '
WITH_ENCODING =
CHANGING
FILE_TABLE = filetable
RC = rc
USER_ACTION =
FILE_ENCODING =
EXCEPTIONS
FILE_OPEN_DIALOG_FAILED = 1
CNTL_ERROR = 2
ERROR_NO_GUI = 3
NOT_SUPPORTED_BY_GUI = 4
others = 5.
IF SY-SUBRC = 0 AND rc = 1.
READ TABLE filetable INDEX 1 INTO line.
fpath = p_upload = line-filename.
CALL FUNCTION 'PC_SPLIT_COMPLETE_FILENAME'
EXPORTING
COMPLETE_FILENAME = fpath
CHECK_DOS_FORMAT =
IMPORTING
DRIVE =
EXTENSION = ext
NAME =
NAME_WITH_EXT =
PATH =
EXCEPTIONS
INVALID_DRIVE = 1
INVALID_EXTENSION = 2
INVALID_NAME = 3
INVALID_PATH = 4
OTHERS = 5.
IF SY-SUBRC = 0.
IF ext = c_tab.
p_csv = ' '. "first radio button
p_tab = 'X'. "second radio button
ELSEIF ext = c_csv.
p_tab = ' '.
p_csv = 'X'.
ENDIF.
ENDIF.
ENDIF.
Message was edited by:
Gopinath Natesan
‎2007 Jan 08 11:25 AM
You have to loop at screen and modify the screen inorder to choose the corresponding radio button.
‎2007 Jan 08 10:02 AM
hi there,
in the corresponding block for output ( AT SELECTION-SCREEN OUTPUT if there is a selection screen or within a PBO module) you just set desired radiobutton to 'X' and clear all other radiobuttons from the same radiogroup (otherwise you'll get a short dump).
please ask if questions (but firstly give all relevant info)
br
‎2007 Jan 08 10:04 AM
if you are using selection screen for that you have to use
at selection-screen output.
if p_file = 'CSV'.
radio1 = 'X'.
endif.
like that.
or if you have any your screen you have to do it in PBO.
regards
shiba dutta
‎2007 Jan 08 10:14 AM
Hi gopinath,
1. use the event AT SELECTION-SCREEN OUTPUT.
2. There, just put
if filetype = 'CSV'.
radiocsv = 'X'.
endif.
regards,
amit m.
‎2007 Jan 08 10:28 AM
sorry as per as i know if you enter some value in the selection screen field and press enter it will trigger at selection-screen and then again it will trigger at selection-screen output. Correct me if i am wrong.
regards
shiba dutta
‎2007 Jan 08 10:36 AM
hi,
the AT SELECTION-SCREEN OUTPUT is executed everytime something happens in the screen (enter values, push buttons, etc) since is the correspondent of the PBO for normal screens.
so, if you want to modify the screen elements (activating/deactivating, modifying input, etc) or want to modify values you must do it here.
br
‎2007 Jan 08 11:44 AM
hi ,
Execute the code and see if this is working for u .
parameters : fname like rlgrap-filename." memory id m01.
DATA : filename TYPE string.
DATA : table1 TYPE filetable,
rc TYPE i.
PARAMETERS : R1 RADIOBUTTON GROUP RG user-command r modif id abc
DEFAULT
'X'.
PARAMETERS : R2 RADIOBUTTON GROUP RG modif id def.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR fname.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
default_filename = '*.*'
CHANGING
file_table = table1
rc = rc.
IF sy-subrc <> 0.
MESSAGE e000(zXXX) WITH 'Error'.
ENDIF.
LOOP AT table1 INTO fname.
ENDLOOP.
at selection-screen output.
IF fname cs '.CSV'.
LOOP AT SCREEN.
IF screen-group1 = 'ABC'.
r1 = 'X'.
r2 = ' '.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
elseif fname cs '.DOC'.
LOOP AT SCREEN.
IF screen-group1 = 'DEF'.
r2 = 'X'.
r1 = ' '.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ENDIF.make the f4 select .CSV or .DOC and the radio button is taking the position based on the input.
hope this helps
regards,
vijay
‎2007 Jan 08 12:21 PM
Vijay,
thx for the reply.
the code will work only when user interacts with the radio button. But what am expecting is the moment user selects a file, the appropriate radio button should be selected automatically w.r.t file extension.
hope I clarified.
awaiting ur response.
‎2007 Jan 08 1:18 PM
Give the input file and hit an <b>enter</b> . either manually or by F4
give .CSV and an enter or .DOC and an enter .
For the system to process the logic it has to trigger at selection-screen output.
so u need to hit the <b>ENTER</b> button .
The code is working fine till here .
just confirm .
//the code will work only when user interacts with the radio button
u need not touch the radiobutton after the value is fetched just hit enter.
next..
Now in order to do that dynamically ie based on extension of file to select the radiobutton dynamically i need to catch that event .. im working on that how to capture the enter ,, let me get back to u once i have a hit.
regards,
vijay
‎2007 Jan 08 1:28 PM
As you said, the code is working bearing in mind that the user has to press <b>ENTER</b>. But we can't demand for it.
‎2007 Jan 08 1:38 PM
Hi gopinath,
1. immediately after calling the file open dialog,
2. we can use the fm SET_DYNP_VALUE'
to set the value of any field on the screen,
eg. input field, radiobutton.
3. But the problem with radiobutton is,
it gives error that TWO buttons are active at same time.
4. just use this kind of code to get a taste of it.
5.
DATA : VAL LIKE DYNPREAD-FIELDVALUE.
CLEAR VAL.
VAL = ' '.
CALL FUNCTION 'SET_DYNP_VALUE'
EXPORTING
I_FIELD = 'MYRADIO1'
I_REPID = SY-REPID
I_DYNNR = SY-DYNNR
I_VALUE = VAL.
VAL = 'X'.
CALL FUNCTION 'SET_DYNP_VALUE'
EXPORTING
I_FIELD = 'MYRADIO2'
I_REPID = SY-REPID
I_DYNNR = SY-DYNNR
I_VALUE = VAL.
regards,
amit m.
‎2007 Jan 10 6:08 AM
Yeah its working fine ..
parameters : fname like rlgrap-filename.
DATA : filename TYPE string.
DATA : table1 TYPE filetable,
rc TYPE i.
DATA : VAL LIKE DYNPREAD-FIELDVALUE.
data: dynfields type table of dynpread with header line.
PARAMETERS : R1 RADIOBUTTON GROUP RG modif id abc.
PARAMETERS : R2 RADIOBUTTON GROUP RG modif id def.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR fname.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
default_filename = '*.*'
CHANGING
file_table = table1
rc = rc.
IF sy-subrc <> 0.
MESSAGE e000(zXXX) WITH 'Error'.
ENDIF.
read table table1 index 1 into fname.
IF fname cs '.XLS'. "substitute .csv
dynfields-fieldname = 'R1'.
dynfields-fieldvalue = 'X'.
append dynfields.
dynfields-fieldname = 'R2'.
dynfields-fieldvalue = ' '.
append dynfields.
elseif fname cs '.DOC'.
dynfields-fieldname = 'R1'.
dynfields-fieldvalue = ' '.
append dynfields.
dynfields-fieldname = 'R2'.
dynfields-fieldvalue = 'X'.
append dynfields.
ENDIF.
call function 'DYNP_VALUES_UPDATE'
exporting
dyname = sy-cprog
dynumb = sy-dynnr
tables
dynpfields = dynfields
exceptions
others = 8.regards,
vijay.
‎2007 Jan 10 7:01 AM
Vijay,
Thx for your work & solution......keep doin gud.....
rewarded points
Cheers!!
Gopinath N
‎2007 Jan 10 7:14 AM
Hi Gopinath ,
One small addition to the code , please refresh the table <b>table1</b> ,before you call the method , if you dont do it you wont get the desired result , on repated execution.
Regards
Arun