2009 Mar 23 10:44 AM
Hi,
In selection screen , I have a to provide a file name and execute the program.
When I execute in foreground its working fine, but where are when I execute in background with variant it shows invalid file name and job cancelled in long text.
Please suggest me what would be the problem and possible solution.
Thanks,
Ameer
2009 Mar 23 11:20 AM
Hi Ameer,
Add the following condition for running the prgram in Background.
*****To upload file*********
IF sy-batch = 'X'. "-----> If backgroung execution option is selected.
OPEN DATASET p_filename FOR INPUT IN TEXT MODE ENCODING DEFAULT.
WHILE sy-subrc = 0.
READ DATASET p_filename INTO wa_struc.
APPEND wa_struc TO itab_struc.
ENDWHILE.
CLOSE DATASET p_filename .
ENDIF.
*****To download file*********
IF sy-batch = 'X'.
OPEN DATASET p_filename1 IN TEXT MODE FOR OUTPUT ENCODING DEFAULT.
IF sy-subrc = 0.
LOOP AT itab_struc INTO wa_struc.
TRANSFER wa_struc TO p_filename1.
ENDLOOP.
CLOSE DATASET p_filename1.
ENDIF.
ENDIF.
Hope this addresses your issue.
Regards,
Arnab
2009 Mar 23 10:50 AM
i guess you must be using GUI_UPLOAd for file uploading. this function module does not work in background mode. and hence your background job is failing.
you will have to store your file on application server and use read dataset for application file reading.
2009 Mar 23 10:50 AM
Hi Ameer,
Make sure that you don't have any user interactive pop ups asking for confirmation while running the program. If your program has any such pop ups then it will create a problem while running in background.
2009 Mar 23 11:02 AM
Hi,
Thanks for update and feedback,
I am not offering any popup during execution process.
2009 Mar 23 11:09 AM
Hi , I am using the following method to get excel file from presentation server to internal table.
l_fname = p_file.
*Validate filename
CALL METHOD cl_gui_frontend_services=>file_exist
EXPORTING
file = l_fname
RECEIVING
result = l_res
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
wrong_parameter = 3
OTHERS = 4
.
IF sy-subrc <> 0 OR l_res IS INITIAL.
MESSAGE e031.
ENDIF.
while executing the program in background , I got message like ,Job cancelled after system exception ERROR_MESSAGE
I wanted to know whether this function module works in background or not . or is there any other problem which causes the error message.
Please suggest me a solution.
Thnaks in advance.
2009 Mar 23 11:17 AM
Hi,
You cannot use the class cl_gui_frontend_services in back ground.
GUI is not available in background mode. So won't work.
Put the file in application server and check its existence.
Use the data statements OPEN, READ, CLOSE for files in app. server
Regards,
Soumya.
Edited by: Soumya Jose on Mar 23, 2009 12:18 PM
2009 Mar 23 10:57 AM
2009 Mar 23 11:20 AM
Hi Ameer,
Add the following condition for running the prgram in Background.
*****To upload file*********
IF sy-batch = 'X'. "-----> If backgroung execution option is selected.
OPEN DATASET p_filename FOR INPUT IN TEXT MODE ENCODING DEFAULT.
WHILE sy-subrc = 0.
READ DATASET p_filename INTO wa_struc.
APPEND wa_struc TO itab_struc.
ENDWHILE.
CLOSE DATASET p_filename .
ENDIF.
*****To download file*********
IF sy-batch = 'X'.
OPEN DATASET p_filename1 IN TEXT MODE FOR OUTPUT ENCODING DEFAULT.
IF sy-subrc = 0.
LOOP AT itab_struc INTO wa_struc.
TRANSFER wa_struc TO p_filename1.
ENDLOOP.
CLOSE DATASET p_filename1.
ENDIF.
ENDIF.
Hope this addresses your issue.
Regards,
Arnab
2009 Mar 25 6:10 PM
IF sy-batch = 'X'. "-----> If backgroung execution option is selected.
OPEN DATASET p_file FOR INPUT IN TEXT MODE.
WHILE sy-subrc = 0.
clear:wa_struc.
READ DATASET P_file INTO wa_struc.
APPEND wa_struc TO it_datatab.
ENDWHILE.
if sy-subrc ne 0.
endif.
CLOSE DATASET p_file .
ENDIF.
Here,p_file is a excel sheet and wa_struc has a four fields.
when i debug at point read dataset p_file into wa_struc , this wa_struc has a value :
first iteration :Start of Conversion (table VBAP )
second iteration : SalesordNo;Item-Num ;Material ;SN old ;SN new ;Comment
third iteration : ; ; ; ; ;
instead of - values of fields of excel sheet.
How to resolve this one.