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

Error while uploading text file....

Former Member
0 Likes
3,190

Halo Friends,

I am uploading 4 text files which contain three columns separated by a tab, but when i am trying to upload those files using WS_UPLOAD Function Module i am getting a runtime error saying 'error while uploading/downloading'.

Please solve this problem as soon as possible.

Thanks in Advance,

rama

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,419

Halo sir,

I have done as said by you and removed the quotes for the filename but now am getting a short dump and the analysis says something like this:

"The reason for the exception is:

The call to the function module "WS_UPLOAD" is incorrect.

The function module interface allows you to specify only fields of a particular type under "FILENAME". The field "IP_FILE1" specified here has a different field type."

Hope this is clear for you.

regards,

rama

12 REPLIES 12
Read only

Former Member
0 Likes
2,419

hi

sorry wrong post

~~Guduri

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
2,419

Lets see your coding.... and the declaration of the internal tables. Also, you may want to use GUI_UPLOAD instead as it is unicode compliant.

Regards,

RIch Heilman

Read only

Former Member
0 Likes
2,419

Hi,

i have a small correction

My error says 'error when opening the downloaded file' but not 'error when uploading/downloading the file'

i am pasting my code here:

REPORT Y_NEW_UPDATE .

Tables: qmfe.

data: begin of gt1_qmfe occurs 0,

qmnum type qmfe-qmnum,

fenum type qmfe-fenum,

/itml/usr20 type qmfe-/itml/usr20,

end of gt1_qmfe.

data: begin of gt2_qmfe occurs 0,

qmnum type qmfe-qmnum,

fenum type qmfe-fenum,

/itml/usr21 type qmfe-/itml/usr21,

end of gt2_qmfe.

data: begin of gt3_qmfe occurs 0,

qmnum type qmfe-qmnum,

fenum type qmfe-fenum,

/itml/usr19 type qmfe-/itml/usr19,

end of gt3_qmfe.

data: begin of gt4_qmfe occurs 0,

qmnum type qmfe-qmnum,

fenum type qmfe-fenum,

/itml/usr07 type qmfe-/itml/usr07,

end of gt4_qmfe.

data: gs1_qmfe like line of gt1_qmfe,

gs2_qmfe like line of gt2_qmfe,

gs3_qmfe like line of gt3_qmfe,

gs4_qmfe like line of gt4_qmfe.

data: ls_lines1 type i,

ls_lines2 type i,

ls_lines3 type i,

ls_lines4 type i.

parameters: ip_file1 default 'C:\Urgent\TextFiles\StoDt.txt' obligatory,

ip_file2 default 'C:\Urgent\TextFiles\RcDtCust.txt' obligatory,

ip_file3 default 'C:\Urgent\TextFiles\DockDate.txt' obligatory,

ip_file4 default 'C:\Urgent\TextFiles\AWB.txt' obligatory.

field-symbols: <fs1> like gs1_qmfe,

<fs2> like gs2_qmfe,

<fs3> like gs3_qmfe,

<fs4> like gs4_qmfe.

perform upload_gt1_qmfe.

perform upload_gt2_qmfe.

perform upload_gt3_qmfe.

perform upload_gt4_qmfe.

perform update_qmfe.

&----


*& Form upload_gt1_qmfe

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM upload_gt1_qmfe .

CALL FUNCTION 'WS_UPLOAD'

EXPORTING

FILENAME = 'ip_file1'

FILETYPE = 'DAT'

TABLES

DATA_TAB = gt1_qmfe.

describe table gt1_qmfe lines ls_lines1.

write: / ls_lines1.

ENDFORM. " upload_gt1_qmfe

&----


*& Form upload_gt2_qmfe

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM upload_gt2_qmfe .

CALL FUNCTION 'WS_UPLOAD'

EXPORTING

FILENAME = 'ip_file2'

FILETYPE = 'DAT'

TABLES

DATA_TAB = gt2_qmfe.

describe table gt2_qmfe lines ls_lines2.

write: / ls_lines2.

ENDFORM. " upload_gt2_qmfe

&----


*& Form upload_gt3_qmfe

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM upload_gt3_qmfe .

CALL FUNCTION 'WS_UPLOAD'

EXPORTING

FILENAME = 'ip_file3'

FILETYPE = 'DAT'

TABLES

DATA_TAB = gt3_qmfe.

