Search code examples
oopabap

How can I define a filled structure/table as class constant in ABAP Objects


I want to have an immutable predefined table as class variable. How do I define such a variable?


Solution

  • This is an old question, with a simple answer: Just create a static method (getter) that returns constant data.

    Instead of using:

    data(ls_sample) = lcl_myclass=>cs_data.
    

    Use:

    data(ls_sample) = lcl_myclass=>cs_data( ).