BKPF x BSEG records

Hello All,
We must to extract an Excel file for auditing which has to have all the account documents created during last year with their values. I got all the records (34K) in BKPF table, but in BSEG it is being impossible due a dump error.
The documents types are:
- SA: G/L account document
- XA: Acc. doc. only GL
I know that BSIS, BSAS, BSIK, BSAK basically have the same information as BSEG, but as it is urgent I suppose that should be faster using BSEG.
Question: what is the best/fast way to extract them by SE16 Transaction?
Thanks in advance!
Michel Khouri
Mars, Inc - Brazil

Hi,
here's a very plain and simple report:
file is transfere to appl-server
you can ut run in background
REPORT z12345.
TABLES: bkpf,
        bseg.
* structure  (Output)
DATA: BEGIN OF datei OCCURS   0,
        gjahr LIKE bkpf-gjahr,
        bukrs LIKE bkpf-bukrs,
        belnr LIKE bkpf-belnr,
        buzei LIKE bseg-buzei,
        monat LIKE bkpf-monat,
        bldat LIKE bkpf-bldat,
        budat LIKE bkpf-budat,
        cpudt LIKE bkpf-cpudt,
        xblnr LIKE bkpf-xblnr,
        koart LIKE bseg-koart,
        konto LIKE bseg-saknr,
        mwskz LIKE bseg-mwskz,
        bschl LIKE bseg-bschl,
        shkzg LIKE bseg-shkzg,
        dmbtr(16),
        wrbtr(16),
        mwsts(16),
        wmwst(16),
        waers LIKE bkpf-waers,
        kostl LIKE bseg-kostl,
        sgtxt LIKE bseg-sgtxt,
      END OF datei.
DATA str TYPE string.
FIELD-SYMBOLS <f>.
PARAMETERS file LIKE rlgrap-filename OBLIGATORY DEFAULT
'/home/ftp/pub/test001'.
START-OF-SELECTION.
  OPEN DATASET file FOR OUTPUT IN TEXT MODE.
GET bkpf.
  CHECK select-options.
  MOVE-CORRESPONDING bkpf TO datei.
GET bseg.
  CHECK select-options.
  MOVE-CORRESPONDING bseg TO datei.
  CLEAR str.
  DO.
    ASSIGN COMPONENT sy-index OF STRUCTURE datei TO <f>.
    IF sy-subrc <> 0.
      EXIT.
    ENDIF.
    CONCATENATE str <f> ';' INTO str.
  ENDDO.
  TRANSFER str TO file.
END-OF-SELECTION.
  CLOSE DATASET file.
kind  regards to all
and nice weekend
God bless
Andreas
Message was edited by:
        Andreas Mann
Message was edited by:
        Andreas Mann

