cancel
Showing results for 
Search instead for 
Did you mean: 

Download SAP Script PDF form using webdynpro java

Former Member
0 Kudos

Hi ,

Iam accessing a BAPI that gives me a SAP Scipt PDF form as a result.can someone give a step by step process of how to display it in portal on clicking a button using webdynpro java.

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member197348
Active Contributor
0 Kudos

Hi Swathi,

Check this [thread|].

You have a link given by Marco. Try it.

Regards,

Siva

Former Member
0 Kudos

Hi ,

The thread talks completely about a different scenario.I want to get the PDF from a BAPI that returns a SAP SCRIPT form.

Former Member
0 Kudos

Hi Swathi,

Refer to this link which might be helpful to you.

http://saptechnical.com/Tutorials/Smartforms/SFinEPasPDF/Page1.htm

Thanks & Regards,

Jhansi Miryala

Former Member
0 Kudos

Hi jhansi,

Thanks for the reply .But iam talking about getting the smartform in webdynpro using a BAPI.

Former Member
0 Kudos

Hi ,

Insert IFrame UI Element and bind the Resource property to the value attribute PdfUrl of type String .

Define a Output parameter of type Binary in RFC .

Insert the following code to dispaly the smart form

byte[] pdfContent = wdContext.currentOutput<node>().get<Binary>();

IWDCachedWebResource pdfResource = WDWebResource.getWebResource(pdfContent,WDWebResourceType.PDF);

try

{

wdContext.currentContextElement().setPdfUrl(pdfResource.getURL());

}

catch(Exception e)

{

wdComponentAPI.getMessageManager().reportException(e.getMessage(),true);

}

Regards,

Sunitha Hari

Former Member
0 Kudos

Hi sunitha,

Is this the same process for a smart form or a sap script form.How easy or hard is it in abap to return a binary parameter for the form because mine is a sap script form.

regards

swathi

Former Member
0 Kudos

Hi Swathi ,

I am not sure about script form , just give it a trial and see if it works.

Regards,

Sunitha.

vmadhuvarshi_
Contributor
0 Kudos

Swathi,

See [this thread|;. This worked for me and if you are getting PDF form from RFC, this just might work for you too.

Vishwas.

Former Member
0 Kudos

Hi vishwas,

Right now the bapi that is displaying the sap script form doesnt have any export parameters.Can you tell me what they need to pass as export parameters to me so that i can follow that code.I know that thye have to send something of format binary.

regards

swathi

vmadhuvarshi_
Contributor
0 Kudos

The thread that I referred to calls for a Byte Array to be returned from R3 side. Function Module CONVERT_OTF can be used for this purpose.

Former Member
0 Kudos

Hi vishwas,

When i debug and see the TDline that i get i see some garbage values and iam trying to convert it into bytes in my webdynpro program.Am i doing right.I dont see any result but i see only a blank page opening up.

regards

swathi

vmadhuvarshi_
Contributor
0 Kudos

Swathi,

This is the code from the thread I referred above. Please see if it helps you.


String s=null
    for(i=0;wdContext.nodeTLINE();i++)
    wdContext.nodeTINE().moveFirst();
   {
      strTline = wdContext.nodeTLINE().nodeTLine().currentTlineElement();
    //check the element in TLINE should of lenght of 2 if not then fill with space "". loop it like that. 
   strTdline = wdContext.nodeTLINE().nodeTdLine().currentTdLineElement();
   //check the element in TDLINE shud be of 138 characters if not loop it to and fill it with spaces. 
   s= s+strTline+strTdline;
wdContext.nodeTINE().moveNext();
    }
 
//From this string that is been obtained convert it into bytearray using following:
  byte[] byteString = s.getBytes[];

Vishwas.

Former Member
0 Kudos

Hi vishwas,

I was tring to use Bytebuffer and the NWDS cannot resolve that API.I tried to add that lib in the project but i couldnt find it.any idea.

vmadhuvarshi_
Contributor
0 Kudos

I found Bytebuffer API in following path. You should find it here too. Are you using ClasLocator tool? It is very helpful in such cases. If not, Search for ClassLocator in SDN.

com.sap.lcr.api.util.ByteBuffer

Hope this helps.

Vishwas.

Former Member
0 Kudos

My NWDS still could not resolve the ByteBuffer API .I tried to read the PDF and it says File doesnt start with %PDF- after i resolved this issue and tried to open it directly in adober reader it gives me an error that the file is corrupted.

vmadhuvarshi_
Contributor
0 Kudos

I had the same problem - "File doesnt start with %PDF-" and this was solved with ByteBuffer API. I'm using JDK 1.4.2_18 and ByteBuffer API is available to me without any specific imports in these 2 locations.

com.sun.corba.se.internal.ior.ByteBuffer

java.nio.ByteBuffer

See if this works for you.

Former Member
0 Kudos

Hi vishwas ,

Thanks for you help.I could finally resolve the problem with a different apporach even without using bytebuffer.I used filedownload api

Here is my code

wdThis.wdGetBenCustController().Execute_PrintEnrollmentForm();

byte[] byteString = wdContext.currentPrintformElement().getPdf_Xstring();

//byte[] byteString = pdfString.getBytes();

String url = null;

// From this string that is been obtained convert it into bytearray using following:

try{

IWDResource wr = WDResourceFactory.createCachedResource(byteString, "PDF-Report", WDWebResourceType.PDF);

IWDWindow w = wdComponentAPI.getWindowManager().createNonModalExternalWindow(wr.getUrl(0), "PDF-Report");

url = wr.getUrl(WDFileDownloadBehaviour.OPEN_INPLACE.ordinal());

w.show();

}

catch (Exception e)

{

wdComponentAPI.getMessageManager().reportException(e.getLocalizedMessage(), false);

}

vmadhuvarshi_
Contributor
0 Kudos

All is well that ends well !

Congratulations on finding another solution for this common issue.

Vishwas.