‎2008 Feb 22 2:33 PM
Hi,
i written the below code for Address updation SAP R/3 using BAPI's:
Please look over it and tell if any more modifications i have to do.
DATA: BEGIN OF I_BUT000 OCCURS 0,
PARTNER LIKE BUT000-PARTNER, " Business Partner Number
NAME_LAST LIKE BUT000-NAME_LAST, " Last Name of Business Partner
NAME_FIRST LIKE BUT000-NAME_FIRST. " First Name of Business Partner
DATA : END OF I_BUT000.
DATA : person type BAPIBUS1006_CENTRAL_PERSON.
DATA : persondata type BAPIBUS1006_CENTRAL_PERSON_X.
DATA : centraldataperson like ADDRESX .
DATA : Adddata type BAPIBUS1006_ADDRESS.
DATA : Adddatax type BAPIBUS1006_ADDRESS_X.
DATA : contact like ADDRESX.
DATA: BEGIN OF ADDRESS OCCURS 0.
INCLUDE STRUCTURE BAPIBUS1006_ADDRESS.
DATA: END OF ADDRESS.
DATA : X type I.
DATA: BEGIN OF ADTEL OCCURS 0.
INCLUDE STRUCTURE BAPIADTEL.
DATA: END OF ADTEL.
DATA: BEGIN OF ADSMTP OCCURS 0.
INCLUDE STRUCTURE BAPIADSMTP.
DATA: END OF ADSMTP.
DATA : wa_return like lt_return.
LOOP AT RELATIONSHIPS.
CALL FUNCTION 'BAPI_BUPA_CENTRAL_CHANGE'
EXPORTING
BUSINESSPARTNER = Businesspartner
CENTRALDATAPERSON = person
CENTRALDATAPERSON_X = persondata
TABLES
RETURN = lt_return.
CALL FUNCTION 'BAPI_BUPA_ADDRESS_CHANGE'
EXPORTING
BUSINESSPARTNER = Businesspartner
ADDRESSDATA = AddData
ADDRESSDATA_X = AddDatax
TABLES
BAPIADTEL = ADTEL
BAPIADSMTP = ADSMTP
BAPIADTEL_X = ADTELX
BAPIADSMT_X = ADSMTPX
RETURN = lt_return.
IF lt_return IS INITIAL .
MOVE-CORRESPONDING ADDRESS TO ADDRESX.
ADDRESX-CONTACT = RELATIONSHIPS .
SELECT PARTNER NAME_LAST NAME_FIRST
FROM BUT000 INTO TABLE I_BUT000
WHERE PARTNER EQ Relationships.
IF SY-SUBRC NE 0. CLEAR I_BUT000. ENDIF.
READ TABLE I_BUT000 INDEX 1.
ADDRESX-fname = I_BUT000-NAME_FIRST.
ADDRESX-lname = I_BUT000-NAME_LAST.
CONCATENATE I_BUT000-NAME_FIRST I_BUT000-NAME_LAST
INTO ADDRESX-C_O_NAME SEPARATED BY SPACE .
APPEND ADDRESX.
UPDATE BUT000 from table I_BUT000.
ENDIF.
LOOP AT ADTEL.
MOVE-CORRESPONDING ADTEL TO ADTELX.
ADTELX-CONTACT = RELATIONSHIPS.
APPEND ADTELX.
ENDLOOP.
LOOP AT ADSMTP.
MOVE-CORRESPONDING ADSMTP TO ADSMTPX.
ADSMTPX-CONTACT = RELATIONSHIPS.
APPEND ADSMTPX.
ENDLOOP.
ENDLOOP.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
*IMPORTING
RETURN = lt_return.
ENDFUNCTION.
Early reply is highely appriciable.
Regards,
Chow.
‎2008 Feb 22 2:45 PM
Hi,
After each fm call, you need to do the error table check. you are not doing on each occation you are calling an fm.
Secondly you need to read the return table not to check if it is initial.
Ex:
READ TABLE return WITH KEY type = 'E'.
IF sy-subrc = 0.
WRITE: return-message.
ENDIF.
In the return table, all kinds messages like status,information, warning and error will be stored.
if the return table has 'E' type then only errors have occured. there is no problem with other types and BAPI will be successful.
Hopes this helps.
if so please reward,
Harikrishna
‎2008 Feb 22 2:59 PM
When i am trying test with this code i havn't get nothing?
Would please check it out please.
Please do modification in the code if any to get the correct output.
Adance thanks fro your reply?
Regards,
chow.