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

getting data from alv

Former Member
0 Likes
2,214

Hi All,

I have a report which display's the output in ALV grid. i also have checkbox to all the rows.

my requirement is that if i check any checkbox of a particular row, i should be able to take that data in intenal table.

how to achieve this?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,436

Hi,

You need to write the following code in the User-Command routine :


  DATA: GD_REPID LIKE SY-REPID,
  REF_GRID TYPE REF TO CL_GUI_ALV_GRID.

  DATA: L_VALID TYPE C.

*Code to reflect the changes done in the internal table

  IF REF_GRID IS INITIAL.
    CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
      IMPORTING
        E_GRID = REF_GRID.
  ENDIF.

  IF NOT REF_GRID IS INITIAL.

    CALL METHOD REF_GRID->CHECK_CHANGED_DATA
      IMPORTING
        E_VALID = L_VALID.

  ENDIF.

LOOP AT IT_MAT WHERE CHK = 'X'.
"Process your logic here
ENDLOOP.

Thanks & Regards,

Rock.

5 REPLIES 5
Read only

Former Member
0 Likes
1,437

Hi,

You need to write the following code in the User-Command routine :


  DATA: GD_REPID LIKE SY-REPID,
  REF_GRID TYPE REF TO CL_GUI_ALV_GRID.

  DATA: L_VALID TYPE C.

*Code to reflect the changes done in the internal table

  IF REF_GRID IS INITIAL.
    CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
      IMPORTING
        E_GRID = REF_GRID.
  ENDIF.

  IF NOT REF_GRID IS INITIAL.

    CALL METHOD REF_GRID->CHECK_CHANGED_DATA
      IMPORTING
        E_VALID = L_VALID.

  ENDIF.

LOOP AT IT_MAT WHERE CHK = 'X'.
"Process your logic here
ENDLOOP.

Thanks & Regards,

Rock.

Read only

Former Member
0 Likes
1,436

A little search could solve you problem more quickly.

refer>

Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
1,436

Hi,

Refer this wiki code by me on ALV Grid Display with checkbox to process selected records at runtime

It will definitely help you.

https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/alv%252bgrid%252bdisplay%252bwith%252bch...

Regards,

Tarun

Read only

Former Member
0 Likes
1,436

Hi Poonam,



* to reflect the data changed into internal table try doing like this:

      DATA : ref_grid TYPE REF TO cl_gui_alv_grid. "new
 
      IF ref_grid IS INITIAL.
        CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
          IMPORTING
            e_grid = ref_grid.
      ENDIF.
 
      IF NOT ref_grid IS INITIAL.
        CALL METHOD ref_grid->check_changed_data.
      ENDIF.


Hope it helps

Regrds

Mansi

Read only

sarbajitm
Contributor
0 Likes
1,436

The below mention process is to

1)First keep a checkbox in your ALV display so that you can mark the row that you wan to delete.

to do so what you have to do is keep a field like below in your final ITAB that you want to ALVdisplay.

BEGIN OF T_final ,

chk(1) TYPE c, for making checkbox..

............

..............

END OF T_final.

2) Then when you create the field catalog for the checkbox(chk field of your ITAB)

write down the following code

WA_fieldcat-fieldname = 'CHK'.

WA_fieldcat-seltext_m = 'CheckBox'.

WA_fieldcat-checkbox = 'X'.

WA_fieldcat-edit = 'X' .

WA_fieldcat-input = 'X'.

WA_fieldcat-tabname = 'IT_FINAL'.

WA_fieldcat-col_pos = 1.

APPEND WA_fieldcat TO IT_fieldcat.

CLEAR WA_fieldcat.

3) Declare a data at your data section of the report

DATA : lc_s_glay TYPE lvc_s_glay.

then before calling REUSE_ALV_GRID_DISPLAY

just write down the following piece of code

lc_s_glay-edt_cll_cb = 'X'.

In the REUSE_ALV_GRID_DISPLAY FM

you must set the follwing 2 Exporting Parameter

i) i_callback_user_command = 'USER_COMMAND'

ii) i_grid_settings = lc_s_glay

for i) write down the following subroutine........

FORM user_command USING I_r_ucomm LIKE sy-ucomm

rs_selfield TYPE slis_selfield.

DATA: l_out_string TYPE string,

l_out_final TYPE ekpo-menge,

l_cntr TYPE i.

CASE I_r_ucomm.

WHEN 'SEL1'. assuming your Fcode

loop at itab into wa_itab where chk = 'X'.

append wa_itab to itab2.

ENDCASE.

ENDFORM.

hope it solve your problem.

Edited by: Sarbajit Majumdar on Mar 16, 2009 12:37 PM