Skip to Content
avatar image
Former Member

Regarding vendor master BAPI issue

Dear guys,

I am working on vendor master creation using the Method VMD_EI_API=>maintain_BAPI. It was working fine for most of the scenarios. Recently when we tried to execute I am getting an error stating " Transaction code was not intended. Enter Xk01 or Xk02" which is almost stopping my development. I am not sure how a BAPI trying to call this. Before posting I checked all the respective codes posted, but it is also giving me the same error. Your help will be much appreciated. Please share the thoughts.

Thanks,

Kalyan

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • avatar image
    Former Member
    Jun 07, 2015 at 06:27 AM

    Hi Kalyan,

    Pls check how your code is differentiating the difference between create and update.

    Im my view for update in header structure we need to pass vendor number .

    If possible pls paste the code.

    Regards,

    Lokeswar reddy byni.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 07, 2015 at 05:43 PM

    Hi ,

    Thanks for the reply. I do pass the vendor number. Please find the code below. Hope that will give some idea. Here I am trying to pass the data to existing vendor.

    Sample code:

    CLASS lcl_data DEFINITION.
    PUBLIC SECTION.
    METHODS: constructor
    IMPORTING
    i_ccode TYPE bukrs
    i_ktokk TYPE ktokk
    i_akont TYPE akont
    i_name  TYPE ad_name1,
    create_vendor_data
    EXPORTING
    e_lifnr TYPE lifnr.

    PRIVATE SECTION.
    METHODS: prepare_data
    RETURNING VALUE(re_flag) TYPE i.
    *   Data Declarations
    DATA: gs_vmds_extern   TYPE vmds_ei_main,
    gs_succ_messages TYPE cvis_message,
    gs_vmds_error    TYPE vmds_ei_main,
    gs_err_messages  TYPE cvis_message,
    gs_vmds_succ     TYPE vmds_ei_main,
    gv_ktokk         TYPE ktokk,
    gv_ccode         TYPE bukrs,
    gv_akont         TYPE akont,
    gv_name          TYPE name1.
    ENDCLASS.                    "lcl_data

    *----------------------------------------------------------------------*
    *       CLASS lcl_data IMPLEMENTATION
    *----------------------------------------------------------------------*
    *
    *----------------------------------------------------------------------*
    CLASS lcl_data IMPLEMENTATION.

    METHOD constructor.
    me->gv_ccode = i_ccode.
    me->gv_ktokk  = i_ktokk.
    me->gv_akont = i_akont.
    me->gv_name = i_name.
    ENDMETHOD.                    "constructor

    METHOD prepare_data.

    *   Local Data Declaration
    DATA: lt_contacts     TYPE vmds_ei_contacts_t,
    ls_contacts     TYPE vmds_ei_contacts,
    lt_vendors      TYPE vmds_ei_extern_t,
    ls_vendors      TYPE vmds_ei_extern,
    ls_address      TYPE cvis_ei_address1,
    lt_company      TYPE vmds_ei_company_t,
    ls_company      TYPE vmds_ei_company,
    ls_company_data TYPE vmds_ei_vmd_company,
    ls_purchas_data TYPE vmds_ei_vmd_purchasing,
    lt_purchasing   TYPE vmds_ei_purchasing_t,
    ls_purchasing   TYPE vmds_ei_purchasing,
    lt_purch_func   TYPE vmds_ei_functions_t,
    ls_purch_func   TYPE vmds_ei_functions,
    ls_message      TYPE cvis_message,
    lv_contactid    TYPE bapicontact_01-contact.

    *   Clear the work area initially.
    CLEAR gs_vmds_extern.

    ls_vendors-header-object_task = 'M'.                                          "Represents Insert or Create
    ls_vendors-header-object_instance-lifnr = '0200014021'.
    *   Set the Name
    ls_address-postal-data-name          = gv_name.                       "Name of the Vendor
    ls_address-postal-data-street          = 'Flat 101, ABS Road'.
    ls_address-postal-data-city            = 'MSP'.
    ls_address-postal-data-postl_cod1  = '400062'.
    ls_address-postal-data-region         = '13'.
    ls_address-postal-data-country       = 'IN'.
    ls_address-postal-data-sort1           = gv_name.
    ls_address-postal-data-langu          = sy-langu.
    **   For all the fields where value was provided, set the flag value also to be 'X'
    ls_address-postal-datax-name         = 'X'.
    ls_address-postal-datax-street         = 'X'.
    ls_address-postal-datax-postl_cod1 = 'X'.
    ls_address-postal-datax-region        = 'X'.
    ls_address-postal-datax-sort1          = 'X'.
    ls_address-postal-datax-country      = 'X'.
    ls_address-postal-datax-langu         = 'X'.
    ls_address-task                                = 'I'.
    ls_address-postal-datax-city            = 'X'.
    **   Set the Address for the Vendor
    ls_vendors-central_data-address = ls_address.

    *   Set Contact Person
    REFRESH: lt_contacts[].
    CLEAR ls_contacts.
    ls_contacts-task = 'I'.                                                         "Represents Creation of Contact person
    ls_contacts-address_type_3-task = 'I'.                               "Represents Creation of Address for CP

    *   Specify how many Contact Person numbers are to be obtained
    *   This will simply provide us a contact person number
    CALL FUNCTION 'BAPI_PARTNEREMPLOYEE_GETINTNUM'
    EXPORTING
    quantity  = '1'
    IMPORTING
    contactid = lv_contactid.

    ls_contacts-data_key-parnr = lv_contactid.                          "Contact Person Number
    *   Set the Name for Contact person
    ls_contacts-address_type_3-postal-data-fullname   = 'John Smith'.
    ls_contacts-address_type_3-postal-data-firstname  = 'John'.
    ls_contacts-address_type_3-postal-data-lastname  = 'Smith.
    APPEND ls_contacts TO lt_contacts.

    *   Set the Contact Person details for the Vendor
    ls_vendors-central_data-contact-contacts = lt_contacts[].

    *   Set the Account Group
    ls_vendors-central_data-central-data-ktokk  = gv_ktokk.
    ls_vendors-central_data-central-data-stcd1  = 'VAT 1'.
    ls_vendors-central_data-central-data-kunnr  = ls_vendors-header-object_instance-lifnr.
    ls_vendors-central_data-central-datax-kunnr  = 'X'.

    ls_vendors-central_data-central-datax-ktokk = 'X'.
    ls_vendors-central_data-central-datax-stcd1 = 'X'.
    ls_vendors-central_data-central-datax-brsch = 'X'.

    *   Set the Company Code and GL Account
    REFRESH: lt_company[].
    CLEAR ls_company.
    ls_company-task                    = 'I'.
    ls_company-data_key-bukrs  = gv_ccode.
    ls_company-data-akont         = gv_akont.                          "Reconciliation Account
    ls_company-data-zuawa        = '018'.                                 "Sort Key
    *    ls_company-data-fdgrv          = 'M1'.                                  "Cash Management Group
    ls_company-data-zterm         = '0001'.                                "Payment Terms
    ls_company-data-zwels         = 'C'.
    ls_company-datax-zwels        = 'X'.
    ls_company-datax-akont       = 'X'.
    ls_company-datax-zuawa      = 'X'.
    *    ls_company-datax-fdgrv        = 'X'.
    ls_company-datax-zterm        = 'X'.
    ls_company-data-reprf         = 'X'.
    ls_company-datax-reprf       = 'X'.
    APPEND ls_company TO lt_company.
    ls_company_data-company = lt_company[].
    ls_vendors-company_data = ls_company_data.

    **   Set the Purchasing Data
    *    ls_purchasing-task                   = 'I'.
    *    ls_purchasing-data_key-ekorg = '1000'.                              "Purchasing Organization
    *    ls_purchasing-data-kalsk         = '01'.                                   "Schema Group, Vendor
    *    ls_purchasing-data-webre       = 'X'.                                     "GR Based Invoice Verification
    *    ls_purchasing-datax-kalsk       = 'X'.
    *    ls_purchasing-datax-webre      = 'X'.

    *   Set the Partner function for Purchase Organization Data
    *   Ordering Address
    *    REFRESH: lt_purchasing[],
    *             lt_purch_func[].
    *    CLEAR ls_purch_func.
    *    ls_purch_func-task = 'I'.
    *    ls_purch_func-data_key-parvw    = 'BA'.
    **   We set the Vendor being created as "Ordering Address"
    *    ls_purch_func-data-partner      = ls_vendors-header-object_instance-lifnr.
    *    ls_purch_func-datax-partner     = 'X'.
    *    APPEND ls_purch_func TO lt_purch_func[].
    *
    **   Invoicing Party
    *    CLEAR ls_purch_func.
    *    ls_purch_func-task = 'I'.
    *    ls_purch_func-data_key-parvw    = 'RS'.
    **   We set the Vendor being created as "Invoicing Party"
    *    ls_purch_func-data-partner      = ls_vendors-header-object_instance-lifnr.
    *    ls_purch_func-datax-partner     = 'X'.
    *    APPEND ls_purch_func TO lt_purch_func[].

    ***   Vendor
    **    CLEAR ls_purch_func.
    **    ls_purch_func-task = 'I'.
    **    ls_purch_func-data_key-parvw    = 'LF'.
    ***   We set the Vendor being created as "Vendor in Purchasing Partner Function"
    **    ls_purch_func-data-partner      = ls_vendors-header-object_instance-lifnr.
    **    ls_purch_func-datax-partner     = 'X'.
    **    APPEND ls_purch_func TO lt_purch_func[].
    **
    ***   Set the Purchasing Data - Partner functions
    **    ls_purchasing-functions-functions  = lt_purch_func[].
    **    APPEND ls_purchasing TO lt_purchasing.
    **
    ***   Set the Purchasing Data
    **    ls_purchas_data-purchasing = lt_purchasing[].
    **    ls_vendors-purchasing_data = ls_purchas_data.
    APPEND ls_vendors TO lt_vendors.
    **
    ***   Set the Final Vendor Data based on which it has to be created
    *   Note if multiple vendors are to be created...please maintain multiple entries in LT_VENDORS
    gs_vmds_extern-vendors = lt_vendors[].
    ENDMETHOD.                    "prepare_data

    METHOD create_vendor_data.

    *   Local Data Declaration
    DATA: lv_return TYPE i.

    *   Prepare the data to be used for Vendor Creation
    lv_return =  me->prepare_data( ).

    *   Do not proceed if the Vendor Data for creation was not prepared
    IF lv_return IS NOT INITIAL.
    EXIT.
    ENDIF.

    *   Initialize all the data
    vmd_ei_api=>initialize( ).

    *   Call the Method for creation of Vendor.
    CALL METHOD vmd_ei_api=>maintain_bapi
    EXPORTING
    is_master_data           = gs_vmds_extern
    IMPORTING
    es_master_data_correct   = gs_vmds_succ
    es_message_correct       = gs_succ_messages
    es_master_data_defective = gs_vmds_error
    es_message_defective     = gs_err_messages.

    IF gs_err_messages-is_error IS INITIAL.
    commit work.
    .
    *     Set the Vendor Number to be returned

    IF sy-subrc = 0.
    WRITE: 'Vendor is created'.

    ENDIF.

    ENDIF.
    ENDMETHOD.                    "create_vendor_data
    ENDCLASS.                    "lcl_data IMPLEMENTATION


    SELECTION-SCREEN BEGIN OF BLOCK tb1.
    PARAMETERS: p_ccode TYPE bukrs,
    p_akont TYPE akont,
    p_ktokk TYPE ktokk,
    p_name  TYPE ad_name1.
    SELECTION-SCREEN END OF BLOCK tb1.

    DATA: lo_data  TYPE REF TO lcl_data,
    gv_lifnr TYPE lifnr.

    START-OF-SELECTION.

    * Create an instance of our class
    CREATE OBJECT lo_data
    EXPORTING
    i_ccode = p_ccode
    i_akont = p_akont
    i_ktokk = p_ktokk
    i_name  = p_name.

    * Create Vendor and obtain the resultant error message and Vendor number
    CALL METHOD lo_data->create_vendor_data
    IMPORTING
    e_lifnr = gv_lifnr.


    Thanks,

    Kalyan

    Add comment
    10|10000 characters needed characters exceeded

  • Jun 08, 2015 at 01:39 PM

    Could you set a break-point at start of static method VMD_EI_API=>SET_TRANSACTION_CODE?

    Regards,

    Raymond

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 08, 2015 at 04:24 PM

    Hi Raymond / Lokeshwar,

    Thanks for helping me. In debugger it is not  stopping at the method mentioned. I am getting the error at the below mentioned methods.

    METHOD-->MAINTAIN_SINGLE : this is the method it is going through


    vmd_ei_api_memory=>read_current_lfa1: Here it is failing to check the t code.

    In the below , it is failing due to non receipt of the T code.

    CALL METHOD vmd_ei_api=>complete_and_check
        EXPORTING
          is_lfa1_new         = ls_lfa1_new
          is_lfa1_old         = ls_lfa1_old
          iv_tcode            = lv_tcode
          iv_collect_messages = iv_collect_messages
        IMPORTING
          es_error            = ls_error
        CHANGING
          cs_vend_flags       = ls_vend_flags.

    Hope this gives you to find some issue.

    Add comment
    10|10000 characters needed characters exceeded

    • The tcode should have been set in the lines immediately before those ones, could you check in your systeme, and if not set, look for suitable OSS notes.

      ***********************************************************************
      * Set TCODE
      ***********************************************************************
         if ls_lfa1_old is initial.
      *   Insert
           lv_tcode    = gc_tcode_create.
           lv_upd_lfa1 = 'I'.
         else.
      *   in LFA1 no deletion is possible =>
      *   Update
           lv_tcode    = gc_tcode_change.
           lv_upd_lfa1 = 'U'.
         endif.

      ***********************************************************************
      * Complete and check
      ***********************************************************************
         call method vmd_ei_api=>complete_and_check

      Nb: constants should be XK01 and XK02

      Regards,
      Raymond