cancel
Showing results for 
Search instead for 
Did you mean: 

Saving a document using webdynpro application

Former Member
0 Kudos

Dear All,

I am new in webdynpro development and I have a requirement to develop a webdynpro application which can save a document in a specified file directory. Can somebody please suggest or give sample code as to how to develope this application ...so that i can understand how to go about it.

Awaiting response.

Thank You.

Ranu

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi

See this Thread

Kind Regards

Mukesh

Former Member
0 Kudos

Dear Mukesh ,

Thank you for your prompt reply. Well as suggested by you I tried developing a small webdynpro application with the UI element FileUpload and a button Save. Then I added the code as mentioned by you in onActionSave. Here I am getting a few errors for the extract of code mentioned below:-

fname = files.getName();

final InitialContext ctx1 = new InitialContext();

final DestinationService dstService1 = (DestinationService)ctx1.lookup(DestinationService.JNDI_KEY);

The Errors are

1.fname cannot be resolved

2.DestinationService cannot be resolved or is not a type.

Can you please tell me what i am missing out.

Thank you.

Ranu

suresh_krishnamoorthy
Active Contributor
0 Kudos

Hi Ranu,

Did you added the reference in webdynpro project:

Do this step also:

(1) In the Package explorer, select your project, right click, cick on "Set Additional Libraries.."

(2) Select security.class and tc/sec/destinations/interface

(3) Click on menu Project > Properties, goto Webdynpro refereces node in the tree and add the following

(a) Interface References: tcsecdestinations~interface

(b) Service References: tcsecdestinations~service

Check this thread too:

Regards, Suresh KB

Former Member
0 Kudos

Dear Suresh,

Thank you for your prompt reply. Well as suggested by you , I have done the part of " Set Additional Libraries " and " WebDynpro References". The error which was earlier come of DestinationService cannot resolved is no longer coming .

Now the errors are

1.fname cannot be resolved( this was there earlier too)

2.Type mismatch: cannot convert from com.sap.security.core.server.destinations.api.Destination to javax.print.attribute.standard.Destination

Please advise.

Thank you.

Ranu

suresh_krishnamoorthy
Active Contributor
0 Kudos

Hi Ranu,

Check my previous reply link: I think you imported wrong packages. is your packages same like this?

import com.sap.security.core.server.destinations.api.Destination;

import com.sap.security.core.server.destinations.api.DestinationService;

import com.sap.security.core.server.destinations.api.HTTPDestination;

Regards, Suresh KB

Former Member
0 Kudos

Dear Suresh,

Thank you very much for your helpful answer.I have rectified the imports. Now the only error that is still persistent is "fname cannot be resolved ".

I am attaching the code snippet that I have written in the part onActionSave for your perusal.Can you please look into it and let me know where I am making a mistake.

public void onActionSave(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )

{

//@@begin onActionSave(ServerEvent)

byte imgsource[] = wdContext.currentDataElement().getDocument();

String filePath = wdContext.currentDataElement().getFileName();

byte[] fileBytes; //an array of bytes

try {

File files = new File(filePath);

fname = files.getName();

final InitialContext ctx1 = new InitialContext();

final DestinationService dstService1 = (DestinationService)ctx1.lookup(DestinationService.JNDI_KEY);

final Destination destination1 = dstService1.getDestination("HTTP", "document");

//specify the Http destination as document

fileBytes = imgsource; //create a byte array from contents of field

String docuurl = "http://impp11.pune.telco.co.in:50000/irj/portal/+fname";

OutputStream targetFile = new FileOutputStream(docuurl);

//define the output stream

targetFile.write(fileBytes); //write the array of bytes to file

targetFile.close(); //close the File stream

} catch (Exception e) {

e.printStackTrace();

wdComponentAPI.getMessageManager().reportSuccess(e.getMessage());

}

}

Thank You.

Ranu

suresh_krishnamoorthy
Active Contributor
0 Kudos

Hi Ranu,

fname = files.getName(); you have to declare that variable fname.

try like this String fname = files.getName();

Regards, Suresh KB

Former Member
0 Kudos

Dear Suresh and Mukesh ,

Thank you, for all the help that you have provided. I have successfully created the webdynpro application to upload a document in a particular directory. There is still some problem with the destination configuration but that is being looked into by system admin. I shall get back to you if i face any problems but for the time being thank you very much for the help provided.

Regards,

Ranu

Answers (0)