Javascript in abap

hi,
I'm trying to dynamically build a condition and then do an IF cond.
Unfortunately, dynamics are not supported very well in ABAP. Therefore, it was suggested to me by a gentleman named Christian to use javascript to do this.
ex.
//dynamically constructed cond
if (cond).
  write:/ 'success'.
else.
  write:/ 'F'.
endif.
I have already built the condition dynamically in ABAP, so I do not need to construct it in JAVA.
I tried several ABAP macros and variations of syntax- unsuccessfully.
Now I plan on creating a javascript within my ABAP. I'm using the following as documentation to lead me in the right direction. (https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/documents/a1-8-4/abap faqs.faq#q-17).
It seems like the  <b>CL_JAVA_SCRIPT </b> javascript class is not available on 46. is this true?
Is there another javascript class on the 46 system I can refer to?
Also, that link refers me to the program DEMO_JAVA_SCRIPT_MINI_EDITOR. How do I access this?
Please help if you can,
Natasha

Hi  Marcin,
Thankyou for your quick reply.
It is server side scripting only. but i have already chekced the link which u sent me. i did not find anything realted ... we are not able to debug the issue?
            This is the place where it is throwing the error:
       var lv_pct=`FREM-TBR_PCT[j]`
                   if (parseInt("`lv_pct`") == `i`)
is the syntax of the code is correct?
Do you want me to send the whole code to you?
Also please tell me if there any way to debug the javascripts  for this IAC applications.
Thanks & Regards,
Kavitha.

