cancel
Showing results for 
Search instead for 
Did you mean: 

Value from java script to ABAP

Former Member
0 Kudos

Hi

Please tell me how to get value from java script to ABAP variable.Here I have a Date variable Which is the input.After the client validations I have to move this value to LV_DATE which is ABAP variable.Please see my code and help me.

<script type="text/javascript">

function checkInput()

{

var dateval = document.form1.date.value

alert(dateval);

var today = new Date();

var get_date = today.getDate();

if (get_date < 9)

{

get_date = "0"+get_date;

}

var get_month = today.getMonth()+1;

if (get_month < 9)

{

get_month = "0"+get_month;

}

var today_date = get_date"."get_month"."(today.getFullYear());

alert(today_date);

if (dateval == "" || dateval > today_date)

{

alert("please enter date less than or equal to today");

}

else

{

htmlbSL(this,2,'mybutton:Submit');

}

}

</script>

<htmlb:tray id = "t1"

title = "Sample Window"

design = "BORDERLESS"

isCollapsed = "false"

width = "75%" >

<htmlb:trayBody>

<htmlb:textView text = "Hello World!"

textColor = "RED"

design = "HEADER1"

align = "CENTER" />

<htmlb:inputField id = "date"

type = "DATE"

showHelp = "TRUE"

alignment = "CENTER"

/>

<htmlb:button id = "mybutton"

text = "Press Me"

onClientClick = "javascript:checkInput();" />

</htmlb:trayBody>

</htmlb:tray>

I am new to BSP Please tell me indetail.I also went through the previous posts but I didn't get it perfectly.

Thank You.

Regards

Giri.

Accepted Solutions (1)

Accepted Solutions (1)

raja_thangamani
Active Contributor
0 Kudos

Do the below changes:

<htmlb:inputField id = "date"
type = "DATE"
showHelp = "TRUE"
value = "<%= LV_DATE %>"
alignment = "CENTER"
/>

TO Get the value from FORM...<b>In OnInputprocessing:</b>

LV_DATE = request->get_form_field( 'date' ).

<i>*Reward each useful answer</i>

Raja T

Former Member
0 Kudos

Hi

But I am using view instead of page.Please give me some alternative solution.

Thank You.

Regards

Giri.

raja_thangamani
Active Contributor
0 Kudos

Then in DO_HANDLE_DATA, Place the below code:

data: FIELD TYPE IHTTPNVP.

  READ TABLE FORM_FIELDS WITH TABLE KEY
  NAME = 'date' INTO FIELD.
  LV_DATE = FIELD-VALUE.

<b>*Reward each useful answer</b>

Raja T

Former Member
0 Kudos

Hi

I wrote this code but how to call this method.I went into the debug mode it is not called automatically like DO_HANDLE_EVENT.Please tell me how to call it and get the data into our view.

Thank You.

Regards

Giri

raja_thangamani
Active Contributor
0 Kudos

you need to redefine this method..There is a button next to "Find Next", you need to click to define the method..

Raja T

Former Member
0 Kudos

Hi

I redefined it and I wrote the code.But it is not called in debugging.Please tell me how to call it.Is it called automatically(like DO_HANDLE_EVENT) or we have to call this method.

Regards

Giri.

raja_thangamani
Active Contributor
0 Kudos

Yes its called automatically...Check whether you have activated or not..

Raja T

Former Member
0 Kudos

Hi Raja

It is in active state.But in debug mode cursor is not going to this method.

Thank You.

Regards

Giri.

Former Member
0 Kudos

Hi

I went through the forum and found that DO_HANDLE_DATA event is called when we are calling the page or leaving the page.Here I want to explain you indetail about my application.I have a date input field whenever the user enter the date value and clicks on the button I have to display all prime rates for that particular date on the same screen.It means I have to display input field and output fields on the same screen.So I am not leaving the page.Please help me how in this case how to get the date value(in HTMLB or Javacsript) which is entered by user into the ABAP.

Thank You.

Regards

Giri

raja_thangamani
Active Contributor
0 Kudos

Irrespective of showing output on same page or different Page, the code I given, will work to get the date value.

Raja T

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi!

First you need a form tag around your coding. It could look like this:

<htmlb:form id = "form1">
</htmlb:form>

And you need to declare your variable "date" at page attributes of your BSP. Don't forget to set the "auto flag".

Hope this helps

Regards

Mark-André