2008 Nov 25 3:02 PM
Hi experts!!
I am trying to use BAPI_ADDRESSORG_CHANGE to change the second tel. nr of one customer. I use the following code:
But the value is not updated. What am i doing wrong?? Please help!!
Thank u in advance!!!
REPORT ZZZZZ_TEST.
DATA: objtype LIKE bapi4001_1-objtype,
obj_id LIKE bapi4001_1-objkey,
obj_id_ext LIKE bapi4001_1-extension,
context LIKE bapi4001_1-context,
address_number LIKE adrc-addrnumber,
bapiadtel LIKE bapiadtel OCCURS 0 WITH HEADER LINE,
bapiadtel_x LIKE bapiadtelx OCCURS 0 WITH HEADER LINE,
return LIKE bapiret2 OCCURS 0.
objtype = 'KNA1'.
obj_id = '0000026245'.
obj_id_ext = ' '.
context = '0001'.
CALL FUNCTION 'BAPI_ADDRESSORG_GETDETAIL'
EXPORTING
obj_type = objtype
obj_id = obj_id
OBJ_ID_EXT = ' '
CONTEXT = 1
IV_CURRENT_COMM_DATA = 'X'
IMPORTING
ADDRESS_NUMBER = address_number
TABLES
BAPIAD1VL =
BAPIADTEL = bapiadtel
BAPIADFAX =
BAPIADTTX =
BAPIADTLX =
BAPIADSMTP =
BAPIADRML =
BAPIADX400 =
BAPIADRFC =
BAPIADPRT =
BAPIADSSF =
BAPIADURI =
BAPIADPAG =
BAPIAD_REM =
BAPICOMREM =
BAPIADUSE =
RETURN =
.
BREAK canezos.
delete bapiadtel where STD_NO = 'X'.
loop at bapiadtel where STD_NO is initial.
bapiadtel-telephone = '2128866543'.
modify bapiadtel.
MOVE-CORRESPONDING bapiadtel to bapiadtel_x.
bapiadtel_x-telephone = '2128866543'.
bapiadtel_x-updateflag = 'U'.
append bapiadtel_x.
endloop.
CALL FUNCTION 'BAPI_ADDRESSORG_CHANGE'
EXPORTING
obj_type = objtype
obj_id = obj_id
OBJ_ID_EXT = ' '
CONTEXT = '1'
ACCEPT_ERROR = 'X'
SAVE_ADDRESS = 'X'
IV_CHECK_ADDRESS = 'X'
IV_TIME_DEPENDENT_COMM_DATA = ' '
IMPORTING
ADDRESS_NUMBER = address_number
TABLES
BAPIAD1VL =
BAPIADTEL = bapiadtel
BAPIADFAX =
BAPIADTTX =
BAPIADTLX =
BAPIADSMTP =
BAPIADRML =
BAPIADX400 =
BAPIADRFC =
BAPIADPRT =
BAPIADSSF =
BAPIADURI =
BAPIADPAG =
BAPIAD_REM =
BAPICOMREM =
BAPIADUSE =
BAPIAD1VL_X =
BAPIADTEL_X = bapiadtel_x
BAPIADFAX_X =
BAPIADTTX_X =
BAPIADTLX_X =
BAPIADSMT_X =
BAPIADRML_X =
BAPIADX40_X =
BAPIADRFC_X =
BAPIADPRT_X =
BAPIADSSF_X =
BAPIADURI_X =
BAPIADPAG_X =
BAPIAD_RE_X =
BAPICOMRE_X =
BAPIADUSE_X =
RETURN = return
.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'
IMPORTING
RETURN =
.
BREAK canezos.
2008 Nov 26 9:47 AM
Iria,
I would like to reccommend some changes for the following piece of code in your program,
(Check my comments)
>>delete bapiadtel where STD_NO = 'X'.
loop at bapiadtel where STD_NO is initial.
bapiadtel-telephone = '2128866543'.
modify bapiadtel.
MOVE-CORRESPONDING bapiadtel to bapiadtel_x. <-- change the move corresponding to direct
assignment statements. The values obtained from the BAPI_ADDRESSORG_GETDETAIL FM should be assigned directly to the structure of the change FM. Assign all the values directly.
bapiadtel_x-telephone = '2128866543'.
bapiadtel_x-updateflag = 'U'.
append bapiadtel_x.
endloop.<<
If the above approach doesn't work I suggest that you delete the existing entries using update flag 'D' and insert the changed values using 'I'.
Sojan
Hi experts!!
I am trying to use BAPI_ADDRESSORG_CHANGE to change the second tel. nr of one customer. I use the following code:
But the value is not updated. What am i doing wrong?? Please help!!
Thank u in advance!!!
REPORT ZZZZZ_TEST.
DATA: objtype LIKE bapi4001_1-objtype,
obj_id LIKE bapi4001_1-objkey,
obj_id_ext LIKE bapi4001_1-extension,
context LIKE bapi4001_1-context,
address_number LIKE adrc-addrnumber,
bapiadtel LIKE bapiadtel OCCURS 0 WITH HEADER LINE,
bapiadtel_x LIKE bapiadtelx OCCURS 0 WITH HEADER LINE,
return LIKE bapiret2 OCCURS 0.
objtype = 'KNA1'.
obj_id = '0000026245'.
obj_id_ext = ' '.
context = '0001'.
CALL FUNCTION 'BAPI_ADDRESSORG_GETDETAIL'
EXPORTING
obj_type = objtype
obj_id = obj_id
OBJ_ID_EXT = ' '
CONTEXT = 1
IV_CURRENT_COMM_DATA = 'X'
IMPORTING
ADDRESS_NUMBER = address_number
TABLES
BAPIAD1VL =
BAPIADTEL = bapiadtel
BAPIADFAX =
BAPIADTTX =
BAPIADTLX =
BAPIADSMTP =
BAPIADRML =
BAPIADX400 =
BAPIADRFC =
BAPIADPRT =
BAPIADSSF =
BAPIADURI =
BAPIADPAG =
BAPIAD_REM =
BAPICOMREM =
BAPIADUSE =
RETURN =
.
BREAK canezos.
delete bapiadtel where STD_NO = 'X'.
loop at bapiadtel where STD_NO is initial.
bapiadtel-telephone = '2128866543'.
modify bapiadtel.
MOVE-CORRESPONDING bapiadtel to bapiadtel_x.
bapiadtel_x-telephone = '2128866543'.
bapiadtel_x-updateflag = 'U'.
append bapiadtel_x.
endloop.
CALL FUNCTION 'BAPI_ADDRESSORG_CHANGE'
EXPORTING
obj_type = objtype
obj_id = obj_id
OBJ_ID_EXT = ' '
CONTEXT = '1'
ACCEPT_ERROR = 'X'
SAVE_ADDRESS = 'X'
IV_CHECK_ADDRESS = 'X'
IV_TIME_DEPENDENT_COMM_DATA = ' '
IMPORTING
ADDRESS_NUMBER = address_number
TABLES
BAPIAD1VL =
BAPIADTEL = bapiadtel
BAPIADFAX =
BAPIADTTX =
BAPIADTLX =
BAPIADSMTP =
BAPIADRML =
BAPIADX400 =
BAPIADRFC =
BAPIADPRT =
BAPIADSSF =
BAPIADURI =
BAPIADPAG =
BAPIAD_REM =
BAPICOMREM =
BAPIADUSE =
BAPIAD1VL_X =
BAPIADTEL_X = bapiadtel_x
BAPIADFAX_X =
BAPIADTTX_X =
BAPIADTLX_X =
BAPIADSMT_X =
BAPIADRML_X =
BAPIADX40_X =
BAPIADRFC_X =
BAPIADPRT_X =
BAPIADSSF_X =
BAPIADURI_X =
BAPIADPAG_X =
BAPIAD_RE_X =
BAPICOMRE_X =
BAPIADUSE_X =
RETURN = return
.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'
IMPORTING
RETURN =
.
BREAK canezos.
2008 Nov 25 3:33 PM
Iria,
Try to run the FM in SE37 editor with test data directory and check if it updates this field. As far as the code is concerned, I do not see any issue.
Sojan
2008 Nov 25 3:38 PM
Hi Sojan & thank u for your reply!!
The code runs perfectly ok when i try to update the BAPIADSMTP-email field but it does nothing for fax numbers or telephone numbers.
Could it be something wring with the consnumbers??
I am really confused!
2008 Nov 26 9:47 AM
Iria,
I would like to reccommend some changes for the following piece of code in your program,
(Check my comments)
>>delete bapiadtel where STD_NO = 'X'.
loop at bapiadtel where STD_NO is initial.
bapiadtel-telephone = '2128866543'.
modify bapiadtel.
MOVE-CORRESPONDING bapiadtel to bapiadtel_x. <-- change the move corresponding to direct
assignment statements. The values obtained from the BAPI_ADDRESSORG_GETDETAIL FM should be assigned directly to the structure of the change FM. Assign all the values directly.
bapiadtel_x-telephone = '2128866543'.
bapiadtel_x-updateflag = 'U'.
append bapiadtel_x.
endloop.<<
If the above approach doesn't work I suggest that you delete the existing entries using update flag 'D' and insert the changed values using 'I'.
Sojan
2008 Nov 26 9:58 AM
Hello
SAP wrote:
* Change an organization address:
* Change, delete and add a telephone number
DATA: objtype LIKE bapi4001_1-objtype,
obj_id LIKE bapi4001_1-objkey,
obj_id_ext LIKE bapi4001_1-extension,
context LIKE bapi4001_1-context,
address_number LIKE adrc-addrnumber,
bapiadtel LIKE bapiadtel OCCURS 0 WITH HEADER LINE,
bapiadtel_x LIKE bapiadtelx OCCURS 0 WITH HEADER LINE,
return LIKE bapiret2 OCCURS 0.
* Assign the following object type and object key to a main customer
* address
objtype = 'KNA1'.
obj_id = <customer number>.
obj_id_ext = ' '.
context = '0001'.
* Get existing data by calling, e.g. FM 'BAPI_ADDRESSORG_GETDETAIL'
...
* Enter the reference structure data
* The telephone number with serial number '002' is to be deleted and
* the one with serial number '003' updated
CLEAR: bapiadtel, bapiadtel_x.
bapiadtel-consnumber = '002'.
bapiadtel_x-updateflag = 'D'.
APPEND: bapiadtel, bapiadtel_x. "Delete entry
CLEAR: bapiadtel, bapiadtel_x.
bapiadtel-consnumber = '003'.
bapiadtel-extension = '77733'.
bapiadtel_x-extension = 'X'.
bapiadtel_x-updateflag = 'U'
APPEND: bapiadtel, bapiadtel_x. "Update entry
CLEAR: bapiadtel, bapiadtel_x.
bapiadtel-telephone = '06227'.
bapiadtel-extension = '11111'.
bapiadtel_x-updateflag = 'I'.
APPEND: bapiadtel, bapiadtel_x. "Insert new entry
* call change module
CALL FUNCTION 'BAPI_ADDRESSORG_CHANGE'
EXPORTING
obj_type = objtype
obj_id = obj_id
obj_id_ext = obj_id_ext
context = context
IMPORTING
address_number = address_number
TABLES
bapiadtel = bapiadtel
bapiadtel_x = bapiadtel_x
return = return.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |