Skip to Content
0

Entries in table BAPIADTEL_X with change flag 'I' must be separated at the end

Feb 01 at 01:32 PM

218

avatar image
Former Member

Hello everyone,

I am facing the issue in the Bapi return table.The issue is the transaction BP need to update telephone number(existing) and also add new mobile number.

Bapi FM - BAPI_BUPA_ADDRESS_CHANGE.

In the above FM there is a table BAPIADTEL_X where I am trying to append 2 records one with update flag as ''U'' and another one with update flag ''I''.Please let me know if I am missing anything here.

Regards,

PD

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Nic Teunckens Feb 01 at 07:29 PM
0

"In the above FM there is a table BAPIADTEL_X where I am trying to append 2 records one with update flag as ''U'' and another one with update flag ''I''.Please let me know if I am missing anything here."

Have you Flagged the other Fields that you want to Update (for example : Set "TEL_NO" to 'X', etc.). And maybe you need to do a test with setting the "VALID_FROM" and "VALID_TO" dates. In our System, these Dates could not be Updated, so we left them Blank ...

As a reference, see SAP-KBA 2484299 How to use BAPI for BP : link

We have always managed to update the BAS (Bus. Address Services) data through BAPI "BAPI_BUPA_CENTRAL_CHANGE" (Changing a business partner) rather than "BAPI_BUPA_ADDRESS_CHANGE" (Change address). Try BAPI "BAPI_BUPA_CENTRAL_CHANGE" ...

Show 9 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hello Nic,

I tried in all the way but still the problems remains the same.

Below is the chunk of the code:

***************Tel *************************
if gs_datatab-col4 is not initial.
ls_adtel-r_3_user = text-017. ""'1' . "Telephone
ls_adtel-country = text-018.
ls_adtel-std_no = abap_true.
ls_adtel-telephone = gs_datatab-col4.""'123'.


read table lt_adtel1 into ls_adtel with key r_3_user = '1'.
if sy-subrc eq 0.
ls_bapiadtelx-r_3_user = abap_true.
ls_bapiadtelx-telephone = abap_true.
ls_bapiadtelx-updateflag = text-020. 'Update
ls_bapiadtelx-country = abap_true.
else.
ls_adtel-consnumber = '029'.
ls_bapiadtelx-consnumber = abap_true.
ls_bapiadtelx-r_3_user = abap_true.
ls_bapiadtelx-telephone = abap_true.
ls_bapiadtelx-updateflag = text-035. "Insert
ls_bapiadtelx-country = abap_true.
endif.
append ls_adtel to lt_adtel.
append ls_bapiadtelx to lt_bapiadtelx.
clear: ls_adtel,ls_bapiadtelx.
* endif.
endif.

*************Mobile****************************
if gs_datatab-col5 is not initial.
ls_adtel-country = text-018. "Mobile
ls_adtel-r_3_user = text-019.
ls_adtel-std_no = abap_true.
ls_adtel-telephone = gs_datatab-col5.
append ls_adtel to lt_adtel.
clear ls_adtel.

read table lt_adtel1 into ls_adtel with key r_3_user = '3'.
if sy-subrc eq 0.
ls_bapiadtelx-r_3_user = abap_true.
ls_bapiadtelx-telephone = abap_true.
ls_bapiadtelx-updateflag = text-020. "Update
ls_bapiadtelx-country = abap_true.
else.
ls_bapiadtelx-r_3_user = abap_true.
ls_bapiadtelx-telephone = abap_true.
ls_bapiadtelx-updateflag = text-035. "Insert
ls_bapiadtelx-country = abap_true.
endif.
append ls_bapiadtelx to lt_bapiadtelx.
clear: ls_adtel,ls_bapiadtelx.
endif.

Regards,

PD

0

A few Remarks :

  • Dit you see any Messages in the "RETURN"-Table. If so, check these and correct the Issue ...
  • You did do a Commit afterwards, right ("BAPI_TRANSACTION_COMMIT")?
  • Why the 'Fixed' Sequence Number ("CONSNUM"). This should be calculated as the Sequence you want to Update if it already Exists OR a New Higher SequenceNmbr ...


See this Sample Code with the "BAPI_BUPA_CENTRAL_CHANGE"-BAPI, this should work ...

