Adding more comment lines to POP Purchase Orders
Just recently, I was asked by a customer to address an issue with their line item comments truncating at 4 lines. In essence, the customer wanted the ability to print more than 4 lines of comments at the line item level on their purchase orders.
My customer happens to be in the Nuclear Waste Management industry, and as it turns out, they have strict requirements to provide contract information, start/end dates, and a number of regulatory and compliance information on purchase orders. Some of this information is very critical to the transportation of certain products on United States highways. So as you can imagine, the request for additional comment lines was critical.
The following shows an example of what the customer was facing:
As you can see, the comments are printing only 4 lines and truncating the rest of the text.
Before going into the details, they are a few articles that guided me through the solution:
How to Display More Than Four Line Item Comments in the "SOP Blank Invoice Form" Report in Sales Order Processing in Microsoft Dynamics GP
Adding more comments to SOP Documents (Developing for Dynamics GP)
Of course, these articles refer to SOP, but the underlying techniques used in them will allow us to make the necessary changes to the report. This blog post should be used in conjunction with the How To article above to provide some additional steps to get the best result for making the changes to the POP Purchase Order report.
Background
Comments for Purchase Order Processing (POP) transactions are entered using a text field which allows for a maximum of 500 characters, as shown above. When the comments are saved, the text field is divided into 4 string fields of 50 characters each, which is printed on the report. The code that parses the text field into the 4 string fields is smart enough to avoid splitting a word oddly. The code will fit as many words as it can up to the last space before the 50 character mark or up to a carriage return (new line). When the POP documents are printed, it is these 4 comment string fields which are printed on the report. This means that if you use carriage returns or type a comment longer than 180-200 characters, you are unlikely to see all of your comment text shown on the report.
If you look at a POP document report, such as the POP Purchase Order Blank Form, you will see that the 4 comment lines are printed using 4 additional footer sections.
Looking at each of these additional sections (Tools > Section Options), you will see that each one is configured to be Suppressed when the appropriate 'sSuppressCommentX' calculated field is empty. The 'sSuppressCommentX' calculated field is defined to look at the comment string array report field and return an empty string or the actual comment to be printed on that footer. The reason for all this complexity is so that the space for the comment line strings is only taken up when there is actually a comment line to display. If this technique with additional footers with conditional suppression was not used, there would be 4 lines between every POP line item whether it was used or not - not an efficient use of already cramped space.
Solution
The solution is to use the RW_POPLINECommentText user-defined Report Writer function in the system series in a set of calculated fields. The same recommendations apply as with the SOP article above, this is, making each line the maximum 80 characters supported by Report Writer strings and creating 8 lines. This gives the potential for 640 characters and so should easily be able to display the 500 characters of comment text (even without breaking words in half or additional carriage returns).
Why 8 lines? This is so we can place two lines on each of the 4 additional footer sections. If we update the suppression logic correctly, it will mean there will only be the possibility of one blank line between SOP line items. With only 4 section breaks, we can only print 0, 2, 4, 6 or 8 lines at a time, so if there are actually an odd number of lines to be printed, there will be one blank line printed. If there are an even number of lines, then there will be no blank line.
For an explanation on why not using additional footers instead, see Adding more comments to SOP Documents over at Developing for Dynamics GP.
The parameters for the RW_POPLINECommentText function are as follows:
RW_POPLINECommentText()
Implementation
The steps below assume some knowledge of Report Writer. If you need detailed step by step instructions please look at the How to document.
Line Comments
1. Create 8 calculated fields of result type string for the 8 Line level comment lines:
(C) Line 1 Comments = FUNCTION_SCRIPT( RW_POPLINECommentText POP_PO.PO Type POP_PO.PO Number popPOLineRollupTemp.Ord 80 1 )
(C) Line 2 Comments = FUNCTION_SCRIPT( RW_POPLINECommentText POP_PO.PO Type POP_PO.PO Number popPOLineRollupTemp.Ord 80 2 )
(C) Line 3 Comments = FUNCTION_SCRIPT( RW_POPLINECommentText POP_PO.PO Type POP_PO.PO Number popPOLineRollupTemp.Ord 80 3 )
(C) Line 4 Comments = FUNCTION_SCRIPT( RW_POPLINECommentText POP_PO.PO Type POP_PO.PO Number popPOLineRollupTemp.Ord 80 4 )
(C) Line 5 Comments = FUNCTION_SCRIPT( RW_POPLINECommentText POP_PO.PO Type POP_PO.PO Number popPOLineRollupTemp.Ord 80 5 )
(C) Line 6 Comments = FUNCTION_SCRIPT( RW_POPLINECommentText POP_PO.PO Type POP_PO.PO Number popPOLineRollupTemp.Ord 80 6 )
(C) Line 7 Comments = FUNCTION_SCRIPT( RW_POPLINECommentText POP_PO.PO Type POP_PO.PO Number popPOLineRollupTemp.Ord 80 7 )
(C) Line 8 Comments = FUNCTION_SCRIPT( RW_POPLINECommentText POP_PO.PO Type POP_PO.PO Number popPOLineRollupTemp.Ord 80 8 )
Note: The only difference for each calculated field is the line number in the field name and the line number constant as the last parameter.
2. Expand each of the comment additional footers to 2 lines height.
3. Move the 4 existing Comment fields to the right of the report.
4. Double Click on each of the 4 old Comment array fields and set the Visibility to Invisible.
5. From Calculated Fields drag out the 8 new calculated fields placing two fields in each section. Drag out the field width as desired (at least 370).
6. The 4 sSuppressCommentX calculated fields will need to be changed to conditional fields and the return type changed to Integer, as shown:
sSuppressComment1 = F6_LAST (C) Line 1 Comments = "" AND F6_LAST (C) Line 2 Comments = ""
sSuppressComment2 = F5_LAST (C) Line 3 Comments = "" AND F5_LAST (C) Line 4 Comments = ""
sSuppressComment3 = F4_LAST (C) Line 5 Comments = "" AND F4_LAST (C) Line 6 Comments = ""
sSuppressComment4 = F3_LAST (C) Line 7 Comments = "" AND F3_LAST (C) Line 8 Comments = ""
After all these changes, it's time to save the report and test:
Now we can see the full line item comment displays nicely on the report.
Downloads
You can download the package file for this customization here.
Until next post!
MG.-
Mariano Gomez, MVP
IntellPartners, LLC
http://www.IntellPartners.com/
Purchasing Comment Entry window and POP Purchase Order Blank form |
POP Purchase Order Blank Form Report Writer Layout showing 4 footers (F3 - F6) |
function returns string OUT_string; in integer IN_Type; { POP Type of Document } in string IN_Number; { POP Number of Document } in long IN_Ord; { Ord Number of Line } in integer IN_characters; { Number of Characters per Line } in integer IN_line; { Line Number to Return }
Line Comments
1. Create 8 calculated fields of result type string for the 8 Line level comment lines:
(C) Line 1 Comments = FUNCTION_SCRIPT( RW_POPLINECommentText POP_PO.PO Type POP_PO.PO Number popPOLineRollupTemp.Ord 80 1 )
(C) Line 2 Comments = FUNCTION_SCRIPT( RW_POPLINECommentText POP_PO.PO Type POP_PO.PO Number popPOLineRollupTemp.Ord 80 2 )
(C) Line 3 Comments = FUNCTION_SCRIPT( RW_POPLINECommentText POP_PO.PO Type POP_PO.PO Number popPOLineRollupTemp.Ord 80 3 )
(C) Line 4 Comments = FUNCTION_SCRIPT( RW_POPLINECommentText POP_PO.PO Type POP_PO.PO Number popPOLineRollupTemp.Ord 80 4 )
(C) Line 5 Comments = FUNCTION_SCRIPT( RW_POPLINECommentText POP_PO.PO Type POP_PO.PO Number popPOLineRollupTemp.Ord 80 5 )
(C) Line 6 Comments = FUNCTION_SCRIPT( RW_POPLINECommentText POP_PO.PO Type POP_PO.PO Number popPOLineRollupTemp.Ord 80 6 )
(C) Line 7 Comments = FUNCTION_SCRIPT( RW_POPLINECommentText POP_PO.PO Type POP_PO.PO Number popPOLineRollupTemp.Ord 80 7 )
(C) Line 8 Comments = FUNCTION_SCRIPT( RW_POPLINECommentText POP_PO.PO Type POP_PO.PO Number popPOLineRollupTemp.Ord 80 8 )
Note: The only difference for each calculated field is the line number in the field name and the line number constant as the last parameter.
2. Expand each of the comment additional footers to 2 lines height.
3. Move the 4 existing Comment fields to the right of the report.
4. Double Click on each of the 4 old Comment array fields and set the Visibility to Invisible.
Comment Footers and Invisible Fields |
Calculated fields on footer sections |
6. The 4 sSuppressCommentX calculated fields will need to be changed to conditional fields and the return type changed to Integer, as shown:
Calculated Field definition |
sSuppressComment1 = F6_LAST (C) Line 1 Comments = "" AND F6_LAST (C) Line 2 Comments = ""
sSuppressComment2 = F5_LAST (C) Line 3 Comments = "" AND F5_LAST (C) Line 4 Comments = ""
sSuppressComment3 = F4_LAST (C) Line 5 Comments = "" AND F4_LAST (C) Line 6 Comments = ""
sSuppressComment4 = F3_LAST (C) Line 7 Comments = "" AND F3_LAST (C) Line 8 Comments = ""
After all these changes, it's time to save the report and test:
Purchase Order Blank Form |
Downloads
You can download the package file for this customization here.
POPBlankFormExtendedNotes.zip |
Until next post!
MG.-
Mariano Gomez, MVP
IntellPartners, LLC
http://www.IntellPartners.com/
Comments
Great article. I've always looked to VBA for this sort of thing but it's nice to get a guide on how to do it with Report Writer functions.
One thing; your download link 404s.
Ian
I have added a link to my SOP post to this post.
http://blogs.msdn.com/b/developingfordynamicsgp/archive/2011/02/02/adding-more-comments-to-sop-documents.aspx
David
http://blogs.msdn.com/DevelopingForDynamicsGP/
I have added a link from my SOP Document post to this one.
http://blogs.msdn.com/b/developingfordynamicsgp/archive/2011/02/02/adding-more-comments-to-sop-documents.aspx
David
http://blogs.msdn.com/DevelopingForDynamicsGP/
Much thanks for the kind words. If you click on the image you will get 404. If you click on the caption under the image, it will allow you to download the file... go figure.
MG.-
Mariano Gomez, MVP
Great Article - One question. I was doing some testing on this and using both "Standard" and "Drop-Ship" type PO Documents and this was only working for "Standard" types. After digging into the data I realized that the DOCTYPE field in the POP10550 table was not matching the DOCTPYE field in the POP10110 table. The POP10550 always had a DOCTYPE of "1". I edited the various Line Comment calculation fields and hard-coded the "POP_PO.PO Type" to an integer of 1 and that made it work for both Standard and Drop-Ship type documents. Anyone else see this happening?
point of purchase displays
MG.-
Thanks for posting this, it helped me solve an issue for a client that required a larger comment area per line.
Scott
How does this set up translate over into a Word Template? I've tried it but what happens is, for example, when there are 8 comment lines only Line 1, 3, 5 and 7 display on the Word Template. Any thoughts?
Alex Smyth
FMT Consultants, LLC
if i am typing 4 lines in the comment id .its takes first two line (3 rd and 4 th lines are not displaying).when we type 5 line in the comment id .all the lines are displaying .any one come across this . pls help.
Never mind that I can't make any changes while the system is in use for fear of corrupting the reports database, even minor changes require incredibly arcane tomfoolery such as described in this page. A fine article with very useful information, don't get me wrong, but yikes, what a nightmare of a system.
Every time I do something with GP it's like I'm transported back to 1998. I still can't believe this is a real product.
Thanks!
This is a great post. Both you and David have thoroughly covered this topic. I have already been able to deploy this at several customers and internally as well to help with the invoicing.
I am currently working on a Project and we are creating an SSRS report that we would like to be able to pull these extra Calculated fields onto. I am trying to find where SQL stores these newly created Calculated fields from Report Writer. I have been able to find the big Text field CMMTTEXT in the SY04200 and the SOP10202 tables and am wondering IF SQL actaully stores these new fields in separate fields within a table.
Do you have any suggestions on where I may find these or grab them to appear on an SSRS report?
Thank you for your time.
David Sirois
Thanks for the kind words. Unfortunately, these fields are only Report Writer calculated fields and are not stored in a table. Technically (and literally) speaking, the fields are stored in the Reports.dic dictionary file, but not the data. In SSRS, you supposed to be able to pull the actual comment field and set the field property to word wrap.
Here's a good example on how to do that:
http://www.sqlrelease.com/text-wrapping-in-ssrs-reports-in-reportviewer-control
This article has been extremely helpful. I'm trying to increase the character count in the Purchasing Line Comments. I'm a newbie to Report Writer. Your "How to" Link sends me to SOP which is not relevant for me. So I've a few questions as follows:
1) Am I supposed to be using the Report Table: Purchasing Comment?
2) How do I create a calculated field?
3) Do I click New in the Header or the Footer of the Report Section Options Window
I forgot to mention that I'm using GP2016R2.
I have a third question, I'm assuming that I need to check the checkbox, "suppress when field is empty" But when I do so, I'm prompted to select a calculated field. And there's where I nee d your assistance to create a calculated field.
I must first direct you to the Report Writer manual, Chapter 7: Creating Calculated Fields for more information as I cannot possibly provide all the steps here.
Also, I am not sure what you mean by "increasing he character count". Report Writer is limited to 80 characters for string and string calculated fields.
I believe your "Suppress when field is empty" will depend on the calculated field first. Please read the chapter on creating calculated fields and if you have further questions I will be happy to assist.