Vendor Master Upload Program

How can I upload vendor master excel file to sap table?

Check this code to upload vendor master through SHDB transaction.

report ZVEND_MST no standard page heading line-size
255.

*include bdcrecx1.

*parameters: dataset(132) lower case default 
'c:\vend.mst'.
***    DO NOT CHANGE - the generated data section - DO
NOT CHANGE    ***
*
*   If it is nessesary to change the data section use
the rules:
*   1.) Each definition of a field exists of two lines
*   2.) The first line shows exactly the comment
*       '* data element: ' followed with the data
element
*       which describes the field.
*       If you don't have a data element use the
*       comment without a data element name
*   3.) The second line shows the fieldname of the
*       structure, the fieldname must consist of
*       a fieldname and optional the character '_' and
*       three numbers and the field length in brackets
*   4.) Each field must be type C.
*
*** Generated data section with specific formatting -
DO NOT CHANGE  ***
data: begin of record,
* data element: LIF16
        LIFNR_001(016),
* data element: BUKRS
        BUKRS_002(004),
* data element: EKORG
        EKORG_003(004),
* data element: KTOKK
        KTOKK_004(004),
* data element: NAME1_GP
        NAME1_005(035),
* data element: SORTL
        SORTL_006(010),
* data element: LAND1_GP
        LAND1_007(003),
* data element: SPRAS
        SPRAS_008(002),
* data element: BSTWA
        WAERS_009(005),
      end of record.

*** End generated data section ***

DATA : ITAB TABLE OF RECORD WITH HEADER LINE.

start-of-selection.

*perform open_dataset using dataset.
*perform open_group.
*
*do.
*
*read dataset dataset into record.
*if sy-subrc <> 0. exit. endif.
CALL FUNCTION 'GUI_UPLOAD'
  EXPORTING
    FILENAME                      = 'C:\VENDOR.TXT'   
"TEXT FILE
   FILETYPE                      = 'ASC'
   HAS_FIELD_SEPARATOR           = 'X'
  TABLES
    DATA_TAB                      = ITAB
 EXCEPTIONS
   FILE_OPEN_ERROR               = 1
   FILE_READ_ERROR               = 2
   NO_BATCH                      = 3
   GUI_REFUSE_FILETRANSFER       = 4
   INVALID_TYPE                  = 5
   NO_AUTHORITY                  = 6
   UNKNOWN_ERROR                 = 7
   BAD_DATA_FORMAT               = 8
   HEADER_NOT_ALLOWED            = 9
   SEPARATOR_NOT_ALLOWED         = 10
   HEADER_TOO_LONG               = 11
   UNKNOWN_DP_ERROR              = 12
   ACCESS_DENIED                 = 13
   DP_OUT_OF_MEMORY              = 14
   DISK_FULL                     = 15
   DP_TIMEOUT                    = 16
   OTHERS                        = 17
          .
IF SY-SUBRC <> 0.
     MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
     WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

LOOP AT ITAB.
*In Loop Change Record With ITAB
* like record-lifnr_001 with itab-lifnr_001  
  perform bdc_dynpro      using 'SAPMF02K' '0100'.
  perform bdc_field       using 'BDC_CURSOR'
                              'RF02K-KTOKK'.
  perform bdc_field       using 'BDC_OKCODE'
                              '/00'.
  perform bdc_field       using 'RF02K-LIFNR'
                              record-LIFNR_001.
  perform bdc_field       using 'RF02K-BUKRS'
                              record-BUKRS_002.
  perform bdc_field       using 'RF02K-EKORG'
                              record-EKORG_003.
  perform bdc_field       using 'RF02K-KTOKK'
                              record-KTOKK_004.
  perform bdc_dynpro      using 'SAPMF02K' '0110'.
  perform bdc_field       using 'BDC_CURSOR'
                              'LFA1-SPRAS'.
  perform bdc_field       using 'BDC_OKCODE'
                              '/00'.
  perform bdc_field       using 'LFA1-NAME1'
                              record-NAME1_005.
  perform bdc_field       using 'LFA1-SORTL'
                              record-SORTL_006.
  perform bdc_field       using 'LFA1-LAND1'
                              record-LAND1_007.
  perform bdc_field       using 'LFA1-SPRAS'
                              record-SPRAS_008.
  perform bdc_dynpro      using 'SAPMF02K' '0120'.
  perform bdc_field       using 'BDC_CURSOR'
                              'LFA1-KUNNR'.
  perform bdc_field       using 'BDC_OKCODE'
                              '/00'.
  perform bdc_dynpro      using 'SAPMF02K' '0130'.
  perform bdc_field       using 'BDC_CURSOR'
                              'LFBK-BANKS(01)'.
  perform bdc_field       using 'BDC_OKCODE'
                              '=ENTR'.
  perform bdc_dynpro      using 'SAPMF02K' '0210'.
  perform bdc_field       using 'BDC_CURSOR'
                                'LFB1-AKONT'.
  perform bdc_field       using 'BDC_OKCODE'
                                '/00'.
  perform bdc_dynpro      using 'SAPMF02K' '0215'.
  perform bdc_field       using 'BDC_CURSOR'
                                'LFB1-ZTERM'.
  perform bdc_field       using 'BDC_OKCODE'
                                '/00'.
  perform bdc_dynpro      using 'SAPMF02K' '0220'.
  perform bdc_field       using 'BDC_CURSOR'
                                'LFB5-MAHNA'.
  perform bdc_field       using 'BDC_OKCODE'
                                '/00'.
  perform bdc_dynpro      using 'SAPMF02K' '0310'.
  perform bdc_field       using 'BDC_CURSOR'
                                'LFM1-WAERS'.
  perform bdc_field       using 'BDC_OKCODE'
                                '/00'.
  perform bdc_field       using 'LFM1-WAERS'
                                record-WAERS_009.
  perform bdc_dynpro      using 'SAPMF02K' '0320'.
  perform bdc_field       using 'BDC_CURSOR'
                                'RF02K-LIFNR'.
  perform bdc_field       using 'BDC_OKCODE'
                                '=ENTR'.
  perform bdc_dynpro      using 'SAPLSPO1' '0300'.
  perform bdc_field       using 'BDC_OKCODE'
                                '=YES'.
  perform bdc_transaction using 'XK01'.

endLOOP..
Check It, Activate it and process in SM35.

Tips by : RAjesh K Khatri

ABAP Tips

Fast Links:
BDC to Upload Schedule Agreement
Schedule Agreement Data Uploading

Get help for your ABAP problems
Do you have a ABAP Question?

SAP Books
SAP Certification, Interview Questions, Functional, Basis Administration and ABAP Programming Reference Books

More ABAP Tips

Best regards,
SAP Basis, ABAP Programming and Other IMG Stuff
http://www.erpgreat.com

All the site contents are Copyright © www.erpgreat.com and the content authors. All rights reserved.
All product names are trademarks of their respective companies.  The site www.erpgreat.com is in no way affiliated with SAP AG.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
 The content on this site may not be reproduced or redistributed without the express written permission of
www.erpgreat.com or the content authors.