Date range selection in abap code in infopackage

Hi!
I have a field called "OPEN_DATE".
When the infopackage is runned, I need the abap code to fint the current date, and from that, make a date range from the first day of current month to the last day of current month
Ex:
Current date = 12.12.2008
Abap code should extract 01.12.2008 - 31.12.2008
Thanks!

Hi helge,
Data: l_idx like sy-tabix.
Data: date_low like sy-datum,
         date_high like sy-datum.
Date_low = sy-datum.
date_low+6(2) = '01'.
CALL FUNCTION 'SLS_MISC_GET_LAST_DAY_OF_MONTH'
  EXPORTING
    DAY_IN                  = Date_low
IMPORTING
   LAST_DAY_OF_MONTH       = date_high
read table l_t_range with key
fieldname = 'OPEN_DATE'.
l_idx = sy-tabix.
Pass Range values to L_T_Range Table.
Move date_low to L_T_Range -Low.
Move date_high to L_T_Range -High.
L_T_Range -Sign = u2018Iu2019. *****(Here: I u2013 Include, E u2013 Exclude)
L_T_Range -Option = u2018BTu2019.****( Here: BT u2013 Between )
modify l_t_range index l_idx.
p_subrc = 0.
Regards,

Similar Messages

  • How to count the days between Date Range using OO ABAP?

    hi experts,
            i want to count the days between Date Range using OO ABAP for that  which class and method  can i use?.
    Thanks,
    Mahesh.

    Not sure I understand the requirement for it to be OO, but you could always write your own (i.e. use this):
    REPORT zz_date_diff.
    CLASS date_diff DEFINITION.
      PUBLIC SECTION.
        METHODS diff IMPORTING     i_date_fm TYPE d
                                   i_date_to TYPE d
                     EXPORTING     e_days    TYPE i.
    ENDCLASS."
    CLASS date_diff IMPLEMENTATION.
      METHOD diff.
        e_days = i_date_to - i_date_fm.
      ENDMETHOD."
    ENDCLASS."
    DATA: g_ref TYPE REF TO date_diff,
          g_days  TYPE i,
          g_date_fm  TYPE d VALUE '20080101',
          g_date_to  TYPE d VALUE '20090101'.
    START-OF-SELECTION.
      CREATE OBJECT g_ref.
      CALL METHOD g_ref->diff
        EXPORTING
          i_date_fm = g_date_fm
          i_date_to = g_date_to
        IMPORTING
          e_days    = g_days.
      WRITE g_days.

  • Date Range Selection in Query Templates

    Hi,
    Can someone please tell me how to use <b>Date Range Selection</b> Tab details in SQL Query and TAG Query (Using Examples).
    Thanks in advance
    Muzammil P.T

    >>>>>>>>>>
    Re: Date Range Selection in Query Templates   
    Posted: Feb 15, 2007 6:43 AM    in response to: Muzammil Ahamed       Reply      E-mail this post 
    Hi Muzammil,
    In data range section you can have multiple options like setting start datetime and end datetime.. And you can set the shift (or) time period and also the format of the time periods.
    Primarily we use the start date and end date querying to fetch data between two time labels. I can explain this one with example..
    You have batch production table with columns Production Time, Batch Id, Production Qty. Then you want all the details between the 02/02/2007 to 05/02/2007.
    Solution :
    1.Map 02/02/2007 with Start date.
    2.Map 05/02/2007 with end dare.
    Now these two become the variables [SD] and [ED].
    Now you have mentioned the date range, but you need to mention for which column these things to be applied. For that
    3.In Query tab enter Production Time column name in Date column at the bottom.
    Now you have written query like Select * from batch prodcution where production time > 02/02/2007 and production time < 05/02/2007.
    4. Even those values you mapped (SD and ED) you can change from the front page through Java script.
    Like wise you have so many other advantages also.
    If you have any other specific doubt let me know.
    Thanks,
    Rajesh.
    PS : Please ward points if answer is useful. <<<<<<<<
    Message was edited by:
            David Dreyer

  • About Date Range Selection in Contributor Recognition Program- List

    Hello SCN,
    Happy that we have a classified date range selection like Year wise, Contest period wise and also with date range in the Top Contributors list. However earlier we had a luxury to see the point classified as  "All Time Contribution".  I personally feel to get back this option as well in the list.
    Dear SDNers share your suggestion on this.
    Thanks,
    SaNv....

    Hi,
    If you want the user to select the date directly rather than entering, you need not to have a dropdown menu in WAD. Directly go to the query which you have selected for the object in WAD, there create a variable with calendar. Put it mandatory, so that the user selection of the date will be mandatory. The variable will be automatically be available when you execute the template inn the browser.
    Assign points if this helps u.
    Regards,
    Koundinya.

  • Display of 2 rows of data for 2 different date range selection

    Hi Folks,
    I have a requirement as follows,
    User has an option of selecting 2 Date Ranges
    From and To Date and again From and To Date
    The result should display 2 different rows of data with From and To Date range selection.
    Eg:
    12/09/20008 to 03/09/2009           10 20 30 40
    23/10/2009 to  18/12/2010           40 20 10 30
    Difference                                   30 0  20 10
    % Change                                   x  y  z   q
    Thanks for your input.
    Regards,
    KJ

    You will need to use union report, and you would have fours union's in this report.
    Union - 1: Data from 1st Date Range
    Union - 2: Data from 2nd Date Range
    Union - 3: Variance Calculation
    Union - 4: Percentage Variance Calculation.
    If the date's are coming from the same field, use cast function to use the same column twice in your prompts. Apply filters on each union as needed.
    Thanks.

  • Debug ABAP code in InfoPackage

    Hi friends,
    How i can debug a ABAP code from a variable selection in Infopackage?
    Thanks,
    EA

    I guess you would have figured it out - but for the use of people who might chance upon this post while searching ...
    to debug the ABAP code in an Infopackage - you need to run it in dialog mode ( Start Data Load Immediately ) and not in background. This is because background processes cannot be debugged.

  • Improve data load performance using ABAP code

    Hi all,
             I want to improve my load performance using ABAP code, how to do this?. If i writing ABAP code in SE38 how i can call
    in BW side? if give sample code to improve load performance it will be usefull. please guide me.

    There are several points that can improve performance of your ABAP code:
    1. Avoid using SELECT...ENDSELECT... construct and use SELECT ... INTO TABLE.
    2. Use WHERE clause in your SELECT statement to restrict the volume of data retrieved.
    3. Use FOR ALL ENTRIES in your SELECT statement to retrieve the matching records at one shot.
    4.Avoid using nested SELECT and SELECT statements within LOOPs.
    5. Avoid using INTO CORRESPONDING FIELDS OF. Instead use INTO TABLE.
    6. Avoid using SELECT * and select only the required fields from the table.
    7. Avoid Executing a SELECT multiple times in the program.
    8. Avoid nested loops when working with large internal tables.
    9.Whenever using READ TABLE use BINARY SEARCH addition to speed up the search.
    10. Use FIELD-SYMBOLS instead of a work area when there are more than 200 entries in an internal table where some fields are being manipulated.
    11. Use MOVE with individual variable/field moves instead of MOVE-CORRESPONDING.
    12. Use CASE instead of IF/ENDIF whenever possible.
    13. Runtime transaction code se30 can be used to measure the application performance.
    14. Transaction code st05 can be used to analyse the SQL trace and measure the performance of the select statements of the program.
    15. Start routines can be used when transformation is needed in the data package level. Field/individual routines can be used for a simple formula or calculation. End routines are used when you wish to populate data not present in the source but present in the target.
    16. Always use a WHERE clause for DELETE statement. To delete records for multiple values, use SELECT-OPTIONS.
    17. Always use 'IS INITIAL' instead of equal to '' because null for a character is '' but '0' for an integer.
    Hope it helps.

  • Date Range Selection

    Dear friends,
    How to select the record from BSEG table between Date range. Please give me the solution . Am also try to find the solution in SDN also.
    select-options post_dt for bkpf-budat obligatory default sy-datum NO-EXTENSION.
    select belnr budat from bkpf into corresponding fields of table it_head
        where bukrs eq compcode
        and gjahr eq year
        and blart eq doctype
        and budat in post_dt
        order by belnr budat.
    For this select query is working in perfect for single date only. But i want to select the date date range wise.
    Thanks
    Saravanan R

    HI,
           U can check the Select Quert by using IN s_option.
    Like eg:--
        Select * form Zemp where empno in s_empno.
    Hope this example will help u...
    here Zemp is a table...... empno is a field     s_empno is a Select-option.
    Thanks and rEgards
    Suraj S Nair

  • How to use 2 Dropdown box in webapplication for date range selection

    Dear all,
    I am working on a report that will show 2 drop down boxes. These should be used as a date range.
    This works fine if I use 2 variables as a date range on 0CALYEAR. However I dont want the user to fill in the dates but selecting the dates with 2 drop down boxes.
    I cannot manage to get this to work. I saw some comments about user exits in the forum but I cannot figure it out if there is an easier way.
    Could you give me an idea of what to do?
    Thanks a lot,
    Andreas

    Hi,
    If you want the user to select the date directly rather than entering, you need not to have a dropdown menu in WAD. Directly go to the query which you have selected for the object in WAD, there create a variable with calendar. Put it mandatory, so that the user selection of the date will be mandatory. The variable will be automatically be available when you execute the template inn the browser.
    Assign points if this helps u.
    Regards,
    Koundinya.

  • Date range select

    Hello
    i have a table with records
    id number , start_date date , end_date date .
    I want to select all ids that are with in an acceptable date range
    ex. table data ( mm/dd/yyyy)
    1 , 1/1/2008 , 1/4/2008
    2. 1/3/2008 , 1/10/2008
    3 1/12/2008 , 1/15/2008
    4 1/4/2008 , 1/8/2008
    5 1/5/2008 , 1/6/2008
    i want to find all ids that the dates between 1/3/2008 and 1/4/2008
    exists in their date range
    acceptable record ids are 1 ,2 and 4
    Thank you

    i want to find all ids that the dates between 1/3/2008 and 1/4/2008
    select id from your_table
    where start_date <= to_date('1/4/2008')
    and end_date >= to_date('1/3/2008')Cheers, APC
    Blog : http://radiofreetooting.blogspot.com/

  • Create new survey data for opportunity using abap code

    Hello to all,
    I have one requirement.
    create survey data for given opportunity ID using abap code. or copy survey data from one opportunity to another opportunity using abap.
    any ideas..
    many thanks
    Babu

    Hello Babu,
    You can do this through the CRM_ORDER_MAINTAIN FM, this is the generic FM to edit any transaction in CRM.
    The FM contains an internal table IT_SURVEY that must be filled. Actually, this table will only contain a reference to the (completed) survey, it doesn't store the data of the survey itself.
    For some example coding, take a look at the SrvTSurvey.do controller. If you want to see what data is stored in the IT_SURVEY table, create a transaction and attach a completed survey to it (you can easily do it in the standard views of the webclient) and take a look at the survey structure in the CRM_ORDER_READ FM/Report.
    Let me know if you need more guidance,
    Reward points if useful,
    Regards,
    Joost

  • Drop Down Box for Date Range Selection

    I have multiple queries on the same worksheet with different variables for each.  To simplify changing the one consistent variable, the date range, I have added a drop down box tied to all infoproviders in the query.  This would work if I wanted to select a single date but I cannot determiine how to select a date range (01/2010 - 12/2010).  Any ideas on how I might accomplish this?  I am using Netweaver 7.1.

    You can use two single-input variables: one for DATE FROM and the other for DATE TO and use them in query definition to restrict the date (restriction type: Range between DATE FROM and DATE TO).
    Then you create two dropdown boxes, one for each variable.
    Regards,
    Dorota

  • Date range selection from session/server variables - possible solution

    I've recently been creating some reports who'se selection is based on the contents of a session variable, using this against a date field. Thought I'd share with everyone how I did it.
    1/ Create a server/static variable called DATE_FORMAT who'se contents are 'dd/mm/yy' . Note, should include the single quotes.
    2/ Create 2 session variables that represent the beginning/end date range for your selection you are after - in my case, it was the first & last date of the previous month, PREVIOUS_PERIOD_FROM and PREVIOUS_PERIOD_TO
    3/ In the selection, add a filter on the date field in question, set the Operator as "is between".
    4/ for each of the 2 valaues, select Add->SQL expression and enter:
    EVALUATE('TO_DATE(%1,%2)',VALUEOF(NQ_SESSION."PREVIOUS_PERIOD_FROM"),VALUEOF("DATE_FORMAT"))
    and
    EVALUATE('TO_DATE(%1,%2)',VALUEOF(NQ_SESSION."PREVIOUS_PERIOD_TO"),VALUEOF("DATE_FORMAT"))

    HI,
           U can check the Select Quert by using IN s_option.
    Like eg:--
        Select * form Zemp where empno in s_empno.
    Hope this example will help u...
    here Zemp is a table...... empno is a field     s_empno is a Select-option.
    Thanks and rEgards
    Suraj S Nair

  • Issue in sorting data in already existing abap code

    Hi all,
    I have a code which fetches the data into an internal table. The content of the internal table is as follows(example):
    1) Header 1 amount 1
    2) item1 amount 2
    3) item1 amount 3
    4) item1 amount 4
    5) header 1 amount 5
    6) item2 amount 6
    7) item2 amount 6
    8) item2 amount 6
    9) item2 amount 6
    10)header1 amount 7
    Now i need to modify the code in such a way that the output should add up all the amounts of the header and a line items and should be displayed at the end of the line items as follows.
    1) item1 amount 2
    2) item1 amount 3
    3) item1 amount 4
    4) item2 amount 6
    5) item2 amount 6
    6) item2 amount 6
    7) item2 amount 6
    8)header1 total amount
    I tried using collect statement, but the header is being displayed at line1 and not line 8 where needed.
    Please do help me and let me know how best can i modify my code.
    In case you are wondering what my req is , it is based on the OB58 configuration.

    HI,
    u have told this scenario -->
    1) Header 1 amount 1
    2) item1 amount 2
    3) item1 amount 3
    4) item1 amount 4
    5) header 1 amount 5
    6) item2 amount 6
    7) item2 amount 6
    8) item2 amount 6
    9) item2 amount 6
    10)header1 amount 7
    I iam not wrong then i think u want the o/p in this way
    1) item1 amount 9
    2) item2 amount 24
    3)header1 amount 13
    But one doubt can there be scenario in this way to if am not wrong
    1) Header 1 amount 1
    2) item1 amount 2
    3) item1 amount 3
    4) item1 amount 4
    5) header 1 amount 5
    6) item2 amount 6
    7) item2 amount 6
    8) item2 amount 6
    9) item2 amount 6
    10)header1 amount 7
    11) header 2 amount 5
    12) item2 amount 6
    13) item2 amount 6
    14) item2 amount 6
    15) item2 amount 6
    16)header2 amount 7
    Regards,
    Madhukar Shetty

  • Date Range: Select which Qtr a date falls into

    Hi All
    I am looking for some code that takes a date passed into a variable and calculates which Quarter it is in.
    My client uses Quarters:
    Feb - Apr (Q1)
    May - Jul (Q2)
    Aug - Oct (Q3)
    Nov - Jan (Q4)
    So, if I pass a date of 21-Mar-2007 into the Variable, the code takes the date, calculates that the date is in Q1 and then returns the date of 200702 (the YEAR/ MONTH of the First Month in the Quarter) into the BW report.
    I have searched the forums and can't find anything that would work, so you help is much appreciated.
    DG

    Hi Ajay
    Thanks very much for your response.
    I'm having a few difficulties getting the code to work in our environment, so was hoping you could help me tune it.
    Input is Current Month
    Output is First Month of Current Quarter
    So, using this code, how can I pass the input date into the code?
    (I'm sorry if this is obvious, I'm really new to SAP Development, so the answer may be and most probably is really obvious)

Maybe you are looking for