Error handling in a select statement

Hello.
I am working on a report andwe have two fields on the selection screen:
Vendor Number:
Sortl:
on the selection screen user will enter the list of vendors and then I need to update the field SORTL with what user enters on the field SORTL on the selection screen. for this I have written the following code:
SELECT lifnr FROM lfa1
                   INTO TABLE it_lfa1
                   WHERE lifnr IN s_lifnr AND
                         bukrs = '001'.
the above code is updating the table it_lfa1with the valid vendor numbers, but I need to put a logic that if a user enters an invalid vendor number then it should produce an error log for all the invalid vendor number and for thsi I modify the above code as:
SELECT lifnr FROM lfa1
                   INTO TABLE it_lfa1
                   WHERE lifnr IN s_lifnr AND
                         bukrs = '001'.
if sy-subrc <> 0.
move s_lifnr to it_invalid-lifnr.
endif.
but when I use the above code it just look for the first vendor and then just don't continue with the other vendors entered by the user. can you please tell what am i doing wrong here?
Thank you.

Hi,
Well, If the user always enter a list as selection (no range, exclusion, ...), I can understand the need.. otherwise this is indeed a bit strange... In case they only need to use single element list in SO, you could restrict all other SO features with the FM SELECT_OPTIONS_RESTRICT and then loop on values and select each single vendor...
E.g under your INITIALIZATION event:
* Only option 'EQ' and sign 'I' are allowed
  lt_opt_list-name        = 'ONLY_EQ'.
  lt_opt_list-options-eq  = 'X'.
  APPEND lt_opt_list TO ls_restriction-opt_list_tab.
  lt_***-kind             = 'S'.        "select-option
  lt_***-name             = 'S_LIFNR'.  "name of select-option
  lt_***-sg_main          = 'I'.        "only inclusive
  lt_***-sg_addy          = space.
  lt_***-op_main          = 'ONLY_EQ'.
  lt_***-op_addy          = space.
  APPEND lt_*** TO ls_restriction-***_tab.
  CALL FUNCTION 'SELECT_OPTIONS_RESTRICT'
    EXPORTING
      restriction            = ls_restriction
    EXCEPTIONS
      too_late               = 1
      repeated               = 2
      selopt_without_options = 3
      selopt_without_signs   = 4
      invalid_sign           = 5
      empty_option_list      = 6
      invalid_kind           = 7
      repeated_kind_a        = 8
      OTHERS                 = 9.
Then just loop on SO table, select single and check subrc...
Kr,
Manu.

