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: 

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

acetedi
Participant
0 Kudos
495

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.
ENDIF.
ENDLOOP.

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

any help or guide would be greatful

5 REPLIES 5

FredericGirod
Active Contributor
0 Kudos
445

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 ?

acetedi
Participant
0 Kudos
445

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)

raymond_giuseppi
Active Contributor
445
  • 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.

Sandra_Rossi
Active Contributor
0 Kudos
445

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 ...
      ENDLOOP.
      IF sy-subrc = 0. " right after ENDLOOP
        " AT LEAST ONE LINE WAS FOUND (especially useful if there's a WHERE in LOOP AT)
      ENDIF.

acetedi
Participant
0 Kudos
445

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.
ENDLOOP.