cancel
Showing results for 
Search instead for 
Did you mean: 

Issue faced while passing variable between 2 different applications

Former Member
0 Kudos

Hi i need some help.--

Issue is the window.open is always picking up an old value of V_TARGET_URL ( 1 run old).

Code attached below

<htmlb:button id = "b_edit"

text = "Edit"

onClick = "onInputProcessing(b_edit)"

onClientClick = "setEdit();" />

function setEdit()

{

window.open("<%= V_TARGET_URL%>");

}

WHEN 'b_edit'.

  • Construct the Target URL

call method runtime->construct_bsp_url

exporting

in_protocol = 'http'

in_application_ns = runtime->application_namespace

in_application = runtime->application_name

in_page = '**/targetapplicationname/maintainrole.htm'

importing

out_abs_url = v_target_url.

CONCATENATE runtime->application_name '/**/' INTO w_app_name.

REPLACE w_app_name IN v_target_url WITH space.

  • Set Server side cookie to store the source BSP appl detail

v_cookie = 'srcappname/listresult.htm'.

CALL METHOD cl_bsp_server_side_cookie=>set_server_cookie

EXPORTING

name = 'source_bsp'

application_name = 'NONE'

application_namespace = 'NONE'

username = sy-uname

session_id = 'NONE'

data_value = v_cookie

data_name = 'sbsp'

expiry_time_rel = 36.

  • Pass the User ID via URL

CONCATENATE v_target_url '?w_uniqueid_enter=' w_uniqueid_enter INTO v_target_url.

Regards

Bhavana

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Raja

This was already done earlier but i get the same issue of old url being picked since v_target_url ABAP scripting is called before OnInput processing

On Input processing everything as u had mentioned

This code mentioend below not required ...

((( * Set Server side cookie to store the source BSP appl detail

v_cookie = 'srcappname/listresult.htm'.

CALL METHOD cl_bsp_server_side_cookie=>set_server_cookie

EXPORTING

name = 'source_bsp'

application_name = 'NONE'

application_namespace = 'NONE'

username = sy-uname

session_id = 'NONE'

data_value = v_cookie

data_name = 'sbsp'

expiry_time_rel = 36.

)))

and then i m population v_target_url as below ..

  • Pass the User ID via URL

CONCATENATE v_target_url '?w_uniqueid_enter=' w_uniqueid_enter INTO v_target_url.

endif.

ENDIF.

Layout:

<htmlb:button id = "b_edit"

text = "Edit"

onClientClick = "setEdit();" />

<% if V_TARGET_URL is not initial. %>

function setEdit()

{

window.open("<%= V_TARGET_URL%>");

}

<% endif. %>

... now it gives me a Javascript error..at this point below...

raja_thangamani
Active Contributor
0 Kudos

Try the below code:

<htmlb:button id = "b_edit"
text = "Edit"
onClientClick = "setEdit();" />

<script type="text/javascript">

function setEdit()
{
<% if V_TARGET_URL is not initial. %>

window.open("<%= V_TARGET_URL%>");

<% endif. % >
}

</script>

Raja T

Former Member
0 Kudos

Hi raja

I shall explain a little in more detail now...

there is a tableview , 2 buttons below it edit and delete ,...the pages for edit and delete are in a different application ,

now to build the url depending on which button was clicked it has to go into the oninput processing where i put the code in Case b_edit and b_delete , to go to 2 different pages on the differnt application , taking along with it the userid which waas clicked for editing / deleting ( this user id i m reading from the tableview row selection like u said )....

Now issue is i am not able to open a new application since like u said it goes into client side scripring before it goes into Server side event...

I am ina fix..... This is the complete problem...... Please tell me if you know any way to ge t out of this tricky situation....

raja_thangamani
Active Contributor
0 Kudos

Dude,

I understood your requirement.

Did you try the below code?


<htmlb:button id = "b_edit"
text = "Edit"
onClientClick = "setEdit();" />
 
<script type="text/javascript">
 
function setEdit()
{
<% if V_TARGET_URL is not initial. %>
 
window.open("<%= V_TARGET_URL%>");
 
<% endif. % >
}
 
</script>

Raja T

