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: 

To get values from editable ALV

Former Member
0 Kudos

HI,

I have a requirement where i have to display data in ALV.

when we select record and press on push button edit it should display a pop-up

with quantity and UOM fields as editable and when pressing OK it should modify data

in main ALV .

I have facing problem to get the changes quantity and UOM .

please let me know how to get the changed value .

Thanks,

Shobhit

8 REPLIES 8

Former Member

Hi Shobhit,

As far I know, The ALV Grid has events data_changed and data_changed_finished. The former method is triggered just after the change at an editable field is perceived. Here you can make checks for the input. And the second event is triggered after the change is committed.

You can select the way how the control perceives data changes by using the method register_edit_event. You have two choices:

i. After return key is pressed: To select this way, to the parameter i_event_id pass cl_gui_alv_grid=>mc_evt_enter.

ii. After the field is modified and the cursor is moved to another field: For this, pass cl_gui_alv_grid=>mc_evt_modifies to the same parameter.

To make events controlling data changes be triggered, you must select either way by calling this method. Otherwise, these events will not be triggered.

To control field data changes, ALV Grid uses an instance of the class CL_ALV_CHANGED_DATA_PROTOCOL and passes this via the event data_changed. Using methods of this class, you can get and modify cell values and produce error messages

A sample code snippet for your reference:-

FORM handle_data_changed USING ir_data_changed
TYPE REF TO cl_alv_changed_data_protocol.
DATA : ls_mod_cell TYPE lvc_s_modi ,
lv_value TYPE lvc_value .
SORT ir_data_changed->mt_mod_cells BY row_id .
LOOP AT ir_data_changed->mt_mod_cells
INTO ls_mod_cell
WHERE fieldname = 'SEATSMAX' .
CALL METHOD ir_data_changed->get_cell_value
EXPORTING i_row_id = ls_mod_cell-row_id
i_fieldname = 'CARRID'
IMPORTING e_value = lv_value .
IF lv_value = 'THY' AND ls_mod_cell-value > '500' .
CALL METHOD ir_data_changed->add_protocol_entry
EXPORTING
i_msgid = 'SU'
i_msgno = '000'
i_msgty = 'E'
i_msgv1 = 'This number can not exceed 500 for '
i_msgv2 = lv_value
i_msgv3 = 'The value is et to ''500'''
i_fieldname = ls_mod_cell-fieldname
i_row_id = ls_mod_cell-row_id .
CALL METHOD ir_data_changed->modify_cell
EXPORTING i_row_id = ls_mod_cell-row_id
i_fieldname = ls_mod_cell-fieldname
i_value = '500' .
ENDIF .
ENDLOOP .
ENDFORM"handledatachanged

Former Member
0 Kudos

Hi,

Create a new screen say 9000 and call it in the user command section of your ALV when the pushbutton is pressed.

CALL SCREEN 9000 starting at xxxx ending on yyyy.

In the PBO of this screen populate the selected record data.

You can then capture the values of the modified the records in the PAI of the new screen and modify the internal table with the new values.

Regards,

Nilesh.

0 Kudos

Hi,

This is not at all acceptable & is not possible. ALV grid has some nice options which I have already posted in my previous post on this question.

Regards

Abhii

0 Kudos

Hi Abhii,

Not sure what do you mean by not at all acceptable and possible. I have done this various times in the past where user needs a pop up with the default values. The requirement is to display the pop up before editing the fields.

Regards,

Nilesh.

0 Kudos

check this....

0 Kudos

Hi Nilesh,

I agree with you. you are correct. I have tried doing this & I have succeeded.

The small code snippet, I have tried as below :-

*&---------------------------------------------------------------------*
*& Report  ZTEST6                                                      *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*&                                                                     *
*&---------------------------------------------------------------------*

REPORT  ztest6 MESSAGE-ID zabhii.
TABLES: mara, sscrfields.
DATA: itab like mara occurs 1 with header line,
      count(5) type n,
      result(60) type c.




