Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Does it possible to create a file automatically?

former_member194142
Participant
0 Kudos

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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

5 REPLIES 5

rosenberg_eitan
Active Contributor
0 Kudos

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.

0 Kudos

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

0 Kudos

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.

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi,

Hard code the file path and call method cl_gui_frontend_services=>GUI_DOWNLOAD.


regards,

Archer