on 05-20-2016 7:57 AM
Hi All,
Is there any FM to get first and last day of financial year by passing date?
Thanks,
Rathinakumar
FIRST_AND_LAST_DAY_IN_YEAR_GET
there are a number of posts with some code examples as well if you search...
M.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I have written the following code. But i am not getting year as output.
Could you please correct me where is the problem?
DATA: IT_TEMP TYPE STANDARD TABLE OF _ty_s_SC_1 ,
IT_TEMP1 TYPE STANDARD TABLE OF _ty_s_SC_1,
WA_TEMP TYPE _ty_s_SC_1.
DATA: DT1 TYPE SY-DATUM,
DT2 TYPE SY-DATUM,
DTF TYPE SY-DATUM,
DTL TYPE SY-DATUM,
MY1 TYPE /BI0/OICALMONTH,
DD1(2) TYPE C,
YEAR(4) TYPE N,
FY(4) TYPE N,
Period(3) TYPE N.
DATA: w_period TYPE t009b-poper,
w_year TYPE t009b-bdatj.
YEAR = W_YEAR.
PERIOD = W_PERIOD.
IT_TEMP = SOURCE_PACKAGE.
SORT IT_TEMP BY PERNR.
DELETE ADJACENT DUPLICATES FROM IT_TEMP COMPARING PERNR.
LOOP AT IT_TEMP INTO WA_TEMP.
DT2 = WA_TEMP-UPDATEDT.
CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
EXPORTING
i_date = DT2
i_monmit = 00
i_periv = 'v3'
IMPORTING
e_buper = w_period
e_gjahr = w_year
EXCEPTIONS
input_false = 1
t009_notfound = 2
t009b_notfound = 3
OTHERS = 4.
IF SY-SUBRC = 0.
FY = YEAR.
ENDIF.
DATA: IT_TEMP TYPE STANDARD TABLE OF _ty_s_SC_1 ,
IT_TEMP1 TYPE STANDARD TABLE OF _ty_s_SC_1,
WA_TEMP TYPE _ty_s_SC_1.
DATA: DT1 TYPE SY-DATUM,
DT2 TYPE SY-DATUM,
DTF TYPE SY-DATUM,
DTL TYPE SY-DATUM,
MY1 TYPE /BI0/OICALMONTH,
DD1(2) TYPE C,
YEAR(4) TYPE N,
FY(4) TYPE N,
Period(3) TYPE N.
DATA: w_period TYPE t009b-poper,
w_year TYPE t009b-bdatj.
YEAR = W_YEAR.
PERIOD = W_PERIOD.
IT_TEMP = SOURCE_PACKAGE.
SORT IT_TEMP BY PERNR.
DELETE ADJACENT DUPLICATES FROM IT_TEMP COMPARING PERNR.
LOOP AT IT_TEMP INTO WA_TEMP.
*** This will give you first date and last date of Month ( from Updated date ) or if you like to fix it on Period 01 or 12, then you will get first and last date of the year.
DT2 = WA_TEMP-UPDATEDT.
* concatenate wa_temp(4) '1215' into DT2_l " middle of month of Dec
* concatenate wa_temp(4) '0115' into DT2_f " middle of month of Jan
CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
EXPORTING
i_date = DT2
i_monmit = 00
i_periv = 'V3'
IMPORTING
e_buper = w_period
e_gjahr = w_year
EXCEPTIONS
input_false = 1
t009_notfound = 2
t009b_notfound = 3
OTHERS = 4.
IF SY-SUBRC = 0.
call function 'LAST_DAY_IN_PERIOD_GET'
exporting
i_gjahr = w_year
i_periv = ''
i_poper = w_period
importing
e_date = zlastdate.
wa_temp-<fieldforlastdate> = zlastdate
call function 'FIRST_DAY_IN_PERIOD_GET'
exporting
i_gjahr = w_year
i_periv = ''
i_poper = w_period
importing
e_date = zfirstdate.
wa_temp-<fieldforfirstdate> = zfirstdate
ENDIF.
modify source_package from wa_temp.
endloop.
Hi Sandeep,
I have a field UPDATEDT with records from 01.04.2013 to Till date.
I want to filter the records for 01.04.2016 To 31.03.2017(Current Fiscal Year).
But, my below start routine, is not providing the right right output. Could you please advice.?
DATA: IT_TEMP TYPE STANDARD TABLE OF _ty_s_SC_1 ,
IT_TEMP1 TYPE STANDARD TABLE OF _ty_s_SC_1,
WA_TEMP TYPE _ty_s_SC_1.
DATA: DT1 TYPE SY-DATUM,
DT2 TYPE SY-DATUM,
DTF TYPE SY-DATUM,
DTL TYPE SY-DATUM,
zlastdate TYPE SY-DATUM,
zfirstdate TYPE SY-DATUM,
MY1 TYPE /BI0/OICALMONTH,
DD1(2) TYPE C,
YEAR(4) TYPE N,
FY(4) TYPE N,
Period(3) TYPE N.
DATA: w_period TYPE t009b-poper,
w_year TYPE t009b-bdatj.
YEAR = W_YEAR.
PERIOD = W_PERIOD.
IT_TEMP = SOURCE_PACKAGE.
SORT IT_TEMP BY PERNR.
DELETE ADJACENT DUPLICATES FROM IT_TEMP COMPARING PERNR.
DELETE IT_TEMP WHERE UPDATEDT = '00000000'.
* LOOP AT IT_TEMP ASSIGNING <SOURCE_FIELDS>.
LOOP AT IT_TEMP INTO WA_TEMP.
CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
EXPORTING
i_date = WA_TEMP-UPDATEDT
i_monmit = 00
i_periv = 'V3'
IMPORTING
e_buper = w_period
e_gjahr = w_year
EXCEPTIONS
input_false = 1
t009_notfound = 2
t009b_notfound = 3
OTHERS = 4.
IF SY-SUBRC = 0.
CALL FUNCTION 'FIRST_AND_LAST_DAY_IN_YEAR_GET'
EXPORTING
I_GJAHR = w_year
I_PERIV = 'V3'
IMPORTING
E_FIRST_DAY = zfirstdate
E_LAST_DAY = zlastdate
EXCEPTIONS
INPUT_FALSE = 1
T009_NOTFOUND = 2
T009B_NOTFOUND = 3
OTHERS = 4.
DELETE IT_TEMP WHERE UPDATEDT < zfirstdate.
DELETE IT_TEMP WHERE UPDATEDT > zlastdate.
DELETE IT_TEMP WHERE WFOPR <> 'DEMP'.
DELETE IT_TEMP WHERE INFTY <> '0002'.
ENDIF.
ENDLOOP.
BREAK-POINT.
SOURCE_PACKAGE[] = IT_TEMP[].
User | Count |
---|---|
82 | |
10 | |
10 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.