Re: join cluster table into transperant table in ABAP Queries

Hi gurus
How to join cluster tables into transperant tables in ABAP Queries,
I want to join KNA1, KNB2, BSEG(cluster table)
pls explain me
amk

Hi
You can use join for KNA1 and KNB1 which will much faster
then use for all entries of this itab to get the BSEG to improve the performance
here you need to do some trial and error method by joining  removing the tables and also for all entries
regards
Shiva

Similar Messages

  • In which Table all ABAP queries store?

    Hi Guys,
    In which Table all ABAP queries store?
    Thanks,
    Sa nkar

    Hi..
    ABAP Queries are also stored in the Table TADIR along with other Repository Objects.
    the following fields must be checked to Find ABAP Queries in this Table:
    PGMID = 'R3TR'
    OBJECT = 'AQQU' "For ABAP Queries
    This will help u to retrieve the ABAP queries from this table TADIR.
    sample code:
    data: itab type table of TADIR.
    SELECT * FROM TADIR into table ITAB.
    WHERE PGMID = 'R3TR'
    and OBJECT = 'AQQU'
    and (OBJ_NAME like 'Z%' or OBJ_NAME like 'Y%').
    REWARD IF HELPFUL.

  • Join cluster table

    Hi
    I would like to make a joint with a table cluster (bseg) but the system put an error compilation. what a solution? Thank you for answer. 
    Even the creation of a view does not make with the tables cluster.

    Hi,
      You cannot write join for cluster tables like BSEG..Instead you can use FOR ALL ENTRIES options..
    EX..
    DATA: T_BKPF TYPE STANDARD TABLE OF BKPF,
          T_BSEG TYPE STANDARD TABLE OF BSEG.
    SELECT * FROM BKPF
           INTO TABLE T_BKPF
           WHERE....
    IF NOT T_BKPF IS INITIAL.
      SELECT * FROM BSEG
             INTO TABLE T_BSEG
             FOR ALL ENTRIES IN T_BKPF
             WHERE BUKRS = T_BKPF-BUKRS
             AND   BELNR = T_BKPF-BELNR
             AND   GJAHR = T_BKPF-GJAHR..
    ENDIF.
    Thanks,
    Naren

  • How to join cluster table?

    How to join the cluster table with the transparent table?In specific ,can you pls tell me how can i join bkpf and bseg?

    Hi Aravind,
    Check this code,
    tables : bkpf,
             bseg.
       INTERNAL TABLE AND WORK AREA FOR THE FIELDS IN BKPF TABLE         *
    data : begin of itab_bkpf occurs 0,
           bukrs like bkpf-bukrs,            "Company Code.
           gjahr like bkpf-gjahr,            "Fiscal Year.
           budat like bkpf-budat,            "Posting Date in the Document.
           belnr like bkpf-belnr,            "Accounting document number.
           blart like bkpf-blart,            "Document Type.
           end of itab_bkpf.
    data : wa_bkpf like line of itab_bkpf.
       INTERNAL TABLE AND WORK AREA FOR THE FIEDLS IN BSEG TABLE         *
    data : begin of itab_bseg_debit occurs 0,
           bukrs like bseg-bukrs,            "Company Code.
           gjahr like bseg-gjahr,            "Fiscal Year.
           belnr like bseg-belnr,            "Accounting Document Number.
           buzei like bseg-buzei,            "Line Item.
           hkont like bseg-hkont,            "General Leadger Account.
           shkzg like bseg-shkzg,            "Credit/Debit Indicator.
           wrbtr like bseg-wrbtr,            "Amount in Document Currency.
           pswsl like bseg-pswsl,            "Update Currency for Gen.Ledger
           dmbtr like bseg-dmbtr,            "Amount in local currency.
           sgtxt like bseg-sgtxt,            "Item Text.
           zuonr like bseg-zuonr,            "Assignment Number.
           end of itab_bseg_debit.
    data : itab_bseg_credit like standard table of itab_bseg_debit with
           header line.
                      FINAL OUTPUT INTERNAL TABLE                        *
    data : begin of itab_output occurs 0,
           belnr(08)            ,
           bukrs(04)            ,
           budat like bkpf-budat,
           buzei(03)            ,
           hkont(07)            ,
           blart(02)            ,
           shkzg(01)            ,
           wrbtr(08)            ,
           pswsl(05)            ,
           dmbtr(10)            ,
           sgtxt(19)            ,
           zuonr(10)            ,
    end of itab_output.
    constants : c_debit  type c value 'S',
                c_credit type c value 'H'.
                               SELECT-OPTIONS                            *
    selection-screen begin of block input with frame title text-t01.
    select-options : s_bukrs for bkpf-bukrs.
    parameters     : p_year like bkpf-gjahr visible length 2.
    select-options : s_budat  for bkpf-budat,
                     s_dbacct for bseg-hkont,
                     s_cracct for bseg-hkont,
                     s_amt    for bseg-dmbtr.
    selection-screen end of block input.
         SELECTING RECORDS FROM BKPF TABLE BASED ON THE CONDITION        *
    select bukrs gjahr budat belnr blart
           from  bkpf into table itab_bkpf
           where bukrs in s_bukrs and
                 gjahr eq p_year  and
                 budat in s_budat.
        SELECTING DEBIT LINE ITEMITEMS FROM BSEG FOR THE DOCUMENT        *
                      NUMBER SELECTED FROM BKPF                          *
    if not itab_bkpf[] is initial.
      select bukrs gjahr belnr buzei
             hkont shkzg wrbtr pswsl
             dmbtr sgtxt zuonr
             from bseg into table itab_bseg_debit
             for all entries in itab_bkpf
             where bukrs eq itab_bkpf-bukrs and
                   belnr eq itab_bkpf-belnr and
                   gjahr eq itab_bkpf-gjahr and
                   hkont in s_dbacct        and
                   shkzg eq c_debit         and
                   dmbtr in s_amt.
        SELECTING CREDIT LINE ITEMITEMS FROM BSEG FOR THE DOCUMENT       *
                      NUMBER SELECTED FROM BKPF                          *
      select bukrs gjahr belnr buzei
             hkont shkzg wrbtr pswsl
             dmbtr sgtxt zuonr
             from bseg into table itab_bseg_credit
             for all entries in itab_bkpf
             where bukrs eq itab_bkpf-bukrs and
                   belnr eq itab_bkpf-belnr and
                   gjahr eq itab_bkpf-gjahr and
                   hkont in s_cracct        and
                   shkzg eq c_credit        and
                   dmbtr in s_amt.
    endif.
    sort itab_bkpf        by bukrs gjahr belnr.
    sort itab_bseg_credit by bukrs gjahr belnr.
                         LOOPING THE DEBIT ENTRIES                       *
    loop at itab_bseg_debit.
    READING THE CREDIT ENTRIES WHICH MATCHES WITH HE CURRENT DOC. NUMBER *
      read table itab_bseg_credit with key
                 bukrs = itab_bseg_debit-bukrs
                 gjahr = itab_bseg_debit-gjahr
                 belnr = itab_bseg_debit-belnr binary search.
      if sy-subrc eq 0.
    *READING THE POSTING DATE AND DOCUMENT TYPE FOR THE CURRENT DOUCMENT   *
           AND APPENDING THE DEBIT AND CREDIT ENTRIES                    *
        read table itab_bkpf into wa_bkpf with key
                   bukrs = itab_bseg_debit-bukrs
                   gjahr = itab_bseg_debit-gjahr
                   belnr = itab_bseg_debit-belnr binary search.
        itab_output-belnr = itab_bseg_debit-belnr.
        itab_output-bukrs = itab_bseg_debit-bukrs.
        itab_output-budat = wa_bkpf-budat.
        itab_output-buzei = itab_bseg_debit-buzei.
        itab_output-hkont = itab_bseg_debit-hkont.
        itab_output-blart = wa_bkpf-blart.
        itab_output-shkzg = itab_bseg_debit-shkzg.
        itab_output-wrbtr = itab_bseg_debit-wrbtr.
        itab_output-pswsl = itab_bseg_debit-pswsl.
        itab_output-dmbtr = itab_bseg_debit-dmbtr.
        itab_output-sgtxt = itab_bseg_debit-sgtxt.
        itab_output-zuonr = itab_bseg_debit-zuonr.
        append itab_output.
        itab_output-belnr = itab_bseg_credit-belnr.
        itab_output-bukrs = itab_bseg_credit-bukrs.
        itab_output-budat = wa_bkpf-budat.
        itab_output-buzei = itab_bseg_credit-buzei.
        itab_output-hkont = itab_bseg_credit-hkont.
        itab_output-blart = wa_bkpf-blart.
        itab_output-shkzg = itab_bseg_credit-shkzg.
        itab_output-wrbtr = itab_bseg_credit-wrbtr.
        itab_output-pswsl = itab_bseg_credit-pswsl.
        itab_output-dmbtr = itab_bseg_credit-dmbtr.
        itab_output-sgtxt = itab_bseg_credit-sgtxt.
        itab_output-zuonr = itab_bseg_credit-zuonr.
        append itab_output.
      endif.
    endloop.
    sort itab_output by belnr budat shkzg.
                     LOOPING OUTPUT INTERNAL TABLE                       *
    *FORMAT INTENSIFIED INPUT.
    *FORMAT INVERSE ON.
    loop at itab_output.
      format hotspot on.
      format color 5 inverse.
      write :/  sy-vline,
               000 itab_output-belnr, 12  sy-vline,
               013 itab_output-bukrs, 17  sy-vline,
               019 itab_output-budat,     sy-vline,
               034 itab_output-buzei, 40  sy-vline,
               042 itab_output-hkont,     sy-vline,
               054 itab_output-blart, 60  sy-vline,
               065 itab_output-shkzg, 70  sy-vline,
               072 itab_output-wrbtr,     sy-vline,
               085 itab_output-pswsl,     sy-vline,
               093 itab_output-dmbtr,     sy-vline,
               106 itab_output-sgtxt,     sy-vline,
                   itab_output-zuonr,     sy-vline.
      format hotspot off.
    endloop.
    uline 0(139).
    <b>Regards,
    Jackie.</b>

  • How do we join cluster table bseg?

    Friends ,
    i just wanna know as 2 how can we combine bseg and bkpf tables.
    since bkpf is a transparent table and bseg is a cluster table.
    regards
    Essam
    [email protected]

    Hi Essam,
        REPORT  ztestport_01.
    TABLES : bkpf,
             bseg.
       INTERNAL TABLE AND WORK AREA FOR THE FIELDS IN BKPF TABLE         *
    DATA : BEGIN OF itab_bkpf OCCURS 0,
           bukrs LIKE bkpf-bukrs,            "Company Code.
           gjahr LIKE bkpf-gjahr,            "Fiscal Year.
           budat LIKE bkpf-budat,            "Posting Date in the Document.
           belnr LIKE bkpf-belnr,            "Accounting document number.
           blart LIKE bkpf-blart,            "Document Type.
           END OF itab_bkpf.
    DATA : wa_bkpf LIKE LINE OF itab_bkpf.
       INTERNAL TABLE AND WORK AREA FOR THE FIEDLS IN BSEG TABLE         *
    DATA : BEGIN OF itab_bseg_debit OCCURS 0,
           bukrs LIKE bseg-bukrs,            "Company Code.
           gjahr LIKE bseg-gjahr,            "Fiscal Year.
           belnr LIKE bseg-belnr,            "Accounting Document Number.
           buzei LIKE bseg-buzei,            "Line Item.
           hkont LIKE bseg-hkont,            "General Leadger Account.
           shkzg LIKE bseg-shkzg,            "Credit/Debit Indicator.
           wrbtr LIKE bseg-wrbtr,            "Amount in Document Currency.
           pswsl LIKE bseg-pswsl,            "Update Currency for Gen.Ledger
           dmbtr LIKE bseg-dmbtr,            "Amount in local currency.
           sgtxt LIKE bseg-sgtxt,            "Item Text.
           zuonr LIKE bseg-zuonr,            "Assignment Number.
           END OF itab_bseg_debit.
    DATA : itab_bseg_credit LIKE STANDARD TABLE OF itab_bseg_debit WITH
           HEADER LINE.
                      FINAL OUTPUT INTERNAL TABLE                        *
    DATA : BEGIN OF itab_output OCCURS 0,
           belnr(08)            ,
           bukrs(04)            ,
           budat LIKE bkpf-budat,
           buzei(03)            ,
           hkont(07)            ,
           blart(02)            ,
           shkzg(01)            ,
           wrbtr(08)            ,
           pswsl(05)            ,
           dmbtr(10)            ,
           sgtxt(19)            ,
           zuonr(10)            ,
    END OF itab_output.
    CONSTANTS : c_debit  TYPE c VALUE 'S',
                c_credit TYPE c VALUE 'H'.
                               SELECT-OPTIONS                            *
    SELECTION-SCREEN BEGIN OF BLOCK input WITH FRAME TITLE text-t01.
    SELECT-OPTIONS : s_bukrs FOR bkpf-bukrs.
    PARAMETERS     : p_year LIKE bkpf-gjahr visible length 2.
    SELECT-OPTIONS : s_budat  FOR bkpf-budat,
                     s_dbacct FOR bseg-hkont,
                     s_cracct FOR bseg-hkont,
                     s_amt    FOR bseg-dmbtr.
    SELECTION-SCREEN END OF BLOCK input.
         SELECTING RECORDS FROM BKPF TABLE BASED ON THE CONDITION        *
    SELECT bukrs gjahr budat belnr blart
           FROM  bkpf INTO TABLE itab_bkpf
           WHERE bukrs IN s_bukrs AND
                 gjahr EQ p_year  AND
                 budat IN s_budat.
        SELECTING DEBIT LINE ITEMITEMS FROM BSEG FOR THE DOCUMENT        *
                      NUMBER SELECTED FROM BKPF                          *
    IF NOT itab_bkpf[] IS INITIAL.
      SELECT bukrs gjahr belnr buzei
             hkont shkzg wrbtr pswsl
             dmbtr sgtxt zuonr
             FROM bseg INTO TABLE itab_bseg_debit
             FOR ALL ENTRIES IN itab_bkpf
             WHERE bukrs EQ itab_bkpf-bukrs AND
                   belnr EQ itab_bkpf-belnr AND
                   gjahr EQ itab_bkpf-gjahr AND
                   hkont IN s_dbacct        AND
                   shkzg EQ c_debit         AND
                   dmbtr IN s_amt.
        SELECTING CREDIT LINE ITEMITEMS FROM BSEG FOR THE DOCUMENT       *
                      NUMBER SELECTED FROM BKPF                          *
      SELECT bukrs gjahr belnr buzei
             hkont shkzg wrbtr pswsl
             dmbtr sgtxt zuonr
             FROM bseg INTO TABLE itab_bseg_credit
             FOR ALL ENTRIES IN itab_bkpf
             WHERE bukrs EQ itab_bkpf-bukrs AND
                   belnr EQ itab_bkpf-belnr AND
                   gjahr EQ itab_bkpf-gjahr AND
                   hkont IN s_cracct        AND
                   shkzg EQ c_credit        AND
                   dmbtr IN s_amt.
    ENDIF.
    SORT itab_bkpf        BY bukrs gjahr belnr.
    SORT itab_bseg_credit BY bukrs gjahr belnr.
                         LOOPING THE DEBIT ENTRIES                       *
    LOOP AT itab_bseg_debit.
    READING THE CREDIT ENTRIES WHICH MATCHES WITH HE CURRENT DOC. NUMBER *
      READ TABLE itab_bseg_credit WITH KEY
                 bukrs = itab_bseg_debit-bukrs
                 gjahr = itab_bseg_debit-gjahr
                 belnr = itab_bseg_debit-belnr BINARY SEARCH.
      IF sy-subrc EQ 0.
    *READING THE POSTING DATE AND DOCUMENT TYPE FOR THE CURRENT DOUCMENT   *
           AND APPENDING THE DEBIT AND CREDIT ENTRIES                    *
        READ TABLE itab_bkpf INTO wa_bkpf WITH KEY
                   bukrs = itab_bseg_debit-bukrs
                   gjahr = itab_bseg_debit-gjahr
                   belnr = itab_bseg_debit-belnr BINARY SEARCH.
        itab_output-belnr = itab_bseg_debit-belnr.
        itab_output-bukrs = itab_bseg_debit-bukrs.
        itab_output-budat = wa_bkpf-budat.
        itab_output-buzei = itab_bseg_debit-buzei.
        itab_output-hkont = itab_bseg_debit-hkont.
        itab_output-blart = wa_bkpf-blart.
        itab_output-shkzg = itab_bseg_debit-shkzg.
        itab_output-wrbtr = itab_bseg_debit-wrbtr.
        itab_output-pswsl = itab_bseg_debit-pswsl.
        itab_output-dmbtr = itab_bseg_debit-dmbtr.
        itab_output-sgtxt = itab_bseg_debit-sgtxt.
        itab_output-zuonr = itab_bseg_debit-zuonr.
        APPEND itab_output.
        itab_output-belnr = itab_bseg_credit-belnr.
        itab_output-bukrs = itab_bseg_credit-bukrs.
        itab_output-budat = wa_bkpf-budat.
        itab_output-buzei = itab_bseg_credit-buzei.
        itab_output-hkont = itab_bseg_credit-hkont.
        itab_output-blart = wa_bkpf-blart.
        itab_output-shkzg = itab_bseg_credit-shkzg.
        itab_output-wrbtr = itab_bseg_credit-wrbtr.
        itab_output-pswsl = itab_bseg_credit-pswsl.
        itab_output-dmbtr = itab_bseg_credit-dmbtr.
        itab_output-sgtxt = itab_bseg_credit-sgtxt.
        itab_output-zuonr = itab_bseg_credit-zuonr.
        APPEND itab_output.
      ENDIF.
    ENDLOOP.
    SORT itab_output BY belnr budat shkzg.
    then loop your final itab_output
    and give write command to print
    your fields.
    <b>Regards,
    Jackie.</b>
    Message was edited by:
            Jackie

  • Text Tables in ABAP Queries

    Can we use Text Tables in ABAP Query?

    HI,
    yes we can use text tables in ABAP SQL Queries example MAKT is a text table for material descriptions
    we can have the query on this table.
    regards
    sarves

  • Reg: how to join more than one cluster table into one

    Hi gurus
    How to join more than one cluster table into one
    amk

    Hi,
    You cannot join cluster tables
    Best way is to select from the header table and then select from the item table table using for all entries of header table.
    regards,
    Advait

  • Joining of cluster tables

    Hello Mr .kishan ,navneet ,sachin and aakash ,
    I asked a doubt and you guyz are making mountain out a molehill.No one is Mr .Know here in this comm, the community should cater to the needs of all the proficiency levels .
    You should also try to think about the freshers or novices who are starting their careers in SAP ABAP.
    My primary concern was ,why we cant join cluster tables ?? all the MR KNOWS have given answers like ,we cant join ,we cant join .I wanted technical reason for it ,
    Using for all entries is a solution they gave ,that i know .You think i havent searched the forum before asking the query .
    Show me the correct technical valid reason for my query in the previous posted threads ,then i will accept my fault.
    You should answer in a polite manner not bullying or degrading the SDN users that you report me to someone or delete my profile .Very disappointing experience .
    Thank you .

    I did not see you first question, so I can't comment on that. I assume it was quite easy to mix up your question with the many redundant ones that clog up this forum without providing added value. Also, there is no basic right that your requestions be answered, everybody is volunteering here, so you should act a bit more humble as the one seeking for advice.
    To help the good cause:
    http://help.sap.com/saphelp_nw04/helpdata/en/cf/21f083446011d189700000e8322d00/content.htm
    > You need the structural information stored in the ABAP Dictionary to read the data from a pooled table or cluster table correctly. These tables can therefore only be processed using Open SQL with the cluster interface, and not with Native SQL directly in the database.
    I assume this applies to joins as well which are done at database level, the table structure needs be known and is not in case of cluster tables.
    Thomas

  • Cluster tables in SAP

    Hi all,
    what are the cluster tables in SAP.
    and shall we use inner join statment on cluster tables.
    regards,
    Suresh

    HI,
    <b>CLUSTER Tables :-</b>Table clusters (clusters) are special table types in the ABAP Dictionary
    The data from several tables is stored together in a table pool or table cluster. Tables assigned to a table pool or table cluster are referred to as pooled tables or cluster tables.
    Table pool or table cluster should be used exclusively for storing internal control information (screen sequences, program parameters, temporary data, continuous texts such as documentation). Data of commercial relevance is usually stored in transparent tables.
    Can check this link for more clarity
    http://help.sap.com/saphelp_47x200/helpdata/en/81/415d363640933fe10000009b38f839/frameset.htm
    <b>We can't use inner join on clustor table.
    To Join cluster table with other table its better use
    several select statements.</b>
    This one sample code to join cluster table with other transperant table.
    In this bseg is a cluster table.
    Check it out.
    TABLES : bkpf,
             bseg.
       INTERNAL TABLE AND WORK AREA FOR THE FIELDS IN BKPF TABLE         *
    DATA : BEGIN OF itab_bkpf OCCURS 0,
           bukrs LIKE bkpf-bukrs,            "Company Code.
           gjahr LIKE bkpf-gjahr,            "Fiscal Year.
           budat LIKE bkpf-budat,            "Posting Date in the Document.
           belnr LIKE bkpf-belnr,            "Accounting document number.
           blart LIKE bkpf-blart,            "Document Type.
           END OF itab_bkpf.
    DATA : wa_bkpf LIKE LINE OF itab_bkpf.
       INTERNAL TABLE AND WORK AREA FOR THE FIEDLS IN BSEG TABLE         *
    DATA : BEGIN OF itab_bseg_debit OCCURS 0,
           bukrs LIKE bseg-bukrs,            "Company Code.
           gjahr LIKE bseg-gjahr,            "Fiscal Year.
           belnr LIKE bseg-belnr,            "Accounting Document Number.
           buzei LIKE bseg-buzei,            "Line Item.
           hkont LIKE bseg-hkont,            "General Leadger Account.
           shkzg LIKE bseg-shkzg,            "Credit/Debit Indicator.
           wrbtr LIKE bseg-wrbtr,            "Amount in Document Currency.
           pswsl LIKE bseg-pswsl,            "Update Currency for Gen.Ledger
           dmbtr LIKE bseg-dmbtr,            "Amount in local currency.
           sgtxt LIKE bseg-sgtxt,            "Item Text.
           zuonr LIKE bseg-zuonr,            "Assignment Number.
           END OF itab_bseg_debit.
    DATA : itab_bseg_credit LIKE STANDARD TABLE OF itab_bseg_debit WITH
           HEADER LINE.
                      FINAL OUTPUT INTERNAL TABLE                        *
    DATA : BEGIN OF itab_output OCCURS 0,
           belnr(08),
           bukrs(04),
           budat LIKE bkpf-budat,
           buzei(03),
           hkont(07),
           blart(02),
           shkzg(01),
           wrbtr(08),
           pswsl(05),
           dmbtr(10),
           sgtxt(19),
           zuonr(10),
    END OF itab_output.
    CONSTANTS : c_debit TYPE c VALUE 'S',
                c_credit TYPE c VALUE 'H'.
                               SELECT-OPTIONS                            *
    SELECTION-SCREEN BEGIN OF BLOCK input WITH FRAME TITLE text-t01.
    SELECT-OPTIONS : s_bukrs FOR bkpf-bukrs.
    PARAMETERS     : p_year LIKE bkpf-gjahr.
    SELECT-OPTIONS : s_budat  FOR bkpf-budat,
                     s_dbacct FOR bseg-hkont,
                     s_cracct FOR bseg-hkont,
                     s_amt    FOR bseg-dmbtr.
    SELECTION-SCREEN END OF BLOCK input.
         SELECTING RECORDS FROM BKPF TABLE BASED ON THE CONDITION        *
    SELECT bukrs gjahr budat belnr blart
           FROM bkpf INTO TABLE itab_bkpf
           WHERE bukrs IN s_bukrs AND
                 gjahr EQ p_year  AND
                 budat IN s_budat.
        SELECTING DEBIT LINE ITEMITEMS FROM BSEG FOR THE DOCUMENT        *
                      NUMBER SELECTED FROM BKPF                          *
    IF NOT itab_bkpf[] IS INITIAL.
      SELECT bukrs gjahr belnr buzei
             hkont shkzg wrbtr pswsl
             dmbtr sgtxt zuonr
             FROM bseg INTO TABLE itab_bseg_debit
             FOR ALL ENTRIES IN itab_bkpf
             WHERE bukrs EQ itab_bkpf-bukrs AND
                   belnr EQ itab_bkpf-belnr AND
                   gjahr EQ itab_bkpf-gjahr AND
                   hkont IN s_dbacct        AND
                   shkzg EQ c_debit         AND
                   dmbtr IN s_amt.
        SELECTING CREDIT LINE ITEMITEMS FROM BSEG FOR THE DOCUMENT       *
                      NUMBER SELECTED FROM BKPF                          *
      SELECT  bukrs gjahr belnr buzei
              hkont shkzg wrbtr pswsl
              dmbtr sgtxt zuonr
              FROM bseg INTO TABLE itab_bseg_credit
              FOR ALL ENTRIES IN itab_bkpf
              WHERE bukrs EQ itab_bkpf-bukrs AND
                    belnr EQ itab_bkpf-belnr AND
                    gjahr EQ itab_bkpf-gjahr AND
                    hkont IN s_cracct        AND
                    shkzg EQ c_credit        AND
                    dmbtr IN s_amt.
    ENDIF.
    SORT itab_bkpf        BY bukrs gjahr belnr.
    SORT itab_bseg_credit BY bukrs gjahr belnr.
                         LOOPING THE DEBIT ENTRIES
    LOOP AT itab_bseg_debit.
    READING THE CREDIT ENTRIES WHICH MATCHES WITH HE CURRENT DOC. NUMBER
      READ TABLE itab_bseg_credit WITH KEY
                 bukrs = itab_bseg_debit-bukrs
                 gjahr = itab_bseg_debit-gjahr
                 belnr = itab_bseg_debit-belnr BINARY SEARCH.
      IF sy-subrc EQ 0.
    *READING THE POSTING DATE AND DOCUMENT TYPE FOR THE CURRENT DOUCMENT
           AND APPENDING THE DEBIT AND CREDIT ENTRIES
        READ TABLE itab_bkpf INTO wa_bkpf WITH KEY
                   bukrs = itab_bseg_debit-bukrs
                   gjahr = itab_bseg_debit-gjahr
                   belnr = itab_bseg_debit-belnr BINARY SEARCH.
        itab_output-belnr = itab_bseg_debit-belnr.
        itab_output-bukrs = itab_bseg_debit-bukrs.
        itab_output-budat = wa_bkpf-budat.
        itab_output-buzei = itab_bseg_debit-buzei.
        itab_output-hkont = itab_bseg_debit-hkont.
        itab_output-blart = wa_bkpf-blart.
        itab_output-shkzg = itab_bseg_debit-shkzg.
        itab_output-wrbtr = itab_bseg_debit-wrbtr.
        itab_output-pswsl = itab_bseg_debit-pswsl.
        itab_output-dmbtr = itab_bseg_debit-dmbtr.
        itab_output-sgtxt = itab_bseg_debit-sgtxt.
        itab_output-zuonr = itab_bseg_debit-zuonr.
        APPEND itab_output.
        itab_output-belnr = itab_bseg_credit-belnr.
        itab_output-bukrs = itab_bseg_credit-bukrs.
        itab_output-budat = wa_bkpf-budat.
        itab_output-buzei = itab_bseg_credit-buzei.
        itab_output-hkont = itab_bseg_credit-hkont.
        itab_output-blart = wa_bkpf-blart.
        itab_output-shkzg = itab_bseg_credit-shkzg.
        itab_output-wrbtr = itab_bseg_credit-wrbtr.
        itab_output-pswsl = itab_bseg_credit-pswsl.
        itab_output-dmbtr = itab_bseg_credit-dmbtr.
        itab_output-sgtxt = itab_bseg_credit-sgtxt.
        itab_output-zuonr = itab_bseg_credit-zuonr.
        APPEND itab_output.
      ENDIF.
    ENDLOOP.
    Reward if it helps you.
    Thanks.

  • Unable to join the tables CDHDR, CDPOS

    Hello,
    I want to create a Query connecting tables CDHDR & CDPOS to extract cost center details which are changed. To be precise, when cost center details are changed using transactions KS02 & KS03, I want to extract those details and run the report. I am unable to join the tables using SAP Queries SQ01, SQ02, SQ03.
    Kindly suggest me regarding the same.
    Thanks in advance.
    Regards
    Sravan Mulumudi.

    Hi Jeve,
    I was testing the report S_ALR_87012308, but this displays changes done to G/L accounts. I have tried every possibility. Could you please explain further ?
    Regards
    Sravan.

  • Tables in ABAP

    why transparent,pooled and cluster tables in ABAP DDIC are called Ttransparent,pooled and cluster?

    Hi,
    Transparent Tables :   There is a physical table on the database for each transparent table. The  names of the physical tables and the logical table definition in the      ABAP/4 Dictionary correspond. All business data and application data are stored in transparent tables. 
    Pooled Tables : Pooled table in R/3 has a many-to-one relationship with a table in the database.
    For one table in the database, there are many tables in the R/3 Data Dictionary.
    In the database, it is stored along with other pooled tables in a single table called a table pool.
    Cluster table :A cluster table is similar to a pooled table.
    It has a many-to-one relationship with a table in the database.
    Many cluster tables are stored in a single table in the database called a table cluster.
    Hope you got some ideas,
    Thanks,
    Sakthi C

  • Why Inner join or Outer join is not used for Pool or Cluster tables  ?

    Hi SAP-ABAP Experts .
    With Due Regards .
    May u explain me why Inner join or Outer join is not useful for Pool or Cluster tables  ?
    because peoples advised not use Joins for Pool and Cluster tables , What harm will take place , If we do this ?
    Best Regards to all : Rajneesh

    Both Pooled and Cluster Tables are stored as tables within the database. Only the structures of the two table types which represent a single logical view of the data are defined within the ABAP/4 Data Dictionary. The data is actually stored in bulk storage in a different structure. These tables are commonly loaded into memory (i.e., 'buffered') due to the fact they are typically used for storing internal control information and other types of data with little or no external (business) relevance.
    Pooled and cluster tables are usually used only by SAP and not used by customers, probably because of the proprietary format of these tables within the database and because of technical restrictions placed upon their use within ABAP/4 programs. On a pooled or cluster table:
    Secondary indexes cannot be created.
    You cannot use the ABAP/4 constructs select distinct or group by.
    You cannot use native SQL.
    You cannot specify field names after the order by clause. order by primary key is the only permitted variation.
    I hope it helps.
    Best Regards,
    Vibha
    Please mark all the helpful answers

  • How to 'inner join' internal table or cluster table ??

    Hi,
    when i inner join table BSEG it said is a cluster table can't be inner joined .
    i wonder how i can "inner join" bseg with a internal table such as
    data: begin of i_bseg_trans,
            bukrs like bseg-bukrs,
            gjahr like bseg-gjahr,
            belnr like bseg-belnr,
            total_runtimes like i_runtimes-total,
            already_runtimes like i_runtimes-already,
            left_runtimes like i_runtimes-left,
          end of i_bseg_trans.
    and similar things trouble me  when considering several internal tables .
    thanks for any help!!

    Hi,
    but if there's more than 2 tables,  for example
    data: begin of it_bseg occurs 0,
            bukrs like bseg-bukrs,
            else_1 type i,
         end of it_bseg.
    data: begin of t occurs 0,
            bukrs like bseg-bukrs,
          end of t.
    data: begin of r occurs 0,
            bukrs like bseg-bukrs,
            else type c,
          end of r.
    select bukrs from bkdf into table t.
    select bukrs from bkdf into corresponding fields of table it_bseg.
    select bseg~bukrs      "else_1
    from bseg      "it_bseg
      into table r
      for all entries in t
      where bseg~bukrs = t-bukrs.
          " and it_bseg-bukrs = t-bukrs.
    in the select clause i mean whether there's a method similar to the way just drop the " in my code.
    now my solution is to use another loop on it_bseg, but i think when table amount is large this is really a boring solution.

  • How to Extract data from Cluster table  and transperant table

    Hello BW Experts ,
    I want to extract the data from cluster table BSEG and a transperant table BKPF .
    The primary fields are BELNR , GJHAR and BUKRS.
    the fields of table BKPF to extarct is BUDAT and fields of BSEG table is HKONT , BSCHL , ZUONR and POSID.
    I can not create a view over these two tables as BSEG is a Cluster table.
    Please guide me.
    Regadrs ,
    Amol.

    hi Amol,
    take a look Sigg's weblog
    /people/siegfried.szameitat/blog/2005/09/29/generic-extraction-via-function-module
    you can use RSAX_BIW_GET_DATA_SIMPLE as sample, there specified import parameters
    FUNCTION RSAX_BIW_GET_DATA_SIMPLE.
    ""Lokale Schnittstelle:
    *" IMPORTING
    *" VALUE(I_REQUNR) TYPE SRSC_S_IF_SIMPLE-REQUNR
    *" VALUE(I_DSOURCE) TYPE SRSC_S_IF_SIMPLE-DSOURCE OPTIONAL
    *" VALUE(I_MAXSIZE) TYPE SRSC_S_IF_SIMPLE-MAXSIZE OPTIONAL
    *" VALUE(I_INITFLAG) TYPE SRSC_S_IF_SIMPLE-INITFLAG OPTIONAL
    *" VALUE(I_READ_ONLY) TYPE SRSC_S_IF_SIMPLE-READONLY OPTIONAL
    *" TABLES
    *" I_T_SELECT TYPE SRSC_S_IF_SIMPLE-T_SELECT OPTIONAL
    *" I_T_FIELDS TYPE SRSC_S_IF_SIMPLE-T_FIELDS OPTIONAL
    *" E_T_DATA STRUCTURE SFLIGHT OPTIONAL
    *" EXCEPTIONS
    *" NO_MORE_DATA
    *" ERROR_PASSED_TO_MESS_HANDLER

  • TEXT into the Cluster Tables.

    A material (eg mat05) is maintained in a material master.
    A purchase order text is maintained for that particular,in <b>STXH</b> table.The Text ID,Text Name,Object ID,Spras are stored along with the TDNAME ( the long text ).I know these data are stored into <b>STXH,STXL</b> tables and some cluster tables.Can someone help me informing about the <b>Cluster Tables</b>( Specially on PO text ).

    Hello Rajarshi,
    There was a somewhat similar query sometime back which I shall point you to.
    Re: BasicText for a Material
    Besides, here's the code which would get you the purchase order texts for a given material -
    parameters: p_matnr type matnr.
    data: temp_text type table of tline with header line,
          where_cond(20) type c.
    data : begin of text_id ,
             tdobject(10) value 'MATERIAL',
             tdname(70),
             tdid(4)  ,
             tdspras      value 'E',
           end of text_id.
    start-of-selection.
      concatenate '%'
                  p_matnr
             into where_cond.
      select tdname
             tdid
        from stxl
        into (text_id-tdname , text_id-tdid)
       where relid   = 'TX' and
             tdspras = 'E'  and
             tdname like where_cond.
      import tline = temp_text[]
        from database stxl(TX)
          id text_id.
       write: / sy-subrc.
       loop at temp_text.
         write : / temp_text-tdline.
       endloop.
    ENDSELECT.
    Hope this is what you were looking for.
    Regards,
    Anand Mandalika.

Maybe you are looking for