1

I have the following code snippet, that I would like to write in functional style :

 data(lt_es) = me->prepare_process_part_ztoa1( ).
 APPEND LINES OF me->prepare_process_part_protocol( ) to lt_es.

How to rewrite the code above in new ABAP 7.5?

1
  • Indeed, appending lines returned from one method to lines on second method of the same class is a bad architecture, this logic can be merged into single one Commented Jun 3, 2019 at 10:27

2 Answers 2

4

Use the LINES OF construct (available since ABAP 7.40 SP 8).

For instance, it could be something like this:

lt_es = VALUE #( BASE me->prepare_process_part_ztoa1( )
                 ( LINES OF me->prepare_process_part_protocol( ) ) ).

Whether it is better/simplier than the original, that's another question :)

Sign up to request clarification or add additional context in comments.

Comments

2

It can be also done without BASE. However one must specify the type explicitly (usage of # ends with a syntax error).

REPORT ZZZ.

DATA: lt_t1 TYPE string_table,
      lt_t2 TYPE string_table.

DATA(lt_t3) = VALUE string_table( ( LINES OF lt_t1 ) ( LINES OF lt_t2 ) ).

Would be interesting to know if this is maybe more performant than the usage of BASE if used in a loop for example.

1 Comment

See here. Seems like LINES OF really makes a copy, while BASE bascially is a move.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.