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

sample code help

Former Member
0 Likes
611

Hi All!

I am getting a .txt file from legacy systems.Now i have to read that file and put the values into internal tables using datasets for further processing.

Can anybody give me sample code on this.

Regards

Pavan

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
574

Hi,

From help.sap.com

http://help.sap.com/saphelp_47x200/helpdata/en/d3/2e974d35c511d1829f0000e829fbfe/frameset.htm

DATA FNAME(60) VALUE 'myfile'.

DATA: TEXT1(12) VALUE 'abcdefghijkl',

TEXT2(5),

LENG TYPE I.

OPEN DATASET FNAME FOR OUTPUT IN BINARY MODE.

TRANSFER TEXT1 TO FNAME.

CLOSE DATASET FNAME.

OPEN DATASET FNAME FOR INPUT IN BINARY MODE.

DO.

READ DATASET FNAME INTO TEXT2 LENGTH LENG.

WRITE: / SY-SUBRC, TEXT2, LENG.

IF SY-SUBRC <> 0.

EXIT.

ENDIF.

ENDDO.

CLOSE DATASET FNAME.

Regards,

Ravi

5 REPLIES 5
Read only

Former Member
0 Likes
574

data: begin of itab occurs 0,

rec(1000) type c,

end of itab.

start-of-selection.

call function 'GUI_UPLOAD'

exporting

filename = 'C:\test.txt'

tables

data_tab = itab.

loop at itab.

check sy-tabix > 1. " Skip first record

endloop.

Read only

0 Likes
574

HI Pavan,

Check this out

http://www.sapdevelopment.co.uk/file/file_uptabpc.htm

Regards,

Kalyani

Read only

Former Member
0 Likes
575

Hi,

From help.sap.com

http://help.sap.com/saphelp_47x200/helpdata/en/d3/2e974d35c511d1829f0000e829fbfe/frameset.htm

DATA FNAME(60) VALUE 'myfile'.

DATA: TEXT1(12) VALUE 'abcdefghijkl',

TEXT2(5),

LENG TYPE I.

OPEN DATASET FNAME FOR OUTPUT IN BINARY MODE.

TRANSFER TEXT1 TO FNAME.

CLOSE DATASET FNAME.

OPEN DATASET FNAME FOR INPUT IN BINARY MODE.

DO.

READ DATASET FNAME INTO TEXT2 LENGTH LENG.

WRITE: / SY-SUBRC, TEXT2, LENG.

IF SY-SUBRC <> 0.

EXIT.

ENDIF.

ENDDO.

CLOSE DATASET FNAME.

Regards,

Ravi

Read only

Former Member
0 Likes
574

Check the link below:

http://sap.ittoolbox.com/code/archives.asp?d=3095&a=s&i=10

for uploading file and convertion...

Cheers,

Thomas.

Read only

Former Member
0 Likes
574

Hi pavan,

Code like this...

<b>data : begin of file occurs 0,

v_mara(255),

end of file.

call function 'GUI_UPLOAD'

exporting

filename = 'C:\legacy.TXT'

filetype = 'ASC'

  • IMPORTING

  • FILELENGTH =

  • HEADER =

tables

data_tab = file

.

loop at file.

write : file-v_mara.

endloop</b>.