Skip to Content
0

ABAP OO Interface for DB Access

Feb 21 at 08:36 PM

175

avatar image
Former Member

Hello guys,

I'm searching for a best practice solution for accessing Z-Tables. My idea is to create an Interface for the CRUD operation, which can be used for all tables.

Maybe there is even a possibility to generate this class for new Z-Tables.

IF_DB_CRUD

create, update, delete, read

What about using "type ref to data" or "type data" as import/export structure?

And what about "mass" activities (deleting, creating several entries)?


Regards

Christopher

10 |10000 characters needed characters left characters exceeded

If this is "Christopher" then who is "Tanja Schipper"? I'm confused... Please be aware that profile sharing is frowned upon on SCN.

2
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Mike Pokraka Feb 21 at 09:25 PM
3

Ditto to Matthew’s answer. I have thought about it but don’t see much benefit. The added complication to make it generic negate the benefits - because now every developer is forced to use references or whatever. By hardcoding the IO parameters we make it easier for devs to just do a data(foo) = zcl_foo_db->read( ‘123’ ).

So explicit classes for me are a trade off in the developer’s favour. Persistent classes did a nice job of generating it for you, and I could also add object specific code in there, but they have sadly not kept up with the times.

Another idea is to go for BOPF. It’s a beastly framework but oh so versatile.

Show 2 Share
10 |10000 characters needed characters left characters exceeded

Not everybody gets access to BOPF.

0

I mentioned it already somewhere else, but IMHO there is a need for a more lightweight solution compared to BOPF.

1
Iftah Peretz
Feb 22 at 05:30 PM
0

Hi,

If you want a good point of reference, take a look at report adbc_demo.

Update: Please see the comments for constraints and caveats.

Show 7 Share
10 |10000 characters needed characters left characters exceeded

Hmm, this wasn't created for that ...

0

I agree, looking at it is enough to spot the difference, but why it is not a point of reference for CRUD operations as the OP asked?

0

Cause I have written that example to demo some capabilities of ADBC (in fact there's the same for EXEC SQL), but not for CRUD.

1

I think you switched demo_amdp and adbc_demo.

I do agree that adbc_demo aim is to show the ABAP database call interface API and not for CRUD, but I found that the OO structure of it includes Creation of rows (method insert_rows), Reading of rows (methods select_into*), Updating of rows (method update_rows) and Deleting rows (method delete_rows), so that's why I pointed at it in this context.

Nonetheless, if you feel it is misleading or out of place, just say the word and I'll delete the answer and comments and deactivate my account ;-)

0

Ah come on ...

If by chance the example hit something that can be called CRUD, so be it.

0

...deactivate account, and take up a career as lion tamer. ;-)

2
0
Matthew Billingham
Feb 21 at 08:45 PM
0

There was the persistence framework, but nowadays, I create a class for handling CRUD with the SQL in various methods. including those for mass operations.

Show 5 Share
10 |10000 characters needed characters left characters exceeded

I was just reading about this in the 2011 Thomas Jung's book "Next generation ABAP Development" (it was still too advanced for my old job in 7.01 version) and it seemed a bit heavy-handed to me. So are you saying we don't really need those persistent object classes anymore? Phew!

0
Jelena Perfiljeva

The name of the game is BOPF and its follow ups ...

0

I hope its follow ups are easier to work with...

1

MeToo

0

I too create custom global class to handle the SQL for my Z tables.

0