
Generally Selective deletion from DSO is done manually. This Document explains how to automate selective deletion from DSO through ABAP Code in transformations.
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 |
For Selective deletion of the records and Inserting new records following procedure is adopted.
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 | 78 |
A101 | 5 | 55 | 54 | 23 | 54 |
Then records Final records that will be inserted into result package are as follows:
Username | BPARTNER | DF1 | DF2 | DF3 | DF4 | Record Mode |
A101 | 1 | 10 | 20 | 30 | 40 | D |
A101 | 2 | 11 | 21 | 31 | 41 | D |
A101 | 3 | 12 | 22 | 32 | 42 | D |
A101 | 4 | 13 | 23 | 33 | 43 | D |
A101 | 6 | 30 | 45 | 67 | 78 | |
A101 | 5 | 55 | 54 | 23 | 54 |
Below is ABAP Code that should be written in END ROUTINE:
DATA: it_result1 TYPE STANDARD TABLE OF _ty_s_TG_1,
it_result2 TYPE STANDARD TABLE OF _ty_s_TG_1,
wa_result1 TYPE _ty_s_TG_1,
wa_result2 TYPE _ty_s_TG_1,
v_tabsize TYPE i,
v_tabix TYPE i.
*Below code is to pull unique username's from flat file which is
*avaialable in reult_package(Flat file).
it_result1 = RESULT_PACKAGE.
sort it_result1 by USERNAME.
delete ADJACENT DUPLICATES FROM it_result1 COMPARING USERNAME.
* To extract the exsisting contents of DSO's Active table.
select * into CORRESPONDING FIELDS OF TABLE it_result2 from
<DSO ACTIVE TABLE>
FOR ALL ENTRIES IN it_result1 where username = it_result1-username.
DESCRIBE TABLE RESULT_PACKAGE LINES v_tabsize.
loop at it_result2 into wa_result2 .
READ TABLE it_result1 into wa_result1 WITH KEY username =
wa_result2-username.
if sy-subrc = 0 and wa_result1-BPARTNER <> wa_result2-BPARTNER.
v_tabsize = v_tabsize + 1.
wa_result2-RECORD = v_tabsize.
wa_result2-RECORDMODE = 'D'.
append wa_result2 to RESULT_PACKAGE.
endif.
CLEAR: wa_result2,
wa_result1.
endloop.
· 1. Automates process of Selective deletion.
· 2. By using selective deletion option in manage TAB of DSO, we can only delete data from active table but not from change log table, but this approach synchronizes both change log and active table in spite of selective deletion.
· 3. Data between the DSO and its upper target (at any level) will also be synchronized automatically.
http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/5080c337-81e5-2c10-97af-8929424f3a4b
http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/d032758c-a61c-2e10-eb9f-afb1460f920d
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
10 | |
5 | |
4 | |
4 | |
4 | |
3 | |
3 | |
3 | |
3 | |
2 |