Application Development and Automation 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: 
Read only

bdc program problem for mi01

Former Member
0 Likes
540

hi expects,

i have an issue that the data upload is done for only one times. how could i do the upload of data for multiple times.and i am not get the data upload to the transaction "mi01".please help me to solve the problem.

types : begin of ty_upload ,

werks type ikpf-werks,

lgort type ikpf-lgort,

matnr type iseg-matnr,

end of ty_upload.

parameters: p_file type localfile obligatory.

data:t_upload type standard table of ty_upload initial size 0,

*internal table for bdcdata.

t_bdcdata type standard table of bdcdata initial size 0 ,

*internal table for bdcmsgcoll.

t_bdcmsgcoll type standard table of bdcmsgcoll initial size 0,

t_error type standard table of ty_upload initial size 0,

w_upload type ty_upload,

w_file type string,

bdcdata type bdcdata,

w_bdcmsg type bdcmsgcoll,

*global variable declaration.

g_message(70) type c.

at selection-screen on value-request for p_file.

call function 'F4_FILENAME'

exporting

program_name = syst-cprog

dynpro_number = syst-dynnr

importing

file_name = p_file.

start-of-selection.

w_file = p_file.

call function 'GUI_UPLOAD'

exporting

filename = w_file

filetype = 'ASC'

has_field_separator = 'X'

tables

data_tab = t_upload.

check sy-subrc = 0.

call function 'BDC_OPEN_GROUP'

exporting

client = sy-mandt

group = 'ERROR_MAT'

user = sy-uname

prog = sy-cprog.

check sy-subrc = 0.

loop at t_upload into w_upload.

refresh t_bdcdata.

perform bdc_dynpro using 'SAPMM07I' '0700'.

perform bdc_field using 'BDC_CURSOR'

'IKPF-LGORT'.

perform bdc_field using 'BDC_OKCODE' '/00'.

perform bdc_field using 'IKPF-WERKS'

'W_UPLOAD-WERKS'.

perform bdc_field using 'IKPF-LGORT'

'W_UPLOAD-LGORT'.

perform bdc_field using 'RM07I-XLVOCA'

'X'.

perform bdc_dynpro using 'SAPMM07I' '0721'.

perform bdc_field using 'BDC_CURSOR'

'ISEG-MATNR(02)'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'ISEG-MATNR(01)'

'W_UPLOAD-MATNR(01)'.

*perform bdc_field using 'ISEG-MATNR(02)'

perform bdc_dynpro using 'SAPMM07I' '0721'.

perform bdc_field using 'BDC_CURSOR'

'ISEG-MATNR(01)'.

perform bdc_field using 'BDC_OKCODE'

'=BU'.

call transaction 'MI01' using t_bdcdata mode 'N' update 'S'

messages into t_bdcmsgcoll.

if sy-subrc = 0.

call function 'BDC_INSERT'

exporting

tcode = 'MI01'

tables

dynprotab = t_bdcdata.

endif.

clear w_bdcmsg.

read table t_bdcmsgcoll into w_bdcmsg index 1.

call function 'FORMAT_MESSAGE'

exporting

id = w_bdcmsg-msgid

lang = sy-langu

no = w_bdcmsg-msgnr

v1 = w_bdcmsg-msgv1

v2 = w_bdcmsg-msgv2

v3 = w_bdcmsg-msgv3

v4 = w_bdcmsg-msgv4

importing

msg = g_message

exceptions

not_found = 1

others = 2.

if sy-subrc = 0.

write:/ w_upload-werks,'----', g_message.

refresh t_bdcmsgcoll.

endif.

endloop.

call function 'BDC_CLOSE_GROUP'.

  • ----------------------------------------------------------------------

  • start new screen

  • ----------------------------------------------------------------------

form bdc_dynpro using program dynpro.

clear bdcdata.

bdcdata-program = program.

bdcdata-dynpro = dynpro.

bdcdata-dynbegin = 'X'.

append bdcdata to t_bdcdata.

clear bdcdata.

endform. "

  • --------------------------------------------------------------------

*insert field *

*----


form bdc_field using fnam fval.

  • IF fval NODATA.

clear bdcdata.

bdcdata-fnam = fnam.

bdcdata-fval = fval.

append bdcdata to t_bdcdata.

clear bdcdata.

  • ENDIF.

endform. "

FLAT FILE

PLANT SLOC MATL

KCPT SLC1 689

KCPT SLC1 690

3 REPLIES 3
Read only

Former Member
0 Likes
497

Hi Rohit,

Why are you going for call transaction in session method. I think this is the main problem with the code. Anyway you are going to create a session and try to run the session from sm35.

Hope this helps you.

Regards,

Chandra Sekhar

Read only

Former Member
0 Likes
497

This message was moderated.

Read only

Former Member
0 Likes
497

This message was moderated.