‎2011 Mar 03 6:56 PM
Hi,
I am using
MODIFY <DB Table> FROM TABLE <ITAB>.
ITAB has a single line that does not exist in DB table. But still it does not create a new record in DB table.
The sy-subrc is 0.
COuld some one please help me figure out why this is not working.
Thank you.
‎2011 Mar 03 7:24 PM
A single line - are you sure it's in the table and not just the header?
Rob
‎2011 Mar 03 7:09 PM
itab is the same structure/type as the database table? itab contains the client/mandt value? Always works for me...
‎2011 Mar 03 7:18 PM
Hi,
I have the MANDT field in the table and ITAB.
ITAB is of the type as that of the internal table. So no type difference.
I have even tried specifying CLIENT SPECIFIED.
The sy-subrc is ZERO but this record does not get inserted...
Any thoughts...
Thank you.
‎2011 Mar 03 7:40 PM
F1 Help excerpt:
Alternative 2 ... FROM TABLE itab
Effect
If an itab internal table is specified, the system processes all lines in the internal table according to the rules for the wa work area. The line type of the internal table has to meet the requirements for use in Open SQL statements.
If the change to a line in the internal table would lead to a double entry in a unique secondary index, the corresponding line is not inserted and sy-subrc is set to 4. If the internal table is empty, sy-subrc is set to 0. The sy-dbcnt system field is always set to the number of lines that were actually processed.
Also check the sy-dbcnt?
Kind regards,
Robert
‎2011 Mar 03 7:12 PM
'MODIFY' statement checks if there is an entry with the same primary key in the database table and makes corresponding changes. If the primary key value exists, it replaces, if not, it creates one. Make sure your primary key has proper values in internal table.
‎2021 Feb 24 10:36 AM
‎2011 Mar 03 7:24 PM
A single line - are you sure it's in the table and not just the header?
Rob
‎2011 Mar 03 8:32 PM
This is the code that I am trying to execute:
DATA: gt_temp LIKE TABLE OF ztemp,
wa_temp TYPE ztemp.
wa_temp-mandt = sy-mandt.
wa_temp-zplatformkey = 'AT'.
wa_temp-zplatformacctid = '597'.
wa_temp-lifnr = '0013650035'.
APPEND wa_temp TO gt_temp.
BREAK-POINT.
MODIFY ztemp FROM TABLE gt_temp .
BREAK-POINT.
This record does not exist in the table but still, it does not get updated.
SY-SUBRC is 0. SY-DBCNT is 1 and SY-TABIX is 1.
There is another keyfield which I am sending it as BLANK. There are entries with field as blank in the table, but we do not have this key combination record in the table.
‎2011 Mar 03 8:39 PM
BREAK-POINT.
MODIFY ztemp FROM TABLE gt_temp .
" add this:
COMMIT WORK.
BREAK-POINT.Regards, Sebastian
‎2011 Mar 03 8:43 PM
If sy-subrc = 0 and sy-dbcnt = 1, then a record was created. Go to SE16 and search the table with
zplatformkey = 'AT'. There should be something there.
Rob
‎2011 Mar 03 8:46 PM
I had this in my mind, but I was like "NO NEED TO COMMIT AFTER A MODIFY TABLE" as I have never done this in my 5 years of ABAP development.
I was wrong...
Thank you Sebastian... COMMIT work helped...
But isnt this weird?????????????????
My apologies if I sound like a fool.. But I have never done a commit after a modify table in my life...
‎2011 Mar 03 8:47 PM
No Rob, no records in the table... COMMIT worked... really freaked out now..
‎2011 Mar 03 8:53 PM
WEre you looking at the table in SE16 after the break-point, but before the program finished??
Rob
‎2011 Mar 03 8:55 PM
No Rob, I was very careful. I had a friend of mine look into this as well.
Any idea why I have to specify a COMMIT work explicitly?
Thank you.
‎2011 Mar 03 7:26 PM
Hi,
Try reading the itab into work area.
Then modify DB Tab from work area.
Regards,
‎2011 Mar 04 8:05 PM
hmmm... I don't use Modify. I use Update <dbtabname> from <workarea>