Skip to Content
0

ABAP pointer typing for e.g. a linked list

Jul 14, 2017 at 09:01 AM

56

avatar image
Former Member

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Fabian Lupa Jul 14, 2017 at 10:12 AM
0
Share
10 |10000 characters needed characters left characters exceeded