Common Implementations – GL Imports

Here is the code snippet:

public void Import(IEnumerable lines, DateTime postingDate)
{
	// TODO: To increase efficiency, comment out any unused DB links.
	using (HuAPConnection Connection = new HuAPConnection())
	using (HuView GLBCTL = Connection.GetView("GL0008"))
	using (HuView GLJEH = Connection.GetView("GL0006"))
	using (HuView GLJED = Connection.GetView("GL0010"))
	using (HuView GLJEDO = Connection.GetView("GL0402"))
	{
		GLBCTL.Compose(GLJEH);
		GLJEH.Compose(GLBCTL, GLJED);
		GLJED.Compose(GLJEH, GLJEDO);
		GLJEDO.Compose(GLJED);

		GLBCTL.RecordCreate(1);
		GLBCTL.Read();
		GLBCTL["PROCESSCMD"] = "1";  // Lock Batch Switch
		GLBCTL.Process();

		GLJEH["BTCHENTRY"] = "";  // Entry Number
		GLJEH.Browse("");
		GLJEH.Fetch();
		GLJEH["BTCHENTRY"] = "00000";  // Entry Number
		GLJEH.RecordCreate(2);
		GLJEH["SRCETYPE"] = "AP";  // Source Type
		GLJEH["DATEENTRY"] = postingDate;
		GLJED.RecordClear();

		foreach (DataLine line in lines)
		{
			GLJED.RecordCreate(0);
			GLJED["ACCTID"] = line.GLAccount;  // Account Number
			GLJED["PROCESSCMD"] = "0";  // Process switches
			GLJED.Process();
			GLJED["SCURNAMT"] = line.Amount;  // Source Currency Amount
			GLJED.Insert();
		}
		GLJEH.Insert();
	}
}

 

Explanation:

HLBCTL is journal entry batches

GLJEH is the header for the journal entry

GLJED is the line items for the journal

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s