Skip to Content
0
Jul 19, 2007 at 06:03 AM

Updation of Primary Key field in HR Tables (PA2001 and PA2002) - Urgent

246 Views

Can anyone please tell me how to update a primary key field in HR Tables (PA2001 and PA2002).

I need to update sprps field in both the tables. I used HR_Infotype_Operation function module, but still it is not updating the field.

Pls find the following code snippet for the table PA2001 and let me know if any discrepancies :

TABLES: pa2001.

DATA: it_pa2001 TYPE TABLE OF pa2001,

wa_pa2001 LIKE LINE OF it_pa2001,

DATA: date TYPE d.

date = sy-datum - 100.

SELECT pernr sprps begda endda FROM PA2001 INTO CORRESPONDING FIELDS OF TABLE it_pa2001

WHERE begda BETWEEN date and sy-datum.

WRITE:/.

WRITE:/ 'PA 2001 Records'.

if sy-subrc <> 0.

WRITE:/ 'No Data Exists'.

else.

LOOP AT it_pa2001 INTO wa_pa2001.

WRITE:/ wa_pa2001-pernr, wa_pa2001-sprps, wa_pa2001-begda, wa_pa2001-endda.

ENDLOOP.

endif.

LOOP AT it_pa2001 INTO wa_pa2001.

wa_pa2001-sprps = 'X'.

CALL FUNCTION 'HR_INFOTYPE_OPERATION'

EXPORTING

infty = '2001'

number = wa_pa2001-pernr

  • SUBTYPE =

  • OBJECTID =

  • LOCKINDICATOR =

  • VALIDITYEND =

  • VALIDITYBEGIN =

  • RECORDNUMBER =

record = wa_pa2001

operation = 'MOD'

  • TCLAS = 'A'

  • DIALOG_MODE = '0'

  • NOCOMMIT =

  • VIEW_IDENTIFIER =

  • SECONDARY_RECORD =

  • IMPORTING

  • RETURN =

  • KEY =

.

ENDLOOP.

if sy-subrc = 0.

write:/ 'SY-subrc is zero'.

write:/ ' Rows modified = ', sy-dbcnt.

else.

write:/ 'No Record(s) updated'.

endif.

commit work.

WRITE: / 'Updated Records in the Internal Table IT_PA2001'.

SELECT pernr sprps begda endda FROM PA2001 INTO CORRESPONDING FIELDS OF TABLE it_pa2001

WHERE begda BETWEEN date AND sy-datum..

LOOP AT it_pa2001 INTO wa_pa2001.

WRITE:/ wa_pa2001-pernr, wa_pa2001-sprps, wa_pa2001-begda, wa_pa2001-endda.

ENDLOOP.