Skip to Content
0
Former Member
Sep 19, 2007 at 07:51 AM

Flat file to upload data using BDC for transaction MM01

43 Views

Hi

I am trying to update data using bdc code has been attached below using a txt file.

It is updating the first set of data into the table mara ,but for the rest it is not

All the data from txt file has being loaded to internal table , but the problem is it does not gets updated from internal table to the database .

Only the first set of data has been loaded ,<u><b> rest of the data is not loaded</b></u>

<u><b>content of txt file</b></u>

zsc zsc kg

zsv zsv kg

zsb zsb kg

<u><b>Actual code</b></u>

report ZMAT_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

FILETYPE = 'DAT'

TABLES

data_tab = i_mat.

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

endloop.

Perform close_group.