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

Saving Data from ALV.

Former Member
0 Likes
1,103

hi all.

I have an issue regarding saving data from alv to data base table.

The problem is like this. I have an internal table consist of 10 column from three diferent tables.one primary key is there.

now i have displayed it in alv grid. there is a column of quantity. i made some changes in quantity of some rows. now i want to save it into the database table from which that quantity field fetched.

i used first check_changed_data method. if the flag is set it means data is changed.

wat shud i do to save that quantity column into data base.

Thanks In advance.

varu

4 REPLIES 4
Read only

Former Member
0 Likes
680

Use the GET_CHANGED_DATA method to get the cahnged data.

Once you have the data in the internal table, you can move it to an internal table which has the same structure as the Z table and then use UPDATE/ MODIFY/ INSERT statements to update the table.

Regards,

Ravi

Read only

Former Member
0 Likes
680

Hi,

<b>To modify database or ztable from the ALV grid,you need to do the following:</b>

---You have to modify the field Catalog fields (fields that you want to make editable).Set the field <b>EDIT as 'X'</b>.For example if you want to make the field below editable:

ls_fcat-fieldname = 'CARRID'.

...

...

ls_fcat-edit = 'X'.

APPEND ls_fcat TO pt_fieldcat.

---Call the method below before you call the set_table_for_first_display.

CALL METHOD ALV_GRID_INSTANCE-><b>set_ready_for_input</b>

EXPORTING

i_ready_for_input = 0. ( For Display ) and ('1' for Edit )

After this put the set_table_for_first_display.

<b>Now if the ALV data has changed,and you want to change the database or ztable,then in your pf status give a function code for SAVE button in the GUI.

In the PAI of the screen,in user command module write the following:</b>

WHEN 'SAVE'.

<b>call method gr_alvgrid->check_changed_data</b>

importing e_valid = l_valid.

if l_valid = 'X'.

<b>MODIFY spfli FROM TABLE itab_spfli.</b>

endif.

<b>(l_valid is a flag.</b>

DATA:l_valid type c.

If you want to check if the user has entered any value on the grid, use the Method : CALL METHOD gr_alvgrid->check_changed_data.

This method returns a flag l_valid which can be checked to see if the data on the ALV grid has been changed or not.)

Regards,

Beejal

**Reward if this helps

Read only

Former Member
0 Likes
680

use update command as below.

UPDATE <ZTABLE> SET QTY = QTY

WHERE <CONDITION>.

Read only

Former Member
0 Likes
680

If the data already exists the UPDATE the data base tabel based on the current entries in ur ALV grid.

IF not INSERT the record into ur table from output Grid.

Reward if this helps.