06-03-2014 5:08 AM
Hello
Currently we have a upload program, wherein by using the below code the prog. is asking user to select a file from his/her local machine for saving the log file
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_log.
* PERFORM get_file_name CHANGING p_log. "Actually I wrote a routine, just here am commenting
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
default_extension = lv_file_type
CHANGING
file_table = lt_file_tab
rc = lv_subrc
EXCEPTIONS
file_open_dialog_failed = 1
cntl_error = 2
error_no_gui = 3
not_supported_by_gui = 4
OTHERS = 5.
IF sy-subrc = 0.
READ TABLE lt_file_tab INTO ls_file INDEX 1.
IF sy-subrc = 0.
p_file_name = ls_file-filename.
ENDIF.
ENDIF.
But, now I need to enhance in such a way that, I need to delete this field (selecting file from local machine) from selection screen and the prog. should automatically create a log file with a name of 'Log_file_of_Z_UPLOAD', pls. help me how I can create a file (Excel) automatically with this specified name on user's local machine's desktop?
Normally, our desktop path is as below,
C:\Users\USER_ID\Desktop\log_file.XLS
Thank you
06-03-2014 7:57 AM
Hi,
I wonder if at all any extra coding is required you can always remove the field and you can just hard code File name to be created.just as mentioned by you C:\Users\USER_ID\Desktop\log_file.XLS and call the respective FM for downloading the file.
Cheers,
Krishnakumar B
06-03-2014 5:43 AM
Hi,
Are we talking about a text file masquerading as XLS ?
If yes:
A better option would be CSV file (http://en.wikipedia.org/wiki/Comma-separated_values).
Use the Basic rules and examples specified in the article (http://en.wikipedia.org/wiki/Comma-separated_values#Basic_rules_and_examples) .
You can use the "OPEN DATASET <file> FOR OUTPUT" .
The folder on the local pc needs to be accessible from SAP by using sharing .
Use UNC naming ( \\server\share\<file> ) for file name .
If you need a log why not use the logging function in sap ?
Regards.
06-03-2014 1:45 PM
Thank you.
Just curious, you said
If you need a log why not use the logging function in sap ?
Do we hv a standard SAP FM for this logging purpose? Pls. suggest me that FM?
Regards
06-03-2014 2:14 PM
Hi,
Yes a full bunch of them.....
Package SZAL .
Look at the demo programs under package SZAL SBAL_DEMO* .
I also include a small program ( y_r_eitan_test_51_10 ) .
* Transactions:
* SLG0 Application Log: Object Maintenance
* SLG1 Application Log: Display Logs
* SLG2 Application Log: Delete logs
Regards.
06-03-2014 7:57 AM
Hi,
I wonder if at all any extra coding is required you can always remove the field and you can just hard code File name to be created.just as mentioned by you C:\Users\USER_ID\Desktop\log_file.XLS and call the respective FM for downloading the file.
Cheers,
Krishnakumar B
06-03-2014 8:07 AM
Hi,
Hard code the file path and call method cl_gui_frontend_services=>GUI_DOWNLOAD.
regards,
Archer