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 module or any other thing...

Former Member
0 Likes
977

Is there any function module to check whether current date falls under which quarter..

01.01.2007 to 31.03.2007 is first quarter,

01.04.2007 to 30.06.2007 is second quarter

01.07.2007 to 31.09.2007 is third quarter

01.10.2007 to 31.12.2007 is four quarter..

year will be divided in the above format and i need to check in which quarter the system date falls.. can any one sugest me any idea

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
929

Hi Alex,

Please check this FM.

BKK_GET_QUARTER_DATE

HR_99S_GET_QUARTER

Otherwise you can try this sample code from other thread.

Assuming date format is MM/DD/YYYY.


v1 = date+0(2).

if V1 = '01' or v1 ='02' or v1 = '03'.
  quarter = 1.
elseif V1 = '04' or v1 ='05' or v1 = '06'.
  quarter = 2.
elseif V1 = '07' or v1 ='08' or v1 = '09'.
  quarter = 3.
elseif V1 = 10' or v1 ='11' or v1 = '12'.
  quarter = 4.
endif.

Regards,

Ferry Lianto

8 REPLIES 8
Read only

Former Member
0 Likes
929

chk this

sorry this one

https://forums.sdn.sap.com/click.jspa?searchID=842442&messageID=2805380

Message was edited by:

Chandrasekhar Jagarlamudi

Read only

0 Likes
929

You can even check out these FM's

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

Regards,

Santosh

Read only

0 Likes
929

hi Alex,

I guess you cannot view that theread ... here is that answer..

report ztest_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.

Read only

Former Member
0 Likes
929

hi Alex,

Check out Rich's Answer in this thread

https://forums.sdn.sap.com/click.jspa?searchID=842366&messageID=2124693

Regards,

Santosh

Read only

Former Member
0 Likes
929

alex,

just take offset of date and check like.

v_date = sy-datum+4(2).

check v_date falls in between '01' and '03', then give 'first quarter'.

or '04 and '06' second quarter......

regds,

kiran

Read only

Former Member
0 Likes
930

Hi Alex,

Please check this FM.

BKK_GET_QUARTER_DATE

HR_99S_GET_QUARTER

Otherwise you can try this sample code from other thread.

Assuming date format is MM/DD/YYYY.


v1 = date+0(2).

if V1 = '01' or v1 ='02' or v1 = '03'.
  quarter = 1.
elseif V1 = '04' or v1 ='05' or v1 = '06'.
  quarter = 2.
elseif V1 = '07' or v1 ='08' or v1 = '09'.
  quarter = 3.
elseif V1 = 10' or v1 ='11' or v1 = '12'.
  quarter = 4.
endif.

Regards,

Ferry Lianto

Read only

Former Member
0 Likes
929

try this example....

data : v_date type i.

start-of-selection.

v_date = sy-datum+4(2).

if v_date ge 1 and v_date le 3.

write : 'first quarter'.

elseif v_date ge 3 and v_date le 6.

write : 'sec quarter'.

elseif v_date ge 6 and v_date le 9.

write : 'third quarter'.

elseif v_date ge 9 and v_date le 12.

write : 'fourth quarter'.

endif.

regds,

kiran

Read only

Former Member
0 Likes
929

Hi

Please check the following code

TYPE-POOLS: P99SG.

DATA: ws_permo TYPE p99sg_quarter.

CALL FUNCTION 'HR_99S_GET_QUARTER'

EXPORTING

im_date = sy-datum

IMPORTING

ex_quarter = ws_permo

ws_permo-q will contain the quarter number..