2007 Nov 19 6:17 PM
hi,
my requirement is i have month and year which i am getiing in select option from the user
in the format eg: '11.2007' and '06.2007' (he enters in the screen) i have to find the months
between and do some calculation.
i have the function module for it HR_HK_DIFF_BT_2_DATES .my problem is i concatenated and passed two days in the format like '20071101' and '20070630' but its not showing the month between .is that the format i give is wrong...plz help me
regards,
karthik.
2007 Nov 19 7:13 PM
Here is the code:
report ztesttej13.
parameters: p_date(10),
p_date1(10).
data: v_date like p0001-begda,
v_date1 like p0001-endda,
v_months like P0347-SCRMM.
v_date = p_date.
v_date1 = p_date1.
CALL FUNCTION 'HR_HK_DIFF_BT_2_DATES'
EXPORTING
DATE1 = v_date
DATE2 = v_date1
OUTPUT_FORMAT = '08'
IMPORTING
YEARS =
MONTHS = v_months
DAYS =
EXCEPTIONS
INVALID_DATES_SPECIFIED = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
ENDIF.
write: v_months.
And I am passing 20071101 to P_date and 20070601 to p_date1.
I am thinking the way you defined your date parameters may be wrong.
Hi.. Looks like you are passing an incorrect Output Format.. If you pass 08.. it gives you the months between..
2007 Nov 19 6:37 PM
Hi.. Looks like you are passing an incorrect Output Format.. If you pass 08.. it gives you the months between..
2007 Nov 19 7:03 PM
thx,
but i tried that too i am pasting my code here
CALL FUNCTION 'HR_HK_DIFF_BT_2_DATES'
EXPORTING
DATE1 = t_dates-high <----
20071101
DATE2 = t_dates-low <----
20070630
OUTPUT_FORMAT = '08'
IMPORTING
YEARS =
MONTHS = w_months
DAYS =
EXCEPTIONS
INVALID_DATES_SPECIFIED = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
i think this could help to sort it out
2007 Nov 19 6:44 PM
2007 Nov 19 7:05 PM
The date format is wrong:
It should be 11/01/2007 and 06/30/2007
2007 Nov 19 7:15 PM
but i dont get the date from user i am just getting as 11.2007(Month.Year) i am concatenating and putting the value there in that format is that i can give as you said 11/01/2007 but again date is length of 8.what could be the format i can specify there??
your help will be appreciated
2007 Nov 19 7:33 PM
You have to pass a date like:
data: l_st_date like sy-datum,
l_end_Date like sy-datum.
data: l_your_date(7) type c value '11.2007'.
l_st_date0(4) = l_your_date3(4).
l_st_date4(2) = l_your_date0(2).
l_st_date+6(2) = '01'.
l_end_date0(4) = l_your_date3(4).
l_end_date4(2) = l_your_date0(2).
l_end_date+6(2) = '31'.
2007 Nov 19 7:13 PM
Here is the code:
report ztesttej13.
parameters: p_date(10),
p_date1(10).
data: v_date like p0001-begda,
v_date1 like p0001-endda,
v_months like P0347-SCRMM.
v_date = p_date.
v_date1 = p_date1.
CALL FUNCTION 'HR_HK_DIFF_BT_2_DATES'
EXPORTING
DATE1 = v_date
DATE2 = v_date1
OUTPUT_FORMAT = '08'
IMPORTING
YEARS =
MONTHS = v_months
DAYS =
EXCEPTIONS
INVALID_DATES_SPECIFIED = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
ENDIF.
write: v_months.
And I am passing 20071101 to P_date and 20070601 to p_date1.
I am thinking the way you defined your date parameters may be wrong.
2007 Nov 19 7:45 PM
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |