‎2009 Dec 16 4:51 PM
Hello all and Happy Holidays!
I've been looking at the Persistence Service and created a demo using PA0002 but then I tried using my own z-structure and hit a roadblock. Namely, where in all of the code that's generated do I put my logic to read from the database (or write, for that matter). I've searched high and low and I've found nothing to help point me to where this code should go.
Could someone point me in the right direction, please?
Many thanks.
‎2009 Dec 16 11:24 PM
Hi Steve,
the Online Help includes some samples at [http://help.sap.com/saphelp_nw70/helpdata/EN/d2/7849bbbec911d4b2e80050dadfb92b/frameset.htm]
Also there have been plenty of blogs and you can also check the wiki for examples of how to interact with the Persistent Object classes.
In re-reading your post you mention that you used your own structure. Does this indicate you have not yet created the database table(s)? If so, you need to do this manually because at the monent the system does not do this automatically for you.
Cheers
Graham Robbo
‎2009 Dec 17 2:19 PM
Graham:
Thank you for the link.
I'm not sure I follow you on the necessity of a new table. Ideally I'd like to have a structure that contains only the relevant fields from, say, PA0002 (rather than EVERY field which is the default if you use the table itself). I created this structure and created a PO from it; however, I can't tell where I'm supposed to go to change the DML (select, insert, update, delete, etc.). You obviously have to be able to do this as one of the options of the code generator is to allow you (the developer) to manually create the data access logic. It's the "where" that I'm having trouble with. All of the examples I've seen thus far use an underlying table rather than a structure.
‎2009 Dec 17 2:42 PM
When you use the Structure system changes DB operation settings to "manual implementation of the database access layer". You can find this setting in Persistent Representation screen. Select the Generator Setting option. When this checkbox is selected, you need to redefine SET and GET methods for your own logic.
Check this help:
http://help.sap.com/saphelp_nw04/helpdata/en/06/f23c46638d11d4966d00a0c94260a5/frameset.htm
Regards,
Naimesh Patel
‎2009 Dec 17 9:58 PM
Hi Steve,
I see what you mean. I think the documentation that Naimesh points to is what you are after.
Cheers
Graham Robbo
‎2009 Dec 18 3:03 PM
I created a Projection View named ZPV_PA0002 which contains all of the key fields from PA0002 as well as a few non-key fields. Next I created a persistence class in SE24 based upon this view. So far so good.
Now the code generated in the CB class does contain SELECT statements in the MAP_LOAD_FROM_DATABASE( ) method, for example. However, it's commented out and I'm not able to edit the CB class directly.
I did find that you could, in the CA class, highlight this method and click the "Redefine" button which will allow you to, well, redefine the code. However, I'm not sure which of the methods in CB that I'll need to redefine since there are many of them. I wish there was some type of roadmap that would help the developer identify those methods which he needs to redefine to implement the DAL.
Thanks again for everyone's help. I'm going to keep plugging along and when I find a solution I'll post it. In the meantime, if anyone comes across something please let me know.
Thanks to all and Happy Holidays.
‎2009 Dec 18 6:52 PM
Well, I've made some progress for anyone interested. I went into the generated CA class and redefined the following methods:
MAP_LOAD_FROM_DATABASE_KEY
Copied the code from this method in CB class and uncommented out the generated SQL Select. Not sure why it was generated commented-out but you cannot edit it in the CB class so you've no choice rather than to redefine in CA.
MAP_LOAD_FROM_DATABASE
Did the same thing here.
MAP_INITIALIZE_METADATA
And the same thing here as well.
To summarize, I did not do any coding - I just copied the generated code from CB, the key parts [relevant to the view] of which were commented out, and redefined the same methods in CA and uncommented out the code. It seems to be working.
Now I've no idea if that's proper but it works. If someone has a better practice I'd love to know it. Thanks.