DatasetModel
 

DatasetModel

5 posts, 1 answered
  1. Roger Blanchard
    Roger Blanchard avatar
    413 posts
    Registered:
    29 Jun 2018
    10 Jul 2018
    Link to this post
    What is the best way to handle importing an XML file on the client and creating records in the DB.

    Should I read in the XML and then send the entire dataset to the appserver via InvokeTask or InvokeMethod to process with the Datasetmodel

    OR

    Read in the XML and then scan through the TT on the client and use the Datasetmodel to create records in DB?

    I think either will work...just trying to use the most efficient way. 

    Thanks.
  2. Mike Fechner
    Mike Fechner avatar
    342 posts
    Registered:
    14 Sep 2016
    02 Aug 2018 in reply to Roger Blanchard
    Link to this post
    Does the XML match the ProDataset structure and is READ-XML enough to import the XML - or is there a significant amount of code required to transform the XML into records in the dataset?
  3. Roger Blanchard
    Roger Blanchard avatar
    413 posts
    Registered:
    29 Jun 2018
    24 Aug 2018 in reply to Mike Fechner
    Link to this post
    The XML matches the PDS perfectly and READ-XML is fine.
  4. Mike Fechner
    Mike Fechner avatar
    342 posts
    Registered:
    14 Sep 2016
    Answered
    18 Sep 2018
    Link to this post
    The requirement is importing of new records. Right? Not merging/updating existing ones?

    I'd import the XML file on the client into the ProDataset and send that using InvokeTask to a Business Task or InvokeMethod to a Business Entity Method. Then you'll have to turn on Tracking Changes:

    DatasetHelper:SetTrackingChanges (DATASET dsYourDataset:HANDLE, TRUE). 

    Then you'll have to loop through the records and mark them as ROW-CREATED. The records have the ROW-STATE of ROW-UNMODIFIED after the Read-XML.You can use the buffers MARK-ROW-STATE method for that:

    BUFFER eYourTable:MARK-ROW-STATE (ROW-CREATED).

    Then call SaveChanges of the Business Entity. 

    If merging of records is required, consider using the Consultingwerk.SmartFramework.Tools.Import.GenericDataImporter class. This is what we use when deploying the framework meta-data.

    This method allows merging new and updated data into a Business Entity. This method should be called from within a Business Task and not the Business Entity you're importing to:

        METHOD PUBLIC ImportResult ImportBusinessEntityData (pcBusinessEntityName AS CHARACTER,
                                                             phDatasetImport      AS HANDLE,
                                                             pcSkipFields         AS CHARACTER):





  5. Roger Blanchard
    Roger Blanchard avatar
    413 posts
    Registered:
    29 Jun 2018
    24 Oct 2018 in reply to Mike Fechner
    Link to this post
    Thanks Mike
5 posts, 1 answered