Fetch from bseg

Hi,
I have a requiremet to get the g/l account from BSEG table and this too by connecting purchase doc no.
Put ebeln in bseg and get the g/l accounts. This prcess I want to do for a large volume of data at a time. Since the search is without keyfields it is consuming more time. Give me some solution for this.
Can we create index for BSEG table
Thanks in advance

No index possible for BSEG (cluster table).
If you have PO number and want G/L account, try searching via table EKKN field SAKTO.
Thomas

Similar Messages

  • 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).

  • Reading data from BSEG table with Non-key fields in where clause

    Hi All,
        I have to read data from BSEG table based on WBS element field (PROJK). As I'm not passing key fields to WHERE clause system couldnt run the select statement. Since BSEG is a cluster table I cant even create secondary index on PROJK field.
       Could you please tell me, how to improve its performance.
    Regards
    Jaker.

    SELECT bukrs
                 belnr
                 gjahr
                 shkzg
                 dmbtr
                 hkont
                 lifnr
                 matnr
                 werks
                 menge
                 meins
                 ebeln
            FROM bseg
            INTO TABLE it_bseg
            PACKAGE SIZE 10
            FOR ALL ENTRIES IN it_final
            WHERE  bukrs EQ it_final-bukrs
               AND belnr EQ it_final-belnr
               AND gjahr EQ it_final-gjahr
               AND buzei EQ it_final-buzei
               AND hkont EQ it_final-hkont
               AND werks IN s_werks.
    By using package and fetch from BSEG table. gathering all other information to a final internal table.This will reduce the hit to database.And also try to put that data in hashed internal table which is it_bseg....then definetly improve the performance.
    <REMOVED BY MODERATOR>
    Dara.
    Edited by: Alvaro Tejada Galindo on Apr 21, 2008 12:47 PM

  • Select From BSEG

    Hi
    The below mentioned piece of code is throwing a dump in Production system.
    Is there any way of alternate selection.
      IF NOT it_pos[] IS INITIAL.
        SELECT * FROM bseg INTO
                 TABLE it_bseg
                 FOR ALL ENTRIES  IN it_pos
                     WHERE  bukrs IN dd_bukrs
                     AND    belnr = it_pos-belnr
                     AND    gjahr = it_pos-gjahr.
      ENDIF.
    Regards
    Subin.S

    I think you need to post a few more details of the environment and error to assist people in offering solution.
    Questions I think of are:
    - What type of dump are you getting? - Out of Time? Out of Memory? Other?
    - How many entries are in internal table it_pos[] before the BSEG select starts?
    - How many entries are in BSEG approximately?
    - Do you need all the BSEG records to be selected into an internal table at once or can you process them in smaller sets?
    - Do you have a number of other large internal tables in your program?  Can any of these be cleared to free up memory?
    - can you run SQL trace (ST05) against the program to see the execution time for each fetch from BSEG and how many records each fetch returns?
    - why are you doing two selects from BSEG? What is the difference between them? normally better to get all the fields at the same time instead of selecting twice.
    - in Development or Test where there is less data, does tha program run OK?  If so, can you run it in SE30 to see what that transaction highlights as performance or similar issues?
    - what table or tables do you fill table it_pos[] from?  are there any duplicate records in this internal table?
    - what SAP version are you running?  32 bit or 64 bit?  What database?
    To solve an issue like this with a program these and probably dozens of other questions must be asked and answered - and as the person on the site you are the only one able to get the answers. 
    Posting more details will help forum readers to evaluate the issue in light of their experience and to provide further suggestions.  The more information you can give - the more likely that someone will be able to answer.
    thanks
    Andrew

  • How to fetch data from bseg based  on 2 internal tables in 1 select query?

    hi,
    i have bukrs and belnr in one internal table and bukrs and vbeln in another internal table..now if i select from bseg twice using for all entries for fields bukrs vbeln and bukrs belnr twice in 2 select statements its fine..but since bseg is a huge table i want to use select only once..but the problem is that none of the belnrs in the one internal table will have vbeln in another internal table....ie if vbeln is selected from bseg based on belnr in 1 internal table non eof those vbeln will be equal to vbeln on another internal tables..in this scenario even if i take all data from two internal tables into 1 single internal table and then use for all entries on vbeln and belnr of that table ..but i think this will not work because and AND operator will not work because no record will satisfy both vbeln and belnr conditions..even if i use OR operator if the 1st condition satisfies the select clause will not enter into the second clause and all the records will not be fetched...Please help how should i tackle this..

    Hi vijaya,
    no simple select statement solution so far.
    As BSEG is a huge table you should try to get the full key values into another internal table first.
    SAP avoids direct selections from BSEG.
    Pleas consider the use of one of the secondary index tables first:
          BSAD : Accounting: Secondary Index for Customers (Cleared Items)
          BSAK : Accounting: Secondary Index for Vendors (Cleared Items)
          BSAS : Accounting: Secondary Index for G/L Accounts (Cleared Item
          BSEC : One-Time Account Data Document Segment
          BSEG : Accounting Document Segment
          BSID : Accounting: Secondary Index for Customers
          BSIK : Accounting: Secondary Index for Vendors
          BSIS : Accounting: Secondary Index for G/L Accounts
    you may include
          BKPF : Accounting Document Header
    for restrictions about time and document type.
    The last step is a FOR ALL ENTRIES selection from BSEG providing the full key values.
    Although you may have even more selects, the overall performance will be much better.
    Regards,
    Clemens

  • Taking time to fetch records from BSEG

    Hi all,
    When iam fetching wrbtr,augdt,zterm fields  from BSEG table by passing VBELN and BUKRS it is taking lot of time to get.My query goes like this
      select vbeln wrbtr augdt zterm from bseg into table t_bsegtab for all
                entries in t_vtab where bukrs = p_bukrs and
                 vbeln = t_vtab-vbeln.
    Is there any wrong in statement.If not what is the possible solution for that.
    regards
    kiran

    Hi,
      As BSEG is a cluster table and has open/close item details of Vendor, Customer & GL account, as far as possible avoid quering BSEG instead use the relevant tables to get the data, BSEG has the combination of following tables,
    BSID & BSAD  --> Customer Accounting details
    BSIK & BSAK  --> Vendor Accounting details
    BSAS & BSIS  --> G/L Account details
    If your requirement is to get the open/close items for Vendor, access BSIK & BSAK tables by passing the key fields in the where condition.
    Hope this helps, get back for further clarifications,
    Rgds,

  • Fetching Invoice details from BSEG

    Hi experts,
                    I  fetched  details like BUZEI BUZEI KOART SHKZG MWSKZ DMBTR PSWBT PSWSL HWBAS KTOSL HKONT KUNNR MATNR TXJCD from Bseg . program execute  well in development server but very slow  in production server. Coding is given below , kindly provide solution for this.
    input.
    1.MANDT
    2.BUKRS
    3.VKORG
    4.FKDAT
    First i fetch invoices based on input from vbrk and vbrp table and  passed  in bseg.
    SELECT VBRKMANDT VBRKVBELN VBRKVKORG VBRKFKDAT VBRKBUKRS VBRPGSBER
      INTO TABLE ITAB
      FROM VBRK
      INNER JOIN VBRP ON VBRKVBELN = VBRPVBELN
      WHERE
       VBRK~MANDT IN S_MANDT AND
            VBRK~BUKRS IN S_BUKRS AND
            VBRK~VKORG IN S_VKORG AND
            VBRK~FKDAT IN S_FKDAT.
      RANGES : R_VBELN FOR VBRK-VBELN.
      LOOP AT ITAB.
        R_VBELN-SIGN = 'I'.
        R_VBELN-OPTION = 'EQ'.
        R_VBELN-LOW = ITAB-VBELN.
        APPEND R_VBELN.
      ENDLOOP.
      LOOP AT ITAB.
        ITAB-FYEAR = ITAB-FKDAT+0(4).
        MODIFY ITAB INDEX SY-TABIX.
      ENDLOOP.
      DATA : BELNR LIKE BSEG-BELNR.
      SELECT BELNR GJAHR BUZEI KOART SHKZG MWSKZ DMBTR PSWBT PSWSL HWBAS KTOSL HKONT KUNNR MATNR TXJCD
      FROM BSEG INTO TABLE GTAB FOR ALL ENTRIES IN ITAB
      WHERE BUKRS IN S_BUKRS AND
            BELNR IN R_VBELN AND      
            GJAHR = ITAB-FYEAR .
    Thanks & regards
    G.Vendhan

    Hi Vendhan,
    SELECT VBRK~MANDT VBRK~VBELN VBRK~VKORG VBRK~FKDAT VBRK~BUKRS VBRP~GSBER
    INTO TABLE ITAB
    FROM VBRK
    INNER JOIN VBRP ON VBRK~VBELN = VBRP~VBELN
    WHERE
    VBRK~MANDT IN S_MANDT AND " Not required so comment it...
    VBRK~BUKRS IN S_BUKRS AND
    VBRK~VKORG IN S_VKORG AND
    VBRK~FKDAT IN S_FKDAT.
    RANGES : R_VBELN FOR VBRK-VBELN.
    LOOP AT ITAB.
    R_VBELN-SIGN = 'I'.
    R_VBELN-OPTION = 'EQ'.
    R_VBELN-LOW = ITAB-VBELN.
    APPEND R_VBELN.
    ENDLOOP.
    LOOP AT ITAB.
    ITAB-FYEAR = ITAB-FKDAT+0(4).
    MODIFY ITAB INDEX SY-TABIX.
    ENDLOOP.
    DATA : BELNR LIKE BSEG-BELNR.
    As you are interesed to get the data for the billing document only select data from vbrk only...
    and use that internal table in for all entries with BSEG rather then join of vbrk and vbrp while
    IF ITAB[] IS NOT INITIAL[]. " Check this condition before using For all Entries alwayse...
    SELECT BELNR GJAHR BUZEI KOART SHKZG MWSKZ DMBTR PSWBT PSWSL HWBAS KTOSL HKONT KUNNR MATNR TXJCD
    FROM BSEG INTO TABLE GTAB FOR ALL ENTRIES IN ITAB
    WHERE BUKRS IN S_BUKRS AND
    BELNR IN R_VBELN AND  " Wrong... You are supposed to pass vbrk-VBELN to BSEG-VBELN as BELNR and VBELN are different and contains diff data as well..
    GJAHR = ITAB-FYEAR
    AND KOART =  'D'. " Include it for customers
    ENDIF.
    Also I would like to suggest you if you can use below tables if possible...
    BSAD                           secondary Index for Customers (Cleared Items)
    BSID                             secondary Index for Customers
    So you need to change the logic to get correct data first...
    Hope it will solve your problem..
    Thanks & Regards
    ilesh 24x7
    ilesh Nandaniya

  • Problem while selecting BELNR from BSEG

    Hi Experts,
    I have a report performance problem while fetching BELNR from BSEG table.
    I have to print latest BELNR from BSEG where BUZID = ‘M’ but at the time of execution of report, It is taking too much time (More that hour and sometimes it gets hanged).
    I have also gone through the comments provided by experts for previous problems asked in this forum e.g. BSEG is a cluster table that is why data retrieval takes long time etc.
    Can any one has any other idea or suggestion  or any other way to solve this problem
    Regards,
    Neeraj

    Hi,
    1) Try to create an index on BUZID field
    2) Don't use SELECT/ENDSELECT statement. Instead of that extract all the concerned entries from BSEG into an internal table :
    select belnr from bseg appending table itab where buzid = 'M'.
    then do this :
    sort itab by belnr.
    describe itab lines n.
    read table itab index n.
    Please reward if helpful.
    Regards,
    Nicolas.

  • Data from Bseg taking too much time

    Hi ,
    I need to extract data from BSEG and it is goin in timeout.
    my query is  :
    1 :  on the basis of VBRK i need to fetch data from bseg.
    loop at it_vbrk.
          awkk = it_vbrk-vbeln.
          CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
            EXPORTING
              input  = awkk
            IMPORTING
              output = awkk.
    it_awkey-vbeln = it_vbrk-vbeln.
    it_awkey-awkey = awkk.
    append it_awkey.
    endloop.
    2.
    if it_awkey[] is not initial.
    select bukrs BELNR gjahr BLART AWKEY from bkpf into table it_bkpf for all entries in it_awkey
    where
    bukrs = '5000'
    and blart EQ 'RV'
    and awkey = it_awkey-awkey.
    endif.
    Please guide me to get solution
    Ashish Gautam

    Ok, u can use the secondary index tables of BSEG...
    BSAS
    BSIS,
    BSAD,
    BSID,
    BSAK,
    BSIK,
    BSIM.
    whatever is in BSEG is also in these tables....
    and if u use BSEG, then try to match the key fields of BSEG, then only it will give the best performance....
    eg.
    BUKRS
    BELNR
    GJAHR
    BUZEI
    use the same order as given in the database...
    and do not use any other fields except the key fields in the where clause...
    and do not use 'NE' 'Not in' in the where clause....
    regards
    Sukriti....

  • Abap query to select a line item # from bseg on basis of following pattern:

    Hello,
    I want to retrieve the line item # from bseg which has the following pattern,
    account type = S
    AND
    gl account starting from 135***** , 136***** , 137*****
    , 138***** , 139*****
    hope i am comprehendable. How do i go on writing the query,
    Thanks..
    Shehryar

    Hi Shehryar,
    This will fetch records with GL A/C starting with <b>13</b> only , if you want 14 and others also write sepearate conditions using <b>LIKE</b> statements.
    REPORT zztest.
    DATA : itab TYPE STANDARD TABLE OF bseg WITH HEADER LINE.
    SELECT * FROM bseg INTO TABLE itab WHERE <b>koart = 'S'
    AND
    hkont LIKE '13%'</b>.
    This will take a lot of DB time for fetching the records, try to include Key Fields(BUKRS and GJAHR .. if possible others).
    Regards,
    Arun Sambargi.
    Regards

  • Regarding Select data from *BSEG

    Hi Experts,
    I am studying the logic of an ABAP in which data has been fetched by a select statement like this
    SELECT * FROM *BSEG
    When i double clicked on *BSEG, system says *BSEG does not exist. Also, there is no table as *BSEG in ABAP dictionary.
    Please let me know what does *BSEG signifies and what it is ?
    Thanks in advance,
    Akash Sawant

    Hi Akash,
    If you declare *BSEG  means its acts as a structure for the corresponding DB table.
    Check this sample code,
    tables : mara, *mara.
    DATA : ITAB LIKE TABLE OF *MARA WITH HEADER LINE.
    SELECT * FROM *MARA INTO TABLE ITAB.
    LOOP AT ITAB.
    WRITE : ITAB-MATNR.
    ENDLOOP.
    Thanks,
    reward If Helpful.

  • Selecting from bseg

    Abap Gurus,
    I am fetching belnr dmbtr buzei hkont from bseg
    for all entries from one table say 'TAB'
    where hkont = TAB-hkont
    and koart = 'S'.
    but in in the code inspector check it;s showing error
    The message is
    "Large table BSEG: No field of a table index in WHERE"
    How to optimize a fetch from a larger cluster table BSEG
    rewards if useful.
    Thanks in advance

    Hi,
         Alternatives to Reading BSEG (Accounting Document Segment).
    Since performance is an issue if reading data from BSEG table ( being a cluster table ), maybe you would
    consider using the tables:
              BSAD      Accounting     : Secondary Index for Customers (Cleared Items)
              BSAK      Accounting     : Secondary Index for Vendors (Cleared Items) 
              BSAS      Accounting     : Secondary Index for G/L Accounts (Cleared Items)
              BSID      Accounting     : Secondary Index for Customers
              BSIK      Accounting     : Secondary Index for Vendors    
              BSIS      Accounting     : Secondary Index for G/L Accounts
              instead of BSEG.
              It depends on what your program has to select (if you're only looking for customers
              you can use BSID and BSAD etc.)
              These are normal database tables, not clusters. Normally every record from BSEG
              can be found back in one of these 6 tables and a program which selects data from
              these tables runs faster than from BSEG.
    Reward points if helpful
    Thanks
    Shambhu

  • How to get internal order and activity type other than from BSEG

    We want the Internal order and activity type fields. From BSEG, it is taking a long time, and it hangs.
    Is there any other table we can get these values from?
    Our query is this:
    select bukrs "Company code
    gjahr "Fiscal year
    belnr "Document no.
    buzei "Document Item no.
    aufnr "Internal order
    lstar "Activity type
    from bseg
    into table gt_add_info
    for all entries in gt_gl_detail
    where bukrs = gt_gl_detail-rbukrs"Comcode from G/L acct detail
    and buzei = gt_gl_detail-buzei "Doc item no. from G/L acct detail
    and belnr = gt_gl_detail-belnr "Doc no. G/L acct detail
    and gjahr = gt_gl_detail-gjahr."Fiscal yea
    Can advise please how to make it faster. My internal table (GT_GL_DETAIL) has over 100000 records. ? thanks.

    I did a SQL trace, and saw that tables CSLA, CSSL, COKL and COKA are being hit with the values I entered inthe Activity type in transaction FB50.
    Still not clear but where it gets stored. If in any of these tables, how do I get the object key?

  • Data not getting fetched from Quotation to Contract

    Hi,Myself new to TM. I have a ticket mentioning data not getting fetched from quotation to contract. How to solve it? Please help...
    Message was edited by: Michael Appleby

    Please add the version of the TM product and which SPs have been installed.  Also more information on the quotation and contract.
    What do you mean by ticket?  It you mean an error message, from where are you reading the message?
    Regards, Mike
    SAP Customer Experience Group - CEG

  • How to parse XML string fetched from the database

    i want to parse the XML string which is fetched from the oracle database.
    i have inserted the string in xml format in the database. The type of the field in which it is inserted is varchart2.
    I am successfully getting it using jdbc, storing it in a String.
    Now it is appended with xml version 1.0 and string is ready for parsing.
    Now i am making following programming.
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document doc = Builder.parse(xmlString);
    Element root = doc.getDocumentElement();
    NodeList node = root.getElementsByTagName("product");
    But i am getting IOException at the statement
    Document doc = Builder.parse(xmlString);
    there fore i request u to kindly help me in solving this error.
    -regards
    pujan

    DocumentBuilder does not have a method parse with xml string as aparameter. The string should be a xml document uri.
    Convert xml string to StringReader.
    parse(new InputSource(new StringReader(xmlString)));

Maybe you are looking for

  • Lightroom 4.3 toolbars

    For some strange reason the right hand side toolbars have all changed from color to B&W on me. I am NOT in B&W mode, I'm in Color develop mode. The usual color sliders have changed to all white and grey giving no color indications in any of the sub p

  • Problem with notebook HP Pavilion dv4 - 2173nr

    Good morning,  I have a HP Pavilion dv4-2173nr notebook for 4 years, recently he started off alone and try to turn it back the following error message Wireless Module not found (701) appears. What does it mean and what can I do to find the problem? H

  • IPad 3 is unreliable at connecting to wifi

    My iPad 3 shows full signal but fails to download web pages etc. it connects for a short time and then drops out. Any advice would be welcome.

  • Journalizing data changes in relational source

    Is there any standard way to allow user to add comments to data changes? And then to show data changes for the specified fact upon request? I am using relational data source, not Essbase-

  • List in List

    Lightswitch HTML: I display a master list and would like to display an embedded second minor list that depends on the item of the master list. I can only do a binding with the "selectedItem" of the master list but I do not want to be obligated to cli