Skip to end of metadata
Go to start of metadata
  1. Give the t-code shdb in the command field.
  2. Click the new recording button. Give a name to the recording and the t-code you want to record.
     E.g.:
              Recording                           : Z_UPLOAD
              Transaction code                : MM01
  3. When you click save, it takes you to t-code (MM01) you would like to do recording for upload.
  4. Record carefully. Fill in the details you want to upload. In this case I have entered the material no, industry sector, material type, material description and basic unit of measure.
  5. Then the Transaction recorder - edit recording Z_UPLOAD screen is displayed. You can edit your recording or just save it and click back button. Select your recording and click create program button.
  6. Enter the program name say Z_UPLOAD.Select the transfer from recording option. Save it.Give the program title, type as executable program and click source code button at the bottom.
  7. The following piece of code is generated automatically.

report Z_UPLOAD

no standard page heading line-size 255.

 include bdcrecx1.

 start-of-selection.

 perform open_group.

 perform bdc_dynpro      using 'SAPLMGMM' '0060'.
perform bdc_field          using 'BDC_CURSOR'

                                      'RMMG1-MATNR'.

perform bdc_field          using 'BDC_OKCODE'

                                       '=AUSW'.

perform bdc_field          using 'RMMG1-MATNR'

                                       'MYMATERIAL10'.

perform bdc_field          using 'RMMG1-MBRSH'

                                       'P'.

perform bdc_field          using 'RMMG1-MTART'

                                       'ZOH'.

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)'

                                       'X'.

perform bdc_dynpro      using 'SAPLMGMM' '4004'.

perform bdc_field          using 'BDC_OKCODE'

                                       '=BU'.

perform bdc_field          using 'MAKT-MAKTX'

                                       'MY MATERIAL10'.

perform bdc_field          using 'BDC_CURSOR'

                                       'MARA-MEINS'.

perform bdc_field          using 'MARA-MEINS'

                                       'G'.

perform bdc_field          using 'MARA-MTPOS_MARA'

                                       'NORM'.

perform bdc_transaction using 'MM01'.

 Perform close_group.

    8. Now make the necessary changes highligted in blue color.

report Z_UPLOAD
       no standard page heading line-size 255.
 *types declaration............................................*
 types : begin of t_mat,
   matnr(20),
   desc(50),
   uom(5),
end of t_mat.
 *internal table and workarea declaration........................*
 data : i_mat type table of t_mat.
data : wa_mat type t_mat.
 include bdcrecx1.
start-of-selection.
 *moving the flat file content to internal table...................*
 CALL FUNCTION 'UPLOAD'

 EXPORTING

** CODEPAGE = ' ' 

FILENAME = 'BDCDATA1'           " Name of the tab delimited flat file on desktop 

FILETYPE = 'DAT'

* ITEM = ' '

** FILEMASK_MASK = ' '

** FILEMASK_TEXT = ' '

** FILETYPE_NO_CHANGE = ' '

** FILEMASK_ALL = ' '

** FILETYPE_NO_SHOW = ' '

** LINE_EXIT = ' '

** USER_FORM = ' '

** USER_PROG = ' '

** SILENT = 'S'

** IMPORTING

** FILESIZE =

** CANCEL =

** ACT_FILENAME =

** ACT_FILETYPE = 

TABLES 

data_tab = i_mat                   " Name of internal table with data.

** EXCEPTIONS

** CONVERSION_ERROR = 1

** INVALID_TABLE_WIDTH = 2

** INVALID_TYPE = 3

** NO_BATCH = 4

** UNKNOWN_ERROR = 5

** GUI_REFUSE_FILETRANSFER = 6

** OTHERS = 7*

.IF sy-subrc <> 0.*

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

** WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

*ENDIF.

perform open_group.
 loop at i_mat into wa_mat.
 perform bdc_dynpro      using 'SAPLMGMM' '0060'.
perform bdc_field       using 'BDC_CURSOR'
                                   'RMMG1-MATNR'.
perform bdc_field       using 'BDC_OKCODE'
                                    '=AUSW'.
perform bdc_field       using 'RMMG1-MATNR'
                                    wa_mat-matnr.
perform bdc_field       using 'RMMG1-MBRSH'
                                    'P'.
perform bdc_field       using 'RMMG1-MTART'
                                    'ZOH'.
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)'
                                    'X'.
perform bdc_dynpro   using 'SAPLMGMM' '4004'.
perform bdc_field       using 'BDC_OKCODE'
                                    '=BU'.
perform bdc_field       using 'MAKT-MAKTX'
                                    wa_mat-desc.
perform bdc_field       using 'BDC_CURSOR'
                                    'MARA-MEINS'.
perform bdc_field       using 'MARA-MEINS'
                                    wa_mat-uom.
perform bdc_field       using 'MARA-MTPOS_MARA'
                                    'NORM'.
perform bdc_transaction using 'MM01'.
 refresh bdcdata.

endloop.
 
Perform close_group.
       We can choose either the session or call transaction method. In our case we continue with session method. Give a name to session say ZMAT_UPLOAD and execute.

 Then you will get a prompt, select the desired file and press the transfer buton.

The session gets crested,

       Then go to SM35 and select your session and click process.

We can process it in 3 modes, choose which ever suites your requirement.

  • No labels