‎2006 Dec 04 10:45 PM
Hi All,
I was trying BAPI_ADDRESSEMP_CREATE to see if it will work for my requirements so I wrote up this quick report but it doesn't create the new address record. Could you please tell me why the below code does not create a new address record?
Thanks.,
REPORT Z_TEST .
CALL FUNCTION 'BAPI_EMPLOYEE_ENQUEUE'
EXPORTING
number = '345'.
call function 'BAPI_ADDRESSEMP_CREATE'
exporting
EMPLOYEENUMBER = '345'
VALIDITYBEGIN = '20061231'
VALIDITYEND = '99991231'
ADDRESSTYPE = '2'
CONAME = 'USA'
CITY = 'Atlanta'.
CALL FUNCTION 'BAPI_EMPLOYEE_DEQUEUE'
EXPORTING
number = '345'.
‎2006 Dec 04 10:52 PM
After BAPI_ADDRESSEMP_CREATE, execute BAPI_TRANSACTION_COMMIT.
Rob
‎2006 Dec 04 10:51 PM
Hi Mark,
Try this one..this will assist in adding employee address records
CALL FUNCTION 'HR_INFOTYPE_OPERATION'
EXPORTING
infty = p2006-infty
number = pernr-pernr
subtype = p2006-subty
validityend = p2006-endda
validitybegin = p2006-begda
record = p2006
operation = 'MOD' " 'INS' 'DEL'
nocommit = 'X'
IMPORTING
return = l_return
key = l_key.
Revert back for more help.
Regards
Naresh
‎2006 Dec 04 10:52 PM
After BAPI_ADDRESSEMP_CREATE, execute BAPI_TRANSACTION_COMMIT.
Rob
‎2006 Dec 04 10:58 PM
Hi Rob,
I tried that but it still does not create the record....
REPORT Z_TEST .
CALL FUNCTION 'BAPI_EMPLOYEE_ENQUEUE'
EXPORTING
number = '48'.
call function 'BAPI_ADDRESSEMP_CREATE'
exporting
EMPLOYEENUMBER = '48'
VALIDITYBEGIN = '20061231'
VALIDITYEND = '99991231'
ADDRESSTYPE = '2'
CONAME = 'USA'
CITY = 'Atlanta'.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
CALL FUNCTION 'BAPI_EMPLOYEE_DEQUEUE'
EXPORTING
number = '48'.
‎2006 Dec 04 11:02 PM
Hi Mark,
U can create a "ZBAPI.." and copy paste the code from the standard BAPI..
U can then add the custom code to populate data in the Ztables n Zfields..
Reason:
If you use your approach and if there is a COMMIT in the standard BAPi, the first part gets stored.. now if there is a problem in populating Zfields, you would want to roll back.. but that would be dificult in case you have run a batch program for large number of records..
Regards
Naresh
‎2006 Dec 04 11:02 PM
You aren't checking the BAPIRETURN structure. You'll likely find that an error has occurred.
Rob
‎2006 Dec 04 11:11 PM
So try:
REPORT ztest MESSAGE-ID 00.
DATA: BEGIN OF return_int OCCURS 0.
INCLUDE STRUCTURE bapireturn1.
DATA: END OF return_int.
CALL FUNCTION 'BAPI_EMPLOYEE_ENQUEUE'
EXPORTING
number = '48'.
CALL FUNCTION 'BAPI_ADDRESSEMP_CREATE'
EXPORTING
employeenumber = '48'
validitybegin = '20061231'
validityend = '99991231'
addresstype = '2'
coname = 'USA'
city = 'Atlanta'
TABLES
return = return_int.
LOOP AT return_int.
ENDLOOP.
IF whatever.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
ENDIF.
CALL FUNCTION 'BAPI_EMPLOYEE_DEQUEUE'
EXPORTING
number = '48'.
Rob
Added logic before commit
Message was edited by:
Rob Burbank
‎2006 Dec 04 11:23 PM
I tried with Bapireturn and it says
"Make an entry in all required fields'
I am giving all the required fields though!
Any ideas why is it giving me the above message?
‎2006 Dec 05 8:25 PM
Perhaps there's some extra configuration in your system. It ran OK in ours.
Rob