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: 

need to put check at the year selection

Former Member
0 Kudos

hi,

how to put this check at selection screen.

1. Program will check at the year selection, that should not be more than 3 years, otherwise, the program will raise the error message of u2018Only allow 3 years difference!u2019.

2. is there any fn module which gives the begin and end dates for a year.

requirement: determine the begin date and the end date of selection period for year selection at the selection screen.

Need this urgently.

Thanks.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

this fm will give begin date and end date of a date HR_JP_MONTH_BEGIN_END_DATE

also for year check....try this code


SELECT-OPTIONS : dat FOR sy-datum.

AT SELECTION-SCREEN ON dat.
  DATA : t(4),
       t1(4).
  t = dat-high(4).
  t1 = dat-low(4).
  t = t - t1.
  IF  t > 3.
  message 'error' type 'E'.
  ENDIF.

Regards

Debarshi

Edited by: Debarshi Roy on Nov 21, 2008 4:28 PM

6 REPLIES 6

former_member1245113
Active Contributor
0 Kudos

HI,

for the first one.

data date type sy-datum

data year(2).

date = 20.11.2008

year = date+6(4).

then date contain 2008.

if the user enters 2004 in parameter p_year.

then

year = year - 3. equal to 2005

if p_year < year.

give some error message

endif.

for the second one.

go to se37 give year or date

this will give you all the related FM

regards

Ramchander Rao.K

0 Kudos

hi,

year which i am giving in the selection screen is a select-option.

s_gjahr for bkpf-gjahr,

do u need to check it for s_gjahr-high.

former_member1245113
Active Contributor
0 Kudos

HI,

for the first one.

data date type sy-datum

data year(2).

date = 20.11.2008

year = date+6(4).

then date contain 2008.

if the user enters 2004 in parameter p_year.

then

year = year - 3. equal to 2005

if p_year < year.

give some error message

endif.

for the second one.

go to se37 give year or date

this will give you all the related FM

regards

Ramchander Rao.K

Former Member
0 Kudos

Hi,

this fm will give begin date and end date of a date HR_JP_MONTH_BEGIN_END_DATE

also for year check....try this code


SELECT-OPTIONS : dat FOR sy-datum.

AT SELECTION-SCREEN ON dat.
  DATA : t(4),
       t1(4).
  t = dat-high(4).
  t1 = dat-low(4).
  t = t - t1.
  IF  t > 3.
  message 'error' type 'E'.
  ENDIF.

Regards

Debarshi

Edited by: Debarshi Roy on Nov 21, 2008 4:28 PM

0 Kudos

hi debarshi,

i need FM for particular year.

i need begin and end dates for a particular year.

FM which u mentioned was for particular month.

Thanks

Former Member
0 Kudos

You can find the difference between 2 dates by simple code

data: year type i.

SELECTION-SCREEN: begin of block b1.

SELECT-OPTIONS: p_date for sy-datum.

SELECTION-SCREEN end of BLOCK b1.

AT SELECTION-SCREEN.

if not p_date-high is initial.

year = p_date-high - p_date-low.

if year >= 1095 .

message e499(sy) with 'ERROR'.

endif.

endif.

Hope this helps

Raj