Former Member
0 Kudos

i tried . it didnt work... it is opening the target Url of last run .....that is it opens it before the Oninput processing is triggered and picks up the last selected V_TARGET_URL.. ,,,,

How i have been trying on this issue for past 2 days,,,,

raja_thangamani
Active Contributor
0 Kudos

Sorry i didnt test the above code...

Here is the code which will solve your problem..I tested in my system also. Its working perfectly..

But still you need to construct the Target url while selecting the Tableview Row.


<htmlb:button id = "b_edit"
text = "Edit"
onClientClick = "setEdit('<%= V_TARGET_URL%>');" />

<script type="text/javascript">
function setEdit(url)
{
if(url != null)
{
alert(url);
window.open(url).focus();
}
}
</script>

<b>Event Handling:</b>


* event handler for checking and processing user input and
* for defining navigation


  DATA: TV          TYPE REF TO CL_HTMLB_TABLEVIEW,
        EVENT       TYPE REF TO CL_HTMLB_EVENT,
        TABLE_EVENT TYPE REF TO CL_HTMLB_EVENT_TABLEVIEW.
  FIELD-SYMBOLS <I> LIKE LINE OF SELECTED_IND.

  TV ?= CL_HTMLB_MANAGER=>GET_DATA( REQUEST = REQUEST
                                    NAME    = 'tableView'
                                    ID      = 'tv' ).
  IF TV IS NOT INITIAL.
    TABLE_EVENT = TV->DATA.
    CLEAR  SELECTED_IND.
    SELECTED_IND = TABLE_EVENT->PREVSELECTEDROWINDEXTABLE.

    IF TABLE_EVENT->EVENT_TYPE EQ CL_HTMLB_EVENT_TABLEVIEW=>CO_ROW_SELECTION.
      READ TABLE  SELECTED_IND WITH KEY TABLE_LINE = TABLE_EVENT->ROW_INDEX
        TRANSPORTING NO FIELDS.
      IF SY-SUBRC EQ 0.
        DELETE  SELECTED_IND INDEX SY-TABIX.
      ELSE.
        APPEND INITIAL LINE TO  SELECTED_IND ASSIGNING <I>.
        <I> = TABLE_EVENT->ROW_INDEX.
      ENDIF.
    ENDIF.
    DATA:V_COUNT(10).

    DESCRIBE TABLE SELECTED_IND LINES V_COUNT.
    IF V_COUNT EQ 1.

* Construct your Target URL here..

    ENDIF.
  ENDIF.

Raja T

Former Member
0 Kudos

I have 2 questions for u now

1) can we define 2 times

2) will this work for 2 buttons--- Edit and delete ( 2 URL´s i mean )

Former Member
0 Kudos

Hi Raja

It now opens Blank.com , back to square one since it doesnt goto Oninput processing at all to read the target URL...

Also if this worked.. how do u propose to contrust 2 different URL´s on 2 different buttons,, ( Edit and Delete )

raja_thangamani
Active Contributor
0 Kudos

Dude..YOu didnt get my point..

It now opens Blank.com , back to square one since it doesnt goto Oninput processing at all to read the target URL...

--->The Target URL will get constructed when you select the Row of Tableview..So while Clicking the Button, it has to open the window...

-->Can you please post your code here..so that i can suggest the modification if you still dont get my points...

Also if this worked.. how do u propose to contrust 2 different URL´s on 2 different buttons,, ( Edit and Delete )

-->Again you need to construct both Edit & delete url when the particular Row is selected..

Raja T

Message was edited by:

Raja Thangamani

raja_thangamani
Active Contributor
0 Kudos

+I have 2 questions for u now

1) can we define --> Answered with point 2

2) will this work for 2 buttons--- Edit and delete ( 2 URL´s i mean )

For Edit & Delete:


<htmlb:button id = "b_edit"
text = "Edit"
onClientClick = "Open_URL('<%= V_EDIT_TARGET_URL%>');" />
 
<htmlb:button id = "b_delete"
text = "Delete"
onClientClick = "Open_URL('<%= V_DELETE_TARGET_URL%>');" />

<script type="text/javascript">
function Open_URL(url)
{
if(url != null)
{

window.open(url).focus();
}
}
</script>

