en:ondemandreplication
Differences
This shows you the differences between two versions of the page.
— | en:ondemandreplication [2021/01/28 16:46] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | TitleEngTAG | ||
+ | |||
+ | |||
+ | |||
+ | < | ||
+ | |||
+ | With Sprinkler, developers can use the new "On Demand" | ||
+ | |||
+ | This feature will allow you to manage, for example, the following scenarios: | ||
+ | * The automatic data export is not active, but you just want to replicate one or more records in the target database. | ||
+ | * Before the activation of the automatic data export, you want to feed all the tables with current data (this operation was however already possible through manual [[AdvancedReplication|Advanced Replication Functionality]]) | ||
+ | * You want to build a test scenario with a series of predetermined data, and the operation must be repeatable. | ||
+ | * You have to archive one or more tables data on a historical database: for example, sale and purchase documents with related tables, with [Posting Date] lower than a specified date. | ||
+ | |||
+ | There is a public Function of [Spk Management] codeunit that allows you to reach the goal: | ||
+ | |||
+ | < | ||
+ | |||
+ | // | ||
+ | |||
+ | **Example** - You need to replicate to a remote historical database the data of tables [Sales Invoice Header], [Sales Invoice Line] and corresponding [G/L Entry] so you can navigate those documents correctly. All the documents with [Posting Date] up to 12/31/2016 must be copied. We suppose that the schema of all involved tables are identical in Source and Target Peer's databases. | ||
+ | |||
+ | Before to start, in the Target Peer you have to create the following Importing Setup for all [Sales Invoice Header], [Sales Invoice Line] and [G/L Entry] tables: this setup will be active in ~1 minute; the user declared as [Data Distribution Service User] on Target Peer must have Insert and Modify permission on destination table. No further setup are required on Source Peer, because this function will send ALL fields belonging to source table. | ||
+ | Of course, the user operating the following code must have the Permission Set EERIS SPK USER, and Read permissions on source table. | ||
+ | |||
+ | **Solution** - Create the following variables: | ||
+ | |||
+ | |||
+ | ^Name ^DataType ^SubType ^ | ||
+ | |SpkMgt |Codeunit |Spk Management | | ||
+ | |Peer |Record |Data Distrib. Peer | | ||
+ | |SalesInvHdr |Record |Sales Invoice Header | | ||
+ | |SalesInvLine |Record |Sales Invoice Line | | ||
+ | |GLEntry |Record |G/L Entry | | ||
+ | |||
+ | The code is: | ||
+ | |||
+ | < | ||
+ | LastDate := 311220D; | ||
+ | Peer.GET(' | ||
+ | |||
+ | SalesInvHdr.SETFILTER(" | ||
+ | IF SalesInvHdr.FINDSET THEN REPEAT | ||
+ | SpkMgt.Replicate_Record(SalesInvHdr, | ||
+ | |||
+ | SalesInvLine.SETRANGE(" | ||
+ | IF SalesInvLine.FINDSET THEN REPEAT | ||
+ | SpkMgt.Replicate_Record(SalesInvLine, | ||
+ | UNTIL SalesInvLine.NEXT = 0; | ||
+ | |||
+ | GLEntry.SETRANGE(" | ||
+ | GLEntry.SETRANGE(" | ||
+ | IF GLEntry.FINDSET THEN REPEAT | ||
+ | SpkMgt.Replicate_Record(GLEntry, | ||
+ | UNTIL GLEntry.NEXT = 0; | ||
+ | |||
+ | UNTIL SalesInvHdr.NEXT = 0; | ||
+ | |||
+ | </ | ||