‎2008 Aug 28 9:09 PM
I have a custom table for some application.
I want to write a program which can reverse the entries in that table for the given selection.
Can you guys please help me with this, I've been able to achieve following:
Note: SYSTEMTIME is one of the primary keys of the table
Code below throws following error:
SAPSQL_ARRAY_INSERT_DUPREC
The ABAP/4 Open SQL array insert results in duplicate database records.
REPORT ZDIFF_REVERSE .
tables: ztable1.
data: itab like ztable1 occurs 0 with header line.
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME.
select-options: LOCATION for ztable1-LOCATION obligatory,
DATE for ztable1-DATE obligatory,
user for ztable1-user obligatory.
parameter: test as checkbox default 'X'.
SELECTION-SCREEN END OF BLOCK blk1.
*select * from ztable1 into table itab*
where LOCATION in LOCATION
and DATE in DATE
and user in user.
Loop at itab.
write:/ itab-LOCATION, itab-DATE, itab-user, itab-ORIGINALAMOUNT,
itab-CORRECTEDAMT, itab-DIFFAMT.
endloop.
if test = ' '.
loop at itab.
*itab-ORIGINALAMOUNT = -1 * itab-ORIGINALAMOUNT.*
*itab-CORRECTEDAMT = -1 * itab-CORRECTEDAMT.*
*itab-DIFFAMT = -1 * itab-DIFFAMT.*
itab-SYSTEMDATE = sy-datum.
itab-SYSTEMTIME = SY-UZEIT.
insert ztable1 from table itab.
endloop.
* *
endif.
‎2008 Aug 28 9:38 PM
Hi,
You didn't modify the internal table...and you are trying to insert the same records that you got.
Try this..
loop at itab.
itab-SYSTEMDATE = sy-datum.
itab-SYSTEMTIME = SY-UZEIT.
MODIFY itab.
endloop.
insert ztable1 from table itab.
Thanks
Naren
‎2008 Aug 28 9:34 PM
IF you want to reverse the records then why are you using insert instead of delete?
You are getting the dump because you are trying to insert records that are already there
‎2008 Aug 28 9:34 PM
Don't you think you first edit one element:
itab-SYSTEMDATE = sy-datum.
itab-SYSTEMTIME = SY-UZEIT.
and then you insert whole itab?
insert ztable1 from table itab.
It would be better to use table without header line...
reg.
wojciech.
‎2008 Aug 28 9:38 PM
Hi,
You didn't modify the internal table...and you are trying to insert the same records that you got.
Try this..
loop at itab.
itab-SYSTEMDATE = sy-datum.
itab-SYSTEMTIME = SY-UZEIT.
MODIFY itab.
endloop.
insert ztable1 from table itab.
Thanks
Naren
‎2008 Aug 29 2:28 PM
Narendra, you nailed it. Adding modifty solved..
In reference to earlier post, I dont want to delete it coz this table feeds BI for reporting. Inorder to have a consistent reporting I am reversing it.