cancel
Showing results for 
Search instead for 
Did you mean: 

PDF -> WebDynpro 4.6C

Former Member
0 Kudos

Hi,

I have an issue where I need to display a PDF generated in a 4.6C system in a WebDynpro Java application. The problem I'm having is the CONVERT_OTF function doesn't export the bin_file parameter in this version so all I have to work with is the lines table.

The code I'm using to output the pdf in the WebDynpro app is:

IWDWebResource webResource = WDWebResource.getWebResource(
		wdContext.currentOutputElement().getPdf_String(),
		WDWebResourceType.PDF);
try {
	url = webResource.getURL();
} catch (WDURLException ex) {
}

This needs me to convert my pdf from the lines table format into a byte array.

I've tried doing this in ABAP using the CONCATENATE command and this results in a corrupted pdf file. I think the issue there is that the CONCATENATE is working in CHARACTER MODE as the BYTE MODE addition is not available until 4.7

I've also tried merging the contents on the java side by converting the output of the lines table into byte[] and combining them together, with similar results.

I can't imagine it is not possible to do this in 4.6C.

Any help would be greatly appreciated.

Thanks

Ian

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

hi Ian,

The problem with 4.6C version it desn't have a BINFILE equivalent or ZSTRING type. But byte array can be obtained in 4.6C. In order to obtain that you need to get the information in structure having TLINE and TDLINE columns/parameters.


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[];

once u obtain in Byte array. You can get the PDF.

I've done this way in past. Presently not having access to that piece of code but idea is to do this way only.

Thanks in advance

Srikant

Former Member
0 Kudos

Hi Srikant,

I've finally got it working using the following code.

Thanks

Ian

String pdfString = "";
String temp1 = "";
String temp2 = "";

for (int i = 0; i < wdContext.nodePdf().size(); i++) {
	temp1 = wdContext.nodePdf().getPdfElementAt(i).getTdformat();
	int diff = 2 - temp1.length();
	while (diff > 0) {
		temp1 = temp1 + " ";
		diff--;
	}
	temp2 = wdContext.nodePdf().getPdfElementAt(i).getTdline();
	diff = 132 - temp2.length();
	while (diff > 0) {
		temp2 = temp2 + " ";
		diff--;
	}
	pdfString = pdfString + temp1 + temp2;
}

IWDWebResource webResource = WDWebResource.getWebResource(
				pdfString.getBytes(), 
				WDWebResourceType.PDF);

Former Member
0 Kudos

hi Ian gee..

i am doing the same thing. Can u please explain this code?and where we need to put this code either in the custom controller or in the result view..

My task is i have one Function module which gives output in the pdf format text in webdynpro.So we want the output in the actual text,(readable).

The thing we need is to convert from pdf to the readable text.

thanks

Gobinath R.

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi at all,

I've the same problem but i'm using NW2004 and

IWDWebResource is an Interface of 2004s .

Have you any idea ?

former_member197348
Active Contributor
0 Kudos

Hi Ian,

It is possible to generate to PDF in a 4.6C with WebDynpro.Using Function Module CONVERT_OTF converts to byte form. Then do the following

com.sap.lcr.api.util.ByteBuffer bb = new com.sap.lcr.api.util.ByteBuffer();

for (int i = 0; i < wdContext.node<name>().size(); i++)

{

bb.append(wdContext.node<name>().get<name>ElementAt(i).get<attribute>());

}

try{

IWDResource wr = WDResourceFactory.createCachedResource(bb.toByteArray(), "PDF Report", WDWebResourceType.PDF);

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

w.show();

}

catch (Exception e)

{

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

}

regards,

siva.

Former Member
0 Kudos

Siva,

You are a lifesaver! Your solution worked for me in the first go. I was on the verge of giving it up and try a different approach after trying concatenating Bytes in a String or StringBuffer and always getting a corrupted file. Your Bytebuffer approach just saved my work of many hours.

Thanks a lot.

Vishwas.