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.

Similar Messages

  • 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

  • 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!!\")";

  • 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,

  • 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...

  • 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

  • Not able to call action method from the javascript

    I am using weblogic 10.3.2 portal.
    My requirement is to call a action in controller throuhg java script when user selects a different option in a dropdown.
    When try it we are not able to call it is returning null as a elementId. Below is the snippet of my code.
    <%@ page language="java" contentType="text/html;charset=UTF-8"%>
    <%@taglib uri="http://beehive.apache.org/netui/tags-html-1.0" prefix="netui"%>
    <%@taglib uri="http://beehive.apache.org/netui/tags-databinding-1.0" prefix="netui-data"%>
    <%@taglib uri="http://beehive.apache.org/netui/tags-template-1.0" prefix="netui-template"%>
    <netui:html generateIdScope="true">
    <head>
    <netui:base/>
    </head>
    <script language="JavaScript" type="text/JavaScript">
    function SelectBANSubmit(id)
         var scope = document.getElementById("scopeOneSpan");
         alert("value====arv" + scope);
         //var form = document.getElementById(lookupIdByTagId(form,scope));
         //alert("value====arv" + form);
         var knoVal = document.getElementById(lookupIdByTagId(id,scope));
    alert("in method" + knoVal);
         </script>
    <netui:body>
    <span id="scopeOneSpan">
         <netui:form action="getBillDetails" >
         <netui:select dataSource="actionForm.selection" tagId="arvind" optionsDataSource="${actionForm.resDTO.kno}" onChange="SelectBANSubmit('arvind')"/>
              </netui:form>
         </span>
         </netui:body>
    </netui:html>
    Any help would be appreciated.

    Below is my code
    JS Code
    function fundemo(id)
    alert("so currently we are in fundemo function ");
         var scope = document.getElementById("scopeOneSpan");
    alert(scope);
         var check = document.getElementById(lookupIdByTagId('textbox1',scope));
    alert("check id is " + check.id + " and its value is "+ check.value);
    JSP Code
    <%@ page language="java" contentType="text/html;charset=UTF-8"%>
    <%@taglib uri="http://beehive.apache.org/netui/tags-html-1.0" prefix="netui"%>
    <%@taglib uri="http://beehive.apache.org/netui/tags-databinding-1.0" prefix="netui-data"%>
    <%@taglib uri="http://beehive.apache.org/netui/tags-template-1.0" prefix="netui-template"%>
    <netui:html generateIdScope="true">
    <head>
    <netui:base/>
    </head>
    <script type="text/JavaScript" src="D:/testWS/testWebProject/WebContent/WEB-INF/js/test.js"> </script>
    <script language="JavaScript" type="text/JavaScript">
    function SelectBANSubmit(id)
    alert("In JS Method of the JSP File ");
    fundemo(id);
    </script>
    <netui:body>
    <span id="scopeOneSpan">
    <netui:form action="getBillDetails">
    <td >
    <netui:textBox dataSource="actionForm.selection" tagId="textbox1" />
    </td>
    <td>
    <netui:button type="button" onClick="javascript:fundemo('textbox1')" value="Test click"/>
    </td>
    </netui:form>
    </span>
    </netui:body>
    </netui:html>

  • Calling ABAP methods in Web-dynpro for ABAP

    Hi
    Can any one tell me how we can call any method which is defined in ABAP.
    eg.
    CALL METHOD ref_edit_chg->get_text_as_stream.
    This is the method i want to call in the first view.
    on the button action Process.
    Please reply at the earliest.
    Ragards,
    Rahul

    Hi Rahul,
    You can use WebServices, please have a look at below links,
    Re: The webdynpro/ABAP (WDA) calling RFC enabled FM of other ECC systems
    /people/thomas.jung3/blog/2004/11/15/bsp-150-a-developer146s-journal-part-xiii-developing-abap-webservices
    BSP a Developer's Journal Part XIV - Consuming WebServices with ABAP
    Regards,
    Nitin

  • Calling a method from a callback function under ARC

    Hi All
    I previously wrote some HIDManager software. The HIDManager references were done in a Objective C class so within this object you have the code:
        IOHIDManagerRegisterDeviceMatchingCallback( k8055HIDManager, k8055BoardWasAdded, (__bridge void*)self );
    Which registers with the HIDManager
    The Callback function which is outside the class was as follows:
    static void k8055BoardWasAdded(void* inContext, IOReturn inResult, void* inSender, IOHIDDeviceRef k8055HIDDevice)
        IOHIDDeviceOpen(k8055HIDDevice, kIOHIDOptionsTypeNone);
        CCVellemanK8055Driver * k8055 = (__bridge CCVellemanK8055Driver *)inContext;
        [k8055 setHardwareConnectionStatus : YES];
    Any how my problem is in converting the code to ARC as under OS X 10.9 SDK and 64bit I'm now getting a EXC_BAD_ACCESS (Code=EXC_I386_GPFLT) at this line
        CCVellemanK8055Driver * k8055 = (__bridge CCVellemanK8055Driver *)inContext;
    although removing the method
    [k8055 setHardwareConnectionStatus : YES];
    will alow it to build but then obviously the app won't work as required.
    Could someone suggest a ARC safe way of accessing the passed instance so I can again call methods on it.
    Cheers
    Steve

    Try using blocks instead. This is the callback I am using for libcurl.
    static size_t callback(
      void * contents, size_t size, size_t nmemb, void * context)
      size_t (^block)(void *, size_t) =
        (__bridge size_t (^)(void *, size_t))context;
      size_t result = block(contents, size * nmemb);
      return result;

  • Calling PL SQL in a Javascript function

     

    I've written a function :
    function removeCouvent (id)
    //var empSelectObj = document.getElementById(empSelect);
    var ajaxRequest = new
    htmldb_Get(null,&APP_ID.,'APPLICATION_PROCESS=Del_couvent',0);
    ajaxRequest.add('CodeCouv',id);
    ajaxResult = ajaxRequest.get();
    if(ajaxResult)
              alert("test1");
         else
              alert("test2");
    ajaxRequest = null;
    with the pl / sql app process (Del_couvent) :
    BEGIN
    DELETE FROM COUVENT WHERE CV_CODE= :CodeCouv;
    END;
    It does nothing, no deletes, any idea ?

  • Call Java Method From JavaScript Function

    hi everyone
    i need a help in calling Java method from a javaScript method
    ex:
    function confirmAddRecord() {
    cHours =document.getElementById('frmP:ChargeHours').value;
    cSTime =document.getElementById('frmP:ChargeStartTime').value;
    var answer = confirm("Are you sure you want to add Record?")
    if (answer){
    here i want to call the Java Method that is located in session bean that takes the upper params cHours & cSTime
    else{
    return false;
    i know i can do it as an action button but it is required me to be in that way can any one help plz
    Message was edited by:
    casper77

    That depends on the nature of your parameters. I guess you calculate the params on client and then want to submit them. In this case and if you don't want to use Ajax simple add some <input type="hidden"> elements (of course there correspondend components dependent of your framework) and store the params there. If the javascript isn't invoked by a button click, you can use a button nevertheless. Set visible="false" and call
    document.getElementById('client_id_of_my_hidden_button').click();
    (or maybe doClick() dependent on your framework).

  • How to call ABAP function module/ class method through web service?

    Hi Colleagues,
    I need to write an iphone version of current ABAP program. I want to call ABAP method and function module through my iphone so that I can re-use the ABAP APIs.So I choose web service. Can you give me any details information about how to do that?
    Thank you very much

    Hi,
    you need to create webservice out of FM. goto SE80 and follow the webservice creation wizard. Finally use webservice url for calling FM (remote enabled) from your iPhone.
    Regards,
    Gourav

  • Call Java method from JavaScript

    Hi,
    I have a Java class called abc.java and in that I have a method called assignValue(String value).
    I need to call this method, assignValue() , from JavaScript.
    Is there a way to call a Java method from JavaScript.
    Any help is greatly appreciated.
    Thanks.

    Yes I did, and I still don't get it, I have created a JSF web application, not an applet, as I posted earlier my code to executes sit's in a class file, not an applet file.
    My Page1.class file is as follows
    * Page1.java
    package a1;
    import ....
    public class Page1 extends AbstractPageBean {
        public void valset(int val) {
    }my jsp file "Page1.jsp" is as follows:
    <?xml version="1.0" encoding="UTF-8"?>
    <jsp:root version="1.2" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:ui="http://www.sun.com/web/ui">
        <jsp:directive.page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"/>
        <f:view>
            <ui:page binding="#{Page1.page1}" id="page1">
                <ui:html binding="#{Page1.html1}" id="html1">
                    <ui:head binding="#{Page1.head1}" id="head1">
                        <ui:link binding="#{Page1.link1}" id="link1" url="/resources/stylesheet.css"/>
                    </ui:head>
                    <ui:body binding="#{Page1.body1}" id="body1" style="-rave-layout: grid">
                        <ui:form binding="#{Page1.form1}" id="form1">
    <applet code="Page1.class" name="Page1" width="1100" height="600">
                    </applet>
                            <ui:button action="#{Page1.button1_action}" binding="#{Page1.button1}" id="button1" onMouseOver="form1.Page1.valset(1);"
                                style="left: 239px; top: 192px; position: absolute" text="Button"/>
    </ui:form>
                    </ui:body>
                </ui:html>
            </ui:page>
        </f:view>
    </jsp:root>All I get is a grey box the size of the applet window. Could you please let me know what I'm doing wrong?

  • How can I call a servlet from a javascript

    Hello
    I have a JSP page that has 2 aim : save and list. I want to use javascript like this to call my save and list methods :
    <SCRIPT language="JavaScript">
    function savedata(){
    document.kaydetsorgula.action = "hatBilgisiKaydetKontroller.java";
    document.kaydetsorgula.submit();     
    function listdata(){
    document.kaydetsorgula.action = "hatbilGoruntulemeKontroller.java";
    document.kaydetsorgula.submit();     
    </SCRIPT>
    I use this js in my JSP, hatBilgisiKaydetKontroller.java and hatbilGoruntulemeKontroller.java are my servlets names.In servlets I call the methods of sessions.
    Also in my JSP I use
    <tr>
    <td colspan=9 align=center>
    <input type="submit" value="Kaydet" >
    <input type="submit" value="Sorgu">
    </td>
    </tr>
    code to call the js.
    But my code does not work?
    Does anyone have any idea?
    Thanks
    ANIL

    Thanks.....
    I could manage to work it by using <input type="submit" value="Sorgu" onClick="sorgula()"> ...
    And know I have another problem...
    I have a listing page.This pages shows data from a database table and in this table there are 100 rows but I want to show data 10 by 10.I mean when I click on next link I want to see the other 10...
    My JSP code is like this :
    <%@ page contentType="text/html;charset=windows-1254"%>
    <%@ page import="java.util.*"%>
    <%@ page import="java.lang.*"%>
    <% Context context = new InitialContext();
    DataSource ds = (DataSource) context.lookup("jdbc/DUKSDS");
    Connection conn = ds.getConnection();
    Statement stmt = conn.createStatement();
    stmt.executeQuery("select rownum,hatKodu,hatAdi from HATBIL where rownum < 11 order by hatkodu");
    String vhatKodu = request.getParameter("hatKodu");
    ResultSet rs = stmt.getResultSet();
    ResultSetMetaData rsmd = rs.getMetaData();
    %>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1254">
    </head>
    <SCRIPT language="JavaScript">
    function sonrakikayitlar(){
    document.listelemeekrani.action = "listeleme.jsp";
    document.listelemeekrani.submit();     
    </SCRIPT>
    <body>
    <img src="file:/C:/DUKS/ERD Logo.gif" width="100" height="100">
    <H2><center>DEMIR URETIM KONTROL SISTEMI</center> </H2>
    <br>
    <H3><center>HAT BILGISI LISTELEME EKRANI</center> </H3>
    <center><input type="hidden" name="hiddenField">
    <form name="listelemeekrani" method="get">
    <table class="clsScroller" cellspacing="2" cellpadding="3">
    <tr>
    <td>Previous</td>
    <td align="center">
    <select>
    <option selected value="1">1-2 of 2</option>
    </select>
    </td>
    <td>Next</td>
    </tr>
    </table>
    <table border="1">
    <tr>
    <td align="center" colspan="5" >HAT KODU</td>
    <td align="center" colspan="5">HAT ADI</td>
    </tr>
    <%
    while (rs.next()) {
    %>
    <tr>
    <td bgcolor="pink" colspan="5"><%=rs.getString("hatKodu")%></td>
    <td bgcolor="pink" colspan="5"><%=rs.getString("hatAdi")%></td>
    <!-- <td bgcolor="pink" colspan="5"><%=vhatKodu%></td>-->
    </tr>
    <%
    rs.close();%>
    </table>
    <% System.out.println(rsmd.getColumnCount()); %></p>
    BILGI GIRIS EKRANI
    </table>
    </form>
    </body>
    </html>
    How?
    Thanks
    ANIL

  • ADF: Can i call javascript function from java clsss method in ADF?

    Hi,
    I want to call javascript function in Java class method, is it possible in ADF? , if yes then how?
    or I need to use Java 6 feature directely?
    Regards,
    Deepak

    private void writeJavaScriptToClient(String script)
    FacesContext fctx = FacesContext.getCurrentInstance();
    ExtendedRenderKitService erks = Service.getRenderKitService(fctx, ExtendedRenderKitService.class);
    erks.addScript(fctx, script);
    }usage
    StringBuilder script = new StringBuilder();
    script.append( "var popup = AdfPage.PAGE.findComponentByAbsoluteId('p1');");
    script.append("if(popup != null){"); script.append("popup.show();"); script.append("}");
    writeJavaScriptToClient(script.toString());Timo

Maybe you are looking for

  • Error while creating first database instance

    Hi, after installing MaxDB i got the following message:  "ERROR in 'C:\Program Files\sdb\programs\pgm\dbmcli -R "C:\Program Files\sdb\MAXDB1"  -R "C:\Program Files\sdb\MAXDB1" db_create  -a MAXDB1 DBM,*** .ing!1' ERR -24996,ERR_PARAM: wrong parameter

  • Dropped sequences in oracle 10g

    Hi All, Can we get back the dropped sequences in oracle 10g? Command? Thanks. Edited by: user545846 on Apr 9, 2009 7:32 AM

  • Dim Build Error

    There isn't any keywords or reserved words for dimensions, are there? I'm building dimensions from a sql call, it creates all of them except for "OTHER" which gives the following error: \\Record #10 - Incorrect Dimension (Region) for Member OTHER (33

  • What is the simplest way to export Address Book into a spreadsheet (Numbers) and get all the information including physical address?

    Can anyone help with this?  I've exported the address book, but all the information does not appear.  I've expanded out the columns but still don't get the home address. Also, formatting is an issue with phone numbers.  Not all phone numbers were ent

  • Satellite U920T - volume keys are not working

    I have the Toshiba u920t factory standard laptop and after a reboot the volume keys (F9 and F10) do not work. I need to run the Toshiba Function Keys software and select Repair which fixes the problem until the next reboot. How do I fix this annoying