cancel
Showing results for 
Search instead for 
Did you mean: 

Retrieve a JavaScript variable data filled in BSP embedded in a WDA

0 Kudos

Hi,

Requirement :

I have a view in my web dynpro application. Inside that view I have embedded an Iframe. The source of this Iframe is link of a BSP Application.

Inside my BSP Application, I am calling a javascript function which fills up a variable declared inside it. Now I need the data of this variable inside my Web Dynpro Application.

Things tried :

I created a page attribute, which i tried filling inside the JavaScript function but failed. I observed that it is possible to pass page attribute data into a javascript variable but not vice-versa. Then I tried to create a cookie inside the JS function and tried to read the cookie inside the Web Dynpro using

' cl_bsp_server_side_cookie=>get_server_cookie' but again failed since I used to set the cookie inside the JS but while reading, didn't get anything.

Finally I created a button in BSP, on the click of which OnInputProcessing event gets triggered, here i got the data by reading the UI Element (textarea)

and then from here i exported the data, but this involves an extra event(i.e. a button click) which I don't want.

Kindly suggest the solution.

SA

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

1) If both your webdynpro application and BSP are in the same session(which i doubt), then go as below


-> Create a global class in SE24(say zcl_test) and create a public static attribute(say lv_test)

-> Populate this static attribute from your BSP as zcl_test=>lv_test = 'test'.

-> Access this static attribute from webdynpro as zcl_test=>lv_test

2) If both applications are in different session with different users then do as below in BSP, where lv_attr is your variable which you want to transfer to WD


EXPORT lv_attr TO SHARED BUFFER indx(st) ID 'ZTEST'.

Now fetch this variable in WD as


data: lv_attr type string.

IMPORT lv_attr = lv_attr FROM SHARED BUFFER indx(st) ID 'ZTEST'.

This will also not work if your applications are running on different application servers

0 Kudos

Let me make my requirement more clear:

I have a JS function in my BSP where I perform some calculation. Now the data in one of the variable inside the JS needs to be exported to my WebDynpro Application. What I have found is that we cannot pass the JS variable value to page attribute of my BSP appl but vice-versa is possible. If I am able to get the data into my BSP page attribute then it will be possible for me to pass the data to my WD Appl through various ways. Simply speaking, requirement is to get the JS variable data into my ABAP variable.

Former Member
0 Kudos

try mapping the value of your textArea in html to the page attribute as below

value="<%= lv_page_attr %>"

0 Kudos

'try mapping the value of your textArea in html to the page attribute as below'

This statement contradicts

'value="<%= lv_page_attr %>"'


As I have already mentioned, value of my textArea cannot be assigned to my page attribute as it is gives below error.


'<%= lv_page_attr %>' = value;

'textedit.htm:14 Uncaught ReferenceError: Invalid left-hand side in assignment'