dimanche 23 décembre 2018

ABAP OOP (patterns) - How to properly encapsulate granular RFCs into ABAP objects?

I hope it's not too basic or maybe too wide question but I have doubts to migrate from ABAP RFC functions to classes in a satisfactory way.

Let's say that I have an object "Sales Order" that has multiple properties like ID, description and also a list of "Items". Each item also has multiple properties including a list of "Serial Numbers". In my real scenario things are much more complicated but this is OK for the question.

I have a long list of RFC functions that do very specific things, for instance:

  • Get Sales Order (with option to get items or no...)
  • Update Sales Order Header
  • Update Sales Order Long Text
  • Update Sales Order Status
  • Copy Sales Order
  • Sales Order Item Add
  • Sales Order Item Serial Number Add
  • ...

Now I want to implement this using ABAP Objects, I still need to use RFCs (can be new ones) to expose the calls due to an old middleware. However I'm not sure how to create the classes properly. My first idea is to create only CRUD RFCs mapped to respective methods and force myself to create the necessary objects for that which in this case would be: SalesOrder, SalesOrderStatus, SalesOrderLongText, SalesOrderItem, SerialNumber. Then I still would have some special function like Sales Order Copy that may required to be static but I'm not sure. This one could be handled by the frontend with Read + Create, but it's not a good idea for performance reasons.

A second option I thought is to just use static methods, but then I don't see how I benefit from OOP.

Do you think my first approach is correct?

Aucun commentaire:

Enregistrer un commentaire