cancel
Showing results for 
Search instead for 
Did you mean: 

Customer exit to get data from 1st month to entered month

former_member808763
Discoverer
0 Kudos

Hello Experts , I need a Customer exit to fetch data from 1st month of the year to Entered month (based on FISCPER)

For example - If I enter May I should get all the data from January to May

Currently this is the code I have written (Variable = ZVAR_FISCPER1)

Please help me with correct logic


DATA:
l_s_range TYPE rrrangesid,
loc_var_range LIKE rrrangeexit,
lv_month TYPE d,
lv_year(4) TYPE n,
lv_first_month TYPE sy-datum,
lv_last_month TYPE sy-datum.

*To Calculate First Month of the year
CASE i_vnam.

WHEN 'ZVAR_FISCPER1'.
IF i_step = 2.
LOOP AT i_t_var_range into loc_var_range WHERE vnam = 'ZVAR_FISCPER1'.

lv_month = loc_var_range-low+4(2).
lv_year = loc_var_range-low+0(4).

CONCATENATE lv_year '01' INTO lv_month.
CALL FUNCTION 'CACS_DATE_GET_YEAR_MONTH'
EXPORTING
day_in = lv_first_month
IMPORTING
last_month_of_year = lv_last_month.
l_s_range-low = lv_first_month.
l_s_range-high = lv_last_month.
l_s_range-sign = 'I'.
l_s_range-opt = 'BT'.

APPEND l_s_range TO e_t_range.
ENDLOOP.
ENDIF.
ENDCASE.

endmethod.


jerryjanda
Community Manager
Community Manager
0 Kudos

Hi, Praveen:

Welcome to the SAP Community. Thank you for visiting us to get answers to your questions. If you're trying to learn how to do something for the first time, you're definitely in the right place!

Since you're asking a question here for the first time, I'd like to offer some friendly advice on how to get the most out of your community membership and experience.

First, please see https://community.sap.com/resources/questions-and-answers, as this resource page provides tips for preparing questions that draw responses from our members. Second, feel free to take our Q&A tutorial at https://developers.sap.com/tutorials/community-qa.html, as that will help you when submitting questions to the community.

I also recommend that you include a profile picture. By personalizing your profile, you encourage readers to respond: https://developers.sap.com/tutorials/community-profile.html.

Now for some specific suggestions on how you might improve your question:

* Outline what steps you took to find answers (and why they weren't helpful) -- so members don't make suggestions that you've already tried.

* Share screenshots of what you've seen/done (if possible), as images always helps our members better understand your problem.

* Make sure you've applied the appropriate tags -- because if you don't apply the correct tags, the right experts won't see your question to answer it.

Should you wish, you can revise your question by selecting Actions, then Edit.

The more details you provide (in questions tagged correctly), the more likely it is that members will be able to respond. As it stands, I don't know if there is enough information here for members to understand your issue. So please consider revising your question because I'd really like to see you get a solution to your problem!

I hope you find this advice useful, and we're happy to have you as part of SAP Community!

All the best,

--Jerry

Accepted Solutions (0)

Answers (1)

Answers (1)

Hemanth
Explorer
0 Kudos

Hi Praveen,

Can you please check if this function module(CACS_DATE_GET_YEAR_MONTH) exist in your Bw environment ?

former_member808763
Discoverer
0 Kudos

Hi Hemanth, Yes that Function didn't exist in my system so I have changed the code to as follows

Please tell me if this code will suffice my requirement or not

DATA:
l_s_range TYPE RSR_S_RANGESID,
loc_var_range TYPE RRRANGEEXIT,
lv_month TYPE d,
lv_year(4) TYPE n,
lv_first_month TYPE sy-datum,
lv_last_month TYPE sy-datum.

*To Calculate First Month of the year
CASE i_vnam.
WHEN 'ZVAR_FISCPER1'.
IF i_step = 2.
READ TABLE i_t_var_range into loc_var_range WITH KEY vnam = 'ZVAR_YEAR'.
lv_month = loc_var_range-low+4(2).
lv_year = loc_var_range-low+0(4).
concatenate lv_year '001' into lv_first_month.
lv_last_month = loc_var_range-low.
l_s_range-low = lv_first_month.
l_s_range-high = lv_last_month.
l_s_range-sign = 'I'.
l_s_range-opt = 'BT'.
APPEND l_s_range TO c_t_range.

ENDIF.
ENDCASE.

endmethod.