03-06-2008 7:08 AM
Hi All.
I want urgent help.
Actually i ahve one VB exe file on presintation server which create a excel file. Now i have to read data from this excel file in sap. My program first execute the VB exe file with function module 'WS_EXECUTE' and create excel file and then read it. Now we want this program to be run in background, but now the problem is how the program pick path from presentation server?
Please help me...
Thanks
03-06-2008 7:26 AM
Hi,
I think we cannot schedule a back ground job for the files in presentation server, only we can schedule background job when the files exists in the application server......
Bye....
03-06-2008 7:28 AM
Hi,
I guess it cannot be possible to pick a presentation server file in background job. In background job we can get application server files.
Rgds,
Bujji
03-06-2008 7:43 AM
You can not read file from presentation server in background job. What you can do is to upload the presentation server data to application server by T-Code cg3z or through program. and then in background job you can read the application server file by open dataset, read dataset and close dataset command.
03-06-2008 8:27 AM
07-25-2013 5:04 AM
Hi,
i too got the same problem and got the solution for that.
code:
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
PERFORM file_browse.
PERFORM file_upload. " Files into internal table before start of selection event
AT SELECTION-SCREEN OUTPUT.
DATA: exclude LIKE rsexfcode OCCURS 0 WITH HEADER LINE,
ls_submit_info TYPE rssubinfo.
START-OF-SELECTION.
PERFORM process_data.
FORM file_upload .
DATA ip_file TYPE string.
CLEAR ip_file.
REFRESH it_data.
ip_file = p_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = ip_file " Path of the file
has_field_separator = 'X'
TABLES
data_tab = it_data
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.
***Using this concept" Export into another variable
REFRESH: exp_data.
exp_data = it_data.
*Index key is group of Report & UserId.
CONCATENATE sy-repid sy-uname INTO indxkey .
EXPORT exp_data FROM exp_data
TO DATABASE mcdx(zb) FROM wa_indx ID indxkey.
ENDFORM. "file_upload
****import into start of selection
FORM process_data .
IF sy-batch EQ 'X'.
REFRESH it_data.
CONCATENATE sy-repid sy-uname INTO indxkey .
IMPORT exp_data = exp_data FROM DATABASE mcdx(zb) ID indxkey.
it_data = exp_data.
ENDIF.
IF it_data IS NOT INITIAL.
LOOP AT it_data INTO wa_data.
wa_bapi_data-payer_code = ''.
wa_bapi_data-labr_value = wa_data-labr_value.
wa_bapi_data-plant = wa_data-plant.
wa_bapi_data-text = wa_data-text.
wa_bapi_data-dealer_code = wa_data-dealer_code.
wa_bapi_data-claim_mnth = wa_data-claim_mnth.
wa_bapi_data-claim_yr = wa_data-claim_yr.
wa_bapi_data-dr_cr_indicator = wa_data-dr_cr_indicator.
APPEND wa_bapi_data TO it_bapi_data.
ENDLOOP.
ELSE.
MESSAGE:'No entry found' TYPE 'E'.
ENDIF.
ENDFORM. "
I think you get the correct answer.
Regards,
Ankita Jain
07-25-2013 7:30 AM
Hi,
I had the same problem before
Gui_upload is a Gui function that only runs in the foregound
So you cant use that one in the background
What i did was to transefer the file to the application server
use open dataset ...
close dataset ...
then you can do the other parts
to execute external commands you can use the
cl_gui_frontend_services->execute method
check that one!!
07-25-2013 6:51 AM
Hi,
i too got the same problem and got the solution for that.
code:
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
PERFORM file_browse.
PERFORM file_upload. " Files into internal table before start of selection event
AT SELECTION-SCREEN OUTPUT.
DATA: exclude LIKE rsexfcode OCCURS 0 WITH HEADER LINE,
ls_submit_info TYPE rssubinfo.
START-OF-SELECTION.
PERFORM process_data.
FORM file_upload .
DATA ip_file TYPE string.
CLEAR ip_file.
REFRESH it_data.
ip_file = p_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = ip_file " Path of the file
has_field_separator = 'X'
TABLES
data_tab = it_data
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.
***Using this concept" Export into another variable
REFRESH: exp_data.
exp_data = it_data.
*Index key is group of Report & UserId.
CONCATENATE sy-repid sy-uname INTO indxkey .
EXPORT exp_data FROM exp_data
TO DATABASE mcdx(zb) FROM wa_indx ID indxkey.
ENDFORM. "file_upload
****import into start of selection
FORM process_data .
IF sy-batch EQ 'X'.
REFRESH it_data.
CONCATENATE sy-repid sy-uname INTO indxkey .
IMPORT exp_data = exp_data FROM DATABASE mcdx(zb) ID indxkey.
it_data = exp_data.
ENDIF.
IF it_data IS NOT INITIAL.
LOOP AT it_data INTO wa_data.
wa_bapi_data-payer_code = ''.
wa_bapi_data-labr_value = wa_data-labr_value.
wa_bapi_data-plant = wa_data-plant.
wa_bapi_data-text = wa_data-text.
wa_bapi_data-dealer_code = wa_data-dealer_code.
wa_bapi_data-claim_mnth = wa_data-claim_mnth.
wa_bapi_data-claim_yr = wa_data-claim_yr.
wa_bapi_data-dr_cr_indicator = wa_data-dr_cr_indicator.
APPEND wa_bapi_data TO it_bapi_data.
ENDLOOP.
ELSE.
MESSAGE:'No entry found' TYPE 'E'.
ENDIF.
ENDFORM. "
I think you get the correct answer.
Regards,
Ankita Jain
07-25-2013 8:12 AM
Hi,
Instead of storing the file in INDX table, you can directly store the excel file in Application server as well with.xls extension. Later read the excel file from application server and process.
Thanks & Regards
Bala Krishna