莫西西小盆友吧 关注:35贴子:3,003
  • 1回复贴,共1
2、数据库表更新用TRY.的时候,语法如下
DATA: lcx_error TYPE REF TO cx_root.
DATA: err_text type c length 1000.
try.
xxxxxxxxxxxxxxxxx "更新数据库语句
CATCH cx_sy_open_sql_db INTO lcx_error.
err_text = lcx_error->get_text( ).
endtry.
if err_text is initial.
commit work.
else.
rollback work.
endif.
err_text就是try失败的原因描述


IP属地:广东来自iPhone客户端1楼2021-06-29 11:14回复
    1.数据库异常:
      DATA: lcx_error TYPE REF TO cx_root. "cx_sy_sql_error . "cx_sy_open_sql_db.
      DATA i_tab LIKE TABLE OF spfli WITH HEADER LINE.
      DATA err_text TYPE c LENGTH 1000.
    TRY.
       INSERT spfli FROM TABLE i_tab.
       CATCH cx_sy_open_sql_db INTO lcx_error.
       err_text = lcx_error->get_text( ). "得到错误信息
       sy-subrc = 4. "改变系统变量
       ENDTRY.
    IF sy-subrc <> 0.
       WRITE :/ '数据更新失败!'.
       WRITE err_text.
       ROLLBACK WORK.
       ELSE.
       WRITE :/ '数据更新成功!'.
       COMMIT WORK.
       ENDIF.


    IP属地:广东来自iPhone客户端2楼2021-06-29 11:17
    回复