ABAP OO: methods as method params, method chains

Hello all,
I am currently developing quite much ABAP OO and wonder if this is possible, because I got compilation errors.
a) Methods as method params w/o temp vars:
I have a method whose parameter shall be the return value (let s say a string) shall be the parameter:
document->set_owner( owner = person->get_name( ) ).
This throws an error and I have to code this instead
data: owner type String.
ownerString = person->get_owner( ).
document->set_owner( owner = ownerString ).
... so I have always a temp variable which is getting MUCH overhead when having such stuff often...
Am I doing wrong or is this impossible in ABAP OO? ...am used to do such things in all other languages I know... mean, that methods can be params of other methods.
b) "chaining of methods"
Is this possible somehow?:
data: tmp type String.
tmp = employee->get_orgUnit( )->get_name( ).
Calling one level (the get_OrgUnit() method) works fine, but an immediate call to the second level ( get_name() method) fails and I have to code this:
data: tmp     type String,
      orgUnit type ZOrgUnit.
orgUnit = employee->get_orgUnit( ).
tmp = orgUnit->get_name( ).
This also very annoying to have so much temporary help variables on the way.
Is there any help for me?
Thank you for any hints and reagrds,
Timo

Hi Timo,
as Richard's reply says it's impossible in ABAP-OO. The nature of this language is ABAP not OO
Only helpful for you, could be the returning parameter. It's very useful in conditional expressions like
if m1->a() = '2'.
A preferred parameter to avoid writing parameter names like
m1->b( '2' ).
All other useful stuff of method or parameter chaining, and so on is NOT possible. Sorry.

