Application Development 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: 

Internal Table

Former Member
0 Kudos

I want to copy the data into internal table from flat file(legacy data) to check the data with SAP tables.How to insert that data from file into internal table?

7 REPLIES 7

Former Member
0 Kudos

HI USE THE FUNCTON MODULE

GUI_UPLOAD.

REGARDS

KARTHIK

former_member386202
Active Contributor
0 Kudos

Hi,

Use fm GUI_UPLOAD

*--Call the function to get the file into an internal table.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = lv_file

filetype = 'ASC'

TABLES

data_tab = pr_eord

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.

  • File not found.

MESSAGE e503.

ELSE.

otherwise FM for excel sheet ALSM_EXCEL_TO_INTERNAL_TABLE

Regards,

PRashant

Former Member
0 Kudos

hi

using GUI_upload function module you can achieve that.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = 'c:\material.txt'

FILETYPE = 'ASC'

  • HAS_FIELD_SEPARATOR = ' '

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

TABLES

DATA_TAB = itab

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

regards,

pavan

Message was edited by:

pavan kumar pisipati

Former Member
0 Kudos

use WS_UPLOAD

Former Member
0 Kudos

Hi,

If your file is on application server tab then you can do as follows :

First use Open Data base. Read the file using Read File and take the whole file in an internal table of type string. then do as follows :

Loop at it_file.

split it_file at ';' into itab-field1 itab-field2...

append itab.

clear it_file.

endloop.

Message was edited by:

Lalit Kabra

Former Member
0 Kudos

Hi Khanna,

Hi

creat a internal table of structure like ur internal table

and creat that flat file

and di like this

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = LV_FILENAME

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X' " Check here

  • HEADER_LENGTH = '1'

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

TABLES

DATA_TAB = IT_COJRNL

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.

<b>Kindly reward points if you found the reply helpful.<b>

Cheers,

Chaitanya.

paruchuri_nagesh
Active Contributor
0 Kudos

hi

have look at this code

REPORT ZBDC1.

TABLES: LFA1.

DATA: BEGIN OF ITAB OCCURS 0,

EMPNO LIKE ZEMP-EMPNO,

NAME1 LIKE ZEMP-NAME1,

ORT01 LIKE ZEMP-ORT01,

END OF ITAB.

DATA: BEGIN OF JTAB OCCURS 0.

INCLUDE STRUCTURE BDCDATA.

DATA: END OF JTAB.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = 'C:/NAG.TXT'

FILETYPE = 'ASC'

  • HAS_FIELD_SEPARATOR = ' '

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

TABLES

DATA_TAB = ITAB

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

write 😕 itab-empno,itab-name1,itab-ort01.

endloop.

Reward for useful inputs

Regards

Nagesh.Paruchuri