Similar Messages

  • Getting error while executing this select statement

    Hi All,
    I am new to this community.
    I am getting error whie compiling the below code. Its telling 'Text' is invalid identifier. Also i want to know how can we obtain 'parseable' version of the below query?
    my basic intention is to create a trigger header through a select statement and show it the complete text as a single column..
    select text from
    (select 'CREATE OR REPLACE TRIGGER '||SUBSTR(column_name,2,4)||'aud
    AFTER INSERT
    OR UPDATE
    OF '||column_name||',
    OR DELETE ON '||table_name||'
    FOR EACH ROW'
    FROM(SELECT lower(REPLACE(column_name,'O_','')) column_name , /*changing O to O_*/
    lower(replace(t.table_name,'_A_','_')) table_name,
    lower(t.table_name) table_name1,
    c.column_id
    FROM all_tab_columns c,
    (SELECT object_name table_name
    FROM all_objects
    WHERE object_name LIKE '%/_A/_%' ESCAPE '/') t
    WHERE c.table_name(+) = t.table_name
    AND SUBSTR(column_name(+),1,2) = 'O_'))

    thanks prathamesh. it solved the problem. i have one more question.
    as of now it creates single create trigger statement for each column on a table.
    example:
    CREATE OR REPLACE TRIGGER ust_aud
    AFTER INSERT
    OR UPDATE
    OF cust_id,
    OR DELETE ON characteristic_t
    FOR EACH ROW
    however, i want to create trigger for all columns in a single statement. can you please help me how to do it?
    basically want to 'CREATE TRIGGER' for all columns in a table. i am finding difficult how to change my query to suit this!!
    i am pasting my original query again for your reference. pls advise...
    example:
    CREATE OR REPLACE TRIGGER ust_aud
    AFTER INSERT
    OR UPDATE
    OF cust_id,
    fixed_item_val,
    copy_item_val,
    rgn_id,
    txn_id,
    OR DELETE ON characteristic_t
    FOR EACH ROW
    ORIGINAL QUERY
    select text from
    (select 'CREATE OR REPLACE TRIGGER '||SUBSTR(column_name,2,4)||'aud
    AFTER INSERT
    OR UPDATE
    OF '||column_name||',
    OR DELETE ON '||table_name||'
    FOR EACH ROW' text
    FROM(SELECT lower(REPLACE(column_name,'O_','')) column_name , /*changing O to O_*/
    lower(replace(t.table_name,'_A_','_')) table_name,
    lower(t.table_name) table_name1,
    c.column_id
    FROM all_tab_columns c,
    (SELECT object_name table_name
    FROM all_objects
    WHERE object_name LIKE '%/_A/_%' ESCAPE '/') t
    WHERE c.table_name(+) = t.table_name
    AND SUBSTR(column_name(+),1,2) = 'O_'))

  • 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

  • How to handle exception in select statement

    eg:select empno into variable_1 from emp where empno=10 (Fails here the value of variable_1 should be 010)
    select empno into variable_1 from emp where empno=102 (sucess)
    in this statement i have to handle no_data_found exception
    can u please suggest
    emp table
    empno ename sal
    102 abc 1000
    103 abcd 10002

    In that case, don't use an implicit cursor, use an explicit cursor and do a fetch.
    If you're going to use an implicit cursor, you will need to cater for no_data_found and (if the statement doesn't guarentee that only one row will be returned) too_many_rows (or you could leave them unhandled so they can raise an error back to the calling proc).
    I would question why you don't want to use an exception block in this case, though.

  • 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..

  • Executing a stored procedure containing multiple Select statements

    Post Author: Beverly
    CA Forum: General
    I am using Crystal  10.0 against a MS SQL 2000 server.
    I am trying to create a report based on a stored procedure that contains multiple select statements.  The sp requires a single parameter (Claim number) and contains 17 Select statements that produce results.
    I am able to use the Add command and execute the sp with the parameter, but I am only getting the results of the first select statement in the sp back in my data set.  Is there a way to have the data from each Select statement returned to my report?
    I have used Crystal for a while, but pretty much for straight-forward reporting.  I am familiar with the basics of SQL.
    I would appreciate any help anyone can offer.
    Thanks.

    Post Author: BISoftware
    CA Forum: General
    I believe Crystal Reports can only handle one recordset at a time, which means it can only handle a single select statement.  The only way I can see around this would be to break up your stored procedure into multiple stored procedures, so that each only contains a single select statement.  Then, use subreports to report on each individual sp. Hope this helps. - Davewww.BusinessSoftwareResource.com

  • Error handling in B1if

    Dear All,
    I searched the forum but could not find a full answer to my question.
    How can you handle errors in B1if?
    When something goes wrong the errormessage is displayed in the failure section of the message log.
    I found out that on the package design in the defintions section you can choose document "error handling".
    There you should be able to choose your error handling step.
    For now I only see the default error handling step.
    How can you create such a error handling step?
    Does somebody has some full documentation on this subject?
    I guess we must create a new step design with inbound type Predecessor or am I wrong?
    Thanks in advance for any help.
    Kind regards,
    Steven

    Hi Vijay,
    Create a package with your development in a step.
    Create a second step called for instance: errorhandling
    This errorhandling step must be of inbound type internal queue
    In the errorhandling step you can handle the error as you like... for example email it or save it in a user table in B1.
    The trick is:
    Go to package design - select your package - press definitions buttons and select error handling
    Here you select your errorhandling step instead of default error handling.
    Save everything.
    When you scenario goes into error during the processing the errorhandling step will be carried out.
    That is it.
    Kind regards,
    Steven

  • Error in select statement in CMOD

    Hi Friends
    I am enhancing a data source with some fields and in the CMOD i am writing the code.
    My delcaration is as follows
    begin of  ty_dfkkzp,
                    SELW2       type  dfkkzp-SELW2,
                    BLART       type  dfkkzp-BLART ,
                    BUDAT       type  dfkkzp-BUDAT ,
                    BLDAT       type  dfkkzp-BLDAT ,
                    TBETR       type  dfkkzp-TBETR  ,
                    ZZRECEIPT   type  dfkkzp-ZZRECEIPT ,
                    ZZPAYCAT  type  dfkkzp-ZZPAYCAT ,
                    ZZPAYSRC  type  dfkkzp-ZZPAYSRC ,
                    ZZPAYTYPE   type  dfkkzp-ZZPAYTYPE ,
                    ZZTENDER  type  dfkkzp-ZZTENDER ,
                end of  ty_dfkkzp.
    Following is my SELECT statement.
    select
            SELW2
            BLART
            BUDAT
            BLDAT
            TBETR
            ZZRECEIPT
            ZZPAYCAT
            ZZPAYSRC
            ZZPAYTYPE
            ZZTENDER
            into corresponding fields of table lt_dfkkzp
            from dfkkzp
            for all entries in it_data
           where SELW2 = it_data-VTREF.
    I am getting an error in the where clause. This is becuase VTERF ( Contract) is of type CHAR and length 20, where as SELW2 is of type CHAR but Length 35. I know the length and type should be the same. But this table DFKKZP strangely has SELW2(Contract) has length 35.
    Can someone please suggest me how to handle this inorder for me to get this correct?.
    Thanks in adv.
    Regards
    BN

    Hi,
    try this and let me know if it works.
    Declare another internal table and work area like it_data1 type it_data as shown below.
    Begin of it_data1_wa,
    ......... type........,
    ......... type .......,
    SELW2 type dfkkzp-SELW2,
    end if it_data_wa1.
    data: it_data1 like standard table of it_data_wa.
    data: it_data_wa type it_data
    include all the fields inside the table.
    loop at it_data into it_data_wa.
    move corresponding lt_data_wa to it_data1_wa.
    it_data1_wa-SELW2 = it_data_wa-VTREF.
    append it_data1_wa to it_data1.
    end loop.
    now write the same select statement for all entries in it_data1 instead of it_data.
    Regards,
    Anusha

  • Error handling return code for Provide Statement

    Hi Experts,
    For select statement we have error handling return code sy-subrc.
    What is the error handling return code for provide.. end provide statement.
    Thanks,
    Ragu

    Ragu,
    Same thing.
    Check sy-subrc.
    sy-subrc is the return code for all ABAP statements as far as I know.
    Regards,
    Dilek

  • Runtime error at select statement in RFC_READ TABLE FM

    Dear All,
       I have copied the standard FM RFC_READ_TABLE to incorporate the customer needs. Below is the select query which I have written in this FM.
    SELECT (po_search_text-column_text) INTO <wa> FROM ekko
          INNER JOIN ekpo ON ekko~ebeln = ekpo~ebeln
          INNER JOIN eket ON ekpo~ebeln = eket~ebeln AND ekpo~ebelp = eket~ebelp
          INNER JOIN lfa1 ON ekko~lifnr = lfa1~lifnr
          INNER JOIN lfm1 ON ekko~lifnr = lfm1~lifnr AND ekko~ekorg = lfm1~ekorg
          INNER JOIN lfb1 ON ekko~lifnr = lfb1~lifnr AND ekko~bukrs = lfb1~bukrs
          INNER JOIN t024 ON ekko~ekgrp = t024~ekgrp
          INNER JOIN zatscsng_status ON eket~ebeln = zatscsng_status~po_number
          AND   eket~ebelp = zatscsng_status~po_line
          AND   eket~etenr = zatscsng_status~po_sched_line
          INNER JOIN adrc ON zatscsng_status~delivery_addr = adrc~addrnumber
          WHERE (po_search_text-cond_text)
          ORDER BY (po_search_text-sort_text).
    Here, posearch_text-column_text_ will have the fields to be selected at runtime and posearch_text-cond_text_ is the where condition. It is running fine in this case.
    But when I try to select Item Category ( EKPO-PSTYP), if data is present for this category, it is returning the values but if data is not there for the particular item category in the where clause, it is giving a RUNTIME ERROR at the select statement.
    Here is the ERROR ANALYSIS:
    An exception occurred that is explained in detail below.
    The exception, which is assigned to class 'CX_SY_DYNAMIC_OSQL_SEMANTICS', 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 current ABAP program has tried to execute an Open SQL statement
    which contains a WHERE, ON or HAVING condition with a dynamic part.
    The part of the WHERE, ON or HAVING condition specified at runtime in
    a field or an internal table, contains the invalid value "<L_LINE>-PSTYP".
    Edited by: Rob Burbank on Mar 17, 2010 5:09 PM

    Now that's what I call a join statement...
    You probably have a bug in how you build po_search_text-cond_text, the content must be a syntactically correct where clause. It seems that in your example there is just "<L_LINE>-PSTYP" without a condition, so try omitting it altogether.
    Debug the content of po_search_text-cond_text before it hits the select statement.
    Thomas

  • Dynamic SELECT statement causing CX_SY_DYNAMIC_OSQL_SEMANTICS error.

    Hello Gurus,
    We have a dynamic SELECT statement in our BW Update Rules where the the Selection Fields are populated at run-time and so are the look-up target and also the WHERE clause. The code basically looks like below:
              SELECT (lt_select_flds)
                FROM (lf_tab_name)
                INTO CORRESPONDING FIELDS OF TABLE <lt_data_tab>
                FOR ALL ENTRIES IN <lt_source_data>
                WHERE (lf_where).
    In this instance, we are selecting 5 fields from Customer Master Data and the WHERE condition for this instance of the run is as below:
    WHERE: DIVISION = <lt_source_data>-DIVISION AND DISTR_CHAN = <lt_source_data>-DISTR_CHAN AND SALESORG = <lt_source_data>-SALESORG AND CUST_SALES = <lt_source_data>-SOLD_TO AND OBJVERS = 'A'
    This code was working fine till yesterday when we encountered serious performance problems and the Basis team had to do some changes at the DB level [Oracle]. Ever since, when we execute our data load, we get the CX_SY_DYNAMIC_OSQL_SEMANTICS.
    Is setting changes at the Oracle level cause issues with how the data is being read at the DB. If yes, can you suggest what can we do to this code to get is working correctly [in case Basis can't revert back their changes]?
    Would appreciate any help we can get here.

    You don't understand - this error comes up when we run specific BEx queries.  It was working yesterday, but today it is not.  Our support package did not change from yesterday.  We did not apply any OSSnotes.
    We are however doing pre-prepare on our Prod system.
    The temporary table is used to store SIDs for use in the join.  the table exists in the dictionary, but not at an Oracle level.

  • Urgent, SELECT statement results in error

    hi all, this is very urgent, could you guys have a look at my SELECT statement?
      SELECT vk~kunnr         "customer no
              vk~vbeln         "sales order no
              vk~audat         "date
              vk~vbtyp         "SD DOCUMENT CATEGORY
              vk~knumv         "lwk
              vp~kwmeng        "qty
              vp~matnr         "material no
              vp~posnr         "LINE ITEM
              vd~bstkd         "PURCHASE ORDER NO
    *          kv~kwert         "lwk
              FROM  vbak AS vk
              INNER JOIN vbap AS vp
              ON vk~vbeln = vp~vbeln
              INNER JOIN vbkd AS vd
              ON vk~vbeln = vd~vbeln
    *          INNER JOIN konv AS kv
    *          ON kv~knumv = vk~knumv
              INTO CORRESPONDING FIELDS OF TABLE it_so
              WHERE vk~vkorg IN s_vkorg
              AND vk~audat IN s_date
              AND vk~kunnr IN s_kunnr
              AND vp~matnr IN s_matnr
              AND vd~bstkd IN s_bstkd
              AND vk~vbeln IN s_vbeln
    *          AND kv~kschl = 'ZP00'
              AND vk~vbtyp = 'C'.
    The commented lines are the new additions that i want to add to the SELECT statement. But when i un-comment them, i get an error while activating my program. Error is as follows:
    For pooled tables, cluster tables, and project views, JOIN is not allowed: "KONV".
    Is there a way i can go around it?

    Hi,
    look at this SAP note : 550043
    Symptom
    KEPM: dump 'MESSAGE_TYPE_X' during automatic planning method execution.
    Other terms
    KEPM MESSAGE_TYPE_X transform characteristic value
    Reason and Prerequisites
    This note is related only to cases, if dump 'MESSAGE_TYPE_X' is raising
    during execution of planning method, for which is possible to define
    transformation of characteristics values i.e. Copy, Forecast, Top-Down
    distribution, Ratios and Customer Enhancement.
    Dump is raising in case, if there was defined transformation of char.
    values in parameter set definition for some characteristic. Later on,
    this characteristic was removed from planning level definition but
    characteristic wasn't removed from relevant customizing of transform
    characteristic values before.
    Solution
    Please apply attached program correction.
    Regards,
    GSR.

  • Error in select statement

    Hello experts,
    i am quite new to forms and i am trying to do a select based on a condition. but its giving me and error
    post_query
    begin
    if :EFT_EXCLUSION.retailer_num <> null and :EFT_EXCLUSION.bank_acct = null
    select retailer_name
    into :EFT_EXCLUSION.retailer_name
    from retailers
    where retailer_num = :EFT_EXCLUSION.retailer_num;
    else if :EFT_EXCLUSION.bank_acct <> null
    select retailer_name
    into :EFT_EXCLUSION.retailer_name
    from retailers
    where bank_account_id = :EFT_EXCLUSION.bank_acct;
    end if
    end;error
    encountering the symbol SELECT when expecting one of the following
    i'm not too sure if my code is ok

    if :EFT_EXCLUSION.retailer_num is NULL and :EFT_EXCLUSION.period_id is NULL thenTry to check you this statement i mean THAT :EFT_EXCLUSION.retailer_num and :EFT_EXCLUSION.period_id are NULL or not to make sure create one message before calling this procedure to check the values of these fields.
    EFT_EXCLUSION.SAVEAlso confirm the name of this button i mean block and button name are same as you defined.
    For the debug create message before calling this procedure like
    MESSAGE(':EFT_EXCLUSION.retailer_num='||:EFT_EXCLUSION.retailer_num||' :EFT_EXCLUSION.period_id='|| :EFT_EXCLUSION.period_id);
    MESSAGE(':EFT_EXCLUSION.retailer_num='||:EFT_EXCLUSION.retailer_num||' :EFT_EXCLUSION.period_id='|| :EFT_EXCLUSION.period_id); place these lines before calling the procedure you created so it will be sure that both the fields are NULL and for the items ENABLE/DISABLE we use the same code which i gave you before. Problem is in you IF condition.
    -Ammad

  • Error by using database procedure in select statement

    hi ,
    I have built a database procedure having one parameter with in out varchar type. that return value with some addition.
    i am using it with some column in select statement only for display purpuses but i am facing error by doing that in select statement. that procedure is working well with bind variable but not with select statement.
    plz help me how i can use a procedure in select statement. or can i do it or not.

    plz help me how i can use a procedure in select statement. or can i do it or not.A workaround could be to create a wrapper function for your procedure. One that only passes the input parameters and returns the output parameter.
    The simply call this function in your select which internally calls the procedure.

  • Getting error after putting variable in select statement

    Hi All,
    Kindly help me with Pl/sql code
    here i'm trying to put variable in select statement ....
    I successfully put the Yr and Mnth ..but getting error for loop variable "i"
    Here i'm getting error that too because of " i" only-->TRIM(UPPER(TO_CHAR(TO_DATE(i||'-'||Mnth||'-'||Yr,'dd-Mon-YYYY'),'DAY')))
    Please find the full code below.
    Declare
    Yr number not null:=2010;
    Mnth varchar2(20) not null:='Jun';
    v_val number:=0;
    begin
    for i in 1..2 loop
    case i
    SELECT count(*) into v_val
    FROM DUAL
    WHERE TRIM(UPPER(TO_CHAR(TO_DATE(i||'-'||Mnth||'-'||Yr,'dd-Mon-YYYY'),'DAY')))
    in (UPPER('Monday'),UPPER('Tuesday'),UPPER('WEDNESDAY'),UPPER('THURSDAY'),UPPER('friday'))
    end case;
    end loop;
    end;

    Declare
      Yr number not null:=2010;
      Mnth varchar2(20) not null:='Jun';
      v_val number:=0;
    begin
      for i in 1..2 loop
      SELECT count(*) into v_val
      FROM DUAL
      WHERE TRIM(UPPER(TO_CHAR(TO_DATE(i||'-'||Mnth||'-'||Yr,'dd-Mon-YYYY'),'DAY')))
      in (UPPER('Monday'),UPPER('Tuesday'),UPPER('WEDNESDAY'),UPPER('THURSDAY'),UPPER('friday'));
    end loop;
    end;

Maybe you are looking for