Application Development 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: 

custom container

Former Member
0 Kudos

hi all,

how to capture the field values of the row we have selected from alv grid(custom container).

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Use this method to get the selected rows.

CALL METHOD g_alv->get_selected_rows

IMPORTING

et_row_no = lt_marked_rows.

and the the required table with the specific index l_fs_marked_row-row_id.

READ TABLE t_timesheet INTO fs_timesheet INDEX

l_fs_marked_row-row_id.

Hope it helps you.

Regards

Manjari.

10 REPLIES 10

Former Member
0 Kudos

Hi,

Check the sample standard code BCALV_DND_02.

Thanks & Regards,

Navneeth K.

Former Member
0 Kudos

Hi,

If you see the IMPORT parameters of the event double click It gives you the following information

E_ROW

E_COLUMN

ES_ROW_NO

That means you have the row no, and the column name on which the user has clicked. So, just read the internal table with the index of the row number and you should have the data.

Regards,

Omkaram.

0 Kudos

but the user will just single click. then how to do ?

Former Member
0 Kudos

Hi,

Use this method to get the selected rows.

CALL METHOD g_alv->get_selected_rows

IMPORTING

et_row_no = lt_marked_rows.

and the the required table with the specific index l_fs_marked_row-row_id.

READ TABLE t_timesheet INTO fs_timesheet INDEX

l_fs_marked_row-row_id.

Hope it helps you.

Regards

Manjari.

0 Kudos

Can u send me the code as i'm new to oops concept

0 Kudos

Hi Anil,

Here is a sample code

DATA : itab TYPE STANDARD TABLE OF zzzmaterial,"Output table

i_selected_rows TYPE lvc_t_row,"Selected Rows

w_selected_rows TYPE lvc_s_row,

i_modified TYPE STANDARD TABLE OF zzzmaterial,"For getting modified rows

w_modified TYPE zzzmaterial,

wa TYPE zzzmaterial,

o_docking TYPE REF TO cl_gui_docking_container,"Docking Container

o_grid TYPE REF TO cl_gui_alv_grid."Grid

  • Getting the selected rows index

CALL METHOD o_grid->get_selected_rows

IMPORTING

et_index_rows = i_selected_rows.

  • Through the index capturing the values of selected rows

LOOP AT i_selected_rows INTO w_selected_rows.

READ TABLE itab INTO wa INDEX w_selected_rows-index.

IF sy-subrc EQ 0.

MOVE-CORRESPONDING wa TO w_modified.

APPEND w_modified TO i_modified.

ENDIF.

ENDLOOP.

MODIFY zzzmaterial FROM TABLE i_modified.

Regards

Bala Krishna.

0 Kudos

Hi Bala,

but I'm using this in module pool..how to and where to write all this code..

0 Kudos

Hi,

Write in the PAI of the corresponding screen where you are displaying the Grid display.

Regards

Bala Krishna

0 Kudos

Hi,

Create the custom container in one screen and in the PBO of the screen write this code.

----


  • MODULE STATUS_0100 OUTPUT *

----


  • This module will create the objects for the instance and display *

  • the records *

----


MODULE status_0100 OUTPUT.

SET PF-STATUS c_alv_scr.

PERFORM set_titlebar USING w_display.

  • If program executed in foreground.

IF sy-batch IS INITIAL.

  • If g_grid is empty.

IF g_grid IS INITIAL.

  • To create object for instance grid

CREATE OBJECT g_grid

EXPORTING

container_name = g_container.

  • To create object for object grid

CREATE OBJECT g_alv

EXPORTING

i_parent = g_grid.

ENDIF. " IF G_GRID IS INITIAL

ENDIF. " IF SY-BATCH IS INITIAL

REFRESH t_fcat.

DATA: lt_exclude TYPE ui_functions.

  • To exclude buttons on the ALV grid

PERFORM exclude_tb_functions CHANGING lt_exclude.

  • To display ALV

CALL METHOD g_alv->set_table_for_first_display

EXPORTING

i_default = space

is_layout = g_fcatlayo

it_toolbar_excluding = lt_exclude

CHANGING

it_outtab = pr_table[]

it_fieldcatalog = pr_fcat[].

ENDIF. " IF W_SUBMIT EQ C_BOOLEAN_YES

ENDMODULE. " STATUS_0100 OUTPUT

In the PAI of the screen write this code.

DATA:

lt_marked_rows TYPE lvc_t_roid, " Table to get rowid

