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

Dates with month calculation

Former Member
0 Likes
1,378

Hi Friends,

Here is my query, i need to get the date for past 6 months.

Ex : suppose if i have date 23.07.2008 i need to get the date 23.01.2008 as output can u suggest me where i comitted a mistake for below code as it is throughing short dump.

data : v_date type datum,

l_date type datum,

v_durmm type PSEN_DURATION-durmm value 6.

move sy-datum to v_date.

CALL FUNCTION 'HR_99S_DATE_ADD_SUB_DURATION'

EXPORTING

IM_DATE = v_date

IM_OPERATOR = '-'

IM_DURATION = v_durmm

IMPORTING

EX_DATE = l_date.

write l_date.

thnks in advance.

Regards,

poorna.

8 REPLIES 8
Read only

Former Member
0 Likes
1,076

Hi,

can you mention the error what it is throwing.

Read only

0 Likes
1,076

Hi Chandrika,

Error analysis

An exception occurred that is explained in detail below.

The exception, which is assigned to class 'CX_SY_DYN_CALL_ILLEGAL_TYPE', was

not caught and

therefore caused a runtime error.

The reason for the exception is:

The call to the function module "HR_99S_DATE_ADD_SUB_DURATION" is incorrect:

The function module interface allows you to specify only

fields of a particular type under "IM_DURATION".

The field "V_DURMM" specified here is a different

field type

.

Read only

Former Member
0 Likes
1,076

Hi,

Step 1: take the date like Sy-datum in declaration.

Step 2: tkae the month by setting the offset 4(2) to the date.

Step 3: subtruct 6 from it.

You will get the result.

Check the code:

parameters:
p_date type sy-datum.

data:
temp_month type i.

temp_month = p_date+4(2) - 6.

p_date+4(2) = temp_month.

write:p_date.

change accordingly in your FM code

Regards,

anirban

Read only

0 Likes
1,076

Hi friend,

if i have month FEB then this logic will not be applicable, i am right? date calcuation should be done dynamically as per the current date.

ex. if i run the report for every week and fetching the records for the past 6 months as of run date.

thanks,

poorna

Read only

Former Member
0 Likes
1,076

Hi purna

Do coding like this

data : v_date type datum,
l_date type datum,
v_durmm type PSEN_DURATION.
v_durmm-durmm = 6.
move sy-datum to v_date.


CALL FUNCTION 'HR_99S_DATE_ADD_SUB_DURATION'
EXPORTING
IM_DATE = v_date
IM_OPERATOR = '-'
IM_DURATION = v_durmm
IMPORTING
EX_DATE = l_date.

write l_date.

HOPE THIS HELPS U

Thanks and regards

Tamilselvan.K

Read only

0 Likes
1,076

Hi friend,

I have done the same thing thank you very much.

dont boughter you will get the points.

regards,

poorna

Read only

0 Likes
1,076

Hi,

Check this,

REPORT ZSCD_TEST10.

data : v_date type datum,

l_date type datum,

v_durmm type PSEN_DURATION.

v_durmm-DURMM = '6'.

v_date = sy-datum.

CALL FUNCTION 'HR_99S_DATE_ADD_SUB_DURATION'

EXPORTING

IM_DATE = v_date

IM_OPERATOR = '-'

IM_DURATION = v_durmm

IMPORTING

EX_DATE = l_date.

write l_date.

Pranu

Read only

Former Member
0 Likes
1,076

Hi Purna,

data : v_date type datum,

l_date type datum,

v_durmm type PSEN_DURATION-durmm value 6.

move sy-datum to v_date.

CALL FUNCTION 'HR_99S_DATE_ADD_SUB_DURATION'

EXPORTING

IM_DATE = v_date

IM_OPERATOR = '-'

IM_DURATION = v_durmm

IMPORTING

EX_DATE = l_date.

write l_date.

u double click on function 'HR_99S_DATE_ADD_SUB_DURATION' and then click the tab exporting & importing to see what is the type of IM_DATE and EX_DATE and then u declare v_date and I_date of the same type ...

i hope this will help u..

Thanks & Regards

Ashu Singh.