Skip to Content
author's profile photo Former Member
Former Member

Pl. provide ABAP logic

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

Add a comment
10|10000 characters needed characters exceeded

Related questions

5 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 13, 2012 at 11:18 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 16, 2012 at 09:35 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 13, 2012 at 10:12 AM

    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
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 13, 2012 at 11:31 AM

    Hi Neeraj,

    Is it possible to possible logic also ?

    Thanks in advance.

    Maddali VSKP

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 17, 2012 at 11:13 AM

    As issue resolved, I am closing the thread.

    Thanks,

    Maddali VSKP.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.