Home Dynamics Projects Dynamics Blogs Microsoft Watch Stem cells

 

 

Uploading journals

 

Import the xpo file for this project into version 3- SP3 system

Version 1:  (Do not use the above project)

Import the xpo file for this project into version 3- SP3 system

Though this project is for V3Sp3, you could use the concept for any system from Version 2.5 to Version3 SP4. 

bullet

Functionality

A lot of times you have some interface to Axapta and want to upload data from a text file and post the journals into Axapta.

For e.g.

"We are interfacing a Payroll system with Axapta. A text file will be generated from the Payroll system containing one line ledger a/c Dr. and 2nd line bank a/c cr.
But the journal number and Voucher number should be generated by Axapta."

What do you do in this case? Write a lot a lot and lot of code. For eg. creating ledger journal table, ledger journal trans, getting the journal number and voucher numbers, calling the code that posts the journal etc etc etc. That's a lot of code. Further, this code is not upgrade proof, something changes in the next version and you do not notice it, poofs your journal is being posted with the wrong data.

Do you know there is a simple way around?

Just run an instance of the form, hide the form from the user and manipulate it in the back ground. The zip file contains a txt file that has the following line

11005,2,11010

basically you want to post a line in journal debiting '11005' and crediting '11010'.

The zip file also has a xpo file containing a class and a menu item, import this into standard axapta, run the menu item, specify the file to be uploaded (the file mentioned above) and check the posted journals.

Now check the code in the xpo file, its unbelievably simple, there is not a lot of code and its upgrade proof.

cheers!

******************************************************

What follows is transcript of an email questioning the basics of this project and my answer to this email

My answer aptly describes the philosophy behind this site. Please do let me know if you do not agree with anything on my site.

******************************************************

Q. Why is this project not done through code and classes? Simply, it not the best of practices to load a form, hide it, and then manipulate the form. It's better to work with classes, and tables directly when doing such a task.

A. trust me, sometimes its better to do such upload thingys thru hidden forms.

The biggest advantage is that you do not have write a lot of code and it becomes completely upgrade proof.

Further, you are always sure that all the validations that are associated with the table are always performed. This is so because practically speaking you are emulating what a user does when he creates the journal manually.

I have upgraded about 20 Axapta systems so far and upgradeability for me has the highest priority than anything else.

Coming back to best practices. I always prefer to follow best practices, but you have to understand that best practices is something that is 100% applicable to code written by Microsoft. When it comes to partners, sometimes you have to deviate from best practices.

A partner never has enough testing resources. If you write the code as above then you have to do a lot less testing compared to the code that actually invokes the classes.

There is one more scenario where the code I have written will be applicable:

(I have actually written this code for someone). My client wanted real transfer journals between warehouses (not the instantaneous one in Axapta). In this case the only choice I had was to create a completely new module. But I used the 'hidden form' concept like this:

Create a new table with fromwarehouse - interimwarehouse - towarehouse - quantity

Create a new table holding two lines

1st line from warehouse - interimwarehouse - date of transfer

2nd line interimwarehouse - towarehouse - date of transfer

At this point of time I linked the two lines to normal inventory transfer journals (a separate journal for each line) and used hidden forms to emulate the functionality.

There was no way I could write an entire module for this functionality (from upgradeability point of view). But this way it was a piece of cake, 8 hours of programming and I could deliver exactly what the client wanted.

Last but not the least: I never expect that code on this site will go live, it is meant to give new direction in which one can think. I Hope it serves the purpose.

******************************************************

Version 1

******************************************************

I received a lot of emails asking me how to manipulate data in the table that is not returned via datasource() method on the form.

I also discovered a bug where the modified method on the field is not being called automatically. I remember fixing this issue long time back but somehow cannot get this done this time (do not have a lot of time to spend on this). However, I have fixed this issue in a round about way.

I also received an email asking me how to assign journal name if its not specified in the data being uploaded.Remember that you are emulating exactly what a user does if he creates a journal manually. So in this case give a dialog box to user asking him to select the journal.

Import this xpo file into v3s3 system with demo data. The project will create inventjournaltable and then inventjournaltrans (of type profit and loss). It will assign good old "B-R14 " , quantity of 10, warehouse "MW" and post the journal. 

Cheers!

 

 

Send mail to harry@systomatics.com with questions or comments about this web site.
Disclaimer: I am working with Microsoft Business Solutions. The code on this site may or may not be related to my official duties with Microsoft. I do not claim in any expertise in modules represented on this website. Essentially there is just one person doing functional specifications (in head), design specifications (in head), coding and some testing. There is no way the project on this site will be free of bugs. The projects are intended as guidelines and may god help you if you decide to implement the projects without making any changes. If you implement any project resulting into data corruption or anything like that then do not even think of suing me because a. I have already warned you and b. I don't have any money. I may or may not respond to your emails about supporting the project. I may or may not upgrade the projects to the next service pack / version.