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 file problem

Former Member
0 Likes
1,902

HI,

i use this method to upload file from server the problem is that i get just one line (in data_tab) instead of 20,

and the first line is cutting what can be the problem?

Regards

TYPES: BEGIN OF tp_data_tab,
         text TYPE string,
         END OF tp_data_tab.

  DATA : data_tab TYPE STANDARD TABLE OF tp_data_tab.

CALL METHOD cl_gui_frontend_services=>gui_upload
    EXPORTING
      filename                = fir_file
      filetype                = 'ASC'
     has_field_separator     = 'X'
*    header_length           = 0
*      read_by_line            = 'X'
*    dat_mode                = space
*    codepage                = space
*     ignore_cerr             = abap_true
*    replacement             = '#'
*    virus_scan_profile      =
*  IMPORTING
*    filelength              =
*    header                  =
    CHANGING
      data_tab                = data_tab
    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.

Regards

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,764

If u are uploading a txt file then remove has_field_separator = 'X'

CALL METHOD cl_gui_frontend_services=>gui_upload

EXPORTING

filename = fir_file

filetype = 'ASC'

  • has_field_separator = 'X' -> comment this

12 REPLIES 12
Read only

Former Member
0 Likes
1,764

Hi,

Try this

call function 'DX_FILE_READ' destination d_server

exporting

filename = lv_app_ser_file

tables

data_tab = it_up1

exceptions

no_file_on_server = 1

no_data_on_server = 2

gui_upload_failed = 3

no_authority = 4

others = 5.

if file in application server cl_gui_frontend_services=>gui_upload

will not help.

Thanks,

Durai.V

Read only

0 Likes
1,764

Hi Durai V ,

thanks ,

but how i find the server name

and pc because i have dump.

Regards

Read only

0 Likes
1,764

Hi,

Can you tell me exactly, where the upload file?.

if it is in Application server. Go to AL11 t-code there you can see the file.

Go to menu click system ---> status -> there Host data block server name.

Thanks,

Durai.V

Read only

0 Likes
1,764

Hi Durai V ,

i try it but i have dump like :

An exception occurred that is explained in detail below.

The exception, which is assigned to class 'CX_SY_DYN_CALL_PARAM_MISSING', was

not caught in

procedure "Z__TEST_READ_FILE" "(FUNCTION)", nor was it propagated by a

RAISING clause.

Since the caller of the procedure could not have anticipated that the

exception would occur, the current program is terminated.

The reason for the exception is:

The reason for the exception is:

When calling the function module "DX_FILE_READ", one of the parameters

needed according to the interface description was not specified.

This parameter was "PC".

Regards

Read only

Former Member
0 Likes
1,765

If u are uploading a txt file then remove has_field_separator = 'X'

CALL METHOD cl_gui_frontend_services=>gui_upload

EXPORTING

filename = fir_file

filetype = 'ASC'

  • has_field_separator = 'X' -> comment this

Read only

0 Likes
1,764

HI sreekanth,

i try that and i get the same problem,

any other idea plz?

Regards

Read only

0 Likes
1,764

Is u r file on u r presentation server or application server.

I am using the same code for uploading file which is present on my presentation server in C drive of my system. I am getting all the records into data_tab from the file.I have checked both txt file and xls file in both the cases all the records are coming into data_tab

Read only

0 Likes
1,764

Hi sreekanth,

thanks,

how i now that?

i new with that.

i get path like : '
iltlvp01.t.st.corp\DE_Development\EP 6\Port\dept\Program Office\'.

Reagrds

Read only

0 Likes
1,764

Check this code if it is useful

REPORT ZSRK_046 .

DATA : FIR_FILE(512) VALUE '
iltlvp01.t.st.corp\DE_Development\EP 6\Port\dept\Program Office\TEST.json'.

TYPES: BEGIN OF TP_DATA_TAB,

TEXT(512),

END OF TP_DATA_TAB.

DATA : DATA_TAB TYPE STANDARD TABLE OF TP_DATA_TAB,

WA_DATA_TAB LIKE LINE OF DATA_TAB .

DATA : WA(512).

OPEN DATASET FIR_FILE FOR INPUT IN TEXT MODE ENCODING DEFAULT.

IF SY-SUBRC EQ 0.

DO.

READ DATASET FIR_FILE INTO WA.

IF SY-SUBRC NE 0.

EXIT.

ENDIF.

WA_DATA_TAB-TEXT = WA.

APPEND WA_DATA_TAB TO DATA_TAB.

CLEAR : WA_DATA_TAB, WA.

ENDDO.

ENDIF.

LOOP AT DATA_TAB INTO WA_DATA_TAB.

WRITE : / WA_DATA_TAB-TEXT.

ENDLOOP.

Read only

0 Likes
1,764

HI sreekanth ,

i try it but i get sy-subrc = 8.

and i have authorization to this folder what can be the problem?

Regards

Read only

0 Likes
1,764

In AL11 tcode can u see u r text file in this folder
iltlvp01.t.st.corp\DE_Development\EP 6\Port\dept\Program Office\

If u can see the file in this folder give me the value u have storing in FIR_FILE field

Read only

Former Member
0 Likes
1,764

Hi friends,

the text file format is JSON if it helps.

Regards