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.
 

posted on 2007-08-29 13:58  毛小娃  阅读(152)  评论(0编辑  收藏  举报

导航