The workflow process moves purchase requisitions through the review process, from an initial status of Draft to a final status of Approved. When a purchase requisition is submitted for review, the workflow process is started. After a purchase requisition is approved, a purchase order can be generated for the purchase requisition lines and submitted to the vendor for order fulfillment.

We will use AIF standard service for import PR from outside, service name PurchReqImportService.

in AxPurchReqTable class and setPurchReqId() method

protected void setPurchReqId()
{
    NumberSequenceReference numberSequenceReference;

    if (this.isMethodExecuted(funcName()))
    {
        return;
    }

    if (this.isFieldSetExternally(fieldNum(PurchReqTable, PurchReqId)))
    {
        if (this.isSetMethodsCalledFromSave())
        {
            if (!this.purchReqTable())
            {
                numberSequenceReference = PurchReqTable::numRefPurchReqId();
                this.checkNumber(numberSequenceReference.numberSequenceTable(),fieldNum(PurchReqTable,PurchReqId),this.parmPurchReqId());
                if (numberSequenceReference.NumberSequenceId && numberSequenceReference.numberSequenceTable().Continuous)
                {
                    NumberSeq::newReserveNum(numberSequenceReference).reserve(this.parmPurchReqId());
                }
            }
        }
    }
    else
    {
        if (this.isFieldSet(fieldNum(PurchReqTable, PurchReqId)))
        {
            return;
        }

        if (!this.parmPurchReqId())
        {
            if (this.isSetMethodsCalledFromSave())
            {
                //this.parmPurchReqId(NumberSeq::newGetNum(PurchParameters::numRefPurchReqId()).num());
                numberSequenceReference = PurchReqTable::numRefPurchReqId();
                if(numberSequenceReference)
                {
                    this.setField(fieldNum(PurchReqTable, PurchReqId), NumberSeq::newGetNum(PurchParameters::numRefPurchReqId()).num());
                }
                else
                {
                    this.setField(fieldNum(PurchReqTable, PurchReqId), this.parmExternalSourceID());
                }
            }
        }
    }
}

Base on this method, you could know how System get PurchReqId.

How to do

Go to Inbound ports form to create new service with NETTCP adapter, choose service operations likes below:

Then active AIF inbound service

Consume Pruchase requisition service

Open visual studio and create new console project.

Add service reference

http://DEV-ERP:8101/DynamicsAx/Services/MavPurchaseRequisition

This one just for demo, so I just create code base on required fields of AIF.

Here is the code in main method

PurchReqImportServiceClient client = new PurchReqImportServiceClient();
CallContext context = new CallContext()
{
	Company = "BGR",
	Language = "En-us"
};

AxdEntity_PurchReqLine purchReqLine = new AxdEntity_PurchReqLine()
{
	Requisitioner = "000007",
	BuyingLegalEntity = "BGR",
	ItemId = "110329",
	PurchUnitOfMeasure = "Box",
	CurrencyCode = "KRW",
	PurchQty = 100,
	PurchQtySpecified = true,
	PriceUnit = 1,
	PriceUnitSpecified = true,
};

// Create an instance of the document class.
AxdEntity_PurchReqTable purchReqTable = new AxdEntity_PurchReqTable()
{
	PurchReqId = "",
	PurchReqName = "Purch Req by Max",
	ExternalSourceID = "PR002",
	ExternalSourceName = "PR002",
	AutoSubmitToWorkflowRequired = AxdEnum_NoYes.No,
	StatusToBeSaved = AxdEnum_PurchReqCreationStatus.Draft,
	RequisitionStatus = AxdEnum_PurchReqRequisitionStatus.Draft,
	RequisitionStatusSpecified = true,
	RequiredDate = new DateTime(2016, 12, 30),
	RequiredDateSpecified = true,
	TransDate = new DateTime(2016, 12, 30),
	TransDateSpecified = true,
	PurchReqLine = new AxdEntity_PurchReqLine[1] { purchReqLine }
};


// Create instances of the entities that are used in the service and
// set the needed fields on those entities.
AxdPurchReqImport purchReq = new AxdPurchReqImport()
{
	PurchReqTable = new AxdEntity_PurchReqTable[1] { purchReqTable }
};

try
{
	client.create(context, purchReq);
}
catch (Exception e)
{
	Console.WriteLine(e.ToString());
	Console.ReadLine();
}

Run it and check result in AX

Please prefer previous post for another operations

Thank you for reading!

