Skip to Content
0

How to read a pdf file placed in application server and display its contents in webdynpro.

Apr 24 at 01:27 AM

58

avatar image
Former Member

Hi all,

I have a requirement to create a test menu in a standard SNC webdynpro application. When i click on this menu, it dhould read a pdf file ehich is in AL11 and display its contents in webdynpro browser or a new window.

I have tried searching a lot SDN community, i gave got partial solution but not the complete idea.

I have implemented a badi WD_BADI_DOMODIFYVIEW in which i have written code to read pdf from AL11 and its in an internal table now but how do i bind this data to a node and how to display this data .please note that, here the UI element i.e test menu is created dynamically, using the configuration. How do i assign action to this menu item button? Please suggest me with the complete flow.

Thanks in advance.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Himanshu Gupta
Apr 24 at 02:42 AM
0

Hi Akshatha,

Adobe form can only be visible to Webdynpro using UI element - "Interactive PDF" . You can bind those Xstring data with the element and it will automatically available .

Show 2 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi Himanshu,

Thanks for your reply.

I have tried binding this xstring to a node created in the component controller using set attribute but I am getting an error

Below code i have written inside the BADI WD_BADI_DOMODIFYVIEW.

if first_time = abap_true.

* open dataset file for input in TEXT MODE ENCODING DEFAULT.

open dataset file for input in BINARY MODE.

if sy-subrc is initial.

DO.

READ DATASET file INTO gs_pdfout-line.

IF sy-subrc is initial.

APPEND gs_pdfout TO gt_pdfout.

else.

APPEND gs_pdfout TO gt_pdfout.

exit.

ENDIF.

clear gs_pdfout.

ENDDO.

endif.

CLOSE DATASET file.

DESCRIBE TABLE gt_pdfout LINES size.

CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'

EXPORTING

INPUT_LENGTH = size

* FIRST_LINE = 0

* LAST_LINE = 0

IMPORTING BUFFER = pdf_source

TABLES BINARY_TAB = gt_pdfout

* EXCEPTIONS

* FAILED = 1

* OTHERS = 2

"To set the xstring to node PDF_DATA

CALL METHOD WD_CONTEXT->SET_ATTRIBUTE

EXPORTING

* INDEX = USE_LEAD_SELECTION

VALUE = pdf_source

NAME = 'PDF_DATA' .

After excuting this, i m getting the error, Couldnot find the attribute PDF_DATA

Also, the other way out, i tried to download it by using below method, but its giving me an error saying," file is damaged or corrupted.Can't open the pdf file."

CALL METHOD CL_WD_RUNTIME_SERVICES=>ATTACH_FILE_TO_RESPONSE

EXPORTING

I_FILENAME = file

I_CONTENT = pdf_source "gt_pdfout

I_MIME_TYPE = 'pdf'

* I_IN_NEW_WINDOW = ABAP_FALSE

* I_INPLACE = ABAP_FALSE

Please help me out to solve this issue.

Thanks in advance
0

Check the blog to get access the context from the badi

https://blogs.sap.com/2015/02/25/wdbadidomodifyview-little-known-things/

0