1、通过函数操作。
INFOTYPES: 0001. DATA: ZRETURN TYPE BAPIRETURN1, ZPAKEY TYPE BAPIPAKEY. GET PERNR. LOOP AT P0001 WHERE ... *锁定人员编号 CALL FUNCTION ‘BAPI_EMPLOYEE_ENQUEUE‘ EXPORTING NUMBER = PERNR-PERNR * IMPORTING * RETURN = . ... *新建信息类型 CALL FUNCTION ‘HR_INFOTYPE_OPERATION‘ EXPORTING INFTY = ‘0001‘ NUMBER = P0001-PERNR * SUBTYPE = ‘ ‘ * OBJECTID = LOCKINDICATOR = P0001-SPRPS VALIDITYEND = P0001-ENDDA VALIDITYBEGIN = P0001-BEGDA RECORDNUMBER = P0001-SEQNR RECORD = P0001 OPERATION = ‘INS‘ * TCLAS = ‘A‘ DIALOG_MODE = ‘1‘ * NOCOMMIT = * VIEW_IDENTIFIER = * SECONDARY_RECORD = IMPORTING RETURN = ZRETURN KEY = ZPAKEY . COMMIT WORK.
*解除锁定 CALL FUNCTION ‘BAPI_EMPLOYEE_DEQUEUE‘ EXPORTING NUMBER = PERNR-PERNR * IMPORTING * RETURN = . ENDLOOP.
OPERATION: MOD(change) INS(insert) COPY(copy) DEL(delete) LIS9(delimit)
2、更新数据库。
PARAMETERS: P_NATIO_O LIKE P0002-NATIO DEFAULT ‘DE‘, P_NATIO_N LIKE P0002-NATIO DEFAULT ‘D‘. UPDATE PA0002 SET NATIO = P_NATIO_N WHERE PERNR = P0002-PERNR AND NATIO = P_NATIO_O. IF SY-SUBRC = 0. ENDIF.
原文:http://www.cnblogs.com/xher/p/5719306.html