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

Load file

Former Member
0 Likes
734

Hi experts,

I have a problum that is need to upload a text file from my c drive .I am using ws_upload function module for it,a internal table i created for same structure of my file want to upload a file .

thanks

2 REPLIES 2
Read only

Former Member
0 Likes
408

Try something like this:

REPORT ZUPLOAD.

data: begin of lt_gen occurs 0,

str(50),

end of lt_gen.

data: begin of lt_mara occurs 0,

matnr like mara-matnr,

mbrsh like mara-mbrsh,

end of lt_mara.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = 'c:\mat.txt'

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

  • VIRUS_SCAN_PROFILE =

  • NO_AUTH_CHECK = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

TABLES

DATA_TAB = lt_gen

  • 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 lt_gen.

split lt_gen-str at ',' into lt_mara-matnr lt_mara-mbrsh.

append lt_mara.

endloop.

delete adjacent duplicates from lt_mara.

sort lt_mara.

loop at lt_mara.

write:/ lt_mara-matnr, lt_mara-mbrsh.

endloop.

Read only

Former Member
0 Likes
408

Hi Ankur,

Try to Upload Using GUI_UPLOAD Ok in that Provide the File with the drive itself. And if the Flat file(Text file) is having Tab Spacing then U give 'X' in Has_Field_Seperator.

Bye

Murthy