Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

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

Former Member
0 Kudos
713

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.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
377

Hi,

Please do not do that. You are asking for big trouble if you proceed. Do not ever change the primary key of a standard table.

<b>Reward points</b>

Regards

7 REPLIES 7

Former Member
0 Kudos
378

Hi,

Please do not do that. You are asking for big trouble if you proceed. Do not ever change the primary key of a standard table.

<b>Reward points</b>

Regards

0 Kudos
377

Thanks Kiran.

But I need to change this field as we need to lock the records, as soon as the employee fills his/her time sheets which will be sent for HR Payroll, later on.

When I am updating directly the field the database table PA2001, its not updating but for table PA2002, only few records are being updated.

Is there any other alternative for this problem?

Pls reply.

Thanks,

Harish

0 Kudos
377

Hi,

you should create a new table ZXXXXX with all keys of Youre reqired fields .

<b>Reward points</b>

Regards

0 Kudos
377

thanks for ur reply,

Can u tell me how this Lock indicator is set (Functionally) in the standard table.

as this indiactor is checked while payroll is run , so what action sets this indiactor.

amit_khare
Active Contributor
0 Kudos
377

Instead of this FM, refer this BAPI -

BAPI_ABSENCE_CHANGE

Regards,

Amit

Reward all helpful replies.

0 Kudos
377

But Amit, I need to change the field SPRPS. How can I do it when I am passing it to the function module <b>BAPI_ABSENCE_CHANGE</b>.

Could anyone pls provide me with a sample code snippet.

Thanks,

Harish

0 Kudos
377

That field you need to change manually, by reading the record and modifying the field. We had a similar requirement and none of the FM worked for that, even HR_INFOTYPE_OPERATION has ACTION as EDQ for lock/unlock.

Regards,

Amit