In previous post, I already show how to create purchase order through AIF with NETTCP or HTTP adapter. In this post, we will get little deep more about action on line of order.

The following code sample shows how to insert, update, delete a line of an existing purchase order through AIF, currently I’m using C#.NET console project for demo.

As Partial update, we must include just the fields to change and any fields required by the document (you can check Data policies in AIF Service ports form for that).

Also, notice how action properties are specified – no matter we do with the line, which means updating the order.

I’m giving you an idea how it looks like, here is the code

The first method will handle the key of AIF Service

private static EntityKey[] EntityForPurchId(string purchId)
{
	KeyField field = new KeyField()
	{
		Field = "PurchId",
		Value = purchId
	};

	EntityKey key = new EntityKey()
	{
		KeyData = new[] { field }
	};

	return new[] { key };
}

create Line, delete Line, update line in Purchase order

EntityKey[] entityKeyList = EntityForPurchId("BGR-000054");

CallContext callContext = new CallContext();
callContext.Company = "bgr";

Mav_PurchOrderServiceServiceClient client = new Mav_PurchOrderServiceServiceClient();
AxdMav_PurchOrderService purchOrders = client.read(callContext, entityKeyList);

//Define which line need to be update or delete
var lastLine = purchOrders.PurchTable[0].PurchLine.Last();

var purchLine = new AxdEntity_PurchLine()
{
	ItemId = "110329",
	PurchQty = 1,
	CurrencyCode = "KRW",
	RecIdSpecified      = true,
	LineNumberSpecified = true,
	action              = AxdEnum_AxdEntityAction.create,
	actionSpecified     = true

	//for delete
	//RecId               = lastLine.RecId,
	//RecIdSpecified      = true,
	//action              = AxdEnum_AxdEntityAction.delete,
	//actionSpecified     = true

	//for Update
	//RecId               = lastLine.RecId,
	//RecIdSpecified      = true,
	//action              = AxdEnum_AxdEntityAction.update,
	//actionSpecified     = true
	
};

var purchTable = new AxdEntity_PurchTable()
{
	_DocumentHash = purchOrders.PurchTable[0]._DocumentHash,
	OrderAccount = "101-01-75441",
	LanguageId = "en-us",
	CurrencyCode = "KRW",
	PurchName = "AIF PO Test",
	action = AxdEnum_AxdEntityAction.update,
	actionSpecified = true,
	PurchLine = new[] { purchLine }
};

AxdMav_PurchOrderService purchOrder = new AxdMav_PurchOrderService()
{
	PurchTable = new AxdEntity_PurchTable[] {purchTable}
};


client.update(callContext, entityKeyList, purchOrder);

Thank you for reading!

Due to Purchase order doesn’t have Standard document service so we have to create new Document service for that using AIF wizards.

I’m using AIF document service with NETTCP or HTTP Adapter to Create Purchase order service, here is steps

Create Query

with three datasouce (PurchTable, PurchLine, InventDim) likes below

As best practice for Document service, name of query should be start with Axd* prefix.

Using AIF Wizards

In AX development environment, go to Tools > Wizards > AIF document service wizards

Choose recent created query and click next.

Create Service operation and AxBC class

Click next and then Generate.

You will get service project in Private project

Deploy and create service

• Right click on PurchOrderService > Add-Ins > Register service

• System administration > Setup > Services and AIF > Inbound ports

• Click New on Inbound ports form and name the Service.

• Adapter: NETTCP (it also works with HTTP adapter)

• In Service contract customizations fast tab click Service operations

Active recent created Service

Consume service using C#.NET

After service is activated, you can get WSDL URI likes

http://servername:port/DynamicsAx/Services/PurchaseOrder

Create console project and Add Service References, the code below

In Class, I will write method to return list of EnityKey PurchId

private static EntityKey[] EntityForPurchId(string purchId)
{
	KeyField field = new KeyField()
	{
		Field = "PurchId",
		Value = purchId
	};

	EntityKey key = new EntityKey()
	{
		KeyData = new[] { field }
	};

	return new[] { key };
}

Code for create purchase order

var dim = new AxdEntity_InventDim()
{
	InventSiteId = "DN",
	InventLocationId = "F10-S120",
	InventBatchId = "BATCH001"
};

var purchLine = new AxdEntity_PurchLine()
{
	ItemId = "220067",
	PurchQty = 15,
	PurchUnit=  "ea",

	InventDim = new AxdEntity_InventDim[] { dim }
};


