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

Regarding Between Dates

Hi Experts,

I am having this data.

PERNR ENDDA BEGDA

00000004 31.12.9999 01.02.2007

<b>00000004 31.01.2007 05.01.2007</b>

00000004 04.01.2007 13.11.2006

00000004 12.11.2006 14.01.1982

I want to fetch those records those will collapse in this month.

Regards,

Rajneesh Gupta

Add a comment
10|10000 characters needed characters exceeded

Related questions

6 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jan 08, 2007 at 05:51 AM

    Hi Rajneesh ,

    Use a between clause in your select statement .

    Please reward if useful.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 08, 2007 at 05:54 AM

    sorry can not get your actual requirement.

    if your internal table contains this data then you can do like this.

    loop at itab.

    if itab-endda(6) ne itab-begda(6).

    delete itab index sy-tabix.

    endif.

    endloop.

    please clear me if it is not your requirement.

    regards

    shiba dutta

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 08, 2007 at 05:55 AM

    Hi,

    Store the date by concatenating the month and year from sy-datum and using 01 for date in a variable called v1.

    select * from db into table itab where begda > = v1 and endda < = v1.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 08, 2007 at 05:57 AM

    Hi Rajneesh,

    Please refer the reply of Kripa in the link,

    sample code for month / year needed

    Similarly you can fetch for the specific month data.

    Hope this helps.

    Regards,

    Hema.

    • Reward points if it is useful.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 08, 2007 at 05:58 AM

    Hello Rajneesh

    You could use a function module like HR_JP_MONTH_BEGIN_END_DATE to determine begin date and end date of a month based on a single date. Then you select:

    SELECT * FROM <guess some infotype> INTO TABLE gt_itab
       WHERE ( endda >=  ev_month_begin_date  AND
                      endda <=  ev_month_end_date )
       AND      ( begda >=  ev_month_begin_date  AND
                      begda <= ev_month_end_date ).

    00000004 31.12.9999 01.02.2007: 01.02.2007 > 31.01.2007 -> not selected

    00000004 31.01.2007 05.01.2007: selected

    00000004 04.01.2007 13.11.2006: 13.11.2006 < 01.01.2007 -> not selected

    00000004 12.11.2006 14.01.1982: 12.11.2006 < 01.01.2007 -> not selected

    Regards

    Uwe

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 08, 2007 at 06:11 AM

    hi Rajneesh,

    Just copy this demo code of mine ,it will serve ur purpose..u have to just fetch dat based on ur requirement from databsae and then use my logic as below..solution 2 is exactly same as tht of ur requirement.

    reward if helpfull.

    1)tables pa0006.

    data:begin of itab occurs 0,

    pernr like p0006-pernr,

    begda like p0006-begda,

    endda like p0006-endda,

    end of itab.

    data itab1 like table of itab with header line.

    data d_beg like p0006-begda.

    data d_end like p0006-begda.

    select * from pa0006 up to 20 rows into corresponding fields of table itab.

    loop at itab.

    d_beg = itab-begda.

    CALL FUNCTION 'RP_LAST_DAY_OF_MONTHS'

    EXPORTING

    day_in = d_beg

    IMPORTING

    LAST_DAY_OF_MONTH = d_end.

    • EXCEPTIONS

    • DAY_IN_NO_DATE = 1

    • OTHERS = 2 .

    if itab-endda ge d_beg and itab-endda le d_end.

    move itab to itab1.

    append itab1.

    endif.

    endloop.

    loop at itab1.

    write:/ itab1.

    endloop.

    2) tables pa0006.

    data:begin of itab occurs 0,

    pernr like p0006-pernr,

    begda like p0006-begda,

    endda like p0006-endda,

    end of itab.

    data itab1 like table of itab with header line.

    data d_beg like p0006-begda.

    data d_end like p0006-begda.

    *select * from pa0006 up to 20 rows into corresponding fields of table itab.

    Clear itab.

    itab-pernr = '00000004'.

    itab-begda = '20070105'.

    itab-endda = '20070131'.

    append itab.

    itab-pernr = '00000004'.

    itab-begda = '20070201'.

    itab-endda = '99991231'.

    append itab.

    loop at itab.

    d_beg = itab-begda.

    CALL FUNCTION 'RP_LAST_DAY_OF_MONTHS'

    EXPORTING

    day_in = d_beg

    IMPORTING

    LAST_DAY_OF_MONTH = d_end.

    • EXCEPTIONS

    • DAY_IN_NO_DATE = 1

    • OTHERS = 2 .

    if itab-endda ge d_beg and itab-endda le d_end.

    move itab to itab1.

    append itab1.

    endif.

    clear itab.

    endloop.

    loop at itab1.

    write:/ itab1.

    endloop.

    Message was edited by:

    Amit Tyagi

    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.