SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Vendor Master Upload Program



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ММ
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Sat Oct 27, 2007 3:10 pm    Post subject: Vendor Master Upload Program Reply with quote

Code:
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
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ММ All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.