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

Function Module on Date

Former Member
0 Likes
344

Hi,

Function Module on the Last working Date of a month and Last day of th emonth based on the company code and period.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
314

HI,

We want to fill the two selection screen fields p_fromdate and p_todate

with the first and last date of the previous month.

DATA:

l_monthn(2) TYPE n,

l_yearn(4) TYPE n.

  • Find current month and year

MOVE sy-datum+4(2) TO l_monthn.

MOVE sy-datum+0(4) TO l_yearn.

  • If current month > 1 subtract 1 from then month

IF l_monthn > 1.

l_monthn = l_monthn - 1.

ELSE.

l_monthn = 12.

l_yearn = l_yearn - 1.

ENDIF.

  • First date of month

CONCATENATE l_yearn l_monthn '01' INTO p_fromdate.

  • Last date of month

CALL FUNCTION 'RP_LAST_DAY_OF_MONTHS'

EXPORTING

day_in = p_fromdate

IMPORTING

last_day_of_month = p_todate

EXCEPTIONS

day_in_no_date = 1

OTHERS = 2.

Regards,

Laxmi.

2 REPLIES 2
Read only

anversha_s
Active Contributor
0 Likes
314

hi,

for last and first day.

data:f_date type sy-datum,
l_date type sydatum.


CALL FUNCTION 'HR_JP_MONTH_BEGIN_END_DATE'
EXPORTING
iv_date = sy-datum
IMPORTING
EV_MONTH_BEGIN_DATE = f_date
EV_MONTH_END_DATE = l_date.

last working day

TM_DATE_CHECK_WORKING_DAY

rgds

Anver

if hlped pls mark poin ts

Read only

Former Member
0 Likes
315

HI,

We want to fill the two selection screen fields p_fromdate and p_todate

with the first and last date of the previous month.

DATA:

l_monthn(2) TYPE n,

l_yearn(4) TYPE n.

  • Find current month and year

MOVE sy-datum+4(2) TO l_monthn.

MOVE sy-datum+0(4) TO l_yearn.

  • If current month > 1 subtract 1 from then month

IF l_monthn > 1.

l_monthn = l_monthn - 1.

ELSE.

l_monthn = 12.

l_yearn = l_yearn - 1.

ENDIF.

  • First date of month

CONCATENATE l_yearn l_monthn '01' INTO p_fromdate.

  • Last date of month

CALL FUNCTION 'RP_LAST_DAY_OF_MONTHS'

EXPORTING

day_in = p_fromdate

IMPORTING

last_day_of_month = p_todate

EXCEPTIONS

day_in_no_date = 1

OTHERS = 2.

Regards,

Laxmi.