Select query to combine two variable data

Hi
I have following variable data
DECLARE @col1 VARCHAR(250)='A,B,C'
DECLARE @col2 VARCHAR(250)='A1,B1,C1'
I want to select data in following form like @col1,@col2 :
A,A1
B,B1
C,C1
Thanks

In fact i fear that this is not even on a table query but on a function or procedure, notice the word variable data ...
However, as we always want to learn something new here we go :-):
create table testdata (s1, varchar(250), s2  varchar(250))
insert into testdata values ('A,B,C','A1,B1,C1,D1')
with comb (s1,v1,s2,v2) as (
select
  cast(substring(s1,1,1) as varchar(251)), cast(substring(s1+',', charindex(',', s1)+1, len(s1) - charindex(',', s1) + 1) as varchar(251))
, cast(substring(s2,1,1) as varchar(251)), cast(substring(s2+',', charindex(',', s2)+1, len(s2) - charindex(',', s2) + 1) as varchar(251))
from testdata
union all
select
  cast(substring(v1, 1, case when charindex(',', v1) - 1 < 0 then 0 else charindex(',', v1) - 1 end) as varchar(251)), cast(substring(v1, charindex(',', v1) + 1, len(v1) - charindex(',', v1))  as varchar(251))
, cast(substring(v2, 1, case when charindex(',', v2) - 1 < 0 then 0 else charindex(',', v2) - 1 end) as varchar(251)), cast(substring(v2, charindex(',', v2) + 1, len(v2) - charindex(',', v2))  as varchar(251))
from comb
where
len(v1)>0 or len(v2)>0
select s1,s2 from comb
s1         s2
A          A
B          B1
C          C1
           D1That's no fun. Notice this cast mess.
Happy coding!

Similar Messages

  • How to Run a Select Query  stored in a Variable

    Hello,
    I have a following requirement:
    Result of one select query on Var1 , result of other select query in Var2 ,
    if Va2 = 'value11' OR Var2 = 'Value2' then Var1 = 'select query'. Now how can I run this SQL query at the end of the Pl/SQL?
    so I'm writing following query for the same:
    DECLARE
    qry nvarchar2(500);
    result nvarchar2(500);
    BEGIN
    select 'select TEXTVAL as "CHARG" FROM TABLE1 WHERE LOC =''[ParameterValue]'' and KEYNAME =''<<REPLACE>>''' INTO qry from dual;
    SELECT CASE WHEN count(RW."CountofBATCH") > 1 then 'Mixing'
    WHEN count(RW."CountofMAT") = 0 then 'None'
    ELSE 'Other'
    END
    INTO result
    FROM TABLENAME2 TT, XMLTable('/Rowsets/Rowset/Row' PASSING TT.XMLCOL
    COLUMNS
    "CountofBATCH" PATH '/Row[CLABS > 0]/CHARG',
    "CountofMAT" PATH '/Row[MATNR = "[Parameter Value]"]/MAT'
    ) AS RW
    where
    TT.PL = '[Parameter Value]' and
    TT.TANK = '[Parametr Value]' ;
    IF result = 'Mixing' OR result = 'None' THEN
    qry := replace( qry , '<<REPLACE>> ' , result);
    else
    qry := 'Nothing';
    END IF;
    This way the variable qry will have select statement. Now How can I run this qry variable to get the output of that select statement in the same query?

    you can use execute immediate if the output of the query is in the single query.
    that is very simple.
    have the query in the signle string and then pass like this
    declare
    qry varchar2(255);
    result varcharf2(2500);
    vempid number :=1;
    begin
    qry:='select empname from emp where empid=:empid';
    execute immediate qry into result using vempid;
    -----now the data result is in result
    end;

  • Hierarchical query to combine two groupings into one broad joint grouping

    Hi there,
    I would like to know if anyone knows a way to solve the problem below with a SQL querie, maybe using some hierarchical queries or window functions (or anything else in SQL for that matter).
    My environment is:
    Oracle Database 11g Release 11.2.0.2.0 - 64bit
    The problem is this:
    I have a list of items that are grouped together in two different grouping ways (two columns).
    This gives the ability for items to be linked to other items in two ways:
    1. Directly if both have same value on GROUP1 and/or GROUP2;
    2. indirectly if they have an item in common with at least one match on either GROUP1 or GROUP2.
    The idea is to start from this dataset:
    WITH T AS
      SELECT 1 AS ITEM_ID, 'A' AS GROUP1, 100 AS GROUP2 FROM DUAL UNION
      SELECT 2 AS ITEM_ID, 'A' AS GROUP1, 100 AS GROUP2 FROM DUAL UNION
      SELECT 3 AS ITEM_ID, 'A' AS GROUP1, 101 AS GROUP2 FROM DUAL UNION
      SELECT 4 AS ITEM_ID, 'B' AS GROUP1, 100 AS GROUP2 FROM DUAL UNION
      SELECT 5 AS ITEM_ID, 'B' AS GROUP1, 102 AS GROUP2 FROM DUAL UNION
      SELECT 6 AS ITEM_ID, 'C' AS GROUP1, 103 AS GROUP2 FROM DUAL UNION
      SELECT 7 AS ITEM_ID, 'D' AS GROUP1, 101 AS GROUP2 FROM DUAL
    SELECT * FROM T;
    And end up with this dataset with a one single joint grouping:
    WITH T AS
      SELECT 1000 AS JOINT_GROUP_ID, 1 AS ITEM_ID FROM DUAL UNION
      SELECT 1000 AS JOINT_GROUP_ID, 2 AS ITEM_ID FROM DUAL UNION
      SELECT 1000 AS JOINT_GROUP_ID, 3 AS ITEM_ID FROM DUAL UNION
      SELECT 1000 AS JOINT_GROUP_ID, 4 AS ITEM_ID FROM DUAL UNION
      SELECT 1000 AS JOINT_GROUP_ID, 5 AS ITEM_ID FROM DUAL UNION
      SELECT 1000 AS JOINT_GROUP_ID, 7 AS ITEM_ID FROM DUAL UNION
      SELECT 2000 AS JOINT_GROUP_ID, 6 AS ITEM_ID FROM DUAL
    SELECT * FROM T;The relationships are:
    Item 1 is linked to Item 2 by GROUP1 and GROUP2;
    Item 1 is linked to Item 3 by GROUP1 only;
    Item 1 is linked to Item 4 by GROUP2 only;
    Item 1 is linked to Item 5 through Item 4 by GROUP1;
    Item 1 is linked to Item 7 through Item 3 by GROUP2;
    Item 6 is not linked to any other item since it does not match on GROUP1 nor GROUP2 with any other item.
    NOTEs:
    - JOINT_GROUP_ID values could be any sequential value. I used 1000 and 2000 just to avoid confusion with the other IDs and group values used to picture the problem.
    - The level of relationship is not restricted to 2 like the example above. There could be deeper relationships.
    This seems to me like something that could be solved with a hierarchical query, but I could not get my head around it to solve the problem.
    Hope one of you guys can help me on this.
    Chears.

    Hi Bruno,
    You are correct. Frank's solution does not work. You can do this using CONNECT BY on smaller problems, but it will be very inefficient for larger problems wirth significant looping. I wrote a quick blog article on this subject after reading your question this morning. This is actually an example of a very general class of problems and I already had three SQL solutions. I'll put the CONNECT BY one here, and you can look at my blog if you want more details (I include a diagram so I can't just post it here).
    Data
    item_groups
    SQL> SELECT *
      2    FROM item_groups
      3  /
    ITEM_ID    GROUP1                         GROUP2
    01         A                              100
    02         A                              100
    03         A                              101
    04         B                              100
    05         B                              102
    06         C                              103
    07         D                              101
    08         E                              104
    09         E                              105
    10         F                              106
    10 rows selected.Query
    WITH links_v AS (
    SELECT t_fr.item_id node_id_fr,
           t_to.item_id node_id_to,
           t_fr.item_id || '-' || Row_Number() OVER (PARTITION BY t_fr.item_id ORDER BY t_to.item_id) link_id
      FROM item_groups t_fr
      JOIN item_groups t_to
        ON t_to.item_id > t_fr.item_id
       AND (t_to.group1 = t_fr.group1 OR t_to.group2 = t_fr.group2)
    ), nodes_v AS (
    SELECT item_id node_id
       FROM item_groups
    ), tree AS (
    SELECT link_id, CONNECT_BY_ROOT (link_id) root_id
      FROM links_v
    CONNECT BY NOCYCLE (node_id_fr = PRIOR node_id_to OR node_id_to = PRIOR node_id_fr OR
                         node_id_fr = PRIOR node_id_fr OR node_id_to = PRIOR node_id_to)
    ), group_by_link AS (
    SELECT DISTINCT Min (root_id) OVER (PARTITION BY link_id) group_id, link_id
      FROM tree
    ), linked_nodes AS (
    SELECT g.group_id, l.node_id_fr node_id
      FROM group_by_link g
      JOIN links_v l
        ON l.link_id = g.link_id
    UNION
    SELECT g.group_id, l.node_id_to
      FROM group_by_link g
      JOIN links_v l
        ON l.link_id = g.link_id
    SELECT l.group_id "Network", l.node_id "Node"
      FROM linked_nodes l
    UNION ALL
    SELECT '00 (unlinked)', node_id
      FROM nodes_v n
    WHERE n.node_id NOT IN (SELECT node_id FROM linked_nodes)
    ORDER BY 1, 2Output
    Network       Node
    00 (unlinked) 06
                  10
    01-1          01
                  02
                  03
                  04
                  05
                  07
    08-1          08
                  09

  • Need Help With Combining Two Variables For A Redirect

    Hello-
    <br />
    <br />In a different part of my site (built with ADDT) I have this script that creates a variable by combining two session variables, and then the new variable is submitted into a mysqul database table using a hidden form field:
    <br />
    <br />
    <form>
    <input type="hidden" name="exerreference" id="exerreference" value="<?php echo $_SESSION['kt_login_user']; ?><?php echo $_SESSION['kt_exer_reference']; ?> <br />" />
    <br />
    <br />There is also this part of the script in the header script:
    <br />
    <br />$ins_exer1-&gt;addColumn("exerreference", "STRING_TYPE", "POST", "exerreference");
    <br />
    <br />What I am trying to do now on another page is combine a session variable "kt_login_user" with a piece of dynamic text "AA" so that I can compare it to the field "exerreference" that was inserted into the database using the above script. If the two variables match, the idea is to have a redirect to another page.
    <br />
    <br />So in a hypothetical example, if the value of the session variable "kt_login_user " is "bestperson," and static text is "AA" then I need to create the variable bestpersonAA (because this is how the variables exist in the exerreference recordset). This variable bestpersonAA then needs to be compared to the recordset value exerreference and if they match, the page redirects to ../previous/portalpre.php. If the two variables do not match, then there is no redirect.
    <br />
    <br />Here is what I have so far:
    <br />
    <br />if (isset($_SESSION['kt_login_user']))
    <br />{
    <br />if ($_SESSION['kt_login_user'.'AA'] = $row_Recordsetexer1['exerreference'])
    <br />{
    <br /> header ("Location: ../previous/portalpre.php");
    <br />}
    <br />}
    <br />
    <br />The script doesn't work yet - it's redirecting regardless of if the two varibles match. Any ideas on the correct syntax to get this working correctly?
    <br />
    <br />Thanks
    <br />Dale</form>

    Hi Dale,
    if ($_SESSION['kt_login_user'.'AA'] = $row_Recordsetexer1['exerreference'])
    for checking whether two variables match, you´ll need the == comparison operator:
    if ($_SESSION['kt_login_user'.'AA'] == $row_Recordsetexer1['exerreference'])
    Cheers,
    Günter Schenk
    Adobe Community Expert, Dreamweaver

  • Select query with combination of two columns

    I need looking to write a nested select statement that would achieve the following.
    Support i have a table as follows
    TestTable
    Name : Age : Country
    Test1 : 10 : USA
    Test2 : 11 : USA
    Test3 : 12 : USA
    Test4 : 11 : Canada
    Test5 : 12 : Canada
    Now i want to select from the above table the following information.
    Get all the names of people who dont belong to this combinations (10:USA,11:Canada,12:Canada). The list can be huge.
    The result should be
    Test1:10:USA
    Test1:12:USA
    If it were one combination i can write
    select * from TestTable
    where age <> 10 and country <>Canada
    Also i can also do
    select * from TestTable
    where age NOT IN (10,11) and country NOT IN (USA,COUNTRY)
    But i don't this it would give me correct result.

    sush_msn wrote:
    Is there a way i can pass the age and country as list to the query ?You asked the right question.
    Three things you need to know:
    1) Your test data doesn't cover all combinations. Here is more complete test data:create table test_table1 as
    WITH AGES AS (
      SELECT LEVEL+10 AGE FROM DUAL CONNECT BY LEVEL <= 3
    ), COUNTRIES AS (
      SELECT 'USA' COUNTRY FROM DUAL
      UNION ALL
      SELECT 'CANADA' COUNTRY FROM DUAL
    SELECT 'Test' || ROWNUM NAME, AGE, COUNTRY FROM AGES, COUNTRIES;
    NAME                                                AGE COUNTRY
    Test1                                                11 USA    
    Test2                                                11 CANADA 
    Test3                                                12 USA    
    Test4                                                12 CANADA 
    Test5                                                13 USA    
    Test6                                                13 CANADA2) Now here is the answer to your question. You can put two or more values together in an expression by putting parentheses around them.SELECT * FROM TEST_TABLE1
    WHERE (AGE, COUNTRY) NOT IN (
      (11, 'USA'),
      (12, 'CANADA')
    NAME                                                AGE COUNTRY
    Test2                                                11 CANADA 
    Test3                                                12 USA    
    Test5                                                13 USA    
    Test6                                                13 CANADAThis is what Etbin did above, but he used a SELECT instead of a list of values.
    3) Can AGE or COUNTRY ever be NULL? Do you want to return the records that have NULL values in them? If so, you need to use NOT EXISTS instead of NOT IN. Warning: Etbin's code needs a little change: "where (age,country) = (t.age,t.country)" should be "where (age,country) = ((t.age,t.country))". You always need extra parentheses on the right side.

  • Combining two different data warehouses

    i have a user who wants to combine data from 2 different data warehouses.  Can someone explain or provide instructions on how this can be done in BO Deski Reporter?
    Thanks.

    Hi-Create 2 data providers from the 2 different universes representing the data warehouses. After they are created go the data manager by clicking on View Data and then click the data provider. Make sure the Definition tab is open. Click the dimension/s you want to join in the other data provider (one at a time)  and click Link to..select the dimension in other data provider you want to join. Repeat for each dimensions you want to join in the other data provider.
    When creating a report the joined dimension can be placed in the report and dimensions from one data provider. Dimensions from the other data provider can be added by creating new detail variables pointin to the dimension.
    Any questions let me know and do award points if it works for you.
    Ashok

  • Combine two columns data in single field STRAS

    Hi experts,
    I have to upload vendor master using direct method LSMW,
    I have been given an excel file having number of fields along with data and  House number and Street the data is in two different columns, but in master table there is only one field called STRAS which is combined for House number and street.
    How do i combine data of this two columns in single field STRAS
    Regards,
    Vijaya B.

    field-symbols: <fs> type line of itab_excel.
    loop at itab_excel assigning <fs>.
       concatenate <fs>-house <fs>-street into <fs>-newfield.
    endloop.
    by the end of the loop new filed will hold value needed for STRAS

  • How to compare dates in a select query in open sql

    Hi
                       How can I retrieve data pertaining to a specified date using a select query.
    I have inserted date using the following code:
    String dateString = "2009-03-11";
    java.sql.Date date = java.sql.Date.valueOf(dateString);
    PreparedStatement stmt =con.prepareStatement("insert into DATEACCESS"
                                                                            + "(DATETEST)"
                                                                            + "values (?)");
    stmt.setDate(1,date);
    stmt.executeUpdate();
    How can I pass this in a select query,the below mentioned query did not fetch me any results.
    Select * from  DATEACCESS where DATETEST='2009-03-11'

    Hi
    Has ur date  problem resolved  ?
    If not resolved u can do the following
    As u already have sql date today declared . You want to get the data depending on that date
    As ur query is
    if( today != null)
    String query2 = select * from DATEACCESS where DATETEST<= ?
    PreparedStatement ps = conn.prepareStatement(query2);
    ps.setDate(1,today)
    ResultSet rs = ps.executeQuery();
    While(rs.next)
        ////// Here u will get data from query u needed ///
    If this also does not work just print the date and check in which format is it returning u .
    Regards
    Anuradha Rao
    Edited by: Anuradha Rao on Mar 20, 2009 10:16 AM

  • Select query for dates

    Hi All,
    Could you please help with a SELECT query to retrieve the following dates ...
    sysdate - 1
    sysdate,
    sysdate + 1
    Sorry for the miscommunication .. I wanted these dates in a single column as given below
    21-May-2012
    22-May-2012
    23-May-2012
    Regards,
    Jitesh Gurnani
    Edited by: Jitesh Gurnani on May 22, 2012 2:53 AM

    >
    Sorry for the miscommunication .. I wanted these dates in a single column as given below
    21-May-2012
    22-May-2012
    23-May-2012
    >
    select sysdate - level + 2
      from dual
    connect by level <= 3
    order by 1Edited by: Paul Horth on 22-May-2012 02:59

  • Questions on the most efficient select query..

    What is the difference between the two select query & please explain y is the 2nd select query more efficient??
    DATA: MAX_MSGNR type t100-msgnr.
    MAX_MSGNR = '000'.
    SELECT * FROM T100 INTO T100_WA
      WHERE SPRSL = 'D' AND
            ARBGB = '00'.
      CHECK: T100_WA-MSGNR > MAX_MSGNR.
      MAX_MSGNR = T100_WA-MSGNR.
    ENDSELECT.
    DATA: MAX_MSGNR type t100-msgnr.
    SELECT MAX( MSGNR ) FROM T100 INTO max_msgnr
      WHERE SPRSL = 'D' AND
            ARBGB = '00'.

    Hi,
    First never use Check statement in the Select.
    Next thing Select ... end select.
    Coming to ur question In case of first select it will fetch each record from the data base and compares that record value with the variable(MAX_MSGNR) and assigns the value to the variable. And this process will continue till the select reads all the records of the data base. Also these operations happens on the data base server. SO this query not only affect ur program but also others who is accessing the same data base.
    Second query is most efficient because of the aggregate function MAX. Here it will fetch all the records in single go and checks the max value for that column using
    optimising algorithm. So number of checks, assignments(single assignment) and fetches will be less compared to first select. This is the main reason. Hope this clarified ur doubt.
    Another thing is in first query we are selecting all the fields where as in second we are selecting only one field(required)
    Thanks,
    Vinod.
    Edited by: Vinod Kumar Vemuru on Mar 13, 2008 4:55 PM

  • Combining two single recordset into one two column recordset

    Hi Forum
    Assume we have three types , each 'table of'
    CREATE OR REPLACE type type1 as table of number ;
    CREATE OR REPLACE type type2 as table of varchar2 (255);
    CREATE OR REPLACE TYPE TYPEVALUE AS OBJECT
    (object_type number ,
    object_value varchar2(255)
    resultset1 type1 := type1() ;
    resultset2 type2 := type2() ;
    resultset3 typevalue := typeValue3() ;
    I want to populate records of resultset3 from resultset1 and resultset2 , using resultset1 for first column of record and resultset2 for second column.
    One way is to do for loop but I don't want to use this.
    I need something similar to resultset3 to use it dynamically in select statement to do MINUS operation with another resultset . I think things like MULTISET, COLLECT, CAST can achieve what I want to do.
    Can you please help me to have a select statement that combines two single column rowset and put into a two column recordset.
    Thanks

    Hi,
    You can do something like this:
    SQL> create or replace type type1 as table of number;
      2  /
    Type created.
    SQL> create or replace type type2 as table of varchar2(255);
      2  /
    Type created.
    SQL> create or replace type typevalue as object(object_type number, object_value varchar2(255));
      2  /
    Type created.
    SQL> create type typevalue_tab as table of typevalue;
      2  /
    Type created.
    SQL> ed
      1  declare
      2     resultset1 type1 := type1(1, 2, 3, 4, 5);
      3     resultset2 type2 := type2('one', 'two', 'three', 'four', 'five');
      4     resultset3 typevalue_tab;
      5  begin
      6     for l_res in (
      7        select typevalue(t1.col1, t2.col2) as col
      8        from (
      9           select column_value col1
    10           , rownum rn
    11           from table(cast(resultset1 as type1))
    12        ) t1
    13        , (
    14           select column_value col2
    15           , rownum rn
    16           from table(cast(resultset2 as type2))
    17        ) t2
    18        where t1.rn = t2.rn
    19     )
    20     loop
    21        dbms_output.put_line(
    22           'Object Type:  '||l_res.col.object_type||' '||
    23           'Object Value: '||l_res.col.object_value
    24        );
    25     end loop;
    26* end;
    SQL> /
    Object Type:  1 Object Value: one
    Object Type:  2 Object Value: two
    Object Type:  3 Object Value: three
    Object Type:  4 Object Value: four
    Object Type:  5 Object Value: five
    PL/SQL procedure successfully completed.All the work here is done in SQL so it should work similarly if you have these things defined as nested table columns in the database.
    However, there is a caveat here: the lines highlighted in bold above are defining an arbitrary ordering for the nested table elements using rownum, as there is no concept of ordering within a nested table. You should change this part of the query to whatever makes sense in your environment, otherwise this solution cannot be guaranteed to be correct. Another option would be to use VARRAYs, as they will retain the order of elements.
    cheers,
    Anthony

  • Dynamic From statement in select query and/or outer join not working

    Dear Experts, I have a select query where the select columns are dynamic, the where condition is also dynamic. It is of the below format:
    Select (dynamic columns) INTO <wa>
    FROM a inner join b on af1 = bf1
    inner join c on af2 = cf2......
    WHERE (dynamic conditios)
    ORDER BY ( dynamic sort condition).
    Now I have to include some tables (dynamically depending on the user input) in the inner join statement which will give description for the selected fields. And these database tables may or may no be empty. So in this case, my select query will not return any data if these tables are empty. And I dont want that.
    I tried using outer join for the extra tables but it gave me a runtime error. I also tried forming the inner join statement dynamically but it was not supporting.
    Kindly give me pointers.
    Thanks

    Hey thanks for the reply, but the problem is not solved.
    I am already using  ( fileds, value) like table in my where condition and the select statement was working properly.
    the problem is that now I have to include some tables in the join statement which can be empty and so i want to use Outer join.
    But I am getting a runtime error as below:
    Error analysis
        An exception occurred that is explained in detail below.
        The exception, which is assigned to class 'CX_SY_DYNAMIC_OSQL_SYNTAX', was not
         caught in
        procedure "ZATSCSNG_RFC_READ_TABLE" "(FUNCTION)", nor was it propagated by a
         RAISING clause.
        Since the caller of the procedure could not have anticipated that the
        exception would occur, the current program is terminated.
        The reason for the exception is:
        The running ABAP program wanted to execute a SELECT statement whose
        WHERE condition was (partly) specified dynamically. The part that is
        specified in an internal table at runtime is compared to a field of the
        right table of an LEFT OUTER JOIN. Such comparisons are not supported by
         all database systems and are therefore not allowed.

  • Select query dump

    Hi all,
    tables: ikpf,iseg.
    TYPES: BEGIN OF i_ikpf,
           werks TYPE ikpf-werks,    "Plant
           lgort TYPE ikpf-lgort,    "Storage location
           iblnr TYPE ikpf-iblnr,    "Physical Inventory Document
           gjahr TYPE ikpf-gjahr,    "Fiscal Year
           zldat TYPE ikpf-zldat,    "Last Count Date
           sobkz TYPE ikpf-sobkz,
           bldat TYPE ikpf-bldat,
           gidat TYPE ikpf-gidat,
           budat TYPE ikpf-budat,
           END   OF i_ikpf.
    DATA:  it_ikpf  TYPE STANDARD TABLE OF i_ikpf              ,
           wa_ikpf  TYPE i_ikpf                                .
    SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS  : s_matnr FOR iseg-matnr,
                      s_werks FOR ikpf-werks,
                      s_lgort FOR ikpf-lgort,
                      s_iblnr FOR ikpf-iblnr,
                      s_gjahr FOR ikpf-gjahr,
                      s_zldat FOR ikpf-zldat,
                      s_abcin FOR iseg-abcin.
    SELECTION-SCREEN: END OF BLOCK b1     .
    SELECT iblnr gjahr werks lgort sobkz bldat gidat zldat budat
      from ikpf
      INTO TABLE it_ikpf
      WHERE werks IN s_werks and
            lgort IN s_lgort and
            iblnr IN s_iblnr and
            gjahr IN s_gjahr and
            zldat IN s_zldat.
    select query is giving dump as " data could not be placed in an output area"
    thanks in advance,

    When selecting the fields, order of fields selection and fields in internal table should be same.
    Check the below code
    tables: ikpf,iseg.
    TYPES: BEGIN OF i_ikpf,
    iblnr TYPE ikpf-iblnr, "Physical Inventory Document
    gjahr TYPE ikpf-gjahr, "Fiscal Year
    werks TYPE ikpf-werks, "Plant
    lgort TYPE ikpf-lgort, "Storage location
    sobkz TYPE ikpf-sobkz,
    bldat TYPE ikpf-bldat,
    gidat TYPE ikpf-gidat,
    zldat TYPE ikpf-zldat, "Last Count Date
    budat TYPE ikpf-budat,
    END OF i_ikpf.
    DATA: it_ikpf TYPE STANDARD TABLE OF i_ikpf ,
    wa_ikpf TYPE i_ikpf .
    SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS : s_matnr FOR iseg-matnr,
    s_werks FOR ikpf-werks,
    s_lgort FOR ikpf-lgort,
    s_iblnr FOR ikpf-iblnr,
    s_gjahr FOR ikpf-gjahr,
    s_zldat FOR ikpf-zldat,
    s_abcin FOR iseg-abcin.
    SELECTION-SCREEN: END OF BLOCK b1 .
    SELECT iblnr
           gjahr
           werks
           lgort
           sobkz
           bldat
           gidat
           zldat
           budat
    from ikpf
    INTO TABLE it_ikpf
    WHERE werks IN s_werks and
    lgort IN s_lgort and
    iblnr IN s_iblnr and
    gjahr IN s_gjahr and
    zldat IN s_zldat.
    Other wise use "INTO CORRESPONDING FIELDS" while selecting.
    Hope this helps u.

  • How to store data in a variable in select query

    Hi,
    Below is the select query in which i want to store the data in variable but i am getting runtime error as the fields are more as compared to variable,the declaration is necessary for it due to the reteriving for data.
    Please provide me guidelines how to do it.
    DATA: BEGIN OF ITSC01 OCCURS 0,
          PRUEFLOS LIKE QALS-PRUEFLOS,
          MBLNR LIKE QAMB-MBLNR,
          LGORT LIKE MSEG-LGORT,
          END OF ITSC01.
    IF STIT-MGEIG GE 0.
    LOOP AT STIT." WHERE PRUEFLOS EQ STIT-PRUEFLOS.
        SELECT A~PRUEFLOS B~MBLNR C~LGORT FROM QALS AS A
               INNER JOIN QAMB AS B ON B~PRUEFLOS = A~PRUEFLOS
               INNER JOIN MSEG AS C ON C~MBLNR = B~MBLNR AND C~MJAHR = B~MJAHR
               INTO SLOC WHERE A~PRUEFLOS EQ STIT-PRUEFLOS.
    *           INTO TABLE ITSC01 WHERE A~PRUEFLOS EQ STIT-PRUEFLOS AND A~MATNR EQ STIT-MATNR AND C~LGORT EQ 'SC03'.
        SORT ITSC01 BY PRUEFLOS.
         READ TABLE ITSC01 WITH KEY PRUEFLOS = ITSC01-PRUEFLOS.
          IF ITSC01-LGORT EQ 'SC03'.
          STIT-MGEIG = 0.
          ENDIF.
    MODIFY STIT.
    ENDLOOP.
    ENDIF.

    hmm..
    try this:
    DATA: l_PRUEFLOS LIKE QALS-PRUEFLOS,
              l_MBLNR LIKE QAMB-MBLNR,
             l_LGORT LIKE MSEG-LGORT,
    IF STIT-MGEIG GE 0.
    LOOP AT STIT." WHERE PRUEFLOS EQ STIT-PRUEFLOS.
        SELECT APRUEFLOS BMBLNR C~LGORT FROM QALS AS A
               INNER JOIN QAMB AS B ON BPRUEFLOS = APRUEFLOS
               INNER JOIN MSEG AS C ON CMBLNR = BMBLNR AND CMJAHR = BMJAHR
               INTO ( l_PRUEFLOS , l_MBLNR, l_LGORT )
          WHERE A~PRUEFLOS EQ STIT-PRUEFLOS.
              INTO TABLE ITSC01 WHERE APRUEFLOS EQ STIT-PRUEFLOS AND AMATNR EQ STIT-MATNR AND C~LGORT EQ 'SC03'.
        SORT ITSC01 BY PRUEFLOS.
         READ TABLE ITSC01 WITH KEY PRUEFLOS = ITSC01-PRUEFLOS.
          IF ITSC01-LGORT EQ 'SC03'.
          STIT-MGEIG = 0.
          ENDIF.
    MODIFY STIT.
    ENDLOOP.
    ENDIF.

  • Select Query Between two dates...

    Hi Guru's,
    I need a Select Query between two dates, also if the record not found for any in between date then it should return NULL or 0 ...
    for Example
    1. I am having two records in DB for date 2-10-2008 & 4-10-2008
    2. Now suppose I have given Query for date between 1-10-2008 to 5-10-2008
    Then it should return me 5 records with valid values for 2 & 4 and NULL for other 1,3,5
    Thanks.

    Try like this:
    with
      t as
          select date '2008-10-02' as dt, 'Record #1 (in DB)' as str from dual union all
          select date '2008-10-04' as dt, 'Record #2 (in DB)' as str from dual
    select v.dt, t.str
      from (
             select date '2008-10-01' + level - 1 as dt
               from dual
             connect by level <= (date '2008-10-05' - date '2008-10-01') + 1
           ) v
      left join t
        on v.dt = t.dt
    order by 1

Maybe you are looking for

  • Error (Aborted) executing CT mapping

    Hi I 've a big problem with execution of CT mapping, When I try to execute a code template mapping It ended with failure. I've OWB 11gr2 and my sources are Adabas (heterogeneous database) and my targets are in Oracle. Other code templete mapping exec

  • LE 8 doesn't see all of my installed Jam Packs

    Just setting up a new mac. I installed all the Jam Packs. After that I brought up Garageband and when I click on "Loops" it show the following list. I did notice that when Garage Band came up, it indicated that it was searching for Jam Packs... Garag

  • Can you automate a PDF to change its contents every time it is downloaded?

    I would like to create a coupon / voucher document that when people download it, it changes the coupon code every time it is downloaded. I purchased an online shopping cart that allows you to upload digital documents so that when it is purchased, it

  • Faulting Application

    Hello, I appear to be having an interesting problem. For some reason, both Flash and Photoshop are crashing when I'm attempting to load them. Flash crashes around the time when it is building the workspace. Photoshop is crashing around when it is ini

  • Photoshop actions function keys script

    I work with a lot actions organized in multiple action folders. Is it possible to create a Photoshop CC script that will remove every function key shortcuts from the entire Photshop CC Action panel folders?