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: 

Selecting data according to condition

Former Member
0 Kudos

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?

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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

3 REPLIES 3

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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