SELECTION-SCREEN BEGIN OF BLOCK blk WITH FRAME TITLE text-001 .

SELECT-OPTIONS: mat_num FOR mara-matnr.

SELECTION-SCREEN END OF BLOCK blk.

SELECTION-SCREEN FUNCTION KEY 1.

SELECTION-SCREEN BEGIN OF SCREEN 123 AS WINDOW TITLE text-002.
SELECTION-SCREEN COMMENT /10(60) text003.
selection-screen skip 2.

   SELECTION-SCREEN END OF SCREEN 123.

initialization.
 sscrfields-functxt_01 = 'Number of Entries'.


 AT SELECTION-SCREEN.
   IF sscrfields-ucomm = 'FC01'.
   IF MAT_NUM-LOW = ' ' OR MAT_NUM-HIGH = ' '.
    TEXT003 = 'NO VALUES FOUND'.
    CALL SELECTION-SCREEN 123 STARTING AT 5 10.
   ELSE.
   perform display.
   CALL SELECTION-SCREEN 123 STARTING AT 5 10.
   ENDIF.
endif.


*&---------------------------------------------------------------------*
*&      Form  display
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form display .
select * from mara into corresponding fields of table itab where
matnr in mat_num.

count = sy-dbcnt.
result = 'Number of entries matching the selection criteria'.

concatenate result '   = ' count into text003.

endform.                    " display

0 Kudos

Hi Nilesh,

I agree with you. you are correct. I have tried doing this & I have succeeded.

The small code snippet, I have tried as below :-

*&---------------------------------------------------------------------*
*& Report  ZTEST6                                                      *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*&                                                                     *
*&---------------------------------------------------------------------*

REPORT  ztest6 MESSAGE-ID zabhii.
TABLES: mara, sscrfields.
DATA: itab like mara occurs 1 with header line,
      count(5) type n,
      result(60) type c.




SELECTION-SCREEN BEGIN OF BLOCK blk WITH FRAME TITLE text-001 .

SELECT-OPTIONS: mat_num FOR mara-matnr.

SELECTION-SCREEN END OF BLOCK blk.

SELECTION-SCREEN FUNCTION KEY 1.

SELECTION-SCREEN BEGIN OF SCREEN 123 AS WINDOW TITLE text-002.
SELECTION-SCREEN COMMENT /10(60) text003.
selection-screen skip 2.

   SELECTION-SCREEN END OF SCREEN 123.

initialization.
 sscrfields-functxt_01 = 'Number of Entries'.


 AT SELECTION-SCREEN.
   IF sscrfields-ucomm = 'FC01'.
   IF MAT_NUM-LOW = ' ' OR MAT_NUM-HIGH = ' '.
    TEXT003 = 'NO VALUES FOUND'.
    CALL SELECTION-SCREEN 123 STARTING AT 5 10.
   ELSE.
   perform display.
   CALL SELECTION-SCREEN 123 STARTING AT 5 10.
   ENDIF.
endif.


*&---------------------------------------------------------------------*
*&      Form  display
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form display .
select * from mara into corresponding fields of table itab where
matnr in mat_num.

count = sy-dbcnt.
result = 'Number of entries matching the selection criteria'.

concatenate result '   = ' count into text003.

endform.                    " display

Regards

Abhii

Former Member
0 Kudos

Hi. Unless I have misunderstood your issue which is quite possible knowing me then I think it is quite easy.

Are you using OO ALV or are you using the function module REUSE_ALV_GRID_DISPLAY?

If you are using OO then just call method check_changed_data.

If you are using the function module then in the user command form put code similar to this:

data: lc_alv TYPE REF TO cl_gui_alv_grid.

CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'

IMPORTING

e_grid = lc_alv.

CALL METHOD lc_alv->check_changed_data.

Then the internal table that you called the ALV with oringinally will have the values that you have changed.

Sorry if I have misunderstood.

Regards,

Dave.