Date fetching from table

I have a customized table which contains monthwise details.say 12 entries for an year.I want to fetch the previous 5 month entries from the table wrto sy-datum.
ie) if the month is 08 , then i want the records frm 03-07.
ie) if the month is 02, i want the records 01,12,11,10,09.
What logic to use?
Rgds,
SAPUSER100

Hello,
You have to also consider the year in your selection. so, change in the logic ...
data: begin of r_mon occurs 0,
mon(2),
year(4),
end of r_mon.
l_month = sy_datum+4(2) - 1.
l_year = sy_datum+0(4).
do 5 times.
r_mon-mon = l_month.
r_mon-year = l_year.
append r_mon.
clear  r_mon
l_mont = l_month - 1.
if l_month = 0 .
l_month = 12.
l_year = sy_datum+0(4) - 1.
endif.
enddo.
Once you got filled your range of the Month,
I would advice like,
loop at r_mon.
select * from ztab
appending table itab
where mon = r_mon-mon
and   year = r_mon-year.
endloop.
Regards,
Naimesh

Similar Messages

  • Data fetch from table without Refresh and without using tab key.

    hi Friends,
    I have a problem i want to extract data from table without Refresh into text field without using Tab key. when i'll enter any value in a text field then corressponding value should come in to corressponding textfield without using Tab Key.
    eg. when i enter emp_id 101 in a text field then the first_name and last_name ,adress should come in to corressponding text fields without refresh and without using Tab key.
    How Can I do this.
    Thanks
    Manoj

    Hi Manoj,
    I assume that this is similar to: Data fetch without Refresh rather than Re: Value of one textfield should come into another textfield Without Using TAB ?
    If so, the only change you need to make on the first one is to use "onkeyup" instead of "onchange" in the item's "HTML Form Element Attributes" setting.
    Note, however, that the user must move away from the item at some point (for example, to click a button), so the onchange will be triggered anyway.
    Andy

  • Data fetch from table

    i have to select data from a database table into internal table but i want that it shud be selected as it is means i have a char 30 field which may have CAPS and small values in table but in the internal table it comes as all CAPS but it shud come as it is e.g "Data" shud come as "Data" in internal table but it comes as "DATA".

    Just check the Domain of the concerned field. There will be a characteristic check box called "lower case" in the Definition tab of your domain. See if that is Flagged. If that is flagged, then the stored record will be case sensitive. In best practice, you should not have that flagged, So that the records will not be case sensitive and you will not have to face a similar situation.
    Hope this helps.

  • Data fetch from table GLPCA taking long .

    Hi Friends,
    I am fetching five fields from GLPCA table and i have RACCT and RPRCTR ( account Number and profit Centre res ) in the where condition. neither of these field is the primary key of the table GLPCA. I have around 161096,482 entries in the GLPCA. It takes around 20 min to fetch the data. can you guys think of some method so that it works faster.

    Hi Vidya,
    The time utilization is due to the way data base is been accessed. Just think that you are selecting same data in SE16 with 200 hits. See how that behaves. If you find its Ok(i.e. around 1/2 mins) go for open cursor logic. Check this syntax and change the code accordigly and try:
    OPEN CURSOR w_cur1 FOR
           SELECT  ktabg vkorg ktaar ktaer kunnr
                   vtweg spart
                   FROM vbka
                   WHERE ktabg IN so_ktabg AND
                         vkorg IN so_vkorg AND
                         kunnr IN so_kunnr AND
                         ktaar IN so_ktaar AND
                         ktaer IN so_ktaer.
        DO.
          FETCH NEXT CURSOR w_cur1 INTO CORRESPONDING
                FIELDS OF TABLE it_vbka2 PACKAGE SIZE 200.
          IF sy-subrc NE 0.
            CLOSE CURSOR w_cur1.
            EXIT.
          ENDIF.
       ENDDO.
      It behaves just like Select ... Endselect. The most important thing here is the Pakage size which you have to decide based on the SE16 results. Also please mind that if the Package size is less, number of times it hits the DB is high, reducing the efficiency thereby.
    Regards & Thanks,
    Anand

  • Data fetching from BSEG table

    Hi,
    I have used smartforms for generating suppler payment statement for financial department. more time duration is taken by the program when it is generating.
    I think this problem comes while data fetching from BSEG table. because, it has more records for one vendor ID.
    I want reduce this time duration.
    Please guide me.

    Have you tried this selection in se16? I'm quite sure that It will take
    a long time.
    The problem has been explained in this group before and I think you
    should search for bseg in the answers given.
    As a hint: It has to do with the selection universe. You are restricting
    only bukrs from the primary key (all the other restrictions in your
    where clause are filters that are applied on SAP's side (not on the
    database side)). The problem is that bseg isn't stored as separated
    fields in the RDBMS, but as a table with the primary key and a stream of
    bits in a raw field.
    You should review and change the logic you're using before reading bseg.
    It's the only way you'll improve the performance of this select. (for
    example, you could use one or more secondary index tables - bi or ba
    to retrieve belnr and access bseg with a better where clause).

  • Data fetching from Standard tables or transaction to SAP PI

    Dear Friends !
         Good day ! How are you ? 
         I have one requirement , My client asks me to develop a solution in that I should get the data from standard SAP tables like EKKO, EKPO ( MM related ) etc..  and send it to PI system and then PI system sends it to third party system database system.
    We have current scenario is working fine,  I have abap proxy that I called in various  standard transaction codes ( MIRO, MIGO, etc ) ' Baddis just beforethe commit stament and it passed the data to SAP PI system and it sends to SQL system.
    but my client dont want me to use Baddis. Client wants  like u should read from those EKKO,EKPO tables as soon as you get new entry there and send it to PI system.  I have no clue How can I go further in that. Shall I use events ? but then question is same I need to trgger them somewere?  Is any one have idea  How I can send the data to PI system frm SAP standard tcodes and tables without using Baddis.
    Please reply me. your any help will be appreciated.
    Regards
    Naeem

    The current Approach of your development perfectly good approach,
    it is not possbiel to read data directly from SAP Tables, you have to use IDoc/RFC/Proxy,if you want to avoid BADI's then better to contact ABAP Team, they will help you different approches .
    But you have to use Porxy/IDoc/BAPI for sure.
    Regards,
    Raj

  • Perofrmance issue on data fetch from db table

    Dear Experts,
    I have one requirement which explained below step wise.
    Step - 1 : I have a parameter on selection screen from where i ll get my ebeln value (User Input field) and that ebeln i ll check in ekpo table for validations.
                  If valid i  keep it in a variable gw_ebeln.
    Step - 2 : Need to fetch lifnr fron ekko based on gw_ebeln value.
    Step - 3 : Need to fetch adrnr from lfa1 based on lifnr (Previously fetched from ekko table in step 2)
    Step - 4 : Need to fetch email field from adr6 table based on adrnr value (Previously fetched from lfa1 table in step 3)
    Step - 5 : Now for these mail id , I need to send mail by given fm.
    My question is : I can create structure for step 2 , step 3, step 4 and by using " for all entries " in select statement i ll fetch my mail id in step 4.
    So instead of creating structure and then use for all entries , I can fetch by using "select single" statement for step 2 , step3 step 4.bcz i am fetching only one field from all 3 table.
    So which one is better performance wise and why ?
    I need more and clear clarifications on these difference.
    Please provide me suggestions.
    Thanks & Regards,
    Ajit Sarangi

    Hi Ajit,
    We are referring item table EKPO. Multiple entries are possible.
    To append the values in final internal table, we are going to process the LOOP. Inside loop, we should not use the Select statement, that decreases the performance. Database Interaction process should not done inside Loop...Endloop.
    That's why we are creating the Internal table for processing the values. Since we need limited number of fields in the particular table, we are creating our own structure in the program.
    For this case, For all entries will give better performance with compare to Select Single.
    Regards
    Rajkumar Narsimman

  • Data fetched from buffer or database

    Hi,
    How to check tin the select query the data is being fetched from buffer or database .Is there any method to trace that  or it is just the setting we are  doing while creating a table..
    Pls suggest

    Hi,
    >
    arun purushothaman wrote:
    >Is there any method to trace that  or it is just the setting we are  doing while creating a table..
    > Pls suggest
    sure. ST05.
    SQL Trace shows everything that is going to the database. This means those statements are NOT
    using the buffer. The SQL Trace lines are yellow.
    Buffer Trace shows everything that is going to the buffer. This means those statements are NOT
    going to the database. The Buffer Trace lines are blue.
    Kind regards,
    Hermann

  • Fetching from tables

    a report is being generated in which we put sold to party,delivery date and plant.This gives us some output
    Now we have to add two fields that is loading date and ship to party in the screen and the output has to be same as the previous.can u please guide me as to how can i fetch the data.

    Hi,
    First of all check that two fileds exits same table where you are adding new fields in select stament.
    SELECT Field1 Field2 Newfield1 Newfield2
    FROM Table
    INTO CORRESPONDING FIELDS OF TABLE Internal_Table
    WHERE Conditions (Newfield1).
    Once you added two new fileds in same manar you should update internal table structure also then only that values passes in to that internal table.
    Regads
    Md.MahaboobKhan

  • Data relocation from table SOFFCONT1

    Hi experts,
    I have to relocate data from table SOFFCONT1 to an external repository with help of report RSIRPIRL...I went through all related Sap notes and it seems pretty straightforward.
    When I run the report RSIRPIRL I see all the fields I have to fill up (I have already created an content repository as well as a catalogue) but my question is how to select some data manually for testing purpose? Is it any way how to see from table SOFFCONT1 just 1 file for example?? I couldn't see that field in the report RSIRPIRL.
    Regards,
    Blaiso

    Applied OSS note 1536325 which will add an extra field to select by date and narrow the number of documents to test

  • Data retrivel from table ausp table

    Helllo Experts,
    I want to retrive data from table ausp based on the data retrived from the VBAK table.
    I have selected data from VBAK and VBAP tabble using code :
    SELECT VKORG VTWEG VBAKSPART VKGRP VKBUR KUNNR KNUMV VBAKVBELN VBAPMATNR VBAPARKTX INTO CORRESPONDING FIELDS OF  TABLE GT_DATA
    FROM VBAK INNER JOIN VBAP ON VBAKVBELN = VBAPVBELN
    WHERE VKORG        IN SVKORG
    AND  VTWEG        IN SVTWEG
    AND  VBAK~SPART   IN SSPART
    AND  VKGRP        IN SVKGRP
    AND  VKBUR        IN SVKBUR
    AND  KUNNR        IN SKUNNR
    AND  MATNR        IN SMATNR.
    SELECT MATNR BREIT ZEINR BRGEW INTO CORRESPONDING FIELDS OF TABLE GT_EANCODE FROM MARA
    FOR ALL ENTRIES IN LT_DATA WHERE MATNR = GT_DATA-MATNR.
    SORT GT_EANCODE BY MATNR.
    ENDIF.
    SELECT MATNR MVGR1 MVGR2 MVGR3 INTO CORRESPONDING FIELDS OF TABLE GT_MVGR FROM MVKE
    FOR ALL ENTRIES IN LT_DATA WHERE MATNR = LT_DATA-MATNR.
    SORT GT_MVGR BY MATNR.
    ENDIF.
    SELECT KNUMV KPOSN KSCHL KWERT INTO CORRESPONDING FIELDS OF TABLE GT_KONV  FROM KONV
    FOR ALL ENTRIES IN LT_DATA WHERE KNUMV = LT_DATA-KNUMV AND KSCHL IN ('ZG02').
    SORT GT_KONV BY KNUMV.
    So based on the material field in the table GT_DATA i have to select data from table ausp. The ausp table also having the field
    material ( but the name of the material field in the ausp table is OBJEK) . Material field in t the VBAP table have data type character and field length 18 and OBJEC field in the ausp table have data type character and lenght 50.
    So if i give select statement for ausp table
    SELECT OBJEK ATINN ATWRT  INTO CORRESPONDING FIELDS OF TABLE GT_AUSP FROM AUSP
    FOR ALL ENTRIES IN GT_DATA WHERE OBJEK = LT_DATA-MATNR AND
              .                        MFID = '01' AND
                                       KLART = '001' AND
                                       ATINN = V_ATINN.
    it is giving  error : when you use addition for all entries in internal table the object and GT_DATA-MATNR must have same data type and same length.
    So if i change the length of the matnr field it will effect for other select statement.
    please let me know hw to over come errors.
    Thakns in advace.
    Best Regards,
    Zubera

    Hi shridarudupi ,
    when you are declaring structure  for GT_DATA,define matnr field of type ausp-objek , so when you will select data from AUSP using for all entries of GT_DATA , there will  not be any type mismatch.
    For Ex.
    TYPES : BEGIN OF t_mara ,
             matnr TYPE ausp-objek,
             ersda TYPE mara-ersda,
            END OF t_mara,
             BEGIN OF t_ausp ,
             objek TYPE ausp-objek,
             atinn  TYPE ausp-atinn,
            END OF t_ausp.
    DATA : i_mara     TYPE STANDARD TABLE OF t_mara,
                 i_ausp     TYPE STANDARD TABLE OF t_ausp,
                wa_mara  LIKE LINE OF i_mara,
                wa_ausp  LIKE LINE OF i_ausp.
    SELECT matnr
                 ersda
                 FROM mara INTO TABLE i_mara
                 WHERE matnr = '4510'.
    IF sy-subrc = 0 .
      SELECT objek
                    atinn
                    FROM ausp
                    INTO TABLE i_ausp
                    FOR ALL ENTRIES IN i_mara
                    WHERE objek = i_mara-matnr.
      IF sy-subrc = 0 .
        WRITE : 'successful'.
      ENDIF.
    ENDIF.
    Hope this helps.
    Edited By Tejaswini Khante

  • Fast data retreival from Table BSAD

    Dear Friends,
    I want to retrive data from table BSAD and right now it have more than 1,300,000 records.
    for "where condition" i have Customer number, Document number, Document type fixed RV and only
    debit side S.
    What should i do for fast retreival or any function module . right now data fatching is too slow with simple select.
    regards
    Malik

    Hi Malik,
    Pass all the key fields present in the database table, and in the current selection you are using only 2 key fields.  The remaining key fields in this table i.e, BSAD are:
    BUKRS-----     BUKRS---     CHAR     4     0--
         Company Code
    KUNNR-----     KUNNR---     CHAR     10     0--
         Customer Number 1
    UMSKS------     UMSKS-----CHAR     1     0--
         Special G/L Transaction Type
    UMSKZ------     UMSKZ-----CHAR     1     0--
         Special G/L Indicator
    AUGDT-----AUGDT---DATS8     0--
         Clearing Date
    AUGBL------     AUGBL------     CHAR--     10     0--
         Document Number of the Clearing Document
    ZUONR-----DZUONR-     CHAR     180--
         Assignment number
    GJAHR-----     GJAHR---     NUMC     4     0--
         Fiscal Year
    BELNR-----     BELNR_D--     CHAR--10     0--
         Accounting Document Number
    BUZEI--     BUZEI     NUMC     3     0--
         Number of Line Item Within Accounting Document
    Therefore pass as many key fields as possible to improve the performance of the select query.
    Regards,
    Md Ziauddin.

  • Cost center data fetch from COSS/COSP tables.

    Hi Experts,
    I need to fetch data from COSS/COSP tables for particular Cost centers fetched in CSKS select.
    As there is no Costcenter field I cannot access the database tables directly.
    Fetching entire dat and then deleting is causing performance issue with the report.
    I need to reduse the time taken by COSS/COSP table select , as I have Cost center field on the selection screen.
    Is there any other method or  FM that I can use?
    Thanks in advance!!!

    Hi
    This is my code to get the data from a certain cost element group:
    }call function 'G_SET_GET_ID_FROM_NAME'
         exporting
           shortname                      = p_kagru
           tabname                        = 'CCSS'
           fieldname                      = 'KSTAR'
           kokrs                          = p_kokrs
           ktopl                          = 'ENPC'
           setclass                       = '0102'
           check_set_empty                = 'X'
         importing
           new_setid                      = setid
    *     SET_INFO                       =
        exceptions
          no_set_found                   = 1
          no_set_picked_from_popup       = 2
          wrong_class                    = 3
          wrong_subclass                 = 4
          table_field_not_found          = 5
          fields_dont_match              = 6
          set_is_empty                   = 7
          formula_in_set                 = 8
          set_is_dynamic                 = 9
          others                         = 10
       if sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
       endif.
       call function 'G_SET_GET_ALL_VALUES'
         exporting
    *     CLIENT                      = ' '
    *     FORMULA_RETRIEVAL           = ' '
    *     LEVEL                       = 0
           setnr                       = setid
    *     VARIABLES_REPLACEMENT       = ' '
    *     TABLE                       = ' '
    *     CLASS                       = ' '
    *     NO_DESCRIPTIONS             = 'X'
    *     NO_RW_INFO                  = 'X'
    *     DATE_FROM                   =
    *     DATE_TO                     =
    *     FIELDNAME                   = ' '
         tables
           set_values                  = t_set_values
        exceptions
          set_not_found               = 1
          others                      = 2
       if sy-subrc <> 0.
         message id sy-msgid type sy-msgty number sy-msgno
                 with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
       endif.
      loop at t_set_values.
        count = count + 1.
        r_kstar(3) = 'IEQ'.
        r_kstar-low = t_set_values-from.
        append r_kstar.
        if count = 500.
          perform read_coep.
        else.
          at last.
            perform read_coep.
          endat.
        endif.
      endloop
    U can use somthing like that to get data from cost center
    Max

  • Table refresh is not working in case of data fetched from OUCM

    Hi All,
    I have created a Content Repository data control for a OUCM connection in an ADF application.
    I have five methods inside that. (advancedSearch, getURI, getAttributes, getItems, search)
    I have dragged and dropped the Return inside search method, as an ADF table in a jspx page. The table displays the list of documents in OUCM.
    The table code looks as follows.
    <af:table value="#{bindings.Return.collectionModel}" var="row"
    rows="#{bindings.Return.rangeSize}"
    emptyText="#{bindings.Return.viewable ? 'No data to display.' : 'Access Denied.'}"
    fetchSize="#{bindings.Return.rangeSize}"
    rowBandingInterval="0"
    disableColumnReordering="true"
    selectionListener="#{bindings.Return.collectionModel.makeCurrent}"
    rowSelection="multiple" id="t2"
    binding="#{MyDocumentBean.documentTable}"
    filterModel="#{bindings.ReturnQuery1.queryDescriptor}"
    queryListener="#{bindings.ReturnQuery1.processQuery}"
    filterVisible="true" varStatus="vs"
    immediate="true" partialTriggers="delete"
    columnStretching="column:c2" width="948"
    columnResizing="disabled"
    contentDelivery="immediate" verticalGridVisible="false"
    displayRow="selected" summary="document table">
    I have a remove button with code as follows
    <af:commandButton text="Remove" actionListener="#{MyDocumentBean.deleteDoc}" id="delete" partialSubmit="true">
         </af:commandButton>
    In the MyDocumentBean's deleteDoc method , I am connecting to OUCM using RIDC and then deleting the content from OUCM.
    I have set the partialTrigger on table on partialSubmit of the remove button. But after I remove a document, the content is deleted from OUCM, but the table that shows the list of documents is not refreshed.
    I have to manually click a refresh button to refresh the table's content . The code for refresh button is
    <af:commandButton actionListener="#{bindings.search.execute}" text="Refresh" disabled="#{!bindings.search.enabled}" id="refresh" >
         </af:commandButton>
    I even tried using the below code for the search to be executed in the deleteDoc method
         BindingContext bindingContext = BindingContext.getCurrent();
         BindingContainer bindings = bindingContext.getCurrentBindingsEntry();
         OperationBinding operationBinding = (OperationBinding) bindings.get("search");
         operationBinding.execute();
    But it also didn't work.
    I have even tried the following in the pageDefinition file. But in vain :(
    <methodIterator Binds="search.result" DataControl="OUCMDataControl"
    RangeSize="25"
    BeanClass="OUCMDataControl.search_return"
    id="searchIterator" Refresh="always"/>
    Please let me know how to refresh the table.
    Thanks in advance,
    Harini.

    Hi,
    can you try to refresh table "deleteDoc" action listener method using the below code
    AdfFacesContext.getCurrentInstance().addPartialTarget(tableBinding);if this doesn't work you can try to refresh the whole page (dont know whether its a good practice)
                            FacesContext context = FacesContext.getCurrentInstance();
                            String currentView = context.getViewRoot().getViewId();
                            ViewHandler vh = context.getApplication().getViewHandler();
                            UIViewRoot x = vh.createView(context, currentView);
                            context.setViewRoot(x);~Abhijit

  • Data fetch from two table without refresh

    hi Friends,
    I have a problem i want to extract data from two table without refresh into text field when i'll enter any value in a text field then corressponding value should come in to corressponding textfield.
    eg. there two table A and B.
    Table A has Colunm
    s_id Number;
    c_id Varchar2(30);
    sec varchar2(4);
    Second Table B Colunm Name
    s_id Number;
    f_name varchar(30);
    l_name varchar(20);
    when i enter s_id 101 in a text field then the c_id ,sec,first_name and last_name should come in to corressponding text fields without refresh.
    How Can I do this.
    Thanks
    Manoj

    Hi Manoj,
    You have to make an Ajax call to display data without refreshing the page. Search this forum for Ajax and you can find lots of related posts. This link might help too. http://www.dba-oracle.com/t_html_db_apex_ajax_application_express.htm
    Thanks,
    Manish.

Maybe you are looking for

  • IPhone 4 ear speaker not working

    Looking for more info regarding this problem.. Purchased iPhone 4 for my wife and I last month. My iPhone ear-speaker went dead, but the external speaker, plug-in wired ear-phones work, and mic still work. I went to take it in, and then the darn thin

  • Unable to release transport request for modified Planning book from Dev Sys

    Hi All can someone advice on this: We have included a new key figure to our existing Planning book, which is already defined in Planning Area. This key figure is just getting shipping data for comparison and is not having any impact on macros also. W

  • I am no longer able to resize my firefox window horizontally, any ideas?

    I noticed earlier that I can no longer resize my firefox window horizontally, the border seems to have disappeared. I've searched, using google and various other sites to find a solution to this and I'm coming up short. I've tried multiple things, sa

  • How to locate the path of ExpressVI associated with a step in TestStand 3.1??

    When I associate an ExpressVI with a Step in Teststand 3.1 by using SpecifyModule, its Path is not available in any of the Teststand Variables unlike Standard VI's whose path is located in "Step.TS.SData.VIPath".  Is there any way I can find out the

  • Mysterious Quicktime Error -50

    Just tried to do a compression (I took the standard 640x480 iTunes compression setting and turned on reverse telecine, for what it's worth) and got a failure with "Quicktime Error: -50" Needless to say, this microsoftian error message (absolutely acc