PLS-00382 Type error in the select statement in the Cursor.

Hi,
I am trying to combine several different sql statements to form one large cursor for my java layer. I have attached the PL/SQL procedure that I am using and when I am trying to compile it is giving PLS-00382 error. Please help me.
PL/SQL Code.
CREATE OR REPLACE PROCEDURE test IS
tmpVar NUMBER;
TYPE checkRecord is RECORD (
name1 APPS.EMCSV_R25_DIST_PROF_TBL.distmgrfname%TYPE,
     name2 APPS.EMCSV_R25_DIST_PROF_TBL.distmgrfname%TYPE,
     name3 APPS.EMCSV_R25_DIST_PROF_TBL.distmgrfname%TYPE,
     name4 APPS.EMCSV_R25_DIST_PROF_TBL.distmgrfname%TYPE,
     oppstatus1 APPS.EMCSV_R25_DIST_PROF_TBL.oppstatus%TYPE,
     oppcount1 APPS.EMCSV_R25_DIST_PROF_TBL.oppcount%TYPE,
     oppamount1 APPS.EMCSV_R25_DIST_PROF_TBL.oppamount%TYPE,
oppstatus2 APPS.EMCSV_R25_DIST_PROF_TBL.oppstatus%TYPE,
     oppcount2 APPS.EMCSV_R25_DIST_PROF_TBL.oppcount%TYPE,
     oppamount2 APPS.EMCSV_R25_DIST_PROF_TBL.oppamount%TYPE,
     oppstatus3 APPS.EMCSV_R25_DIST_PROF_TBL.oppstatus%TYPE,
     oppcount3 APPS.EMCSV_R25_DIST_PROF_TBL.oppcount%TYPE,
     oppamount3 APPS.EMCSV_R25_DIST_PROF_TBL.oppamount%TYPE,
     oppstatus4 APPS.EMCSV_R25_DIST_PROF_TBL.oppstatus%TYPE,
     oppcount4 APPS.EMCSV_R25_DIST_PROF_TBL.oppcount%TYPE,
     oppamount4 APPS.EMCSV_R25_DIST_PROF_TBL.oppamount%TYPE);
TYPE checkCur IS REF CURSOR RETURN checkRecord;
checkCurVal checkCur;
checkCurRec checkRecord;
chechcurVal checkCur;
NAME: test
PURPOSE:
REVISIONS:
Ver Date Author Description
1.0 3/8/2006 1. Created this procedure.
NOTES:
Automatically available Auto Replace Keywords:
Object Name: test
Sysdate: 3/8/2006
Date and Time: 3/8/2006, 10:01:59 AM, and 3/8/2006 10:01:59 AM
Username: (set in TOAD Options, Procedure Editor)
Table Name: (set in the "New PL/SQL Object" dialog)
BEGIN
tmpVar := 0;
OPEN checkCurVal FOR
SELECT
     a.distmgrfname,
a.distmgrlname,
     a.salesrepfname,
     a.salesreplname,
     cursor (
     SELECT b.oppstatus,
     b.oppcount,
     b.oppamount
     from APPS.EMCSV_R25_DIST_PROF_TBL b
     where b.userid = '100000001' AND
     b.reportid = 'ISARPTR25' AND
               b.oppstatus = 'Open' AND
               b.isoppstatusselected = 'Y'),
     cursor (
     SELECT c.oppstatus,
     c.oppcount,
     c.oppamount
     from APPS.EMCSV_R25_DIST_PROF_TBL c
     where c.userid = '100000001' AND
     c.reportid = 'ISARPTR25' AND
               c.oppstatus = 'Commit' AND
               c.isoppstatusselected = 'Y'),
     cursor (
     SELECT
     d.oppstatus,
     d.oppcount,
     d.oppamount
     from APPS.EMCSV_R25_DIST_PROF_TBL d
     where d.userid = '100000001' AND
     d.reportid = 'ISARPTR25' AND
               d.oppstatus = 'Closed-Won' AND
               d.isoppstatusselected = 'Y'),
     cursor (
     SELECT
     e.oppstatus,
     e.oppcount,
     e.oppamount
     from APPS.EMCSV_R25_DIST_PROF_TBL e
     where e.userid = '100000001' AND
     e.reportid = 'ISARPTR25' AND
               e.oppstatus = 'Closed-Lost' AND
               e.isoppstatusselected = 'Y')               
               from APPS.EMCSV_R25_DIST_PROF_TBL a
     where a.userid = '100000001' AND
     a.reportid = 'ISARPTR25' AND
               a.isoppstatusselected = 'Y' ;
     LOOP
     FETCH checkCurVal INTO checkCurRec;
          EXIT WHEN checkCurVal%NOTFOUND;
          DBMS_OUTPUT.PUT_LINE (checkCurRec.name1 ||
          checkCurRec.name2 ||
                                        checkCurRec.name3 ||
                                        checkCurRec.name4 ||
                                        checkCurRec.oppstatus1 ||
                                        checkCurRec.oppcount1 ||
                                        checkCurRec.oppamount1 ||
                                        checkCurRec.oppstatus2 ||
                                        checkCurRec.oppcount2 ||
                                        checkCurRec.oppamount2 ||
                                        checkCurRec.oppstatus3 ||
                                        checkCurRec.oppcount3 ||
                                        checkCurRec.oppamount3 ||
                                        checkCurRec.oppstatus4 ||
                                        checkCurRec.oppcount4 ||
                                        checkCurRec.oppamount4);                                        
     END LOOP;     
