Quantcast
Channel: SCN: Message List - Data Warehousing
Viewing all articles
Browse latest Browse all 3366

Re: Start Routine - Delete Data w/ No Matching Record In Target

$
0
0

Hi Larry,

 

I fear with both approaches that it can lead to technical problems. SQL select statements cannot deal with thousands of distinct values. Also FOR ALL ENTRIES without a distinct list of values can lead to memory problems.

Furthermore, your DELETE statement needs a selection table (i.e. like a range table).

 

Since the target DSO is rather small, I suggest to load the entire table into an internal table. Alternatively, you can filter on Company Code, Fiscal Year/Period and Fiscal Year Variant (i.e. leave out Accounting Document Number). But then you have to do a preliminary step to prepare an FAE (For All Entries) table to be used in the SELECT.

 

Then you can LOOP over the source package and check if the Accounting Document exists in the target DSO. If not, delete.

 

Coding could look as follows:

 

DATA:

  gt_fae TYPE _ty_T_SC_1.

 

REFRESH gt_fae.

 

gt_fae = source_package[].

SORT gt_fae BY comp_code fiscper fiscvarnt.

DELETE ADJACENT DUPLICATES FROM gt_fae COMPARING comp_code fiscper fiscvarnt.

 

SELECT DISTINCT ac_doc_no comp_code fiscper fiscvarnt

                            FROM /bic/azfi_o0100

                            INTO CORRESPONDING FIELDS OF TABLE gt_valid_records

                            FOR ALL ENTRIES IN gt_fae

                            WHERE comp_code = gt_fae-comp_code AND

                                         fiscper        = gt_fae-fiscper AND

                                         fiscvarnt      = gt_fae-fiscvarnt.

 

LOOP AT source_package ASSIGNING <source_fields>.

  READ TABLE gt_valid_records TRANSPORTING NO FIELDS

                       WITH KEY ac_doc_no  = <source_fields>-ac_doc_no

                                        comp_code = <source_fields>-comp_code

                                        fiscper        = <source_fields>-fiscper

                                        fiscvarnt      = <source_fields>-fiscvarnt.

  IF sy-subrc <> 0.

    DELETE <source_fields>.

  ENDIF.

ENDLOOP.

 

Best regards,

Sander


Viewing all articles
Browse latest Browse all 3366

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>