Raja T

raja_thangamani
Active Contributor
0 Kudos

I got what you are saying..about Blank page...If the Target URL is initial. Disable the buttons as follows: Same applies to Delete also..


<% If V_TARGET_URL is initial.
v_disabled = 'true'.
endif.
%>
<htmlb:button id = "b_edit"
text = "Edit"
disabled = "<%= v_disabled %>"
onClientClick = "Open_URL('<%= V_EDIT_TARGET_URL%>');" />

Raja T

Message was edited by:

Raja Thangamani

Former Member
0 Kudos

Thanks a lotttttttttt...

You r simply a genius..

Thanks again..

Shall assign u all points for this answer..

raja_thangamani
Active Contributor
0 Kudos

Please close the other thread also..

Raja T

Answers (2)

Answers (2)

Former Member
0 Kudos

Construct the URL with Table row selection..???

Can u help me .. never done this before...

how exactly do i do this,, ?

raja_thangamani
Active Contributor
0 Kudos

Here you....


       EVENT       TYPE REF TO CL_HTMLB_EVENT,
        TABLE_EVENT TYPE REF TO CL_HTMLB_EVENT_TABLEVIEW.
  FIELD-SYMBOLS <I> LIKE LINE OF SELECTED_IND.
 
  TV ?= CL_HTMLB_MANAGER=>GET_DATA( REQUEST = REQUEST
                                    NAME    = 'tableView'
                                    ID      = 'tv' ).
  IF TV IS NOT INITIAL.
    TABLE_EVENT = TV->DATA.
    CLEAR  SELECTED_IND.
    SELECTED_IND = TABLE_EVENT->PREVSELECTEDROWINDEXTABLE.
 
    IF TABLE_EVENT->EVENT_TYPE EQ CL_HTMLB_EVENT_TABLEVIEW=>CO_ROW_SELECTION.
      READ TABLE  SELECTED_IND WITH KEY TABLE_LINE = TABLE_EVENT->ROW_INDEX
        TRANSPORTING NO FIELDS.
      IF SY-SUBRC EQ 0.
        DELETE  SELECTED_IND INDEX SY-TABIX.
      ELSE.
        APPEND INITIAL LINE TO  SELECTED_IND ASSIGNING <I>.
        <I> = TABLE_EVENT->ROW_INDEX.
      ENDIF.
    ENDIF.

DESCRIBE TABLE SELECTED_IND LINES v_count. 

if v_count EQ 1. "Only one Row Selected

* Construct the Target URL
call method runtime->construct_bsp_url
exporting
in_protocol = 'http'
in_application_ns = runtime->application_namespace
in_application = runtime->application_name
in_page = '**/targetapplicationname/maintainrole.htm'
importing
out_abs_url = v_target_url.

CONCATENATE runtime->application_name '/**/' INTO w_app_name.

REPLACE w_app_name IN v_target_url WITH space.

* Set Server side cookie to store the source BSP appl detail

v_cookie = 'srcappname/listresult.htm'.

CALL METHOD cl_bsp_server_side_cookie=>set_server_cookie
EXPORTING
name = 'source_bsp'
application_name = 'NONE'
application_namespace = 'NONE'
username = sy-uname
session_id = 'NONE'
data_value = v_cookie
data_name = 'sbsp'
expiry_time_rel = 36.


* Pass the User ID via URL
CONCATENATE v_target_url '?w_uniqueid_enter=' w_uniqueid_enter INTO v_target_url.

endif.

  ENDIF.

<b>Layout:</b>


<htmlb:button id = "b_edit"
text = "Edit"
onClientClick = "setEdit();" />
 
<% if V_TARGET_URL is not initial. %>
 
function setEdit()
{
window.open("<%= V_TARGET_URL%>");
}
 
<% endif. %>
 

Raja T

Message was edited by:

Raja Thangamani

raja_thangamani
Active Contributor
0 Kudos

whats your requirement?

I dont understand why you used both events..

onClick = "onInputProcessing(b_edit)"

onClientClick = "setEdit();" />

Can you post the entire code so that we can understand..

Some more thoughts..

