Текущее время: Вт, июл 22 2025, 21:16

Часовой пояс: UTC + 3 часа


Правила форума


ВНИМАНИЕ!

Вопросы по SAP Query и Quick View - сюда



Начать новую тему Ответить на тему  [ Сообщений: 9 ] 
Автор Сообщение
 Заголовок сообщения: Обработка ошибки
СообщениеДобавлено: Чт, июл 15 2010, 15:03 
Младший специалист
Младший специалист

Зарегистрирован:
Ср, янв 21 2009, 10:13
Сообщения: 57
Пол: Мужской
Мне необходимо программно обработать ошибки после выполнения выборки
Code:
execute sql.
    {....}
  endexec.


Пробовал так.
Code:
  catch system-exceptions
     others = 4.
   EXEC SQL.
     select field1, field2
       into :field
       from vi.tab1
       where
         code = :codn
   ENDEXEC.
   endcatch.

Но отчет все равно вываливается в дамп.
Можно ли это реализовать в версии 4.6С?
Вся суть именно программно обработать ошибку.
P.S. я так понял в 4.6С нет try ... catch.


Принять этот ответ
Вернуться к началу
 Профиль  
 
 Заголовок сообщения: Re: Обработка ошибки
СообщениеДобавлено: Пн, июл 19 2010, 20:41 
Президент
Президент

Зарегистрирован:
Пт, апр 28 2006, 22:39
Сообщения: 2514
Откуда: North Taxolina, USA
Пол: Женский
Почитайте Help (F1) на команду EXEC SQL в вашем релизе. Там есть список catchable exceptions и non-catchable exceptions.

Цитата:
Before release 6.10, exception situations recognized by the system, whose causes could be treated in the program, triggered catchable runtime errors, which are treated with CATCH SYSTEM-EXCEPTIONS. All exception situations. whose causes cannot be treated in the program triggered non-catchable runtime errors.

_________________
"One of the symptoms of an approaching nervous breakdown is the belief that one's work is terribly important." Bertrand Russell


Принять этот ответ
Вернуться к началу
 Профиль  
 
 Заголовок сообщения: Re: Обработка ошибки
СообщениеДобавлено: Вт, июл 20 2010, 15:08 
Младший специалист
Младший специалист

Зарегистрирован:
Ср, янв 21 2009, 10:13
Сообщения: 57
Пол: Мужской
Jelena написала:
Почитайте Help (F1) на команду EXEC SQL в вашем релизе. Там есть список catchable exceptions и non-catchable exception.

Я еще раз прочитал хэлп по Exec SQL. Там вообще нет таких слов как 'exceptions'.
Такое ощущение, что технология исключительных ситуаций в версии 4.6С повсеместно не используется (как в данном случае).


Принять этот ответ
Вернуться к началу
 Профиль  
 
 Заголовок сообщения: Re: Обработка ошибки
СообщениеДобавлено: Вт, июл 20 2010, 15:17 
Гуру-эксперт
Гуру-эксперт

Зарегистрирован:
Вт, сен 07 2004, 17:47
Сообщения: 2988
ulmichael написал:
Я еще раз прочитал хэлп по Exec SQL. Там вообще нет таких слов как 'exceptions'.
Такое ощущение, что технология исключительных ситуаций в версии 4.6С повсеместно не используется (как в данном случае).

Какой дамп? Приведите его.
Там обычно, насколько помню, пишется - перехватываемое исключение или окончательное и бесповоротное.

_________________
"После" - не значит "вследствие"


Принять этот ответ
Вернуться к началу
 Профиль  
 
 Заголовок сообщения: Re: Обработка ошибки
СообщениеДобавлено: Вт, июл 20 2010, 15:35 
Гуру-эксперт
Гуру-эксперт
Аватара пользователя

Зарегистрирован:
Чт, ноя 11 2004, 16:25
Сообщения: 3109
Пол: Мужской
sy-uname написал(а):
ulmichael написал:
Я еще раз прочитал хэлп по Exec SQL. Там вообще нет таких слов как 'exceptions'.
Такое ощущение, что технология исключительных ситуаций в версии 4.6С повсеместно не используется (как в данном случае).

Какой дамп? Приведите его.
Там обычно, насколько помню, пишется - перехватываемое исключение или окончательное и бесповоротное.