Similar Messages

  • How to get the Equity Share (%) based on a BSEG record

    Dear JVA experts,
    I have to model a relation with BSEG and JVA tables to get the Equity Share from T8JQ.
    it has been proposed to me to build a relation as follows:
    BSEG-BELNR - BKPF-BELNR
    BKPF-AWKEY  -> JVSO1-REFDOCNR
    BKPF-GJAHR   -> JVSO1-REFYEAR
    BKPF-BUKRS  -> JVSO1-RBUKRS
    get JVSO1-VNAME
    finally get T8JQ-VNAME and get T8JQ-EQSHARE.
    My question to you.
    I have found that in BSEG there are some JVA fields. Would it be possible to model another relation in order to get the Equity Share from T8JQ from a BSEG record, avoiding the reading of JVSO1 ?
    thanks in advance for your help ?
    best regards,
    Lory

    Hi Lory,
    You can refer BSEG table to mapp with T8JQ to retrieve Equity share. You have not mentioned what are the line item you would consider to retrieve Equity share details. If you are not considering clearing documents which normally refer the line item which has to be cleared for JV details, will have not JV information to get  corresponding Equity share details from T8JQ
    Example:
    I have two line items
      Doc No
    1 . DR 400  JV1
    2 Doc No. CR 400   --    Clearing document

  • How to use BKPF and BSEG without using  inner join

    Hi,
    can anybody plz tell me the logic about how to complete the report without inner joining bkpf and bseg.Is this report can be really be made by using only bseg,bkpf ?
    *selection-criteria .
    BKPF-USNAM
    BKPF-CPUDT
    BKPF-BUDAT
    BKPF-GJAHR
    BKPF-BUKRS
    BKPF-BELNR
    BSEG-SAKNR
    BSEG-LIFNR
    BSEG-KUNNR
    BSEG-ZUONR
    BSEG-SGTXT
    Output fields required.
    BKPF-BUKRS
    BKPF-BELNR
    BKPF-GJAHR
    BKPF-MONAT
    BKPF-BLART
    BKPF-CPUDT
    BKPF-BLDAT
    BKPF-BUDAT
    BKPF-USNAM
    BKPF-XBLNR
    BKPF-STBLG
    BKPF-BKTXT
    BKPF-WAERS
    BKPF-KURSF
    BSEG-BUZEI
    BSEG-BSCHL
    BSEG-KOART
    BSEG-UMSKZ
    BSEG-SHKZG
    BSEG-MWSKZ
    BSEG-PSWBT
    BSEG-PSWSL
    BSEG-DMBTR
    BSEG-SAKNR
    BSEG-HKONT
    BSEG-KOSTL
    BSEG-KUNNR
    BSEG-VBELN
    BSEG-LIFNR
    BSEG-ANLN1
    BSEG-ANLN2
    BSEG-AUFNR
    BSEG-MATNR
    BSEG-MENGE
    BSEG-MEINS
    BSEG-ZUONR
    BSEG-SGTXT
    Thanks,
    Rahman
    Moderator Message: Please search before posting your question. Thread locked.
    Edited by: Suhas Saha on Jan 31, 2012 3:07 PM

    Quick question - what's preventing your from using built-in functions?
    I suggest mapping your Time Dim to a standard Time Dim and work with it - you'll save a lot more time. You'd even need this table if you wanted to work around Todate/AGO.
    It is possible to model this functionality w/o functions, but it'll be time consuming task, similar to using Time Series Wizard in Siebel Analytics. You'll need to build aliases and views along with some complex joins (such as TIME.KEY=TIME.KEY-365), introduce a bunch of variables to control. Also, you might not get much flexibility in terms of years. For each year, you'd need an alias table. (TIME_DIM_PY).

  • How to create view on bkpf and bseg?

    friends,
      can we create views on bkpf and bseg if yes wht are the steps...please note it down n send me..regards essam ([email protected])

    Hi,
    Use standard views...
    View name                      Short text
    BKPF_AEDAT                     BW FI: BKPF Extraction Using AEDAT
    BKPF_BSAD                      BW FI: BSAD Extraction Using CPUDT
    BKPF_BSAD_AEDAT                BW FI: BSAD Extraction using AEDAT
    BKPF_BSAK                      BW FI: BSAK Extraction Using CPUDT
    BKPF_BSAK_AEDAT                BW FI: BSAK Extraction using AEDAT
    BKPF_BSID                      BW FI: BSID Extraction Using CPUDT
    BKPF_BSID_AEDAT                BW FI: BSID Extraction using AEDAT
    BKPF_BSIK                      BW FI: BSIK Extraction Using CPUDT
    BKPF_BSIK_AEDAT                BW FI: BSIK Extraction using AEDAT
    CRMV_BKPF_BEBD                 FI Documents Relevant for Feedback to CRM
    V_EWU_BKPF                     Update View for Parallel Processing on BKPF
    V_VBSEGK
    V_VBSEGS
    Regards,
    Omkar.

  • How to join anla anlc bkpf and bseg in sap

    any can u tel me how to join the anla anlc bkpf and bseg tables in sap.if any body having asset report send me plz

    Moderator message - Welcome to SCN
    But please search for answers here before posting and do not ask the forum to do your work for you.
    Thread locked.
    Please read [Rules of Engagement|https://wiki.sdn.sap.com/wiki/display/HOME/RulesofEngagement], How to post code in SCN, and some things NOT to do... and [Asking Good Questions in the Forums to get Good Answers|/people/rob.burbank/blog/2010/05/12/asking-good-questions-in-the-forums-to-get-good-answers] before posting again.
    Rob

  • How to join BKPF and BSEG

    Hi Experts,
    how to join BKPF and BSEG
    Thanks
    nagini

    Hi,
    BKPF is Transparent table but BSEG is cluster table.  We can't create views by joining cluster tables.
    hope it helps...
    regards,
    Raju

  • Query with tables of BKPF and BSEG and Structures COBL, RF05A

    hi experts,
              I want to create query with the tables of BKPF and BSEG and  Structures COBL, RF05A
    How can i proceed?
    Please give me complete points
    Edited by: Alvaro Tejada Galindo on Feb 14, 2008 2:52 PM

    check the common fields and required fields and the write SELECT query useing Inner Joins or For all entries
    <REMOVED BY MODERATOR>
    Edited by: Alvaro Tejada Galindo on Feb 14, 2008 2:52 PM

  • BAPI_ACC_DOCUMENT_POST posted data not reflected in BKPF or BSEG

    Friends,
    I am using BAPI_ACC_DOCUMENT_POST, for posting the  FI bad debts data through FB01. I am using BAPI_ACC_DOCUMENT_CHECK for checking the input data and subsequently BAPI_ACC_DOCUMENT_POST and BAPI_TRANSACTION_COMMIT for committing the data posted. 
    After using BAPI_ACC_DOCUMENT_POST, the commit bapi is also successful.  The bapi return the document no. posted.  But if you see the data in the tables BKPF and BSEG the data is not found. 
    It is really frustating, what could be the reason.  Anyone of you faced such problem before.  Any help on this issue.
    regards
    Bill Joseph

    Hi,
                  CALL FUNCTION 'BAPI_ACC_DOCUMENT_CHECK'
                       EXPORTING
                            documentheader    = it_hdr
                       TABLES
                            accountgl         = it_gl
                            ACCOUNTRECEIVABLE = act_rec
                            currencyamount    = it_curr
                            return            = t_result.
                  LOOP AT t_result WHERE ( type = 'E' OR
                                           type = 'A' ).
                    EXIT.
                  ENDLOOP.
                  IF sy-subrc <> 0.
                    REFRESH t_result.
                    CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
                         EXPORTING
                              documentheader    = it_hdr
                         TABLES
                              accountgl         = it_gl
                              ACCOUNTRECEIVABLE = act_rec
                              currencyamount    = it_curr
                              return            = t_result.
                    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
                  ENDIF.
    See the above code.
    And check wether you are checking for right company code and year that which you are checking in tables.
    Thanks.

  • Performance issue in BI due to direct query on BKPF and BSEG tables

    Hi,
    We had a requirement that FI document number fieldshould be extracted in BI.
    Following code was written which has the correct logic but performance is bad.
    It fetched just 100 records in more than 4-5 hrs.
    The reason is there was a direct qury written on BSEG and BKPF tables(without WHERE clause).
    Is there any way to improve this code like adding GJAHR field  in where clause? I dont want to change the logic.
    Following is the code:
    WHEN '0CO_OM_CCA_9'." Data Source
        TYPES:BEGIN OF ty_bkpf,
        belnr TYPE bkpf-belnr,
        xblnr TYPE bkpf-xblnr,
        bktxt TYPE bkpf-bktxt,
        awkey TYPE bkpf-awkey,
        bukrs TYPE bkpf-bukrs,
        gjahr TYPE bkpf-gjahr,
        AWTYP TYPE bkpf-AWTYP,
        END OF ty_bkpf.
        TYPES : BEGIN OF ty_bseg1,
        lifnr TYPE bseg-lifnr,
        belnr TYPE bseg-belnr,
        bukrs TYPE bseg-bukrs,
        gjahr TYPE bseg-gjahr,
        END OF ty_bseg1.
        DATA: it_bkpf TYPE STANDARD TABLE OF ty_bkpf,
        wa_bkpf TYPE ty_bkpf,
        it_bseg1 TYPE STANDARD TABLE OF ty_bseg1,
        wa_bseg1 TYPE ty_bseg1,
        l_s_icctrcsta1 TYPE icctrcsta1.
        "Extract structure for Datasoure 0co_om_cca_9.
        DATA: l_awkey TYPE bkpf-awkey.
        DATA: l_gjahr1 TYPE gjahr.
        DATA: len TYPE i,
        l_cnt TYPE i.
        l_cnt = 10.
        tables : covp.
        data : ref_no(20).
        SELECT lifnr
        belnr
        bukrs
        gjahr
        FROM bseg
        INTO TABLE it_bseg1.
        DELETE ADJACENT DUPLICATES FROM it_bseg1 COMPARING belnr gjahr .
        SELECT belnr
        xblnr
        bktxt
        awkey
        bukrs
        gjahr
        AWTYP
        FROM bkpf
        INTO TABLE it_bkpf.
        IF sy-subrc EQ 0.
          CLEAR: l_s_icctrcsta1,
          wa_bkpf,
          l_awkey,
          wa_bseg1.
          LOOP AT c_t_data INTO l_s_icctrcsta1.
            MOVE l_s_icctrcsta1-fiscper(4) TO l_gjahr1.
          select single AWORG AWTYP INTO CORRESPONDING FIELDS OF COVP FROM COVP
          WHERE belnr = l_s_icctrcsta1-belnr.
          if sy-subrc = 0.
              if COVP-AWORG is initial.
           concatenate l_s_icctrcsta1-refbn '%' into ref_no.
                  READ TABLE it_bkpf INTO wa_bkpf WITH KEY awkey(10) =
                  l_s_icctrcsta1-refbn
                  awtyp = COVP-AWTYP
                  gjahr = l_gjahr1.
            IF sy-subrc EQ 0.
              MOVE wa_bkpf-belnr TO l_s_icctrcsta1-zzbelnr.
              MOVE wa_bkpf-xblnr TO l_s_icctrcsta1-zzxblnr.
              MOVE wa_bkpf-bktxt TO l_s_icctrcsta1-zzbktxt.
              MODIFY c_t_data FROM l_s_icctrcsta1.
              READ TABLE it_bseg1 INTO wa_bseg1
              WITH KEY
              belnr = wa_bkpf-belnr
              bukrs = wa_bkpf-bukrs
              gjahr = wa_bkpf-gjahr.
              IF sy-subrc EQ 0.
                MOVE wa_bseg1-lifnr TO l_s_icctrcsta1-lifnr.
                MODIFY c_t_data FROM l_s_icctrcsta1.
                CLEAR: l_s_icctrcsta1,
                wa_bseg1,
                l_gjahr1.
              ENDIF.
            ENDIF.
                ELSE. " IF AWORG IS NOT BLANK -
                concatenate l_s_icctrcsta1-refbn COVP-AWORG into ref_no.
                READ TABLE it_bkpf INTO wa_bkpf WITH KEY awkey(20) =
                ref_no
                awtyp = COVP-AWTYP
                gjahr = l_gjahr1.
            IF sy-subrc EQ 0.
              MOVE wa_bkpf-belnr TO l_s_icctrcsta1-zzbelnr.
              MOVE wa_bkpf-xblnr TO l_s_icctrcsta1-zzxblnr.
              MOVE wa_bkpf-bktxt TO l_s_icctrcsta1-zzbktxt.
              MODIFY c_t_data FROM l_s_icctrcsta1.
              READ TABLE it_bseg1 INTO wa_bseg1
              WITH KEY
              belnr = wa_bkpf-belnr
              bukrs = wa_bkpf-bukrs
              gjahr = wa_bkpf-gjahr.
              IF sy-subrc EQ 0.
                MOVE wa_bseg1-lifnr TO l_s_icctrcsta1-lifnr.
                MODIFY c_t_data FROM l_s_icctrcsta1.
                CLEAR: l_s_icctrcsta1,
                wa_bseg1,
                l_gjahr1.
              ENDIF.
            ENDIF.
               endif.
          endif.
            CLEAR: l_s_icctrcsta1.
            CLEAR: COVP, REF_NO.
          ENDLOOP.
        ENDIF.

    Hello Amruta,
    I was just looking at your coding:
    LOOP AT c_t_data INTO l_s_icctrcsta1.
    MOVE l_s_icctrcsta1-fiscper(4) TO l_gjahr1.
    select single AWORG AWTYP INTO CORRESPONDING FIELDS OF COVP FROM COVP
    WHERE belnr = l_s_icctrcsta1-belnr.
    if sy-subrc = 0.
    if COVP-AWORG is initial.
    concatenate l_s_icctrcsta1-refbn '%' into ref_no.
    READ TABLE it_bkpf INTO wa_bkpf WITH KEY awkey(10) =
    l_s_icctrcsta1-refbn
    awtyp = COVP-AWTYP
    gjahr = l_gjahr1.
    Here you are interested in those BKPF records that are related to the contents of c_t_data internal table.
    I guess that this table does not contain millions of entries. Am I right?
    If yes, the the first step would be to pre-select COVP entries:
    select BELNR AWORG AWTYP into lt_covp from COVP
    for all entries in c_t_data
    where belnr = c_t_data-belnr.
    sort lt_covp by belnr.
    Once having this data ready, you build an internal table for BKPF selection:
    LOOP AT c_t_data INTO l_s_icctrcsta1.
      clear ls_bkpf_sel.
      ls_bkpf_sel-awkey(10) = l_s_icctrcsta1-refbn.
      read table lt_covp with key belnr = l_s_icctrcsta1-belnr binary search.
      if sy-subrc = 0.
        ls_bkpf_sel-awtyp = lt_covp-awtyp.
      endif.
      ls_bkpf_sel-gjahr = l_s_icctrcsta1-fiscper(4).
      insert ls_bkpf_sel into table lt_bkpf_sel.
    ENDLOOP.
    Now you have all necessary info to read BKPF:
    SELECT
    belnr
    xblnr
    bktxt
    awkey
    bukrs
    gjahr
    AWTYP
    FROM bkpf
    INTO TABLE it_bkpf
    for all entries in lt_bkpf_sel
    WHERE
      awkey = lt_bkpf_sel-awkey and
      awtyp = lt_bkpf_sel-awtype and
      gjahr = lt_bkpf_sel-gjahr.
    Then you can access BSEG with the bukrs, belnr and gjahr from the selected BKPF entries. This will be fast.
    Moreover I would even try to make a join on DB level. But first try this solution.
    Regards,
      Yuri

  • Performance tuning on BKPF and BSEG for my code.

    Please provide alternative code for the following code so that processing is fast.
    my select queries are as follows. It take a lot of time and system gets loaded when it is scheduled.
    select BUKRS
               BELNR
               GJAHR
               BLART
               BLDAT
               BUDAT
               TCODE
               XBLNR
               STBLG
               WAERS
               KURSF
               AWKEY
               STGRD
        into CORRESPONDING FIELDS OF TABLE
    IT_BKP   from bkpf where bukrs =   p_bukrs
                                              and   gjahr in s_gjahr
                                              AND BLART NE 'SA'
                              and   budat in s_date.
    select BELNR
             KOART
             SHKZG
             MWSKZ
             DMBTR
             KTOSL
             SGTXT
             VBELN
             HKONT
             KUNNR
             MATNR
             MENGE
      FROM BSEG INTO  CORRESPONDING FIELDS OF TABLE it_bseg
                                        for all entries in it_bkpf
                                         where bukrs = it_bkpf-bukrs
                                         and   belnr = it_bkpf-belnr
                                         and   gjahr = it_bkpf-gjahr
                                         and   MWSKZ in s_MWSKZ .  
    Please help.

    Hi,
       Declare internal table same fields as the you are selecting from table and
      remove corresponding fields of and also check ur t_bkpf table is not initial
      before using for all enteries.
      foe e.g.
    select BUKRS
    BELNR
    GJAHR
    BLART
    BLDAT
    BUDAT
    TCODE
    XBLNR
    STBLG
    WAERS
    KURSF
    AWKEY
    STGRD
    into TABLE
    IT_BKP from bkpf where bukrs = p_bukrs
    and gjahr in s_gjahr
    AND BLART NE 'SA'
    and budat in s_date.
    IF IT_BKPF[] IN NOT INITIAL.
    select BELNR
    KOART
    SHKZG
    MWSKZ
    DMBTR
    KTOSL
    SGTXT
    VBELN
    HKONT
    KUNNR
    MATNR
    MENGE
    FROM BSEG INTO TABLE it_bseg
    for all entries in it_bkpf
    where bukrs = it_bkpf-bukrs
    and belnr = it_bkpf-belnr
    and gjahr = it_bkpf-gjahr
    and MWSKZ in s_MWSKZ .
    ENDIF.
      reward if useful.

  • Selecting from BKPF and BSEG

    Hi all,
    Can someone help me optimize the performance of this code as i don't know how else to select from BSEG as i cannot use a join coz its a cluster table. I need to find a way to improve the perfomance.Any help would be much appreciated.
    SELECT belnr gjahr bukrs budat stblg awkey blart
             FROM bkpf INTO CORRESPONDING FIELDS OF TABLE t_bkpf
             WHERE belnr IN s_belnr and
                   gjahr = p_gjahr  and
                   bukrs = p_bukrs.
      LOOP AT t_bkpf.
          SELECT belnr gjahr buzei ebeln ebelp
               wrbtr fipos geber fistl fkber
               augbl augdt shkzg
        INTO CORRESPONDING FIELDS OF table t_bseg
        FROM bseg
        WHERE belnr = t_bkpf-belnr
        AND   gjahr = t_bkpf-gjahr
        AND   bukrs = t_bkpf-bukrs.
    Thanks alot
    seema

    Hi Seema,
    You have to avoid the database retrival inside the loop.You can use for all entries.
    This is taken from a link.
    Some of the SAP tables are not transparant, but pooled or clustered. Be aware of this !
    There are a lot of limitations on how such tables can be accessed. You can not include such
    tables in database views and join constructs. The FI-GL table BSEG, which is one of our
    biggest PR1 tables, is an example of a clustered table. At the database-level, there is no table
    called BSEG, but instead RFBLG is being used for the BSEG data. Most of the fields known
    in BSEG are not known in the database table RFBLG, but are compressed in a VARDATA
    field of RFBLG. So tests in the WHERE clause of SELECTs agains BSEG are not used by
    the database (e.g. lifnr = vendor account number, hkont = G/L account, kostl = cost center).
    As a consequence, these tests are done after the facts similar to using the CHECK statement,
    and as already said in tip 1, CHECK statements are worse than tests in the WHERE-clause.
    Check this link also.
    How to Read BSEG Efficiently
    you'll never select table bkpf alone.
    alternatives:
    1) select with header information from bkpf
    2) use secondary index tables
    Re: Tuning cluster table selection
    3) use logical data base e.g.: BRF
    Hope this helps.If so,reward points.Otherwise, get back.

  • Bkpf-xblnr & bseg-rebzg

    hi all,
    may i know where does the system define or which tcode that i can see to have the billing number updated in bkpf-xblnr and bseg-rebzg after posted to fi?
    thanks
    rgds

    Dear Eliana,
    I think you should confirm the billing doc No in BSEG-VBELN.
    Best Regards,
    Gladys xing

  • LDB SDF - why can not we add fields of BKPF and BSEG?

    I went to SE36 - SAP to CUS and added the field CPUDT fron BKPF to functionla group 03 Document.
    But it does not appear in the Dynamic Selections.
    Any thing needs to be activated or

    no solution heard - so closing

  • LOGICAL DATABASE BRF   FOR ...  BKPF AND BSEG

    Hi friends  ,
    i want the change the input criteria  ( select option) in my program , i am using the LDB  "BRF"  ..it gives me standard selection screen  .. but i want to add the GSBER   field in the input  condition  ..
    How can i cahge the selection  criteria in standard LDB ..How can i do that ..
    Ialso want to convert select option in  output to  parameter ...
    Plz suggest..

    Dude LDB gives me one extra selection  parameter   but i need not that parameter ...
    Is ther any way by which i remove that  selection parameter and add up my new paramere ...
    The same thing  i done in pnp LDB  but i am unable to do  same in brf LDB. 
    Beaus in PNP there is "HR report  category "  BY which i cam made  >>>>

  • Alternative for FV60 transaction

    Hi All,
    I need to use an alternative method/process of achieving the functionality of parking an Invoice as done in FV60.
    I tried using FM PRELIMINARY_POSTING_FB01 for the same, ISSUE: its not creating the bseg records.
    Tried FM POST_DOCUMENT, though its creating bkpf and bseg records, the split of records is not happening.
    Can any of you suggest an alternative process of parking an FI invoice through a FM etc...as is done in transaction FV60
    Thanks
    Raj

    Hi
    Thanks for your reply but this BAPI you suggested is for transaction MIR7, but not for FV60.
    I need an alternative for FV60.
    Regards
    Raj

Maybe you are looking for