Scope:

Generally Selective deletion from DSO is done manually. This Document explains how to automate selective deletion from DSO through ABAP Code in transformations.

Scenario:

We have 2 Key fields and 4 data fields in DSO. We need to do selective deletion based on One of the key field value. Sample data is give as below.

Contents of Active table in DSO:

Uname(KF) Bpno(KF) DF1 DF2 DF3 DF4
A101

1

10

20

30

40

A101

2

11

21

31

41

A101

3

12

22

32

42

A101

4

13

23

33

43

A101

5

14

24

34

44

A102

1

15

25

35

45

A103

2

16

26

36

46

A103

5

17

27

37

47

A103

9

18

28

38

48

Above data is active table content of DSO. In next data load if we get new record whose Uname is A101 then it should delete all records from active table whose Uname is A101 and insert new records.

Records in New data load:

Uname Bpno DF1 DF2 DF3 DF4
A101

6

30

45

67

78

A101

5

55

54

23

54

Final contents of Active table:

Uname Bpno DF1 DF2 DF3 DF4
A101

6

30

45

67

78

A101

5

55

54

23

54

A102

1

15

25

35

45

A103

2

16

26

36

46

A103

5

17

27

37

47

A103

9

18

28

38

48

Procedure:

For Selective deletion of the records and Inserting new records following procedure is adopted.

  1. Get unique usernames (Uname) from the new records which should be loaded into DSO.
  2. For corresponding unique username (Uname) select all entries from Active table of DSO.
  3. Now in the internal table we have records which need to be deleted (records which are selected from DSO active table) and records which need to be updated.
  4. 4.Insert First set of records with record mode ‘D’, and second set without any manipulation.

So, upon activation all the records in active table for which a username exists in New records which are to be loaded will be deleted.

Above mentioned procedure should be carried out in END ROUTINE.

For example:

If following records exists in DSO

Username BPARTNER DF1 DF2 DF3 DF4
A101

1

10

20

30

40

A101

2

11

21

31

41

A101

3

12

22

32

42

A101

4

13

23

33

43

A101

5

14

24

34

44

And following records are to be loaded

Username BPARTNER DF1 DF2 DF3 DF4
A101

6

30

45

67

<span