Generics for Higher Order Function Support

Perhaps I'm not looking hard enough, but it seems that all arguments for generics relate to containers. Has anyone considered the impact of generics and at least rudimentary type inference on higher order function support.
Consider the case in which you want to execute a particular operation under time constraints, or with specified cleanup operations to occur afterwards, for example:
interface DBOperation
  void doOperation(Connection con);
void DoDBOperation(DBOperation op)
  Connection c = acquireConnection()
  try
    op.doOperation(con);
  finally
    c.release();
}One would then call:
DoDBOperation(new DBOperation() ...);Now what happens if I want to make a DBOperation that returns an integer and throws a specific checked exception. I would need to define an alternative DBOperation2 class, and rewrite DoDBOperation for each possible permutation of checked exceptions, and for each return type.
Or one would just have:
interface DBOperation
  Object doOperation(Connection inCon) throws Exception
}But now when I call it, I need to catch Exception, not just the ones I specifically throw, and I have to cast the return type.
Clearly, a generics mechanism with type inference could infer the appropriate throws and return type for the DoDBOperation call, given the compile-time type of the parameter.

Ahh, i think I'm starting to see. My guess is that to achieve that in the current generic Java proposal, it would need to look something like:
public interface OperationInterface<T extends Object, X extends Exception>
   <T> doOperation() throws <X>
