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

function to get quarter

kowong
Participant
0 Likes
7,982

Hi all

Hi , is there any function to get Current Quarter of the year??

Thank you all

3 REPLIES 3
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
2,783

Don't think that there is a standard function. You will need to determine what the current period which sy-datum falls under using function module 'FI_PERIOD_DETERMINE'. Then in your code, you will need to determine the 4 buckets for the quarters in ranges. Then check the value against each range.

REgards,

Rich Heilman

Read only

0 Likes
2,783

Take the following for example.....



report zrich_0001.

data: xspbup type spbup.

data: xgjahr type bkpf-gjahr.
data: xpoper type t009b-poper.
data: check_spbup type spbup.


ranges: q1 for xspbup.
ranges: q2 for xspbup.
ranges: q3 for xspbup.
ranges: q4 for xspbup.

q1-sign = 'I'.
q1-option = 'BT'.
q1-low+0(4) = sy-datum+0(4).
q1-low+4(2) = '01'.
q1-high+0(4) = sy-datum+0(4).
q1-high+4(2) = '03'.
append q1.

q2-sign = 'I'.
q2-option = 'BT'.
q2-low+0(4) = sy-datum+0(4).
q2-low+4(2) = '04'.
q2-high+0(4) = sy-datum+0(4).
q2-high+4(2) = '06'.
append q2.

q3-sign = 'I'.
q3-option = 'BT'.
q3-low+0(4) = sy-datum+0(4).
q3-low+4(2) = '07'.
q3-high+0(4) = sy-datum+0(4).
q3-high+4(2) = '09'.
append q3.

q4-sign = 'I'.
q4-option = 'BT'.
q4-low+0(4) = sy-datum+0(4).
q4-low+4(2) = '09'.
q4-high+0(4) = sy-datum+0(4).
q4-high+4(2) = '12'.
append q4.


call function 'FI_PERIOD_DETERMINE'
     exporting
          i_budat = sy-datum
          i_periv = 'YT'
     importing
          e_gjahr = xgjahr
          e_poper = xpoper.

check_spbup+0(4) = xgjahr.
check_spbup+4(2) = xpoper.

if check_spbup in q1.
  write:/ 'This date is under Q1'.
endif.
if check_spbup in q2.
  write:/ 'This date is under Q2'.
endif.
if check_spbup in q3.
  write:/ 'This date is under Q3'.
endif.
if check_spbup in q4.
  write:/ 'This date is under Q4'.
endif.

Regards,

Rich Heilman

Read only

ferry_lianto
Active Contributor
0 Likes
2,783

Hi Kokwei,

Please check this FM.

BKK_GET_QUARTER_DATE

TSTR_PERIODS_QUARTERS

HR_99S_GET_DATES_QUARTER

SLIM_GET_QUARTERLY_PERIODS

RS_VARI_V_QUARTER1XXXX

RS_VARI_V_QUARTER2XXXX

RS_VARI_V_QUARTER3XXXX

RS_VARI_V_QUARTER4XXXX

Hope this will help.

Regards,

Ferry Lianto

Please reward points if helpful.