cancel
Showing results for 
Search instead for 
Did you mean: 

saving data in application in desktop to take printout

Former Member
0 Kudos

hai all,

When the user clicks on save button he should be able to save the data in desktop and should be allowed to take print out of the same .Its very urgent plz help me in this issue.

Thanks n Regards

Sharanya.R

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

You can use FileDownload UIElement in your case,

and the following code under init or action methods

{
// some code

File f = new File("Sample.word");
f.createNewFile();
FileOutputStream fos = new FileOutputStream(f);
byte[] b=wdContext.currentNode().getData().getBytes(); fos.write(b);
fos.write("\t".getBytes());


FileInputStream fis = new FileInputStream(f); 
FileChannel fc = fis.getChannel(); 
 byte[] data = new byte[(int)(fc.size())]; 
 ByteBuffer bb = ByteBuffer.wrap(data); 
 fc.read(bb); 
 IWDCachedWebResource objCachedWebResource = null; 
 if (data != null) 
 { 
objCachedWebResource = WDWebResource.getWebResource(data,WDWebResourceType.DOC); 
objCachedWebResource.setResourceName(f.getName()); 
 } 
wdContext.currentContextElement().setResource(objCachedWebResource.getAbsoluteURL()); 


//some code
}

Create FileDownload UIElement, Create one Context named Resource, with type String, Map to FileDownload and add above code to some where like init() or any action methods...

regards

rajesh

Former Member
0 Kudos

hai Rajesh,

My requirement is one where i need to save the elements chosen in the application as a word doc in desktop on clicking the save button in application.There is no file here.

Thanks n Regards

Sharanya.R

Former Member
0 Kudos

Hi Sharanya,

For saving the data in a file, u need to create a file right?? get the data & export that in a doc as explained in excel export sample application (changes r required here bcos in this application xls is used). In the application they r exporting the data to xls & showing that in a popup window, same thing u have to do, only difference is instead of showing that file in a popup window, u have to save it on local system . for that create the file & give the path to save the file using Java IO package.

regards

Sumit

Former Member
0 Kudos

Hi,

Let me know ...can u use , Adobe interactive Forms ,,,,,,,...?

I hopeit is possible to make the user view on AIF , then the user can print , save ...what ever he want,,,and can be any type of doc...

Thanks ,

Srini

Former Member
0 Kudos

hai,

If iam using Adobe interactive forms

1.Can i get the data from database to be displayed in the form.

2.can one view alone of my application contain this AIF.

3.Can we save this as Word doc.

Then in the excel export when i tried they say it deals with XML which can be done only for excel not for word.Plz suggest me if there is any other option for doing that

Thanks n Regards

Sharanya.R

Former Member
0 Kudos

Hi,

3) It saves as PDF not as word.

1) and 2)

Basically Adobe interactive form is also an UIelement , which can contain subForm just like our view .

And then u can add the elements , input field, table, label,etc as same in the view.

Suppose u are bringing the data from backend into node of a context, we do binding for uielements in the view.

The same we do here. Binding with the node.

So procedure is --> View --> add ui Adobe Interactive Form --> Edit the form by adding controls on it and then binding.

But If already AIF are using in your project , then you can go ...otherwise again configurations settings may kill

your time at present....

Can you say how much data you need ....on the word document ....

Is it one page or it will be multiple pages..........

Thanks ,

Srini

Former Member
0 Kudos

hai Srinivas,

Thanks for the inpt.The data will be only be within a page.In that case An AIF may contain so many ui elements in that case if i bind the data from backend to AIF which UI element in form will carry the data.Plz do suggest me if there any other way to acheive this.

Thanks n Regards

Sharanya.R

Former Member
0 Kudos

Hi,

Forget about AIF , How u thought earlier, In the view , u will bind the backend data for a node of a context.

You will execute the method through JCo connections etc.

say :

Context

|

nodeBackend (node)

\ x (attibute)

y (attribute)

z (attribute)

Then , u will bind these x, y,z to some UIelements in the View. Isn't it .

Similarly ..........

Now come to AIF point,

In the Interactive form .........u take some controls ( these are not UI elements of the view , they are different for AIF form ) ..........add it form adn bind x,y,z .

The nodeBackend , x,y,z are also available to Interactive form , because it is just a control in the View.

Send your email address,,,,,so that i will send one page screen shot of binding...of AIF Form....

Thanks ,

Srini

Former Member
0 Kudos

hai Srinivas,

thanks for the input.

my mail id is

sharanya.r@enteg.com

Thanks n Regards

Sharanya.R

Former Member
0 Kudos

Hi,

can u send me some sample output ...how the end user wants to have .............????

Just if possible draft it on word and send......

With Regards,

Srini

Former Member
0 Kudos

hai Srinivas,

thanks for the input.

my mail id is

sharanya.r@enteg.com

can you please send the screen shot.Its very urgent.Also provide me some pdfs or links to help me achieve my requirement.

