You can use the instructions in this topic to build the COBOL sample. Alternatively, you can import the completed DFDL schemas, application, and library for the sample.
This sample uses an application and a library to contain the sample artifacts. First create the Library:
A library is created, named COBOLLibrary, and is shown in the Broker Development view.
Now that you have created the library, create the application:
An application is created, named COBOLApplication, and is shown in the Broker Development view.
This section describes how to create the DFDL schema files used in this sample, by importing COBOL copybooks. Save the following COBOL copybooks into your workspace:
To create a DFDL schema file for each of these COBOL copybooks:
The DFDL schema file is created (file extension .xsd), and is displayed in the Schema Definitions folder of your library, COBOLLibrary. Repeat these steps for each of the three COBOL copybooks.
Before the DFDL schema files OrderList.xsd and PurchaseData.xsd can be used in this sample, you must add discriminators to each of the choice elements.
To add the required discriminators to OrderList.xsd:
To add the required discriminators to PurchaseData.xsd:
You should now have three DFDL schema files, which look like this:
At this point you can test your DFDL schema files by running a test parse of the sample data, see Testing a DFDL schema by parsing test input data.
To create the OrderList2PurchaseData message flow that is used in this sample.
Node | Page | Property | Value |
---|---|---|---|
MQInput | Basic | Queue name | ORDERLIST.IN1 |
Input Message Parsing | Message domain | DFDL | |
Input Message Parsing | Message model | OrderList.xsd | |
Input Message Parsing | Message | {}OrderList.xsd | |
MQInput | Basic | Queue name | XMLORDERLIST.IN1 |
Input Message Parsing | Message domain | XMLNSC | |
Input Message Parsing | Message model | OrderList.xsd | |
MQOutput | Basic | Queue name |
PURCHASEDATA.OUT1 |
CREATE COMPUTE MODULE OrderList2PurchaseData_Compute CREATE FUNCTION Main() RETURNS BOOLEAN BEGIN CALL CopyMessageHeaders(); SET OutputRoot.DFDL.PurchaseData.InvoiceCount = InputRoot.DFDL.OrderList.InvoiceCount; SET OutputRoot.DFDL.PurchaseData.ItemCount = InputRoot.DFDL.OrderList.ItemCount; DECLARE TotalQuantity INTEGER 0; DECLARE I INTEGER 1; DECLARE J INTEGER; SET J = CARDINALITY(InputRoot.DFDL.OrderList.SaleList.Invoice[]); WHILE I <= J DO SET OutputRoot.DFDL.PurchaseData.SaleList.Invoice[I].CustomerInitial[1] = InputRoot.DFDL.OrderList.SaleList.Invoice[I].InvoiceHeader.CustomerInitial[1]; SET OutputRoot.DFDL.PurchaseData.SaleList.Invoice[I].CustomerInitial[2] = InputRoot.DFDL.OrderList.SaleList.Invoice[I].InvoiceHeader.CustomerInitial[2]; SET OutputRoot.DFDL.PurchaseData.SaleList.Invoice[I].Surname = InputRoot.DFDL.OrderList.SaleList.Invoice[I].InvoiceHeader.Surname; DECLARE K INTEGER 1; DECLARE L INTEGER; SET L = CARDINALITY(InputRoot.DFDL.OrderList.SaleList.Invoice[I].Items.Item[]); WHILE K <= L DO DECLARE OutputItem ROW; SET OutputItem = THE ( SELECT Inv.ItemType , Inv.ItemCode , Inv.Description , Inv.Price , Inv.Category , It.Quantity FROM InputRoot.DFDL.OrderList.SaleList.Invoice[I].Items.Item[K] AS It , InputRoot.DFDL.OrderList.Inventory.Item[] AS Inv WHERE Inv.ItemCode = It.ItemCode AND Inv.ItemCode = InputRoot.DFDL.OrderList.SaleList.Invoice[I].Items.Item[K].ItemCode ); IF OutputItem.ItemType = '1' THEN SET OutputRoot.DFDL.PurchaseData.SaleList.Invoice[I].Items[K].ItemType = OutputItem.ItemType; SET OutputRoot.DFDL.PurchaseData.SaleList.Invoice[I].Items[K].Item1.ItemCode = 'AA';--OutputItem.ItemCode; SET OutputRoot.DFDL.PurchaseData.SaleList.Invoice[I].Items[K].Item1.Price = OutputItem.Price; SET OutputRoot.DFDL.PurchaseData.SaleList.Invoice[I].Items[K].Item1.Description = OutputItem.Description; SET OutputRoot.DFDL.PurchaseData.SaleList.Invoice[I].Items[K].Item1.Category = OutputItem.Category; SET OutputRoot.DFDL.PurchaseData.SaleList.Invoice[I].Items[K].Item1.Quantity = OutputItem.Quantity; ELSE SET OutputRoot.DFDL.PurchaseData.SaleList.Invoice[I].Items[K].ItemType = OutputItem.ItemType; SET OutputRoot.DFDL.PurchaseData.SaleList.Invoice[I].Items[K].Item2.ItemCode = OutputItem.ItemCode; SET OutputRoot.DFDL.PurchaseData.SaleList.Invoice[I].Items[K].Item2.Price = OutputItem.Price; SET OutputRoot.DFDL.PurchaseData.SaleList.Invoice[I].Items[K].Item2.Colour = OutputItem.Description; SET OutputRoot.DFDL.PurchaseData.SaleList.Invoice[I].Items[K].Item2.Quantity = OutputItem.Quantity; END IF; SET TotalQuantity = TotalQuantity + OutputItem.Quantity; SET K = K + 1; END WHILE; SET I = I + 1; END WHILE; --Trailer SET OutputRoot.DFDL.PurchaseData.Trailer.TotalQuantity = TotalQuantity; IF EXISTS(InputRoot.DFDL.OrderList.PointOfSale1[]) THEN SET OutputRoot.DFDL.PurchaseData.Trailer.PointOfSaleType = '1'; ELSE SET OutputRoot.DFDL.PurchaseData.Trailer.PointOfSaleType = '2'; END IF; RETURN TRUE; END; CREATE PROCEDURE CopyMessageHeaders() BEGIN DECLARE I INTEGER 1; DECLARE J INTEGER; SET J = CARDINALITY(InputRoot.*[]); WHILE I < J DO SET OutputRoot.*[I] = InputRoot.*[I]; SET I = I + 1; END WHILE; END; END MODULE;
To create the Redefine message flow that is used in this sample.
Node | Page | Property | Value |
---|---|---|---|
MQInput | Basic | Queue name | BINARYADDR.IN1 |
Input Message Parsing | Message domain | DFDL | |
Input Message Parsing | Message model | CustomerAddress.xsd | |
Input Message Parsing | Message | {}CustomerAddress.xsd | |
MQOutput | Basic | Queue name |
XMLADDR.OUT1 |
CREATE COMPUTE MODULE RedefineAddr_Compute CREATE FUNCTION Main() RETURNS BOOLEAN BEGIN CALL CopyMessageHeaders(); SET OutputRoot.XMLNSC = InputRoot.DFDL; RETURN TRUE; END; CREATE PROCEDURE CopyMessageHeaders() BEGIN DECLARE I INTEGER 1; DECLARE J INTEGER; SET J = CARDINALITY(InputRoot.*[]); WHILE I < J DO SET OutputRoot.*[I] = InputRoot.*[I]; SET I = I + 1; END WHILE; END; END MODULE;
To deploy your application, drag the application, COBOLApplication onto the execution group to which you want to deploy it. A BAR file is generated automatically, and deployed to the broker.
This sample provides some example test data for all three scenarios. They are OrderList.bin, OrderListLogicalInstance.xml and TestInputAddress1.bin located in the library, COBOLLibrary.
For information on how to use the Test Client, see Test Client Overview.