Application Development and Automation 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: 
Read only

BAPI_ADDRESSEMP_CREATE

Former Member
0 Likes
1,043

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'.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
990

After BAPI_ADDRESSEMP_CREATE, execute BAPI_TRANSACTION_COMMIT.

Rob

8 REPLIES 8
Read only

Former Member
0 Likes
990

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

Read only

Former Member
0 Likes
991

After BAPI_ADDRESSEMP_CREATE, execute BAPI_TRANSACTION_COMMIT.

Rob

Read only

0 Likes
990

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'.

Read only

0 Likes
990

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

Read only

0 Likes
990

You aren't checking the BAPIRETURN structure. You'll likely find that an error has occurred.

Rob

Read only

0 Likes
990

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

Read only

0 Likes
990

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?

Read only

0 Likes
990

Perhaps there's some extra configuration in your system. It ran OK in ours.

Rob