cancel
Showing results for 
Search instead for 
Did you mean: 

Reusing a Gateway DPC_EXT class in ABAP report / simulate via ABAP a call to gateway

SimoneMilesi
Active Contributor

Hi all,

i was pondering if it's possible to simulate via ABAP a call to a gateway service developed on the same system.

A little scenario

I created an OData service to create and update materials: it receive a JSON, retrieve a model material and copy it to create the new one.

This is working perfectly but, of course, it works one by one.


For an upcoming golive project, we have to create around 1000 materials and, one by one, can be a bit tricky, so i'm developing the classical ABAP report which reads an XLSX file and does the dirty job.

The issue/question

Yes, i can copy-and-paste the same methods of my OData service, but it would be a mess to keep updated the same code in two different places.
i can detach the original code, put into another class and call the class in the service and the report.

But i was wondering if it would be possible to invoke the service i already implemented, just paramter io_data_provider seems to be a bit tricky.

Anyone already tried it?

Accepted Solutions (1)

Accepted Solutions (1)

gregorw
Active Contributor
0 Kudos

se38 is absolutely right. Please check out https://grahamrobbo.github.io/building_gateway_services/ with sample code and presentation on this topic. But there is actually a way to call OData services inside the ABAP system: Automating OData Service Testing with the eCATT OData Assistant. But it's intend is for testing.

Answers (2)

Answers (2)

UweFetzer_se38
Active Contributor

You never should have business logic in the dpc_ext classes, always call external methods. If you refactor (outsource) the logic into a standalone class you have the solution for your current problem and a cleaner code for the future. Win win.

SimoneMilesi
Active Contributor
0 Kudos

Thanks both se38 and gregorw for your hints.
i agree, outsourcing code is the best option, but i was young and stupid, err.. young and not expert in OData when i wrote that code so i messed up a bit.

i can blame some wiki here around where the examples show how to put coding in the _dpc_ext class, but it's quite possible i misunderstood the whole examples since they refer all to standard BAPIs 🙂

Again, thanks a lot for the hints 🙂

gregorw
Active Contributor
0 Kudos

Hi Simone,

please link the wiki pages so we might correct them.

Thanks.

Gregor

SimoneMilesi
Active Contributor
0 Kudos

i cannot find the blog/wiki i used 2 years ago, but maybe they were just blogs and not official wiki like this or this where the logic (even if just for the read operation) are put directly in the _DPC_EXT class.

i'll do my best to find it again, but the laptop change doesn't help me