Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

ABAP pointer typing for e.g. a linked list

Former Member
0 Kudos

does ABAP allow linked lists,
with forward declaration of typed pointers?

I tried like so:
>>

types: begin of t_elem1,
  kunnr type kunnr,
  next  type ref to t_elem1,
end of t_elem1.

<<
This gives Syntax Error: Type "T_ELEM1" is unknown
(at the penultimate line: "next type ref to t_elem1")

I guess it's a circular logic within this structure,
(which however worked in Pascal/C/Java, IIRC)

So I tried a logic like shown there:
https://archive.sap.com/discussions/thread/1512042
>>

types: begin of t_elem1,
  kunnr type kunnr,
  next  type ref to data,
end of t_elem1.

<<

disadvantage e.g. field "next" is not "upfront type-compatible" 😉
("full" Syntax-Checks won't be there, auto-filler in se80 missing, etc.)

Now, I got that idea:

with Unit-Testing "definition deferred" can be used
to solve a circular logic of classes referring to one another;
as discussed there:
https://archive.sap.com/discussions/thread/1458598

Is there some "forward typing" or "type deferred" thing, to get this going
with structures (like this), too?

types: begin of t_elem1,
  kunnr type kunnr,
  next  type ref to t_elem1,
end of t_elem1.

AHGA

1 REPLY 1

fabianlupa
Contributor