Similar Messages

  • ABAP OO Method

    Greeting Gurus,
    I am working with the Purchasing cube and I have come accross a routing that PERFORMs LOC_CURR_CONVERT.  I need to convert this to a ABAP OO Method.  I find it difficult to find any information on this.  Does anybody have any suggestions?
    I am on SP8, waiting on SP10.
    Does SAP have a method name that replaces this ABAP Routine?  Or do I need to code myself?  Is there any handy documentation (I found HOW To... Routines within Transformations already, however, not explicity to Methods.)
    Kind Regards,
    Alex

    Hi KJ,
    I have executed the steps already on the document you gave me.  I am on the "further edit the transformation manually" step.  Since I am on SP8, my guess, is that it is not giving me the "proposal" of migrating the PERFORM call to a FUNCTION call.
    Please see the following post, where Rohan also is experiencing the same problem in SP8.  Re: How to convert  old Abap routine in to ABAP OO in 2004s
    My guess is I need a comperable FUNCTION call to that of the old LOC_CURR_CONVERT.

  • ABAP OO method on Task - won't execute in background

    I've been trying to get workflow with ABAP OO methods up and running on our 6.20 system.  I've followed Jocelyn's blog series and the associated white paper, and can get the DISPLAY method working for her example ZCL_PLANT class.
    I can't seem to get a task working with the static CREATEINSTANCE method, however.  The method works fine (tested in SE24), but when I create an associated task and test it in SWUS, the log shows the status of the work item as Ready, with my name as the Agent.
    I've flagged the task as synchronous and background - is there anything else I should be doing?
    Thanks in advance,
    Andrew

    Hi Andrew,
    Check your Synchronous and Background parameters on the Task again, activate your WF again and start a new workflow.
    This should definitely work and not have you as an agent. But sometimes it can be a bit stubborn if you e.g. stay in the same transaction and make changes in another session. Always go back to the main Easy Access menu before testing changes.
    Cheers,
    Mike

  • ON COMMIT ABAP CLASS METHOD

    Hi Friends,
    Can i execute and abap oo method on commit work.
    similiar to perform form on commit.
    thanx

    Hi Kaushik!
    This should be possible, but with a little bit different approach:
    You can implement an event handler for the commit event. Then you have to register this method for the commit event. Have a look at program SAPMSSY0. In routines %_before_commit, %_commit and %_after_commit you will find some events, e.g.
    * Raise event 'Commit Requested' for Object Manager
      CALL METHOD cl_os_transaction_end_notifier=>raise_commit_requested.
    , for which you might like to register your method.
    Regards,
    Christian

  • ABAP OOP method in Workflow task 6.20

    Hello all!
    In the following blog /people/jocelyn.dart/blog/2006/07/25/using-abap-oo-methods-in-workflow-tasks it is mentionned that to enable OOP methods for workflow tasks on 6.20 one needs to run report SWF_CATID.
    I'm currently on a customer system 6.20 ABAP SP50 and this report simply does not exist. Is this report appearing in a later support pack or is this not available until 6.40 as I belived....
    Any advise on how to enable this on an above system is highly appriciated!
    Regards
    Martin Jonsson

    Hi,
    Check this Report - RSWF_CATID.
    Regards,
    Surjith

  • ABAP class method with dialogue

    Hi all,
    I want to use a ABAP class method within a Workflow definition with user interaction. The SAP help says, that is possible, but I couldn't find a way, to mark the method as "with dialogue".
    For BOR-objects there is a checkbox in the details for the method definition. Can anybody tell me, how it can be done?
    Thanks in advance
    Nick

    Hi Nicolas,
      When you create the Task with the ABAP OO Method, you can select it as "Background Processing" else it will be a "Dialog Process".
    If you notice here, "Background Processing" checkbox will be editable if ABAP OO Method is used, whereas in case of Business Objects it directly comes from method definition.
    Reward points if useful.

  • Function module or ABAP-OO method to start DTP via Coding

    Hello experts,
    is there any function module or ABAP-OO-method, which I can use to start DTP's via ABAP-Coding (e.g. in my own programm)? I know there are FM's to start, change, delete, etc. InfoPackges. Are there any functions like them also available for DTP's?
    Kind regards,
    André

    Hello Andre,
    [Re: CL_RSBK_DTP - How to use...]
    I've tested and it works fine!
    Regards,
    William

  • How The ABAP Proxy method gets triggered

    Hi All,
    I have created a ABAP Proxy for inbound interface.For this interface the data is coming from XI system.So i am writing the logic to read the XI data into an internal table and am populating the same data into a BAPI.
    So my question is,once the XI system sends the data, Will this ABAP Proxy Method automatically gets trigger or Do we need to make any settings?
    Please Help me As early as possible.
    Thanks in advance
    Regards
    Srinivas Kodukula

    Hi srinivas,
    Refer the below points for the configuration needed at R/3 side:
    1. Create a HTTP connection in the business system using transaction SM59
    2. Configuration Business system as local Integration Engine in SXMB_ADM
    3. Connection between Business System and System Landscape Directory. For this check the RFC destinations LCRSAPRFC and SAPSLDAPI
    4. Maintaining the SAP J2EE Connection Parameters for LCRSAPRFC and SAPSLDAPI in SAP J2EE engine
    5. Maintain SLD access details in Transaction SLDAPICUST
    Regards,
    Kiran Bobbala

  • Somebody explain me method chaining.

    Hi.
    I'm looking for somebody to give me an explanation of how does Method Chaining (I think this is how it's called) work.
    i.e:
    myObject.setPrice(2)
    .setQuantity(10)
    .solveLifeProblems()
    .setAvailavility(true);
    Where's the theory about this?
    Can I do this with every class?
    What requisites are needed so that I can use this technique with my classes?
    What if the method, say solveLifeProblems() returns somethin strange (such as an boolean or another object)?
    Thanks.

    All you're doing is invoking a method on the return value of another method. All solveLiveProblems() has to do is return a class with a method called setAvailability.
    Sodog()
    .cat()
    .monkey();is the same as
    dog().cat().monkey();which is the same as (for example)
    Hammer hammer = dog();
    Screwdriver sd = hammer.cat();
    sd.monkey();I'd advise not formatting your code like this until you have more experience.

  • Method chaining and casting

    I was wondering if anyone knows whether it is possible to somehow apply method chaining on an object that requires a cast.
    For example:
    ArrayList ar = new ArrayList();
    ar.add(new Integer(3));
    int i = ar.get(0).intValue();The third line obviously produces a compile error to the effect that you can't call method intValue() on object Object.
    To get the int value from the ArrayList above I have to do the following:
    ArrayList ar = new ArrayList();
    ar.add(new Integer(3));
    Integer intObject = (Integer)ar.get(0);
    int i = intObject.intValue();Is it at all possible to get the int value somehow without explicitly creating an Integer object? Is there a possible way to combine method chaining and casting in this case?

    You may combine the two lines by casting at the same time:
    int i = ((Integer)ar.get(0)).intValue();
    Notice the additional brackets to help the compiler understand the precedence of your intentions. It makes no sense if the compile tries to call intValue THEN cast to Integer.
    When you call:
    Integer intObject = (Integer)ar.get(0);
    No Integer object is created, only a reference to the object is created. I'm not sure if an implicit reference is created in the previous example, but I see no substantial benefit using the first method. In fact I won't use it as its not very readable (to me).

  • Method Chaining

    Hi all,
    I have these method chaining:
    boolean b = Services.getInstance().getEntitleReferenceService().getUser(username) != null;
    As I understood, I have to follow the method chain from right to left, right?
    Services.getInstance()> returns an object of type: Services
    On the Services object, I call the method: getEntitleReferenceService()
    this method returns an object of type: EntitlementsReferenceService which is object of type interface: EntitlementsReferenceService
    The only class that implements that interface is: RemoteEntitleReferenceService.java
    In RemoteEntitleReferenceService.java, I have the method: getUser(String userID)
    The point is that the method: getUser() does NOT return boolean as expected!
    This is the method signature:
    public User getUser(final String userId){}
    I have this part of code in Intellij and it does not show an error as it usually does when these kind of error happens.
    Does anybody has any idea that where am I making a mistake? Any help is greatly appreciated.

    The point is that the method: getUser() does NOT return boolean as expected! Nobody expects it to. It'll return a reference, which will be evaluated against null, and the reult of that gets assigned to the boolean.

  • Method Chaining - Benefit?

    Hiii...
    I have read about Method Chaining like
    obj.method1().method2().method3();
    Its easy for development like you are concatinating 3 calls into 1, but I want to know whether its improving perfromance something or not?
    Thanks..

    endasil wrote:
    georgemc wrote:
    String url = new StringBuilder("file://")
    .append(baseUrl).append(File.separator)
    .append(resourceDir).append(File.separator)
    .append(resourceName)
    .append(extension).toString();Now you can just read down the "right-hand column" and see what the url string is composed of.Forgive my ignorance, but how is that example better than
    String url = "file://" +
    baseURL + File.separator +
    resourceDir + File.separator +
    resourceName +
    extension;I don't mean to attack an example whose purpose was something different (it correctly showed why chain methods), but I just thought I'd ask. It seems to me like using a StringBuilder really only has benefit if you're going to be building the string dynamically/not all in one statement. Otherwise just using String concatenation seems cleaner.:sigh: I'm not being side-tracked here. By your own admission, the example was to demonstrate method chaining.

  • ABAP program to add in the process chain before the attribute change run

    Hi
    I need a ABAP program to add in the process chain before the attribute change run(process) to avoid the locks, can any one send me the program
    Regards,
    Satish

    I am not sure of any standard program .... but you can write your own... should be a small one..
    you can check if the table RSDMDENQ has entry for your InfoObject... if yes, then its locked.. if not.. its not locked

  • How would YOU retype these old XM08 types for use in an ABAP OO method?

    The XM08 function group has the following type declarations:
    TYPES: BEGIN OF mmcr_drseg_co.
            INCLUDE STRUCTURE cobl_mrm_d.
    TYPES: cr LIKE drseg_cr    OCCURS 0,
           unpl_refwr TYPE refwr,
           END OF mmcr_drseg_co.
    TYPES: mmcr_tdrseg TYPE mmcr_drseg OCCURS 0,
    TYPES: BEGIN OF mmcr_drseg.
            INCLUDE STRUCTURE drseg.
    TYPES: cr LIKE drseg_cr OCCURS 0,
           co TYPE mmcr_drseg_co OCCURS 0,
           sm LIKE drseg_sm OCCURS 0,
           charact TYPE rbcharact_instance OCCURS 3,
                                           "instances of characteristics
           uebgmat  TYPE matnr,
           uebrblgp TYPE rblgp,
           selkz_db TYPE selkz,
           rblgp_old TYPE rblgp,           "rblgp before aggregation
           END OF mmcr_drseg.
    How would YOU redeclare these types so that they work in an ABAP Objects class?  
    Some of the "fixes" are easy, like replacing "LIKE" with "TYPE:".
    But what about the "INCLUDE STRUCTURE" and the "occurs 0" specifications?
    The reason I'm asking this is that I have to call a method from ZXM08U16 and I'd like to be able to pass this method exactly what XXM08U16 gets from SAP, i.e. the table E_TDRSEG of type  MMCR_TDRSEG

    David,
    I wonder it can be directly in ABAP (I would like to hear opinions from others as well!), I needed to use Data Dictionary as well:
    TYPES: BEGIN OF mmcr_drseg_co.
            INCLUDE STRUCTURE cobl_mrm_d.
    TYPES: cr TYPE z_tt_drseg_cr,
           unpl_refwr TYPE refwr,
           END OF mmcr_drseg_co.
    z_tt_drseg_cr is a table type created in SE11, based on structure drseg_cr.
    the way to create internal table and work area, based on the above:
    DATA : gt_... TYPE TABLE OF mmcr_drseg_co.
    DATA : gw_... TYPE mmcr_drseg_co.
    hope this helps some
    ec
    UPDATE : Rich is right, it is possible to do it only in ABAP with the DEFAULT KEY addition.

  • Call an URL with ABAP program (Method POST)

    Hi everyone,
      I need to call an URL for example "www.google.com?q=hello" with ABAP using POST method.
      Like the FM "Call_Browser", but my variable q=hello need to be passed with POST method.
    Any idea ?
    Thanks.

    here is one example I use from abap to call a web browser ITS solution with a project number, I guess you can adapt the it for your purpose?
          check <data>-pspid is not initial.
          concatenate gv_pfs_link
                      'zpfs2?~okcode=PROJ_SEL&zpspid=<###>&sel_action=X'
          into lv_url.
          replace '<###>' with <data>-pspid into lv_url.
          condense lv_url no-gaps.
          cl_gui_frontend_services=>execute(
            exporting document = lv_url ).

Maybe you are looking for

  • Can't save attachments to selected folder

    I've just started using BT Yahoo email, as my LiveMail is kaput, and I find I can't download an attachment to a selected folder. When I click on the file, I'm given merely the generic option to 'Save to computer'. (See screen shot.) This just sends t

  • Make library available to multiple users on the same computer

    I want to have the library available to more than one user on the same computer. The "share my music" option doesn't seem to help. I also tried running iTunes as the second user and setting the library file to the one I had created as the first user,

  • Http tool not connecting with the PI

    Hii,, I have done http to soap scenario... but when i want to test from http tool (HTML file which i got from sdn) its not connecting with PI i given the right information in Header portion and copied my payload to html tool. when i press send button

  • Ati rage & tv out & tv in

    I have udev & 2.6.10 kernel... and i don;t have change it.. Tell me how I can make tv out and tv in ... to work with my archlinux....

  • JSP Designer: Error: "Your browser is not JavaScript enabled"

    Oracle jDeveloper 11g 11.1.1.0.2 FireFox 3.5b4 IE 7.0.5730.13 In the design view of an xml document created from the faces-config I'm getting an error that JavaScript is not enabled. "This page uses JavaScript and requires a JavaScript enabled browse