REPORT ztmp_testreport.

*---> BP Detail BAPI
  DATA businesspartner               TYPE bapibus1006_head-bpartner.
  DATA telefondatanonaddress         TYPE STANDARD TABLE OF bapiadtel.
  DATA return                        TYPE STANDARD TABLE OF bapiret2.
  DATA telefondatanonaddressx        TYPE STANDARD TABLE OF bapiadtelx.
  DATA updateflag                    TYPE ad_updflag.

  businesspartner = 'SOME_BP_NMBR'.

  CALL FUNCTION 'BAPI_BUPA_CENTRAL_GETDETAIL'
    EXPORTING
      businesspartner       = businesspartner
    TABLES
      telefondatanonaddress = telefondatanonaddress
      return                = return.
  CALL FUNCTION 'ALM_ME_CHECK_RETURN_TABLE'
    TABLES
      return          = return
    EXCEPTIONS
      error_in_return = 1
      OTHERS          = 2.
  IF sy-subrc <> 0.
    "Has Errors, Exit ...
    RETURN.
  ENDIF.

  "Get Highest SequenceNmbr
  SORT telefondatanonaddress BY consnumber.
  DESCRIBE TABLE telefondatanonaddress.
  READ TABLE telefondatanonaddress INTO DATA(telefon)
    INDEX sy-tfill.
  IF sy-subrc <> 0.
    "Nothing found ...
  ENDIF.
  DATA(consnum) = telefon-consnumber.

*---> BP Update BAPI
  "Set UpdateFlag and SequenceNmbr => Check TelNmbr Exists Already?
  READ TABLE telefondatanonaddress TRANSPORTING NO FIELDS
    WITH KEY telephone = 'TEL_NUMBER'.
  IF sy-subrc = 0.
    "No change to SequenceNmbr
    updateflag = 'U'.
  ELSE.
    ADD 1 TO consnum.
    updateflag = 'I'.
  ENDIF.

  FREE telefondatanonaddress.
  CLEAR telefon.
  telefon-country    = 'COUNTRY'.
  telefon-countryiso = 'COUNTRY'.
  telefon-consnumber = consnum.
  telefon-r_3_user   = 'R_3_USER_VAL'.
  telefon-std_no     = abap_true.
  telefon-telephone  = 'TEL_NUMBER'.
  telefon-tel_no     = 'TEL_NUMBER'.
  telefon-caller_no  = 'TEL_NUMBER'.
  telefon-valid_from = sy-datum.
  telefon-valid_to   = '99991231'.
  APPEND telefon TO telefondatanonaddress.

  READ TABLE telefondatanonaddressx INTO DATA(telefon_x) TRANSPORTING NO FIELDS
    INDEX 1.
  telefon_x-country    = abap_true.
  telefon_x-countryiso = abap_true.
  telefon_x-consnumber = abap_true.
  telefon_x-r_3_user   = abap_true.
  telefon_x-std_no     = abap_true.
  telefon_x-telephone  = abap_true.
  telefon_x-tel_no     = abap_true.
  telefon_x-caller_no  = abap_true.
  telefon_x-valid_from = abap_true.
  telefon_x-valid_to   = abap_true.
  telefon_x-updateflag = updateflag.
  APPEND telefon_x TO telefondatanonaddressx.

  CHECK telefondatanonaddressx IS NOT INITIAL.
  CALL FUNCTION 'BAPI_BUPA_CENTRAL_CHANGE'
    EXPORTING
      businesspartner        = businesspartner
    TABLES
      telefondatanonaddress  = telefondatanonaddress
      telefondatanonaddressx = telefondatanonaddressx
      return                 = return.

  CALL FUNCTION 'ALM_ME_CHECK_RETURN_TABLE'
    TABLES
      return          = return
    EXCEPTIONS
      error_in_return = 1
      OTHERS          = 2.
  IF sy-subrc <> 0.
    "Has Errors, don't allow COMMIT
    RETURN.
  ENDIF.

  CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'


See if you can do something like this. Works for me in a Creation and Update Scenario ...

0
Former Member
Nic Teunckens

Hi,

Thanks for your time and reply.