+1, точно, пишется в заголовке дампа, если есть...
ulmichael, к сожалению нет под рукой системы 46с, но судя по хелпу, технология исключительных ситуаций в 46с есть, и она единственная CATCH SYSTEM-EXCEPTIONS ... ENDCATCH.
TRY ... ENDTRY начинается с релиза 610.
А валится у Вас в дамп, потому что Вы неправильно используете catch system-exceptions, others = 4, такого исключения нету у EXEC SQL, а перехват до релиза 610 работает только для объявленных исключений, имхо...


Принять этот ответ
Вернуться к началу
 Профиль  
 
 Заголовок сообщения: Re: Обработка ошибки
СообщениеДобавлено: Вт, июл 20 2010, 15:41 
Менеджер
Менеджер

Зарегистрирован:
Чт, янв 20 2005, 08:34
Сообщения: 573
Пол: Мужской
ulmichael написал:
P.S. я так понял в 4.6С нет try ... catch.


Все верно. Там нет try.
Вот хелп по EXEC в 4.6С:
Code:
EXEC


Basic form
EXEC SQL.


Addition: ... PERFORMING form



Effect
Executes the Native SQL statements enclosed between EXEC SQL and ENDEXEC statements. Unlike Open SQL Native SQL statements can address tables that are not declared in the ABAP Dictionary.



Example
Creating the Table AVERI_CLNT:



EXEC SQL.
  CREATE TABLE AVERI_CLNT (
         CLIENT   CHAR(3)  NOT NULL,
         ARG1     CHAR(3)  NOT NULL,
         ARG2     CHAR(3)  NOT NULL,
         FUNCTION CHAR(10) NOT NULL,
         PRIMARY KEY (CLIENT, ARG1, ARG2)
                          )
ENDEXEC.



In a Native SQL statement, data is passed between the ABAP program and the database using host variables. A host variable is an ABAP variable that is identified as such in the Native SQL statement by a preceding colon (:).



Example
Displaying an extract from the table AVERI_CLNT:



DATA: F1(3), F2(3), F3(3).
F3 = ' 1 '.
EXEC SQL.
  SELECT CLIENT, ARG1 INTO :F1, :F2 FROM AVERI_CLNT
         WHERE ARG2 = :F3
ENDEXEC.
WRITE: / F1, F2.



To simplify the form of the INTO lists in the SELECT statement, you can, as in Open SQL, specify a single structure as the target area.



Example
Displaying an Extract from the Table AVERI_CLNT:



DATA: BEGIN OF WA,
        CLIENT(3), ARG1(3), ARG2(3),
      END OF WA.
DATA  F3(3).
F3 = ' 1 '.
EXEC SQL.
  SELECT CLIENT, ARG1 INTO :WA FROM AVERI_CLNT
         WHERE ARG2 = :F3
ENDEXEC.
WRITE: / WA-CLIENT, WA-ARG1.



Native SQL supports the directly-executable commands of your underlying database system. There are other special commands that you can use after the EXEC SQL statement for cursor handling, stored procedures (procedures stored in the database) and connections to other databases.


Cursor Processing


Cursor processing in Native SQL is similar to that in Open SQL. Use the OPEN c FOR SELECT ... command to open a cursor, and the FETCH NEXT c INTO ... to read a line into a given target area. The CLOSE c command closes the cursor. As in the SELECT statement, the target area can be either a list of variables or a structure. FETCH NEXT sets SY-SUBRC to 4 if there are no more records to read. You can also specify the name of the cursor as a host variable.


Example
Cursor Processing with Table AVERI_CLNT:



DATA: F1(3), F2(3), F3(3).
F3 = ' 1 '.
EXEC SQL.
  OPEN C FOR
    SELECT CLIENT, ARG1 FROM AVERI_CLNT
        WHERE ARG2 = :F3
ENDEXEC.
DO.
  EXEC SQL.
    FETCH NEXT C INTO :F1, :F2
  ENDEXEC.
  IF SY-SUBRC <> 0.
    EXIT.
  ENDIF.
  WRITE: / F1, F2.
ENDDO.
EXEC SQL.
  CLOSE C
ENDEXEC.



Stored Procedures


The command EXECUTE PROCEDURE proc allows you to call a procedure stored in the database. When you call it, you can pass a list of host variables as parameters. When yuo call a procedure, you must specify for each parameter whether it is an input parameter ( IN), output parameter (OUT) or changing parameter (INOUT).


Example
Calling a Procedure:



DATA Y TYPE I VALUE 300.
DATA Z TYPE I.