describe table gt3_qmfe lines ls_lines3.

write: / ls_lines3.

ENDFORM. " upload_gt3_qmfe

&----


*& Form upload_gt4_qmfe

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM upload_gt4_qmfe .

CALL FUNCTION 'WS_UPLOAD'

EXPORTING

FILENAME = 'ip_file4'

FILETYPE = 'DAT'

TABLES

DATA_TAB = gt4_qmfe.

describe table gt4_qmfe lines ls_lines4.

write: / ls_lines4.

ENDFORM. " upload_gt4_qmfe

Please go through this

Read only

0 Likes
2,419

Do not use literals when passing values to the function call.

Here you have....


CALL FUNCTION 'WS_UPLOAD'
EXPORTING
FILENAME = 'ip_file1'     "<--  HERE
FILETYPE = 'DAT'
TABLES
DATA_TAB = gt1_qmfe.

It should be....

CALL FUNCTION 'WS_UPLOAD'
EXPORTING
FILENAME = ip_file1     "<-  HERE
FILETYPE = 'DAT'
TABLES
DATA_TAB = gt1_qmfe.

Do this for all your calls to WS_UPLOAD. IT should fix the problem.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
2,419

DATA:

BEGIN OF FS_SPFLI,

CARRID TYPE SPFLI-CARRID,

CONNID TYPE SPFLI-CONNID,

COUNTRYFR TYPE SPFLI-COUNTRYFR,

CITYFROM TYPE SPFLI-CITYFROM,

AIRPFROM TYPE SPFLI-AIRPFROM,

COUNTRYTO TYPE SPFLI-COUNTRYTO,

CITYTO TYPE SPFLI-CITYTO,

AIRPTO TYPE SPFLI-AIRPTO,

FLTIME TYPE SPFLI-FLTIME,

DEPTIME TYPE SPFLI-DEPTIME,

ARRTIME TYPE SPFLI-ARRTIME,

DISTANCE TYPE SPFLI-DISTANCE,

DISTID TYPE SPFLI-DISTID,

FLTYPE TYPE SPFLI-FLTYPE,

PERIOD TYPE SPFLI-PERIOD,

END OF FS_SPFLI.

DATA:

T_SPFLI LIKE

STANDARD TABLE

OF FS_SPFLI.

DATA:

BEGIN OF FS_TABLE,

CHAR(100) TYPE C,

END OF FS_TABLE.

DATA:

T_TABLE LIKE

STANDARD TABLE

OF FS_TABLE.

DATA:

BEGIN OF FS_TABLE1,

CHAR(100) TYPE C,

END OF FS_TABLE1.

DATA:

T_TABLE1 LIKE

STANDARD TABLE

OF FS_TABLE1.

SELECT CARRID

CONNID

COUNTRYFR

CITYFROM

AIRPFROM

COUNTRYTO

CITYTO

AIRPTO

FLTIME

DEPTIME

ARRTIME

DISTANCE

DISTID

FLTYPE

PERIOD

FROM SPFLI

INTO TABLE T_SPFLI.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

  • BIN_FILESIZE =

FILENAME = 'd:\files\yh627_spfli04'

FILETYPE = 'ASC'

  • APPEND = ' '

  • WRITE_FIELD_SEPARATOR = ' '

  • HEADER = '00'

  • TRUNC_TRAILING_BLANKS = ' '

  • WRITE_LF = 'X'

  • COL_SELECT = ' '

  • COL_SELECT_MASK = ' '

  • DAT_MODE = ' '

  • CONFIRM_OVERWRITE = ' '

  • NO_AUTH_CHECK = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • WRITE_BOM = ' '

  • TRUNC_TRAILING_BLANKS_EOL = 'X'

  • WK1_N_FORMAT = ' '

  • WK1_N_SIZE = ' '

  • WK1_T_FORMAT = ' '

  • WK1_T_SIZE = ' '

  • IMPORTING

  • FILELENGTH =

TABLES

DATA_TAB = T_SPFLI

  • FIELDNAMES =

EXCEPTIONS

FILE_WRITE_ERROR = 1

NO_BATCH = 2

GUI_REFUSE_FILETRANSFER = 3

INVALID_TYPE = 4

NO_AUTHORITY = 5

UNKNOWN_ERROR = 6

HEADER_NOT_ALLOWED = 7

SEPARATOR_NOT_ALLOWED = 8

