Quantcast
Channel: SCN : Document List - SAP Business Warehouse
Viewing all articles
Browse latest Browse all 1574

Delta for pricing tables like A004 , A005 , A006, A581 etc

$
0
0

Requirement:

Delta for pricing tables like A004, A005, A006, A581 etc. In the pricing tables there are two date fields DATAB and DATBI. When a new record for condition record is created the record has date for the validity date for that condition record. The condition record when first created has the end date (DATBI) as 31/12/9999 and the start date can be anything. When the condition record validity is define the DATBI date is updated from 31/12/9999 to the date till which the date is valid and a new condition record is created with a new valid from date (DATAB i.e last DATBI+1 date)  and the valid to date DATBI is 31/12/9999. Now the delta for these condition record tables is of two types delta based on DATAB and DATBI both needs to be captured.

Problem:

No field to mark the change records.

Solution:

There are two date fields DATAB (from date) and DATBI (to date) for condition records.

Based on the changes based on these fields delta needs to be loaded.

We have created two Full IP’s  (one to capture change w.r.t DATAB and the other w.r.t DATBI).

Written an ABAP Routine in IP which will fetch the data from the range when the last record was loaded till sy-datum w.r.t DATAB and DATBI accordingly.

Pre-requisite:

Create a table entry for variable which will store the date of last load w.r.t DATAB (high) and DATBI (low).

 

ABAP routine w.r.t DATAB.

TABLES: TVARVC.
TYPES: BEGINOF y_tvarvc,
name
LIKE tvarvc-name,
low 
LIKE tvarvc-low,
high
LIKE tvarvc-high,
ENDOF y_tvarvc.

DATA: e_l_itab TYPE y_tvarvc.

CONSTANTS: c_ds_nm(10) typecvalue'DS_A581_F5'.


data: l_idx like sy-tabix.


readtable l_t_range withkey
fieldname =
'DATAB'.
l_idx = sy-tabix.
*....

* clear work area
CLEAR e_l_itab.

selectSINGLE low
high
from tvarvc into CORRESPONDING FIELDSOF e_l_itab
where name = c_ds_nm.

if e_l_itab-high ISINITIALand e_l_itab-low ISINITIAL.
* when doing full load for the first time (no range defined)

CLEAR: L_T_RANGE.
l_t_range-option =
'EQ'.
l_t_range-
sign   = 'I'.


*when doing delta load after first full load (range defined from last
*loaded delta to sy-datum)
elseif e_l_itab-high ISINITIAL.
l_t_range-HIGH   = sy-datum.
l_t_range-low    = e_l_itab-low.
l_t_range-option =
'BT'.
l_t_range-
sign   = 'I'.

else.
*when doing delta load after first full load (range defined from last
*loaded delta to sy-datum)

l_t_range-HIGH   = sy-datum.
l_t_range-low    = e_l_itab-high.
l_t_range-option =
'BT'.
l_t_range-
sign   = 'I'.

endif.

modify l_t_range index l_idx.



p_subrc =
0.
* clear work area
CLEAR e_l_itab.

ABAP routine w.r.t DATBI.

TABLES: TVARVC.
TYPES: BEGINOF y_tvarvc,
name
LIKE tvarvc-name,
low 
LIKE tvarvc-low,
high
LIKE tvarvc-high,
ENDOF y_tvarvc.

DATA: e_l_itab TYPE y_tvarvc.

CONSTANTS: c_ds_nm(10) typecvalue'DS_A581_F5'.


data: l_idx like sy-tabix.


readtable l_t_range withkey
fieldname =
'DATBI'.
l_idx = sy-tabix.
*....

* clear work area
CLEAR e_l_itab.

selectSINGLE low
high
from tvarvc into CORRESPONDING FIELDSOF e_l_itab
where name = c_ds_nm.

if e_l_itab-high ISINITIALand e_l_itab-low ISINITIAL.
* when doing full load for the first time (no range defined).
CLEAR:   l_t_range.
l_t_range-option =
'EQ'.
l_t_range-
sign   = 'I'.

*when doing delta load after first full load (range defined from last
*loaded delta to sy-datum)
elseif e_l_itab-low ISINITIALAND e_l_itab-high isnotINITIAL.
l_t_range-HIGH   = sy-datum.
l_t_range-low    = e_l_itab-high.
l_t_range-option =
'BT'.
l_t_range-
sign   = 'I'.
else.
*when doing delta load after first full load (range defined from last
*loaded delta to sy-datum)

l_t_range-HIGH   = sy-datum.
l_t_range-low    = e_l_itab-low.
l_t_range-option =
'BT'.
l_t_range-
sign   = 'I'.

endif.

modify l_t_range index l_idx.



p_subrc =
0.
* clear work area
CLEAR e_l_itab.

 

……

Please find the above code which you need to add in IP’s. This code will check if the data is been loaded for the first time(the variant has a blank value if we are loading the data for the first time).

  • It will check the condition if it is been loaded before this so the date which will maintain the latest dates for change where the variable low value is for DATBI and high is for DATAB. If it is initial then it will do a full load and the last load date will get updated in the tvarvc table for the corresponding variable for eg.DS_A581_F5.

 

  • If the data load is already done then only the data which is present in the range from last load and todays system date will be fetched and the variable value date will be updated (DS_A581_F5) value to today’s system date when the data load is done.

Below is the program to update the TVARVC table entries for variables.

Program to update variable values in TVARVC Table.

REPORT ZT_TAVRVC_VAR_UPDT.

PARAMETERS: p_varnm(10) typec OBLIGATORY,
p_delta(
5typec OBLIGATORY.

CONSTANTS: c_datab(5) typecvalue'DATAB',
c_datbi(
5) typecvalue'DATBI'.

If p_delta EQ c_datbi.

update tvarvc
set low = sy-datum
where name = p_varnm.

else.

update tvarvc
set high = sy-datum
where name = p_varnm.

endif.

 

We have a kept this program separate as it should update TVARVC variable entry only if the IP runs successfully.

The Flow for data loading in process chain is as follow:

 

(unable to upload the image...)


Viewing all articles
Browse latest Browse all 1574

Trending Articles