Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Reading back for 6 months ago in the table

Former Member
0 Kudos

Hi All,

I do have data for Meter reading scheduled date are like this in table TE418

ADATSOLL--- Field name(having TE418 -field having value like this)

.

;;;etc

02/20/2003

03/20/2003

04/17/2003

05/16/2003

06/16/2003

07/15/2003

08/12/2003

09/10/2003

.....

.......

......Etc. From this table field .

From this table i need to findout date 6months ago. Example i know the startdate as 08/12/2003, I need to back 6 months & findout the scheduled date 6 months ago, thati 's 02/20/2003.

How can i do this using select statement? Please give me logic.

Thanks

3 REPLIES 3

Former Member
0 Kudos

Hi,

Use the ranges..

DATA: V_DATE TYPE SY-DATUM.

RANGES: R_DATE FOR SY-DATUM.

CALL FUNCTION 'CCM_GO_BACK_MONTHS'

EXPORTING

currdate = SY-DATUM

backmonths = '006'

IMPORTING

NEWDATE = V_DATE

.

  • BUILD A RANGE.

R_DATE-SIGN = 'I'.

R_DATE-OPTION = 'BT'.

R_DATE-LOW = V_DATE.

R_DATE-HIGH = SY-DATUM.

APPEND R_DATE.

use the ranges in your select statement..

Thanks,

Naren

Message was edited by: Narendran Muthukumaran

ferry_lianto
Active Contributor
0 Kudos

Hi Rose,

You can code something like this.


SELECT ADATSOLL UP TO 6 ROWS 
INTO TABLE I_ADATSOLL
FROM TE418
WHERE ADATSOLL LE WA_DATE.

SORT I_ADATSOLL DESCENDING.

READ TABLE I_ADATSOLL INDEX 1.

WRITE: / I_ADATSOLL.

Regards,

Ferry Lianto

Former Member
0 Kudos

Try:

REPORT ztest MESSAGE-ID 00.

DATA: back_date LIKE sy-datum.

DATA: BEGIN OF date_int OCCURS 0,
        budat LIKE te418-adatsol,
      END   OF date_int.

CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'
  EXPORTING
    date      = '20030812'                                  "08/12/2003
    days      = 0
    months    = 4
    signum    = '-'
    years     = 0
  IMPORTING
    calc_date = back_date
  EXCEPTIONS
    OTHERS    = 1.

SELECT adatsol FROM te418
  INTO TABLE date_int
  UP TO 1 ROWS
  WHERE adatsol LE back_date
  ORDER BY adatsol DESCENDING.

Rob