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: 

Is there any function module which will only take 1st and last day of the same month?

0 Kudos

in select-option i want to select any month's 1st date and last date, then it will ok, and if I give other date rather than 1st and last date then it will not take. so basically in raise exception that should be written that rather than 1st and last date of the selected month will not take.

8 REPLIES 8

IN
Contributor
0 Kudos

Define l_first and l_last as date. You can try:

  • FM RP_LAST_DAY_OF_MONTHS for the last day. Put the result into l_last.
  • concatenate l_last+0(6) '01'. Put the result into l_first.

Regards,

Igor

0 Kudos

could you please explain more ? i mean i just want to show incorrect as a output if i input wrong date in starting and end date range. and If I put 1st day of the month and last day of the month in the range then it will show correct as a output .

Sandra_Rossi
Active Contributor

Why a function module for so special need? Can't you just use the basic ABAP operations on date types? Example:

DATA date TYPE d.
SELECT-OPTIONS s_date FOR date.
AT SELECTION-SCREEN.
IF s_date-low+6(2) <> '01'. MESSAGE 'low date must be 1st month day' TYPE 'E'. ENDIF.
DATA(high_date_plus_1_day) = CONV d( s_date-high + 1 ).
IF high_date_plus_1_day+6(2) <> '01'. MESSAGE 'high date must be end of month' TYPE 'E'. ENDIF.
DATA(low_date_plus_1_month) = CONV d( s_date-low + 31 ).
IF low_date_plus_1_month(6) <> high_date_plus_1_day(6).
  MESSAGE 'low date and high date must belong to same month' TYPE 'E'.
ENDIF.

Note: +6(2) is to get the day out of a date (01 or 31 for instance), while (6) is to get the year and month concatenated.

former_member199306
Participant
0 Kudos

Hi,

Please check this FM - HR_JP_MONTH_BEGIN_END_DATE

IN
Contributor
0 Kudos

You must loop at screen and check the values in selection screen.

Check these 2 options:

  • loop at screen output
  • loop at screen

You will find a lot of examples for checking the selection screen. You have to pass through the selection screen, check your date value and give the corresponding message.

Regards,

Igor

dev_parbutteea
Active Contributor

Hi,

Dumb question: why even put such a select option when the user can only input first and last day of month.. Why don't you rather put month on the selection screen ?

Regards,

Dev.

Jelena
Active Contributor

If you are always expecting the first and last day of the month then why not simply make month/year the parameter instead of the date range? You can use FM POPUP_TO_SELECT_MONTH as F4 help for it.

Then in the code, convert the month into the date range, if necessary.

As a user, I wouldn't be very happy if I had to remember every time what's the last date in every month is.