0

I need to delete the data from VBFA table which is an SLt table. We need to delete the data till Oct 2017. How we can achieve this as only date filed we have is MJAHR which is Material document year and ERDAT date on which record is created.

How we can delete the data till Oct 2017

Mayankb024
  • 11
  • 2

1 Answers1

0

Table [VBFA][1] (SAP Sales Document Flow Table and data) contains two fields that track when a record was created (ERDAT) and when it was last changed (AEDAT).

The way you describe the requirement, I understand it like this:

  • the table from which the data should be deleted is a replicated (via SLT replication) table in a HANA database that is not the actual transactional system.

  • all records that have been last changed before (but not including) October, 1st 2017 should be deleted from this table.

If this is correct, you could run a DELETE statement like this:

    DELETE FROM "VBFA" WHERE "AEDAT" < '20171001'

Note that this does only affect this table and not any related records in other tables. Also, if the table is partitioned, be aware that this command does not remove partitions that may be empty after the deletion.

Lars Br.
  • 9,949
  • 2
  • 15
  • 29
  • Don't know why but select count on this condition showing all the data in datable – Mayankb024 Nov 14 '19 at 10:34
  • Ok, how many records match the condition in the `WHERE` clause? – Lars Br. Nov 14 '19 at 10:39
  • almost all the records only few thousands are are left from the total count.if decrease the date value from oct to sep record count is only increasing . – Mayankb024 Nov 14 '19 at 10:44
  • And the count does not change after a successful `DELETE`? You may want to add **detailed** information about all commands you run to the question. – Lars Br. Nov 14 '19 at 10:49
  • i run the command "select count(*) from VBFa where "AEDAT" < '20170901' " to check how many records will be there and found query is selecting almost all the records. when i changed the date from oct to sep records count increased instead of decrease – Mayankb024 Nov 14 '19 at 10:55
  • i found we also have 0 values for AEDAT field hence it fetching those values too. – Mayankb024 Nov 15 '19 at 03:49