Skip to Content

Creating an interested in the ERP using method cmd_ei_api=>maintain_bapi

It is only an exmple  for creating  an interested in the ERP using method cmd_ei_api=>maintain_bapi

All data to interested are transferred in the structure LS_MASTERDATA. The LS_MASTERDATA is a deep structure of type CMDS_EI_MAIN (see Figures).

/wp-content/uploads/2012/06/ls_masterdata_107553.jpg

Untzerstruktur customer.jpg

In the sub-structures / tables all the data will be stored in that way which is known from creating customers in dialog: the general data, the plant data and the sales data. The individual views are subdivided according to the tables” in which the data are stored.

Alpha

In my application I have used only the general data: address data, phone number, fax number  and e-mail address. In this case, I needed the component CENTRAL  and  from ADDRESS, the part POSTAL and the part COMMUNICATION with its components PHONE FAX and EMAIL.

Alpha

The structure header is divided into and OBJECT_INSTANCE  and OBJECT_TASK. OBJECT_INSTANCE is filled with the customer number, if it is an external number assignment, otherwise, the system determines the customer number.

OBJECT_TASKindicates whether there is acreation(I) a change in (U) or deletion(D). Such a TASKfield exists in all higher-level units, and it must be filled every time.The subordinate units each contain two structures, a DATA and a DATAX with the same  field names. The DATA fields contains the values, The DATAX fields marks the corresponding as used . (Marker : Field is to evaluate)


Now for the code. One can use certainly Field symbols to access to the structures, but to clarify what is actually filled, here the fields are named directly.

…..

is_adr_data is an user structure, which contains VCARD Data from a portal applikation

data: ls_masterdata type cmds_ei_main,
ls_customers
type  cmds_ei_extern,
lt_customers
type cmds_ei_extern_t,

* for Exportparameters of Methode
        ls_master_data_correct type  cmds_ei_main,
ls_message_correct    
type  cvis_message,
ls_master_data_defective
type  cmds_ei_main,
ls_message_defective 
type  cvis_message,
* for Transfer Communication data
ls_phone_main
type cvis_ei_cvi_phone,
ls_phone
type cvis_ei_phone_str,
lt_phone
type cvis_ei_phone_t,
ls_fax_main
type cvis_ei_cvi_fax,
ls_fax
type cvis_ei_fax_str,
lt_fax
type cvis_ei_fax_t,
ls_mail_main
type cvis_ei_cvi_smtp,
ls_mail
type cvis_ei_smtp_str,
lt_mail
type cvis_ei_smtp_t.

* Customer number (in case of external creating of numbers)

  ls_customers-header-object_instance-kunnr = lv_nummer.

* Mark CREATE
  ls_customers-header-object_task = ‘I’.
* Fill central data like Customer Account Group
  ls_customers-central_data-central-data-ktokd = c_interessent.
ls_customers-central_data-central-datax-ktokd =
‘X’.
* now address data
  ls_customers-central_data-address-task = ‘I’.
* if the FROM date should be filled here , it has also to be filled in all other used structures
  ls_customers-central_data-address-postal-data-from_date = sy-datum.
* NAME and SORT1 are Mandatory fields
  ls_customers-central_data-address-postal-data-name = is_adr_data-name_last.
ls_customers-central_data-address-postal-data-sort1  = is_adr_data-name_last.
ls_customers-central_data-address-postal-data-name_2 = is_adr_data-name_first.
ls_customers-central_data-address-postal-data-city  = is_adr_data-city1.
ls_customers-central_data-address-postal-data-postl_cod1  = is_adr_data-post_code1.
ls_customers-central_data-address-postal-data-street = is_adr_data-street.
ls_customers-central_data-address-postal-data-country = is_adr_data-country.
ls_customers-central_data-address-postal-data-langu = is_adr_data-country.
* and now mark all used fields
  ls_customers-central_data-address-postal-datax-from_date = ‘X’.
ls_customers-central_data-address-postal-datax-to_date =
‘X’.
ls_customers-central_data-address-postal-datax-name =
‘X’.
ls_customers-central_data-address-postal-datax-sort1 =
‘X’.
ls_customers-central_data-address-postal-datax-name_2 =
‘X’.
ls_customers-central_data-address-postal-datax-city =
‘X’.
ls_customers-central_data-address-postal-datax-postl_cod1 =
‘X’.
ls_customers-central_data-address-postal-datax-street =
‘X’.
ls_customers-central_data-address-postal-datax-house_no =
‘X’.
ls_customers-central_data-address-postal-datax-country =
‘X’.
ls_customers-central_data-address-postal-datax-langu =
‘X’.
* fill telephon data
  ls_phone-contact-task = ‘I’.
ls_phone-contact-data-telephone = is_adr_data-telnummer.
ls_phone-contact-data-country = is_adr_data-country.
ls_phone-contact-datax-country =
‘X’.
ls_phone-contact-datax-telephone =
‘X’.
append ls_phone to lt_phone.
ls_phone_main-phone = lt_phone.
* fill fax data
ls_fax-contact-task =
‘I’.
ls_fax-contact-data-fax = is_adr_data-faxnummer.

  ls_fax-contact-datax-fax = ‘X’.
ls_fax-contact-data-country = is_adr_data-country.
ls_fax-contact-datax-country =
‘X’.
append ls_fax to lt_fax.
ls_fax_main-fax = lt_fax.
* fill mail data
ls_mail-contact-task =
‘I’.
ls_mail-contact-data-e_mail = is_adr_data-smtp_addr.
ls_mail-contact-datax-e_mail =
‘X’.
append ls_mail to lt_mail.
ls_mail_main-smtp = lt_mail.

ls_customers-central_data-address-communication-smtp = ls_mail_main.
ls_customers-central_data-address-communication-phone = ls_phone_main .
ls_customers-central_data-address-communication-fax = ls_fax_main.

append ls_customers to lt_customers.
ls_masterdata-customers = lt_customers.

cmd_ei_api=>maintain_bapi(
exporting
iv_test_run              = space
*    iv_collect_messages      = SPACE
is_master_data           = ls_masterdata
importing
es_master_data_correct   = ls_master_data_correct
es_message_correct       = ls_message_correct
es_master_data_defective = ls_master_data_defective
es_message_defective     = ls_message_defective
).

* to start booking

    call function ‘BAPI_TRANSACTION_COMMIT’ 

….

 

4 Comments
You must be Logged on to comment or reply to a post.
    • Hi Kesav,

      i understood very well,  In the moment I need only the Creation Function , but in future may be ...  Good to know.

      Have a nice weekend.

      Veronika

      • Hello Veronika,

        Hello Witold,

        I am trying to create vendor with partner functions using this class.

        I have 3 partner functions that are mandatory.

        In XK01 during manual creation, the partner numbers are filled INTERNAL & after saving, it is replaced by the vendor number being generated. I face issues when trying this via maintain BAPI method.

        I fill all the current state = 'X' , when I do not fill the partner number (which is the requirement), I get message to fill a partner number.

        Do you have any idea on this?

        Regards

        Seema M

    • Hello Kesav,

      I am trying to create vendor with partner functions using this class.

      I have 3 partner functions that are mandatory.

      In XK01 during manual creation, the partner numbers are filled INTERNAL & after saving, it is replaced by the vendor number being generated. I face issues when trying this via maintain BAPI method.

      I fill all the current state = 'X' , when I do not fill the partner number (which is the requirement), I get message to fill a partner number.

      Do you have any idea on this?

      Regards

      Seema M