2023 Jul 12 7:37 AM
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
2023 Jul 12 8:04 AM
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 ?
2023 Jul 12 8:26 AM
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)
2023 Jul 12 8:40 AM
2023 Jul 12 8:51 AM
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.
2023 Jul 12 9:05 AM
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.