Thanks n Regards

Sharanya.R

Former Member
0 Kudos

hai Srinivas,

The requirement is as follows.

1.I have developed a web dynpro appln for customers.

2.when a customer clicks on a product he ll be shown the details(eg-wiring diameter,voltage level) of the product in a text edit which comes from database based on product selected.

3.The customer needs to save the details in the text edit in desktop and if he needs he may take prinout of that details in future.

Plz help me in doing this.

Thanks n Regards

Sharanya.R

Former Member
0 Kudos

Hi,

Can I know .... .. In your project AIF usage is ready ....ADS configuration is ok .

For your NWDS , life cycle designer is installed . If so ... if you have decided to use AIF means ...

And also usage of AIFs are limited , if crossed the number , company will be charged for extra usage of AIF

I will develop small application according to u r output and send you.

Thanks ,

Srini

Former Member
0 Kudos

hai Srinivas,

Thanks for the screen shot.I have not worked with adobe forms.So can you help me with step by step procedure in achieving the target.

Also suggest me will adobe form be the right option for achieving my requirement.

Thanks n Regards

Sharanya.R

Former Member
0 Kudos

Hi,

Hold for sometime ( around 1 hour ) .... i will send you sample application...

Then better u can decide ....what to use................

Meanwhile....pls make your trails .........................

See ,Saving on client machine. and Printing is biggest problem .....we too are facing........

I cannot say this is the right option ..but if this suits your requirement ..proceed....

Thanks ,

Srini

Former Member
0 Kudos

Hi,

Even if you use the AIF ,,,,

You need some practice to do changes according to your need.....

Because ...the controls of AIF are little bit confusing............

Any have i will send you sample application

Thanks,

Srini

Former Member
0 Kudos

Hi,

I have send you .

Let me know how far it may be helpful to you.

Thanks

Srini

Former Member
0 Kudos

hai Srinivas,

Thanks for all the input you have given.Also can you brief me regarding converting string to bytes and making word document from those bytes.

Thanks n Regards

Sharanya.R

Former Member
0 Kudos

Hi,

I have sent you two docs ...Both the options work fine for your needs, Choose the one with which u r comfort.

1) Adobe Interactive Forms. -- SampelAIF

2) KM related . -- SaveFile.

Just briefly I have written points in the starting . All the conversions everything is there in the word document.

Step by Step , no need to convert again ...

String s = new String(wdContext.currentContextElement().getStr()); // str is the TextEdit binded String

byte[] bytes = s.getBytes(); // string converted to bytes

WDWebResourceType.getWebResourceTypeForFileExtension("doc"); // setting to doc for word doc or else

// u can set anything like pdf, xls,etc

// making the contents to create a file in KM

_in = new ByteArrayInputStream(bytes);

IContent cont1 =(IContent) new Content(_in,resourceType1.getHtmlMime() /"image/jpg"/, _in.available());

// creating the file

IResource resource2 = empFolder.createResource(fn, null, cont1); // create the file where fn is the file name

Pls , go through the document....That is tested application ......

Thanks ,

Srini

Former Member
0 Kudos

hai srinivas

Thanks for all the input given by you.

Thanks n Regards

Sharanya.R

Former Member
0 Kudos

Hi,

Thank you very much .....since two days i am waiting for my points ........................

Thanks ,

Srini..

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Sharanya,

In which format ur data has to be saved?? U want to save data in a ms word file or pdf or what.???? In case u want word file, use office control provided by sap.

regards

Sumit

Former Member
0 Kudos

hai Sumit malhotra,

I have a text edit in my web dynpro appln.when the user clicks on the save button i need to save the contents of the text edit as a word file in desktop.can you help me in doing this with step by step procedure.

Thanks n Regards

Sharanya.R

Former Member
0 Kudos

Hi Sharanya,

I don't have any running application with me, so can't provide the code. Check these Tutorials, it requires some excercise,

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.highlightedcontent?documenturi=...

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.highlightedcontent?documenturi=...

Here u can find the sample application as Excel export.

https://www.sdn.sap.com/irj/sdn/webdynpro?rid=/library/uuid/49f2ea90-0201-0010-ce8e-de18b94aee2d#58

regards

Sumit

Former Member
0 Kudos

hai Sumit malhotra,

As per my requirement.I dont have and word doc but whatever data available in a text edit in webdynpro should be saved as a word file in the desktop.

Can you help me on this.

Thanks n Regards

Sharanya.R

Former Member
0 Kudos

Hi Sharanya,

have u checked the excel export sample application & tutotial?? There data is exported to xls but u can try with .doc file as well.

Check the exportToExcel2003 method in that & make some changes like instead of WDWebResourceType.XLS u can use WDWebResourceType.Doc etc.

I m not very sure abt that but it may work.

regards

Sumit

Edited by: Sumit Malhotra on Mar 25, 2008 12:35 PM