Duplication in SELECT query with XML column

Oracle 11gR1 RHEL 5
Hi all,
I am having a small problem. I am selecting some rows from an XML column with the following query and for each row I get a new set of columns that are displayed.
select extractvalue(old_row,'/xml/WORK_ITEM_RID') WORK_ITEM_RID,
extractvalue(old_row,'/xml/PARENT_RID') PARENT_RID,
extractvalue(old_row,'/xml/ASSIGNED_TO') ASSIGNED_TO
from audit_trail
where audit_trail_rid = 177147;
So instead of getting this:
WORK_ITEM_RID PARENT_RID ASSIGNED_TO
4045 4044 2930
I get:
WORK_ITEM_RID PARENT_RID ASSIGNED_TO
4045
WORK_ITEM_RID PARENT_RID ASSIGNED_TO
4044
WORK_ITEM_RID PARENT_RID ASSIGNED_TO
2930
How can I get rid of this?
Thanks.
Edited by: JrOraDBA on Feb 12, 2010 10:14 AM

Here is what I got so far...but it keeps telling me that I am missing right parenthesis (ORA-00907) at the assigned_date TO_CHAR(....
insert into iswrnew.WORK_ITEM (WORK_ITEM_RID, PARENT_RID, ASSIGNED_TO, WORK_ITEM_TYPE_RID, FPRC_APPLICATION_RID, REQUEST_RID, ASSIGNED_DATE, EST_START_DATE, EST_COMPLETION_DATE, SHORT_DESCRIPTION, ASSIGNED_BY, COMPLETED, COMPLETION_DATE, LONG_DESCRIPTION)
SELECT t1.work_item_rid, t1.parent_rid, t1.assigned_to, t1.work_item_type_rid, t1.fprc_application_rid, t1.request_rid, t1.assigned_date, t1.est_start_date, t1.est_completion_date, t1.short_description, t1.assigned_by, t1.completed, t1.completion_date, t1.long_description
  FROM fprchr.audit_trail,
       XMLTable('/xml'
                PASSING fprchr.audit_trail.old_row
                COLUMNS
                work_item_rid                  NUMBER PATH 'WORK_ITEM_RID',
                parent_rid                     NUMBER PATH 'PARENT_RID',
                assigned_to                 NUMBER PATH 'ASSIGNED_TO',
                work_item_type_rid            NUMBER PATH 'WORK_ITEM_TYPE_RID',
                fprc_application_rid        NUMBER PATH 'FPRC_APPLICATION_RID',
                request_rid                    NUMBER PATH    'REQUEST_RID',
                *assigned_date                TO_CHAR(assigned_date,'YYYY-MM-DD HH24:MI:SS') PATH    'ASSIGNED_DATE',*
                est_start_date                TO_CHAR(est_start_date,'YYYY-MM-DD HH24:MI:SS') PATH    'EST_START_DATE',
                est_completion_date          TO_CHAR(est_completion_date,'YYYY-MM-DD HH24:MI:SS') PATH    'EST_COMPLETION_DATE',
                short_description            VARCHAR2(50) PATH 'SHORT_DESCRIPTION',
                assigned_by                    NUMBER PATH    'ASSIGNED_BY',
                completed                    VARCHAR2(1) PATH 'COMPLETED',
                completion_date                TO_CHAR(completion_date,'YYYY-MM-DD HH24:MI:SS') PATH 'COMPLETION_DATE',
                long_description            VARCHAR2(4000) PATH 'LONG_DESCRIPTION') t1
WHERE audit_trail_rid = 177147;I think I'm missing something obvious but I just cannot see it. I need a fresh pair of eyes to look at this :)
Thanks for all your help

Similar Messages

  • ADF BC : "Attributes selected in query with no column type found! ..."

    hi
    Using JDeveloper 10.1.3.3.0, I have this "Selected in Query" attribute, "Never" updatable, in my Entity Object.
    The Entity Object is based on the SCOTT.EMP table and the attribute, called "BonusInfo", is defined using the expression " '[bonus info ' || (SAL * 2) || ']' ".
    see http://verveja.footsteps.be/~verveja/files/oracle/NoColumnTypeFoundApp-v0.01.zip
    While creating this Entity Object, I got a "Business Components" dialog that says:
    "Column type is not specified for this attribute. Specifying column-type and precision results in better query performance at runtime. Do you wish to set column type to VARCHAR2(255)?"
    I clicked "Yes".
    I also created two View Objects based on this Entity Object.
    In the "Create View Object" wizard "Step 4 of 7: Attribute Settings" I got a "Business Components" diaglog that says:
    "Attributes selected in query with no column type found! Specifying column-type and precision results in better query performance at runtime. Do you wish to set default column type for these attributes?"
    I clicked "Yes".
    Testing the query in "Step 5 of 7: SQL Statement" showed "Query is valid.".
    question:
    Why do I keep getting the message ...
    "Attributes selected in query with no column type found! Specifying column-type and precision results in better query performance at runtime. Do you wish to set default column type for these attributes?"
    ... in the View Object Editor if I click on different attributes?
    (I don't get such a message the first time I click on an attribute after opening the View Object Editor, but after that it keeps popping up each time I click on a different attribute, no matter what I answer "Yes", "No" or "Cancel".)
    many thanks
    Jan Vervecken

    Jan,
    BC needs the column type and precision so that we can allocate the correct JDBC buffer size; otherwise we would just allocate 2k per string.
    Blaise

  • Attributes selected in query with no column type found! (solved)

    Dear JHeadstart Team,
    In the view object Editor I have two entity based attributes attrib1 and attrib2
    both with type Number. Both have aliases with type number(9,0)
    If attrib1 is null I want to have the value of attrib2.
    In the expression box I put: nvl(attrib1,attrib2)
    When I press the ok button I get the next error message.
    "Attributes selected in query with no column type found!
    Specifying column-type and precision results in better query performance at runtime.
    Do you wish to set default column type for these attributes? "
    When I say ok I get the next message:
    "An error occurred. Unable to apply all the wizard changes.
    Column type cannot be changed for Entity based attribute.
    Exception: oracle.jbo.dt.objects.JboExeption."
    The details button serves no extra information.
    Since both the attributes have the same type I thought the nvl commando should work.
    But what does the "no column type found" sentence mean?
    regards,
    Marcel.
    Message was edited by:
    user571204

    Thanks Jan,
    You've put me on the right track.
    I found out that this is only possible in the entity object class.
    So I have to check my limited java skills.

  • Issue in select query with where clause

    Hi guys,
    I'm facing an issue while using select query with the where clause. When I'm selecting all the data from the table it returns the correct result. But when I'm using the where clause to get the specific rows from the table it returns no rows. But the data I'm trying to fetch using the where condition exists in the table.
    Here is my query which causing the issue,
    select * from mytable where myfield = 'myvalue'
    But if I use the following query it returns the result correctly.
    select * from mytable
    Also the myfield value 'myvalue' exists in the table.
    I have tried by running this query in both SQL Developer and SQL Plus. I have tried this query in mssql as well. It works perfectly and returns correct result sets for both the queries I have mentioned above. I'm unable to predict the issue as I'm new to ORACLE. Please help.
    Thanks,
    Ram.

    Hi Ram,
    I experienced an issue similar to this with a varchar2 field. Some of our records had a hidden newline character at the end of them, which was making queries like the one below fail:
    select * from employees
    where email = '[email protected]'The best way I found to detect this was to use
    select 'XX'||email||'XX' from employeesTo make sure that there were no newlines. But that is just a guess. If you could provide some example table data and the outputs of your selects, it would be helpful.
    Jeff

  • How to write XSJS Select Query with input parameters

    Hello Experts,
    I am creating a xsjs file and in that file I am trying to write a Select Query based on a Calculation View
    I have tried it the following way:
    var query = 'SELECT TOP 100 \"Name\", \"Address\", \"City\", \"Country\" FROM \"_SYS_BIC\".\"Test.HL/AddressView\"'
        + 'WITH PARAMETERS(\'PLACEHOLDER\' = (\'$$P_Name$$\', \' Akhil \'),'
      + '\'PLACEHOLDER\' = (\'$$P_City$$\', \' Lucknow \'))';
    But it gives me the "Mixed spaces and tabs error".
    How should I write XSJS Select Query with input parameters?
    Regards,
    Rohit

    >But it gives me the "Mixed spaces and tabs error".
    Mixed spaces and tabs has nothing to do with the syntax of the statement. You used both spaces and the tab in the content - which JSLint doesn't like.  Remove the beginning spaces of each line and use only one or the other.
    The actual syntax of your statement doesn't look right.  The problem is that you are escaping the \ when you don't need to if you are using ' instead of " for your string.  You escape with \" in the first line but then escape with \' in the 2nd and 3rd line.  That is going to cause serious parsing problems with the command.

  • Creating Query with dynamic columns to show results

    Hi experts,
    I need to know how to create a query with dynamic columns. Meaning, I don't want to create a query with fixed columns representing the 12 periods of the fiscal year to show me actuals as the fiscal year proceeds.
    For example, if I am currently in the middle of period 3 (March) of a fiscal year, when I execute the query, I need it to automatically only show me the 'Actuals' for periods 1 and 2, without seeing the columns from periods 3 to 12 showing blank.
    Then when I am in the middle period 5 (May) the query should ONLY show me the columns for periods 1 to 4 'Actuals', no results should be shown for periods 5 to 12 yet, and I don't want to even see blank columns for period 6 to 12.
    How do I define my columns, to achieve this.
    Maximum points will be awarded.
    Thanks Everyone.

    Hi Josh,
    I'm having a little difficuluty understanding what should be included in my restricted key figures.
    The time characteristics that I have available to use are:
    0FISCPER3 (posting period)
    0FISCYEAR (fiscal year), currently using SAP EXIT to default current fiscal year.
    0FISCVARNT (fiscal year variant).
    In addition, I have the following characteristics available to be used in the columns:
    Value type (10)
    version (currently I'm using variable for it)
    Currency type (020)
    Currency (USD).
    Can you explain what my restricted key figure should be based on and how it should look.
    I tried to create a restircted key figure using 0AMOUNT, and 0FISCPER3. For 0FISCPER3  I created a range from 1 to previous period (using SAP EXIT that supplied previous period).I also had value type, version, currency type, and currency included in that restricted key figure.Then when I tried to drag 0FISCPER3 under the restricted key figure once again, it wouldn't let me, probably because I've already used 0FISCPER3 in the restricted key figure.
    Please let me know if my explanation is not clear.
    Your step by step help would be great.
    Thanks
    Edited by: Ehab Mansour on Sep 23, 2008 2:40 PM

  • Absolute dynamic select query with dynamic join and where

    Has anyone ever tried creating an absolutely dynamic SELECT query with dynamic Join and Where conditions.
    I have a requirement of creating such a query in an Utility Class, and i have written the code. But its throwing my sysntax errors.
    Please let me know where am I going wrong OR is it really possible to create such a dynamic Query??
        SELECT (FIELDS) INTO TABLE IT_TABLES
          FROM ( (ME->TABLE1)  inner join ( me->table2 )
          on ( on_condition ) )
          WHERE (me->where_fields).
    Ags.

    It worked for me in a following way:
    select * into corresponding fields of table <result_table>
            from (join_string)
            where (l_where).
    Where the contents of join_string were dynamically build using concatenation. So it will be something like
    concatenate ME->TABLE1 'as a INNER JOIN' me->table2 'as b ON (' into join_string separated by space.
    <...>
    add here matching/reference colums, something like
    concatenate 'a~' me->TABLE1_JOIN_COL into temp1.
    concatenate 'b~' me->TABLE2_JOIN_COL into temp2.
    concatenate join_string temp1 '=' temp2 into join_string separated by space.
    <...>
    concatenate join_string ')' into join_string separated by space.
    And then use similar approach for l_where variable.

  • Dynamic select query with dynamic where condition

    Hi all,
    I want to use the dynamic select query with dynamic where condition. For that I used the below code but I am getting dump when using this code.
    Please advice, if there is any other way to achieve this requirement.
    Thanks,
    Sanket Sethi
    Code***************
    PARAMETERS: p_tabnam      TYPE tabname,
                p_selfl1      TYPE edpline,
                p_value       TYPE edpline,
                p_where1      TYPE edpline .
    DATA: lt_where    TYPE TABLE OF edpline,
          lt_sel_list TYPE TABLE OF edpline,
          l_wa_name   TYPE string,
          ls_where    TYPE edpline,
          l_having    TYPE string,
          dref        TYPE REF TO data,
          itab_type   TYPE REF TO cl_abap_tabledescr,
          struct_type TYPE REF TO cl_abap_structdescr,
          elem_type   TYPE REF TO cl_abap_elemdescr,
          comp_tab    TYPE cl_abap_structdescr=>component_table,
          comp_fld    TYPE cl_abap_structdescr=>component.
    TYPES: f_count TYPE i.
    FIELD-SYMBOLS : <lt_outtab> TYPE ANY TABLE,
    *                <ls_outtab> TYPE ANY,
                    <l_fld> TYPE ANY.
    struct_type ?= cl_abap_typedescr=>describe_by_name( p_tabnam ).
    elem_type   ?= cl_abap_elemdescr=>describe_by_name( 'F_COUNT' ).
    comp_tab = struct_type->get_components( ).
    comp_fld-name = 'F_COUNT'.
    comp_fld-type = elem_type.
    APPEND comp_fld TO comp_tab.
    struct_type = cl_abap_structdescr=>create( comp_tab ).
    itab_type   = cl_abap_tabledescr=>create( struct_type ).
    l_wa_name = 'l_WA'.
    CREATE DATA dref TYPE HANDLE itab_type.
    ASSIGN dref->* TO <lt_outtab>.
    *CREATE DATA dref TYPE HANDLE struct_type.
    *ASSIGN dref->* TO <ls_outtab>.
    * Creation of the selection fields
    APPEND p_selfl1 TO lt_sel_list.
    APPEND 'COUNT(*) AS F_COUNT' TO lt_sel_list.
    ** Creation of the "where" clause
    *CONCATENATE p_selfl1 '= '' p_value ''.'
    *            INTO ls_where
    *            SEPARATED BY space.
    *APPEND ls_where TO lt_where.
    * Creation of the "where" clause
    APPEND p_where1 TO lt_where.
    * Creation of the "having" clause
    l_having = 'count(*) >= 1'.
    * THE dynamic select
    SELECT          (lt_sel_list)
           FROM     (p_tabnam)
           INTO CORRESPONDING FIELDS OF TABLE <lt_outtab>.
    *       WHERE    (lt_where).

    Hi Sanket,
    The above given logic of mine works for you, put the code in the If condition and try-
    just like below:
    IF NOT P_EBELN IS INITIAL.
    lt_where = '& = ''&'' '.
    REPLACE '&' WITH p_ebeln INTO lt_where.
    REPLACE '&' WITH field_value INTO lt_where.
    SELECT (lt_sel_list) INTO CORRESPONDING FIELDS OF TABLE <lt_outtab>
    FROM (p_tabnam)
    WHERE (lt_where).
    ENDIF.
    thanks\
    Mahesh

  • BDC select query with addition based on all If conditions

    Hi can any one send me the select query with conditions like
    If Itab is not initial.
    Endif. and if possible with valiadations messages also.
    IF CHECK_NUMBER of CHECK_ADVICE of the flat file = PAYR-CHECT. Then update SAP field BSEG-XREF2 .
    9.     When Flat file check Number = PAYR-CHECT then Insert or Update Flat file RECEIPT_DATE into SAP field BSEG-XREF1.
    Please send me immediately.

    >     SELECT rsnum
    >            rspos
    >            matnr
    >            werks
    >         lgort
    >            shkzg
    >            aufnr
    >            bdmng
    >            enmng                      
    >            FROM  resb INTO  TABLE it_rsnum FOR ALL ENTRIES IN it_aufnr
    >            WHERE rsnum EQ it_aufnr-rsnum
    >            AND   xloek NE 'X'
    >            AND   postp NE 'X'
    >            AND   resbbdmng GE resbenmng.
    >   ENDIF.
    >
    > Database Table RESB: 40,000,000 Records (40 Million)
    > Internal Table   it_aufnr:  20,000 Entries
    > Entries selected from RESB: 150,000.
    >
    Hi,
    the problem is the big for all entries table.
    Your 20.000 records FAE will be split into SEVERAL sql statements depending on the size of the table.
    Where do you get the it_auftrn from?
    If it's another transparent table try to JOIN this table to your big table.
    SELECT rsnum
                rspos
                matnr
                werks
            lgort
                shkzg
                aufnr
                bdmng
                enmng                      
                FROM  resb JOIN tab_auftrn  on  resbrsnum = tab_auftrnauftrn
                AND   xloek NE 'X'
                AND   postp NE 'X'
                AND   resbbdmng GE resbenmng.
    Make sure that your WHERE filter and the JOIN keys on both tables are supported by indexes.
    150.000 records about of 40 Mio. can definitly be serviced by an appropriate index:
    i.e. Index fields (check your PK or secondary indexes):
    rsnum
    enmng                      
    aufnr
    bye
    yk

  • I need to add a single field from with_item table . need to write select query with reference to company code , account doc no , fiscal year

    I need to add a single field from with_item table . need to write select query with reference to company code , account doc no , fiscal year

    Hi Arun ,
    Can you explain little bit more ??
    what is account doc no? 
    what are the transactions should be displayed in your output??
    -Rajesh N

  • Creating Select List with multiple columns

    I want to create a select list with multiple columns. I followed the demo application model described in the by Denes Kubicek (Currently my reference for APEX !!)
    The code is as follows:
    CREATE OR REPLACE FUNCTION getcrops(p_cropid IN NUMBER)
    RETURN VARCHAR2
    IS
    v_cropid VARCHAR2 (400);
    v_fcode VARCHAR2 (400);
    v_product VARCHAR2 (400);
    v_var VARCHAR2 (400);
    v_fname VARCHAR2 (400);
    v_acres VARCHAR2 (400);
    v_style_start VARCHAR2 (400);
    v_style_end VARCHAR2 (400);
    v_return VARCHAR2 (400);
    BEGIN
    FOR c IN (select "CROP"."CROPID" as "CROP ID",
         "CROP"."FIELDCODE" as "FIELD CODE",
         "CARROTPRODUCTLIST"."CARROTPRODUCTNAME" as "PRODUCT",
         "VARIETYLIST"."VARIETYNAME" as "VARIETY",
         "FIELD"."FIELDNAME" as "FIELD NAME",
         "CROP"."SIZEINACRES" as "ACRES"
    from     "FIELD" "FIELD",
         "CARROTPRODUCTLIST" "CARROTPRODUCTLIST",
         "VARIETYLIST" "VARIETYLIST",
         "CROP" "CROP"
    where "CROP"."CARROTPRODUCTTYPE"="CARROTPRODUCTLIST"."CARROTPRODUCTID"
    and     "CROP"."VARIETYID"="VARIETYLIST"."VARIETYLISTID"
    and     "CROP"."FIELDID"="FIELD"."FIELDID")
    LOOP
    v_cropid := TO_CHAR (c.'CROP ID', 'FML999G999G999G999G990');
    v_fcode := c.'FIELD CODE';
    v_product := c.'PRODUCT';
    v_var := c.'VARIETY';
    v_fname :=c.'FIELD NAME';
    v_acres :=c.'ACRES';
    FOR i IN 1 .. 12 - LENGTH (c."CROP ID")
    LOOP
    v_cropid := v_cropid || ' ';
    END LOOP;
    FOR i IN 1 .. 12 - LENGTH (c.'FIELD CODE')
    LOOP
    v_fcode := v_fcode || ' ';
    END LOOP;
    FOR i IN 1 .. 12 - LENGTH (c.'PRODUCT')
    LOOP
    v_product := v_product || ' ';
    END LOOP;
    FOR i IN 1 .. 12 - LENGTH (c.'VARIETY')
    LOOP
    v_var := v_var || ' ';
    END LOOP;
    FOR i IN 1 .. 12 - LENGTH (c.'FIELD NAME')
    LOOP
    v_fname := v_fname || ' ';
    END LOOP;
    FOR i IN 1 .. 12 - LENGTH (c.'ACRES')
    LOOP
    v_acres := v_acres || ' ';
    END LOOP;
    v_return := v_cropid || v_fcode || v_product || v_var || v_fname || v_acres;
    END LOOP;
    RETURN v_return;
    END;
    I created this anonymous Pl/SQL function at a application level ..Then I followed up to create a select list with a function inside. However I could not create select list with the command suggested in the demo which is
    select getcrops(cropid) d, cropid r from crop;
    APEX (2.1) returns a error message. What am I missing ? Should the function be called from somewhere else after creating a regular select list..? Where the functions (Pl/SQL) should be ideally stored for application level access..? and for across application level access ? How can I check the function works good. Help is appreciated.

    Still really one column.
    If they need to be independent then you've got to have three selection lists.
    %

  • Selection list with multiple columns

    How can i create a selection list with multiple columns?

    Still really one column.
    If they need to be independent then you've got to have three selection lists.
    %

  • Select list with multiple columns

    I want to create a select list with multiple column option. What are the options. Any developments in apex 3.0.1 ? Thanks in advance. I tried the tutorials by Kubicek.
    I am kind of stuck to see the function entry inside LOV definition returns a error.

    Still really one column.
    If they need to be independent then you've got to have three selection lists.
    %

  • How to re-write this big SELECT Query with INNER JOINs?

    Hi Experts
    I have a performance killer SELECT query with an inner join of 3 tables u2013 VBAP, VBAK and VBEP together, which populates records to an internal table INT_COLL_ORD. Based on these records selected, in another SELECT query, records are fetched from VBUK table to the internal table INT_VBUK.
    SELECT A~VBELN A~POSNR A~MATNR A~KWMENG A~KBMENG A~ERDAT A~ERZET A~PSTYV D~AUART E~ETTYP E~EDATU
    INTO TABLE INT_TAB_RES
    FROM VBAP AS A INNER JOIN VBAK AS D
    ON D~VBELN EQ A~VBELN AND D~MANDT EQ A~MANDT
    INNER JOIN VBEP AS E
    ON E~VBELN EQ A~VBELN AND E~POSNR EQ A~POSNR AND E~MANDT EQ A~MANDT
    WHERE  A~VBELN IN s_VBELN AND
           D~auart in s_auart AND
           D~vkorg in s_vkorg AND
           D~vbtyp eq 'C'     AND
           ( ( matnr LIKE c_prefix_sp AND zz_msposnr NE 0 AND kbmeng EQ 0 )
           OR ( matnr LIKE c_prefix_fp AND kwmeng NE A~kbmeng ) ) AND
           A~ABGRU EQ SPACE AND
           A~MTVFP IN R_MTVFP AND
           A~PRCTR IN R_PRCT AND
           E~ETENR EQ '1'.
    SORT INT_COLL_ORD BY VBELN POSNR ETTYP.
    DELETE ADJACENT DUPLICATES FROM INT_TAB_RES COMPARING VBELN POSNR.
    CHECK NOT INT_TAB_RES [] IS INITIAL.
    SELECT VBELN UVALL CMGST INTO TABLE INT_VBUK
    FROM VBUK FOR ALL ENTRIES IN INT_TAB_RES
    WHERE VBELN = INT_TAB_RES-VBELN AND UVALL NE 'A'.
    Now, the requirement is:
    I want to split this query. Like, first join VBAK and VBUK first. With this selection, go to the inner join of VBAP and VBEP (on key VBELN) to get the results. How can I re-write this Query?
    Please help.
    Thx n Rgds

    Hi Nagraj
    As of your suggestion, I have re-written the query as below:
    * Declarations
    TYPES: BEGIN OF TYP_COLL_ORD,
            VBELN  LIKE VBAK-VBELN,
            POSNR  LIKE VBUP-POSNR,
            MATNR  LIKE VBAP-MATNR,
            KWMENG LIKE VBAP-KWMENG,
            KBMENG LIKE VBAP-KBMENG,
            ERDAT  LIKE VBAK-ERDAT,
            ERZET  LIKE VBAK-ERZET,
            PSTYV  LIKE VBAP-PSTYV,
            AUART  LIKE VBAK-AUART, u201Calready exists in type
            ETTYP  LIKE VBEP-ETTYP,
            EDATU  LIKE VBEP-EDATU.
    TYPES: END OF TYP_COLL_ORD.
    DATA: INT_COLL_ORD TYPE TABLE OF TYP_COLL_ORD WITH HEADER LINE.
    TYPES: BEGIN OF TYP_VBUK,
            AUART  LIKE VBAK-AUART, u201Chave added this field
            VBELN  LIKE VBUK-VBELN,
            UVALL  LIKE VBUK-UVALL,
            CMGST  LIKE VBUK-CMGST.
    TYPES: END OF TYP_VBUK.
    DATA: INT_VBUK TYPE TABLE OF TYP_VBUK WITH HEADER LINE.
    *QUERY#1 u2013 for VBAK & VBUK Join
    SELECT A~AUART B~VBELN B~UVALL B~CMGST
    INTO TABLE INT_VBUK
    FROM VBAK AS A INNER JOIN VBUK AS B
    ON A~VBELN EQ B~VBELN
    WHERE A~VBELN IN s_VBELN AND
    A~auart in s_auart AND
    A~vkorg in s_vkorg AND
    A~vbtyp eq 'C' AND
    B~UVALL NE 'A'.
    IF NOT INT_VBUK[] IS INITIAL.
    SORT INT_VBUK BY VBELN.
    DELETE ADJACENT DUPLICATES FROM INT_VBUK COMPARING VBELN.
    *QUERY#2 u2013 for VBAP & VBEP Join
    SELECT A~VBELN A~POSNR A~MATNR A~KWMENG A~KBMENG A~ERDAT A~ERZET A~PSTYV B~ETTYP B~EDATU
    INTO TABLE INT_COLL_ORD
    FROM VBAP AS A INNER JOIN VBEP AS B
    ON B~VBELN EQ A~VBELN AND B~POSNR EQ A~POSNR AND B~MANDT EQ A~MANDT
    FOR ALL ENTRIES IN INT_VBUK
    WHERE A~VBELN = INT_VBUK-VBELN AND
    ( ( matnr LIKE c_prefix_sp AND zz_msposnr NE 0 AND kbmeng EQ 0 )
    OR ( matnr LIKE c_prefix_fp AND kwmeng NE A~kbmeng ) ) AND
    A~ABGRU EQ SPACE AND
    A~MTVFP IN R_MTVFP AND
    A~PRCTR IN R_PRCT AND
    B~ETENR EQ '1'.
    ENDIF.
      SORT INT_COLL_ORD BY  VBELN POSNR ETTYP.
      DELETE ADJACENT DUPLICATES FROM INT_COLL_ORD
        COMPARING VBELN POSNR.
      CHECK NOT INT_COLL_ORD[] IS INITIAL.
      LOOP AT INT_COLL_ORD.
        CLEAR: L_MTART,L_ATPPR,L_ETTYP.
        IF L_PREVIOUS_ETTYP NE INT_COLL_ORD-ETTYP OR
          L_PREVIOUS_AUART NE INT_COLL_ORD-AUART.
          READ TABLE INT_OVRCTL WITH KEY AUART = INT_COLL_ORD-AUART ETTYP = INT_COLL_ORD-ETTYP.
          CHECK SY-SUBRC NE 0.
    Now, the issue is:
    Please note that declaration for INT_COLL_ORD has a field AUART, which is used in further parts of program (see the statement just above)
    But, since neither VBAP nor VBEP contains AUART field, it cannot be fetched through the QUERY#2. So this value is not populated into INT_COLL_ORD through SELECT Query.
    Since this field is used in later part of program & that the internal table has no value for this field, it dumps!!
    How to include this value into the INT_COLL_ORD?
    Plz suggest....

  • Select Query with diagonally  matching columns

    hi
    the following is the table struncture and insert statements
    create table emp_trans values (empno number , emptran_no number, prev_amount number, current_amount number)
    insert into emp_trans values(102,109,0,20);
    insert into emp_trans values(102,119,10,20);
    insert into emp_trans values(102,129,20,30);
    insert into emp_trans values(102,139,30,0);
    insert into emp_trans  values(201,101,0,20);
    insert into emp_trans values(201,110,20,30);
    insert into emp_trans values(201,120,0,30);
    insert into emp_trans values(201,130,30,20);
    insert into emp_trans values(201,140,0,20);In the table we can see some mappings as follows
    The data is on empno basis.
    we have 2 employees with empno 201 and 102 . Each empno has different emptrans_no. Need not be in an sequence.
    we need to select the set of records where prev_amount column matches with the current_amount column values for
    the previous record for every individual empno.
    prior to that the following basic select statement can be considered
    select * from emp_trans  order by empno , emptran_nofor ex:
    emp no 102 emptran_no 129 prev_amount column having values of 20 matches with the current_amount column having values 20
    with emptran_no 119.
    for empno 201 with emptran_no 110 we can see the prev_amount column having value 20 matched with current_account column havig values of 20
    of previous emptran_no 101 for the same empno 201.
    something like we need to see the diagnally mathced values.
    Any help on such query most welcome.
    Regards,

    Hi,
    sri wrote:
    Hi
    A small Change required
    For empno 201 we need to display
    EMPNO EMPTRAN_NO PREV_AMOUNT CURRENT_AMOUNT
    102 129 20 30
    102 139 30 0
    201 *120* 20 30
    201 130 30 20
    rathe than
    EMPNO EMPTRAN_NO PREV_AMOUNT CURRENT_AMOUNT
    102 129 20 30
    102 139 30 0
    201 *110* 20 30
    201 130 30 20Always explain how you get the results you want. Otherwise, the solution that works on your sample data won't necessarily work on your real data.
    Given that the data for empno=201 is:
    insert into emp_trans values (201, 101,  0, 20);
    insert into emp_trans values (201, 110, 20, 30);
    insert into emp_trans values (201, 120,  0, 30);
    insert into emp_trans values (201, 130, 30, 20);
    insert into emp_trans values (201, 140,  0, 20);Why do you want the row with emptrn_no=120, and not the row with emptran_no=110?
    If you want the row with emptran_no=120, why don't you want the row with emptran_no=101?
    If you want the row with emptran_no=130, why don't you want the row with emptran_no=110?
    can u please let me know the way you formatted the code for the query and sample output This site noramlly compresses whitespace.
    Whenever you post formatted text (such as query results) on this site, type these 6 characters:
    \(small letters only, inside curly brackets) before and after each section of formatted text, to preserve spacing.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Maybe you are looking for

  • Externally Hosted DNS - How do I set up my 2003 DNS server for sub domain to point to internal IP address??

    I have a domain name(domain.com) DNS hosted at my ISP. I also have 3 sub domains DNS hosted at the same ISP pointing to various external ip addresses (mail.domain.com, vpn.domain.com and ts.domain.com). We want to set up sales.domain.com to point to

  • Receiver File Adapter Content Conversion Problem.

    Hi All, I am getting in receiver file adapter due to content conversion setting. Problem is that all the fields coming in file adapter are optional. In content conversion , i have specified fieldfixedlengths. So whenever any optional field is not pre

  • Need FM to know value table of Data element

    Hello frieds , I need such function module which will give me domain , value table of Specified data element . Something like if I give WDY_BOOLEAN it should return me abap_true and abap_false too possible values from value table. I urgently need it

  • Events 'dropping off' my iPhone 6 calendar

    Why do all events (apart from, seemingly, repeating events or birthday) 'drop off' my iPhone 6 a few weeks afterwards? I want them to stay there so I can refer back to things...

  • Recovered files gone after restarting Muse after Update

    Muse quit unexpectedly while I was working on several websites in that were in recovery mode.  When I restarted Muse, it told me that an update was available. After restarting Muse after the update, it did not attempt to recover the files that I was