Skip to Content

Table Expressions for Method Return Parameter

Hi,

I wonder why I can't use table expression with return parameters.

For example: The method JOB_GET_LIST( ) returns a table of type TBTCJOB_TT.

Now I would like to find one or more lines in this table where its STATUS is aborted. Of course I could do this using two lines of code, however, I wanted to try this task with a single line of coding like this:

IF line_exists( me->JOB_GET_LIST( )[ STATUS = 'A' ] ).

...

ENDIF.

This does not work as expected, at least not this way. Maybe I can't use table expressions with method return parameters at all, right?

Thanks,

Michael

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    Posted on Sep 22, 2015 at 11:30 AM

    Michael Fritz wrote:

    (....)

    This does not work as expected, at least not this way. Maybe I can't use table expressions with method return parameters at all, right?

    Right.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 22, 2015 at 12:51 PM

    Well, you can use the return parameters of methods in iteration expressions. E.g. to fullfill your requirement you can do something like this.

    IF lines( VALUE tbtcjob_tt( FOR job IN job_get_list( )
    WHERE ( status = 'A' )
    ( job ) ) ) > 0.
    ENDIF.

    Ok, it's not one line but one expression. You can condense it into one line, but it won't improve readability. 😉

    Add a comment
    10|10000 characters needed characters exceeded

    • Christian,

      as usual 😉 this is a possible and correct solution.

      You know I do not really concern about readability, since I'm not only an ABAP rogrammer but C#, JS or Delphi developer, too, and I use those and much more confusing constructs every day 🤣

      Thanks,

      Michael

  • Posted on Sep 22, 2015 at 10:04 AM

    Hi Micheal,

    can you try the syntax

    lt_TBTCJOB TYPE TABLE OF TBTCJOB_TT

    lt_TBTCJOB = me-> JOB_GET_LIST( STATUS = 'A')

    IF lt_TBTCJOB is bound.


    //code here


    ENDIF.

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi,

      lt_aborted what u mentioned and lt_TBTCJOB are the same.I just gave data declaration.


      saving these line of code (checking together if condition and filling the internal table)won't be having such impact.


      also it will be much better if you use pattern for calling method,since the other Abaper will have ease when working on it later.

  • Posted on Sep 22, 2015 at 10:40 AM

    Hi,

    for example you can define a table type in SE11 and refer to it as type in the method-table parameter.

    or you can define a class-type and refer to it via "type"

    you have to use type "tabletype"

    you can no longer use "type table of" when working with abap-oo

    regards

    Stefan Seeburger

    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.