07-12-2007 11:24 AM
hi,
I have a requirement where , i have to fetch data of employees who joined or left the organisation in the previous month.
The condition is : if i run the report on 11th July, 2007, ...the data fetched must be between 1st June and 30th June , 2007.
if i run the report on 23rd March , 2007...the data fetched must be between 1st Feb and 28th Feb, 2007.
How can i achieve this?
07-12-2007 11:39 AM
Hi Balaji,
you can capture date in some variable of type date, say l_date.
now l_date+4(2) shall give you the current month, deduct 1 from that.
data : l_date type date,
prev_month_same_day type date,
prev_month type n.
prev_month = l_date+4(2) - 1.
concatenate l_date0(4) prev_month l_date6(2) into prev_month_same_day.
now pass this prev_month_same_day to FM <b>HR_JP_MONTH_BEGIN_END_DATE</b> . This shall return you the start date and end dates of the previous month.
From here i think you can solve on your own.
<b>Reward points if this helps,</b>
Kiran
07-12-2007 11:30 AM
use the fm HR_JP_MONTH_BEGIN_END_DATE pass any date of a particular month. fm returns the first date and last date of that month.
now use ur logic
07-12-2007 11:31 AM
Hi
It's not very clear but it seems you need the first and last day of the previuos month:
DATA: DATE TYPE SY-DATUM VALUE '20070711',
FIRST_DATE TYPE SY-DATUM,
LAST_DATE TYPE SY-DATUM.
LAST_DATE(6) = DATE(6).
LAST_DATE+6(2) = '01'.
LAST_DATE = LAST_DATE - 1.
FIRST_DATE(6) = LAST_DATE(6).
FIRST_DATE+6(2) = '01'.
Max
07-12-2007 11:39 AM
Hi Balaji,
you can capture date in some variable of type date, say l_date.
now l_date+4(2) shall give you the current month, deduct 1 from that.
data : l_date type date,
prev_month_same_day type date,
prev_month type n.
prev_month = l_date+4(2) - 1.
concatenate l_date0(4) prev_month l_date6(2) into prev_month_same_day.
now pass this prev_month_same_day to FM <b>HR_JP_MONTH_BEGIN_END_DATE</b> . This shall return you the start date and end dates of the previous month.
From here i think you can solve on your own.
<b>Reward points if this helps,</b>
Kiran