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: 

"Fully-free" type using class pool enhancement, possible?

Sandra_Rossi
Active Contributor
0 Kudos

Hello,

I just realized that with an enhancement, you can't "compose" your own type in a standard class pool or interface pool.

You may only add a type which refers to another existing type.

For instance, you can't add a type defined like this:

TYPES zz_your_type TYPE TABLE OF zyour_db_table.

But you can add a type like this:

TYPES zz_your_type TYPE zyour_db_table.

I run ABAP 7.52 SP1.

To reproduce:

  • SE24 standard class
  • Click enhancement button
  • Add the type ZZ_YOUR_TYPE of type I (any type)
  • Click button "direct type entry" -> button ignored, no message (I expect the ABAP editor to be displayed s that I can enter directly the details)

Do you have the same behavior in your ABAP release?

What is the interest of defining a type as duplicate of another type? (the only interest I see is defining a short alias of a type from another class or interface)

If it's not possible then the only solution I can see is to define the type in a custom class pool or interface pool (or in the ABAP dictionary), and refer to it from the enhancement. Please confirm if you have the same opinion, or not.

Thanks.

Sandra

1 ACCEPTED SOLUTION

Tomas_Buryanek
Active Contributor

I could not reproduce the problem. I am able to create enhancement for standard class, and there create type:

TYPES zz_my_type TYPE TABLE OF mara.

And after that I activated the class/enhancement without a problem...

SAP_ABA 740 SP. 0016

Actually is the "zyour_db_table" in your example in DDIC or not?

-- Tomas --
6 REPLIES 6

former_member182550
Active Contributor

Your code implies that you are trying to create a table type for a table. You can only create table types from non-table types (if you see what I mean)...

Also, defined the 'type' that the table is - ANY, STANDARD, SORTED or HASHED.

ie.

TYPES zz_your_type TYPE HASHED TABLE OF zyour_db_STRUC

                   with Unique Key Key1, Key2.

Rich

0 Kudos

Thanks for the answer.

The question is not specific to table types, it's not about the syntax of types (sorry for misleading you). It could be with other syntax forms like TYPE LINE OF, BEGIN OF, etc.

The question is about how to create a non-trivial type in a class pool enhancement (category of enhancement option in the enhancement framework).

ADDENDUM: in fact I don't get you, "TYPES zz_your_type TYPE TABLE OF zyour_db_table" is a valid syntax, I think it means TYPE STANDARD TABLE.

Sandra_Rossi
Active Contributor
0 Kudos

The question is not specific to table types, and it's not about the syntax of TYPES. It could be with other non-trivial forms like TYPE LINE OF, BEGIN OF, etc.

So, the question is about how to create a non-trivial type in a class pool enhancement (category of enhancement option in the enhancement framework).

Tomas_Buryanek
Active Contributor

I could not reproduce the problem. I am able to create enhancement for standard class, and there create type:

TYPES zz_my_type TYPE TABLE OF mara.

And after that I activated the class/enhancement without a problem...

SAP_ABA 740 SP. 0016

Actually is the "zyour_db_table" in your example in DDIC or not?

-- Tomas --

Well well well ... I don't understand, now it works perfectly in my system. I guess I had a rare bug because of sequence of actions... (I had created an attribute, implicit enhancements at the start and end of methods, then added the type... but I had not restarted a new session to verify - Maybe it's also related to a mixed usage of ADT and SE80)

Thanks ! 🙂

(answer to your question: yes)

sandra.rossi glad I could help...
By testing this problem I encountered another problem 😐

WARNING - do not enhance this class or you will end up with same problem ...
I created Z enhancement implementation for CL_ABAP_CHAR_UTILITIES. But when I try to delete this enh.impl. it dumps on LOAD_PROGRAM_CLASS_MISMATCH, because in process of deleting enh.impl. the class interface is changed, but this same class is used while deleting... So it is kind of like dead-lock.

-- Tomas --