FILESIZE_NOT_ALLOWED = 9

HEADER_TOO_LONG = 10

DP_ERROR_CREATE = 11

DP_ERROR_SEND = 12

DP_ERROR_WRITE = 13

UNKNOWN_DP_ERROR = 14

ACCESS_DENIED = 15

DP_OUT_OF_MEMORY = 16

DISK_FULL = 17

DP_TIMEOUT = 18

FILE_NOT_FOUND = 19

DATAPROVIDER_EXCEPTION = 20

CONTROL_FLUSH_ERROR = 21

OTHERS = 22

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = 'd:\files\yh627_spfli04'

FILETYPE = 'ASC'

  • HAS_FIELD_SEPARATOR = ' '

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

  • VIRUS_SCAN_PROFILE =

  • IMPORTING

  • FILELENGTH =

  • HEADER =

TABLES

DATA_TAB = T_TABLE

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 T_TABLE INTO FS_TABLE.

  • WRITE:

  • / FS_TABLE-CHAR.

*ENDLOOP.

OPEN DATASET 'yh627_spfli04' FOR INPUT IN TEXT MODE ENCODING DEFAULT.

IF SY-SUBRC EQ 0.

MESSAGE 'File Already Exists' TYPE 'I'.

EXIT.

ELSE.

CLOSE DATASET 'yh627_spfli04'.

OPEN DATASET 'yh627_spfli04' FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

LOOP AT T_TABLE INTO FS_TABLE.

TRANSFER FS_TABLE TO 'yh627_spfli04'.

ENDLOOP.

CLOSE DATASET 'yh627_spfli04'.

ENDIF.

Read only

Former Member
0 Likes
2,420

Halo sir,

I have done as said by you and removed the quotes for the filename but now am getting a short dump and the analysis says something like this:

"The reason for the exception is:

The call to the function module "WS_UPLOAD" is incorrect.

The function module interface allows you to specify only fields of a particular type under "FILENAME". The field "IP_FILE1" specified here has a different field type."

Hope this is clear for you.

regards,

rama

Read only

0 Likes
2,419

Please declare your parameters like this.

parameters: ip_file1 type RLGRAP-FILENAME  default 'C:UrgentTextFilesStoDt.txt' obligatory,
ip_file2 type RLGRAP-FILENAME default 'C:UrgentTextFilesRcDtCust.txt' obligatory,
ip_file3 type RLGRAP-FILENAME default 'C:UrgentTextFilesDockDate.txt' obligatory,
ip_file4 type RLGRAP-FILENAME default 'C:UrgentTextFilesAWB.txt' obligatory.

Regards,

Rich Heilman

Read only

0 Likes
2,419

Hi Rama,

Parameters need to be declared like this.

parameters:

ip_file1 like rlgrap-filename default 'C:\Urgent\TextFiles\StoDt.txt' obligatory,

ip_file2 like rlgrap-filename default 'C:\Urgent\TextFiles\RcDtCust.txt' obligatory,

ip_file3 like rlgrap-filename default 'C:\Urgent\TextFiles\DockDate.txt' obligatory,

ip_file4 like rlgrap-filename default 'C:\Urgent\TextFiles\AWB.txt' obligatory.

Thanks,

Srinivas

Read only

Former Member
0 Likes
2,419

Halo Mr. Heilman n Srinivas,

Thanks a lot for that. Now i have got it.

Now i can proceed with my program further, if i get any doubts i would be here again.

bbbbye

Thanks again for both of you.

Cheers,

rama

Read only

Former Member
0 Likes
2,419

Halo again,

Now that i am able to upload the files, i need to update the database table the update statement is executing correctly but when i debug i see that the sy-subrc value is 4 but not 0.

and hence the it is not committed.

Any suggestions. i am pasting my code here for your reference:

Tables: qmfe.

data: begin of gt1_qmfe occurs 0,

qmnum like qmfe-qmnum,

fenum like qmfe-fenum,

/itml/usr20 like qmfe-/itml/usr20,

end of gt1_qmfe.

data: begin of gt2_qmfe occurs 0,

qmnum like qmfe-qmnum,

fenum like qmfe-fenum,

/itml/usr21 like qmfe-/itml/usr21,

end of gt2_qmfe.

data: begin of gt3_qmfe occurs 0,

qmnum like qmfe-qmnum,

fenum like qmfe-fenum,

