Adding more comments to SOP Documents
In keeping with my recent theme of Microsoft Dynamics GP Report Writer related articles, I thought I would post an example of how to get more comment lines showing a SOP Document. This is a follow on from the Working with Text fields in Report Writer post.
There was a Knowledge Base (KB) article on this topic:
Which has now been moved to "How To" section of PartnerSource and CustomerSource:
While the How To article is good, there are some techniques not covered in the article which can be used when increasing the number of comment lines beyond the 4 line mark. This blog post should be used in conjunction with the How To article to provide some additional steps to get the best result for your customised report.
Background
Comments for Sales Order Processing (SOP) transactions are entered using a text field which allows for a maximum of 500 characters. When the comments are saved, the text field is broken down into 4 string fields of 50 characters each. The code that parses the text field into the 4 string fields is smart enough to avoid breaking words in half. It 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 SOP 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 SOP document report, such as the SOP Blank Invoice 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 '(C) Suppress Comment X' calculated field is empty. The '(C) Suppress Comment X' calculated field is defined to look at the comment string field on the report and return 0 (empty) when the comment string is "" (empty). 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 SOP line item whether it was used or not.
As discussed in the Working with Text fields in Report Writer post, we can't have automatically resizing text fields on a graphics report, so how can we increase the number of comment lines displayed while not adding large chunks of blank space to the report when the comments are not used?
Solution
The solution is to use the RW_SOPLINECommentText user defined report writer function in the system series in a set of calculated fields. I recommend making each line the maximum 80 characters 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 with not 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.
You might ask (as Mariano did): "Why not create 4 additional footers, so that each comment line can have its own section?". Well, the problem here is that there are no additional fields that can be used as a break field to add an additional footer. The Component Sequence and Break Field 1, Break Field 2, & Break Field 3 are all used for the 4 existing additional footers.
We will also create a similar 8 lines of 80 characters for the document level comments to demonstrate the use of the RW_SOPHDRCommentText report writer function.
The parameters for the RW_SOPLINECommentText report writer function are:
in integer IN_Type; { SOP Type of Document }
in string IN_Number; { SOP Number of Document }
in long IN_LineItem; { Line Item Sequence of Line }
in long IN_Component; { Component Sequence of Line }
in integer IN_characters; { Number of Characters per Line }
in integer IN_line; { Line Number to Return }
The parameters for the RW_SOPHDRCommentText report writer function are:
in integer IN_Type; { SOP Type of Document }
in string IN_Number; { SOP Number of Document }
in integer IN_characters; { Number of Characters per Line }
in integer IN_line; { Line Number to Return }
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.
PART A: Line Comments
- Create 8 calculated fields of result type string for the 8 Line level comment lines:
(c) Line Comments 1 = FUNCTION_SCRIPT( RW_SOPLINECommentText SOP_LINE_WORK.SOP Type SOP_LINE_WORK.SOP Number SOP_LINE WORK.Line Item Sequence SOP_LINE_WORK.Component Sequence 80 1 )
(c) Line Comments 2 = FUNCTION_SCRIPT( RW_SOPLINECommentText SOP_LINE_WORK.SOP Type SOP_LINE_WORK.SOP Number SOP_LINE WORK.Line Item Sequence SOP_LINE_WORK.Component Sequence 80 2 )
(c) Line Comments 3 = FUNCTION_SCRIPT( RW_SOPLINECommentText SOP_LINE_WORK.SOP Type SOP_LINE_WORK.SOP Number SOP_LINE WORK.Line Item Sequence SOP_LINE_WORK.Component Sequence 80 3 )
(c) Line Comments 4 = FUNCTION_SCRIPT( RW_SOPLINECommentText SOP_LINE_WORK.SOP Type SOP_LINE_WORK.SOP Number SOP_LINE WORK.Line Item Sequence SOP_LINE_WORK.Component Sequence 80 4 )
(c) Line Comments 5 = FUNCTION_SCRIPT( RW_SOPLINECommentText SOP_LINE_WORK.SOP Type SOP_LINE_WORK.SOP Number SOP_LINE WORK.Line Item Sequence SOP_LINE_WORK.Component Sequence 80 5 )
(c) Line Comments 6 = FUNCTION_SCRIPT( RW_SOPLINECommentText SOP_LINE_WORK.SOP Type SOP_LINE_WORK.SOP Number SOP_LINE WORK.Line Item Sequence SOP_LINE_WORK.Component Sequence 80 6 )
(c) Line Comments 7 = FUNCTION_SCRIPT( RW_SOPLINECommentText SOP_LINE_WORK.SOP Type SOP_LINE_WORK.SOP Number SOP_LINE WORK.Line Item Sequence SOP_LINE_WORK.Component Sequence 80 7 )
(c) Line Comments 8 = FUNCTION_SCRIPT( RW_SOPLINECommentText SOP_LINE_WORK.SOP Type SOP_LINE_WORK.SOP Number SOP_LINE WORK.Line Item Sequence SOP_LINE_WORK.Component Sequence 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.
Unsupported Bit: if you add the first of the 8 calculated fields needed, then export the report as a package from Customisation Maintenance, you can then edit the package with notepad.exe can duplicate the field 7 times, changing the name and the line number. Then import the modified package back into the system and return to report writer.
- Expand each of the comment additional footers to 2 lines height.
- Move the 4 existing Comment fields to the right of the report.
- Double Click on each of the 4 old Comment fields and set the Visibility to Invisible.
- 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).
- Select one of the old Comment fields, then shift or control click on the 8 new comment fields to select them. Press Ctrl-D and then press Enter. This will format the 8 new fields to match the old ones. While the fields are selected use the Arrange tab in the Toolbox and select Size To shortest.
- Edit the 4 (C) Suppress Comment X calculated Fields to change the Conditional Expression, leave the True and False Expressions as they are:
(C) Suppress Comment 1 = F5_LAST (c) Line Comments 1 = "" AND F5_LAST (c) Line Comments 2 = ""
(C) Suppress Comment 2 = F4_LAST (c) Line Comments 3 = "" AND F4_LAST (c) Line Comments 4 = ""
(C) Suppress Comment 3 = F3_LAST (c) Line Comments 5 = "" AND F3_LAST (c) Line Comments 6 = ""
(C) Suppress Comment 4 = F2_LAST (c) Line Comments 7 = "" AND F2_LAST (c) Line Comments 8 = ""
PART B: Header Comments
- Create 8 calculated fields of result type string for the 8 Document level comment lines:
(c) Header Comments 1 = FUNCTION_SCRIPT( RW_SOPHDRCommentText SOP_HDR_WORK.SOP Type SOP_HDR_WORK.SOP Number 80 1 )
(c) Header Comments 2 = FUNCTION_SCRIPT( RW_SOPHDRCommentText SOP_HDR_WORK.SOP Type SOP_HDR_WORK.SOP Number 80 2 )
(c) Header Comments 3 = FUNCTION_SCRIPT( RW_SOPHDRCommentText SOP_HDR_WORK.SOP Type SOP_HDR_WORK.SOP Number 80 3 )
(c) Header Comments 4 = FUNCTION_SCRIPT( RW_SOPHDRCommentText SOP_HDR_WORK.SOP Type SOP_HDR_WORK.SOP Number 80 4 )
(c) Header Comments 5 = FUNCTION_SCRIPT( RW_SOPHDRCommentText SOP_HDR_WORK.SOP Type SOP_HDR_WORK.SOP Number 80 5 )
(c) Header Comments 6 = FUNCTION_SCRIPT( RW_SOPHDRCommentText SOP_HDR_WORK.SOP Type SOP_HDR_WORK.SOP Number 80 6 )
(c) Header Comments 7 = FUNCTION_SCRIPT( RW_SOPHDRCommentText SOP_HDR_WORK.SOP Type SOP_HDR_WORK.SOP Number 80 7 )
(c) Header Comments 8 = FUNCTION_SCRIPT( RW_SOPHDRCommentText SOP_HDR_WORK.SOP Type SOP_HDR_WORK.SOP Number 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.
Unsupported Bit: if you add the first of the 8 calculated fields needed, then export the report as a package from Customisation Maintenance, you can then edit the package with notepad.exe can duplicate the field 7 times, changing the name and the line number. Then import the modified package back into the system and return to report writer.
- Move the 4 existing Comment fields to the right of the report.
- Double Click on each of the 4 old Comment fields and set the Visibility to Invisible.
- Move the Yellow hidden Currency Index field out of the way, but make sure it says in the Report Footer Section
- From Calculated Fields drag out the 8 new calculated fields into the Report Footer section. Drag out the field width as desired (at least 370).
- Select one of the old Comment fields, then shift or control click on the 8 new comment fields to select them. Press Ctrl-D and then press Enter. This will format the 8 new fields to match the old ones. While the fields are selected use the Arrange tab in the Toolbox and select Size To shortest.
- Adjust vertical position of the 8 comment lines as needed.
Below is a screenshot of what the Report Writer layout window looks like after the changes were made:
And here is a screenshot of the Report Writer screen output with 8 line comments and 8 header comments:
The package for this customisation for Microsoft Dynamics GP 2010 is attached to the bottom of this post.
For more information have a look at the following posts:
- Working with Text fields in Report Writer
- Using the built-in Report Writer Functions
- The Dynamics GP Blogster: Adding more comment lines to POP Purchase Orders
- How to display more than four line item comments in the SOP Blank Invoice Word Template
Hope you find this information useful.
David
17-May-2012: Added Link to Mariano's article on adding more comment lines to POP Documents.
12-Sep-2012: Added Link to Andy's article on adding more comments to the associated Word Template.
19-Feb-2014: Fixed typo on Suppress Comment 4 line in article.
SOPBlankInvoiceForm_Comments.zip
Comments
Anonymous
February 02, 2011
David, This is such a complete and easy to understand post! Thank you for taking the time to be so complete. You have helped countless people out there. It always pleases me to see articles about the true flexibility of Report Writer. Now that it is used as the engine for the .XML files used by the Word templates, the world is going to be taking a closer look at our old friend 'Report Writer' LeslieAnonymous
February 06, 2011
Posting from Mark Polino at DynamicAccounting.net msdynamicsgp.blogspot.com/.../adding-more-comments-to-sop-documents.htmlAnonymous
February 07, 2011
I have a client right now that is struggling on how he can add additional lines to the bottom of his BOL and I can see that if we were to add a Comment ID to the Document this could solve all of his text problems. Thank you David. I found it very easy to follow your instructions. SheilaAnonymous
February 07, 2011
The comment has been removedAnonymous
May 16, 2012
Posting by Mariano Gomez, The Dynamics GP Blogster dynamicsgpblogster.blogspot.com.au/.../adding-more-comment-lines-to-pop.htmlAnonymous
May 16, 2012
Posting from Vaidy Mohan at Dynamics GP - Learn & Discuss vaidymohan.com/.../adding-more-comment-lines-to-pop-purchase-order-marianoAnonymous
February 18, 2014
The comment has been removedAnonymous
February 18, 2014
The comment has been removedAnonymous
February 20, 2014
No problem Dave, only caught it since I was actually trying to do it! I appreciate your great blog!Anonymous
November 16, 2014
Very nice, I tried and worked fine with me, but the comments are not printing on packing slip, any solution please.Anonymous
August 03, 2015
Hi David, Thank you for your wonderful post! I have downloaded the zip and imported the modified form. I have found that after doing so, the left and right margins are not equal. I have tried this on several printers, and it doesn't seem to be related to the printer. I would like to see if anyone else has had this problem with the modified form? Thanks! LaurieAnonymous
August 06, 2015
Hi Laurie It is possible that the package I created was from an Australian install and so would be formatted for A4. This would make the width narrower and the length longer. If that is the case, look at the changes I made and then remake them to your US Letter format. Thanks DavidAnonymous
December 15, 2015
The comment has been removedAnonymous
July 25, 2016
Thank you for posting this SOP text and document solution. I tried it and works well. If you are using Magento then these steps help.- Anonymous
July 25, 2016
Hi MarkGlad you found the post helpful.David
- Anonymous