‎2008 May 24 6:50 AM
Hi Experts
I have prepared a flat file for a bdc upload.
when i execute the UPLOAD fm, my internal table is not getting the values, it returns the value 5(unknown error),
what could be the reason actually.
I am sure that i have prepared flat file correctly.
Pls advise me on this.
Thanks in advance.
Regards
Rajaram
‎2008 May 24 6:53 AM
Hi,
Try to use FM : GUI_UPLOAD or Class with GUI_UPLOAD
It will solves ur problem.
Reward points if helpful..
Regards,
N.L.
‎2008 May 24 8:01 AM
Hello Check out this its working fine for me..just change the upload path according to your file name of the flatfile you will get it
report ZCU_MM01 no standard page heading line-size 255.
*structure declaration
types: BEGIN OF TY_UPLOAD,
MATNR LIKE RMMG1-MATNR,
MBRSH LIKE RMMG1-MBRSH,
MTART LIKE RMMG1-MTART,
MAKTX LIKE MAKT-MAKTX,
MEINS LIKE MARA-MEINS,
END OF TY_UPLOAD.
INTERNAL TABLE & WORKAREA DECLARATION
DATA : T_UPLOAD TYPE STANDARD TABLE OF TY_UPLOAD INITIAL SIZE 0,
T_BDCDATA TYPE STANDARD TABLE OF BDCDATA INITIAL SIZE 0,
T_BDCMSGCOLL TYPE STANDARD TABLE OF BDCMSGCOLL INITIAL SIZE 0,
W_UPLOAD TYPE TY_UPLOAD,
BDCDATA TYPE BDCDATA,
W_BDCMSGCOLL TYPE BDCMSGCOLL,
G_MESSAGE TYPE C.
start-of-selection.
*perform open_dataset using dataset.
*perform open_group.
*
*do.
*
*read dataset dataset into record.
*if sy-subrc <> 0. exit. endif.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = 'D:\Documents and settings
Desktop\MM01_FL.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
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
NO_AUTHORITY = 6
UNKNOWN_ERROR = 7
BAD_DATA_FORMAT = 8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
OTHERS = 17
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT T_UPLOAD INTO W_UPLOAD.
REFRESH T_BDCDATA.
perform bdc_dynpro using 'SAPLMGMM' '0060'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-MATNR'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RMMG1-MATNR'
W_UPLOAD-MATNR.
perform bdc_field using 'RMMG1-MBRSH'
W_UPLOAD-MBRSH.
perform bdc_field using 'RMMG1-MTART'
W_UPLOAD-MTART.
perform bdc_dynpro using 'SAPLMGMM' '0070'.
perform bdc_field using 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(02)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
*perform bdc_field using 'MSICHTAUSW-KZSEL(01)'
record-KZSEL_01_004.
perform bdc_dynpro using 'SAPLMGMM' '4004'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'MAKT-MAKTX'
W_UPLOAD-MAKTX.
perform bdc_field using 'BDC_CURSOR'
'MARA-MEINS'.
perform bdc_field using 'MARA-MEINS'
W_UPLOAD-MEINS.
perform bdc_dynpro using 'SAPLSPO1' '0300'.
perform bdc_field using 'BDC_OKCODE'
'=CANC'.
perform bdc_dynpro using 'SAPLMGMM' '4004'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'BDC_CURSOR'
'MAKT-MAKTX'.
perform bdc_field using 'MAKT-MAKTX'
W_UPLOAD-MAKTX.
perform bdc_field using 'MARA-MEINS'
W_UPLOAD-MEINS.
perform bdc_dynpro using 'SAPLSPO1' '0300'.
perform bdc_field using 'BDC_OKCODE'
'=YES'.
CALL TRANSACTION 'MM01' USING T_BDCDATA MODE 'A' update 'S' MESSAGES
INTO T_BDCMSGCOLL.
CLEAR T_BDCMSGCOLL.
*perform bdc_transaction using 'MM01'.
*
*enddo.
*
*perform close_group.
*perform close_dataset using dataset.
*
READ TABLE T_BDCMSGCOLL INTO W_BDCMSGCOLL INDEX 1.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = SY-MSGID
LANG = '-D'
NO = SY-MSGNO
V1 = SY-MSGV1
V2 = SY-MSGV2
V3 = SY-MSGV3
V4 = SY-MSGV4
IMPORTING
MSG = G_MESSAGE
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
WRITE : W_UPLOAD-MATNR, W_UPLOAD-MAKTX.
ENDIF.
ENDLOOP.
----
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.
ENDIF.
ENDFORM.
‎2009 May 19 12:49 PM
‎2009 May 19 12:51 PM
The Comments Box while closing your thread is not mandatory. Please skip that box while closing your threads if not providing solutions thereby not bumping your old threads back into the queue.
pk