/itml/usr19 like qmfe-/itml/usr19,

end of gt3_qmfe.

data: begin of gt4_qmfe occurs 0,

qmnum like qmfe-qmnum,

fenum like qmfe-fenum,

/itml/usr07 like qmfe-/itml/usr07,

end of gt4_qmfe.

data: gs1_qmfe like line of gt1_qmfe,

gs2_qmfe like line of gt2_qmfe,

gs3_qmfe like line of gt3_qmfe,

gs4_qmfe like line of gt4_qmfe.

data: ls_lines1 type i,

ls_lines2 type i,

ls_lines3 type i,

ls_lines4 type i.

parameters: ip_file1 type RLGRAP-FILENAME default 'C:\Urgent\TextFiles\StoDt.txt' obligatory,

ip_file2 type RLGRAP-FILENAME default 'C:\Urgent\TextFiles\RcDtCust.txt' obligatory,

ip_file3 type RLGRAP-FILENAME default 'C:\Urgent\TextFiles\DockDate.txt' obligatory,

ip_file4 type RLGRAP-FILENAME default 'C:\Urgent\TextFiles\AWB.txt' obligatory.

field-symbols: <fs1> like gs1_qmfe,

<fs2> like gs2_qmfe,

<fs3> like gs3_qmfe,

<fs4> like gs4_qmfe.

perform upload_gt1_qmfe.

perform upload_gt2_qmfe.

perform upload_gt3_qmfe.

perform upload_gt4_qmfe.

perform update_qmfe.

&----


*& Form upload_gt1_qmfe

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM upload_gt1_qmfe .

CALL FUNCTION 'WS_UPLOAD'

EXPORTING

FILENAME = ip_file1

FILETYPE = 'DAT'

TABLES

DATA_TAB = gt1_qmfe.

describe table gt1_qmfe lines ls_lines1.

write: / ls_lines1.

ENDFORM. " upload_gt1_qmfe

&----


*& Form upload_gt2_qmfe

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM upload_gt2_qmfe .

CALL FUNCTION 'WS_UPLOAD'

EXPORTING

FILENAME = ip_file2

FILETYPE = 'DAT'

TABLES

DATA_TAB = gt2_qmfe.

describe table gt2_qmfe lines ls_lines2.

write: / ls_lines2.

ENDFORM. " upload_gt2_qmfe

&----


*& Form upload_gt3_qmfe

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM upload_gt3_qmfe .

CALL FUNCTION 'WS_UPLOAD'

EXPORTING

FILENAME = ip_file3

FILETYPE = 'DAT'

TABLES

DATA_TAB = gt3_qmfe.

describe table gt3_qmfe lines ls_lines3.

write: / ls_lines3.

ENDFORM. " upload_gt3_qmfe

&----


*& Form upload_gt4_qmfe

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM upload_gt4_qmfe .

CALL FUNCTION 'WS_UPLOAD'

EXPORTING

FILENAME = ip_file4

FILETYPE = 'DAT'

TABLES

DATA_TAB = gt4_qmfe.

describe table gt4_qmfe lines ls_lines4.

write: / ls_lines4.

ENDFORM. " upload_gt4_qmfe

&----


*& Form update_qmfe

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM update_qmfe .

data ls_cnt type i.

loop at gt1_qmfe assigning <fs1>.

update qmfe set /itml/usr20 = <fs1>-/itml/usr20

where qmnum = <fs1>-qmnum

and fenum = <fs1>-fenum.

if sy-subrc = 0.

commit work.

add 1 to ls_cnt.

endif.

endloop.

write: / ls_cnt.

ENDFORM. " update_qmfe

Read only

Former Member
0 Likes
2,419

Halo Mr. Heilman,

Can you please explain me the exact meaning of this keyword that you have suggested me to use.

RLGRAP-FILENAME

It worked fine for my program, but can u explain me it in detail

Best Regards,

rama

Read only

0 Likes
2,419

The reason I am replying to your question is that I was wondering this myself. Why did the programmer who created this structure name it RLGRAP? I was expecting kind of German abbreviation,

The program SAPLGRAP uses the structure and my version of this program regenerated by GRAPH.

It defines: DATA: GLOBAL_DOWNLOAD_PATH LIKE RLGRAP-FILENAME. Which notably is in English.

So GRAP -> Graph

My best guess is ReLationship GRAPh-Filename.