‎2008 Jan 25 4:46 PM
‎2008 Jan 25 5:00 PM
‎2008 Jan 25 5:02 PM
Hi..
You can use Function module :
GUI_UPLOAD.
CALL FUNCTION GUI_UPLOAD.
Regards
Sandeep.
‎2008 Jan 25 5:22 PM
Hi,
The usage of syntax depends upon where the flat file is located.
If you are trying to read the flat file from the presentation server(local PC), then you can use the function module GUI_UPLOAD.
If you are trying to read a flat file from the application server, then you need to use OPEN DATASET command.
These are very simple to use, you just need to do a F1 and go through the sample code provided in the help.
I hope this helps.
Edited by: Priyabrata Samanta on Jan 25, 2008 10:53 PM
‎2008 Jan 25 5:33 PM
1. To Read/Upload file from Physical/User's machine use the FM:CALL FUNCTION 'GUI_UPLOAD'
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = p_file
filetype = 'ASC'
TABLES
data_tab = itab
So ur internal table itab will have the data from the File u wish to read/upload.
2. To read file form application Server.
DATA: DSN(20) VALUE '/usr/test',
RECORD(80).
OPEN DATASET DSN.
DO.
READ DATASET DSN INTO RECORD.
IF SY-SUBRC NE 0.
EXIT.
ELSE.
WRITE: / RECORD.
ENDIF.
ENDDO.
CLOSE DATASET DSN.
Hope this helps.
‎2008 Jan 25 5:38 PM
Hi Manjula
see this code...uploading material number
p_file1 LIKE rlgrap-filename.
DATA: l_line TYPE string,
l_matnr LIKE mara-matnr.
OPEN DATASET p_file1 FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc NE 0.
MESSAGE ID 'FB' TYPE 'E' NUMBER '002'
WITH p_file1.
ENDIF.
DO.
CLEAR: l_line,
l_matnr.
READ DATASET p_file1 INTO l_line.
IF sy-subrc <> 0.
EXIT.
ENDIF.
l_matnr = l_line.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = l_matnr
IMPORTING
output = l_matnr.
APPEND l_matnr TO it_material.
ENDDO.
CLOSE DATASET p_file1.
for opening application server path :
CALL FUNCTION 'F4_DXFILENAME_4_DYNP'
EXPORTING
DYNPFIELD_FILETYPE =
dynpfield_filename = 'P_FILE1'
dyname = sy-repid
dynumb = sy-dynnr
filetype = 'P'
location = 'A'
server = ''
sy-repid = program name
sy-dynnr = 1000 ( selection screen )