cancel
Showing results for 
Search instead for 
Did you mean: 

Save an excel file in a local host from RFC executed from SAP Portal

Former Member
0 Kudos

Hi experts,

I'm creating a NWDS application that executes a RFC. The RFC creates an excel Document and saves it atomatically in a path (like C:\documents) at the local host .If i execute the RFC from SE37 transaction, the file saves succesfully, but through the portal, the file is not saved in the path or anywhere.

Here is the code that saves the file:

* g_c_nomarch is the path where the file should had been saved.

CALL FUNCTION 'FLUSH'
    EXCEPTIONS
      cntl_system_error = 1
      cntl_error              = 2
      OTHERS              = 3.


  GET PROPERTY OF excel 'ActiveSheet' = hoja.
  FREE OBJECT hoja.
  FREE OBJECT libro.


  GET PROPERTY OF excel 'ActiveWorkbook' = libro.
  CALL METHOD OF libro 'SAVEAS'
    EXPORTING
    #1 = g_c_nomarch
    #2 = 1.

  CALL METHOD OF libro 'CLOSE'.
  CALL METHOD OF excel 'QUIT'.


  FREE OBJECT hoja.
  FREE OBJECT libro.
  FREE OBJECT excel.

So, can someone help me with any suggestion in order to solve this issue?

Thanks!!!

Accepted Solutions (1)

Accepted Solutions (1)

junwu
Active Contributor
0 Kudos

i don't think you can do this in portal with just one RFC call.

in portal case, rfc call can only return you some data, you have to write java code to consume the data and ask user to download to local drive.

Answers (1)

Answers (1)

vijay_kumar49
Active Contributor
0 Kudos

1.       When you click on any action, you need to execute BAPI/RFC and Read the data from BAPI/RFC and Saved into the One Node.

2.       At the same time you have to open one Popup Window. In the Popup window you have to create 2 Buttons. One for OK and another for Cancel.

3.       Whenever you click on OK button.

a.       Create One Excel file

File dir = new File("c:\\Folder Name");

File file = new File("c:\\Folder Name\\"_"+ new SimpleDateFormat("MM-dd-yyyy HHmm").format(new Date())+ ".excel");

     file.createNewFile();

     FileWriter fw = new FileWriter(file);

     BufferedWriter  logFile = new BufferedWriter(fw)

b.      Now Read the all data from Value Node and saved into the Excel file

c.       But you need to create folder path in EP Server system only.

4.       Whenever you click on Cancel button. Your script is not generated. So that time file is not created.

I hope this is help full !!!

Regards

Vijay Kalluri

junwu
Active Contributor
0 Kudos

step a is pretty much wrong and unnecessary

vijay_kumar49
Active Contributor
0 Kudos

Jun...

Why its wroing...Same Senario i have to generated .txt file into the C drive in Portal Server...If you want see my src code. i will to your gmail....is it Okay

junwu
Active Contributor
0 Kudos

to generate resource for downloading, there is no need to use file api to generate file in server