END test;
/

Thanks for Replying.
I am trying to build a cursor to fetch the records from the table. Table structure is something like this.
reportid VARCHAR2(10) NOT NULL,
distmgrid NUMBER DEFAULT 0,
salesrepid NUMBER DEFAULT 0,
distmgrfname VARCHAR2(40 CHAR) DEFAULT 'rfname',
distmgrlname VARCHAR2(40 CHAR) DEFAULT 'rlname',
salesrepfname VARCHAR2(40 CHAR) DEFAULT 'afname',
salesreplname VARCHAR2(40 CHAR) DEFAULT 'aname',
issalesrepselected CHAR(1 CHAR) DEFAULT 'Y',
oppstatus VARCHAR2(40 CHAR) DEFAULT 'oppstatus',
isoppstatusselected CHAR(1 CHAR) DEFAULT 'Y',
oppcount NUMBER DEFAULT 0,
oppamount NUMBER DEFAULT 0,
oppquote NUMBER DEFAULT 0,
Attribute1 VARCHAR2(10 CHAR),
Attribute2 VARCHAR2(15 CHAR),
Attribute3 NUMBER,
Attribute4 NUMBER
But from the above table, I am trying to build a report for which I need a cursor which I listed in the proc. Is it not possible to build a cursor within a cursor?
Yes each individual cursor return only one row.