l_fs_marked_row LIKE LINE OF lt_marked_rows.

" Field-string for lt_marked_rows

  • To get all the selected rows in the table lt_marked_rows

CALL METHOD g_alv->get_selected_rows

IMPORTING

et_row_no = lt_marked_rows.

  • Reading each row id and updating the database.

LOOP AT lt_marked_rows INTO l_fs_marked_row.

  • Reading the table t_timesheet with rowid

READ TABLE t_timesheet INTO fs_timesheet INDEX

l_fs_marked_row-row_id.

  • If record is there in the table.

IF sy-subrc EQ 0.

CLEAR fs_timesheet-appstatus.

GET PARAMETER ID 'ZEMPID' FIELD w_empid.

  • Changing the appstatus.

fs_timesheet-appstatus = pr_status.

fs_timesheet-approvedby = w_empid.

  • Updating the database table.

UPDATE zcl_timesheet FROM fs_timesheet.

IF sy-subrc EQ 0.

fs_temp-empid = fs_timesheet-empid.

fs_temp-workdate = fs_timesheet-workdate.

fs_temp-linenum = fs_timesheet-linenum.

append fs_temp to t_temp.

ENDIF. " IF SY-SUBRC EQ 0.

ENDIF. " IF SY-SUBRC EQ 0

ENDLOOP. " LOOP AT LT_MARKED_ROWS...

perform delete_data .

Hope it helps you.

Regards

Manjari

0 Kudos

Hi,

Create the custom container in one screen and in the PBO of the screen write this code.

----


  • MODULE STATUS_0100 OUTPUT *

----


  • This module will create the objects for the instance and display *

  • the records *

----


MODULE status_0100 OUTPUT.

SET PF-STATUS c_alv_scr.

PERFORM set_titlebar USING w_display.

  • If program executed in foreground.

IF sy-batch IS INITIAL.

  • If g_grid is empty.

IF g_grid IS INITIAL.

  • To create object for instance grid

CREATE OBJECT g_grid

EXPORTING

container_name = g_container.

  • To create object for object grid

CREATE OBJECT g_alv

EXPORTING

i_parent = g_grid.

ENDIF. " IF G_GRID IS INITIAL

ENDIF. " IF SY-BATCH IS INITIAL

REFRESH t_fcat.

DATA: lt_exclude TYPE ui_functions.

  • To exclude buttons on the ALV grid

PERFORM exclude_tb_functions CHANGING lt_exclude.

  • To display ALV

CALL METHOD g_alv->set_table_for_first_display

EXPORTING

i_default = space

is_layout = g_fcatlayo

it_toolbar_excluding = lt_exclude

CHANGING

it_outtab = pr_table[]

it_fieldcatalog = pr_fcat[].

ENDIF. " IF W_SUBMIT EQ C_BOOLEAN_YES

ENDMODULE. " STATUS_0100 OUTPUT

In the PAI of the screen write this code.

DATA:

lt_marked_rows TYPE lvc_t_roid, " Table to get rowid

l_fs_marked_row LIKE LINE OF lt_marked_rows.

" Field-string for lt_marked_rows

  • To get all the selected rows in the table lt_marked_rows

CALL METHOD g_alv->get_selected_rows

IMPORTING

et_row_no = lt_marked_rows.

  • Reading each row id and updating the database.

LOOP AT lt_marked_rows INTO l_fs_marked_row.

  • Reading the table t_timesheet with rowid

READ TABLE t_timesheet INTO fs_timesheet INDEX

l_fs_marked_row-row_id.

  • If record is there in the table.

IF sy-subrc EQ 0.

CLEAR fs_timesheet-appstatus.

GET PARAMETER ID 'ZEMPID' FIELD w_empid.

  • Changing the appstatus.

fs_timesheet-appstatus = pr_status.

fs_timesheet-approvedby = w_empid.

  • Updating the database table.

UPDATE zcl_timesheet FROM fs_timesheet.

IF sy-subrc EQ 0.

fs_temp-empid = fs_timesheet-empid.

fs_temp-workdate = fs_timesheet-workdate.

fs_temp-linenum = fs_timesheet-linenum.

append fs_temp to t_temp.

ENDIF. " IF SY-SUBRC EQ 0.

ENDIF. " IF SY-SUBRC EQ 0

ENDLOOP. " LOOP AT LT_MARKED_ROWS...

perform delete_data .

Hope it helps you.

Regards

Manjari