Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Getting JS variable value in ABAP variable

former_member183993
Participant
0 Kudos

hi experts,

I am fairly new to ABAP programming so please bear with me. To my issue.

I am creating a BSP which will read from the tax number table in CRM into an itab.

Next it loops into an wa and then passes each tax number through a javascript/JQuery API to validate the number.

The JSON response then comes back and is stored in a JS variable.

I am unclear how to get this into an ABAP variable so I can handle as needed. I have read some posts but they seem to be created for those ABAP experts which I am not there yet.

Any help is most appreciated.

thank you kindly!

Chris

1 ACCEPTED SOLUTION

former_member184578
Active Contributor
0 Kudos

Hi,

Check this threads:

hope this helps u,

Thanks & Regards,

Kiran

6 REPLIES 6

former_member184578
Active Contributor
0 Kudos

Hi,

Check this threads:

hope this helps u,

Thanks & Regards,

Kiran

0 Kudos

Thanks for the reply Kiran.

I am still stuck where I try to create the hidden field, assign the JS variable value to it and then retrieve on server side using ABAP.

I read some places where it mentions accessing in the controller but this is not specific enough for me to know what to do. Here is a snippet of my JS/html code.

<form id="api">

<div><input type="hidden" name="json" id="json" value="" /></div>

var json = data;

document.getElementById("json").value = json;

document.api.submit();

</form>

I am using a Jquery api to get a boolean value and storing it in the json variable. then I want to pass that value to an ABAP variable. I did maintain a page attribute of json type STRING as well. I also tried maintaining a controller class attribute of the same. I did not redefine any controller class methods.

Your help is most appreciated.

thx

Chris

0 Kudos

Hi chris,

check this thread for getting hidden field variable

hope this helps u,

@moderators: don't close this thread, instead move to bsp forum,

Thanks & Regards,

Kiran

0 Kudos

Hi,

Below code may be useful to you. Define hidden field in ur html. Call JS function apiValidation, in this case, on the click of any button that you might be using in html code. Here the json value will be transfer into your hidden field and as the form will be posted you can retrieve the value of hidden fied using the HTTP request method (POST).

function apiValidation{

"your valisation code".

var json = data;

document.getElementById("taxnum").value = json;

document.api.submit();

}

<form id="api" method = "post">

<input type="hidden" name="taxnum" id="taxnum" value="" />

</form>

former_member183993
Participant
0 Kudos

Thank you two so much! I was able to see the value now. My only remaining issue is getting it into an abap variable. I have read folks doing it in the controller but I am very unclear how this is accomplished.

Thanks again for your help!

Chris

former_member183993
Participant
0 Kudos

hi all,

I actually found the answer. i referred to this very EASY to read step by step example of how to accomplish what I need.

http://www.sapdev.co.uk/webapps/bsp/bsp_userinput.htm

Enjoy and thanks for your help!!

Chris