var purchTable = new AxdEntity_PurchTable()
{
	OrderAccount = "101-01-75441",
	LanguageId = "en-us",
	CurrencyCode = "KRW",
	PurchName = "AIF PO Test",
	PurchLine = new AxdEntity_PurchLine[] { purchLine }

};

AxdMav_PurchOrderService purchOrder = new AxdMav_PurchOrderService();

purchOrder.PurchTable = new AxdEntity_PurchTable[] { purchTable };

CallContext callContext = new CallContext
{
	Company = "bgr",
	Language = "en-us"
};

Mav_PurchOrderServiceServiceClient client = new Mav_PurchOrderServiceServiceClient();

try
{
	EntityKey[] purchOrderCreatedEntity = client.create(callContext, purchOrder);
	EntityKey purchOrderCreated = (EntityKey)purchOrderCreatedEntity.GetValue(0);

	Console.WriteLine("The purch order created has a Purch ID of " + purchOrderCreated.KeyData[0].Value);
	Console.ReadLine();
}
catch (Exception e)
{
	Console.WriteLine(e.ToString());
	Console.ReadLine();
}

Code for read purchase order

EntityKey[] entityKeyList = EntityForPurchId("BGR-000054");

CallContext callContext      = new CallContext();
callContext.Company          = "bgr";
Mav_PurchOrderServiceServiceClient client = new Mav_PurchOrderServiceServiceClient();

AxdMav_PurchOrderService purchOrders = client.read(callContext, entityKeyList);
AxdEntity_PurchTable[] purchTables = purchOrders.PurchTable;
AxdEntity_PurchTable    purchTable = purchTables[0];
AxdEntity_PurchLine purchLine = purchTable.PurchLine[0];

Console.WriteLine("Purch Name: " + purchTable.PurchName);            
Console.WriteLine("Order Account: " + purchTable.OrderAccount);
Console.WriteLine("Language Id: " + purchTable.LanguageId);
Console.WriteLine("Qty: " + purchLine.PurchQty);
Console.WriteLine("Item Id: " + purchLine.ItemId);

client.Close();
Console.ReadLine();
			

Code for update purchase order

Mav_PurchOrderServiceServiceClient client = new Mav_PurchOrderServiceServiceClient();
CallContext callContext = new CallContext();
callContext.Company = "bgr";

EntityKey[] entityKeyList = EntityForPurchId("BGR-000078");
AxdMav_PurchOrderService purchOrders = client.read(callContext, entityKeyList);

//salesOrders.GetHashCode();
AxdEntity_PurchTable[] purchTables = purchOrders.PurchTable;
AxdEntity_PurchTable purchTable = new AxdEntity_PurchTable();
purchTable = purchTables.First();

//salesTable.GetHashCode();
AxdEntity_PurchLine purchLine = new AxdEntity_PurchLine();
purchLine = purchTable.PurchLine.First();

decimal purchQty = 20;
purchLine.PurchQty = purchQty;

try
{
	client.update(callContext, entityKeyList, purchOrders);
	EntityKey purchOrdersUpdated = (EntityKey)entityKeyList.GetValue(0);
	Console.WriteLine("The purchase order has been updated has a Purch ID of " + purchOrdersUpdated.KeyData[0].Value + " with Qty " + purchQty.ToString() + "");
	Console.ReadLine();
}
catch (Exception ex)
{
	Console.WriteLine(ex.ToString());
	Console.ReadLine();
}

Code for delete purchase order

Mav_PurchOrderServiceServiceClient client = new Mav_PurchOrderServiceServiceClient();
CallContext callContext = new CallContext();
callContext.Company = "bgr";

EntityKey[] entityKeyList = EntityForPurchId("BGR-000054");
try
{
	client.delete(callContext, entityKeyList);
	EntityKey purchOrdersDeleted = (EntityKey)entityKeyList.GetValue(0);
	Console.WriteLine("The purch order has been deleted has a purch ID of " + purchOrdersDeleted.KeyData[0].Value);
	Console.ReadLine();
}
catch (Exception ex)
{
	Console.WriteLine(ex.ToString());
	Console.ReadLine();
}

Thank you for reading!

Scenarios:

I’m trying to create product/master product in Dynamics AX using AIF inbound port, the AIF services consume by C#.NET.

From AX 2012 R2, Item is replaced with Product. Item master was in Inventory Management Module, now there is a separate module for item/product creation Product information Management.

