Skip to Content
-1
Oct 21, 2016 at 06:21 PM

ABAP ROUTINE CURRENT DAY -1 IN DTP

871 Views

Hello Experts!

I've an ODS with a lot of registers of a several periods, so I use a DTP to transfer only registers that starts in the day 1 (of the current month) until the current day -1 to another ODS.

Example: Today is 21/10/2016 - My DTP will transfer only data from 01/10/2016 to 20/10/2016.

Tomorrow (22/10) it'll transfer from 01/10/2016 to 21/10/2016, then successively...

I'm using the following ABAP Routine:

*&---------------------------------------------------------------------*
*& Include RSBC_SEL_ROUTINE_TPL
*&---------------------------------------------------------------------*

program conversion_routine.
* Type pools used by conversion program
type-pools: rsarc, rsarr, rssm.
tables: rssdlrange.
* Global code used by conversion rules
*$*$ begin of global - insert your declaration only below this line *-*
* TABLES: ...
* DATA: ...
*$*$ end of global - insert your declaration only before this line *-*
* -------------------------------------------------------------------
* Fieldname = PSTNG_DATE
* data type = DATS
* length = 000008
* -------------------------------------------------------------------
form c_PSTNG_DATE
tables l_t_range structure rssdlrange
using i_r_request type ref to IF_RSBK_REQUEST_ADMINTAB_VIEW
i_fieldnm type RSFIELDNM
changing p_subrc like sy-subrc.
* Insert source code to current selection field
*$*$ begin of routine - insert your code only below this line *-*
data: l_idx like sy-tabix.
read table l_t_range with key
fieldname = 'PSTNG_DATE'.
l_idx = sy-tabix.

data: g_date(6) type n.
data: g_date1 type d.
data: g_date2 type d.

g_date1 = sy-datum.
g_date = g_date1+0(6).

clear g_date1.

concatenate g_date '01' into g_date1.

g_date2 = sy-datum - 1.

l_t_range-iobjnm = 'ZPSTNG_DATE'.
l_t_range-FIELDNAME = 'PSTNG_DATE'.
l_t_range-sign = 'I'.
L_T_RANGE-OPTION = 'BT'.
l_t_range-LOW = g_date1.
l_t_range-high = g_date2.

modify l_t_range index l_idx.

p_subrc = 0.


*$*$ end of routine - insert your code only before this line *-*
endform.


But when it's executed, I've a dump in ST22: TABLE_INVALID_INDEX.

What is wrong?

Can you help me?

Thanks in advanced,

Flávio Costa