cancel
Showing results for 
Search instead for 
Did you mean: 

Compare Date

Former Member
0 Kudos

Hi,

Is there a fast way that I can compare date in a table field. For example, I have

salesorder pos seq date

10001 10 1 01/02/2007

10001 10 2 01/02/2007

10001 10 3 01/02/2007

If the date is the same based on 3 seq, then return true, else return false.

Thanks, rewards will be given. Thanks a lot.

Accepted Solutions (0)

Answers (3)

Answers (3)

former_member189629
Active Contributor
0 Kudos

Hui,

try this... move ur itab values into a temp itab for comparision

itab2[] = itab[].

loop at itab where seq BETWEEN 1 AND 3.

read table itab2 with key seq = itab-seq.

if sy-subrc = 0.

if itab2-date = itab-date.

write: 'true'.

else.

write: 'false'.

endif.

endif.

endloop.

Reward if helpful,

Karthik

Former Member
0 Kudos

Hi,

You need to loop throught the Internal table and check the dates,

LOOP AT ITAB, then pass the Date field to a local variable, then look at the second record in the internal table whether the second record is also having the same date or not, and also look at the third date also

Regards

Sudheer

amit_khare
Active Contributor
0 Kudos

You can directly compare the dates by passing it a variable type DATS in yyyymmdd format.

w_date type dats.

loop at itab.

concatenate itab-date6(4) itab-date0(2) itab-date+3(2) into w_date.

if w_date1 is initial.

w_date1 = w_date.

endif.

if w_date1 NE w_date.

w_flag = '1'. "False

w_date1 = w_date.

else.

w_flag = '0'. "True

endif.

endloop.

Former Member
0 Kudos

Can you show an example?

Former Member
0 Kudos

HI HUI

SEE THIS EXAMPLE

l_err = text-022.

ENDIF.

*for back dating

IF wa_data-efffromdate < sy-datum.

l_err = text-023.

ENDIF.

*FOR INVALID DATE.

CONDENSE wa_data-efffromdate.

l_lines = STRLEN( wa_data-efffromdate ).

IF l_lines LT 8.

l_err = text-025.

ENDIF.

CONDENSE wa_data-efftodate.

l_lines = STRLEN( wa_data-efftodate ).

IF l_lines LT 8.

l_err = text-025.

ENDIF.

IF NOT wa_data-efffromdate+4(2) BETWEEN '01' AND '12'.

l_err = text-029.

ENDIF.

IF NOT wa_data-efftodate+4(2) BETWEEN '01' AND '12'.

l_err = text-030.

ENDIF.

IF NOT wa_data-efffromdate+6(2) BETWEEN '01' AND '31'.

l_err = text-031.

ENDIF.

IF NOT wa_data-efftodate+6(2) BETWEEN '01' AND '31'.

l_err = text-032.

ENDIF.