Some definitions you should know There are two types of Products in 2012 they are:

  1. Product

    Product information management/Common/Products/Products

  2. Product Master

    Product information management/Common/Products/Products master

    a. Variants:

To create a product variant, you must define at least one product dimension for a product master. You can also rename dimensions. To create product variants, you must complete the following tasks:

  • Set up dimensions, such as size, color, and style.

  • Set up variant groups.

  • Assign variant groups to a retail hierarchy.

  • Create a product master and variants.

    b. Product dimensions

Product dimensions are characteristics that serve to identify a product variant. You can use combinations of product dimensions to define product variants. You must define at least one product dimension for a product master to create a product variant.

Process:

Normally in AX, we create items master follow process:

  • Create product/product master.

  • Assigning Dimensions Groups to a Product Master.

  • Create Product dimension combinations (Product Variants)

  • Release product to legal entities

  • Assigning Item Model Group & Item Groups to a Product Master

How to do:

Ax provides us standard services for this purpose, so we don’t need to create any custom services for this. I will use 4 services for this purpose, descriptions below

Service Purpose
EcoResProductService Create products (all types). The service can also be used to retrieve data that has already been created (Create Product details in The EcoRes tables).
EcoResProductMasterDimValueService Specify values of product dimensions for a product master. These values become available for the creation of product variants. The service can also be used to retrieve data that has already been created.
ItemService Release distinct products and product masters. The service can also be used to retrieve data that has already been created.
InventDimCombinationService Release product variants. The service can also be used to retrieve data that has already been created.

we have 4 steps

  1. Create 4 AIF inbound services against Services operation above and active it http://DEV-ERP:8103/DynamicsAx/Services/BCEcoResProduct http://DEV-ERP:8103/DynamicsAx/Services/BCEcoResProductMasterDimValue http://DEV-ERP:8103/DynamicsAx/Services/BCItemsMaster http://DEV-ERP:8103/DynamicsAx/Services/BCInventDimCombination

  2. After services creation, open visual studio then creates new Console project and add service References for that, you will get somethings like pic below:

  3. Using C#.Net to consume service

using ItemsMaster.ItemsRef;
using ItemsMaster.EcoResProductRef;
using ItemsMaster.EcoResProductMasterRef;
using ItemsMaster.InventDimRef;
static void Main(string[] args)
{
	Program master = new Program();
	master.createDistinctProduct();
	Program.releaseProduct();
}

EcoResProductServiceClient

public void createDistinctProduct()
{
	AxdEntity_Product_EcoResDistinctProduct distinctProduct = new AxdEntity_Product_EcoResDistinctProduct()
	{
		DisplayProductNumber = "MAX00002",
		ProductType = AxdEnum_EcoResProductType.Item,
		SearchName = "Max",
	   
	};

	distinctProduct.Translation = new AxdEntity_Translation[1];
	distinctProduct.Translation[0] = new AxdEntity_Translation()
	{
		LanguageId = "en-us",
		Name = "Max Nguyen"
	};

	distinctProduct.Identifier = new AxdEntity_Identifier[1];
	distinctProduct.Identifier[0] = new AxdEntity_Identifier()
	{
		ProductNumber = "MAX00002"
	};

	distinctProduct.StorageDimGroup = new AxdEntity_StorageDimGroup[1];
	distinctProduct.StorageDimGroup[0] = new AxdEntity_StorageDimGroup()
	{
		Product = "MAX00002",
		StorageDimensionGroup = "SW_P"
	};

	distinctProduct.TrackingDimGroup = new AxdEntity_TrackingDimGroup[1];
	distinctProduct.TrackingDimGroup[0] = new AxdEntity_TrackingDimGroup()
	{
		Product = "MAX00002",
		TrackingDimensionGroup = "Batch Only"
	};

	AxdEcoResProduct product = new AxdEcoResProduct()
	{
		Product = new AxdEntity_Product_EcoResProduct[1] { distinctProduct }
	};

	EcoResProductRef.CallContext EcoResProductSctx = new EcoResProductRef.CallContext()
	{
		Company = "bgr",
		Language = "en-us",
	};

	EcoResProductRef.EcoResProductServiceClient ecoResProductSClient = new EcoResProductRef.EcoResProductServiceClient();
	
	ecoResProductSClient.create(EcoResProductSctx, product);

}

EcoResProductServiceClient