public class LoggedOperation<T extends Object, X extends Exception> implements OperationInterface<T, X>
  OperationInterface<T, X> delegatee;
  public LoggedOperation<T extends Object, X extends Exception>(OperationInterface<T, X> d)
    delegatee = d;
  <T> doOperation() throws <X>
    logStart();
    try {
      return delegatee.doOperation();
    finally {
      logEnd();
Or somesuch.  The important thing to note is that the genericity is on the objects, not on their methods. So it can behave a little like you suggest, provided the class is created properly in the first place.
Note: I haven't tried the demo version of the generic compiler, so I'm sure every line of that code is wrong.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Similar Messages

  • Higher order function and threads

    Does anyone knows if I define an interface ApplyObj with a binary function f as it's only method; the binary operator that we want to pass as an argument into the reduction is then declared as a class that implements this interface. How to I do that??
    Taking example.
    applic is the function to excute. and this applic can store instructions to add, concat or minus. Then I have this set of array which can be alpha or int array, passing the function in, it's suppose to create threads to get the result
    e.g array[3] store [0]= 2 [1]=4 and [2]=8
    after the first round will result to array[0] and array[1] to add each other and result stored in [0]. since [2] does not have a neighbour [3], [2] after step 1 still have the value of 8
    then step 2 will result to [0] which stores the step 1 results which is 2+4=6, [0] will then add with [2] and the final results [0]=14.
    Just how can I program like this?
    1st can anyone tell me... how to decipher a higher order function that is pass in as a object?
    Thanks

    Sounds to me like you want this:public interface ApplyObj
        public int[] applic(int[] args);
    }Then e.g.public class Add implements ApplyObj
        public int[] applic(int[] args)
            int[] result = new int[(args.length + 1) / 2];
            for (int i = 0; i < args.length; i += 2)
                result[i / 2] = args[i] + args[i + 1];
            // Deal with the last element of an odd length array
            if (args.length % 2 == 1)
                result[result.length - 1] = args[args.length - 1];
            return args;
    }Warning: this code is untested. Note: pizza is a superset of Java which has proper higher order functions. Maybe you should use that instead.
    Answer provided by Friends of the Water Cooler. Please inform forum admin via the 'Discuss the JDC Web Site' forum that off-topic threads should be supported.

  • Design Studio 1.3 SDK - Are script contributions for SAPUI5 method functions supported?

    All of the SAPUI5 SDK component examples provided with the Design Studio Samples demonstrate how to expose property getter/setter functions as script contributions.  Indeed, the SDK Developer Guide also just focuses on this.  However, UI5 controls may also include method functions that allow certain actions to be performed on the control.  In this context, I have the following questions:
    1)  Is it possible to expose method functions via script contributions in the contribution.ztl file?  If yes, what is the correct syntax for doing so?  Based on my experimentation so far, it seems like method functions cannot be exposed directly via script contributions;
    2)  If method functions are not supported for script contributions, are there any recommended approaches as a workaround?  One possible approach that comes to mind is as follows:
    i)  Define an invisible "dummy" property of type boolean to correspond with each method function that we want to expose as a script contribution;
    ii)  Define invisible properties to correspond to the parameters required by the method functions;
    iii) In the contributon.ztl code, perform the following tasks:
    (a) Set the invisible parameter property values that correspond to the desired method function;
    (b) Invoke the dummy property getter or setter function by getting or setting the boolean value of the dummy property in the contribution.ztl code;
    iii).  Override the corresponding dummy property getter or setter function in the component.js code with additional logic to read the invisible parameter property values and then call the method function.
    Any feedback would be appreciated.
    Thanks,
    Mustafa.

    Hi Mike,
    Thanks very much for your suggestion.  Your mind-bogglingly creative solutions never cease to amaze me .
    Reviewing the code, yes I did wonder about the use of the Math.random() function.  Then when I subsequently read your explanation about the state saving, the penny dropped as to the issue I was experiencing with the approach I had previously tried (as described in point form in my question), whereby I could not invoke the setter function multiple times from the BIAL script.  So I added a call to the fireDesignStudioPropertiesChanged() function, which has partially solved my issue but the parameter properties are out of sync.
    I'll describe what I've implemented and hopefully you can shed some more light on how to resolve the issue:
    In the contribution.xml file I've defined invisible properties for the method function and it's parameters as follows:
    <component id="ActionLabel"
           title="Action Label"
           icon="res/com.infovizi.prototypes.actionlabel/icon.png"
           handlerType="sapui5">
          <jsInclude>res/com.infovizi.prototypes.actionlabel/js/component.js</jsInclude>
           <cssInclude>res/com.infovizi.prototypes.actionlabel/css/component.css</cssInclude>
           <property id="text" type="String" title="Text" visible="true" />
           <property id="showAlert" type="boolean" title="Show Alert" visible="false" />
           <property id="alertText1" type="String" title="Alert Text 1" visible="false" />
           <property id="alertText2" type="String" title="Alert Text 2" visible="false" />
           <initialization>
                <defaultValue property="SHOWALERT">false</defaultValue>
                <defaultValue property="TEXT">"Hello"</defaultValue>
           </initialization>
      </component>
    In the contribution.ztl file I've defined a script method to invoke a method function for displaying an alert as follows:
    class com.infovizi.prototypes.ActionLabel extends Component {
      /* Displays an alertbox */
      void showAlertBox(/* Text 1 */ String alertMsg1, /* Text 2 */ String alertMsg2) {*
      this.alertText1 = alertMsg1;
      this.alertText2 = alertMsg2;
      this.showAlert = true;
    In the component.js file, to keep things simple I've chosen the UI5 Label control to extend with a custom method function that I want to invoke via the script contribution as follows:
    sap.ui.commons.Label.extend("com.infovizi.prototypes.ActionLabel",{
      metadata : {
         properties : {
          "showAlert" : "boolean",
            "alertText1" : "string",
            "alertText2" : "string"
      initDesignStudio: function(){
      renderer:{},
      // Override ShowAlert setter to perform action
      setShowAlert: function(alertState){
      if(alertState == true) {
      this.displayAlert(this.getAlertText1(),this.getAlertText2());
      // Reset showAlert property value to "false" and call fireDesignStudioPropertiesChanged()
      // to allow setShowAlert function to be invoked multiple times via BIAL script
      this.showAlert = false;
      this.fireDesignStudioPropertiesChanged(["showAlert"]);
      return this;
    // Alert method
      displayAlert: function(alertMsg1, alertMsg2){
      alert("Message: " + alertMsg1 + " " + alertMsg2);
    I then created a DS app with the following script in the click event of a button to invoke the method function in the custom Label control:
    ACTIONLABEL_1.showAlertBox("Hello", "World!");
    After launching the application and clicking the button for the first time, the alert display function is displayed as expected but the parameters have not been updated, even though they are updated in the script contribution function, so the parameters are not displayed, as follows:
    After the alert is dismissed and the DS button is clicked again, this time the parameters are passed correctly as follows:
    So the parameter updates for alertText1 and alertText2 seem to be out of sync for some reason.  I'm sure I'm missing a nuance here.  Any ideas?
    Conceptually, I'm just trying to achieve what Leandro Cardoso has done with the script contribution action function calls in his Notify component.  The only difference is that I'm implementing HandlerType "sapui5" instead of "div".
    Any thoughts about the parameter syncing issue would be appreciated.

  • Bom for production order - Function module

    Hi
    I'm looking for a function module or bapi which can provide me with the BOM for a specific production order.
    The FM should also handle changes to the BOM and just show me the updated BOM on the production order.
    KR
    Jesper Dueholm

    Dear JDU,
    You can use this FM BAPI_PRODORD_GET_DETAIL if you want to get the BOM components related to the production order or
    use FM,CS_BOM_EXPL_MAT_V2 for getting BOM multi-level display.
    There is no functional Module through which you can do BOM changes in the production order or in the BOM and it has to
    reflect the changes in the order immediately.
    Check these functional modules for BOM change,
    S_BI_BOM_CHANGE_BATCH_INPUT   Change bill of material via batch input
    S_BI_CHG_CHANGE_BATCH_INPUT
    S_CL_P_ITM_MASS_CHANGE
    S_CL_S_ITM_CHANGE
    S_CL_S_ITM_CHANGE_COMPLETE
    S_CL_S_ITM_ODP_CHANGE
    S_CL_S_SUI_CHANGE
    S_CL_P_BOM_MASS_CHANGE
    S_CL_S_BGR_CHANGE
    Regards
    Mangalraj.S

  • Material Availablity check for production order - function module?

    I have a production order with Material BOM, which has more than 30 components in it. Please suggest me if there is any function module to do the material availability check of a production order. I need the missing component list as output of that function module, with quantities if possible.
    thanks,
    Subbareddy

    You might want to look at these FMs:
    CO_ZA_AVAILABILITY_CHK_ORDER
    ISA_AUC_MATERIAL_AVAILABILITY
    Thanks,
    Santosh

  • Back order functionality in B2B

    Hi
    How the back order functionality works in B2B? Any specific settings?
    Regards

    Assuming CRM backend for the discussion.
    There is no explicit configuration step for back order functionality directly in CRM. Configuration of Availability Check is mandatory.
    No additional configuration is required, other than what is available to configure ATP under Menu path
        Customer Relationship Management
            Basic functions
                Availability Check
    However, the choice of using availability with R/3 or APO is configurable. Please see
    [Note 819744 - Composite SAP Note: ATP in CRM|https://service.sap.com/sap/support/notes/819744]
    [Note 624992 - CRM 4.0: Availability check with SAP R/3|https://service.sap.com/sap/support/notes/624992]
    Backorder feature provides:
    Orders containing items that are due (requested quantity is not totally confirmed as relates to requested delivery date
    Selection of back orders in document search
    Display of back order items in work list shows back order items from multiple orders
    Easwar Ram
    http://www.parxlns.com

  • How to Skip weight data from Sales order for Higher level BOM material

    I have maintained a BOM at Item level with item category group LUMF.
    And the higher level item is not subjected for pricing and costing. While creating the higher level Item I did not maintain weight for it. Now when I create a sales order due to the incompletion log system is asking to maintain Weight details for higher level item also.
    But I donu2019t want to maintain weight for that item nor I want to remove net weight and gross wt from incompletion log.
    While creating higher level material with material type FERT and I have maintained LUMF and all things are normal. Also tell me do I need to select any different material type or do I need to go for different settings ?
    I hope my query is clear. Please ask if query is not clear.
    Please Guruu2019s suggest me.

    Hi ,
    I do not know what a reference charactersitcs is,but there are all independant characeristics in terms of their values.
    A guess it is because the VC data is changed after the sales order is created, the updated VC data is displayed properly only in VA02 or VA03 but other function modules fail to display the updated VC data.
    I understand there is a relationship of instance -between sales order object and VC data object-which we need to update and then see the latest data.
    Please let me know if anyone has debgged VA03 to know how the standard SAP program retrieves VC data in a sales order.
    Thank you,
    Hemant

  • I downloaded Lightroom version 5.7 in order to support tethered capture on my Nikon D750 and its still not working. Additionally when I was prompted to give my serial number for the update it was no where to be found on my Adobe profile although I purchas

    I downloaded Lightroom version 5.7 in order to support tethered capture on my Nikon D750 and its still not working. Additionally when I was prompted to give my serial number for the update it was no where to be found on my Adobe profile although I purchased, and am paying monthly for my creative cloud for photography. Please help

    Does your Cloud subscription properly show on your account page?
    If you have more than one email, are you sure you are using the correct Adobe ID?
    https://www.adobe.com/account.html for subscriptions on your Adobe page
    If yes
    Some general information for a Cloud subscription
    Cloud programs do not use serial numbers... you log in to your paid Cloud account to download & install & activate... you MAY need to log out of the Cloud and restart your computer and log back in to the Cloud for things to work
    Log out of your Cloud account... Restart your computer... Log in to your paid Cloud account
    -Sign in help http://helpx.adobe.com/x-productkb/policy-pricing/account-password-sign-faq.html
    -http://helpx.adobe.com/creative-cloud/kb/sign-in-out-creative-cloud-desktop-app.html
    -http://helpx.adobe.com/x-productkb/policy-pricing/activation-network-issues.html
    -http://helpx.adobe.com/creative-suite/kb/trial--1-launch.html
    -ID help https://helpx.adobe.com/contact.html?step=ZNA_id-signing_stillNeedHelp
    -http://helpx.adobe.com/creative-cloud/kb/license-this-software.html
    If no
    This is an open forum, not Adobe support... you need Adobe staff to help
    Adobe contact information - http://helpx.adobe.com/contact.html
    -Select your product and what you need help with
    -Click on the blue box "Still need help? Contact us"

  • I am trying to find a function module or BAPI for internal order change. I

    I am trying to find a function module or BAPI for internal order change. I did come across a function module ALE_INTERNALORDER_DB_CHANGE which directly updates the internal order using insert statements. Can i use this for internal order change or this is any other Function module for updating the internal order.
    I dont want to use BDC as a option. Please suggest.

    This is possible using the Rotator Component Widget from Infosemantics.com.au but it is only compatible with  SWF output, not HTML5.
    Go to this page and scroll down to the video tutorials about the Rotator Component widget:
    http://www.infosemantics.com.au/adobe-captivate/youtube-video-tutorials

  • Legal Control functionality for Purchase order

    Hi,
    We have a requirement where in while saving the Purchase Order, the system should look whether for that material if the legal control data/ foreign trade data is maintained specifying that it is a controlled substance then the licence should be maintained before saving the PO. If the licence is not maintained then the Purchase order should not be allowed to be saved.
    In a nut shell, we want to control the saving of Purchase order depending on whether the licence is maintained or not.
    This has been done for Sales order. The standard SAP functionality allows the document control.
    This can be seen in SPRO - Materials Management - Purchasing - Foreign trade/Customs - Legal control - Document control.
    Here we can see that only Sales order and shipping documents can be controlled.
    Is there any way we can control the Purchase Ordr also?
    Please let me know for any clarification regarding the requirement.
    Regards,
    Ramachandra DN

    Hi Ramachandra,
    this kind of functionality is not available in SRM. Have a look into GTS Module, which can be connected to SRM for achiving your requirement. http://help.sap.com/saphelp_gts30/helpdata/en/1d/8082ab7248f74ca09861d9713b9a52/content.htm
    All somehow available control, compliance and trade features are available via GTS. Any further need to be accomplished via self development.
    Cheers,
    Claudia

  • Function Module for data retrival for work order clearence (WCA)

    Hi All ,
      Function Module for data retrival for work order clearence (WCA) for a particular Planning plant and (WCD's).
    Thanks.

    Hi Anne,
    BAPI_PRODORD_GET_DETAIL
    BAPI_PRODORD_GET_LIST
    You can find further FM in Function Group COPRINT and CODR or take F4 on CO* in Function Group
    These will serve your purpose.
    Cheerz.
    Ram

  • Function Module to Create Addresses for PM order

    We are currently using BDC process to Create addresses for PM orders. I would like use a Function Module instead of the BDC process. Can somebody point me to FM that can create ADRC record and return ADDRNO?
    Thanks Guru's

    hi,
    check this link:
    [Business Address Services|http://help.sap.com/saphelp_nw04/helpdata/EN/c8/13b237b9a9a968e10000009b38f8cf/frameset.htm]
    regards,darek

  • Function module for Production order update (Table AFKO)

    Hello All,
    I know similar subject has been posted but please read the following.
    SAP 4.6c doesn't provide BAPI for production order update.
    We did develop an ABAP program that update production order and schedule it in a job.
    We are looking of avoiding direct update in table AFKO which our program do right now.
    We looked (with SE37) at either BAPI or FM to pass parameters to a functioin that would perform that update and ensure data integrity.
    CO_ZV_ORDER_POST seems interesting but is also using a lot of parameters and we have diffiulties to test it and understand it our dev team being fairly new.
    Can somebody tell us how to use this function or tell us another FM that could be used. (ie passing internal table content (New fields values) and a key value (AUFNR)) to update table AFKO and related objects/tables
    Regards
    Marc

    hi,
    TABLE IS AFKO
    rgds
    anver
    if hlped mark points

  • Function Module or BAPI to update Short text  for sales order item(vl02n)

    Hi All,
    I need to update the Short text for sales order item in vl02n transaction from an internal table with Delivery number and other relevant details .
    Does any body know any Function Module or BAPI which can accomplish this purpose .
    Or else writing BDC is the only option I have got ? .
    Please clarify .
    Thanking you in advance .
    With Regards,
    Suriya .

    Hi
    You can try using BAPI_SALESORDER_CHANGE if you want to change sales order
    Regards
    MD

  • Is there any function module for purchase order change

    Hi Experts,
    Is there any function module for purchase order change or i need to do new recording in me22n.
    Thanks,
    Senthil

    Hi
    Function module <b>BAPI_PO_CHANGE</b> enables you to change purchase orders. The Change method uses the technology behind transaction ME22N.
    Regards,
    Viven

Maybe you are looking for

  • Full load from a DSO to a cube processes less records than available in DSO

    We have a scenario, where every Sunday I have to make a full load from a DSO with OnHand Stock information to a cube, where I register on material and stoer level a counter if there is stock available. The DTP has no filters at all and has a semantic

  • Ipad 2 is not that old, you wont let us have tethering?

    Is it really that hard to give us function to share internet or just tethering with usb? even iphone4 support personal hotspot, ipad 2 who share same cpu would able to do it fine but you want us to buy THE NEW IPAD that badly? i even use ipad2 about

  • URL iView Problem - How to Use URL Parameter of Type 'User Information'

    Hello URL iView experts I am currently working on integration of backend-functionality with the help of an URL iView. I want to use a parameter of type 'User Information'. In SAP Help Library it is said, that it is possible to set the value of a para

  • AppleWorks documents are being saved automatically as Unix files. How?

    Working on a G3 iBook with OS X (10.3), all AppleWorks documents are being saved as Unix Executable Files by the program despite the dialogue box saying they will be saved as Appleworks documents complete with ".cwk". After a while of successfully op

  • Poor Business Plan

    I love that Verizon has great coverage around the country, but I have had issues inside my house (inside the house only) where I keep dropping calls.  Verizon opened a ticket and said the whole city is in a low laying area (not true), so our signal w