PO number from EKBE Table

Hi Experts,
I want to prepare a new custom report in which the PO number should appear. I was advised to use EKBE table. On checking I found that I can pass only Material doc# and Fiscal Year and No company code field is found. Is it reliable to use only to input values and try to fetch the PO number? I am not sure if there could be more documents across company codes since the number range is set as company code level. Can you suggest any alternative?
I have already searched for similar topic but could not find the correct answer.
Please help.
Thanks in advance.
Sunil

Hi Both,
If I use MSEG table, I must use GR-MM document. As per my knowledge, IR document (MM/FI) won't reflect in MSEG table.
If GR entry is done first, then I can fetch the AWKEY field from IR-FI doc to get the MM doc#. If the IR entry is done first, (without GR entry posted on PO line) then it is not very easy to fetch the GR-MM document number at a later point of time also.
If the PO# is unique, independent from company code and year, then there are no issues, the below logic will work.
Pass the IR-FI Document number to BKPF with BUKRS&GJAHR and take get IR-MM document (AWKEY - 10 +4). Then pass this to EKBE table with BELNR and GJAHR then pick the EBELN (PO#) and EBELP (line item).
Please correct if I am not right.
Thanks in advance!

Similar Messages

  • Get FI Documet number from BKPF table using CO document number in COVP tabl

    Hi,
    In  datasource 0CO_OM_CCA_9 , we have written a code in CMOD to get the FI Document Number from CO document Number.
    The flow of code is:
    1) From the CO document number, get reference document number  (REFBNfield) from, COVP table
    2) Pass this REFBN in AWKEY(10) field of BKPF table.
    3) We have created new field in datasource named 'ZBELRE' which gets populated with BELNR field obtained from BKPF table.
    This ZBELNR is the FI Document number.
    But somehow wrong FI Document number is getting populated.
    After analyzing code, we found that the AWKEY which we passed in BKPF table is incomplete and the full AWKEY is
    COVP-REFBN+COVP-AWORG
    Is this condition always remains true in all the cases? Also, is the selection criterion which we have used to find the FI document number from BKPF table is sufficient?
    Our CO Consultant says that we should also pass AWTYP along with AWKEY in BKPF table.
    Please suggest a solution.
    Following is the code :
    ***********Datasource Modification for0CO_OM_CCA_9*******************
      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,
        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.
        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
        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.
            READ TABLE it_bkpf INTO wa_bkpf WITH KEY awkey(10) =
            l_s_icctrcsta1-refbn
            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.
            CLEAR: l_s_icctrcsta1.
          ENDLOOP.
        ENDIF.
    ***End of Datasource Modification for 0CO_OM_CCA_9*******************

    Hi,
    this forum is for the SAP BusinessObjects BI Solution Architecture. Please post your question into the corresponding product forum for SPA BW
    regards
    Ingo Hilgefort

  • Want to fetch data from AFVU table with input of order number from AUFK table

    Hi,
    I have a requrement in report where in the user wil enter  the order number from AUFK table and it should display detais like job code condition code (from AFVU table) along with other fields. There is no relation ship between AFVU and AUFK. Can anybody help me in getting the replation ship between 2 tables. What is the table that iam missing and where can i find that relationship and fetch records for that order number?

    Check if this helps..
    AUFK -> AFKO -> AFVU
    AUFK-AUFNR = AFKO-AUFNR
    AFKO-AUFPL = AFVU-AUFPL
    Hope this helps.

  • Delivery Number and EKBE table

    I have  a requirement to find out and print Delivery number all I have is PO number.
    and I was told that In EKBE if the PO history cat is "L" then fetch the Delivery Number.
    My question is from which table and which field i need to pull if the PO history category is L in EKBE table.
    Thanks in advance,,

    Here is the Link
    Get all the PO's From EKBE-BEWTP  " PO history cat is "L"
    Equal to 'L'.
    select * from ekbe
    into table it_ekbe
    where BEWTP = 'L'.
    if sy-subrc eq 0.
    select * from LIPS
       into table it_lip
       for all entries in it_ekbe
       where vgbel = it_ekbe-ebeln and
                vgpos = it_ekbe-ebelp.
    "This will give all the Deliveries realted to PO histort cat " L"
    endif.

  • How to fetch the latest change number from CDPOS Table..?

    Hi All,
    im trying to fetch teh change number from CDPOS with the below select, but my requirement is always i wants to fetch the latest change number.
              SELECT SINGLE objectid changenr FROM cdpos
                     INTO wa_cdpos
                     WHERE objectid = wa_e1kna1m-kunnr
                     AND ( tabname = 'KNA1' OR tabname = 'KNVV')
                     AND   fname = 'AUFSD'
                     AND ( value_new = '01' OR value_new = space ).
    Please let me know how to achive this..?
    Ashok

    try this way
    "           SELECT SINGLE objectid changenr FROM cdpos
    "                 INTO wa_cdpos
               SELECT objectid changenr FROM cdpos
                      INTO table t_cdpos
                      WHERE objectid = wa_e1kna1m-kunnr
                      AND ( tabname = 'KNA1' OR tabname = 'KNVV')
                      AND   fname = 'AUFSD'
                      AND ( value_new = '01' OR value_new = space ).
    SORT t_cdpos by  changenr Descending.
    read t_cdos index 1.    "this is the latest change
    Prabhudas

  • 2LIS_02_SCL - need Doc Currency Amount (WRBTR) from EKBE table

    Problem:  We are using the 2LIS_02_SCL to get our purchasing order data.  The problem is that instead of sending over the Doc Value Amounts found in the EKBE table, SAP is doing a calculation based on the the local currency.  They are then using the Exchange rate from the PO Header.  Our users are complaining, because they expect it to match up with what is in the purchase order history.
    I was planning to create a new amount field and and in my transfer rules write ABAP code to take the following fields from 2LIS_02_SCL:
    BW:CValLC(BWGEO), Local cur.(HWAER), Posting Date, Currency(WAERS)
    Use this Date to go back to TCURR to get the correct exchange rate that is used and do my calculation to doc currency (basically replicating the data as viewed in PO History).
    I ran into an issue however.  The Currency (WAERS) field is being filled with the value from EKKO.  I have a below example where in EKBE, the PO was invoiced in a currency other than the DOC Currency. 
    Data in R/3 from EKBE (History per PO)
    PO:                           1
    Amount in Local Currency(DMBTR):     250,01
    Local Currency (HSWAE):            USD
    Amount in Doc Currency(WRBTR):     250,01
    Doc Currency (WAERS):          USD
    Data in R/3 from EKKO (Purchase Order Header)
    PO:                         1
    WAERS:                    DKK
    In this scenario, I am unable to populate the correct value (as seen in purchase order history).
    I don’t see of a way that I can get around this.  Does anyone have any ideas?
    Thanks

    Hi Jiri,
    You can suggest the RRI from cube built on SCL report to cube built on EKBE based on PO.
    Also check if this can be solved by using a multi-cube on these 2 cubes.
    I have done a RRI when I was facing the same issue.
    Regards,
    Niraj

  • Finding the missing number from the table

    I have vendor table with the following column, refvendor_id, the refvendor_id is a primary key in the table. the customer use the application to enter information to the vendor table using an interface
    created in Java. my question is how can I query the refvendor_id numbers that have been skipped by the customer when they enter information to the vendor table.
    refvendor_id is a varchar data type.
    for example
    refvenodr_id
    1
    2
    3
    5
    6
    9
    I would like to capture in my sql the refvendor_id that is skipped here.
    4,7,8
    select refvendor_id
    from  vendor

    I suggest to find the number values with a regular expression.
    Here is a modified version, that will only use the pure number refvendor_ids
    -- Test-Data:
    with vendor as
    select '1' refvendor_id from dual union all
    select '2' refvendor_id from dual union all
    select '3' refvendor_id from dual union all
    select '5' refvendor_id from dual union all
    select '6' refvendor_id from dual union all
    select '9' refvendor_id from dual union all
    select '10'  refvendor_id from dual union all
    select '12'  refvendor_id  from dual union all
    select 'A'  refvendor_id from dual
    -- Query:
    select rownum from dual connect by rownum <= (select max(to_number(refvendor_id)) from vendor where regexp_like(refvendor_id,'^[0-9]+$') )
    minus
    select to_number(refvendor_id) from vendor where regexp_like(refvendor_id,'^[0-9]+$')
    order by 1;(I produce output in number-format, because i want numeric ordering in output)
    Edited by: hm on 14.12.2010 13:32 :
    Of cause you can also use your restrictions, but I can't see if that are really only numbers:
    select rownum from dual connect by rownum <= (select max(to_number(refvendor_id)) from vendor where SUBSTR (refvendor_id, 1, 1) IN ('1', '2', '3', '4', '5', '6', '7', '8', '9') AND LENGTH (refvendor_id) < 5 )
    minus
    select to_number(refvendor_id) from vendor where SUBSTR (refvendor_id, 1, 1) IN ('1', '2', '3', '4', '5', '6', '7', '8', '9') AND LENGTH (refvendor_id) < 5 )
    order by 1;

  • Get records number from internal table with condition.

    Internal table itab got more than 1000 records,now i need to get the number of records with condition that itab-field1 = 'XXXX'.
    actully, i got an inefficient logic to count the number in a loop statement. is there better way to implement it?

    hello,
    Every time assigning data into temp table and delete may that may not be much efficient. You can check in loop logic how much time is taken. You can check the below code. here I am trying to check the numbers of plant for for one material.
    In this logic material is the first field. So if there is option to make the required field in to the 1 st position then it will be nice.
    TYPES: BEGIN OF x_count,
            matnr TYPE matnr,
            count TYPE i,
           BEGIN OF x_count.
    DATA: i_marc  TYPE STANDARD TABLE OF marc,
          i_count TYPE STANDARD TABLE OF x_count,
          wa_count TYPE x_count.
    FIELD-SYMBOLS: <wa_marc> TYPE marc.
    SELECT * UP TO 1000 ROWS
      FROM marc
      INTO TABLE i_marc.
    IF sy-subrc = 0.
      SORT i_marc BY matnr.
      LOOP AT i_marc ASSIGNING <wa_marc>.
        wa_count-count = wa_count-count + 1.
        AT END OF matnr.
          wa_count-matnr = <wa_marc>-matnr.
          APPEND wa_count TO i_count.
        ENDAT.
      ENDLOOP.
    ENDIF.
    Thanks
    Subhanakr

  • Get the records number from internal table with conditon.

    Internal table itab got more than 1000 records,now i need to get the number of records with condition that itab-field1 = 'XXXX'.
    actully, i got an inefficient logic to count the number in a loop statement. is there better way to implement it?

    Hi,
    One alternative solution, which may be useful for other parts of your program, is to have an aditional itab1 with a single column/field (field1), which acts like a index or shadow table, and which is filled simultaneously with itab. Then you can use DESCRIBE TABLE itab1 LINES lv_lines.
    Atb

  • How to select data from a table by passing document number from another tab

    How to select data from a table by passing document number from another table.
    for eg:-
    I want to display name, adres, region from ADRC table
    by using field delivery document number
    Kind Regards,
    Shanbagavalli.S

    Hi Shanbagavalli,
    There are multiple solutions to this questions a few i will try to answer and then you can take the best required for your requirements.
    **Consider that you have a Internal table having document number from other table..
    SELECT NAME ADRES REGION FROM ADRC
           INTO IT_ADRC
           FOR ALL ENTRIES IN IT_DOC
           WHERE DOCUMENT_NO = IT_DOC-DOCUMENT_NO.
    **Consider that you have 1 document number then
    SELECT NAME ADRES REGION FROM ADRC
         INTO IT_ADRC
         WHERE DOCUMENT_NO = W_DOCUMENT_NO.
    Hope this solves your problem.
    Regards,
    Kunjal

  • From which table, the current number is taken for a WM TO?

    Dear Experts, 
    Kindly let me know when a transfer order is created in LT01,  how the TO number is  assigned?
    Before assigning a number, from which table it takes the current number?
    regards
    shetty

    Hi,
    r u able to see the current no in LT01 tcode ,if it is means pls let me know the field of that.
    and check with the below tables also,
    LAGP
    LECMOFF
    LEIN
    LINK
    LINP
    LINV
    LL01
    LL02
    thanks,
    sankar m

  • The Candidate mobile number disappeared from ADR2 table

    Hi,
    I have an observation that, when candidate gets registered in the system with all the basic details like First name, last name, Email ID and Mobile number. The details get stored in respective tables. The mobile number of the candidate gets stored in ADR2 table. In ADR2 table requires ADRCOMM number which we get from BUT000. Till the candidate was not hired the ADRCOMM Number was there in BUT000 table but as soon as the hiring has been done for that candidate the ADRCOMM number got vanished from BUT000.
    Kindly let me know that after hiring is that mobile number getting stored in any other table? Or what is the reason for mobile number to get disappeared?
    Regards,
    Sarika Mansukh

    Hi Nicole,
    Thanks for your response. In E-recruitment the candidate gets register in the system then gives the confirmation and then go to My profile and fills mobile number becoz we have made customization on my profile page that the mobile number is the mandatory field. However, i want to display that mobile number in one of my applicant details report.
    Therefore, I have given logic to fetch mobile number from ADR2 table. But ADR2 table needs ADDRCOMM number which we get from BUT000 table. For registered candidates the ADDRCOMM numbers get created in BUT000 but as soon as hiring done that number gets diapered from the table.
    Can you pls let me know that after hiring the mobile number gets stored in other table?
    Or
    What is the reason to ADDRCOMM number to get disappeared from BUT000 table.
    Regards,
    Sarika Mansukh

  • Purchase order EKKN/EKBE tables

    Hi,
    I m creating a report based on purchase order. I'm getting sequence number from EKKN table and then getting the invoice details from EKBE table using where clause on EBELN, EBELP and ZEKKN(Seq number) fields.
    My question is in some cases in EKBE table, 00 seq number is populated, mostly for VGABE = 1 (Mat doc number) or VGABE= 9(Service entry sheet). But this 00 is not in EKKN table. So in that case i miss these invoices in my internal table, bcoz i'm querying based on seq number, and 00 is not there.
    Bcoz you cann't use 00 seq number at the time of PO creation.
    Can any body tell me how and in which senarios seq no (EKBE-ZEKKN) field is being populated, so that i can write the code accordingly....
    Thanks,

    Start your selection query from EKBE first and then go to EKKN based on the EBELN, EBELP & ZEKKN.
    Regards,
    Naimesh Patel

  • EKBE table data

    Acutally I am fetching data from EKBE table for a given EBELN. Here I am getting all the GR and IR number for a EBELN. I have to fileter those GR which have IR. It means for a BELNR if the IR is raised, then the reference document (LFBNR) will be GR no. When I am going to ouput I am getting the IR and GR. I want to bring want to get oneline. If the IR is not raised for GR then it has to dispaly one line item.
    Ex: EBELN - BELNR - BWETP - LFBNR
    4100000000 - 5000000200 - E - 5000000200   
    4100000000 - 5000000201 - E - 5000000201
    4100000000 - 5100000501 - Q - 5000000200
    4100000000 - 5100000502 - Q - 5000000200
    OUTPUT EXPECTED:
    4100000000 - 5000000201 - E - 5000000201
    4100000000 - 5100000501 - Q - 5000000200
    4100000000 - 5100000502 - Q - 5000000200
    E - GR & Q - IR.
    for an E if IR is not there, it has to pick. See the Belnr 5000000201
    This is my Prob.
    Regards
    Ram

    HI
    try with this code
    data : begin of wa_pur_itm occurs 0,
             ebeln like ekpo-ebeln,
             ebelp like ekpo-ebelp,
             loekz like ekpo-loekz,
             aedat like ekpo-aedat,
             matkl like ekpo-matkl,
             matnr like ekbe-matnr,
             shkzg like ekbe-shkzg,
             bewtp like ekbe-bewtp,
             bwart like ekbe-bwart,
             wrbtr like ekbe-wrbtr,
             waers like ekbe-waers,
             belnr like ekbe-belnr,
             menge like ekbe-menge,
             buzei like ekbe-buzei,
             lfbnr like ekbe-lfbnr,
             hkont like bseg-hkont,
             xncop like bseg-xncop,
             maktx type makt-maktx,
             BEWTK type T163C-bewtk,
           end of wa_pur_itm.
    DATA : t_pur_itm   like wa_pur_itm occurs 0 with header line,
           t_pur_itm1  like wa_pur_itm occurs 0 with header line,
           t_pur_itm2  like wa_pur_itm occurs 0 with header line,
           t_pur_itm3  like wa_pur_itm occurs 0 with header line.
    select aebeln aebelp aloekz aaedat amatkl amatnr
           bshkzg bbewtp bbwart bwrbtr bwaers bbelnr
           bmenge bbuzei b~lfbnr
       into (t_pur_itm1-ebeln, t_pur_itm1-ebelp,
            t_pur_itm1-loekz, t_pur_itm1-aedat,
            t_pur_itm1-matkl, t_pur_itm1-matnr,
            t_pur_itm1-shkzg, t_pur_itm1-bewtp,
            t_pur_itm1-bwart, t_pur_itm1-wrbtr,
            t_pur_itm1-waers, t_pur_itm1-belnr,
            t_pur_itm1-menge, t_pur_itm1-buzei,
            t_pur_itm1-lfbnr)
           from ekpo as a
           inner join ekbe as b
           on aebeln eq bebeln and
              aebelp eq bebelp
         where a~aedat in s_aedat and
               a~matkl eq s_matkl and
               a~loekz eq space and
               a~bstyp eq 'F' and
               b~gjahr eq s_gjahr and
               b~bewtp eq 'E'.
    append t_pur_itm1.
    endselect.
    loop at t_pur_itm2.
      loop at t_pur_itm1 where ebeln eq t_pur_itm2-ebeln and
                               ebelp eq t_pur_itm2-ebelp and
                               lfbnr eq t_pur_itm2-lfbnr and
                               bewtp eq 'E'.
        t_pur_itm-ebeln = t_pur_itm1-ebeln.
        t_pur_itm-ebelp = t_pur_itm1-ebelp.
        t_pur_itm-bewtp = t_pur_itm1-bewtp.
        t_pur_itm-loekz = t_pur_itm1-loekz.
        t_pur_itm-aedat = t_pur_itm1-aedat.
        t_pur_itm-matkl = t_pur_itm1-matkl.
        t_pur_itm-matnr = t_pur_itm1-matnr.
        t_pur_itm-shkzg = t_pur_itm1-shkzg.
        t_pur_itm-bwart = t_pur_itm1-bwart.
       if t_pur_itm1-bewtp eq 'R'.
         t_pur_itm-wrbtr = t_pur_itm1-wrbtr.
       elseif t_pur_itm1-bewtp eq 'Q'.
       t_pur_itm-wrbtr = - t_pur_itm1-wrbtr.
       endif.
        t_pur_itm-wrbtr = t_pur_itm1-wrbtr.
        t_pur_itm-waers = t_pur_itm1-waers.
        t_pur_itm-belnr = t_pur_itm1-belnr.
        t_pur_itm-menge = t_pur_itm1-menge.
        t_pur_itm-buzei = t_pur_itm1-buzei.
        t_pur_itm-lfbnr = t_pur_itm1-lfbnr.
        append t_pur_itm.
      endloop.
    endloop.
    sort t_pur_itm by ebeln ebelp bewtp belnr buzei.
    loop at t_pur_itm1.
      loop at t_pur_itm2 where ebeln eq t_pur_itm1-ebeln and
                               ebelp eq t_pur_itm1-ebelp and
                               bewtp eq 'Q'.
        t_pur_itm-ebeln = t_pur_itm2-ebeln.
        t_pur_itm-ebelp = t_pur_itm2-ebelp.
        t_pur_itm-bewtp = t_pur_itm2-bewtp.
        t_pur_itm-loekz = t_pur_itm2-loekz.
        t_pur_itm-aedat = t_pur_itm2-aedat.
        t_pur_itm-matkl = t_pur_itm2-matkl.
        t_pur_itm-matnr = t_pur_itm2-matnr.
        t_pur_itm-shkzg = t_pur_itm2-shkzg.
        t_pur_itm-bwart = t_pur_itm2-bwart.
        if t_pur_itm2-bewtp eq 'R'.
          t_pur_itm-wrbtr = t_pur_itm2-wrbtr.
        elseif t_pur_itm2-bewtp eq 'Q'.
        t_pur_itm-wrbtr = - t_pur_itm2-wrbtr.
        endif.
       t_pur_itm-wrbtr = t_pur_itm2-wrbtr.
        t_pur_itm-waers = t_pur_itm2-waers.
        t_pur_itm-belnr = t_pur_itm2-belnr.
        t_pur_itm-menge = t_pur_itm2-menge.
        t_pur_itm-buzei = t_pur_itm2-buzei.
        t_pur_itm-lfbnr = t_pur_itm2-lfbnr.
        select single maktx into maktx from makt
            where matnr eq t_pur_itm2-matnr and
                  spras eq 'EN'.
        select single bewtk into bewtk from T163C
            where bewtp eq t_pur_itm2-bewtp and
                  spras eq 'EN'.
        concatenate t_pur_itm2-belnr s_gjahr into awkey.
        select single belnr into t_belnr from bkpf
          where awkey eq awkey and
                gjahr eq s_gjahr.
        concatenate t_belnr s_gjahr into t_zuonr.
        select single hkont
            into t_pur_itm2-hkont
            from bseg
            where belnr eq t_belnr and
                  gjahr eq s_gjahr and
                  zuonr eq t_zuonr.
        t_pur_itm-maktx = maktx.
        t_pur_itm-bewtk = bewtk.
        t_pur_itm-hkont = t_pur_itm2-hkont.
        append t_pur_itm.
      endloop.
    endloop.
    sort t_pur_itm by ebeln ebelp bewtp belnr buzei bwart lfbnr hkont.
    DELETE ADJACENT DUPLICATES FROM t_pur_itm.
    if s_opt = 'X'.
      loop at t_pur_itm.
        if t_pur_itm-BEWTP eq 'E'.
          move-corresponding t_pur_itm to t_pur_itmE.
          append t_pur_itmE.
          sort t_pur_itmE by ebeln ebelp bewtp belnr bwart lfbnr hkont.
        elseif t_pur_itm-BEWTP eq 'Q'.
          move-corresponding t_pur_itm to t_pur_itmQ.
          append t_pur_itmQ.
          sort t_pur_itmQ by ebeln ebelp bewtp belnr bwart lfbnr hkont.
        endif.
      endloop.

  • How to display the column into the narrative or section from pivot table

    I have a report. I have the basic number displayed in the pivot table, but missing one column and I need move one column to the top. The column missing (% of tested) should be calculated by column c /column F's last number, ie, F7=48. My desired column would be H3=c3/F48 9/48, H4=c4/F488/48.... But I could not get the number 48 into my formula, because it is the running total of the all column E. These data is in Pivot table.
    I also need display No of Students 74 in the top of the report. I am not able to get this number from pivot table. It is count distinct on student key from the repository.
    I appreciate any help.
    A     B     C     D     E     F     G
    2          # of Questions     Average # Correct     % Correct     Running total no. of test items     No of students
    3     PATTERNS, FUNCTIONS, AND ALGEBRA     9     4.68     51.95     9     74
    4     PROBABILITY AND STATISTICS     8     3.97     49.66     17     74
    5     MEASUREMENT AND GEOMETRY     11     6.11     55.53     28     74
    6     NUMBER AND NUMBER SENSE     8     4.16     52.03     36     74
    7     COMPUTATION AND ESTIMATION     12     8.2     68.36     48     74
    Edited by: user7315022 on Feb 3, 2010 2:28 PM

    I wish it was this easy. I must not explain it right. All the score from each student and each question for each subject and each test is stored in database. The number of question for the subject is the max of the questions for each subject. Basically, it needs 'parittion by'... But in the OBIEE, it would not let me add any 'partition by' in the column formula. Is this true? ie, can you use partition by in the column formula? Here are the query from trace file.
    RqList
    TEST_YEAR_SEASONS.TEST_SEASON_NAME as c1 GB,
    REPORTING_SCHOOL_YEARS.SCHOOL_YEAR as c2 GB,
    MAX_TEST_SCORE:[DAggr(STUDENT_TEST_SCORES.MAX_TEST_SCORE by [ REPORTING_SCHOOL_YEARS.SCHOOL_YEAR, TEST_YEAR_SEASONS.TEST_SEASON_NAME, STUDENT_TEST_SCORES.STDNT_STNDRD_TEST_KEY, STUDENT_TEST_SCORES.STUDENTS_KEY, RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME, RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME, TEST_SCORE_TYPES.TEST_SCORE_TYPE_NAME, SCHOOLS.SCHOOL_NAME, STUDENT_TEST_SCORES.TEST_SCORE_NUMBER] )] as c3 GB,
    STUDENT_TEST_SCORES.TEST_SCORE_NUMBER as c4 GB,
    DIVISION_TOTAL_TESTS:[DAggr(STUDENT_TEST_SCORES.DIVISION_TOTAL_TESTS by [ REPORTING_SCHOOL_YEARS.SCHOOL_YEAR, TEST_YEAR_SEASONS.TEST_SEASON_NAME, STUDENT_TEST_SCORES.STDNT_STNDRD_TEST_KEY, STUDENT_TEST_SCORES.STUDENTS_KEY, RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME, RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME, TEST_SCORE_TYPES.TEST_SCORE_TYPE_NAME, SCHOOLS.SCHOOL_NAME, STUDENT_TEST_SCORES.TEST_SCORE_NUMBER] )] as c5 GB,
    RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME as c6 GB,
    RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME as c7 GB,
    TEST_SCORE_TYPES.TEST_SCORE_TYPE_NAME as c8 GB,
    SCHOOLS.SCHOOL_NAME as c9 GB,
    SUM_TEST_SCORE:[DAggr(STUDENT_TEST_SCORES.SUM_TEST_SCORE by [ REPORTING_SCHOOL_YEARS.SCHOOL_YEAR, TEST_YEAR_SEASONS.TEST_SEASON_NAME, STUDENT_TEST_SCORES.STDNT_STNDRD_TEST_KEY, STUDENT_TEST_SCORES.STUDENTS_KEY, RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME, RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME, TEST_SCORE_TYPES.TEST_SCORE_TYPE_NAME, SCHOOLS.SCHOOL_NAME, STUDENT_TEST_SCORES.TEST_SCORE_NUMBER] )] as c10 GB,
    SUM_TEST_SCORE:[DAggr(STUDENT_TEST_SCORES.SUM_TEST_SCORE by [ REPORTING_SCHOOL_YEARS.SCHOOL_YEAR, TEST_YEAR_SEASONS.TEST_SEASON_NAME, STUDENT_TEST_SCORES.STDNT_STNDRD_TEST_KEY, STUDENT_TEST_SCORES.STUDENTS_KEY, RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME, RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME, TEST_SCORE_TYPES.TEST_SCORE_TYPE_NAME, SCHOOLS.SCHOOL_NAME, STUDENT_TEST_SCORES.TEST_SCORE_NUMBER] )] / nullif( COUNT_TEST_SCORE:[DAggr(STUDENT_TEST_SCORES.COUNT_TEST_SCORE by [ REPORTING_SCHOOL_YEARS.SCHOOL_YEAR, TEST_YEAR_SEASONS.TEST_SEASON_NAME, STUDENT_TEST_SCORES.STDNT_STNDRD_TEST_KEY, STUDENT_TEST_SCORES.STUDENTS_KEY, RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME, RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME, TEST_SCORE_TYPES.TEST_SCORE_TYPE_NAME, SCHOOLS.SCHOOL_NAME, STUDENT_TEST_SCORES.TEST_SCORE_NUMBER] )] , 0) as c11 GB,
    MAX_TEST_SCORE:[DAggr(STUDENT_TEST_SCORES.MAX_TEST_SCORE by [ REPORTING_SCHOOL_YEARS.SCHOOL_YEAR, TEST_YEAR_SEASONS.TEST_SEASON_NAME, STUDENT_TEST_SCORES.STDNT_STNDRD_TEST_KEY, STUDENT_TEST_SCORES.STUDENTS_KEY, RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME, RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME, TEST_SCORE_TYPES.TEST_SCORE_TYPE_NAME, SCHOOLS.SCHOOL_NAME, STUDENT_TEST_SCORES.TEST_SCORE_NUMBER] )] as c12 GB,
    (SUM_TEST_SCORE:[DAggr(STUDENT_TEST_SCORES.SUM_TEST_SCORE by [ REPORTING_SCHOOL_YEARS.SCHOOL_YEAR, TEST_YEAR_SEASONS.TEST_SEASON_NAME, STUDENT_TEST_SCORES.STDNT_STNDRD_TEST_KEY, STUDENT_TEST_SCORES.STUDENTS_KEY, RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME, RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME, TEST_SCORE_TYPES.TEST_SCORE_TYPE_NAME, SCHOOLS.SCHOOL_NAME, STUDENT_TEST_SCORES.TEST_SCORE_NUMBER] )] / nullif( COUNT_TEST_SCORE:[DAggr(STUDENT_TEST_SCORES.COUNT_TEST_SCORE by [ REPORTING_SCHOOL_YEARS.SCHOOL_YEAR, TEST_YEAR_SEASONS.TEST_SEASON_NAME, STUDENT_TEST_SCORES.STDNT_STNDRD_TEST_KEY, STUDENT_TEST_SCORES.STUDENTS_KEY, RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME, RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME, TEST_SCORE_TYPES.TEST_SCORE_TYPE_NAME, SCHOOLS.SCHOOL_NAME, STUDENT_TEST_SCORES.TEST_SCORE_NUMBER] )] , 0)) / nullif( MAX_TEST_SCORE:[DAggr(STUDENT_TEST_SCORES.MAX_TEST_SCORE by [ REPORTING_SCHOOL_YEARS.SCHOOL_YEAR, TEST_YEAR_SEASONS.TEST_SEASON_NAME, STUDENT_TEST_SCORES.STDNT_STNDRD_TEST_KEY, STUDENT_TEST_SCORES.STUDENTS_KEY, RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME, RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME, TEST_SCORE_TYPES.TEST_SCORE_TYPE_NAME, SCHOOLS.SCHOOL_NAME, STUDENT_TEST_SCORES.TEST_SCORE_NUMBER] )] , 0) * 100 as c13 GB,
    STUDENT_TEST_SCORES.STDNT_STNDRD_TEST_KEY as c14 GB,
    STUDENT_TEST_SCORES.STUDENTS_KEY as c15 GB,
    max(SUM_TEST_SCORE:[DAggr(STUDENT_TEST_SCORES.SUM_TEST_SCORE by [ REPORTING_SCHOOL_YEARS.SCHOOL_YEAR, TEST_YEAR_SEASONS.TEST_SEASON_NAME, RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME, RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME, SCHOOLS.SCHOOL_NAME] )] by [ REPORTING_SCHOOL_YEARS.SCHOOL_YEAR, TEST_YEAR_SEASONS.TEST_SEASON_NAME, RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME, RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME, SCHOOLS.SCHOOL_NAME] at_distinct [ ] ) / nullif( max(COUNT_TEST_SCORE:[DAggr(STUDENT_TEST_SCORES.COUNT_TEST_SCORE by [ REPORTING_SCHOOL_YEARS.SCHOOL_YEAR, TEST_YEAR_SEASONS.TEST_SEASON_NAME, RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME, RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME, SCHOOLS.SCHOOL_NAME] )] by [ REPORTING_SCHOOL_YEARS.SCHOOL_YEAR, TEST_YEAR_SEASONS.TEST_SEASON_NAME, RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME, RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME, SCHOOLS.SCHOOL_NAME] at_distinct [ ] ) , 0) as c16 GB,
    (max(SUM_TEST_SCORE:[DAggr(STUDENT_TEST_SCORES.SUM_TEST_SCORE by [ REPORTING_SCHOOL_YEARS.SCHOOL_YEAR, TEST_YEAR_SEASONS.TEST_SEASON_NAME, RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME, RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME, SCHOOLS.SCHOOL_NAME] )] by [ REPORTING_SCHOOL_YEARS.SCHOOL_YEAR, TEST_YEAR_SEASONS.TEST_SEASON_NAME, RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME, RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME, SCHOOLS.SCHOOL_NAME] at_distinct [ ] ) / nullif( max(COUNT_TEST_SCORE:[DAggr(STUDENT_TEST_SCORES.COUNT_TEST_SCORE by [ REPORTING_SCHOOL_YEARS.SCHOOL_YEAR, TEST_YEAR_SEASONS.TEST_SEASON_NAME, RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME, RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME, SCHOOLS.SCHOOL_NAME] )] by [ REPORTING_SCHOOL_YEARS.SCHOOL_YEAR, TEST_YEAR_SEASONS.TEST_SEASON_NAME, RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME, RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME, SCHOOLS.SCHOOL_NAME] at_distinct [ ] ) , 0)) / nullif( max(MAX_TEST_SCORE:[DAggr(STUDENT_TEST_SCORES.MAX_TEST_SCORE by [ REPORTING_SCHOOL_YEARS.SCHOOL_YEAR, TEST_YEAR_SEASONS.TEST_SEASON_NAME, RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME, RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME, SCHOOLS.SCHOOL_NAME] )] by [ REPORTING_SCHOOL_YEARS.SCHOOL_YEAR, TEST_YEAR_SEASONS.TEST_SEASON_NAME, RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME, RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME, SCHOOLS.SCHOOL_NAME] at_distinct [ ] ) , 0) * 100 as c17 GB
    DetailFilter: RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME = 'GRADE 5' and SCHOOLS.SCHOOL_NAME = 'GLASGOW MIDDLE' and TEST_SCORE_TYPES.TEST_SCORE_TYPE_NAME = 'RAW SCORE' and TEST_YEAR_SEASONS.TEST_SEASON_NAME = 'SPRING' and REPORTING_SCHOOL_YEARS.SCHOOL_YEAR = '200102' and TESTS.TEST_ID = 'SOL' and TEST_DEFINITIONS.PARENT_TEST_SUBJECT_NAME = 'MATHEMATICS' and STUDENT_TEST_SCORES.TEST_SCORE_NUMBER < 900
    OrderBy: c1 asc, c2 asc, c4 asc, c6 asc, c7 asc, c8 asc, c9 asc, c14 asc, c15 asc
    +++azadams:320000:32001b:----2010/02/03 16:48:36
    -------------------- Sending query to database named tacdev (id: <<51109>>):
    select distinct D1.c5 as c1,
    D1.c4 as c2,
    D1.c9 as c3,
    D1.c14 as c4,
    D1.c12 as c5,
    D1.c6 as c6,
    D1.c7 as c7,
    D1.c15 as c8,
    D1.c8 as c9,
    D1.c11 as c10,
    D1.c11 / decode(D1.c10 , 0 , to_number(null), D1.c10) as c11,
    D1.c9 as c12,
    (D1.c11 / decode(D1.c10 , 0 , to_number(null), D1.c10)) / decode(D1.c9 , 0 , to_number(null), D1.c9) * 100 as c13,
    D1.c13 as c14,
    D1.c16 as c15,
    D1.c3 / decode(D1.c2 , 0 , to_number(null), D1.c2) as c16,
    (D1.c3 / decode(D1.c2 , 0 , to_number(null), D1.c2)) / decode(D1.c1 , 0 , to_number(null), D1.c1) * 100 as c17
    from
    (select max(D1.c1) over (partition by D1.c4, D1.c5, D1.c6, D1.c7, D1.c8) as c1,
    sum(D1.c2) over (partition by D1.c4, D1.c5, D1.c6, D1.c7, D1.c8) as c2,
    sum(D1.c3) over (partition by D1.c4, D1.c5, D1.c6, D1.c7, D1.c8) as c3,
    D1.c4 as c4,
    D1.c5 as c5,
    D1.c6 as c6,
    D1.c7 as c7,
    D1.c8 as c8,
    max(D1.c1) over (partition by D1.c4, D1.c16, D1.c5, D1.c13, D1.c6, D1.c7, D1.c15, D1.c8) as c9,
    sum(D1.c2) over (partition by D1.c4, D1.c16, D1.c5, D1.c13, D1.c6, D1.c7, D1.c15, D1.c8) as c10,
    sum(D1.c3) over (partition by D1.c4, D1.c16, D1.c5, D1.c13, D1.c6, D1.c7, D1.c15, D1.c8) as c11,
    sum(D1.c12) over (partition by D1.c4, D1.c16, D1.c5, D1.c13, D1.c6, D1.c7, D1.c15, D1.c8) as c12,
    D1.c13 as c13,
    D1.c14 as c14,
    D1.c15 as c15,
    D1.c16 as c16
    from
    (select max(T56699.TEST_SCORE_NUMBER) as c1,
    count(T56699.TEST_SCORE_NUMBER) as c2,
    sum(T56699.TEST_SCORE_NUMBER) as c3,
    T33435.SCHOOL_YEAR as c4,
    T34232.TEST_SEASON_NAME as c5,
    T52429.TEST_SUBJECT_NAME as c6,
    T52429.TEST_LEVEL_NAME as c7,
    T59709.SCHOOL_NAME as c8,
    count(T36922.STDNT_STNDRD_TEST_KEY) as c12,
    T36922.STDNT_STNDRD_TEST_KEY as c13,
    T56699.TEST_SCORE_NUMBER as c14,
    T56693.TEST_SCORE_TYPE_NAME as c15,
    T36922.STUDENTS_KEY as c16
    from
    SCHOOLS T59709,
    TEST_DEFINITIONS T58733,
    TEST_SCORE_TYPES T56693,
    RPT_TEST_DEFINITIONS T52429,
    TEST_YEAR_SEASONS T34232,
    REPORTING_SCHOOL_YEARS T33435,
    TESTS T34149,
    DETAIL_TEST_SCORES T33341,
    STUDENT_STANDARD_TEST T36922,
    TEST_SCORES T56699
    where ( T33341.TEST_SCORE_TYPES_KEY = T56693.TEST_SCORE_TYPES_KEY and T36922.ADMIN_SCHOOLS_KEY = T59709.SCHOOLS_KEY and T34232.TEST_YEAR_SEASONS_KEY = T36922.TEST_YEAR_SEASONS_KEY and T33435.REPORTING_SCHOOL_YEARS_KEY = T36922.REPORTING_SCHOOL_YEARS_KEY and T34149.TESTS_KEY = T36922.TESTS_KEY and T36922.TEST_DEFINITIONS_KEY = T58733.TEST_DEFINITIONS_KEY and T33341.STDNT_STNDRD_TEST_KEY = T36922.STDNT_STNDRD_TEST_KEY and T33341.TEST_SCORES_KEY = T56699.TEST_SCORES_KEY and T33435.SCHOOL_YEAR = '200102' and T34149.TEST_ID = 'SOL' and T34232.TEST_SEASON_NAME = 'SPRING' and T36922.RPT_TEST_DEFINITIONS_KEY = T52429.RPT_TEST_DEFINITIONS_KEY and T52429.TEST_LEVEL_NAME = 'GRADE 5' and T56693.TEST_SCORE_TYPE_NAME = 'RAW SCORE' and T58733.PARENT_TEST_SUBJECT_NAME = 'MATHEMATICS' and T59709.SCHOOL_NAME = 'GLASGOW MIDDLE' and T56699.TEST_SCORE_NUMBER < 900 )
    group by T33435.SCHOOL_YEAR, T34232.TEST_SEASON_NAME, T36922.STDNT_STNDRD_TEST_KEY, T36922.STUDENTS_KEY, T52429.TEST_SUBJECT_NAME, T52429.TEST_LEVEL_NAME, T56693.TEST_SCORE_TYPE_NAME, T56699.TEST_SCORE_NUMBER, T59709.SCHOOL_NAME
    ) D1
    ) D1

Maybe you are looking for