public void createMaster()
{
	AxdEntity_Product_EcoResProductMaster productMaster = new AxdEntity_Product_EcoResProductMaster()
	{
		DisplayProductNumber = "MAX00002",
		ProductType = AxdEnum_EcoResProductType.Item,
		SearchName = "Max Nguyen"
	};

	productMaster.Translation = new AxdEntity_Translation[1];
	productMaster.Translation[0] = new AxdEntity_Translation()
	{
		LanguageId = "en-us",
		Name = "Max Nguyen"
	};

	productMaster.Identifier = new AxdEntity_Identifier[1];
	productMaster.Identifier[0] = new AxdEntity_Identifier()
	{
		ProductNumber = "MAX00002"
	};
	productMaster.ProductDimGroup = new AxdEntity_ProductDimGroup[1];
	productMaster.ProductDimGroup[0] = new AxdEntity_ProductDimGroup()
	{
		Product = "MAX00002",
		ProductDimensionGroup = "MAX10"
	};
	productMaster.VariantConfigurationTechnology = AxdEnum_EcoResVariantConfigurationTechnologyType.PredefinedVariants;

	AxdEcoResProduct axdProduct = new AxdEcoResProduct()
	{
		Product = new AxdEntity_Product_EcoResProduct[1] { productMaster }
	};

	EcoResProductRef.CallContext EcoResProductSctx = new EcoResProductRef.CallContext()
	{
		Company = "bgr",
		Language = "en-us",
	};

	EcoResProductRef.EcoResProductServiceClient ecoResProductSClient = new EcoResProductRef.EcoResProductServiceClient();
	
	ecoResProductSClient.create(EcoResProductSctx, axdProduct);

}

EcoResProductMasterDimValueServiceClient

static void createMasterDimensions()
{

	EcoResProductMasterRef.AxdEntity_EcoResSize ecoResSizeL = new EcoResProductMasterRef.AxdEntity_EcoResSize()
	{
		Name = "L"
	};

	EcoResProductMasterRef.AxdEntity_EcoResSize ecoResSizeM = new EcoResProductMasterRef.AxdEntity_EcoResSize()
	{
		Name = "M"
	};
	//master dimensions definition (two sizes, L and M)
	AxdEntity_MasterDim_EcoResProductMasterSize sizeDimensionL = new AxdEntity_MasterDim_EcoResProductMasterSize()
	{
		SizeProductMaster = "MAX00002",
		Size = "L",
		EcoResSize = new EcoResProductMasterRef.AxdEntity_EcoResSize[1] { ecoResSizeL }
	};
	AxdEntity_MasterDim_EcoResProductMasterSize sizeDimensionM = new AxdEntity_MasterDim_EcoResProductMasterSize()
	{
		SizeProductMaster = "MAX00002",
		Size = "M",
		EcoResSize = new EcoResProductMasterRef.AxdEntity_EcoResSize[1] { ecoResSizeM }

	};

	AxdEcoResProductMasterDimValue axdDimValue = new AxdEcoResProductMasterDimValue()
	{
		MasterDim = new AxdEntity_MasterDim_EcoResProductMasterDimensionValue[2] { sizeDimensionL, sizeDimensionM }
	};

	EcoResProductMasterRef.CallContext masterDimctx = new EcoResProductMasterRef.CallContext();
	EcoResProductMasterDimValueServiceClient masterDimensionService = new EcoResProductMasterDimValueServiceClient();
	try
	{
		masterDimensionService.create(masterDimctx, axdDimValue);
	}
	catch (Exception e)
	{
		System.Console.WriteLine(e.Message);
		System.Console.ReadKey();
	}
}

EcoResProductServiceClient

static void createVariant()
{
	//product variant definition
	AxdEntity_Product_EcoResDistinctProductVariant productVariant = new AxdEntity_Product_EcoResDistinctProductVariant()
	{
		DisplayProductNumber = "MAXL",
		ProductType = AxdEnum_EcoResProductType.Item,
		SearchName = "MAXL",
		ProductMaster = "MAX00002"
	};
	productVariant.Translation = new AxdEntity_Translation[1];
	productVariant.Translation[0] = new AxdEntity_Translation()
	{
		LanguageId = "en-us",
		Name = "Max L size"
	};
	productVariant.VariantDimValue = new AxdEntity_VariantDimValue_EcoResProductVariantDimensionValue[1];
	productVariant.VariantDimValue[0] = new AxdEntity_VariantDimValue_EcoResProductVariantSize()
	{
		DistinctProductVariant = "MAXL",
		ProductDimensionAttribute = 3173,//The ID of the EcoResSize table
		Size = "L",
		EcoResSize = new EcoResProductRef.AxdEntity_EcoResSize[1]
		{
			new EcoResProductRef.AxdEntity_EcoResSize() { Name = "L" }
		}
	};

	AxdEcoResProduct axdProduct = new AxdEcoResProduct()
	{
		Product = new AxdEntity_Product_EcoResProduct[1] { productVariant }
	};
	EcoResProductRef.CallContext inventDimctx = new EcoResProductRef.CallContext();
	EcoResProductServiceClient productService = new EcoResProductServiceClient();
	try
	{
		productService.create(inventDimctx, axdProduct);
	}
	catch (Exception e)
	{
		System.Console.WriteLine(e.Message);
		System.Console.ReadKey();
	}
}

