cancel
Showing results for 
Search instead for 
Did you mean: 

How to get PDF on to WebDynpro iView ?

Former Member
0 Kudos

Hi Friends,

We are in need of showing the receipt in the PDF. Which is returned by the ABAP Function Module and the out parameter is of 'C' character.

I am a novice for ABAP, what we came to know is that Our ABAP team is not using the SMARTFORMS. They want to give the PDF without using SMARTFORMS.

Now, Anyone please guide me for the following :

1. How to get the PDF content from ABAP function Module when we dont use the SMARTFORMS ? (wht should be the type of the out parametr of BAPI)

2. How to show the PDF content returned from the ABAP ?

3. Is the following way correct to return the PDF from ABAP to EP iView ?

<i><b>byte[] actualPdfContent=pdfContent.getBytes(); IWDWebResource pdfResource = WDWebResource.getWebResource(actualPdfContent, WDWebResourceType.PDF);

wdComponentAPI.getWindowManager().createExternalWindow(pdfResource.getAbsoluteURL(),"Order Details",false).open();</b></i>

4. Please let me know how to achieve this kind of scenario?

Thanks in advance!!

- Raghavendra P

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi

What you can do is ask your ABAP team to create a SAP script (if not SMARTFORMS) for printing receipts.

Now there is a function module called 'CONVERT_OTF'. which will convert the data of SAP script into bin file which you can display using WebDynpro.

Sample of ABAP fm 'Convert_OTF'

IM_SF_DEMO --> Smart form Name to be passed.

function zsf_pdf_demo.

*"----


""Local interface:

*" IMPORTING

*" VALUE(IM_SF_DEMO) TYPE SSFSCREEN-FNAME DEFAULT

*" 'ZNOTIF_DEMO'

*" EXPORTING

*" VALUE(LV_SIZE) TYPE I

*" VALUE(BIN_FILE) TYPE XSTRING

*" TABLES

*" ET_PDF STRUCTURE TLINE OPTIONAL

*"----


data : out_opt type ssfcompop, ctrl type ssfctrlop, out_info type

ssfcrescl.

data: function_name type rs38l_fnam.

out_opt-tdnoprev = 'X'.

out_opt-tddest = 'WIND'.

*NO_OPEN

*NO_CLOSE

*DEVICE

ctrl-no_dialog = 'X'.

ctrl-preview = ' '.

ctrl-getotf = 'X'.

call function 'SSF_FUNCTION_MODULE_NAME'

exporting

formname = im_sf_demo

  • VARIANT = ' '

  • DIRECT_CALL = ' '

importing

fm_name = function_name

exceptions

no_form = 1

no_function_module = 2

others = 3.

  • call function to process smart form

call function function_name

exporting

  • archive_index = is_archive_index

control_parameters = ctrl

output_options = out_opt

importing

job_output_info = out_info

  • job_output_options = es_job_output_options

exceptions

output_canceled = 1

parameter_error = 2

others = 3

.

.

call function 'CONVERT_OTF'

exporting

format = 'PDF'

  • MAX_LINEWIDTH = 132

  • ARCHIVE_INDEX = ' '

  • COPYNUMBER = 0

  • ASCII_BIDI_VIS2LOG = ' '

importing

bin_filesize = lv_size

bin_file = bin_file

tables

otf = out_info-otfdata

lines = et_pdf

exceptions

err_max_linewidth = 1

err_format = 2

err_conv_not_possible = 3

err_bad_otf = 4

others = 5

.

if sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

endif.

endfunction.

After this abap function call what you can do is

//Code snippet in WebDynpro

You will get the return as a byte array from the RFC

Then you can write the following code.

you can write this code in OnactionClick for example

byte[] pdfContent={here document is created i.e returned from RFC};                                   
 IWDCachedWebResource pdfResource=WDWebResource.getWebResource                  (pdfContent,WDWebResourceType.PDF);                                         
 wdComponentAPI.getWindowManager().createExternalWindow(  
     pdfResource.getURL(),"receipt view",true).open();   

Hope that helps you out. :)..

regards

Ravi

Answers (1)

Answers (1)

Former Member
0 Kudos

hi Ravi,

Thanks for your solution..!!!

- Raghavendra Pothula

Former Member
0 Kudos

Hi Ravi,

We are able to show the PDF using the download control but not using the

<u><b>IWDCachedWebResource pdfResource =WDWebResource.getWebResource(wdContext.currentContextElement().getFilesource_1(),WDWebResourceType.PDF);

wdComponentAPI.getWindowManager().createExternalWindow(pdfResource.getURL(),"receipt view",true).open();</b></u>

We are getting the Popup window with blank content. Could you please let me know how to get out of this problem.

We are getting proper pdf data from ABAP. I can say it sure coz, we are able to show/open the PDF using the donwload control.

But, we need to show the PDF directly on the popup.

Please let me know how can we get rid of this BLANK window popup without pdf content.

Thanks for your time...

-

Raghavendra P

Former Member
0 Kudos

Hi

sorry for the delay in the response. Are you getting the data in the byte array. It should work. what is the version of NDS you are using. we were using SP11. So let me know. I dont have a system now where i can check.

Let me know what exactly are you returning from RFC.

regards

Ravi

Former Member
0 Kudos

Hi Ravi,

I got the solution.. now i am able to get the PDF in the external window. The changed code which i used to get the solution is as belwo

This is how i got solution...

try {

String key = "order-receipt-999";

IWDCachedWebResource pdfResource = WDWebResource.getPublicCachedWebResource(

wdContext.currentContextElement().getFilesource_1(),

WDWebResourceType.PDF,

WDScopeType.CLIENTSESSION_SCOPE,

wdThis.wdGetAPI().getComponent().getDeployableObjectPart(),

key);

wdComponentAPI.getWindowManager().createExternalWindow(pdfResource.getURL(), "my window name", false).open();

} catch (WDURLException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

Theonly change is, we used the WDWebResource.getPublicCachedWebResource instead of other method.

Thanks for your response to help..!!

Thanks,

RP

former_member182294
Active Contributor
0 Kudos

Hi Raghavendra,

We have similar kind of requirement. This thread so much useful for us. We are facing a problem with this code. When we execute the BAPI through SAP GUI(transaction se37) we are able to see the output in BIN_FILE. But when we are calling this RFC through standalone Java program or with WebDynpro the byte array returning is always NULL. Do we need to make any changes? Please suggest.

Thanks in advance.

Regards

Abhilash

Former Member
0 Kudos

Hi Raghavendra and Abhilash,

I have the same problem as Abhilash, I can get bin_file from function module . but the in web dynpro side we get error message as null array or out of bound error, could you give me some clue ? Thank you very much!

Former Member
0 Kudos

Hi Hao,

I have the same problem.

I can get bin_file from function module . but the in web dynpro we get error message as null array or out of bound.

You Solve this?

I need help.

Thaks

Nohemi

BeGanz
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hallo Nohemi,

in NW 7.0 you should store the retrieved binary file as a resource object of type IWDResource inside the context.

Regards, Bertram