Hi Gaurav
As Malgorzata stated, you should use the FM 'HR_INFOTYPE_OPERATION' to do personnel (PA) infotype operations. For organization part (PD), you can use 'RH_INSERT_INFTY' and other relevant FMs for deleting and updating.
Here is an example and some information that I wrote before about the subject:
DATA ls_data LIKE p0015 . DATA ls_return LIKE bapireturn1 . *--Fill "ls_data" as required here *- Be careful about the checks that will be done during * execution of the function module. The checks it will *do, will be more or less like when you insert the *record using the tcode "PA30". e.g. you must fill *obligatory fields CALL FUNCTION 'ENQUEUE_EPPRELE' EXPORTING mode_prel = 'E' mandt = sy-mandt pernr = ls_data-pernr infty = '0015' subty = '1650' endda = ls_data-endda begda = ls_data-begda _scope = '1' EXCEPTIONS foreign_lock = 1 system_failure = 2 OTHERS = 3. IF sy-subrc NE 0 . *... EXIT. ENDIF. CALL FUNCTION 'HR_INFOTYPE_OPERATION' EXPORTING infty = '0015' number = ls_data-pernr subtype = ls_data-subty validityend = ls_data-endda validitybegin = ls_data-begda record = ls_data operation = 'INS' tclas = 'A' nocommit = space IMPORTING return = ls_return . CALL FUNCTION 'DEQUEUE_EPPRELE' EXPORTING mode_prel = 'E' mandt = sy-mandt pernr = ls_data-pernr infty = '0015' subty = '1650' endda = ls_data-endda begda = ls_data-begda.
<u><b>Some Basics:</b></u>
i. You may wonder why I locked the personel but as far as I remember, there is a problem in the FM "HR_INFOTYPE_OPERATION" about this. Locking the personel overcomes the problem. But it may have been solved. So, if you want first try without locking explicitly.
ii. The FM calls the dialog module for the program MPXXXX00 (XXXX: Infotype number, here MP001500) of the infotype.
iii. "ls_data" which is passed to the parameter "record" should be type "PXXXX" (here P0015).
iv. If the infotype has subtypes, pass the subtype you want ( in our case 1650) to the parameter "subtype" .
v. You must give the validity period to the parameters "validityend" and "validitybegin".
vi. The operation type you need is "INS" if you want to insert an infotype record. You can see other values from the fixed values of the domain of the parameter "operation".
vii. Since some infotypes are common for both employee an applicants data, you should pass 'A' to the parameter "tclas". This way the record is inserted to the table PAXXXX. In case of 'B', it behaves your record as to be an applicant data.
viii. You have the option to force the FM not to commit at the end.
ix. The exporting parameter "return" of the FM is of type "BAPIRETURN1". That is, it can be used like other BAPI returns. You can analyze the result of the execution from this table.
Best Regards...
*--Serdar
Add a comment