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

Upload data from flat file into internal table

Former Member
1,036

Hi friends,

I want to upload the data from a flat file into internal table , but the problem is that all the columns in that flat file are seperated by "|" character instead of tabs.

Plz help me out.........

4 REPLIES 4
Read only

Former Member
0 Likes
598

HEllo,

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

VAsanth

Read only

0 Likes
598

My fields are seperated by a symbol "|" not tab .

and the file is in TXT format.

so this line HAS_FIELD_SEPARATOR = 'X' " Check here

is not working here

Read only

0 Likes
598

Hi

i have a problem with PERNO ,

in role EMP PERNo is a standard field, when i entered data in BP it is taking input , but in table BUT000 it is not desplaying,

i added the same field for MKK role , which has a additional field ,

but this accepting the data BP , but showing in 00 in BUT000,

is this a mistake in config or it is done by abap code only ?

please , its urgent

full points will be in waiting

Read only

uwe_schieferstein
Active Contributor
0 Likes
598

Hello Archit

First of all you should use the static method CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD instead of the function module because the method is already Unicode-enabled.

You have to set parameter HAS_FIELD_SEPARATOR = ' ' (space) because your data are NOT separated by Tabs.

Check in the debugger how the character "|" is represented. Based on the character table on my Windows XP desktop "I" corresponds to U+007C.

For converting the data you can use function module TEXT_CONVERT_TEX_TO_SAP using "|" as field separator (parameter I_FIELD_SEPERATOR). However, if the converted data contain any "#" the SAP system interprets the field separator different in your ABAP program and the uploaded file data.

Regards

Uwe