Similar Messages

  • Calling Javascript from ABAP webdynpro application

    Hai All,
    I want to call a Javascript from ABAP-Webdynpro application. If anyone has done this. Please let me know.
    Thanks & Regards,
    H.K.Hayath Basha.

    go to window
    create suspend outbound plug and resume inbound type
    when create an outbound plug of Suspend type a parameter Url is automatically created,
    fire the outbuond plug with the Url to a BSP page where you have JavaScript.
    and fromt he BSP navigate back to WDA again which you can do using by reading the url parameter sap-wd-resumeurl, which contains the WDA URL
    Abhi

  • Javascript in ABAP is throwing error

    Hi all,
    We are having some IAC applications, the older version is ECC 4.6 . All the applications are working fine there.
    Now that we have migrated from ECC 4.6C to  ECC 6.0, we have just copied all the IAC applications to the new system.
    When tested in the new system. one of the applcitions is throwing a Javascript error.(i.e., the ABAP dump is pointing to the Javascript ParseInt method.)
    The error is "0.00  could not be converted into numerical value"."ITS_EXPRESSION_NOT_NUM".
    My question is:
    Is there any possibility that ECC 6.0 is not recognizing the java script of 4.6C(specially the ParseInt functionality).
    is there any help documents which give us code samples for syntax to be followed when writing the java script in ABAP.
    Any clue to resolve the error would be greatly appreciated.
    Thanks & Regards,
    Kavitha

    Hi  Marcin,
    Thankyou for your quick reply.
    It is server side scripting only. but i have already chekced the link which u sent me. i did not find anything realted ... we are not able to debug the issue?
                This is the place where it is throwing the error:
           var lv_pct=`FREM-TBR_PCT[j]`
                       if (parseInt("`lv_pct`") == `i`)
    is the syntax of the code is correct?
    Do you want me to send the whole code to you?
    Also please tell me if there any way to debug the javascripts  for this IAC applications.
    Thanks & Regards,
    Kavitha.

  • JavaScript in ABAP Program

    hi folk,
    I have some Javascript codes in my abap program as you can see below.
    It does simple not work for me.
    But in the debugger mode as I can see the message it says something about:
    " ReferenceError: ActiveX Object is not defined "
    It has something with Acticve XObject. What am I missing here? Do I need install any additional component?
        data JS_CODE type STRING.
        data RETURN_JS_VAR type STRING.
        data JS_PROC type ref to CL_JAVA_SCRIPT.
        JS_PROC = CL_JAVA_SCRIPT=>CREATE( ).
        concatenate
          'var filePath = "C:
    Windows
    notepad.exe";            '
          'set fso = CreateObject("Scripting.FileSystemObject");'
          'var string = fso.GetFileVersion(filePath);                  '
        'function Set_String()                  '
          '  { string += ", this is a Blog!"; '
          'Set_String();                          '
          'string;                                '
        into JS_CODE separated by CL_ABAP_CHAR_UTILITIES=>CR_LF.
        JS_PROC->COMPILE( SCRIPT_NAME = 'GETVERSION.JS'
                             SCRIPT      = JS_CODE ).
        RETURN_JS_VAR = JS_PROC->EXECUTE( 'GETVERSION.JS' ).
        write RETURN_JS_VAR.

    hi Tomek,
    You have absolutely right regarding the security and the problem by using of Active X Object.
    My goal was to get the file version from the user's PC and at the beginning I used the method
    CL_GUI_FRONTEND_SERVICES->FILE_GET_VERSION but it doesn't work out. So I tried to get the version via Active X Object and it doesn't work either.
    Now I've found this function GUI_GET_FILE_INFO and it works perfectly even though it tells me that the function is absolete and suggest  to use the method FILE_GET_VERSION instead.
    Best regards
    LNN

  • Sha256 - how to do this javascript in ABAP. Is it possible?

    Hello,
    I would like to use the amazon product advertising api. For this my requests need to be "signed". In an example I found the following javaScript for signing requests:
         function sign(secret, message) {
           var messageBytes = str2binb(message);
           var secretBytes = str2binb(secret);
           if (secretBytes.length > 16) {
               secretBytes = core_sha256(secretBytes, secret.length * chrsz);
           var ipad = Array(16), opad = Array(16);
           for (var i = 0; i < 16; i++) {
               ipad<i> = secretBytes<i> ^ 0x36363636;
               opad<i> = secretBytes<i> ^ 0x5C5C5C5C;
           var imsg = ipad.concat(messageBytes);
           var ihash = core_sha256(imsg, 512 + message.length * chrsz);
           var omsg = opad.concat(ihash);
           var ohash = core_sha256(omsg, 512 + 256);
           var b64hash = binb2b64(ohash);
           var urlhash = encodeURIComponent(b64hash);
           return urlhash;
    Could someone please tell me if this is also possible with ABAP and if yes, how?
    Thanks a lot in advance. Unfortunatley I don't get it done by myself.
    bye, Vanessa

    Hi
    You can code JavaScript directly in your ABAP code.
    data: l_JS_PROCESSOR type ref to CL_JAVA_SCRIPT,
          l_RETURN_VALUE type STRING,
          l_SOURCE       type STRING.
    Create a new javaScript
    l_JS_PROCESSOR = CL_JAVA_SCRIPT=>CREATE( ).
    Your Javascript code
    concatenate
       'var l_source = "Hello,"; '
       'l_source += " World"; '
        into l_SOURCE separated by CL_ABAP_CHAR_UTILITIES=>CR_LF.
    compile the code
    l_JS_PROCESSOR->COMPILE( SCRIPT_NAME = 'MYSCRIPT.JS' SCRIPT = L_SOURCE ).
    syntax errors ?
    if l_JS_PROCESSOR->LAST_CONDITION_CODE <> 0.
       write: / 'Error', l_JS_PROCESSOR->LAST_ERROR_MESSAGE.
       exit.
    else.
       write / 'compiled'.
    endif.
    execute
    l_JS_PROCESSOR->EXECUTE( SCRIPT_NAME = 'MYSCRIPT.JS' ).
    Errors ?
    if l_JS_PROCESSOR->LAST_CONDITION_CODE <> 0.
       write: / 'Error in execution',l_JS_PROCESSOR->LAST_ERROR_MESSAGE.
       exit.
    else.
       write / 'Script was executed'.
    endif.
    return the output variable
    l_RETURN_VALUE = l_JS_PROCESSOR->EVALUATE( JAVA_SCRIPT = 'l_source;' ).
    write : / l_RETURN_VALUE.

  • Find Hidden Characters-in downloaded file

    All,
    I have a file interface that downloading file to SANS server using open dataset. But recently we are getting some hidden characters in the file. These are getting from a long text.
    Now my requirement is to find these hidden characters and display in the screen and user can correct then go for download.
    Currently i am using Notepad++ or using this link for finding the hidden characters
    http://string.online-toolz.com/tools/string-functions.php
    Now user wanted to use the same functionality with in SAP using ABAP.
    Any input on this appreciated.

    Similar functionality can be achieved by JavaScript. You can pass the entire Text and create your function in JS to find out the Hidden Characters. If you are successful finding the JS which can do this job for you, you can use [JS Engine|http://help.sap.com/saphelp_nw04/helpdata/en/49/a8e3c8d59811d4b2e90050dadfb92b/frameset.htm] available in ABAP.
    Refer to [ABAP & JavaScript|http://help-abap.zevolving.com/2011/10/javascript-in-abap/] to see the simple JS usage.
    Regards,
    Naimesh Patel

  • Dynamic title Display in WAD

    Hi,
        I would like to change the Title in the chart dynamically...for example..
    Value is
    <param name="TITLE" value="Forecast Report xxx xx xxxx"/>
    During run time..using the javascript or abap code  we need to pass current date to the tile..so title will display......."Forecast Report july 9,2007"
    Any Ideas?
    thanks

    Create a text variable with cusotmer exit as processing type.
    data h_datum LIKE sy-datum.
      WHEN 'test1'(customer exit text variable).
        CLEAR h_datum.
        h_datum = sy-datum.
        CLEAR l_s_range.
        l_s_range-low  = h_datum.
        l_s_range-sign = 'I'.
        l_s_range-opt  = 'EQ'.
        APPEND l_s_range TO e_t_range.
        EXIT.
    But i am not sure about the way to place this variable in the chart title.
    hope it is clear
    assign points if useful

  • Enhancing standard BSP application by using WebDynpro components

    Hi all,
    We have standard BSP application delivered by SAP; we need to enhance the functionality and some new views to meet our requirement. We have planned to develop new things in WebDynpro ABAP and attach those to BSP.
    Is it good practice to use WebDynpro component instead customizing BSP application?
    If any body has fair knowledge on BSP and WDA, please let me know.
    Regards,
    Rajesh

    hi
    good
    BSP->
    It is a set of pages that represent a user interface (layout and page flow definition). The layout part of a page normally contains ABAP or JavaScript code which is inserted into the HTML structure. They can contain server-side scripting code in either JavaScript or ABAP. BSP applications use all the conventional ABAP technologies, such as Open SQL and internal tables, allowing developers to create Web pages quickly. This enables existing SAP logic, data structures, and interfaces to be directly used in Web applications.
    http://www.thespot4sap.com/Articles/SAP_WAS_BSP_Apps.asp
    WDA->
    Web Dynpro for ABAP or Web Dynpro for ABAP (WD4A, WDA) is the SAP standard UI technology for developing Web applications in the ABAP environment. It consists of a runtime environment and a graphical development environment with special Web Dynpro tools that are integrated in the ABAP Workbench (SE80).
    Web Dynpro offers the following advantages for application developers:
    &#9679;      The use of declarative and graphical tools significantly reduces the implementation effort
    &#9679;      Web Dynpro supports a structured design process
    &#9679;      Strict separation between layout and business data
    &#9679;      Reuse and better maintainability by using components
    &#9679;      The layout and navigation is easily changed using the Web Dynpro tools
    &#9679;      Stateful applications are supported – that is, if the page is changed and the required data remains intact so that you can access it at any time throughout the entire application context.
    Note that stateless applications are not possible.
    &#9679;      Automatic data transport using data binding
    &#9679;      Automatic input check
    &#9679;      Automatic operation of the Web Dynpro application using the keyboard
    &#9679;      User interface accessibility is supported
    &#9679;      Full integration in the reliable ABAP development environment
    http://help.sap.com/saphelp_nw04s/helpdata/en/77/3545415ea6f523e10000000a155106/content.htm
    thanks
    mrutyun^

  • Neptune for UI development Pros and Cons

    Hi ,
    we are evaluating neptune for UI development for what are the pros and cons of using neptune.
    i see only that webdynpro abap developer can be easily moved to neptune , some javascript knowledge is still required.
    some question
    1) can neptune make calls to odata services ? do that requires code in javascript or ABAP
    2) any accelerators provided by neptune  like for workflow scenarios , list and details .
    3) can sap standard fiori apps extensibility  or modification is possible through neptune
    4) security if its accessing business functionality directly
    regards
    Yashpal

    Hi Yashpal,
    I will give you my view, but as Robbe says I work for the company and other SAP developers like DJ Adams has other development tool preferences than me ( I call his Sublime Text development spaghetti coding and he sees Neptune as a crutch that restricts a developer's freedom but this is just a friendly point-of-view discussion and I have promised him a beer in Walldorf next time our paths cross there)
    So the important message is that SAP has opened up their platform for different development tools and it is now a choice for the individual developer or SAP customer. This is a fantastic move by SAP and I think a bit overlooked by the community, Look at the new Xamarin partnership as an example (and yes they are a competitor, but I did mention them )
    Now the pros of Neptune are in my opinion:
    ABAP developer friendly development (removed 90% of JavaScripting needed)
    Connected to the SAP transport System (Software Logistics as is)
    Drag Drop designer that gives structured code (easy for a new developer to take over code, compared to the spaghetti provided by DJ <-  I'll need to buy a few extra beers for that remark)
    Native json communication provided by the Neptune Server (you can argue all you want about Odata, our solution is more flexible gives incredible performance and superb and easy to use offline capabilities)
    Integration with Adobe build, use an SAP program to generate hybrid apps  (The average ABAP developer does not install cordova and build hybrid apps - with Neptune he/she does)
    Integration with SMP. Automatic connection with the REST API's of SMP both on-premise and in the Cloud
    Reduced time to market. One of the largest SAP implementation partners in the Nordics stated that Neptune reduced development time by 80%
    Free templates (Advanced templates such as fully functional PM, HCM, SD templates are available Experience | Neptune Software  <- sorry for the marketing but you did ask)
    UI5, all of the other third-party tools (Not SAP tools like App Builder, Eclipse etc) uses non UI5 frameworks. I personally believe that SAPUI5 (UI5) is the future of SAP UX and thus it only makes sense to keep a common and future-proof framework.
    Network crunching. We optimize all networking. Which makes sense for mobility.
    no extra infrastructure needed - it is a certified add-on and takes 15 mins to install.
    Works with most versions of SAP. We even have alot of customers using 4.7 (we need the ICF so nothing lower). This is something the community often forgets. Yes it is cool to play with the latest Netweaver release, but do our customers have that installed?
    Cons (woot!)
    Cost, even if Neptune is very affordable it still requires license for productive usage (free for developers though - and hey we need to live as well ) So custom coding  is cheaper in respect to license (but not in TCO in my opinion)
    Generated code, even if we have added as much freedom to code custom JavaScript as possible there will always be restrictions in generated code compared to notepad. (But I haven't met an issue that couldn't be solved by custom coding in the Neptune Application Designer yet)
    Other backend systems. Neptune is based on ABAP and as such it obviosly works best with an ABAP backend.
    .... (Add stuff from other non Neptune ppl )
    Regarding your questions:
    1. Yes you can use Odata, best way is to consume it on the ABAP level, but you can of course consume it through JavaScript as well (Not recomended by me)
    2. Yes see above (free templates and also premium templates by our partners)
    3. No you can't modify a fiori app with Neptune, but the two solutions work perfectly together (You can add Neptune apps in the Fiori launchpad) One of our partners have created an RDS solution based on both Fiori and Neptune.
    4. Neptune is an add-on to Netweaver and as such has no extra security in itself beyond that (And we seek not to do that). But we support any security you wish to add on top. I strongly advice having a look at the SAP Secure offering (App protection and MDM)  as well as SMP (also the new Cloud edition which gives easy affordable protection for your backend)
    So that was my very biased answer
    Njål

  • Launching a new browser from webGUI

    Is using mixed mode the best/easiest way to launch a new browswer passing parameters during a webGUI session?
    Is there a simple way directly from ABAP?  I tried using embedded JavaScript in ABAP, but didn't work.
    Thanks,
    Brian

    Jan,
    Good questions...
    By "mixed mode", I mean the ITS mode where it automatically uses SAP GUI for HTML to display screens when it can not find a template.
    We have a an ABAP report that is being called via webGUI from an outside application.  The users would like to click on a line of the report and "drill down" in a new browser window.  The "drill down" is to a URL that accepts parameters and does some kind of database lookup in PeopleSoft (dirty word, I know), then displays an HTML report.
    I think I may have found a solution last night.  There is a function called "ITS_BROWSER_WINDOW_OPEN" that appears to do exactly what I need.  I just need to test the parameter passing, etc...
    If you know of another way, please let me know as I am not 100% confident in the function module yet.
    Thanks,
    Brian

  • Disable URL-Mangling in BSP Runtime

    Hi Experts,
    we decided to provide some web applications für mobile devices. Currently (and maybe never) WD ABAP does not support mobile devices. Therefore we are looking for alternatives.
    There are a lot of threads in the net where other people discussed the same topic and several decided to use BSP. We wanted to use BSP and jQueryMobile but we noticed that there are some problems because of URL-Mangling / rewriting.
    Do you have any idea if it is possible to disable URL-Mangling without modification? We already thought about an own request handler in TA SICF but in this case we also need an own CL_BSP_RUNTIME (to disable the coding in method on_check_rewrite). However this is difficult because some standard BSP runtime classes (RUNTIME, NAVIGATION...) are marked as final, so it isn't possible to inherit from them and we don't want to copy / redevelop all relevant classes.
    Furthermore there are other disadvantages like:
    - many redirects (problematical with low-bandwidth connections)
    - client cookie handling is more difficult
    Do you have any idea?
    Kind regards
    Danny

    Hello!
    I've done quite a lot of BSP development together with and without javascript frameworks like jQuery. It's possible to create a scenario without URL mangling if you set the system architecture in a specific way. I could speak a lot about this setup as it works really well! Here is a quick guide to get started:
    Step 1:
    The BSP runtime isn't really used at all. Create a BSP application but only store MIME objects in it. The MIME objects isn't URL mangled! The drawback is of course you can't do server side ABAP in your HTML documents. On the positive side, any Web Developer can create the HTML and javascript without ABAP programming skills. SAP functions as a static web server with all the benefits of the ICM cache and transport system.
    Step 2:
    Add an external alias in SICF for the BSP application. Like pointing "/myapp" to "/sap/bsp/sap/zmyapp_v001". The external alias is configured with a service account (without any authorizations) with authentication set to "Required with Logon Data". All fields should be specified (Client, User and Language). Now, any anonymous user can request the HTML files without interfering with logon data.
    You don't need an external alias, but they come in handy to have nice-looking URLs; the possibility to change their target when you have multiple versions at the same time; and you can create multiple alias for the same application with different logon data. Like "/myapp/english" if you want. Or "/myapp/client800". Or "/myapp/latest", "/myapp/version1" etc.
    Step 3:
    Create a custom HTTP handler for your business data and assign it to a node in SICF. For example "/customers/orders/get" or whatever you find appropriate for your app. Since you now have your own handler, the BSP runtime isn't involved and no URL mangling exists.
    The handler returns data in a suitable format for Web Developers (read: JSON).
    Protect this node with security that matches the flexibility required from the frontend. I usually set another service account for this service and handle authorization myself; returning HTTP status codes like 403, 200 to the Web Developer (but not 401 as it's quite difficult to handle in AJAX scenarios). In it's most simple form you can provide username and password as form fields and perform a user switch in the handler for every request, effectively changing SY-UNAME in the handler ensuring that the correct user context is used.
    Best regards,
    Mikael Gurenius
    SAP Solution Architect (Mobility)
    PS: MIME objects are of course served with URL Mangling if referenced relative to the BSP application. You can avoid this (for example for the Apple icons) by always linking your MIME objects from the root. Get the application path using code or type manually. Like
      <link rel="apple-touch-icon-precomposed"
    sizes="57x57"
    href="<%= lv_path %>/icon_57x57.png" /> where lv_path is "/myapp/images" or "/sap/bc/bsp/myapp/images". If you do this, you can have URL Mangling (and do ABAP development) in your BSP pages but still have "clean" URLs for MIME objects.

  • DrillDown from Web Application Designer

    Hi,
    I have a BW web report with some tables. The users compare this with the old pivot tables that they used in excel. When they double clicked on a certain cell in that pivot table, they got a detail of all the records that resulted in that number in that cell.
    My question is: when I have a table in a BW report, can they in a certain way do the same transaction. In other words, can they get the same detail in BW. This without using a different query and web report?
    Pascal

    Pascal,
    you would have to do an RRI for this as suggested , . In your case , the user experiencs seems key , is it absolutely essential that they go to the details level on double clicking on the column or will they be okay with a popup menu instead ?
    If it becomes absolutely essential for a clickthrough , you will have to invest some more time into JavaScript and ABAP.
    Hope this helps..
    Arun
    Assign points if useful

  • Running SAP Transaction from Portal

    Hello, Is there any way to tell from within the ABAP program whether it has been executed from the Portal or from within SAP?
    Thanks  a lot, Ashley.

    Hi Ashley,
    Can you check this topic: ABAP and JavaScript on how to use javascript in abap editors.
    Because if you are viewing your transaction through ITS its perfectly OK to have Javascript in it.
    Regards,
    Prem.
    P.S.
    Or, Are you into Portal development. And may I please know what eaxctly is the purpose of knowing whether your transaction is running in portal?
    You could also try making a Java iView (Abstract Portal Component -> JSP). And in your JSP create an IFRAME tage to hold the ITS URL to your transaction. Above the IFRAME create the script tags to hold the window.location code. This will definitely work as its a JSP.
    e.g.
    <html>
    <script language = "JavaScript">
    .... your js code....
    </script>
    <body>
    <iframe src = "http://...your its url to the abap program z transaction..."></iframe>
    </body>
    </html>
    Message was edited by:
            Prem Mascarenhas

  • Help to template-template jump

    Hi Experts!
    I´m new developing  Templates. I have a template with a TABLE and  when I 'click' into a cell i want to jump to other template. I think I should use the 'rri jump' but i don´t know how i do it.
    Any idea??

    the option to retain the context menu and move the entry onto the context menu instead of submenu is the how to paper desribed by durairaj.
    Also if click through is the only option it can be done using javascript and the table inerface. It is not that tough depending on your comfort level of Javascript and ABAP and command URLs.
    Arun
    Message was edited by: Arun Varadarajan

  • Assigning Javascript value to ABAP variables

    Hi Experts,
    I have written the HTML code mixed with Javascripts to create a table in the 'View' of a BSP Component.
    I was able to set the value of assign the value of ABAP parameters into HTML fields.
    This table has some input fields. I need to fetch the value of input parameters which has been entered by screen on an event which is present in Overview Page.
    I can calulate the value mentioned in input field but i am not able to assign the same value to ABAP parameter for further processing.
    I have already referred the following link but it did not work.
    Assign Javascript variable to Abap variable
    Please help me how i should i acheive it.
    Thanks In Advance,
    Rajeev Singh

    Hi,
    I am not understanding your problem and what you want due to description, but it seems to be very similar to a post which I answered very recently [here|How to return values from a BSP page to Javascript;.

Maybe you are looking for

  • Opening Excel file in User browser window

    Hi, My application generates Excel file from the rowset and stores on the server automatically when the user clicks a button, but I want the Excel file to be downloadable by the user either by opening the Excel file in the browser or by prompting the

  • SocialMiner bulk transcript export

    Does someone knows if you can export all chat transcripts on Social Miner 10.6(1) in bulk? Thanks Alex

  • Replication for Sharepoint SQL Server

    First, let me explain the situation: My company is planing to use Sharepoint for intranet and as replacement of file servers, so there will be lot of data inside the SQL databases. I'm the DBA and so I'm responsible to implement and administrator the

  • Seahorse keeps asking about password, even when ssh-key is used

    Hi, I want easy access to my repos on bitbucket. I have set my id_rsa.pub in bitbucket preferences, but when I try take any action on repo I have to type password . First there is graphical popup menu to type password, when I cancel it I can type pas

  • Runtime error when restricting the Characteristic...

    Hi All, When i am doing restriction on characteristic i am getting the error like Run time error '-2147417848(80010108)'; Automation error The object invoked has disconnected from its clients. I dont understand its my problem or any other Basis Issue