Can any body help me in providing the logic (ABAP logic-infopackage) for extracting data for 6th month considering sydatum.
Logic should be on Caday.
Example: If I am executing I/P today i.e. 13.01.2012, I should get the data of 01.06.2011 to 30.06.2011.
Please help.
Thanks in Advance.
Maddali VSKP
Hi,
1. put sy-datum in a local date variable.
2. check using offset if the month is less than or equal to 6 . ( ex:- curr_month = curr_date+3(2). )
3. if yes then reduce the year by one and add 5 to the month
4. if no then keep the same year and reduce 6 from the month
5 take the first day of the month
6. pass the first day of the month to FM "/OSP/GET_DAYS_IN_MONTH" to get the number of days in a month . this will give last day of the month
Regards,
Neeraj.
Hi,
As I am not core ABAPER, I tried below logic in the development. Logic is working fine. I am getting expected results.
_______________________________________________
DATA: l_cur_month(2) type n,
l_pre_month(2) type n,
l_cur_year(4) type n,
z_ppredat type DATS,
z_ppredat1 type INT1,
z_ppredat2(8) type n,
z_ppredat3(2) type n,
l_pre_year(4) type n.
data: l_idx like sy-tabix.
read table l_t_range with key
fieldname = 'CALDAY'.
l_idx = sy-tabix.
*....
l_cur_month = sy-datum+4(2).
l_cur_year = sy-datum(4).
l_pre_year = sy-datum(4).
if l_cur_month >= 7.
l_pre_month = l_cur_month - 7.
endif.
if l_cur_month <= 6.
l_pre_year = l_cur_year - 1.
.
l_pre_month = 12 - ( 7 - l_cur_month ).
endif.
break-point.
concatenate l_pre_year l_pre_month '01'
into z_ppredat.
CALL FUNCTION '/OSP/GET_DAYS_IN_MONTH'
EXPORTING
IV_DATE = z_ppredat
IMPORTING
EV_DAYS = z_ppredat1 .
z_ppredat3 = z_ppredat1.
concatenate l_pre_year l_pre_month z_ppredat3
into z_ppredat2.
concatenate "l_pre_year l_pre_month z_ppredat1" into z_ppredat2
l_t_range-sign = 'I'.
l_t_range-option = 'BT'.
l_t_range-low = z_ppredat.
l_t_range-high = z_ppredat2.
modify l_t_range index l_idx.
p_subrc = 0.
_________________________________________
Request you to help me to validate the logic.
Thanks in Advance,
Maddali VSKP
Hi ,
You can simply create the OLAP variable for the same .For Infopackage/DTP istep is taken as less then 2.
Then you can use the Function module DATE_GET_MONTH to get the current month based up on the calday .
Then using table L_T_RANGE-LOW you can pass current month - 6 and in L_RANGE-HIGH you can pass the variable for the month that you are getting from the FM as mentioned above .
L_T_RANGE-SIGN = 'i' and L_T_RANGE-OPTION = 'BT'.
You can easily achieve this implementing the logics mentioned above .
You got the logic right .
Let me know in case any thing more is required from my side .
Thanks
Kamal Mehta
Add a comment