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

uploading flat file

Former Member
0 Likes
759

hi ,

can any one help me how to upload the data in flat file to an internal table .the file is of tabe table of delimiter .

Regards,

kumar

8 REPLIES 8
Read only

Former Member
0 Likes
736

Hi,

Use GUI_UPLOAD func.module.

Regards

Subramanian

Read only

Former Member
0 Likes
736

fm GUI_UPLOAD or WS_UPLOAD(OBSOLETE).

here give file type DAT.

regards

shiba dutta

Read only

Former Member
0 Likes
736

Hi,

Try using the function module GUI_UPLOAD and pass HAS_FIELD_SEPARATOR = 'X' to get tab delimited file..

THanks,

Naren

Read only

Former Member
0 Likes
736

Hi ,

you can use followinf FM.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = LV_FILENAME

FILETYPE = 'ASC'

TABLES

data_tab = IT_DATA_FILE

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,

Sumit

Read only

Former Member
0 Likes
736
parameters: p_fname like rlgrap-filename.

types: begin of t_data,
         fld1(300) type c,
         fld2(10) type c,
       end of t_data.
data: it_data type standard table of t_data,
      wa_data type t_data.
data: l_fname type string.
 
 
at selection-screen on value-request for p_fname.
 
CALL FUNCTION 'F4_FILENAME'
 IMPORTING
   FILE_NAME           = p_fname.
 
start-of-selection.
 
l_fname = p_fname.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD
  EXPORTING
    FILENAME                = l_fname
*    FILETYPE                = 'ASC'
    HAS_FIELD_SEPARATOR     = 'X'
*    HEADER_LENGTH           = 0
*    DAT_MODE                = SPACE
*    CODEPAGE                = SPACE
*    IGNORE_CERR             = ABAP_TRUE
*    REPLACEMENT             = '#'
*    READ_BY_LINE            = 'X'
*  IMPORTING
*    FILELENGTH              =
*    HEADER                  =
  CHANGING
    DATA_TAB                = it_data[]
  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
    NOT_SUPPORTED_BY_GUI    = 17
    ERROR_NO_GUI            = 18
    others                  = 19.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Read only

Former Member
0 Likes
736

mahendra,

DATA : s_filename(400),

I_TEMP(400).

OPEN DATASET S_FILENAME FOR input IN TEXT MODE.

IF SY-SUBRC EQ 0.

DO.

READ DATASET s_filename INTO I_TEMP.

IF SY-SUBRC <> 0.

EXIT.

ELSE.

move I_TEMP to I_FINALTAB.

append I_FINALTAB.

clear I_FINALTAB.

ENDIF.

ENDDO.

ENDIF.

CLOSE DATASET s_filename .

Pls.Mark if useful.

Read only

Former Member
0 Likes
736

Use FM GUI_UPLOAD'. The sample code is as pasted below:

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = 'C:/TESTDATAXKO1.TXT'

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X '

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

TABLES

DATA_TAB = it_upload

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

.

Read only

Former Member
0 Likes
736

Refer this link, will help to solve ur problem

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