Application Development and Automation 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: 
Read only

DATE VALIDATION

Former Member
0 Likes
2,919

1) My requirement is to validate

current date of system(sy-datum) and past date in selection screen.

If difference between these

two dates more than six months than one error must display.

for example assume

current date = 21/02/2008 &

past date = 19/08/2007 ,

difference between these two dates is 6 month 3 days.

Then error must display

" difference between current date & past date should not be more than six months"

2)Please explain me how to validate these two dates?

8 REPLIES 8
Read only

Former Member
0 Likes
1,558

Hi,

look here:

Regards, Dieter

Read only

Former Member
0 Likes
1,558

use FM

HR_HK_DIFF_BT_2_DATES and pass your dates ..

and enter 05 in OUTPUT_FORMAT ... of FM

Read only

Sm1tje
Active Contributor
0 Likes
1,558

there are a lot of function modules around in which you can add month, weeks, days to a given date.

Look for something like (addmonths* or adddate* / dateadd*) in SE37. This way you can add 6 months to the current date (date low let's say). Next you check if date low > or > date high.

No SAP System available else I would have given you the exact name.

Read only

Former Member
0 Likes
1,558

Hi,

Use the below logic.

parameters: p_past type sy-datum,

p_curr type sy-datum default sy-datum.

data: v_date type sy-datum.

at selection-screen.

CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'

EXPORTING

DATE = p_curr

DAYS = 0

MONTHS = '06'

SIGNUM = '-'

YEARS = 0

IMPORTING

CALC_DATE = v_date.

if p_past lt v_date.

message

'difference between current date & past date should not be more than six

months' type 'E'.

endif.

Read only

manubhutani
Active Contributor
0 Likes
1,558

Hi

Either use that FM, it will work

or simply ise sy-datum0(4) - curr_date0(4) > 6

<REMOVED BY MODERATOR>

Edited by: Alvaro Tejada Galindo on Apr 11, 2008 5:26 PM

Read only

Former Member
0 Likes
1,558

Hi,

Check the following code:

DATA: EDAYS LIKE VTBBEWE-ATAGE,

EMONTHS LIKE VTBBEWE-ATAGE,

EYEARS LIKE VTBBEWE-ATAGE.

PARAMETERS: FROMDATE LIKE VTBBEWE-DBERVON,

TODATE LIKE VTBBEWE-DBERBIS DEFAULT SY-DATUM.

call function 'FIMA_DAYS_AND_MONTHS_AND_YEARS'

exporting

i_date_from = FROMDATE

i_date_to = TODATE

  • I_FLG_SEPARATE = ' '

IMPORTING

E_DAYS = EDAYS

E_MONTHS = EMONTHS

E_YEARS = EYEARS.

if emonths > 6.

write:/ 'Months exceeds 6'.

endif.

Regards,

Bhaskar

Read only

Former Member
0 Likes
1,558

Hi,

Please refer the below code:


tables : bsis.

data : month like VTBBEWE-ATAGE.

parameters : sp_date like sy-datum.


at selection-screen.

CALL FUNCTION 'FIMA_DAYS_AND_MONTHS_AND_YEARS'
  EXPORTING
    i_date_from          = sp_date
*   I_KEY_DAY_FROM       = I_KEY_DAY_FROM
    i_date_to            = sy-datum
*   I_KEY_DAY_TO         = I_KEY_DAY_TO
*   I_FLG_SEPARATE       = ' '
 IMPORTING
*   E_DAYS               = E_DAYS
   E_MONTHS             = month
*   E_YEARS              = E_YEARS
          .

if month GT '6'.
  message 'Invalid date' type 'E'.
endif.

Thanks,

Sriram Ponna.

Read only

Former Member
0 Likes
1,558

Use Function module "FIMA_DAYS_AND_MONTHS_AND_YEARS".