Application Development and Automation 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: 
Read only

Error using Persistent Objects: attribute AGENT is unknown

Former Member
0 Likes
786

Hello,

I'm working through the excellent book NextGen ABAP, and have started experimenting with Persistent Objects.

One issue I've noticed so far is that you cannot map cluster tables into a persistent object. I was not going to confine myself to the example tables and classes in the book, but wanted to create a real world example, working with tables BKPF and BSEG. As you know, BSEG is a cluster table, and these can apparently not be used, neither "as is" or in a view. There may be a workaround here, but at least for the moment, for me, this is a somewhat serious limitation to using the persistent object technology as opposed to Open SQL.

But the thing that really bugs me is that I cannot seem to instanciate the agent class. Using the code snippet below (taken from the book and slightly modified to allow for access to BKPF), I get the annoying message "Field "AGENT" is unknown" when trying to compile:

REPORT ztst_test_persistent_objects.

DATA: l_agent_persistent TYPE REF TO zca_bkpf_persistent,

l_bkpf_obj TYPE REF TO zcl_bkpf_persistent,

l_objects TYPE ref to object.

TRY.

l_agent_persistent = zca_bkpf_persistent=>agent.

...

ENDTRY.

My classes are activated, but the desired static attribute AGENT is not visible in the ZCA_BKPF_PERSISTENT class. Should not this attribute have been created automatically?

I'm on WAS 6.40; on my Sneak Preview 2004s it worked (although with the book's example, as there's no BKPF in that system, unfortunately). Could the version explain what goes on? If so, what's the solution in 6.40 as opposed to 7.00?

Regards,

Trond

3 REPLIES 3
Read only

matt
Active Contributor
0 Likes
675

I've had a search, and I know that R/3 4.70 had the AGENT attribute, so what you're experiencing seems odd. But that's all I've found.

Read only

Former Member
0 Likes
675

I was able to code the attribute manually, but it should have been generated.

Another thing I've noticed is that you cannot (apparently) create a "singleton" in our 6.40 system, since trying to define a constructor as private doesn't work, even if the class is private.

Read only

uwe_schieferstein
Active Contributor
0 Likes
675

Hello Trond

I have done little work with persistent classes but I remember having similar problems like you. I believe it is a random problem with the class generation on older SAP releases.

My "Trial-and-Error" recommendation is to make a big change to the class (e.g. removing most of the mapped DB fields) in order to push a complete compilation of the classes which hopefully generates the agent as well.

Regards

Uwe