Wednesday, July 17, 2013

Posting trade agreements

Posting trade agreements is not a straightforward thing and i found it during a recent assignment. Trade agreements broadly revolve around three main tables, PriceDiscAdmTable, PriceDiscAdmTrans and PriceDiscTable and posting is handled via class PriceDiscAdmCheckPost.

So i create a journal header and fill the journal lines (details in another blog maybe) and call the below method to do the posting.

 void postTradeAgreement(PriceDiscAdmTable  _priceJourHeader)  
 {  
   PriceDiscAdmCheckPost    jourPost;  
   PriceDiscTable            tradeTable;  
   InfologData               infologData;  
   //Post  
   jourPost = new PriceDiscAdmCheckPost(false);  
   infologData = infolog.infologData();          // store infolog data  
   infolog.clear();                    // if you don't clear the infolog, posting errors out.  
   jourPost.initJournalNum(_priceJourHeader.JournalNum);  
   jourPost.run();  
   infolog.import(infologData);              // import infolog data  
 }  

See anything strange?
I do three things related to Infolog.
1. Store the contents. I am storing the contents of infolog (my logic needs to show info to user later) in a data type InfologData, which is a container.

2. Clear the infolog. If i dont clear the infolog just before i hit run() method to post, i get an error which makes no sense.

3. Import the infolog contents again.

Anybody knows a better way?

No comments:

Post a Comment