Skip to Content
author's profile photo Former Member
Former Member

Is there a code sample for a custom action that can accept parameters?

I looked through the help documentation and couldn't find any reference/example to define a custom action that accepts parameters.

I want to create a custom action FooBar(), which can accept parameters such as ID, Type

I would assume that when I call the action it would be CustomBO.FooBar(12, "AB");

The custom action definition would then use 12 and "AB" parameters as variables in the custom action script.

There are no examples of calling an action with parameters and defining an action with parameters , so does this mean this is not possible or it is, but not documented?

Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jan 06, 2014 at 11:52 PM

    As far as i've seen, this isn't possible, at least as of 1308. I haven't really read through the 1311 documentation, though.

    There are ways around it. You can use elements (regular or transient) and use these within the Business Object action.

    Then within CustomBO.FooBar() (without parameters) you can use these elements.

    Alternately, you can make a Reuse Library function, which DOES allow for parameters to be passed in - however, the Reuse Library functions don't let you raise messages as part of the function. I've used it in a few circumstances where i'd pass parameters in to a reuse function that would return a Code data type, and based on the code returned i'd take further action.

    Generally i'd do this if i need to have validations in multiple locations within a SAP Business Object.

    What does this requirement stem from? That'd help use recommend the best alternative.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 07, 2014 at 12:27 PM

    Hi Rei,

    That is possible, use a Reuse Library and there you can create functions with parameters.

    You can define an Import (with parameters) or a Return (returns something) method.

    In order to call in ABSL, you use YourReuseLibrary.YourMethod(Params here).

    There are a few restrictions with Reuse Libraries as mentioned by Daniel.

    Best regards,

    Fernando Giroleti

    SAP Cloud Service Center AMEA

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 10, 2014 at 04:14 PM

    You can try something funky with Reusable libraries though and let us know the results if you need it so badly.

    Consider the primary key of your CustomBO as UUID.

    Call ReUseLib.FooBar(UUID,12, "AB") and "Retrieve" your customBO's instance with UUID in the library's action FooBar and perform your operations there. I am going ahead and taking a wild guess that as this is happening in the same session, user whoever is performing actions should not get any lock messages.

    But, I believe SAP would be providing this feature very soon as this is something being asked from long time.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.