Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member

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: BEGIN OF y_tvarvc,
name
LIKE tvarvc-name,
low 
LIKE tvarvc-low,
high
LIKE tvarvc-high,
END OF y_tvarvc.

DATA: e_l_itab TYPE y_tvarvc.

CONSTANTS: c_ds_nm(10) type c value 'DS_A581_F5'.


data: l_idx like sy-tabix.


read table l_t_range with key
fieldname =
'DATAB'.
l_idx = sy-tabix.
*....

* clear work area
CLEAR e_l_itab.

select SINGLE low
high
from tvarvc into CORRESPONDING FIELDS OF e_l_itab
where name = c_ds_nm.

if e_l_itab-high IS INITIAL and e_l_itab-low IS INITIAL.
* 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 IS INITIAL.
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: BEGIN OF y_tvarvc,
name
LIKE tvarvc-name,
low 
LIKE tvarvc-low,
high
LIKE tvarvc-high,
END OF y_tvarvc.

DATA: e_l_itab TYPE y_tvarvc.

CONSTANTS: c_ds_nm(10) type c value 'DS_A581_F5'.


data: l_idx like sy-tabix.


read table l_t_range with key
fieldname =
'DATBI'.
l_idx = sy-tabix.
*....

* clear work area
CLEAR e_l_itab.

select SINGLE low
high
from tvarvc into CORRESPONDING FIELDS OF e_l_itab
where name = c_ds_nm.

if e_l_itab-high IS INITIAL and e_l_itab-low IS INITIAL.
* 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 IS INITIAL AND e_l_itab-high is not INITIAL.
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) type c OBLIGATORY,
p_delta(
5type c OBLIGATORY.

CONSTANTS: c_datab(5) type c value 'DATAB',
c_datbi(
5) type c value '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...)

2 Comments
Labels in this area