Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Validation check in selection screen

Former Member
0 Likes
871

Hi experts,

I have a selection screen in which there are 2 radio buttons S1 n S2, and a text field (Parameter) namely P_PATH.

I am using a method (CALL METHOD cl_gui_frontend_services=>file_save_dialog) for selecting a file to save some

data in the XLS format.

Once the user selects S2, and presses the F4 help in the parameter P_PATH, this method is called.

CALL METHOD cl_gui_frontend_services=>file_save_dialog

EXPORTING

window_title = p_title

default_file_name = p_filename

file_filter = l_file_filter

initial_directory = p_download_path

CHANGING

filename = p_filename

path = p_download_path

fullpath = p_full_path

user_action = g_user_action "save or cancel

EXCEPTIONS

OTHERS = 1.

The g_user_action given here has a value of 9 in case the user selects the CANCEL button in the pop up that asks for the file name to be given for saving the file.

My req. is that when g_user_action = 9. then the selection screen should be displayed back, with the S1 being selected (instead of the earlier S2).

I have done the below coding, but its not working. Is there something that I am doing incorrect?

SELECTION-SCREEN: BEGIN OF BLOCK b4 WITH FRAME TITLE text-004.

PARAMETERS: s1 RADIOBUTTON GROUP rad2 DEFAULT 'X' USER-COMMAND ac,

s2 RADIOBUTTON GROUP rad2.

SELECTION-SCREEN: END OF BLOCK b4.

DATA: g_s1 type c.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path.

PERFORM get_download_path

AT SELECTION-SCREEN OUTPUT.

if g_s1 = 'X'.

s1 = 'X'.

s2 = ''.

endif.

FORM get_download_path

    • the above method is called**

IF g_user_action = 9.

g_s1 = 'X'.

exit.

endif.

ENDFORM.

1 ACCEPTED SOLUTION
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
745

Hello Ajay,

As Advait has pointed out already AT SELECTION_SCREEN OUTPUT event (or the PBO) does not trigger after the ON VALUE-REQUEST (or the POV) event.

You have to use the FM: DYNP_VALUES_UPDATE to update the selection-screen value.

FORM get_download_path
** the above method is called**
  data: dyname like d020s-prog,
        dynumb like d020s-dnum.

  data: it_dyfields type standard table of dynpread,
           st_dyfields type dynpread.

IF g_user_action = 9.

  dyname = sy-repid.
  dynumb = sy-dynnr.

  CLEAR s2.
  s1 = 'X'.
  move 'S1' to st_dyfields-fieldname.
  move  'X'  to st_dyfields-fieldvalue.
  append st_dyfields to it_dyfields.

  move 'S2' to st_dyfields-fieldname.
  CLEAR st_dyfields-fieldvalue.
  append st_dyfields to it_dyfields.

  call function 'DYNP_VALUES_UPDATE'
       exporting
            dyname               = dyname
            dynumb               = dynumb
       tables
            dynpfields           = it_dyfields
       exceptions
            invalid_abapworkarea = 1
            invalid_dynprofield  = 2
            invalid_dynproname   = 3
            invalid_dynpronummer = 4
            invalid_request      = 5
            no_fielddescription  = 6
            undefind_error       = 7
            others               = 8.
  check sy-subrc eq 0.
endif.
ENDFORM.

Check this out.

BR,

Suhas

5 REPLIES 5
Read only

Former Member
0 Likes
745

The reason why the S1 is not getting 'X' is because the selection-screen output event will not trigger after the ON VALUE-REQUEST event. This is a standard behavior of the dialog step procedure and you cannot do much.

Also you are assigning 'X' to S1 in the selection-screen output if gs_1 is 'X'. Thus the consecutive attempts to select S2 radio button will fail forever after the first attempt.

This is because the selection-screen output will tigger and gs_1 is 'X' so it will always make S1 as 'X' and on the screen you will always see 'S1' radiobutton selected eventhough one selects the S2 radiobutton.

The question is why do you want the S1 do be selected as default if Cancel is pressed on the file save dialog?

Br,

Advait

Read only

0 Likes
745

Hi Advait,

This is a req. that seems to be more of a logical thing than technical. The only point is that once the user presses CANCEL, it is assumed that he is not interested in the excel output (S2), and he wants to now go for the ALV output (S1).

So to make it convenient, S1 should itself be selected.

I cant argue much on this point, as this is the req. given to me n I need to deliver it.

Thanks,

Ajay.

Read only

Former Member
0 Likes
745

Hi,

Instead of exit, try to use "LEAVE LIST PROCESSING".

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
746

Hello Ajay,

As Advait has pointed out already AT SELECTION_SCREEN OUTPUT event (or the PBO) does not trigger after the ON VALUE-REQUEST (or the POV) event.

You have to use the FM: DYNP_VALUES_UPDATE to update the selection-screen value.

FORM get_download_path
** the above method is called**
  data: dyname like d020s-prog,
        dynumb like d020s-dnum.

  data: it_dyfields type standard table of dynpread,
           st_dyfields type dynpread.

IF g_user_action = 9.

  dyname = sy-repid.
  dynumb = sy-dynnr.

  CLEAR s2.
  s1 = 'X'.
  move 'S1' to st_dyfields-fieldname.
  move  'X'  to st_dyfields-fieldvalue.
  append st_dyfields to it_dyfields.

  move 'S2' to st_dyfields-fieldname.
  CLEAR st_dyfields-fieldvalue.
  append st_dyfields to it_dyfields.

  call function 'DYNP_VALUES_UPDATE'
       exporting
            dyname               = dyname
            dynumb               = dynumb
       tables
            dynpfields           = it_dyfields
       exceptions
            invalid_abapworkarea = 1
            invalid_dynprofield  = 2
            invalid_dynproname   = 3
            invalid_dynpronummer = 4
            invalid_request      = 5
            no_fielddescription  = 6
            undefind_error       = 7
            others               = 8.
  check sy-subrc eq 0.
endif.
ENDFORM.

Check this out.

BR,

Suhas

Read only

Former Member
0 Likes
745

The S1 radio button is now selected successfully in case user presses CANCEL button.

I used the solution given by Suhas Saha (using 'DYNP_VALUES_UPDATE')

Now I need to make the parameter P_PATH as grey out as soon as S1 is selected.

How can I achieve this functionality? Will that need to be done inside this FM??

Edited by: ajay singh on Jan 8, 2010 11:35 AM