Hello friends,
I need to write an end routine to insert a new records in the target DSO when the records get deleted in the source ssytem. the source ssytem is JDE system so the datasource is through DBCONNECT. Sometimes some trandacational data might get deleted in the source system , so we wanted to do the same thing. Instead of deleting we wanted to update all the columns to 0 if the record get deleted in the source ssytem. first of all is there any better way to do this.
Here is the code that we wrote and it is giving me some errors.
DATA: ls_data LIKE LINE OF RESULT_PACKAGE.
*This routine is meant to resolve issue where record in source table
*is deleted but BW has no knowledge of said deletion because datasource
*is not delta-capable.
CALL FUNCTION 'DATE_CREATE'
EXPORTING
ANZAHL_KALTAGE = -45
DATUM_EIN = sy-datum
IMPORTING
DATUM_AUS = v_date1.
CALL FUNCTION 'DATE_CREATE'
EXPORTING
ANZAHL_KALTAGE = -1
DATUM_EIN = sy-datum
IMPORTING
DATUM_AUS = v_date2.
*Takes data from Inflow layer into internal table
*break-point.
SELECT *
INTO CORRESPONDING FIELDS OF TABLE lt_na015o0300
FROM /BIC/ANA015O0300
WHERE CALDAY BETWEEN v_date1 AND v_date2.
*
*Loops on internal table (from inflow layer) and reads
*data from result package with same keys.
LOOP AT lt_na015o0300 INTO ls_na015o0300 .
READ TABLE RESULT_PACKAGE TRANSPORTING NO FIELDS
WITH KEY
/bic/NA_UKID = ls_na015o0300-/bic/NA_UKID .
*
**If record from inflow does not exist in result package (sy-subrc<>0)
**then create a new zero record
IF sy-subrc NE 0.
ls_data-/bic/na_ukid = ls_na015o0300-/bic/na_ukid.
ls_data-/bic/na_plant = ''.
ls_data-/bic/bi_srcsys = ''.
ls_data-/bic/na_usrid = ''.
ls_data-calday = ''.
ls_data-/bic/na_uom = ''.
ls_data-/bic/na_itm = ''.
ls_data-/bic/na_litm = ''.
ls_data-/bic/na_trqt = 0.
ls_data-/bic/na_dct = ''.
ls_data-/bic/na_dgl = ''.
*
**Add the new zero record to the result package
APPEND ls_data to RESULT_PACKAGE.
ENDIF.
ENDLOOP.
The erro that it is giving is ..
Record 0, segment 0001 is not in the cross-record table
Message no. RSM2716
Diagnosis
You created new data records in a routine of the transformation. They do not have a data record number. An error occurred in one of these data records. Since this record does not have a data record number, it cannot be handled by error processing.
You cannot process the error on single-record basis since this sorts out the corresponding original data records and provides a correction.
System Response
The processing of the data package is terminated.
Procedure
Copy the data record number (field RECORD) from the original data record into the new data record.
Example
DATA: result_fields TYPE tys_tg_1.
LOOP AT result_package INTO result_fields WHERE accounttype = 'I'.
result_fields-accounttype = 'E'.
APPEND result_fields TO result_package.
ENDLOOP.
Result
Each data record of the original package exists twice, once with accounttype = 'I', and once with accounttype = 'E'. The new data records have the same record numbers as the original data records.