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

read from flat file

Former Member
0 Likes
787

Hi experts,

how can i read from flat file .

5 REPLIES 5
Read only

Former Member
0 Likes
763

Press F1 on OPEN DATASET.

Rob

Read only

Former Member
0 Likes
763

Hi..

You can use Function module :

GUI_UPLOAD.

CALL FUNCTION GUI_UPLOAD.

Regards

Sandeep.

Read only

Former Member
0 Likes
763

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

Read only

Former Member
0 Likes
763

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.

Read only

Former Member
0 Likes
763

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 )