2019 Sep 30 12:33 PM
Hello,
I select the document using method
cl_gui_frontend_services=>file_open_dialog
which gives me the path to the folder type STRING.Then I read the file using Function Module : TEXT_CONVERT_XLS_TO_SAP
which has an importing parameter i_filename type RLGRAP-FILENAME , length limited to 128 CHAR.
Sometimes the path can be longer than 128 Char and like this the prg does not find the file.
Do you know a way to shorten the path or read the file path entirely?
Please let me know!
2019 Oct 01 2:04 PM
Just duplicate TEXT_CONVERT_XLS_TO_SAP and increase the length of the parameter.
Duplication of such a simple function module is not an issue, as it's not important to apply future patches.
2019 Sep 30 12:48 PM
Hello Jonathan Blavatsky,
Recommend you to Kindly stick to the file path less than 128 Characters,
You can try using GUI_UPLOAD FM but not sure if its supports all File formats
Regards
2019 Sep 30 1:18 PM
2019 Oct 01 9:11 AM
if you provide an answer where GUI_Upload can upload an excel file,I will accept your answer ,but as far as I have searched and tried there is problem with data convertion
2019 Sep 30 1:24 PM
You may define a drive which points to a directory (Windows Explorer "map network drive"), that will shorten the path.
2019 Sep 30 1:35 PM
2019 Sep 30 1:42 PM
2019 Oct 01 11:07 AM
sorry but this is not a solution to provide to the client,since not all clients will change the directory of their pc's
2019 Sep 30 2:09 PM
your root problem is because that function module only accept a path up to 128 characters. you may use upload using gui_upload and BIN file type, then read the file detail with XML class or transformations...or else you should change to CSV file or xlsx.
2019 Oct 01 10:34 AM
Hello Jonathan Blavatsky,
Try the below Code, This should work:
FORM receive_file .
* Function to Provide F4 for receiving the file
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
IMPORTING
file_name = s_fname.
*Get the File path to local variable
gw_fname = s_fname.
*Receive the data into an Internal Table
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = gw_fname
filetype = 'DAT'
TABLES
data_tab = gt_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.
ENDFORM.
Try the below steps for formatting the file that you want to load.
1) Prepare the Excel file first with the data in CSV format.
2) Now copy the data from Excel file and paste it in Note pad (Along with Column Name)
3) Paste the Text File as DAT format in your machine
4) Now load your DAT file into the program.
Note: Your GT_UPLOAD Internal table should have the same structure as the File with Data Type String for all columns. Later you process the Internal table to the required Data type by passing the Values to Another Internal table which is defined with actual Data Type.
2019 Oct 01 11:04 AM
have tried it like this,it does not work,the characters are all wrong and it has only one column ,instead of all the columns that I have already specified from the structure
2019 Oct 01 1:28 PM
Sorry maybe I was clear...I will not do any process manually.The goal is to select the file using open file dialog and then call this FM...which turns the data into Binay format...not what I want.the goal to simply select the file and upload it programatically.
2019 Oct 02 6:34 AM
It is not logic what you request: "then call this FM" if it does not work it will never work until somebody change the code inside. And I am pretty sure it will never append.
So,
You could use Abap2xls
You could copy the function group & the function module to change the size of the file (the code used the FM GUI_UPLOAD, and this FM used a string)
You could create your own code based on the classes used in this FM
2019 Oct 02 9:38 AM
2019 Oct 02 9:41 AM
2019 Oct 02 10:38 AM
I'm surprised: couldn't you just edit your answer, instead of adding a new one?
2019 Oct 02 10:50 AM
2019 Oct 02 1:38 PM
2019 Oct 01 2:04 PM
Just duplicate TEXT_CONVERT_XLS_TO_SAP and increase the length of the parameter.
Duplication of such a simple function module is not an issue, as it's not important to apply future patches.
2019 Oct 02 9:03 AM