Similar Messages

  • How to get the select statement from the DISPLAY_ERROR; window

    Hi
    Do you know a way to get the select statement that is displayed in the
    display_error; window ( select hola from u where a = :d),
    this for saving to a text file.
    Thanks in Advance.

    You must copy-and-paste it. You can't access that error from within Forms.
    Regards,
    Robin Zimmermann
    Forms Product Management

  • Table or view does not exists error while executing select statement

    Hi,
    I am new to Oracle. I am getting a error while executing the select statement if i give table name without double quotes.
    Ex: Select * from Customer;
    But working fine when the table name is enclosed within a double quotes.
    Ex: Select * from "Customer";
    Is there any way to execute the select statement without the double quotes?
    Actually I am using NHibernate objects for data access.
    Thanks,
    Sai

    Actually I am using NHibernate objects for data access.And probably that's the problem:
    SQL> select * from mytab;
             A
             1
    SQL> select * from mYtAb;
             A
             1
    SQL> select * from MYTAB;
             A
             1
    SQL>  select * from MYTAb;
             A
             1Oracle statements are case insensitive and doesn't require double quotes unless the object names are reserved words.
    As wrote by others if table is created using double quotes it's name bacomes case-sensitive... and this could be the problem...
    Max
    [My Italian Oracle blog|http://oracleitalia.wordpress.com/2010/02/05/gestione-degli-errori-in-sql-con-log-errors/]
    Edited by: Massimo Ruocchio on Feb 5, 2010 7:08 PM
    Added last comment..

  • Calling an SP takes over 200% more time over the select statement

    As part of my POC converting a SQL Server application over to SAP HANA, I'm find that CALL is taking over 200% more time than calling the SELECT statement directly. The result is that the application that uses ODBC against HANA with CALL statements is taking much more time than SQL Server. I'm finding this for all stored procedure calls in the application. Here is an example:
    CREATE PROCEDURE dbo.usp_GetOrdersByCustomerID
    (IN C_ID bigint)
    LANGUAGE SQLSCRIPT DEFAULT SCHEMA "DBO" READS SQL DATA
    AS BEGIN
    SELECT  TOP 20
       C_F_NAME,
                C_L_NAME,
                C_EMAIL,
                O_ID,
                O_TOTAL,
                O_DTS,
                O_FM_DTS
    FROM    dbo.Customer JOIN dbo.Orders ON C_ID = O_C_ID
    WHERE   C_ID = :C_ID
        ORDER   BY O_ID DESC;
    END;
    When using the following CALL statement in SAP HANA Studio
    CALL dbo.usp_GetOrdersByCustomerID(3429);
    I get execution times that look like this:
    Statement 'CALL dbo.usp_GetOrdersByCustomerID(3429)'
    successfully executed in 9 ms 663 µs  (server processing time: 8 ms 115 µs)
    Fetched 5 row(s) in 0 ms 69 µs (server processing time: 0 ms 0 µs)
    Statement 'CALL dbo.usp_GetOrdersByCustomerID(3429)'
    successfully executed in 11 ms 851 µs (server processing time: 8 ms 238 µs)
    Fetched 5 row(s) in 0 ms 62 µs (server processing time: 0 ms 0 µs)
    Statement 'CALL dbo.usp_GetOrdersByCustomerID(3429)'
    successfully executed in 8 ms 522 µs  (server processing time: 6 ms 892 µs)
    Fetched 5 row(s) in 0 ms 93 µs (server processing time: 0 ms 0 µs)
    When I execute the select statement with the hard coded parameter value, I get much faster results:
    Statement 'SELECT TOP 20 C_F_NAME, C_L_NAME, C_EMAIL, O_ID, O_TOTAL, O_DTS, O_FM_DTS FROM dbo.Customer JOIN ...'
    successfully executed in 4 ms 430 µs  (server processing time: 2 ms 424 µs)
    Fetched 5 row(s) in 0 ms 73 µs (server processing time: 0 ms 0 µs)
    Statement 'SELECT TOP 20 C_F_NAME, C_L_NAME, C_EMAIL, O_ID, O_TOTAL, O_DTS, O_FM_DTS FROM dbo.Customer JOIN ...'
    successfully executed in 4 ms 105 µs  (server processing time: 2 ms 210 µs)
    Fetched 5 row(s) in 0 ms 69 µs (server processing time: 0 ms 0 µs)
    Statement 'SELECT TOP 20 C_F_NAME, C_L_NAME, C_EMAIL, O_ID, O_TOTAL, O_DTS, O_FM_DTS FROM dbo.Customer JOIN ...'
    successfully executed in 4 ms 694 µs  (server processing time: 2 ms 810 µs)
    Fetched 5 row(s) in 0 ms 60 µs (server processing time: 0 ms 0 µs)
    I have 500,000 rows in the Customers table and 2,500,000 rows in the Orders table. The tables are COLUMN tables.
    Is there an optimization that I'm missing?
    Regards,
    Bill

    Hi Bill,
    Can you please try something:
    tab_cust =
    SELECT
       C_F_NAME,
                C_L_NAME,
                C_EMAIL
    FROM    dbo.Customer
    WHERE   C_ID = :C_ID;
    tab_orders =
    SELECT
                O_ID,
                O_TOTAL,
                O_DTS,
                O_FM_DTS
    FROM    dbo.Orders ON C_ID = O_C_ID
    WHERE   O_C_ID = :C_ID
    SELECT  TOP 20
       C_F_NAME,
                C_L_NAME,
                C_EMAIL,
                O_ID,
                O_TOTAL,
                O_DTS,
                O_FM_DTS
    FROM    :tab_cust JOIN :tab_orders ON C_ID = O_C_ID
        ORDER   BY O_ID DESC;
    END;
    Expected behavior: The data set for each of the tables is filtered out and then joined. Although the filter is expected to be pushed to each of the joined tables even in your case, but this is worth the try.
    Regards,
    Ravi

  • PLS -00428-- an INTO clause is expected in the SELECT statement

    I dnt know what i'm doing wrong with statement, can you help me please.
    DECLARE start_date DATE:= to_date('01/09/2006' , 'DD-MON-YYYY');
    end_date DATE:= to_date('30/09/2006' , 'DD-MON-YYYY');
    BEGIN
    SELECT t.SEC_SHORT_NAME, t.SEC_ISIN, t.SEC_NO,t.SEC_NAME, t.TRADE_DATE,
    t.PAYMENT_DATE,t.COUNTERPARTY, t.PRICE , t.NOMINAL ,
                        t.TRANSACTION_NO,t.CURRENT_VALUE_PC, t.CURRENT_VALUE_SC, t.PAYMENT_AMOUNT_PC,
                        t.PAYMENT_AMOUNT_SC,
                   ct.AMOUNT , ct.CURRENCY,
              sb.BUSINESS_CLASS_LEVEL_2 ,sb.BUSINESS_CLASS_LEVEL_2_NAME,
              sb.BUSINESS_CLASS_LEVEL_3 ,sb.BUSINESS_CLASS_LEVEL_3_NAME,
              sb.BUSINESS_CLASS_LEVEL_4 ,sb.BUSINESS_CLASS_LEVEL_4_NAME,
    sb.BUSINESS_CLASS_LEVEL_5 ,sb.BUSINESS_CLASS_LEVEL_5_NAME
    from scdat.A_TRANSACTIONS t
    INNER JOIN scdat.A_COSTTAX ct     
         ON ct.TRANS_REF = t.TRANS_REF
    INNER JOIN scdat.A_SECS_BUSINESS_CLASS_TS sb
    ON sb.SEC_REF = t.SEC_REF           
    where t.TRADE_DATE >= to_char(start_date ,'DD-MON-YYYY')
    and t.TRADE_DATE < to_char(end_date ,'DD-MON-YYYY')
    and ct.COST_NAME = 'Broker commission'
    and sb.BUSINESS_CLASS_DEFINITION = 'FTSE';
    END;

    i think you should have placed your SELECT statement in a cursor variables since you
    are using a date range instead of the INTO clause. this is to avoid too many rows error.
    DECLARE
      Cursor c1(pStartDate Date, pEndDate Date) Is
        SELECT t.SEC_SHORT_NAME,
               t.SEC_ISIN,
               t.SEC_NO,
               t.SEC_NAME,
               t.TRADE_DATE,
               t.PAYMENT_DATE,
               t.COUNTERPARTY,
               t.PRICE,
               t.NOMINAL ,
               t.TRANSACTION_NO,
               t.CURRENT_VALUE_PC,
               t.CURRENT_VALUE_SC,
               t.PAYMENT_AMOUNT_PC,
               t.PAYMENT_AMOUNT_SC,
               ct.AMOUNT,
               ct.CURRENCY,
               sb.BUSINESS_CLASS_LEVEL_2,
               sb.BUSINESS_CLASS_LEVEL_2_NAME,
               sb.BUSINESS_CLASS_LEVEL_3,
               sb.BUSINESS_CLASS_LEVEL_3_NAME,
               sb.BUSINESS_CLASS_LEVEL_4,
               sb.BUSINESS_CLASS_LEVEL_4_NAME,
               sb.BUSINESS_CLASS_LEVEL_5,
               sb.BUSINESS_CLASS_LEVEL_5_NAME
          FROM scdat.A_TRANSACTIONS t
               INNER JOIN scdat.A_COSTTAX ct ON ct.TRANS_REF = t.TRANS_REF
               INNER JOIN scdat.A_SECS_BUSINESS_CLASS_TS sb ON sb.SEC_REF = t.SEC_REF
         WHERE t.TRADE_DATE                >= pStartDate
           AND t.TRADE_DATE                 < pEndDate
           AND ct.COST_NAME                 = 'Broker commission'
           AND sb.BUSINESS_CLASS_DEFINITION = 'FTSE';
      start_date     DATE:= to_date('01/09/2006','DD-MON-YYYY');
      end_date       DATE:= to_date('30/09/2006','DD-MON-YYYY');
    BEGIN
      For c1_rec in c1(start_date, end_date) Loop
         dbms_output.put_line('t.SEC_SHORT_NAME: '||t.SEC_SHORT_NAME);
         dbms_output.put_line('t.SEC_ISIN: '||t.SEC_ISIN);
      End Loop;
    END;

  • Oracle Error while execute the Select statement

    Hi all,
    I have two database, from one databse to another datadase, i am not able get value. while i am generating the select statement in one database, it throws an
    error ORA-00942: table or view does not exist.
    For this, what i have to do.can anyone post more detail on this.
    Any idea?

    Please do not create duplicate threads.
    ORA-00942: table or view does not exist

  • Error Msg in Select Statement

    Hi,
        Can you declare an error message under select statement?

    Hi..
    You can use the Message statement for this..
    PARAMETERS: P_MATNR TYPE MARA-MATNR.
    AT SELECTION-SCREEN ON P_MATNR.
       SELECT SINGLE * FROM MARA WHERE MATNR  = P_MATNR.
       IF SY-SUBRC NE 0.
      <b>    MESSAGE E100(ZCLASS).</b>  
    ENDIF.
    <b>Reward if Helpful</b>

  • Error: Encountered a SELECT WHEN EXPECTING the following ( + - all mod num

    I have a conditional INSERT statement where I update the record if todays date is found in the table or i will INSERT a new record if that date is not found..
    Insert statement that comes after ELSE works fine but IF part fails with the error
    encountered a select when expecting the following
    *( - + all case mod new null.. and lot more*
    IF EXISTS
    (SELECT (TO_CHAR(UpdateDate, 'MM/DD/YYYY')) FROM EmployeeUpdateEmails
         WHERE UpdateDate = select (TO_CHAR(sysdate, 'MM/DD/YYYY')) from dual)
         UPDATE EMPLOYEEUPDATEEMAILS
    SET EMP_MGR_TOTAL_CHANGES = total
         WHERE UpdateDate = select (TO_CHAR(sysdate, 'MM/DD/YYYY')) from dual
    ELSE
    This is how EmployeeUpdateEmails table is created
    CREATE TABLE EmployeeUpdateEmails
    UpdateNum SMALLINT          PRIMARY KEY,
    UpdateDate               DATE,
    Emp_Mgr_Total_Changes SMALLINT,
    Emp_Term_Total_Chnages SMALLINT
    Please Help

    IF EXISTS is not aproppriate syntax:
    SQL> declare
      2  begin
      3   if exists (select count(*) from dual)
      4   then
      5     dbms_output.put_line('it exists');
      6   else
      7     dbms_output.put_line('it doesn''t exist');
      8   end if;
      9  end;
    10  /
    if exists (select count(*) from dual)
    ERROR at line 3:
    ORA-06550: line 3, column 5:
    PLS-00204: function or pseudo-column 'EXISTS' may be used inside a SQL statement only
    ORA-06550: line 3, column 2:
    PL/SQL: Statement ignored
    SQL> declare
      2   my_var number; 
      3  begin
      4  
      5   select count(*) into my_var
      6   from   dual;
      7  
      8   if my_var >= 1
      9   then
    10     dbms_output.put_line('it exists');
    11   else
    12     dbms_output.put_line('it doesn''t exist');
    13   end if;
    14  end;
    15  /
    it exists
    PL/SQL procedure successfully completed.If you're using SQL then
    1) post the complete statement
    2) mention your database version ( the result of: select * from v$version; )
    3) consider using CASE:
    SQL> select case
      2           when (select count(*) from dual) >= 1
      3           then 'it exists'
      4           else 'it doesn''t exist'
      5         end
      6  from   dual;
    CASEWHEN(SELECTC
    it exists
    1 row selected.

  • How can I call a Page Process from the Select statement for Report Page

    I'm able to call a javascript using the below:
    img src="#IMAGE_PREFIX#add2.gif" border="0" alt="Icon 4" onClick="javascript:add_connect1('||CPORT.ID||')"
    But Now,
    I'd like to accomplish (2) New things:
    1. instead of using,....... onClick="javascript:add_connect1,
    I'd like to call a Page Process, onClick=
    2. I'd like to be able to call two different processes onClick.
    a. onClick="javascript:passBack('||ID||')"
    b. onClick= <Please see my question #1 above>
    Can someone please help me with the syntax for this,
    If indeed it can even be done?
    Thanks- Gary

    Greg.
    It seems that my situation is the one you describe in you second paragraph, where you mention:
    you could then add the ID column value as a parameter to the javascript functionBut,
    I do not know how to reference the variable in my javascript nor how to use it in my on-demand process.
    If you can hellp me past this last little bump, then I think I will be able to use these skills in Sooo many different areas of my design.
    Here's what I've got so far:
    A. In the select statement I identify the javascript as:
    onClick="javascript:connect_port('<font color=blue>''||ID||''</font>')";
    B. In my javascript I have this:
    <script language="JavaScript" type="text/javascript">
    function connect_port(ID)
    var get = new htmldb_Get(null,$x('pFlowId').value,'APPLICATION_PROCESS=CONNECT_PORT',0);
    gReturn = get.get();
    get = null;
    </script>
    C. In my on demand function I have this:
    BEGIN
    INSERT INTO CCONNECTIONS_B
    BLDG_ID,CLST_ID,PORT_ID,STRAND_ID
    ) VALUES
    :P2004_BLDG_ID,:P2004_CLST_ID,:P2004_PORT_ID,:P2004_STRAND_ID1
    END;
    You can see that I dont know how to use the value for 'ID' in either the javascript or the On-Process function.
    If you can help me out with this one, Then I can imitate it for the rest.
    -Gary
    Edited by: garyNboston on Apr 3, 2009 6:44 AM
    Edited by: garyNboston on Apr 3, 2009 6:44 AM
    Edited by: garyNboston on Apr 3, 2009 6:45 AM
    Edited by: garyNboston on Apr 3, 2009 6:47 AM

  • * table name in the select statements

    Hi,
      I have come across a select Statement as below.
    Select * into *nast from nast where <conditions>.. End select.
    what does this *nast represents and when is it used. why do we need to call a Table  with *<Table Name>
    Kind Regards,
    Usha

    hi,
    select statement will always points to a database table so we have to give database table name and it gets data from that table. for storing that data we have to use internal tables must have same structure of database table.
    so select statement has the following form as........
    select * from [dbtable] into table [internal table]
    endselect.
    in sap select will act as a loop so that we hav to use end sleect. select has different varities in sap. for some types no need of end select.
    for ex:
    select single *
    select * ..................... into table [internal table name].....
    if helpful reward some points.
    with regards,
    suresh.

  • Using Select Statement in the decoe function in Oralce Form10 g

    Hello All:
    Is it possible to call another Select Statement inside the Decode Function in Oracle Form? I tested the SQL on PL/SQL Plus, it ran without giving any errors. However, I got the following errors when I tried to compile the procedure in the Oracle Form right after the where condiction at the first select statement....
    Error 103 at line number....
    Encountered the symbol "," when expecting one of the following
    ) intersect minus order union .....
    Select a.col1
    a.col2,
    decode((select min(test_date) pa_closr_date from table_name c where a.col1 = c.col1), null, a.col3,(select min(test_date) pa_closr_date from table_name c where a.col1 = c.col1)) test_date,
    a.col4,
    from table_name a;
    thanks ahead for any help.
    KMD

    You don't need the Select within the decode. In SQL Plus, I tried your SQL using this:
    Select
        a.col1,
        a.col2,
        decode( (select min(test_date) pa_closr_date
                   from table_name c where a.col1 = c.col1), null, a.col3,
                (select min(test_date) pa_closr_date
                   from table_name c where a.col1 = c.col1)
              ) test_date
      from table_name a;And this gives the same result:
    Select
        a.col1,
        a.col2,
        decode(c.pa_closr_date, null, a.col3, c.pa_closr_date ) test_date
      from table_name a,
           ( select col1, min(test_date) pa_closr_date
             from table_name
             group by col1 ) c
      where c.col1(+) = a.col1;

  • Re: Select statement in the report

    Hi Experts,
    In my selection-screen contains ernam as a parameter.
    If it balnk in the selection-screen,
    the select statement is not working.
    if it is not blank ,the select statement is  working fine.
    TABLES: vbak.
    TYPES: BEGIN OF ty_vbak,
            vbeln TYPE vbeln,
            knumv TYPE knumv,
           END OF ty_vbak.
    DATA: v_vkorg TYPE vkorg,
          v_vtweg TYPE vtweg,
          v_erdat TYPE erdat.
    DATA: i_vbak  TYPE STANDARD TABLE OF ty_vbak.
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    PARAMETERS:     p_ernam TYPE ernam .
    SELECT-OPTIONS: s_vkorg FOR v_vkorg,
                    s_vtweg FOR v_vtweg,
                    s_erdat FOR v_erdat.
    PARAMETERS:     p_kvgr4 TYPE tvv4-kvgr4 OBLIGATORY.
    SELECTION-SCREEN END OF BLOCK b1.
    START-OF-SELECTION.
      SELECT vbeln
             knumv
      FROM vbak
      INTO TABLE i_vbak
      WHERE erdat IN s_erdat
      AND   ernam = p_ernam
      AND   vkorg IN s_vkorg
      AND   vtweg IN s_vtweg
      AND   kvgr4 = p_kvgr4.
      IF sy-subrc = 0.
        WRITE:/ 'HI'.
      ENDIF.
    Thank's in Advance,
    Harsha.

    report .
    TABLES: vbak.
    TYPES: BEGIN OF ty_vbak,
    vbeln TYPE vbeln,
    knumv TYPE knumv,
    END OF ty_vbak.
    DATA: v_vkorg TYPE vkorg,
    v_vtweg TYPE vtweg,
    v_erdat TYPE erdat.
    DATA: i_vbak TYPE STANDARD TABLE OF ty_vbak with header line.
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    select-options: s_ernam for  vbak-ernam .
    SELECT-OPTIONS: s_vkorg FOR v_vkorg,
    s_vtweg FOR v_vtweg,
    s_erdat FOR v_erdat.
    PARAMETERS: p_kvgr4 TYPE tvv4-kvgr4 .
    SELECTION-SCREEN END OF BLOCK b1.
    START-OF-SELECTION.
    SELECT vbeln
    knumv
    FROM vbak
    INTO TABLE i_vbak
    WHERE erdat IN s_erdat
    AND ernam in s_ernam
    AND vkorg IN s_vkorg
    AND vtweg IN s_vtweg
    AND kvgr4 = p_kvgr4.
    IF sy-subrc = 0.
    loop at i_vbak.
    write:/ i_vbak-vbeln.
    endloop.
    ENDIF.

  • Problem in the select statement

    I have to select the values of the fields BEZEI  depending on tha sales order number vbeln. HOw can i write the select statement what will be the tables associated?

    Hi,
    tables: vbak.
    types: begin of ty_vbak,
               vbeln type vbeln,
               kokrs type kokrs,
              end of ty_vbak,
              begin of ty_it_tka01,
                kokrs type kokrs,
                bezei type bezei,
              end of ty_tka01.
    data: it_vbak type table of ty_vbak,
            wa_vbak type ty_vbak,
            it_tka01 type table of ty_tka01,
            wa_tka01 type ty_tka01.
    Select-options: s_vbeln for vbak-vbeln.
    Select VBELN KOKRS from VBAK into table it_VBAK where vbeln in s_vbeln.
    if sy-subrc = 0.
    select KOKRS BEZEI from TKA01 into it_tka01 for all entries in it_vbak where kokrs = it_vbak-kokrs.
    endif.
    Loop at it_vbak into wa_vbak.
    read table it_tka01 into wa_tka01 with key kokrs = wa_vbak-kokrs.
    if sy-subrc = 0.
    * Move data to final internal table.
    endif.
    endloop.
    Regards,
    Satish

  • Break the SELECT statement.

    Hi,
    My requirement is to break the Select statement and get the fields in where clause in one internal table.
    For eg: Select VBELN
                          POSNR
                          MATNR  from VBAP into wa_vbap where VBELN = '0000000001'
                                                                              and   POSNR = '000010'.
    Here i need to put fields VBELN, POSNR, MATNR in one internal table, table name VBAP in second internal table  and where clause fields  VBELN, POSNR in third internal table.
    Please let me know if anyone has any solution for this.
    Thanks in advance.
    Sunanda.

    Hi
    *& Report  YSELECT                                                     *
    REPORT  YSELECT                                 .
    *Select VBELN
    *POSNR
    *MATNR from VBAP into wa_vbap where VBELN = '0000000001'
    *and POSNR = '000010'.
    *Here i need to put fields VBELN, POSNR, MATNR in one internal table,
    *table name VBAP in second internal table and where clause fields VBELN,
    * POSNR in third internal table.
    TABLES: VBAP.
    TYPES: BEGIN OF STRUCT1,
          VBELN LIKE VBAP-VBELN,
          POSNR LIKE VBAP-POSNR,
          MATNR LIKE VBAP-MATNR,
           END OF STRUCT1.
    TYPES: BEGIN OF STRUCT2,
            TBLNAME(10),
           END OF STRUCT2.
    TYPES: BEGIN OF STRUCT3,
          VBELN LIKE VBAP-VBELN,
          POSNR LIKE VBAP-POSNR,
          END OF STRUCT3.
    DATA: ITAB1 TYPE TABLE OF STRUCT1 WITH HEADER LINE,
          ITAB2 TYPE TABLE OF STRUCT2 WITH HEADER LINE,
          ITAB3 TYPE TABLE OF STRUCT3 WITH HEADER LINE,
          V_TBLNAME(10).
    ITAB3-VBELN = '0000000001'.
    ITAB3-POSNR = '000010'.
    APPEND ITAB3.
    LOOP AT ITAB3.
        SELECT VBELN POSNR MATNR FROM VBAP INTO TABLE ITAB1 WHERE VBELN EQ
    ITAB3-VBELN AND POSNR EQ ITAB3-POSNR.
          WRITE ITAB1-VBELN.
    ENDLOOP.
    WRITE: 'SUBRC=', SY-SUBRC.
    I am unable to find out how to satisfy your second internal table requirement.
    Hope this helps
    Regards,
    Jayanthi.K

  • Msg 116, Level 16, State 1, Line 6 Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.

    Hello,
    Can anyone help me?
    select year(po.rdata) as 'Ano', 
    sum(etotal) as 'Valorp' ,
    (select year(fo.data),Sum(etotal) 
    FROM fo (nolock) 
    where  not exists ( select 1 from pl (nolock) where pl.adoc = fo.adoc and pl.cm = fo.doccode ) 
    group by year(fo.data))as 'Valorap'   
    from po 
    group by year(po.rdata)
    order by year(po.rdata)
    Error 
    Msg 116, Level 16, State 1, Line 6
    Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.
    Consultora

    Hi Prashanth,
    select year(po.rdata) as 'Ano',
    sum(etotal) as 'Valorp' ,
    (select Sum(etotal)
    FROM fo (nolock)
    where not exists ( select 1 from pl (nolock) where pl.adoc = fo.adoc and pl.cm = fo.doccode )
    group by year(fo.data))as 'Valorap'
    from po(nolock)
    group by year(po.rdata)
    order by year(po.rdata)
    Gives me the error: 
    Msg 512, Level 16, State 1, Line 1
    Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
    Thanks
    Consultora

