CaptionClass Function Code

Microsoft Dynamics Nav 2009

This topic explains the function code of CaptionClass. For more information about CaptionClass syntax, see CaptionClass Syntax.

DimCaptionClassTranslate (ID 7)

After CaptionClassTranslate has sifted the contents of the CaptionClass property (passed in the CAPTIONEXPR parameter) in a CAPTIONAREA and a CAPTIONREF, DimCaptionClassTranslate will be called (if CAPTIONAREA equals 1). It passes the Language ID and the CAPTIONREF part of the CaptionClass property.

This function can be split into three main parts:

  1. Collect the General Ledger Setup data, if not already collected.

  2. Sift out the comma-separated subparts of the CAPTIONREF (see the previous description of the CAPTIONREF syntax.)

  3. Determine what the caption should be, depending on the DIMCAPTIONTYPE and DIMCAPTIONREF.

DimCaptionClassTranslate(Language : Integer;CaptionExpr : Text[80]) : Text[80]
//Begin (1) 
IF NOT GLSetupRead THEN BEGIN
IF NOT GLSetup.GET THEN
EXIT(");
GLSetupRead := TRUE;
//End (1) 
END;

// Begin (2) 
CommaPosition := STRPOS(CaptionExpr,',');
IF (CommaPosition > 0) THEN BEGIN
  DimCaptionType := COPYSTR(CaptionExpr,1,CommaPosition - 1);
  DimCaptionRef := COPYSTR(CaptionExpr,CommaPosition + 1);
  CommaPosition := STRPOS(DimCaptionRef,',');
IF (CommaPosition > 0) THEN BEGIN
  DimOptionalParam1 := COPYSTR(DimCaptionRef,CommaPosition + 1);
  DimCaptionRef := COPYSTR(DimCaptionRef,1,CommaPosition - 1);
  CommaPosition := STRPOS(DimOptionalParam1,',');
IF (CommaPosition > 0) THEN BEGIN
  DimOptionalParam2 := COPYSTR(DimOptionalParam1,CommaPosition + 1);
  DimOptionalParam1 := COPYSTR(DimOptionalParam1,1,CommaPosition - 1);
END ELSE BEGIN
  DimOptionalParam2 := ";
 END;
END ELSE BEGIN
  DimOptionalParam1 := ";
DimOptionalParam2 := ";
// End (2) 
END;

CASE DimCaptionType OF
// Begin (3) 
// Code Caption - Global Dimension using No. as Reference.
'1': 
BEGIN
 CASE DimCaptionRef OF
 '1':
  BEGIN
   IF Dim.GET(GLSetup."Global Dimension 1 Code") THEN
    EXIT(DimOptionalParam1 + Dim.GetMLCodeCaption(Language) +      DimOptionalParam2)
   ELSE
    EXIT(
     DimOptionalParam1 +
     GLSetup.FIELDCAPTION("Global Dimension 1 Code") +
     DimOptionalParam2);
  END;
 '2':
  BEGIN
   // Same as case '1' for field "Global Dimension 2 Code").
  END;
 END;
END;
 // Code Caption - Shortcut Dimension using No. as Reference.
 '2': 
  BEGIN
   CASE DimCaptionRef OF
    '1':
     BEGIN
      IF Dim.GET(GLSetup."Shortcut Dimension 1 Code") THEN
       EXIT(DimOptionalParam1 + Dim.GetMLCodeCaption(Language) +    DimOptionalParam2)
      ELSE
       EXIT(
        DimOptionalParam1 +
        GLSetup.FIELDCAPTION("Shortcut Dimension 1 Code") +
        DimOptionalParam2);
     END;
    '2':
     BEGIN
      // Same as case '1' for field "Shortcut Dimension 2 Code".
     END;
    '3':
     BEGIN
      // Same as case '1' for field "Shortcut Dimension 3 Code".
     END;
    '4':
     BEGIN
      // Same as case '1' for field "Shortcut Dimension 4 Code".
     END;
    '5':   
     BEGIN
      // Same as case '1' for field "Shortcut Dimension 5 Code".
     END;
    '6':
     BEGIN
      // Same as case '1' for field "Shortcut Dimension 6 Code".
     END;
    '7':
     BEGIN
      // Same as case '1' for field "Shortcut Dimension 7 Code".
     END;
    '8':
     BEGIN
      // Same as case '1' for field "Shortcut Dimension 8 Code".
     END;
    END;
  END;
 // Filter Caption - Global Dimension using No. as Reference.
 '3': 
  BEGIN
   CASE DimCaptionRef OF
    '1':
     BEGIN
      IF Dim.GET(GLSetup."Global Dimension 1 Code") THEN
       EXIT(DimOptionalParam1 + Dim.GetMLFilterCaption(Language) + DimOptionalParam2)
      ELSE
       EXIT(
        DimOptionalParam1 +
        GLSetup.FIELDCAPTION("Global Dimension 1 Code") +
        DimOptionalParam2);
     END;
    '2':
     BEGIN
      // Same as case '1' for field "Global Dimension 2 Code").
     END;
   END;
  END;
 // Filter Caption - Shortcut Dimension using No. as Reference.
 '4': 
  BEGIN
   CASE DimCaptionRef OF
    '1':
     BEGIN
      IF Dim.GET(GLSetup."Shortcut Dimension 1 Code") THEN
       EXIT(DimOptionalParam1 + Dim.GetMLFilterCaption(Language) + DimOptionalParam2)
      ELSE
       EXIT(
        DimOptionalParam1 +
        GLSetup.FIELDCAPTION("Shortcut Dimension 1 Code") +
        DimOptionalParam2);
     END;
    '2':
     BEGIN
      // Same as case '1' for field "Shortcut Dimension 2 Code".
     END;
    '3':
     BEGIN
      // Same as case '1' for field "Shortcut Dimension 3 Code".
     END;
    '4':
     BEGIN
      // Same as case '1' for field "Shortcut Dimension 4 Code".
     END;
    '5':
     BEGIN
      // Same as case '1' for field "Shortcut Dimension 5 Code".
     END;
    '6':
     BEGIN
      // Same as case '1' for field "Shortcut Dimension 6 Code".
     END;
    '7':
     BEGIN
      // Same as case '1' for field "Shortcut Dimension 7 Code".
     END;
    '8':
     BEGIN
      // Same as case '1' for field "Shortcut Dimension 8 Code".
     END;
  END;
END;
// Code Caption - using Dimension Code as Reference.
'5': 
 BEGIN
  IF Dim.GET(DimCaptionRef) THEN
   EXIT(DimOptionalParam1 + Dim.GetMLCodeCaption(Language) + DimOptionalParam2)
  ELSE
   EXIT(DimOptionalParam1);
 END;
'6': // Filter Caption - using Dimension Code as Reference.
 BEGIN
  IF Dim.GET(DimCaptionRef) THEN
   EXIT(DimOptionalParam1 + Dim.GetMLFilterCaption(Language) + DimOptionalParam2)
  ELSE
   EXIT(DimOptionalParam1);
  END;
// End (3) 
 END;
END;
EXIT(");

VATCaptionClassTranslate (ID 9)

If CAPTIONAREA equals 2, CaptionClassTranslate passes the CAPTIONEXPR parameter CAPTIONREF, which is actually the VATCAPTIONTYPE, and calls VATCaptionClassTranslate. VATCaptionClassTranslate also passes the Language ID and the CAPTIONREF part of the CaptionClass property. This function can be split into two main parts:

  1. Sift out the comma-separated subparts of the CAPTIONREF.

  2. Determine what the caption should be, depending on the VATCAPTIONTYPE. In either case, the original caption is replaced by its original caption plus the string:

  • 'Excl. VAT' if VATCAPTIONTYPE equals 1.

  • 'Incl. VAT' if VATCAPTIONTYPE equals 2.

VATCaptionClassTranslate(Language : Integer;CaptionExpr : Text[80]) : Text[30]
// Begin (1) 
CommaPosition := STRPOS(CaptionExpr,',');
IF (CommaPosition > 0) THEN BEGIN
  VATCaptionType := COPYSTR(CaptionExpr,1,CommaPosition - 1);
// End (1) 
VATCaptionRef := COPYSTR(CaptionExpr,CommaPosition + 1);
// Begin (2) 
CASE VATCaptionType OF
  '0' : EXIT(COPYSTR(STRSUBSTNO('%1
  %2',VATCaptionRef,Text016),1,30));
  '1' : EXIT(COPYSTR(STRSUBSTNO('%1
  %2',VATCaptionRef,Text017),1,30));
// End (2) 
  END;
END;
EXIT(");

See Also

Community Additions

ADD
Show: