‎2013 Mar 12 10:19 AM
I tried to use all the 3 Function Modules : TEXT_CONVERT_XLS_TO_SAP, ALSM_EXCEL_TO_INTERNAL_TABLE, GUI_UPLOAD.
But the program is failing while run in background. The Batch Job is getting cancelled.
Job log for different FM's:
- 'Frontend function cannot be excuted in background',
- 'Excel file C:/xxxx.xls cannot be processed',
- 'ABAP/4 processor: OBJECTS_OBJREF_NOT_ASSIGNED'.
It works fine in foreground.
Can anyone please tell me what FM to use to read Excel file data to Internal Table that works fine in background?
Thanks & Regards,
Sowmya
‎2013 Mar 12 11:19 AM
Hi Sowmya,
Function modules like GUI_UPLOAD work only in dialog mode. Make use of OPEN DATASET to read the file when program is run in background.
Hope this helps,
~Athreya
‎2013 Mar 12 11:19 AM
Hi Sowmya,
Function modules like GUI_UPLOAD work only in dialog mode. Make use of OPEN DATASET to read the file when program is run in background.
Hope this helps,
~Athreya
‎2013 Mar 12 11:24 AM
Hi,
Can you please tell me what did you you mentioned in file path parameter of the FM
Thanks,
Girdhari
‎2013 Mar 12 11:28 AM
Hi Sowmya,
Have you checked in debugging (Select your background job in SM37 and put /nJDBG to debug your background job) what file name is being passed to these FMs? Maybe the filepath and filename are incorrect! Please check and revert! In foreground, you will be able to see the filepath/filename that is being passed to the FMs but check in background.
‎2013 Mar 13 6:27 AM
Yes. I did debug the Jobs. sy-subrc was 3 in the Funciton modules.
Thanks,
Sowmya
‎2013 Mar 12 11:39 AM
Hi Sowmya,
all this FMs uses frontend objects. You can't use then in background.
I think the easier way is to save your files as .CSV, and in background you can read then with OPEN DATASET.
Don't forget that this files should be available in a folder on SAP Application Server. You can check AL11 Tcode to se an available folder.
Regards,
Guilherme Frisoni
‎2013 Mar 12 12:19 PM
‎2013 Mar 12 3:12 PM
Dear Sowmya Sreeram,
The purpose of background job is to be able to execute even in the absence of dialog work processes, therefore, a background job cannot access file on presentation server. Please make some arrangement so that the file can be uploaded to application server, and from there your background job should read file from application server using statements 'OPEN DATASET' and 'READ DATASET'.
If not the second option would be to insert the contents of the file into a custom database table, and the background job will use data present in this database table.
Regards,
Kartik
‎2013 Mar 13 6:26 AM
Thanks everyone!!!
I'm using OPEN DATASET.... READ DATASET now.
Perhaps, it is working only for TXT files and not for XLS files..
Is it possible to read the XLS Files from the Application Server using READ DATASET? If yes, please provide me the syntax.
Thanks again!!
-Sowmya
‎2013 Mar 13 6:31 AM
hi,
its not possible to read .xls in application server..
.csv format is possible via application server..
hope it hwlps,
thanks,
Mathan R.
‎2013 Mar 13 6:34 AM
hi,
First of all, GUI_UPLOAD and gui_download FM and all wont work in background..
Exactly, what im saying is none of the GUI features work in background..
please post your exact issue or requirement hre.. so that we can help you further to work with your object..
thanks,
Mathan R.
‎2013 Mar 13 6:34 AM
No, as of now, there is no functionality to read excel files from application server, please save your excel as tab/comma delimited file on application server and read it using open dataset statement.
Regards,
Kartik
‎2013 Mar 13 6:36 AM
Hi sowmya,
just convert the xls file to csv format, and maintain that csv format in the application server.
then you can use datasets to retrieve the data and then you can use your report to upload data in background.
*------- open file -------------------------------------------------
open dataset v_file for input in text mode encoding default. "v_file is the file from app server
if sy-subrc eq 0.
*------- store records in internal table ------------------------------
do.
clear wa_file.
read dataset v_file into wa_file.
if sy-subrc ne 0.
exit.
endif.
split wa_file at ',' ""The data from diff cells will be separated by "," so split into your work area table and append it to your itab
into wa_file-str1
wa_file-str2
wa_file-str3.
ln = strlen( wa_file-str25 ).
ln = ln - 1.
if ln ge 2.
wa_file-str25 = wa_file-str25+0(ln).
endif.
append wa_file to gt_file. """data from csv file will be stored to gt_file internal table
clear: ln, wa_file.
enddo.
else.
message 'Not accessible' type 'I'.
exit.
endif.
close dataset v_file. """"""""""""Close the file
May i know you actual requirement?
Regards,
Madhumahesh.