public void log(String... entries) {
Arrays.asList(entries).forEach(System.out::println);
}
// Using an array as the actual parameter
String[] entries = {"Log entry one", "Log entry two", "Log entry three"};
log(entries);
// Using varargs
log("Log entry one", "Log entry two", "Log entry three");
CLASS lcl_logger DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
log IMPORTING iv_text TYPE string,
log_table IMPORTING it_entries TYPE stringtab.
ENDCLASS.
CLASS lcl_logger IMPLEMENTATION.
METHOD log.
WRITE: / iv_text.
ENDMETHOD.
METHOD log_table.
LOOP AT it_entries ASSIGNING FIELD-SYMBOL(<lv_text>).
log( <lv_text> ).
ENDLOOP.
ENDMETHOD.
ENDCLASS.
log_table
-call is not too bad, as you can just initialize the internal table inline using the VALUE
statement, like this:log_table( VALUE #( ( `Log entry one` ) ( `Log entry two` ) ( `Log entry three` ) ) ).
log_table
-method at all. I have never seen it in any ABAP code until I recently randomly saw a code section in an ABAP book where a chained statement was used in a functional method call, which I did not even know was possible. With that you could do something like this:log(:
`Log entry one` ),
`Log entry two` ),
`Log entry three`
).
CL_SALV_TREE
-methods. One can argue if it increases or decreases readability and maintainability.mo_object_tree->get_columns( )->get_column(:
'OBJECTNAME' )->set_visible( abap_false ),
'COMPONENT' )->set_visible( abap_false ),
'COMPONENTTYPE' )->set_visible( abap_false ),
'PARENTCOMPONENT' )->set_visible( abap_false )
.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
5 | |
4 | |
3 | |
3 | |
2 | |
2 | |
2 | |
1 | |
1 | |
1 |