‎2018 Apr 17 1:34 PM
Hi,
I'd like to define a recursive structure like
TYPES:
BEGIN OF st_assembly_element,
matnr TYPE matnr,
brkup TYPE c,
state TYPE icon_d,
" ...
pords TYPE STANDARD TABLE OF ebeln WITH DEFAULT KEY,
elems TYPE STANDARD TABLE OF st_assembly_element WITH DEFAULT KEY,
END OF st_assembly_element
.
Compiling this code leads to an "unknown type: st_assembly_element"-error.
Is there a way of forward declaration in ABAP (syntax required)?
How can I avoid this error (without using TYPE REF TO data)?
Regards,
Hubert
‎2018 Apr 17 3:52 PM
Even if the compiler allowed it, I would not do it.
You couldn't read it properly without some kind of dynamic referencing. And if we're going to do that then a hierarchical list is much easier to code, understand, and debug. If you want recursion, use objects; much neater.
‎2018 Apr 18 8:29 AM
Of course can I read it properly without some kind of dynamic referencing.
I need this data structure only in this special case, so I try to avoid the overhead of OO.
‎2018 Apr 18 8:38 AM
Sorry, bad phrasing. I meant dynamic processing or referencing. You will need some kind of looping or nested access methods.
I don't see OO as being significant overhead. Clarity / ease of use is a good tradeoff for a really minor performance hit. To me this screams out for OO 🙂
‎2018 Apr 17 4:05 PM
The "elems" should be just STANDARD TABLE of matnr in my opinion because this i the key for the next layer.
(standard in Bill of Materials [BOM])