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

Problem in the code

Former Member
0 Likes
403

Hi Experts,

See the following code.I am getting list of files in the table ifile.But when i use CALL METHOD cl_gui_frontend_services=>gui_upload

I am getting sy-subrc = 19.

Can any body tell me what may be the problem?

Thanks in Advance.

data: ifile type table of file_info.

data: wa_file like line of ifile.

data: xfile type string.

data: xcount type i.

data: l_xml_table_size TYPE i.

TYPES: BEGIN OF t_xml_line, "Structure for holding XML data

data(256) TYPE x,

END OF t_xml_line.

DATA: l_filename type string.

DATA: l_xml_table TYPE TABLE OF t_xml_line. " XML Table of the structure

call method cl_gui_frontend_services=>directory_list_files

exporting

directory = 'D:\'

FILTER = '*.XML'

FILES_ONLY = 'X'

  • DIRECTORIES_ONLY =

changing

file_table = ifile

count = xcount

exceptions

cntl_error = 1

directory_list_files_failed = 2

wrong_parameter = 3

error_no_gui = 4

others = 5.

*loop at ifile .

write:/ 'ifile'.

*endloop.

loop at ifile into wa_file.

l_filename = wa_file-filename.

  • Upload file from the client's workstation

CALL METHOD cl_gui_frontend_services=>gui_upload

EXPORTING

filename = l_filename

filetype = 'BIN'

IMPORTING

filelength = l_xml_table_size

CHANGING

data_tab = l_xml_table

EXCEPTIONS

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.

endloop.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
373

Dear Ravi,

Please concatenate the file path with your file name before you call the upload method.

loop at ifile into wa_file.

                                    • New line ******************

concatenate 'D:\' wa_file-filename into l_filename.

                                    • New line ******************

  • Upload file from the client's workstation

CALL METHOD cl_gui_frontend_services=>gui_upload

EXPORTING

filename = l_filename

filetype = 'BIN'

IMPORTING

filelength = l_xml_table_size

CHANGING

data_tab = l_xml_table

EXCEPTIONS

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.

endloop.

Please reward points if found useful.

Regards,

Prabhas.

2 REPLIES 2
Read only

Former Member
0 Likes
373

hi Ravi,

Try this way ..

ifile type standard table of char256.

Read only

Former Member
0 Likes
374

Dear Ravi,

Please concatenate the file path with your file name before you call the upload method.

loop at ifile into wa_file.

                                    • New line ******************

concatenate 'D:\' wa_file-filename into l_filename.

                                    • New line ******************

  • Upload file from the client's workstation

CALL METHOD cl_gui_frontend_services=>gui_upload

EXPORTING

filename = l_filename

filetype = 'BIN'

IMPORTING

filelength = l_xml_table_size

CHANGING

data_tab = l_xml_table

EXCEPTIONS

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.

endloop.

Please reward points if found useful.

Regards,

Prabhas.