EXEC SQL.
  INSERT INTO AVERI_CLNT (CLIENT, ARG1, ARG2, ARG3)
         VALUES ('000', 9, 2, 47)
ENDEXEC.

EXEC SQL.
  CREATE OR REPLACE PROCEDURE PROC1 (X IN NUMBER) IS
    BEGIN
      UPDATE AVERI_CLNT SET ARG3 = ARG3 + X;
    END;
ENDEXEC.
EXEC SQL.
  CREATE OR REPLACE PROCEDURE PROC2 (X IN NUMBER, Y OUT NUMBER) IS
    BEGIN
      SELECT ARG3 INTO Y
        FROM AVERI_CLNT
        WHERE CLIENT = '000' AND ARG1 = 9 AND ARG2 = 2;
      UPDATE AVERI_CLNT SET ARG3 = ARG3 - X;
    END;
ENDEXEC.
EXEC SQL.
  EXECUTE PROCEDURE PROC1 ( IN :Y )
ENDEXEC.
EXEC SQL.
  EXECUTE PROCEDURE PROC2 ( IN :Y, OUT :Z )
ENDEXEC.
IF SY-SUBRC <> 0 OR Z <> 347.
  WRITE: / 'Wrong result for EXECUTE PROCEDURE:', Z.
ENDIF.
EXEC SQL.
  DROP PROCEDURE PROC1
ENDEXEC.
EXEC SQL.
  DROP PROCEDURE PROC2
ENDEXEC.


Multi-Connect


When you start the R/3 System, an initial connection is opened to the R/3 database. The multi-connect allows you to open other connections to other databases of the same, or a different, type. The only condition is that the database must be supported by SAP. When you activate a database connection, the subsequent Native SQL statements are executed by this database system. Each connection that you want to address using multi connect must be described by a record in the table DBCON.

You open a connection with the command CONNECT TO dbs, where dbs is the name of the connection as specified in the table DBCON. You can specify the name either as a host variable or a literal. You can use the AS alias addition to specify an alias name for the connection. This is necessary if you want to open more than one connection to the same database. To make connection dbs the current connection, use the statement SET CONNECTION dbs. All subsequent Native SQL statements are then processed by this connection. SET CONNECTION DEFAULT resets the initial connection. To close the current connection, use the DISCONNECT command.



Notes
Unlike in Open SQL, the client field in Native SQL is treated like any other field, and must therefore be listed explicitly in statements.



You cannot perform reliable authorization checks using EXEC SQL. You should implement them at program level instead.



When you start the R/3 System, an automatic CONNECT to the current database occurs. You do not need to execute this CONNECT explicitly.



You can (but do not have to) end a Native SQL statement with a semicolon (";"). You must never conclude a Native SQL statement with a period (".").



Some database systems allow you to differentiate between upper and lowercase in table and field names. If you want to use this, you must ensure that you write the names correctly. To use lowercase letters in names in the ABAP Editor, you must set the "Upper-/lowercase" attribute in the program attributes.



Since there are no arrays in ABAP, you cannot use array operations in Native SQL. If the result of a SELECT command is a table, you can read it into your program either using the Native SQL FETCH command, or the ... PERFORMING form addition.



The " character in Native SQL does not introduce a comment to the end of the line as it does in an ABAP program.



Native SQL allows you to use database commits to avoid locking conflicts with read access.



If you want to select into a work area in a SELECT statement, and not into a list of host variables, the host variable must be a structure. If you cannot determine statically whether the target area is a structure at runtime (for example, an untyped field symbol or formal parameter), the statement may cause a runtime error, or only the first column may be placed into the target field. This depends on the database system that you are using. In this case, you can use INTO STRUCTURE to ensure that the target area really is a structure at runtime.



Addition
... PERFORMING form


This addition is not allowed in an ABAP Objects context. See Subroutine Calls Not Allowed in EXEC SQL.

Effect
If the result of a SELECT command is a table, the system reads the result set line by line in a loop. For each line, the system calls the subroutine form . You can terminate the loop using the EXIT FROM SQL statement in the subroutine form. If the result of the selection is a single record, form is only called once.



Example
Displaying a Selection From Table AVERI_CLNT:



DATA: F1(3), F2(3), F3(3).

F3 = ' 1 '.
EXEC SQL PERFORMING WRITE_AVERI_CLNT.
  SELECT CLIENT, ARG1 INTO :F1, :F2 FROM AVERI_CLNT
         WHERE ARG2 = :F3
ENDEXEC.

FORM WRITE_AVERI_CLNT.
  WRITE: / F1, F2.
