cancel
Showing results for 
Search instead for 
Did you mean: 

data display in flat file

Former Member
0 Kudos

hi,

I've created one link to action . while clicking the link I need to fetch the values from the oracle database and populate it into .txt file.

I need to use one separate java class for fetching the values from the database and keep it inside the .txt file.

I am able to fetch the data from oracle database.But not able to populate in the .txt file which will be the popup onclick of the link.

Please provide some code.

Regards

Vineela

Accepted Solutions (0)

Answers (10)

Answers (10)

Former Member
0 Kudos

Please have a look at below link for complete steps to display data in flat file.

https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/202a850a-58e0-2910-eeb3-bfc3e081...

Former Member
0 Kudos

hi Vinod,

I tried with your code.It's working for .doc file.Means popup is coming with the word.But I want to display the values with the popup in .txt format.When I tried with the .txt file,values are stored in the IE browser.

And one more thing is I need to use tab and new line character inbetween the values.

Can you please give me any solution for this

Regards

Vineela

Former Member
0 Kudos

Vineela,

For Spaces, Tabs and Newline, use escape sequences like \t, \n. I am able to see the data in pop-up window external pop-up window in txt format. May be you should try some plug-ins for IE or try the same in some other browsers.

Note: try some other WDWebResourceTypes; for getting data in txt format, use WDWebResourceType.TXT

vinod v

sanyev
Active Participant
0 Kudos

Hi Vineela,

Using the Java IO will only write the file on the server. You have to use the IWDResource Java type context attribute and use the download function. Information is there in this [tutorial.|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/00062266-3aa9-2910-d485-f1088c3a4d71]

Regards,

Sanyev

Former Member
0 Kudos

You have all the data in your context from Oracle DB. Jut to display those contents in Text file use the following code.


IPrivateExperimentView.IDetailsNode dnode;
    StringBuffer buf = new StringBuffer( "");
    for( int i = 0; i < wdContext.nodeDetails().size(); i++)
    {
    	
    	buf.append( wdContext
    					.nodeDetails()
    					.getDetailsElementAt( i)
    					.getName() + " \n");
    }
    
    IWDResource res = WDResourceFactory.createResource( buf
    			.toString().getBytes(), "Test.txt", WDWebResourceType.TXT);
    wdComponentAPI
    	.getWindowManager()
    	.createNonModalExternalWindow( res.getUrl( 0), "test.txt").show();	

This will open a text file with data from context node.

vinod v

Former Member
0 Kudos

hi Narendra,

We are able to create the file into the server.Could you help us by sending the code for downloading file from the server and generating the popup notepad with that content.

Thanks & Regards

Vineela

Former Member
0 Kudos

Hi Vineela,

I tried the same thing but was not able to do this directly.

I did the the same procedure as i mentioned you in my previos post.

As the application hosts over server so we cannot directly store the file in your local system. You need to use file download UI element.

Regards

Narendra

Former Member
0 Kudos

hi Narendra,

Thanks for your information.

But in our scenario on click of the link we want to generate a pop up notepad in which we want to dispaly some content. Cant we achieve this without saving in the server and downloading from there. Because anyways the user will save the notepad in his local machine later.

Thanks & Regards

Vineela

Former Member
0 Kudos

Hi Vineela,

As you are using Webdynpro application to write into the file, So what it does is it creates the file at the specified location in server only (not in your local machine.). But for storing a file on server you need to have read/write access to that folder means suppose you want to store the file at C:\File then you must have read/write access of File folder.

Now after storing the file on the server you can download that file by using download UI elements.

Hope this will help.

revert if you require more.

Regards

Narendra

Former Member
0 Kudos

hi Narendra,

We are also using the same code inside the java class.But while we are trying to calling from the webdynpro action method it's neither writing the data inside the specified path nor the file is not getting created.We've tried with the FileOutputStream also,it's also not working.

But If I am using simple java without using the webdynpro it's working fine.

Can you please give me the solution for this.

Regards

Vineela

Former Member
0 Kudos

Hi Vineela,

Below is the code for writing into the file.

If the file does not already exist, it is automatically created.

try {
        BufferedWriter out = new BufferedWriter(new FileWriter("C://outfilename"));
        out.write("aString");
        out.close();
    } catch (IOException e) {
    }

Hope this will help

Regards

Narendra

Former Member
0 Kudos

Since WebDynpro doesn't support Client side scripting, you can not write a file to client machine.

For this purpose, use IWDResource and perform download function.

vinod v