In my also its works fine only if there are either 'U' or 'I' .But the issue happens when there is combination of U and I or I and U.In other words when telephone number needs to be updated and mobile number need to insert.
method update_add_data.

  • Why the 'Fixed' Sequence Number ("CONSNUM"). This should be calculated as the Sequence you want to Update if it already Exists OR a New Higher SequenceNmbr ... - Just for testing one scenario tired to hardcode the sequence number later point of time will change it.

I think BAPI_BUPA_ADDRESS_CHANGE' should also serve the purpose.Let me know if still i am missing anything please:

loop at gt_datatab into gs_datatab.

me->ls_par = gs_datatab-col1.

call function 'CONVERSION_EXIT_ALPHA_INPUT'
exporting
input = me->ls_par
importing
output = me->ls_par.

call function 'BAPI_BUPA_ADDRESS_GETDETAIL'
exporting
businesspartner = me->ls_par
reset_buffer = abap_true
* ADDRESSGUID =
valid_date = sy-datlo
importing
addressdata = ls_addressdata1
tables
bapiadtel = lt_adtel1
bapiadfax = lt_bapiadfax1
bapiadsmtp = lt_bapiadsmtp1.
* return = lt_return.

*****************Street & Comm add***********************

ls_addressdata-street = gs_datatab-col2.
ls_addressdata-str_suppl3 = gs_datatab-col3.

ls_addressdata_x-street = abap_true.
ls_addressdata_x-str_suppl3 = abap_true.

***************Tel *************************


if gs_datatab-col4 is not initial.
ls_adtel-r_3_user = text-017. ""'1' . "Telephone
ls_adtel-country = text-018.
ls_adtel-std_no = abap_true.
ls_adtel-telephone = gs_datatab-col4.""'123'.

sort lt_adtel1 by consnumber.
"Get Highest SequenceNmbr
* SORT telefondatanonaddress BY consnumber.
describe table telefondatanonaddress.
read table lt_adtel1 into data(telefon)
index sy-tfill.
if sy-subrc <> 0.
"Nothing found ...
endif.
data(lv_consnum) = telefon-consnumber.

read table lt_adtel1 into ls_adtel with key r_3_user = '1'.
if sy-subrc eq 0.
ls_bapiadtelx-r_3_user = abap_true.
ls_bapiadtelx-telephone = abap_true.
ls_bapiadtelx-updateflag = text-020.
ls_bapiadtelx-country = abap_true.
else.
add 1 to lv_consnum.
ls_adtel-consnumber = lv_connum.
ls_adtel-countryiso = 'IN'.
ls_adtel-valid_from = sy-datum.

ls_bapiadtelx-countryiso = abap_true.
ls_bapiadtelx-valid_from = abap_true.
ls_bapiadtelx-consnumber = abap_true.
ls_bapiadtelx-r_3_user = abap_true.
ls_bapiadtelx-telephone = abap_true.
ls_bapiadtelx-updateflag = text-035.
ls_bapiadtelx-country = abap_true.
endif.
append ls_adtel to lt_adtel.
append ls_bapiadtelx to lt_bapiadtelx.
clear: ls_adtel,ls_bapiadtelx.
* endif.
endif.

*********************************************
if gs_datatab-col5 is not initial.
ls_adtel-country = text-018. "Mobile
ls_adtel-r_3_user = text-019.
ls_adtel-std_no = abap_true.
ls_adtel-telephone = gs_datatab-col5.""'7829872300'.
append ls_adtel to lt_adtel.
clear ls_adtel.

read table lt_adtel1 into ls_adtel with key r_3_user = '3'.
if sy-subrc eq 0.
ls_bapiadtelx-r_3_user = abap_true.
ls_bapiadtelx-telephone = abap_true.
ls_bapiadtelx-updateflag = text-020.
ls_bapiadtelx-country = abap_true.
else.
ls_bapiadtelx-r_3_user = abap_true.
ls_bapiadtelx-telephone = abap_true.
ls_bapiadtelx-updateflag = text-035."text-020.
ls_bapiadtelx-country = abap_true.
endif.
append ls_bapiadtelx to lt_bapiadtelx.
clear: ls_adtel,ls_bapiadtelx.
endif.
* append ls_bapiadtelx to lt_bapiadtelx.
* clear ls_adtel.

