HI EXPERTS,
i have written a coding as per the requirement for inventory data upload by using transaction code 'MI01'.but it is always showing an error that " flat file is not found".please help me in solving this problem.
here is the coding.
report ZMM_RDD0009_MATERIAL_INVENTORY
no standard page heading line-size 255.
structure declaration.
types : begin of TY_UPLOAD ,
WERKS TYPE IKPF-WERKS,
LGORT TYPE IKPF-LGORT,
MATNR TYPE ISEG-MATNR,
END OF TY_UPLOAD.
INTERNAL TABLE DECLARATION.
internal table for upload the data.
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,
WORK-AREA DECLARATION.
work-area for upload the data.
w_upload type ty_upload,
bdcdata type bdcdata,
work-area for bdcmsgcoll.
w_bdcmsg type bdcmsgcoll,
*global variable declaration.
g_message(70) type c.
*include bdcrecx1.
start-of-selection.
call function 'GUI_UPLOAD'
exporting
filename = 'D:/FLATFILE.TXT'
filetype = 'ASC'
has_field_separator = 'X'
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
IMPORTING
FILELENGTH =
HEADER =
tables
data_tab = t_upload.
EXCEPTIONS
call function 'BDC_OPEN_GROUP'
exporting
client = sy-mandt
DEST = FILLER8
group = 'ERROR_MAT'
HOLDDATE = ''
KEEP = 'X'
user = sy-uname
RECORD = FILLER1
prog = sy-cprog.
loop at t_upload into w_upload.
refresh t_bdcdata.
*perform open_group.
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 'RM07I-BLDAT'
'W_UPLOAD-BLDAT'.
*perform bdc_field using 'RM07I-GIDAT'
'W_UPLOAD-GIDAT'.
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)'
'W_UPLOAD-MATNR(02)'.
perform bdc_dynpro using 'SAPMM07I' '0721'.
perform bdc_field using 'BDC_CURSOR'
'ISEG-MATNR(01)'.
perform bdc_field using 'BDC_OKCODE'
'=BU'.
*perform bdc_transaction using 'MI01'.
*perform close_group.
call transaction 'MI01' using t_bdcdata mode 'N' update 'S'
messages into t_bdcmsgcoll.
if sy-subrc <> 0.
*append w_upload to t_error.
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'.
EXCEPTIONS
NOT_OPEN = 1
QUEUE_ERROR = 2
OTHERS = 3
.
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
----
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.
Edited by: rohit on Jun 10, 2008 1:09 PM