DBCO:检查数据库是否连接
代码:
查询:
DATA: gv_dbs TYPE char30 VALUE 'XXXXXXXX'. "数据库连接名称
DATA:gt_ztclaim_2 TYPE TABLE OF ztclaim_2.
DATA:gs_ztclaim_2 TYPE ztclaim_2.
TRY.
EXEC SQL.
CONNECT TO :GV_DBS
ENDEXEC.
EXEC SQL PERFORMING frm_build_ztclaim_2.
SELECT *
INTO :gs_ztclaim_2
from ztclaim_2
ENDEXEC.
ENDTRY.
FORM frm_build_ztclaim_2.
IF gs_ztclaim_2 IS NOT INITIAL.
APPEND gs_ztclaim_2 TO gt_ztclaim_2.
ENDIF.
ENDFORM.
删除:
LOOP AT LT_DATA INTO DATA(LS_DATA).
READ TABLE gt_role INTO DATA(ls_role) WITH KEY personid_ext = ls_data-personid_ext
BINARY SEARCH.
IF sy-subrc EQ 0.
EXEC SQL.
DELETE from HCM_PA_EMP_ROLE
WHERE PERSONID_EXT = :ls_data-personid_ext
ENDEXEC.
ENDIF.
ENDLOOP.
增加:
EXEC SQL.
INSERT INTO HCM_PA_EMP_ROLE
(
PERSONID_EXT,
PERNR,
ASSIGN_PART,
JOB_INDICATOR,
PLANS,
ZJSBM,
ZJSMS,
APPROVER,
APPROVER_PLANS )
VALUES (
:LS_DATA-PERSONID_EXT,
:LS_DATA-PERNR:LV_PERNR_NULL,
:LS_DATA-ASSIGN_PART,
:LS_DATA-JOB_INDICATOR,
:LS_DATA-PLANS:LV_PLANS_NULL,
:LS_DATA-ZJSBM,
:LS_DATA-ZJSMS,
:LS_DATA-APPROVER,
:LS_DATA-APPROVER_PLANS:LV_APPROVER_PLANS_NULL )
ENDEXEC.
断开连接:
EXEC SQL.
ROLLBACK WORK.
DISCONNECT :gv_dbs
ENDEXEC.