‎2015 Sep 22 8:57 AM
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
‎2015 Sep 22 12:30 PM
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.
‎2015 Sep 22 11: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.
‎2015 Sep 22 12:19 PM
Hi,
my example type TBTCJOB_TT is already a DDIC defined table which is used in many SAP standard function modules like the one I'm using in my method JOB_GET_LIST().
The name of the function module is e.g. BP_JOB_SELECT that itself returns a table of type TBTCJOB_TT.
I'm using this result table and return it to the caller of my method without any modification. This means the content of this table contains many line with different status.
In order to filter one of those lines I thought about a kind of chaining that would safe some lines of coding. e.g. data(lt_aborted) = me->job_get_list( )[ status = 'A'] )
Michael
‎2015 Sep 22 6:46 PM
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.
‎2015 Sep 22 11: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
‎2015 Sep 22 12:23 PM
Stefan,
please see my answer above. The result type of my method is already a DDIC defined table type.
I just wanted to filter the method's result table without having to use an additional data declaration and that finally gets the method's result table.
In a further step I have to filter the result table, which can of course be done, with some further coding or as I tried before, using some table expressions and filter the method's result this way.
Michael
‎2015 Sep 22 12:37 PM
Dear Micheal,
As per my understanding, it's not possible to use your expression.
JOB_GET_LIST( )[ STATUS = 'A' ] ).
...
take the return parameter in local table and then use read statement .
Thanks
Nishant
‎2015 Sep 22 12:30 PM
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.
‎2015 Sep 22 1: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.
‎2015 Sep 22 3:33 PM
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