Adding more comments to SOP Documents

David Meego - Click for blog homepageIn 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: 

How to display more than four line item comments in the "SOP Blank Invoice Form" report in Sales Order Processing in Microsoft Dynamics GP (KB 951774) Secure Link

Which has now been moved to "How To" section of PartnerSource and CustomerSource:

How to Display More Than Four Line Item Comments in the "SOP Blank Invoice Form" Report in Sales Order Processing in Microsoft Dynamics GP Secure Link

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

  1. 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.
     
  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 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. 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.
     
  7. 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

  1. 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.
     
  2. Move the 4 existing Comment fields to the right of the report.
     
  3. Double Click on each of the 4 old Comment fields and set the Visibility to Invisible.
     
  4. Move the Yellow hidden Currency Index field out of the way, but make sure it says in the Report Footer Section
     
  5. 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).
     
  6. 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.
     
  7. 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: 

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