2008 Jun 17 9:57 AM
hi
i hve in selection screen data as fiscal year and period
eg 2007 fiscal year
and period 02 - 09
please let me know how to get date range based on this above parameters for fiscal year and period
i want to have code for the above my outcome should be for above eg
01/01/2008 - 30/06/2008 for if month is 30 if month is 31 it should be 31st ie last day of month
regards
Arora
2008 Jun 17 3:19 PM
Here we go. Code for getting the dates
DATA : gv_year TYPE gjahr,
gv_month1 TYPE poper, "start month
gv_month2 TYPE poper, "last month
gv_periv TYPE periv,
gv_begin TYPE datum, "start day
gv_end TYPE datum, "last day
gv_bukrs TYPE bukrs.
SELECT SINGLE periv
INTO gv_periv
FROM t001
WHERE bukrs EQ gv_bukrs.
gv_year = '2008'.
gv_month1 = '001'.
gv_month2 = '006'.
CALL FUNCTION 'FIRST_DAY_IN_PERIOD_GET'
EXPORTING
i_gjahr = gv_year
* I_MONMIT = 00
i_periv = gv_periv
i_poper = gv_month1
IMPORTING
e_date = gv_begin
EXCEPTIONS
input_false = 1
t009_notfound = 2
t009b_notfound = 3
OTHERS = 4.
IF sy-subrc 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'LAST_DAY_IN_PERIOD_GET'
EXPORTING
i_gjahr = gv_year
* I_MONMIT = 00
i_periv = gv_periv
i_poper = gv_month2
IMPORTING
e_date = gv_end
EXCEPTIONS
input_false = 1
t009_notfound = 2
t009b_notfound = 3
OTHERS = 4.
IF sy-subrc 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Here we go. Code for getting the dates
DATA : gv_year TYPE gjahr,
gv_month1 TYPE poper, "start month
gv_month2 TYPE poper, "last month
gv_periv TYPE periv,
gv_begin TYPE datum, "start day
gv_end TYPE datum, "last day
gv_bukrs TYPE bukrs.
SELECT SINGLE periv
INTO gv_periv
FROM t001
WHERE bukrs EQ gv_bukrs.
gv_year = '2008'.
gv_month1 = '001'.
gv_month2 = '006'.
CALL FUNCTION 'FIRST_DAY_IN_PERIOD_GET'
EXPORTING
i_gjahr = gv_year
* I_MONMIT = 00
i_periv = gv_periv
i_poper = gv_month1
IMPORTING
e_date = gv_begin
EXCEPTIONS
input_false = 1
t009_notfound = 2
t009b_notfound = 3
OTHERS = 4.
IF sy-subrc 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'LAST_DAY_IN_PERIOD_GET'
EXPORTING
i_gjahr = gv_year
* I_MONMIT = 00
i_periv = gv_periv
i_poper = gv_month2
IMPORTING
e_date = gv_end
EXCEPTIONS
input_false = 1
t009_notfound = 2
t009b_notfound = 3
OTHERS = 4.
IF sy-subrc 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
2008 Jun 17 3:19 PM
Here we go. Code for getting the dates
DATA : gv_year TYPE gjahr,
gv_month1 TYPE poper, "start month
gv_month2 TYPE poper, "last month
gv_periv TYPE periv,
gv_begin TYPE datum, "start day
gv_end TYPE datum, "last day
gv_bukrs TYPE bukrs.
SELECT SINGLE periv
INTO gv_periv
FROM t001
WHERE bukrs EQ gv_bukrs.
gv_year = '2008'.
gv_month1 = '001'.
gv_month2 = '006'.
CALL FUNCTION 'FIRST_DAY_IN_PERIOD_GET'
EXPORTING
i_gjahr = gv_year
* I_MONMIT = 00
i_periv = gv_periv
i_poper = gv_month1
IMPORTING
e_date = gv_begin
EXCEPTIONS
input_false = 1
t009_notfound = 2
t009b_notfound = 3
OTHERS = 4.
IF sy-subrc 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'LAST_DAY_IN_PERIOD_GET'
EXPORTING
i_gjahr = gv_year
* I_MONMIT = 00
i_periv = gv_periv
i_poper = gv_month2
IMPORTING
e_date = gv_end
EXCEPTIONS
input_false = 1
t009_notfound = 2
t009b_notfound = 3
OTHERS = 4.
IF sy-subrc 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
2008 Jun 23 3:57 PM
2008 Jun 18 8:35 AM
hi
u have replied from my earlie thread in which i have asked for function module
lease not that i havent asked for any funtion module in this question but hard coded code to do so?
please read the query fully...
regards
ARora
2008 Jun 18 1:17 PM
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |