How to create vendor master in SAP











  • Check for the vendor existence 
  
use function module BAPI_VENDOR_EXISTENCECHECK

       CALL FUNCTION 'BAPI_VENDOR_EXISTENCECHECK'

      EXPORTING

        vendorno    = l_f_lifnr "Vendor

        companycode = p_bukrs   "company code

      IMPORTING

        return      = g_r_return.   ( g_r_return TYPE bapiret1.)

      IF g_r_return-type CA 'AEX' .

      Vendor does not exist.

   ELSEIF  g_r_return-type IS INITIAL

    vendor alredy exits 

     MESSAGE I521(FN) WITH l_f_lifnr.

   endif. 

    Populate all the mandatory fields                       i_lfa1 "Vendor Master: General data address,country etc i_lfb1 "Vendor Master: Company data i_lfm1 "Vendor Master: Purchasing Data (Purchasing organization)   t_xlfbk "Bank details  
     Create vendor                   CALL FUNCTION 'VENDOR_INSERT' "in update task
        EXPORTING
          i_lfa1        = i_lfa1 "Vendor Master: General data
          i_lfb1        = i_lfb1 "Vendor Master: Company data
          i_lfm1        = i_lfm1 "Vendor Master: Purchasing Data (Purchasing organization)
        TABLES
          t_xlfas       = t_xlfas
          t_xlfb5       = t_xlfb5
          t_xlfbk       = t_xlfbk "Bank details
          t_xlfza       = t_xlfza
          T_XKNVK       = T_XKNVK
                .
      IF sy-subrc = 0.
        COMMIT WORK.
    *Vendor is created
      ELSE.
    *  Error while creating vendor
      ENDIF.  

 Protected by Copyscape Web Copyright Checker

No comments:

Post a Comment

/*Newer Post*/ Older Post Home