Quick Contact

    SAP Tutorial
    Sap FI

    BDC Call transaction for Material Master MM01

    Create a BDC program with Call Transaction method to migrate(create) material master basic data using a flat file(.txt with tab delimited).

    Requirement analysis:

    To fulfil the above requirement we need to create recording for MM01 t-code using SHDB transaction, upload flat file data to a internal table, process using BDC.

    Follow the below steps to create a BDC form Material

    Create recording for MM01 transaction

    Create recording for material master MM01 with material basic data i:e basic view1, copy the code to create a new program MM01 recording with material basic data , the below code will be generated.Try to understand the below code (explained)

    performbdc_dynpro      using 'SAPLMGMM' '0060'.
    performbdc_field       using 'BDC_CURSOR'
                                  'RMMG1-MTART'. 
    performbdc_field       using 'BDC_OKCODE'
                                  'ENTR'.
    performbdc_field       using 'RMMG1-MATNR'
    record-MATNR_001. "pass material no
    performbdc_field       using 'RMMG1-MBRSH'
    record-MBRSH_002. "pass industry sector
    performbdc_field       using 'RMMG1-MTART'
    record-MTART_003. "pass material type
    performbdc_dynpro      using 'SAPLMGMM' '0070'.
    performbdc_field       using 'BDC_CURSOR'
                                  'MSICHTAUSW-DYTXT(01)'.
    performbdc_field       using 'BDC_OKCODE'  "enter
                                  '=ENTR'.
    performbdc_field       using 'MSICHTAUSW-KZSEL(01)'
    record-KZSEL_01_004. "basic view1 pass 'X'
    performbdc_dynpro      using 'SAPLMGMM' '4004'. "calling second screen (basic view1)
    performbdc_field       using 'BDC_OKCODE'
                                  '=BU'.
    performbdc_field       using 'MAKT-MAKTX'
    record-MAKTX_005. "material description
    performbdc_field       using 'BDC_CURSOR'
                                  'MARA-MEINS'.  "base unit of meassure
    performbdc_field       using 'MARA-MEINS'
    record-MEINS_006.
    performbdc_transaction using 'MM01'.  "finally calling transaction
    

    Add data declerations

    Add required data declerations for material data as per flat file

    TYPES: BEGIN OF TY_MARA, "user defined types as per flat file
           MATNR TYPE MARA-MATNR,
           MBRSH TYPE MARA-MBRSH,
           MTART TYPE MARA-MTART,
           MEINS TYPE MARA-MEINS,
           MAKTX TYPE MAKT-MAKTX,
           END OF TY_MARA.
    DATA : IT_MARA TYPE TABLE OF TY_MARA, "mara internal table
           WA_MARA TYPE TY_MARA. "mara work area
    DATA: IT_BDCDATA TYPE TABLE OF BDCDATA . "BDCDATA
    DATA: WA_BDCDATA TYPE BDCDATA . "work area BDCDATA
    DATA : BDCMSG TYPE TABLE OF BDCMSGCOLL. "BDC message table
    DATA:FILE TYPE STRING. "file name
    PARAMETERS : P_FILE TYPE RLGRAP-FILENAME. "input parameter for file upload
    

    Upload data from flat file

    Upload data into a internal table from a flat file using GUI_UPLOAD, all BDC performs are available in standard programs, simpley double click on each perform and copy from standard program, paste at the bottom.

        FILE = P_FILE.
        CALL FUNCTION 'GUI_UPLOAD' "upload flat file
          EXPORTING
            FILENAME            = FILE "file name
            FILETYPE            = 'ASC' "file type
            HAS_FIELD_SEPARATOR = 'X' "is tab delimited
          TABLES
            DATA_TAB            = IT_MARA.
        IF SY-SUBRC < > 0.
    * Implement suitable error handling here
        ENDIF.
    

    Process records one by one to BDC

    Loop through internal table and pass records to BDC call transaction.

    LOOP AT IT_MARA INTO WA_MARA. "loop all records and pass one by one to BDC
        PERFORM BDC_DYNPRO      USING 'SAPLMGMM' '0060'.
        PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                                      'RMMG1-MTART'.
        PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                      'ENTR'.
        PERFORM BDC_FIELD       USING 'RMMG1-MATNR'
                                      WA_MARA-MATNR. "pass material no
        PERFORM BDC_FIELD       USING 'RMMG1-MBRSH'
                                      WA_MARA-MBRSH. "passindistry sector
        PERFORM BDC_FIELD       USING 'RMMG1-MTART'
                                      WA_MARA-MTART. "pass material type
        PERFORM BDC_DYNPRO      USING 'SAPLMGMM' '0070'.
        PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                                      'MSICHTAUSW-DYTXT(01)'.
        PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                      '=ENTR'.
        PERFORM BDC_FIELD       USING 'MSICHTAUSW-KZSEL(01)'  "select basic view1
                                      'X'.
        PERFORM BDC_DYNPRO      USING 'SAPLMGMM' '4004'.
        PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                      '=BU'.
        PERFORM BDC_FIELD       USING 'MAKT-MAKTX'
                                      WA_MARA-MAKTX. "pass material description
        PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                                      'MARA-MEINS'.
        PERFORM BDC_FIELD       USING 'MARA-MEINS'
                                      WA_MARA-MEINS. "pass base unit oemeassure
    
        CALL TRANSACTION 'MM01' USING IT_BDCDATA "call transaction
                              MODE 'N' "N-no screen mode, A-all screen mode, E-error screen mode
                              UPDATE 'A' "A-assynchronous, S-synchronous
                              MESSAGES INTO  BDCMSG. "messages
        IF SY-SUBRC EQ 0.
    WRITE :/  WA_MARA-MATNR, 'submitted to BDC'.
        ENDIF.
    
      ENDLOOP.
    

     

    Apply now for Advanced SAP Course

    Copyright 1999- Ducat Creative, All rights reserved.

    Anda bisa mendapatkan server slot online resmi dan terpercaya tentu saja di sini. Sebagai salah satu provider yang menyediakan banyak pilihan permainan.