Feedback
Did this article resolve your question/issue?

   

Article

Can't map fields in DATA-SOURCE when using Business Entity

Information

 
TitleCan't map fields in DATA-SOURCE when using Business Entity
URL Namecan-t-map-fields-in-data-source-when-using-business-entity
Article Number000113947
EnvironmentProduct: OpenEdge
Version: 11.x
OS: All Supported Platforms
Question/Problem Description
Using the Business Entity for data access in an application and sometimes the fields in the target are differently named than the fields in the data-source (database table), however there is no means to do this exposed in the Business Entity template and inheritance.
 
Steps to Reproduce
Clarifying Information
Error Message
Defect/Enhancement NumberDefect ADAS-13636
Cause
This is a defect as this was never completely implemented.  An overload for AttachDataSource was created that allows passing an array of mapped fields, however this is not called by any ReadData overload.
 
Resolution
None at this time.
 
Workaround
Define an array variable/property at the class level to store field mappings for each buffer in the Business Entity. You only need one extent for this example.
DEFINE PROTECTED PROPERTY cMapping AS CHARACTER EXTENT 1 NO-UNDO
    GET.
    SET.
  • Define an override method for AttachDataSources to call AttachDataSources in SUPER, passing in the mapping. This will use the existing overload of AttachDataSources.
METHOD OVERRIDE PROTECTED VOID AttachDataSources( ):

    SUPER:AttachDataSources(cMapping).

END METHOD.
 
  • Create an overload of the ReadBe<table></table> method which includes the mapped fields and assign the mapped fields for each table to the cMapping array defined above.
    METHOD PUBLIC VOID ReadBeCust( INPUT pcFilter AS CHARACTER,
                                                                   INPUT pcFields AS CHARACTER,
                                                                   OUTPUT DATASET dsCustomer ):
        cMapping[1] = pcFields.
        SUPER:ReadData(pcFilter).
    
        RETURN.
    
    END METHOD.
    Attached is a set of example programs that demonstrate this using the Sports2000 database.  To use the attachment, connect to a copy of sports2000 and run test.p.  See beCust.cls for the code.
Notes
Last Modified Date1/17/2019 10:54 PM
Attachment 
Files 1. workaround.zip
Disclaimer The origins of the information on this site may be internal or external to Progress Software Corporation (“Progress”). Progress Software Corporation makes all reasonable efforts to verify this information. However, the information provided is for your information only. Progress Software Corporation makes no explicit or implied claims to the validity of this information.

Any sample code provided on this site is not supported under any Progress support program or service. The sample code is provided on an "AS IS" basis. Progress makes no warranties, express or implied, and disclaims all implied warranties including, without limitation, the implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample code is borne by the user. In no event shall Progress, its employees, or anyone else involved in the creation, production, or delivery of the code be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample code, even if Progress has been advised of the possibility of such damages.