Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Flat file to upload data using BDC for transaction MM01

Former Member
0 Kudos

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.

1 ACCEPTED SOLUTION

varma_narayana
Active Contributor
0 Kudos

Hi Sumanth..

Only the First Record gets Uploaded in your case ..

Bcoz you have not Refreshed the BDCDATA Internal table after the BDC_INSERT.

So change your code like this.

perform bdc_transaction using 'MM01'.

<b> REFRESH IT_BDCDATA.</b> "This statement must be used here.

endloop.

Now it works for u...

<b>reward if Helpful.</b>

3 REPLIES 3

Former Member
0 Kudos

Hi Sumant,

just concentrate on bold one

report ZMAT_UPLOAD

no standard page heading line-size 255.

types declaration..........................................................................

<b>

data : begin of t_mat occurs 0,

matnr(20),

desc(50),

uom(5),

end of t_mat.</b>

internal table and workarea declaration.......................................

<b>*data : i_mat type table of t_mat.

*data : wa_mat type t_mat.</b>

include bdcrecx1.

start-of-selection.

moving the flat file content to internal table................................

CALL FUNCTION 'UPLOAD'

EXPORTING

FILETYPE = 'DAT'

TABLES

<b>data_tab = i_mat.---> t_mat.</b>

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.

<b>loop at i_mat into wa_mat.------>loop at t_mat.</b>

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'

<b>wa_mat-matnr.---->t_mat-matnr(change in this for ur wa to t_mat.</b>

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.

Reward points for helpful answers.

Thanks

Naveen khan

Message was edited by:

Pattan Naveen

Message was edited by:

Pattan Naveen

Former Member
0 Kudos

Hi Praveen

It does not works.. i have tried it ..

we need to have internal rather than work area in upload fm

problem is not solved yet

varma_narayana
Active Contributor
0 Kudos

Hi Sumanth..

Only the First Record gets Uploaded in your case ..

Bcoz you have not Refreshed the BDCDATA Internal table after the BDC_INSERT.

So change your code like this.

perform bdc_transaction using 'MM01'.

<b> REFRESH IT_BDCDATA.</b> "This statement must be used here.

endloop.

Now it works for u...

<b>reward if Helpful.</b>