"RPG400-L" <rpg400-l-bounces@xxxxxxxxxxxx> wrote on 09/15/2016 01:33:26 
PM:
A colleague of mine proposed to create a service program for each 
new table, implementing the CRUD functionalities in SQL. We would be
using the functions from the service program to access the files 
instead of native RPG I/O.
        This is basically the path we started down about three years ago. 
We create an MVC framework for our environment and all application 
development is using this model -- whether interactive or batch.  The 
framework is laid out as follows:
1.  VIEW -- is a DSPF DDS which is used by the operating system to 
management interface between a CONTROLLER and an interactive interface 
(whether it be green-screen or browser-based; and we are using the 
Profound Logic rich display file for the browser interface)
2.  CONTROLLER -- is an RPG LE, non-SQL program to manage the interface 
between an MVC service layer (for business logic) and the VIEW
3.  MVC Service Layer -- is an SQL RPG LE service program to apply 
business logic and support SELECT access (via SQL views, only) to manage 
the interface between the MODEL and the CONTROLLER
4.  MODEL -- is an SQL RPG LE DAO service program to support INSERT, 
UPDATE, and DELETE access to a single underlying SQL table (must be the 
physical file)
        Now, first let me say that I know many purists will object to 
splitting SELECT access off from the rest of the functions of the MODEL. 
But, that is just the way they decided to do it here.  They justified it 
based on restricting all SELECT access to SQL Views, only.  At least it 
gets the file I/O out of the CONTROLLER -- which is the biggest no-no in 
the MVC world.
        Anyway, to continue...  We allow CONTROLLERS to call CONTROLLERS 
but a CONTROLLER can only reference a single VIEW and a single MVC service 
layer.  The service layer can call oher service layers as needed but may 
only call a single DAO MODEL and no other service layer can call the same 
DAO MODEL.  To access other DAO MODELs a service layer must call the 
associated service layer.
        RPG-auto-generated data structures for either the display view, 
the SQL view, or the SQL table are passed by reference as parameters 
between the layers of the MVC framework.
Sincerely,
Dave Clark
As an Amazon Associate we earn from qualifying purchases.