Single-entity MVC
MPFormModel():New(); AddFields(); SetPrimaryKey()Defines a model for one dictionary table.
Overview
One entity is represented by a Field submodel created with AddFields. FWFormStruct(1,alias) supplies Model metadata; type 2 supplies View metadata. The community sample uses SBM, while this adaptation uses fictitious ZZ1 keyed by ZZ1_FILIAL+ZZ1_COD. The helper is a ModelDef sketch, not a complete application: it needs prepared SX2/SX3 and integration with ViewDef and actions. The demonstration does not invoke the block. (Sources: refs. 1–5.)
Syntax
MPFormModel():New(); AddFields(); SetPrimaryKey()Commented example
#Include "Protheus.ch"
#Include "FWMVCDef.ch"
User Function Ed553()
// Requires test dictionary ZZ1.
Local bBuild := {|| BuildModel()}
ConOut(ValType(bBuild))
Return Nil
Static Function BuildModel()
Local oModel := MPFormModel():New("ED553M")
Local oStruct := FWFormStruct(1,"ZZ1")
oModel:AddFields("ZZ1MASTER",Nil,oStruct)
oModel:SetPrimaryKey({"ZZ1_FILIAL","ZZ1_COD"})
Return oModelPrints B; the helper is not evaluated and creates/writes no tables. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.
- Verify field types/widths, primary key, relation and actual index before activation. Test validation, cancellation and persistence separately; the View must bind the correct submodel IDs.
- Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Comments
There are no approved comments yet.
Sign in with Google or Microsoft to comment.