Quantcast
Channel: SCN : Blog List - All Communities
Viewing all articles
Browse latest Browse all 2548

How to write code in DTP to select Previous Month Data

$
0
0

Scenario: If I execute DTP in current month, it always picks only "Current month – 1" data.

 

                Eg: If Current month is Jan-2016, the DTP should fetch Dec-2015 Data from Source and updates into Target object.

 

 

Occasionally we need to filter the Date Characteristic InfoObject to extract only “Previous Month” data. Here the filter selection is not on SAP Content InfoObject, the filter selection is on Custom InfoObject.

 

If it is SAP Content InfoObject, we may have few SAP Customer exit/variables to use directly in DTP, but in this example I’m using Custom InfoObject which is created Data Type as DATS.

 

In DTP select the InfoObject and choose Create Routine and write/add the below Code in DTP Routine.

 

* Global code used by conversion rules
*$*$ begin of global - insert your declaration only below this line  *-*
* TABLES: ...


   DATA:   dt_range  TYPE STANDARD TABLE OF rsdatrange,

        btw LIKE STANDARD TABLE OF rsintrange,
        wdt_range
TYPE rsdatrange
.


*$*$ end of global - insert your declaration only before this line   *-*

 

 

*$*$ begin of routine - insert your code only below this line        *-*
     
data: l_idx like sy-tabix.
     
read table l_t_range with key
      fieldname
= ' '.
      l_idx
= sy-tabix.
*....

  CALL FUNCTION 'RS_VARI_V_LAST_MONTH' 
   * EXPORTING
   * SYSTIME          = ' '
  TABLES
   p_datetab 
= dt_range
   p_intrange
= btw.

READ TABLE dt_range INTO wdt_range INDEX 1.

      l_t_range
-fieldname = '/BIC/<Your_InfoObject_Name>'.
      l_t_range
-option = 'BT'.
      l_t_range
-sign = 'I'.
      l_t_range
-low = wdt_range-low.
      l_t_range
-high = wdt_range-high.

APPEND l_t_range
.

 

*  IF l_idx <> 0.
*    MODIFY l_t_range INDEX l_idx.
*  ELSE.
*    APPEND l_t_range.
*  ENDIF.

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


Viewing all articles
Browse latest Browse all 2548

Trending Articles



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