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

problem with GET_SELECTED_ROW

Former Member
0 Likes
419

hi ,

i am working on alv grid,in which when i insert the valuse i need to selct then row and by using GET_SELECTED_ROW i need to update the selected row with DB table. i have 3 fields in table. when i selct the inserted row and leave the corsior on last field ,it will take last field as 0 (zero) but i will get all valuse when corsuor is other than last row.. plz help me why its happning like this since i m using get-selecet_row it shuld take the full row???

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
371

this might help:

REPORT ybc_test05.

  • Example: ALV-List of T000 with the possibility to select various

  • lines and to precess them.

  • Additional to this source a GUI-Status has to be created

  • ( copy from SALV_TABLE_STANDARD in FM SALV_METADATA_STATUS )

  • and there an individual function must be defined.

DATA it_outtab TYPE TABLE OF t000.

DATA gr_table TYPE REF TO cl_salv_table.

CLASS lcl_handle_events DEFINITION DEFERRED.

DATA: gr_handle_events TYPE REF TO lcl_handle_events.

CLASS lcl_handle_events DEFINITION.

PUBLIC SECTION.

METHODS:

on_user_command

FOR EVENT added_function

OF cl_salv_events

IMPORTING e_salv_function.

ENDCLASS. "lcl_handle_events DEFINITION

CLASS lcl_handle_events IMPLEMENTATION.

METHOD on_user_command.

PERFORM user_command_objects USING e_salv_function.

ENDMETHOD. "on_user_command

ENDCLASS. "lcl_handle_events IMPLEMENTATION

START-OF-SELECTION.

SELECT * FROM t000

INTO TABLE it_outtab.

cl_salv_table=>factory(

IMPORTING r_salv_table = gr_table

CHANGING t_table = it_outtab ).

*.................. Allow to mark more than one line ................. *

DATA: lr_sel TYPE REF TO cl_salv_selections.

lr_sel = gr_table->get_selections( ).

lr_sel->set_selection_mode( if_salv_c_selection_mode=>multiple ).

*.................. Set_screen_status ................................ *

DATA: x_repid TYPE syrepid.

x_repid = sy-repid.

gr_table->set_screen_status(

pfstatus = 'SALV_TABLE_TEST05' "GUI-Status

report = x_repid ).

*... Enable Generic ALV functions

DATA: gr_functions TYPE REF TO cl_salv_functions_list.

gr_functions = gr_table->get_functions( ).

gr_functions->set_all( ).

*.................. Handle Event ..................................... *

DATA: lr_events TYPE REF TO cl_salv_events_table.

lr_events = gr_table->get_event( ).

CREATE OBJECT gr_handle_events.

SET HANDLER gr_handle_events->on_user_command FOR lr_events.

*.................. Display ALV ...................................... *

gr_table->display( ).

FORM user_command_objects USING u_comm TYPE salv_de_function.

DATA:

lv_row TYPE i .

CASE u_comm.

WHEN 'DO'. "individual function in GUI-Status

PERFORM get_selected_row USING gr_table

CHANGING lv_row.

ENDCASE.

ENDFORM. "user_command_objects

FORM get_selected_row USING ir_table TYPE REF TO cl_salv_table

CHANGING e_row TYPE i.

*.. get selected line.

DATA: lr_selection TYPE REF TO cl_salv_selections,

lt_selected_row TYPE salv_t_row,

ls_selected_row LIKE LINE OF lt_selected_row,

l_cell TYPE salv_s_cell.

ir_table->get_metadata( ).

lr_selection = ir_table->get_selections( ).

lt_selected_row = lr_selection->get_selected_rows( ).

DATA: wa_outtab TYPE t000.

LOOP AT lt_selected_row INTO ls_selected_row.

READ TABLE it_outtab INDEX ls_selected_row INTO wa_outtab.

CALL FUNCTION 'POPUP_TO_CONFIRM'

EXPORTING

text_question = wa_outtab-mtext.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDLOOP.

ENDFORM. "get_selected_row

1 REPLY 1
Read only

Former Member
0 Likes
372

this might help:

REPORT ybc_test05.

  • Example: ALV-List of T000 with the possibility to select various

  • lines and to precess them.

  • Additional to this source a GUI-Status has to be created

  • ( copy from SALV_TABLE_STANDARD in FM SALV_METADATA_STATUS )

  • and there an individual function must be defined.

DATA it_outtab TYPE TABLE OF t000.

DATA gr_table TYPE REF TO cl_salv_table.

CLASS lcl_handle_events DEFINITION DEFERRED.

DATA: gr_handle_events TYPE REF TO lcl_handle_events.

CLASS lcl_handle_events DEFINITION.

PUBLIC SECTION.

METHODS:

on_user_command

FOR EVENT added_function

OF cl_salv_events

IMPORTING e_salv_function.

ENDCLASS. "lcl_handle_events DEFINITION

CLASS lcl_handle_events IMPLEMENTATION.

METHOD on_user_command.

PERFORM user_command_objects USING e_salv_function.

ENDMETHOD. "on_user_command

ENDCLASS. "lcl_handle_events IMPLEMENTATION

START-OF-SELECTION.

SELECT * FROM t000

INTO TABLE it_outtab.

cl_salv_table=>factory(

IMPORTING r_salv_table = gr_table

CHANGING t_table = it_outtab ).

*.................. Allow to mark more than one line ................. *

DATA: lr_sel TYPE REF TO cl_salv_selections.

lr_sel = gr_table->get_selections( ).

lr_sel->set_selection_mode( if_salv_c_selection_mode=>multiple ).

*.................. Set_screen_status ................................ *

DATA: x_repid TYPE syrepid.

x_repid = sy-repid.

gr_table->set_screen_status(

pfstatus = 'SALV_TABLE_TEST05' "GUI-Status

report = x_repid ).

*... Enable Generic ALV functions

DATA: gr_functions TYPE REF TO cl_salv_functions_list.

gr_functions = gr_table->get_functions( ).

gr_functions->set_all( ).

*.................. Handle Event ..................................... *

DATA: lr_events TYPE REF TO cl_salv_events_table.

lr_events = gr_table->get_event( ).

CREATE OBJECT gr_handle_events.

SET HANDLER gr_handle_events->on_user_command FOR lr_events.

*.................. Display ALV ...................................... *

gr_table->display( ).

FORM user_command_objects USING u_comm TYPE salv_de_function.

DATA:

lv_row TYPE i .

CASE u_comm.

WHEN 'DO'. "individual function in GUI-Status

PERFORM get_selected_row USING gr_table

CHANGING lv_row.

ENDCASE.

ENDFORM. "user_command_objects

FORM get_selected_row USING ir_table TYPE REF TO cl_salv_table

CHANGING e_row TYPE i.

*.. get selected line.

DATA: lr_selection TYPE REF TO cl_salv_selections,

lt_selected_row TYPE salv_t_row,

ls_selected_row LIKE LINE OF lt_selected_row,

l_cell TYPE salv_s_cell.

ir_table->get_metadata( ).

lr_selection = ir_table->get_selections( ).

lt_selected_row = lr_selection->get_selected_rows( ).

DATA: wa_outtab TYPE t000.

LOOP AT lt_selected_row INTO ls_selected_row.

READ TABLE it_outtab INDEX ls_selected_row INTO wa_outtab.

CALL FUNCTION 'POPUP_TO_CONFIRM'

EXPORTING

text_question = wa_outtab-mtext.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDLOOP.

ENDFORM. "get_selected_row