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

Help me on using GUI_UPLOAD function

Former Member
0 Likes
2,105

Dear my friends,

I am using GUI_UPLOAD function to upload a file.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

  • filename contain file path

FILENAME = filepath

  • filetype is ASC

FILETYPE = 'ASC'

  • Use tab key to seperate field

HAS_FIELD_SEPARATOR = ','

  • Internal table keep data from file by function GUI_UPLOAD

TABLES

data_tab = tblTrantable.

but it did not work for HAS_FIELD_SEPARATOR option.

although i tried to use HAS_FIELD_SEPARATOR = '#'

but system still return by fix lengh data column not by separator.

<u>note : my SAP version = 4.6C</u>

Please help me,

Thanks !

Message was edited by:

Quoc Luc Nguyen

Message was edited by:

Quoc Luc Nguyen

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,828

hi,

try specifying 'X' for has field separator parameter. or try calling ws_upload

14 REPLIES 14
Read only

Former Member
0 Likes
1,829

hi,

try specifying 'X' for has field separator parameter. or try calling ws_upload

Read only

Former Member
0 Likes
1,828

can you mention the error that you have got when using this function

Read only

Former Member
0 Likes
1,828

hi,

set has field separartor to 'x'.

chk this FM for example:

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = W_FILENAME1

FILETYPE = W_FILETYPE1

HAS_FIELD_SEPARATOR = 'X'

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

DAT_MODE = 'X'

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

  • VIRUS_SCAN_PROFILE =

  • NO_AUTH_CHECK = ' '

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

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,

keerthi

Read only

Former Member
0 Likes
1,828

hi,,

try this

HAS_FIELD_SEPARATOR = 'X' .

cheers

sri

Read only

Former Member
0 Likes
1,828

Dear my friends,

i have tried many times, but it still seprate column by fix lengh which is defined on internal table.

for ex : my data file contain

Column1,Column2,Column3

internal table :

types : begin of Trantable,

GLAccount(10) type C,

Amount(13) type C,

TaxCode(2) type C

end of Trantable.

when i write data after upload

result always :

GL Account = Column1,Co

Amount = lumn2,Column3

TaxCode =

this mean, system separate by fixlenght, not by separator

Read only

0 Likes
1,828

Hi Quoc ,

What is the saperator you are using in the file ,

Regards

Arun

Read only

Former Member
0 Likes
1,828

Dear my friend,

first time, i am use TAB for separator but it did not work.

so, now i am using COMMA for separator but it still does not work

thanks !

Read only

0 Likes
1,828

Hi,

use tab separator and set dat mode = 'X'.

regards,

keerthi

Read only

0 Likes
1,828

Hi Quoc ,

Use a tab delimited file and use the following statement

<b> HAS_FIELD_SEPARATOR = '#'</b> in you r FM. This will work.

Here is a sample code for the same

types : begin of Trantable,
GLAccount(10) type C,
Amount(13) type C,
TaxCode(2) type C,
end of Trantable.


Data : it_1 type table of trantable ,
       wa_1 type trantable.

data : v_file type string.

v_file = 'c:arun.txt'."File Name


CALL FUNCTION 'GUI_UPLOAD'
  EXPORTING
    filename                      = v_file
*   FILETYPE                      = 'ASC'
   HAS_FIELD_SEPARATOR           = '#'
*   HEADER_LENGTH                 = 0
*   READ_BY_LINE                  = 'X'
*   DAT_MODE                      = ' '
* IMPORTING
*   FILELENGTH                    =
*   HEADER                        =
  tables
    data_tab                      = it_1.
* 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 it_1 into wa_1.


endloop.

Regards

Arun

Read only

Former Member
0 Likes
1,828

Hi quoc,

specify the seperator as 'X',it will work.

HAS_FIELD_SEPARATOR = 'X'

Read only

Former Member
0 Likes
1,828

Dear my friends,

thanks your time so much,

I have tried on two different SAP server,

it work on one SAP server but it does not work on other.

so, i don not know the reason.

is there any special setting on other server !?

thanks !

Read only

Former Member
0 Likes
1,828

Dear my friends,

Is there any function with the same feature with GUI_UPLOAD,

may be, i will try other function

thanks !

Read only

0 Likes
1,828
START-OF-SELECTION.
  gd_file = p_infile.

  CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
      filename                = gd_file
      has_field_separator     = 'X'  "file is TAB delimited
    TABLES
      data_tab                = it_record
    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 NE 0.
      write: 'Error ', sy-subrc, 'returned from GUI_UPLOAD FM'.
      skip.
    endif.

<b>Upload Tab delimited file from PC into internal table</b>

Refer this link

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

Read only

Former Member
0 Likes
1,828

hi,

You should try with 'X' !

HAS_FIELD_SEPARATOR = 'X' .

Regards,

Mehfuze