Skip to Content

append returning lines

Hi ABAP-Experts,

i wonder if there is a better way of appending return lines to a internal table.
I have a lot of methods returning a bapiret2 tables and one main return table.

Everytime i call one of those methods i have to do this:

DATA: lt_return_temp type bapiret2_t.
lt_return_temp = zcl_class=>method().
APPEND LINES OF lt_return_temp TO rt_return.

Is there a way to write it more inline?

Something like that:

append lines of { fill_zdata( EXPORTING is_idoc_data = <s_idoc_data> CHANGING cs_customer = ls_customer ) } to rt_return.

Regards

Fabian

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Feb 28 at 02:19 PM
    data(messages) = thingy->do_stuff( ). 
    append lines of thingy->do_more_stuff( ) to messages. 
    Add comment
    10|10000 characters needed characters exceeded

  • Feb 28 at 03:52 PM

    The following should work:

    APPEND LINES OF zcl_class=>method( ) TO rt_return.

    But even better:

    rt_return = VALUE #( ( LINES OF zcl_class=>method( ) ) ).

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 01 at 01:19 PM

    THANKS.

    append lines of thingy->do_more_stuff()tomessages.

    or

    rt_return = value #( base rt_return ( lines of  zcl_class=>method( ) ) ).

    worked for me. (I thought i already tried "append lines of..". Sorry.)

    I think i should take a deeper look at "value #".

    Thank you all for your input and help.

    Regards

    Fabian

    Add comment
    10|10000 characters needed characters exceeded

    • No, there is no such thing in ABAP. It should be technically feasible to use a function in a writer position as an implicit receiver of whatever is being written to it. It's basically what an inline declaration does.

      Maybe it will happen one day, who knows what the boys and girls in Walldorf are cooking up...

  • Feb 28 at 01:00 PM
    -2

    This might not completely answer your question but you could start with changing it to an inline data declaration which saves you at least one line :)

    DATA(lt_return_temp) = zcl_class=>method().
    APPEND LINES OF lt_return_temp TO rt_return.

    Now for your append function, I don't think there is such an ABAP expression, but I could be wrong.

    Add comment
    10|10000 characters needed characters exceeded