cancel
Showing results for 
Search instead for 
Did you mean: 

FM for assigning Employees to Work center (Assignments to HRMS)

tursko
Participant
983

Is there a standard function module or class method I can use to assign Employees to a Work Center? (Work center HR assignment)

Responding to Oscar Del Castillo: Yes that's exactly what I mean. Like going to CR02 -> Scheduling -> Capacity -> HRMS. I want to be able to do this programmatically.

Oscar_DC
Active Contributor

I'm interested in this too and don't know the answer. Just to clarify, are you talking about how to assign a personnel # to the capacity of the work center?

View Entire Topic
tursko
Participant

The function module to do this is ‘CR_CAPACITY_PERSON_REL_WRITE’. You need to know the Capacity ID of the Work Center and the Personnel Number of the user you want to assign.

Here is an example of the FM below:

DATA: lv_capacity_id type kapid.

" Get Work Center Capacity ID
select single kapid
  from crhd
  into lv_capacity_id
  where werks = 'AB01' " Plant
  and arbpl = '01AB'. " Work Center


" Assign resource (person) to a Work Center
call function 'CR_CAPACITY_PERSON_REL_WRITE'
  exporting
    in_datum_bis          = sy-datum " End Date
    in_datum_von          = sy-datum " Start Date
    in_kapid              = lv_capacity_id " Capacity ID
    in_otype              = 'P' " Object Type
    in_pernr              = '00011122' " Personnel Number
    vtask                 = 'S' " Update (B=Buffer,D=Online,V=Update,S=Sync)
    commit_flg            = 'X'
  exceptions
    capacity_not_existent = 1
    insert_error          = 2
    no_integration        = 3
    person_not_activ      = 4
    relation_existent     = 5
    time_range_incorrect  = 6
    others                = 7.
if sy-subrc <> 0.
* Implement suitable error handling here
endif
Oscar_DC
Active Contributor

Thanks for closing your question. This will help me out too.