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.
Showing results for 
Search instead for 
Did you mean: 

Save data from few row in alv grid with dialog programming (input/ouput field)

0 Kudos

I have alv grid and input field in dialog programming

in first screen display alv grid cl gui

for example i selected 2 record with the same value (sales org, dis channel, division, terget type and type)

so i able to using button update and processing the data

the screen look like this

the value for rebate type and terget type if i change the value its must be changed to in 2 records i selected previously...

i using this syntax in save button

      LOOP AT gt_drebate INTO wa_drebate.
IF sy-subrc = 0.
UPDATE tablename SET
krech = tablename-krech.

can somebody help me guide how to solve this...

any help or guide would be greatful


Active Contributor
0 Kudos

I think you continue to make a confusion between : Transparent table and Internal table.

Internal table exist only in memory, in your program it is GT_DREBATE. This is not in your database.

The ALV display the data of the internal table, not the database table.

If you want to change the value of the ALV, you have to change the value of the Internal table GT_DREBATE.

When you select the field UPDATE and press F1, you will see in the documentation Update database or Update internal table. The statement is different.

Second point : Where did you populate TABLENAME-KRECH ?

0 Kudos

tablename-krech is my input screen in screen painter

in my code.. if i press save button all data with field krech changed

I onyl need two record (only selected record)

Active Contributor
  • Remove the subrc check in the LOOP.
  • In the UPDATE dbtab statement if you use the SET option, provide the primary keys of the table from record in a WHERE clause
  • Is this a custom database table (direct update of table)
  • I hesitate to remind you that with CL_GUI_ALV_GRID you can make certain columns modifiable and eliminate the need to display an update pop-up screen.

Active Contributor
0 Kudos

It's always wrong to do IF sy-subrc = 0 right after LOOP AT.

      LOOP AT gt_drebate INTO wa_drebate.
          IF sy-subrc = 0. "<==================== always wrong

Maybe you are confusing with:

      LOOP AT gt_drebate INTO wa_drebate WHERE ...
        " process each line ...
      IF sy-subrc = 0. " right after ENDLOOP
        " AT LEAST ONE LINE WAS FOUND (especially useful if there's a WHERE in LOOP AT)

0 Kudos

yeah thank u so much i solve my problem with... I add where sel 'X' and where in update stement so that able to find which row i need to update the data

      LOOP AT gt_drebate INTO wa_drebate WHERE sel = 'X'.
UPDATE tablename
SET krech = @tablename-krech,
type = @tablename-type
WHERE rbt = @wa_drebate-rbt AND
vkorg = @wa_drebate-vkorg.