0
votes

I have a table let's call it "dbtab". The name of my internal table is "it_tab".

I have a number in "new_number".

I insert that number into the empty field "laufnr" in my dbtab by using:

update dbtab set laufnr = new_number where laufnr = ''.

This Works just fine, but the changes aren't in my it_tab.

How do I update my internal table from my dbtab?

Or how do I insert a value to a specific field in my internal table?

4

4 Answers

2
votes

You have two options:

  1. Update your internal table when you update the database table with something like: LOOP AT it_tab ASSIGING <tab> WHERE laufnr = ''. <tab>-laufnr = new_number. ENDLOOP.
  2. Reread the data from the database table into your internal table after you have made the update to the database.
0
votes

You could update your itab almost the same like a database table .. the only difference is, that you cannot use "update" ... use "modify" instead.

modify it_tab set laufnr = new_number where laufnr = '' .

An other option would be a simply reload of your dbtab

CLEAR it_tab.
SELECT * INTO it_tab FROM dbtab WHERE .... .
0
votes

There are two different things, and they are not linked. An internal table is a representation of a dataset in a specific moment in time. A database table is the data itself up to date. You can manage to change any of them, but not both at the same time with a single instruction. I will reccomend to: - update your database - refresh the in-memory copy TIP: if you want to do it "the hard way", just create an object, and do both things in some sort of UPDATE method.

0
votes

hi try this hope it helps

LOOP AT it_tab.
   it_tab-lufnr = new_number.
   MODIFY it_tab TRASNPOTING laufnr WHERE laufnr = ''.
ENDLOOP.

or with conditions

 LOOP AT it_tab where laufnr = ''.
   it_tab-lufnr = new_number.
   MODIFY it_tab TRASNPOTING laufnr WHERE laufnr = ''.
 ENDLOOP.