this method can use to release a distinct product or a product master

public static void releaseProduct()
{
	var invent = new AxdEntity_Invent()
	{
		ItemId = "MAX00002",
		UnitId = "box"
	};

	var purch = new AxdEntity_Purch()
	{
		ItemId = "MAX00002",
		UnitId = "box"
	};

	var sales = new AxdEntity_Sales()
	{
		ItemId = "MAX00002",
		UnitId = "box"
	};

	var inventTable = new AxdEntity_InventTable()
	{
		ItemId = "MAX00002",
		PmfProductType = AxdEnum_PmfProductType.MainItem,
		Product = "MAX00002",
		Invent = new AxdEntity_Invent[] { invent },
		Purch = new AxdEntity_Purch[] { purch },
		Sales = new AxdEntity_Sales[] { sales },
		
	};

	var item = new AxdItem()
	{
		InventTable = new AxdEntity_InventTable[1] { inventTable }
	};

	ItemsRef.CallContext callContext = new ItemsRef.CallContext();
	ItemsRef.ItemServiceClient client = new ItemsRef.ItemServiceClient();

	callContext.Company = "bgr";
	callContext.Language = "en-us";

	try
	{
		ItemsRef.EntityKey[] itemCreatedEntity = client.create(callContext, item);
		ItemsRef.EntityKey itemCreated = (ItemsRef.EntityKey)itemCreatedEntity.GetValue(0);

		Console.WriteLine("AxdEntity_Invent " + itemCreated.KeyData[0].Value);
		Console.ReadLine();
	}
	catch (Exception e)
	{
		Console.WriteLine(e.ToString());
		Console.ReadLine();
	}
}

Release product Variants

static void releaseProductVariants()
{
	AxdEntity_InventDimCombination releasedVariant = new AxdEntity_InventDimCombination()
	{
		DistinctProductVariant = "MAX00002",
		ItemId = ""
	};

	AxdInventDimCombination inventDimCombination = new AxdInventDimCombination()
	{
		InventDimCombination = new AxdEntity_InventDimCombination[1] { releasedVariant }
	};

	InventDimRef.CallContext itemsctx = new InventDimRef.CallContext()
	{
		Company = "bgr",
		Language = "en-us"
	};
	InventDimCombinationServiceClient inventDimCombinationService = new InventDimCombinationServiceClient();
	try
	{
		inventDimCombinationService.create(itemsctx, inventDimCombination);
	}
	catch (Exception e)
	{
		System.Console.WriteLine(e.Message);
		System.Console.ReadKey();
	}
}

Just for example, in main I only create Distinct product and release it, but you can use another method to create master, variant, masterDim and so on.

4. Try to run it and here is a result

Thank you for reading and feel free to give me a question.

Base on JournalId on LedgerJournalTable you can use code below for posting into transactions

//Contract class
[
    DataMemberAttribute('gJournalId'),
    SysOperationDisplayOrderAttribute('1')
]
public LedgerJournalId parmJournalNum(LedgerJournalId _journalId = gJournalId)
{
    gJournalId = _journalId;

    return gJournalId;
}

//Processing class
[SysEntryPointAttribute]
public void process(MAV_PostCustPaymentJourContract _contract)
{
    LedgerJournalTable      ledgerJournalTable;
    LedgerJournalCheckPost  postCustPaymentJournal;

    ledgerJournalTable = LedgerJournalTable::find(_contract.parmJournalNum());
    if (ledgerJournalTable)
    {
        postCustPaymentJournal = LedgerJournalCheckPost::newLedgerJournalTable(ledgerJournalTable, NoYes::Yes);
        postCustPaymentJournal.run();
    }
}