‎2007 Jun 04 4:14 PM
I have program with internal table declared as below with 2 fields.
when i specify the input file using FILENAME = P_FILE.....
the input file has only one field values(i.e. only matnr values).
So, I am getting error : "unable to load input file".
so my query is Can i specify input file with only matnr values and download into internal table (ITAB_MATNR--which has 2 fields)
DATA: BEGIN OF ITAB_MATNR OCCURS 0,
MATNR LIKE MARA-MATNR,
COUNT TYPE I,
END OF ITAB_MATNR.
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
FILENAME = P_FILE
filetype = ftype
TABLES
DATA_TAB = ITAB_MATNR
EXCEPTIONS
CONVERSION_ERROR = 1
FILE_OPEN_ERROR = 2
FILE_READ_ERROR = 3
INVALID_TABLE_WIDTH = 4
INVALID_TYPE = 5
NO_BATCH = 6
UNKNOWN_ERROR = 7
GUI_REFUSE_FILETRANSFER = 8
OTHERS = 9.
IF SY-SUBRC <> 0.
MESSAGE E699(PP) WITH 'Unable to load input file' P_FILE.
ENDIF.
Regards
Vaja
‎2007 Jun 04 5:07 PM
Hi,
I think you miss file type and importing parameters. The ws_upload is look like this:
<u><b>Important Export Parameters:</b></u>
CODEPAGE - Only for upload under DOS: Value IBM
FILENAME - Filename
FILETYPE - File type
Use the FILETYPE parameter to specify the transfer mode. Possible values:
BIN
Binary files
ASC
ASCII files: Text files with end of line markers.
DAT
Excel files, saved as text files with columns separated by tabs and lines separated by
line breaks.
WK1
Excel and Lotus files saved as WK1 spreadsheets.
<u><b>Export Parameters:</b></u>
FILELENGTH - Number of bytes transferred
<u><b>Tables Parameters:</b></u>
DATA_TAB - Internal table (target for the import)
<u><b>Exception Parameters:</b></u>
CONVERSION_ERROR - Error converting data
FILE_OPEN_ERROR - Unable to open the file
FILE_READ_ERROR - Unable to read the file
INVALID_TABLE_WIDTH - Invalid table structure
INVALID_TYPE Value of FILETYPE parameter is incorrect
Ex:
Suppose the presentation server is running under Windows NT, and contains the
following text file:
"This file is text file, that is edited with the WINDOWS-notepad editor. It serves to demonstrate how the function module WS_UPLOAD works".
Code;
The following program reads the text file:
PROGRAM SAPMZTST.
DATA: FLENGTH TYPE I.
DATA: TAB(80) OCCURS 5 WITH HEADER LINE.
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
CODEPAGE = 'IBM'
FILENAME = 'd:\temp\mytext.txt'
FILETYPE = 'ASC'
IMPORTING
FILELENGTH = FLENGTH
TABLES
DATA_TAB = TAB
EXCEPTIONS
CONVERSION_ERROR = 1
FILE_OPEN_ERROR = 2
FILE_READ_ERROR = 3
INVALID_TABLE_WIDTH = 4
INVALID_TYPE = 5.
WRITE: 'SY-SUBRC:', SY-SUBRC,
/ 'Length :', FLENGTH.
SKIP.
LOOP AT TAB.
WRITE: / TAB.
ENDLOOP.
Regards,
Bhaskar
‎2007 Jun 04 9:42 PM
Hi baskar ,
thanks for ur reply.
the actual problem is : Iam using the FM 'WS_UPLOAD' with file name as export parameter and data should be populated into internal table .
but iam getting error bcoz the internal table is declared with 2 fields.
and file(file from presentation server) iam using has only one field values i.e. MATNR values
so iam getting error.
even if u dont specify file type it takes default file type ASCII.
so my query is -
i want to upload file with only single field values (MATNR values ) and data shold be populated into internal table which has 2 field fields.
regards
vaja
‎2007 Jun 04 9:52 PM
Hi mallikarjun,
Check what is the value of sy-subrc after the call to the FM.
It will tell you what is the exact problem.
eg: if you get sy-subrc = 4, then it means the table eidth is invalid.
Regards,
Ravi
‎2007 Jun 04 11:06 PM
you can specify any number fields in file and any number fields in internal table,
see the program and when you specify the count variable in your internal table ,if the data is not available,then it will take some defualt values,other than this one it will be okay.
In my system count variable data is 538976288 if the file does not have value.
report x.
DATA: BEGIN OF ITAB_MATNR OCCURS 0,
MATNR LIKE MARA-MATNR,
COUNT TYPE i,
END OF ITAB_MATNR.
data : v_repid like sy-repid.
parameters p_file like rlgrap-filename.
initialization.
v_repid = sy-repid.
at selection-screen on value-request for p_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = v_repid
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = ' '
IMPORTING
FILE_NAME = p_file
.
start-of-selection.
refresh itab_matnr.
clear itab_matnr.
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
FILENAME = P_FILE
filetype = 'ASC'
TABLES
DATA_TAB = ITAB_MATNR
EXCEPTIONS
CONVERSION_ERROR = 1
FILE_OPEN_ERROR = 2
FILE_READ_ERROR = 3
INVALID_TABLE_WIDTH = 4
INVALID_TYPE = 5
NO_BATCH = 6
UNKNOWN_ERROR = 7
GUI_REFUSE_FILETRANSFER = 8
OTHERS = 9.
IF SY-SUBRC <> 0.
MESSAGE E699(PP) WITH 'Unable to load input file' P_FILE.
ENDIF.
in my file
data is like ( No count)
matnr
12344
ssss
sddd
sddff
after ws_upload :
material count
12344 | 538976288 |
ssss | 538976288 |
sddd | 538976288 |
sddff | 538976288