Calling a abap method in a javascript

Hi all,
I've been browsing a bit through this forum, but there has no answer been completely covering my problem...
I would like to call an abap method in the javascript in order to check some values...
This is what I have done:
<script language="JavaScript" defer="defer">
    function do_checks(htmlbevent)
        try
              var doubles = "<%= controller->check_doubles( )%>";
              if(doubles == true){
                  var Check = confirm("Test??");
                  if(Check == false){
                    htmlbevent.cancelSubmit = true;
        catch(e)
  </script>
The method has the following code:
mehod check_doubles. " returning parameter = rv_double of type flag
  rv_double = abap_true.
endmethod.
the button is defined like this...
<htmlb:button
                          id      = "Save"
                          onClick = "save"
                          onClientClick = "do_checks(htmlbevent);"
                          text    = "<%= otr(crm_ic_appl/Save) %>"
                          />
The funny thing is, that the controller->check_doubles( ). is already processed at load of the page (although there is no on_load used somewhere...
If I leave out the " if(doubles == true){ } ", the javascript reacts as foreseen..., but when I keep the " if(doubles == true){ } ", the javascript doesn't go through the method anymore...
Can anybody help me out here???
Thanks!!
Micha

Hi,
You can call them FM inside the javascript something like below...
<script language="JavaScript">
function yourFM()
<%
   DATA: guid TYPE GUID_32.
   CALL FUNCTION 'GUID_CREATE' IMPORTING ev_guid_32 = guid.
%>
</script>
<b>To call the class & method:</b>
<script language="JavaScript">
    function yourFM()
      <% CLASS cl_bsp_login_application DEFINITION LOAD. %>
      var EXIT_URL  = "<%= CL_BSP_LOGIN_APPLICATION=>GET_SESSIONEXIT_URL( page = page ) %>";
  </script>
But i am not clear what do you want to achieve. I didnt understand what you are trying to do with you code. Could you give more detail?
<i>* Reward each useful answer</i>
Raja T
Message was edited by:
        Raja Thangamani

Similar Messages

  • Call abap method in a javaScript Function

    Hi all,
    I want call a abap method via a javaScript function in a view of a bsp application.
    Does someone know how it works?
    regards Alex

    Hi,
    You can either change the location of the page to a target URL usinng "document.location.href = 'targeturl'. So targeturl is the fully qualified url necessary to call the method.
    Or you can take a look at XMLHttpRequest object (http://www.w3.org/TR/XMLHttpRequest/) which can create requests to a given URL. You can parse and use the data returned by the target url.
    Hope it helps,
    Regards.
    Ozcan.

  • Can call an applet method directly in javascript?

    I want to call an applet method directly in javascript
    as the following format:
    function test()
    ret_val = document.myapplet.mymethod();
    myapplet is the applet name,mymethod is a
    public method in applet and it returns a string
    result,can that works?
    //thx

    Hi , i know that that is possible, i dont have the example right here just wait until tomorrow at the morning and i sent it to you , please send me a email to remaind me the code
    [email protected]

  • How can I call a servlet method from a javascript function

    I want to call l a servlet method from a javascript function.
    Does any one have an example of code.
    Thinks in advance

    Actually, as long as the servlet returns valid javascript, you can indeed "call it" from the client. It will initiate a request and return the result to the browser.
    This example uses Perl, but it could be easily modified to go to a servlet instead.
    Note that it is only supported in DOM browsers (IE6+/NN6+/etc)
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
    <html>
    <head>
    <title> Test server-side JS </title>
    </head>
    <body>
    <script type="text/javascript">
    function checkIt(variable, value)
    var newScript = "cgi-bin/validateJS.cgi?"+variable+"="+value;
    var body = document.getElementsByTagName('body').item(0)
    var scriptTag = document.getElementById('loadScript');
    if(scriptTag) body.removeChild(scriptTag);
    script = document.createElement('script');
    script.src = newScript;
         script.type = 'text/javascript';
         script.id = 'loadScript';
         body.appendChild(script)
    </script>
    <p>Test.</p>
    <form id="f1" action="">
    <input type="text" name="t1" id="t1" onChange="checkIt(this.name, this.value)">
    </body>
    </html>
    validateJS.cgi
    #!/opt/x11r6/bin/perl
    use CGI qw(:all);
    my @valArray = split(/=/,$ENV{QUERY_STRING});
    print "Content-type: text/javascript\n\n";
    # myPass is the password
    $myPass = "foobar";
    if ("$valArray[1]" eq "$myPass")
    print "alert(\"Success!!\")";
    else
    print "alert(\"Failure!!\")";

  • How to call a bean method through a javascript function

    I dont discover any problems calling the bean method in this maner:
    <%= helpdesk.data() %>
    But, when I use a Button Onclick= to call the script function and which then is going call my bean method
    an error on the page is reported!
    I have include som code which gives you the idea of what Iam searching for. And is it possible to call
    the bean method without doing from a new jsp page?
    If you have any suggestions to why it doesnt work, please let me know.
    I use Apache Tomcat 4.0
    Best regards Micah.
    <jsp:useBean id='helpdesk' scope='application'
    class='helpdesk.testdb'/>
    <html>
    <head>
    <script language="javascript">
    function broadcast()
    helpdesk.data();
    </script>
    </head>
    <body>
    <input type="button" value="Broadcast" onclick= broadcast()>
    </body>
    </html>

    It's actually quite simple:
    Beans run server-side
    Javascript runs client-side
    So you will never be able to run server-side-code thru the client...

  • How to call a bean method through javascript?

    Hi,
    i want to call a bean method using the javascript.
    thansk in advance.

    hi
    i want to call a backing bean method thought javscript on the button click.
    i am inplementing addition of textbox at runtime.i wrote method and i am calling that on the button click.but the textbox is not created.
    the code is bleow
    public String doAction() {
         tryStuff1();
    return "samplejsf";
    public void tryStuff1()
    System.out.println("Enter the trystuff method");
         FacesContext facesContext = FacesContext.getCurrentInstance();
    UIViewRoot uIViewRoot = facesContext.getViewRoot();
    Application application = facesContext.getApplication();
    UIComponent formComp=uIViewRoot.findComponent("subbody:form1");
    HtmlPanelGrid grid= new HtmlPanelGrid();
    grid.setId("panelgrid2");
    grid.setColumns(2);
    grid.setBorder(2);
    //UIComponent panelGridComp=formComp.findComponent("subbody:panelgrid1");
    //UIComponent panelGroupComp=panelGridComp.findComponent("panelgroup2");
         HtmlOutputText output = new HtmlOutputText();
    output.setValue("dynamic jsf text2");
    System.out.println("hello output text2");
    output.setRendered(true);
    grid.getChildren().add(output);
    HtmlInputText input = new HtmlInputText();
    input.setSize(40);
    input.setValueBinding("value", (ValueBinding) application.createValueBinding("#{sample.text2}"));
    input.setRendered(true);
    grid.getChildren().add(input);
    System.out.println("hello output text1");
    grid.setRendered(true);
    formComp.getChildren().add(grid);
    System.out.println("hello output text3:");
    formComp.getRendersChildren();
    formComp.setRendered(true);
    public boolean getRendersChildren() {
         return true;
    jsp code is
    <h:form id="form1">
    <h:panelGrid columns="2" binding="#{sample.formElements}">
    </h:panelGrid>
    <h:panelGrid id="panelgrid1" columns="1">
    <h:panelGroup id="panelgroup1">
    <h:outputText value="hardcoded jsf text1"/>
    <h:inputText value="#{sample.text1}"/>
    </h:panelGroup>
    </h:panelGrid>
    <h:commandButton id="add" action="#{sample.doAction}" value="add" type="SUBMIT"/>
    </h:form>
    when i click on the button its going into the method and diaplying s.o.p but the text box is not updated to the page.
    why is it so.
    i thought there may be a problem in calling the method directly thru button. i want to try thru javascript calling the bean method.
    why is the page not updated.
    can u help me out
    thanks in advance
    sree

  • Call to Applet Method from JavaScript Failed.

    I Am calling a method from a javascript function from within a web page.
    The page is loaded into a frame. The parent window of the frame has stored a reference to the applet which defines the methods. Note I am treating the reterence to the applet as a global variable. So that I can reference it methods as I navigate from one page to another.
    I have JavaScript objects defined, and I am passing them as parameters to the applet's methods. In java, the JavaScript objects are refererenced as JSObject. When I call a java method passing a JavaScript
    Object I get the following exception. Note Iam using j2sdk1.4.2_01 on a Windows 2000 Professional System. This problem start occurring after the recent Microsoft Worm/Virus a fix was loaded on my system which resulted in the following bug. Could someone please help me.
    java.lang.NullPointerException
         at sun.plugin.javascript.ocx.JSObject.setIExplorerAppletContext(Unknown Source)
         at sun.plugin.com.DispatchImpl.convertParams(Unknown Source)
         at sun.plugin.com.DispatchImpl.invokeImpl(Unknown Source)
         at sun.plugin.com.DispatchImpl$2.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         at sun.plugin.com.DispatchImpl.invoke(Unknown Source)
    java.lang.Exception: java.lang.NullPointerException
         at sun.plugin.com.DispatchImpl.invokeImpl(Unknown Source)
         at sun.plugin.com.DispatchImpl$2.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         at sun.plugin.com.DispatchImpl.invoke(Unknown Source)

    A little code snippet would help. I use JSObjects from Java 1.4 no problem and do have all the latest updates. I also have JavaScript calling Java code as well - also with no problem.

  • Starting new SAP LUW inside ABAP method

    I am calling a ABAP method and in that I want to start a new SAP LUW and do commit when leaving the method.
    The requirement is that all update function modules called inside the method should only be committed and no other prior update FMu2019s(before calling the method) should not be committed.
    Any idea if itu2019s possible to do that in ABAP OO and how do we do it.
    Thanks & Regards,
    Anand.

    HI ,
    Thanks for the quick replies. I tried using SET UPDATE TASK LOCAL but it was also committing all the prior update FM's before calling this method.
    I also tried using the RFM -    CALL FUNCTION 'ABC' IN BACKGROUND TASK   DESTINATION 'NONE' . and then
    COMMIT WORK AND WAIT.
    Now when i do commit work it commits all the previous update tasks also.
    And if i do not call COMMIT WORK right after the call to RFM, then the object that i am trying to create inside the RFM will not be committed.And then if i proceede some validations will fail as the objects were not created.
    Is there a way to commit immediately when the RFM is called without commiting the calling transaction from where this RFM is called.
    Any examples would be highly appreciated ..
    Regards,
    Anand.
    Edited by: Anand Ajitsaria on Feb 4, 2011 9:54 AM

  • SOFM: Dsiplay method is not working when called from ABAP Webdynpro

    Hi All,
    I want to open an attachment from ABAP Webdynpro.
    I have approached in this fashion:
    1) Get the attachments as SOFM object key
    2) On Click of a link on Webdynpro, I am calling a function module within which I am creating an instance of the SOFM object
    3) Then I am calling the DISPLAY method
    It is not opening.
    But, if it opens when I driectly execute the function module. It open when I directly test the business object.
    Any Idea ?
    Thanks & Regards,
    Deb

    Display Method uses the Dialogue Module, You should not access such methods in web dynpro which are SAPGUI specific.
    Web Dynpro Applications are run in Browser environment which cannot understand Dialog, it can understand only HTML.
    Read the attachments and get the content and use FileDownload UI element to show it to user.
    Abhi

  • How to call a bean method from javascript event

    Hi,
    I could not find material on how to call a bean method from javascript, any help would be appreciated.
    Ralph

    Hi,
    Basically, I would like to call a method that I have written in the page java bean, or in the session bean, or application bean, or an external bean, from the javascript events (mouseover, on click, etc...) of a ui jsf component. I.e., I would like to take an action when a user clicks in a column in a datatable.
    Cheers,
    Ralph

  • Calling an interface METHOD of another abap web dynpro application

    Hi Experts,
    Can u plz tell how we can Call an interface METHOD of another abap web dynpro application in main WD Component.
    Thanks
    Mahesh

    Hi ,,
       Example ALV interface method calling   GET_MODEL interface method
       View attribute   declaration   :    M_WD_ALV  type      IWCI_SALV_WD_TABLE
         DATA lo_INTERFACECONTROLLER TYPE REF TO IWCI_SALV_WD_TABLE .
          wd_this->M_WD_ALV =   wd_this->wd_cpifc_alv( ).   "ALV is the usage name
         DATA lv_value TYPE ref to cl_salv_wd_config_table.
          lv_value = wd_this->M_WD_ALV->get_model(  ).   " interface method calling in ALV component usage.....
    Regards,
    Devi

  • Calling abap method in xslt mapping?

    Hi
    I need to call abap method in my xslt mapping , i tried with
    <sap:external-call >and <sap:external-function> .
    But it is giving short dump error.
    Can anybody give me proper syntax..
    thanks
    Prasad

    Hello,
    Please see the code below.
    This is how u call
      <sap:external-function class="ZTEST_CLASS" kind="class" method="GETRECORDCOUNT" name="ns0:GetRecordCount">
        <sap:argument param="XXXX" type="string"/>
        <sap:argument param="YYYY" type="string"/>
        <sap:result param="ZZZZ" type="string"/>
      </sap:external-function>
      <xsl:template match="/">
        <xsl:param name="Counter">
    *And this is how u call below...
    <xsl:value-of select="ns0:GetRecordCount(A,B)"/>
    </xsl:template>
    </xsl:transform>
    Regards,

  • Call RFC (Abap) with Javascript

    Hi all,
    i'm new to Javascript.
    Now i have to write a small piece of code in Javascript that calls an Abap RFC.
    Does anyone have an example for something like that ?
    Greetings
    Henning

    Hi Henning,
    Chk these links Hope this will help you out...
    http://publib.boulder.ibm.com/infocenter/tivihelp/v2r1/index.jsp?topic=/com.ibm.IBMDI.doc_6.1/referenceguide120.htm
    Please reward points if you find this as a right solution
    Regards,
    Harini

  • Is it possible to call a class method using pattern in ABAP editor.

    Hi,
         Is it possible to call a class method using pattern in ABAP editor.
    Thank U for Ur time.
    Cheers,
    Sam

    Yes,
    Click patterns.
    Then choose Abap objects patterns.
    Click on the Tick
    It will give a new screen
    Here Give the name of the class first.
    Then the object (instance of the calss)
    And finally the method ..
    it will give you the pattern
    Hope this helps.

  • Calling ABAP method from JCo

    Hi All,
    I need to invoke a static method of an ABAP class from JCo. Is this possible? I am new to JCo. Any help in this regard is highly appreciated.
    Thanks,
    Praneeth

    Hello Praneeth,
    i'm not sure about calling ABAP class method from JCo directly, but there is a possibility to call function module from SAP R3. And the shortest way to do so is described in Re: Accessing SAP backend from j2ee without entrprise portal thread, answered by me.
    I guess there is no problem to call an class method from an function module.
    Please consider rewording points if helpfull.
    regards,
    mz

Maybe you are looking for

  • Business Intelligence and report Link

     Business Intelligence and report Link is not visible in one of the User Profile with all Required rights,Its visible for other but not for that individual with same rights and permissions In pWA 2010.

  • Data Services XI Management Console

    Does anyone know what is the purpose of the Repositories in Data Services XI Management Console ->Adminstrator ->Management ->Repositories? Does it has anything to do with SAP integration? i.e. If I want to connect into SAP, do I need to add teh Repo

  • Displaying a matrix onto screen

    hi guys, i'm trying to make a game. i'm going to load a two dimensional array with images and then display the whole matrix onto the screen and then add stuff to it like mouselistener. static Object image[][] = new Object[300][300]; i only have a fra

  • Download Lion without native mac app store.

    Hey Guys, I've got a 2011 mac mini server, it's currently got Windows server 2008 R2 installed on it. I'd like to run OSX Lion Server as a virtual machine. But I need a .iso (preferably) to be used to install the operating system. Because I didn't re

  • 'Preferences' tabs for Officejet Pro 8500 A909g

    I'd like the 'Features' tab to be the one that opens up automatically when I invoke 'Preferences' in the print window.  It always comes up 'Advanced' and I begrudge the time to click 'Features' for every job I print.