Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

delete record from Datapackage

Former Member
0 Likes
696

hello all experts,

One simple question.

I have an internal table and one ODS/InfoCube datapackage.

which statement should I use to let datapackage only keep the records in that internal table, delete all others?

Appreciate it!

Linda

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
639

In ABAP there is not single statement to do that. You can do that if you were deleting all records that are in the internal table, but not the other way around.

You will have to get all the records of the database that you want to delete into an internal table, then you can do the statement...

DELETE ZTABLE FROM TABLE itab.

This statement deletes all of the records from the database table ZTABLE where the record matches in the ITAB internal table.

Regards,

Rich Heilman

4 REPLIES 4
Read only

Former Member
0 Likes
639

Pls find attached code of fm to delete data from ODS in BW.

CALL FUNCTION 'RSDRI_ODSO_DELETE_RFC'

EXPORTING

I_ODSOBJECT = 'ZTXHDCNT'

TABLES

I_T_RANGE = i_range

EXCEPTIONS

DATA_TARGET_NOT_ODS = 1

ODS_TYPE_NOT_TRANSACTIONAL = 2

CONFLICTING_DELETION_CRITERIA = 3

DELETE_FAILED = 4

INTERNAL_ERROR = 5

OTHERS = 6.

if sy-subrc eq 0.

write: / 'success'.

endif.

You can populate range of desired data to be deleted and it will delete data from ODS which satisfies the criteria.

In you case you need to compare data with internal table. So i suggest you following solution -

Loop at datapackage.

read Internal table and check if record exist.

if does not exist, delete record from datapackage.

endloop.

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
640

In ABAP there is not single statement to do that. You can do that if you were deleting all records that are in the internal table, but not the other way around.

You will have to get all the records of the database that you want to delete into an internal table, then you can do the statement...

DELETE ZTABLE FROM TABLE itab.

This statement deletes all of the records from the database table ZTABLE where the record matches in the ITAB internal table.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
639

Hi Linda,

Loop at datapackage.

read Internal table and check if record exist.

if does not exist, delete record from datapackage.

endloop.

LOOP AT <DATAPAC NAME>.

READ TABLE ITAB <WHERE CONDITION>.

IF SY-SUBRC = 0.

CONTINUE.

ELSE.

DELETE ITAB.

ENDIF.

ENDLOOP.

Read only

Former Member
0 Likes
639

Thank you very much!

Points awarded.

Linda