Maybe you are looking for

  • Events not triggering in RV60AFZZ exit USEREXIT_SAVE_DOCUMENT_PREPARE

    Hi , I need to start workflow when invoice is created. As there is no standard event for the same, so I created new business object and trigger the event with FM SWE_EVENT_CREATE calling in user exit USEREXIT_SAVE_DOCUMENT_PREPARE in include RV60AFZZ

  • Acrobat won't convert documents

    I have been using Acrobat 8 Professional for a number of months with no problems.  Then in April we were going on vacation and wanted to do work from our laptop, so I installed Acrobat on the laptop.  On vacation the laptop completely crashed and say

  • Using 2 external drives for final cut pro 7

    I have approx. 45hours (prob less after selecting i/o of capture clip) of avchd footage that i need to encode / process as apple proress I think 2tb fw800 drive may just about hold 30 hours of footage, i have 2x2 tb drives (4tb in total). I know its

  • Artwork on ios doesn't display!

    Hi. For some reason no artwork is displayed on my iOS devices with the music synced from iTunes match. On my computer however all the artwork has synced fine. Any ideas why this might be happening? Thanks.

  • Used of 362 & 363 Alternative formula for condition base value in Define Procedures (Tcode obyz)

    Dear          what is the  used of 362 & 363 Alternative formula for condition base value in Define Procedures (Tcode obyz)