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

Get_selected record not working second time

Former Member
0 Likes
4,350

Hi friends,

When i am selecting one record and doing some funtion working fine . but when selecting another row and doing some function second record not displaying  i debug my program in get_selected row not taking 2nd index .

Hi friends,

When i am selecting one record and doing some funtion working fine . but when selecting another row and doing some function second record not displaying  i debug my program in get_selected row not taking 2nd index .

19 REPLIES 19
Read only

PeterJonker
Active Contributor
0 Likes
3,344

more info needed. code snapshots maybe ?

Read only

0 Likes
3,344

Hi peter here on oops alv report when i am selecting one  record  and clicking on modify button one screen is dispalying with selected record . again i m coming back on alv reort and selecting another row and clicking on modify screen is coming blank not showing data.

Read only

0 Likes
3,344

Did you execute some refresh of ALV and/or some cl_gui_cfw=>flush after first record execution?

Read only

0 Likes
3,344

Yes i m using refresh after calling screen.

CALL METHOD c_alvgd->refresh_table_display

         EXPORTING

           is_stable = stable.

Read only

0 Likes
3,344

Could you try to execute a call of c_alvgd>check_changed_data before get_selected_rows, which sel_mode did you pass to the layout structure ?

Read only

0 Likes
3,344

Hi Raymond,

I am doing that thing but not getting.

Read only

Former Member
0 Likes
3,344

Hi Rakhi,

Please can you paste your code snippet, atleast the alv part .

Read only

Former Member
0 Likes
3,344

Hi,

The Blank screen may be because you are refreshing the table that was used to display the content in the screen. In stead of refresh the fields used in the screen, control it before the screen is called.

CALL METHOD <grid>->get_selected_rows

If row_id is not initial.

call the modify screen.

ENDIf.

This logic will avoid calling the modify screen with the blank screen. Also check by removing the Refresh / Flush command within the screen that is called after the user command.

Let me know if it works.

Read only

0 Likes
3,344

No I m not refresing internal table only user clear for work area.

WHEN 'MOD'. " modify button

     

CALL METHOD c_alvgd->check_changed_data.

      CALL METHOD c_alvgd->get_selected_rows " here second time i_selected_rowss is showing zero.

        IMPORTING

          et_index_rows = i_selected_rowss.

*

* Through the index capturing the values of selected rows

      LOOP AT i_selected_rowss INTO w_selected_rowss.

        READ TABLE it_final INTO wa_final INDEX w_selected_rowss-index.

      ENDLOOP.

      CALL SCREEN xyz STARTING AT 12 18

                  ENDING  AT 155 42.

CALL METHOD c_alvgd->refresh_table_display

        EXPORTING

          is_stable = stable.

Read only

0 Likes
3,344

Hi,

The Flow looks perfect. I got the similar error in one of my program, then I got to know that the row selection was not captured but the cell selection was fine. I made the code like below.

DATA: lt_cells TYPE lvc_t_cells,

           ls_cells TYPE lvc_s_cells.

CALL METHOD grid->get_selected_rows

     IMPORTING index rows.

IF row_id is INITIAL.

      CALL METHOD grid->get_selected_cells

          IMPORTING et_cell = lt_cells

          IF sy-subrc EQ 0.

               READ TABLE lt_cells INTO ls_cells INDEX 1.

               then use ls_cells-row_id for the further selection.

** READ TABLE it_final INTO wa_final INDEX ls_cells-row_id.

          ENDIF.

ENDIF.

I will also look for the another solution that I used for similar issues. Let me know if it works.

Read only

0 Likes
3,344

i used that one also but not getting.

WHEN 'MOD'.

      CLEAR: wa_final.

*      REFRESH i_selected_rowss.

     

      CALL METHOD c_alvgd->check_changed_data.

      CALL METHOD c_alvgd->get_selected_rows

        IMPORTING

          et_row_no = i_selected_rowss.

      LOOP AT i_selected_rowss INTO w_selected_rowss.

        READ TABLE it_final INTO wa_final INDEX w_selected_rowss-row_id.

      ENDLOOP.

      CALL SCREEN xyz STARTING AT 12 18

                  ENDING  AT 155 42.

endif.

      CALL METHOD c_alvgd->refresh_table_display

        EXPORTING

          is_stable = stable.

Read only

0 Likes
3,344

Hi,

Upon save and back to screen, the cursor is moved to a cell. So using the below code will choose the next one.

DATA: l_row TYPE i, l_col TYPE i.

Another Solution:-

CALL METHOD <grid>->get_current_cell

     IMPORTING

          e_row = l_row

          e_col = l_col.

IF l_row GE 1.

READ TABLE it_final INTO wa_final INDEX row.

ENDIF.

Read only

0 Likes
3,344

In this case whn selecting one row taht is dispalying and aftr coming back again if selecting another row only first row data is displaying.

Read only

0 Likes
3,344

Hi,

I have tested all the possibilities and it worked fine for me. Could you please remove that stable while refreshing table? I am not sure what are the values you pass to the structure lvc_s_stbl.

Also can you test by selecting the last row (anything other than first row) at first time and then selecting different row at the second time? The get_current_cell row should give the exact row where the cursor is.

Read only

0 Likes
3,344

Not working even my if i m doing two button functionality same time like if i m selecting any row on alv oops report and click on update button after that if selecting another row and clicking on delete button it is not working and if i am coming back and doing individually  it is working.

issue is only get_selected_rows.

thanx for your help .

but still not solved.

Read only

0 Likes
3,344

Hi,

Yes. The Method get_current_cell will select only one row. So call this Method only when the get_selected_rows returns zero rows. Is it possible for you to provide the logic while you create the grid object and set_table_for_first_display?

Read only

0 Likes
3,344

Yes

Read only

0 Likes
3,344

if i m changing that method and using this method same thing happening only when selecting second time only first row data is displaying.

DATA: l_row TYPE i, l_col TYPE i.

clear:l_row.

CALL METHOD c_alvgd->check_changed_data.

CALL METHOD c_alvgd->get_current_cell

     IMPORTING

          e_row = l_row

          e_col = l_col.

READ TABLE it_final INTO wa_final INDEX l_row.

Read only

0 Likes
3,344

Solved my issue .

Problem is only  when i ma displaying oops alv here i have to check frst object is initail aor grid is initial only these two if condition solved my issue.

IF c_ccont IS INITIAL.********** important

     CREATE OBJECT c_ccont

       EXPORTING

         container_name = 'CC_CONT'.

   ENDIF.

*create object of alv grid

   IF c_alvgd IS INITIAL. ******** important

     CREATE OBJECT c_alvgd

       EXPORTING

         i_parent = c_ccont.

   ENDIF.





thanx all for your help .