ENDFORM.



Note
You can only use this addition in a SELECT command.



Related
SELECT, INSERT, UPDATE, MODIFY, DELETE, OPEN CURSOR, FETCH, CLOSE CURSOR, COMMIT WORK und ROLLBACK WORK.




Additional help
Native SQL

_________________
Волю в кулак, мышцы в узду, работай себе и не ахай!


Принять этот ответ
Вернуться к началу
 Профиль  
 
 Заголовок сообщения: Re: Обработка ошибки
СообщениеДобавлено: Вт, июл 20 2010, 16:31 
Младший специалист
Младший специалист

Зарегистрирован:
Ср, янв 21 2009, 10:13
Сообщения: 57
Пол: Мужской
Code:
ABAP-динамич. ошибка   DBIF_DSQL2_SQL_ERROR                                 
       Возникла:       20.07.2010 в  17:03:30                               

SQL error 904 occurred when executing EXEC SQL.                             
                                                                           
Что произошло?                                                             
                                                                           
One of the columns addressed in a table or view                             
does not exist in the database.                                             
table) exists in the ABAP/4 Dictionary, but not in                         
the database.                                                               
                                                                           
The error occurred in the current database connection "ORANT".             
                                                                           
Что Вы можете сделать?                                                     
                                                                           
If this error occurred in ABAP/4 Open SQL, there is an inconsistency       
between the ABAP/4 Dictionary and the database.                             
You can resolve this by converting the table in the database               
to the definition in the ABAP/4 Dictionary.                                 
To do this, call Transaction SE11 and then select                           
Utilities   > Database utility.                                             
Note the actions and input that caused the error.                           
                                                                           
Inform your SAP system administrator.                                       
                                                                           
You can print out this message by choosing "Print". Transaction ST22       
allows you to display and manage termination messages, including keeping   
them beyond their normal deletion date.                                   
                                                                           
Анализ ошибки                                                               
                                                                           
Указания по устранению ошибки                                               
                                                                           
Database error text........: "ORA-00904: "TTT": invalid identifier#"       
Triggering SQL statement...: "select id, ttt from vi.fi_cur where code = ? "
Internal call code.........: "[DBDS/NEW DSQL]"                             
Please check the entries in the system log (Transaction SM21).             



Дамп. Поля ttt нет в таблице. Это я специально указал на не существующее поле, чтобы возникла ошбка.

Пробовал так
Code:
catch system-exceptions DBIF_DSQL2_SQL_ERROR = 2
       others = 4.

    EXEC SQL.
       ...
   ENDEXEC.

   endcatch.
   if sy-subrc = 2.
      mess...
   endif.


Ругается...
Unable to interpret "SYSTEM-EXCEPTIONS". Possible cause of error: Incorrect spelling or comma error.
Наверное, не знает такого исключения.


Принять этот ответ
Вернуться к началу
 Профиль  
 
 Заголовок сообщения: Re: Обработка ошибки
СообщениеДобавлено: Вт, июл 20 2010, 19:25 
Президент
Президент

Зарегистрирован:
Пт, апр 28 2006, 22:39
Сообщения: 2514
Откуда: North Taxolina, USA
Пол: Женский
В 6.0 DBIF_DSQL2_SQL_ERROR указано как catchable, но, судя по всему, это только через TRY... CATCH. В "старом" списке (Catchable Runtime Errors) не нашла вообще ничего для Native SQL. Похоже облом...

_________________
"One of the symptoms of an approaching nervous breakdown is the belief that one's work is terribly important." Bertrand Russell


Принять этот ответ
Вернуться к началу
 Профиль  
 
 Заголовок сообщения: Re: Обработка ошибки
СообщениеДобавлено: Ср, июл 21 2010, 08:08 
Младший специалист
Младший специалист

Зарегистрирован:
Ср, янв 21 2009, 10:13
Сообщения: 57
Пол: Мужской
Всем большое спасибо за советы!

Будем знать.


Принять этот ответ
Вернуться к началу
 Профиль  
 
Показать сообщения за:  Поле сортировки  
Начать новую тему Ответить на тему  [ Сообщений: 9 ] 

Часовой пояс: UTC + 3 часа


Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей


Вы не можете начинать темы
Вы не можете отвечать на сообщения
Вы не можете редактировать свои сообщения
Вы не можете удалять свои сообщения
Вы не можете добавлять вложения

Найти:
Перейти:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Русская поддержка phpBB