***************email***********************
if gs_datatab-col6 is not initial.
ls_bapiadsmtp-e_mail = gs_datatab-col6. "email
append ls_bapiadsmtp to lt_bapiadsmtp.

read table lt_bapiadsmtp1 into ls_bapiadsmtp index 1.
if ls_bapiadsmtp-e_mail is not initial.
ls_bapiadsmtx-e_mail = abap_true.
ls_bapiadsmtx-updateflag = text-020.
else.
ls_bapiadsmtx-e_mail = abap_true.
ls_bapiadsmtx-updateflag = text-035.
endif.
append ls_bapiadsmtx to lt_bapiadsmtx.
clear ls_bapiadsmtx.
endif.
*******************************************

************fax****************************
if gs_datatab-col7 is not initial. "fax
ls_bapiadfax-fax = gs_datatab-col7.
append ls_bapiadfax to lt_bapiadfax.

clear ls_bapiadfax.
read table lt_bapiadfax1 into ls_bapiadfax index 1.
if ls_bapiadfax is not initial.
ls_bapiadfaxx-fax = abap_true.
ls_bapiadfaxx-updateflag = text-020.
else.
ls_bapiadfaxx-fax = abap_true.
ls_bapiadfaxx-updateflag = text-035.
endif.
append ls_bapiadfaxx to lt_bapiadfaxx.
clear ls_bapiadfaxx .
endif.
*******************************************
* data: n type i.
*DESCRIBE TABLE lt_bapiadtelx lines n.

call function 'BAPI_BUPA_ADDRESS_CHANGE'
exporting
businesspartner = me->ls_par
addressdata = ls_addressdata
addressdata_x = ls_addressdata_x
tables
bapiadtel = lt_adtel
bapiadfax = lt_bapiadfax
bapiadtel_x = lt_bapiadtelx
bapiadfax_x = lt_bapiadfaxx
bapiadsmtp = lt_bapiadsmtp
bapiadsmt_x = lt_bapiadsmtx
return = lt_return.

0

Again :

  • Do you Use "BAPI_TRANSACTION_COMMIT" because it does not show in your sample ...
  • Have you Checked the "LT_RETURN"-Parameter ...?


I would strongly Urge you to use the Other BAPI "BAPI_BUPA_CENTRAL_CHANGE" in your Logic which works basically the same. According to the mentioned SAP-KBA 2484299 this is the one you should use.

As a matter of test, you could set up a Test-Directory with that BAPI together with the COMMIT, fill in your data and just test the Behaviour.

0
Former Member
Nic Teunckens

Hi,

Yes, I have used it but unfortunately could not capture the code.The LT_RETURN is returning "Entries in table BAPIADTEL_X with change flag 'I' must be separated at the end".

The problem is, I need to replace BAPI_BUPA_ADDRESS_CHANGE with the BAPI_BUPA_CENTRAL_CHANGE.The above code is tested for other cases in all environments and it got stuck because of tel and mobile update/insert issue.

Regards,

PD

0

OK, so now we are getting somewhere.

I was not aware that the "Entries in table BAPIADTEL_X with change flag 'I' must be separated at the end" was the Actual Message from the "RETURN" in the BAPI (even though you stated that in the Original Message) ...

Anyhow, this is a Msg "AM256" and you will find some Pointers in SAP ONE Support :

  • SAP-KBA 2437000 'Error AM256 happens while updating with BP address BAPI' : link => "Make sure the inserted entry 'I' must be entered after the updated entries 'U' or deleted entries 'D' in the table." => Did you do this?
  • Check other (older) SAP-KBA's for Msg "AM256" ...


With that in mind, you could also do a 'Where-Used' of the Message and try to work out what is going wrong through Debugging. Finally, if none of the suggestions helped, contact SAP Support ...

1
Former Member

Hello Nic,

You have absolutely nailed it.It is working fine now.Thank you very much for your patience and help here.

Regards,

PD

0

Hello PD,

OK, glad it worked out.

Please Close the Question if this is Suffucient for you ...


Kind regards

Nic T.

0
Former Member

Hello Nic,

May I know your Gmail I'd.

Regards

PD

0