Skip to Content
0

Set focus on SALV table using cl_salv_table in container

Jan 16, 2017 at 11:22 AM

399

avatar image

Hello all,

I have a regular dynpro screen that include a container, in this container I built a SALV table with the following code :

SPAN { font-family: "Courier New"; font-size: 10pt; color: #000000; background: #FFFFFF; } .L0S31 { font-style: italic; color: #808080; } .L0S33 { color: #4DA619; } .L0S52 { color: #0000FF; } .L0S55 { color: #800080; } .L0S70 { color: #808080; }

FORM show_recommand_pallets CHANGING p_show_rec TYPE flag.

DATA: lr_columns TYPE REF TO cl_salv_columns_table,
lr_events TYPE REF TO cl_salv_events_table. "#EC NEEDED

IF p_show_rec = 'X'.
gr_rec->refresh( ).
RETURN.
ENDIF.
p_show_rec = 'X'.

IF cl_salv_table=>is_offline( ) EQ if_salv_c_bool_sap=>false.
CREATE OBJECT g_cont_rec
EXPORTING
container_name = 'CNTRL_REC_PALLETS'.
ENDIF.

TRY.
cl_salv_table=>factory(
EXPORTING
r_container = g_cont_rec
container_name = 'CNTRL_REC_PALLETS'
IMPORTING
r_salv_table = gr_rec
CHANGING
t_table = gt_rec ).
CATCH cx_salv_msg. "#EC NO_HANDLER
ENDTRY.

lr_columns = gr_rec->get_columns( ).
lr_columns->set_optimize( 'X' ).

PERFORM set_rec_columns USING gr_rec.
gr_rec_selections = gr_rec->get_selections( ).
gr_rec_selections->set_selection_mode( if_salv_c_selection_mode=>single ).

lr_events = gr_rec->get_event( ).
CREATE OBJECT gr_rec_events.
SET HANDLER gr_rec_events->on_link_click FOR lr_events.

PERFORM display_rec_table.

ENDFORM. " SHOW_RECOMMAND_PALLETS

SPAN { font-family: "Courier New"; font-size: 10pt; color: #000000; background: #FFFFFF; } .L0S31 { font-style: italic; color: #808080; } .L0S33 { color: #4DA619; } .L0S52 { color: #0000FF; } .L0S55 { color: #800080; } .L0S70 { color: #808080; }

FORM display_rec_table .

IF gv_rec_flag IS INITIAL.
gr_rec->display( ).
gv_rec_flag = 'X'.
ELSE.
gr_rec->refresh( ).
ENDIF.

ENDFORM. " DISPLAY_REC_TABLE

The code works great, my question is how can I make the cursor of user get focus on the table during program run from a text box in the save screen to this table (the trigger to fill this table occurs when pressing enter of the text box above the table).

I've tried to search for such case and only found answers on simple ALV and not SALV

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Raymond Giuseppi
Jan 16, 2017 at 12:40 PM
0

Set the focus on the container you used in factory method.

CALL METHOD CL_GUI_CONTROL=>set_focus " set curson on grid
  EXPORTING
    control = g_cont_rec.


Regards,
Raymond

Share
10 |10000 characters needed characters left characters exceeded