Application Development 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: 

Update custom fields in itob table with ITOB_EQUIPMENT_MODIFY_SINGLE

Hi all,

I need to update customer for equipment with the function ITOB_EQUIPMENT_MODIFY_SINGLE but my code does not work correctly. When the function ITOB_EQUIPMENT_MODIFY_SINGLE be called the system will return sy-subrc = 1 back

Could someone tell my why my code does not work and where is the error is, i'm completely new in ABAP Development.

Here is my code with some dummy data in my system.

DATA:l_objnr TYPE itob-objnr value 'IEG351-1491'. "equipment-Object
DATA: ls_itob TYPEitob.
DATA: lt_itob TYPE STANDARD TABLE OF itob.
data i_new_kunnr TYPE c length 18 value '0000044639'.
data: l_valid_equi like itob,
      l_valid_equi_new like itob,
      l_itob_old like itob,
      l_itob_new like itob,
      l_itob_rec like itob.

CALL FUNCTION 'ITOB_EQUIPMENT_READ_SINGLE'
  EXPORTING
*   i_lock         = c_x “lock ignored
    i_objnr        = 'G351-1491'
  IMPORTING
    e_object_rec   =l_valid_equi
  EXCEPTIONS
    not_successful = 1
    OTHERS         = 2.


IF sy-subrc EQ 0.

  l_valid_equi_new        = l_valid_equi.
  l_valid_equi_new-kund1  = i_new_kunnr.

  MOVE: l_valid_equi       TOl_itob_old,
        l_valid_equi_new   TOl_itob_new.

  CLEAR l_itob_rec.

*   Function module to udate equipment data

  CALL FUNCTION 'ITOB_EQUIPMENT_MODIFY_SINGLE'
    EXPORTING
      i_write_buffer   ='X'
      i_post_buffer    ='X'
      i_commit_work    ='X'
      i_object_rec     =l_itob_new
      I_OBJECT_REC_OLD = l_itob_old
    IMPORTING
      E_OBJECT_REC     =l_itob_rec
    EXCEPTIONS
      NOT_SUCCESSFUL   =1
      OTHERS           = 2.
  IF sy-subrc <> 0.
  ENDIF.

ENDIF.

Thanks and Regards

Ton

5 REPLIES 5

Florian
Active Contributor

Without having a deeper look I would say, that you have forgot to pass the parameter for authorization. These equipment-data functions are really strict.

Because of not having a system available, have a look here. This looks very similar to yours and it seems to work.

https://archive.sap.com/discussions/thread/1304974

juan_suros
Contributor

The structure ITOB in the notification area is a view based on six different tables. Getting what you are attempting to work will require you to set up your changes to the underlying tables correctly. I did something like this ten years ago.

I remember these steps were necessary:

  1. In SE11, add your custom fields to an expansion structure, not directly to the definition of any table. I always used structure CI_EQUI.
  2. In SE11, define the new fields to be part of the "Change document". This is a check box in tab [Further characteristics] of the data element.

Even with the data set up correctly, we didn't use the FMs you list. We used this more complicated sequence:

CALL FUNCTION 'EQUIPMENT_READ'
CALL FUNCTION 'EQUIPMENT_UPDATE'
CALL FUNCTION 'EQUI_WRITE_DOCUMENT'
COMMIT WORK.

The combination of these functions always worked. It may be more than you need, but it is something to fall back on.

0 Kudos

Hi Juan,

these three Functions are seem to be too complex for me at the moment and so the colleague has taken the task as in consequence. But thank you very much for you answer.

Thanks and Regards

Ton

0 Kudos

Hi Florian,

thank you very much for your answer. Yes i have thought my problem is the authorization term but i don't know exactly what i have to do. Could you tell me a little bit more about this authorization? I'm a newbie in ABAP 🙂

In addition I have completely read the topic what you mentioned above before starting my own code. In this topic was the issue with update partner of a equipment. For updating customer it is a little bit different because customer is a field in the table itob.

Thanks and regards

Ton

raymond_giuseppi
Active Contributor

Did you also consider implementation of note 2146575 - Customer fields in BAPIs: Technical object (available since 2015 from ehp4 on.) and use BAPI BAPI_EQUI_CHANGE with new parameter EXTENSIONIN and an implementation of BAdI BADI_EAM_ITOB_BAPI_CUST_FIELDS?