HR--上载信息类型的长文本的样例代码

此代码用于维护2002信息类型数据和长文本

TYPES BEGIN OF text_version.
TYPES nummer TYPE x.
TYPES END OF text_version.

DATA: PERSONALDATAKEY LIKE BAPIPAKEY.
DATA: RETURN LIKE BAPIRETURN1.
DATA: P2002 LIKE P2002.
DATA: PSKEY TYPE PSKEY.
DATA: IT_TEXT TYPE HRPAD_TEXT_TAB .
DATA: LINE TYPE HRPAD_TEXT.
DATA: version TYPE text_version.
DATA: pcl1 TYPE pcl1.
Input Parameters:
PARAMETERS: PERNR LIKE PA2002-PERNR DEFAULT '1004511',
AWART LIKE PA2002-AWART DEFAULT 'LW',
BEGDA LIKE PA2002-BEGDA DEFAULT SY-DATUM,
ENDDA LIKE PA2002-ENDDA DEFAULT SY-DATUM,
BEGUZ LIKE PA2002-BEGUZ,
ENDUZ LIKE PA2002-ENDUZ.
Lock Personnel Number:
START-OF-SELECTION.

CALL FUNCTION 'HR_EMPLOYEE_ENQUEUE'
EXPORTING
number = PERNR
IMPORTING
RETURN = RETURN.

IF RETURN-NUMBER IS NOT INITIAL.
EXIT.
ENDIF.
Insert infotype data:
* ADD DATA
CLEAR: P2002.
P2002-PERNR = PERNR.
P2002-SUBTY = AWART.
P2002-ENDDA = BEGDA.
P2002-BEGDA = BEGDA.
P2002-BEGUZ = BEGUZ.
P2002-ENDUZ = ENDUZ.
P2002-AWART = AWART.
P2002-ITXEX = 'X'.

* WRITE DATA
CLEAR: RETURN, PERSONALDATAKEY.
CALL FUNCTION 'HR_INFOTYPE_OPERATION'
EXPORTING
INFTY = '2002'
NUMBER = PERNR
SUBTYPE = AWART
VALIDITYEND = BEGDA
VALIDITYBEGIN = BEGDA
RECORD = P2002
OPERATION = 'INS'
NOCOMMIT = ''
TCLAS = 'A'
IMPORTING
RETURN = RETURN
KEY = PERSONALDATAKEY
EXCEPTIONS
OTHERS = 0.

IF RETURN-NUMBER IS INITIAL.
COMMIT WORK AND WAIT.
ELSE.
ROLLBACK WORK.
EXIT.
ENDIF.
Insert Maintain Text data:
* ADD DATA
CLEAR: PSKEY, IT_TEXT[].
pskey-pernr = PERNR.
pskey-infty = '2002'.
pskey-subty = AWART.
pskey-endda = BEGDA.
pskey-begda = ENDDA.
pskey-seqnr = PERSONALDATAKEY-RECORDNR.
version-nummer = '02'.

pcl1-histo = 'X'.
pcl1-uname = SY-UNAME.
pcl1-aedtm = SY-DATUM.


* ADD IT_TEXT DATA
CLEAR: LINE.
LINE = 'Sample text:'.
APPEND LINE TO IT_TEXT.

CLEAR: LINE.
LINE = 'Here you can store your information.'.
APPEND LINE TO IT_TEXT.

EXPORT
text-version FROM version
ptext FROM IT_TEXT
TO DATABASE pcl1(TX) ID pskey
FROM pcl1.
Unlock Personnel Number:
CALL FUNCTION 'HR_EMPLOYEE_DEQUEUE'
EXPORTING
number = PERNR
IMPORTING
RETURN = RETURN.
 

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值