<htmlb:button id = "b_edit"
text = "Edit"
onClick = "onInputProcessing(b_edit)"
onClientClick = "setEdit();" />

function setEdit()
{
window.open("<%= V_TARGET_URL%>");
}

The New V_TARGET_URL will be constructed only when the Server events triggered..otherwise it will take the same value..

also set expiry_time_rel = 360 instead of 36..

Raja T

Former Member
0 Kudos

Hi Raja

The requirement as u mentioned rightly is that i need to call this new V_TARGT_URL after i click on the b_edit button.

Also since i wanted to open a new page i did the client side scripting.

How do i open a new page onInput processing,,

raja_thangamani
Active Contributor
0 Kudos

correct your code as below:

<htmlb:button id = "b_edit"
text = "Edit"
onClick = "b_edit"
 />
<% if V_TARGET_URL is not initial. %>
<script type="text/javascript">

window.open("<%= V_TARGET_URL%>");
</script>

<%endif.%>

Raja T

Former Member
0 Kudos

I disgree with u a litle on this since

V_TARGET_URL may not be intial when run from the same page on click of the second user id.

How will that help ..

I still want it to go to the new page in the target application with the new userid value each time the button is clicked .

I hope u can help..

raja_thangamani
Active Contributor
0 Kudos

How do you select the second user id?

& Can you tell me the flow?

Raja T

raja_thangamani
Active Contributor
0 Kudos

By linking your other thread, i feel using Tableview->Rowselection you are selecting the user id.

<b>In that The rite place to construct the Target URL is when you select the Tableview rows & not while selecting the EDit button.</b>

IF TABLE_EVENT->EVENT_TYPE EQ CL_HTMLB_EVENT_TABLEVIEW=>CO_ROW_SELECTION.

* Check SELECTED_IND has only one entries-->means only one user selected..
* Construct your Target URL..

If i am wrong, explain me the flow..

Raja T

Message was edited by:

Raja Thangamani

Former Member
0 Kudos

constructing my target url is fine,. but the problem is opening that new url in a NEW Page..

Even if i m doing it in a b_edit,, It constructs and then doesnt do anything when i use the window.open <%= target_url %> on the Input processing page.

i cant use naviagtion->goto_page since it opens in the same frameset as the result page which i dont want

raja_thangamani
Active Contributor
0 Kudos

<i>constructing my target url is fine,. but the problem is opening that new url in a NEW Page..</i>

Yes the issue with construction of URL..when select the second user, you will always show the URL of previously constructed for user 1. Becos of your OnClient Click event.

Hope you understand what i am saying..

Also you can't open the page in new window in Oninputprocessing.

So suggest you this way..

IF TABLE_EVENT->EVENT_TYPE EQ CL_HTMLB_EVENT_TABLEVIEW=>CO_ROW_SELECTION.
 
* Check SELECTED_IND has only one entries-->means only one user selected..
* Construct your Target URL..

<b>In Layout:</b>

<htmlb:button id = "b_edit"
text = "Edit"
onClick = "b_edit"
 />
<% if V_TARGET_URL is not initial. %>
<script type="text/javascript">
 
window.open("<%= V_TARGET_URL%>");
</script>
 
<%endif.%>

Raja T

Message was edited by:

Raja Thangamani

raja_thangamani
Active Contributor
0 Kudos

adding more to the above post...

<i>Even if i m doing it in a b_edit,, It constructs and then doesnt do anything when i use the window.open <%= target_url %> on the Input processing page.</i>

The reason is, Client side code will execute before you Server side event execute..

THe window.open <%= target_url %> will be executed becos you are calling the set_edt Fm using OnClientClick...

Thats the issue in your code..

Raja T

raja_thangamani
Active Contributor
0 Kudos

Other option is...

Construct the URL with Table row selection...

To open the new window, you no need to trigger the server event when you click the Button..

<htmlb:button id = "b_edit"
text = "Edit"
onClientClick = "setEdit();" />

<% if V_TARGET_URL is not initial. %>

function setEdit()
{
window.open("<%= V_TARGET_URL%>");
}

<% endif. %>

This will also work as per your requirement..

Raja T

Message was edited by:

Raja Thangamani