Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

Str lenght

Posted on by Microsoft Employee

In a Report it gets the position reference and currently it doesn't allow for entries over 250 characters. I'm trying to change this to allow for no size restriction. How can I change this code to remove the restriction. I know it's involving the MAXSTRLEN is it that alone I need to remove or anything else. 

The return value in the function is set to text and No Size entered. 


//TIO000007 - Return a comma delimited list of position references
recProdOrderPositionRefs.RESET;
recProdOrderPositionRefs.SETCURRENTKEY(
"Position Order Alpha",
"Position Order Numeric",
"Position Order Suffix"
);
// check if the position refs have been created for the work order
recProdOrderPositionRefs.SETRANGE("Prod. Order No.", "Prod. Order No.");
recProdOrderPositionRefs.SETRANGE("Prod. Order Line No.", "Prod. Order Line No.");
IF NOT recProdOrderPositionRefs.ISEMPTY THEN BEGIN
recProdOrderPositionRefs.SETRANGE("Item No.", "Item No.");
CASE optNotFittedFilter OF
optNotFittedFilter::Yes: recProdOrderPositionRefs.SETRANGE("Not Fitted", TRUE);
optNotFittedFilter::No: recProdOrderPositionRefs.SETRANGE("Not Fitted", FALSE);
optNotFittedFilter::Both: recProdOrderPositionRefs.SETRANGE("Not Fitted");
END;
IF recProdOrderPositionRefs.FINDSET THEN REPEAT
IF strReferences = '' THEN
strReferences :=
recProdOrderPositionRefs."Position Reference"
ELSE IF STRLEN(
strReferences +
',' +
recProdOrderPositionRefs."Position Reference"
) <= MAXSTRLEN(strReferences) THEN
strReferences :=
strReferences +
',' +
recProdOrderPositionRefs."Position Reference"
ELSE
strReferences :=
COPYSTR(
strReferences,
1,
STRLEN(strReferences)-3)
+ '...';
UNTIL recProdOrderPositionRefs.NEXT = 0
END ELSE BEGIN
// else return the references from the BOM
recProductionBOMLine.RESET;
recProductionBOMLine.SETRANGE("Production BOM No.", "Production BOM No.");
recProductionBOMLine.SETRANGE("Version Code", "Production BOM Version Code");
recProductionBOMLine.SETRANGE("Line No.", "Production BOM Line No.");
recProductionBOMLine.SETRANGE("No.", "Item No.");
IF NOT recProductionBOMLine.ISEMPTY THEN
IF recProductionBOMLine.FINDFIRST THEN
strReferences := recProductionBOMLine.PositionReferences(optNotFittedFilter);
END;
EXIT(strReferences);

ProdOrderPositionRefsNew(optNotFittedFilter : 'Yes,No,Both') : Text
//TIO000007 - Return a comma delimited list of position references
recProdOrderPositionRefs.RESET;
recProdOrderPositionRefs.SETCURRENTKEY(
"Position Order Alpha",
"Position Order Numeric",
"Position Order Suffix"
);
// check if the position refs have been created for the work order
recProdOrderPositionRefs.SETRANGE("Prod. Order No.", "Prod. Order No.");
recProdOrderPositionRefs.SETRANGE("Prod. Order Line No.", "Prod. Order Line No.");
IF NOT recProdOrderPositionRefs.ISEMPTY THEN BEGIN
recProdOrderPositionRefs.SETRANGE("Item No.", "Item No.");
CASE optNotFittedFilter OF
optNotFittedFilter::Yes: recProdOrderPositionRefs.SETRANGE("Not Fitted", TRUE);
optNotFittedFilter::No: recProdOrderPositionRefs.SETRANGE("Not Fitted", FALSE);
optNotFittedFilter::Both: recProdOrderPositionRefs.SETRANGE("Not Fitted");
END;
IF recProdOrderPositionRefs.FINDSET THEN REPEAT
IF strReferences = '' THEN
strReferences :=
recProdOrderPositionRefs."Position Reference"
{ ELSE IF STRLEN(
strReferences +
',' +
recProdOrderPositionRefs."Position Reference"
) <= MAXSTRLEN(strReferences) THEN
strReferences :=
strReferences +
',' +
recProdOrderPositionRefs."Position Reference" }
ELSE
strReferences :=
COPYSTR(
strReferences,
1,
STRLEN(strReferences)-3)
+ '...';
UNTIL recProdOrderPositionRefs.NEXT = 0
END ELSE BEGIN
// else return the references from the BOM
recProductionBOMLine.RESET;
recProductionBOMLine.SETRANGE("Production BOM No.", "Production BOM No.");
recProductionBOMLine.SETRANGE("Version Code", "Production BOM Version Code");
recProductionBOMLine.SETRANGE("Line No.", "Production BOM Line No.");
recProductionBOMLine.SETRANGE("No.", "Item No.");
IF NOT recProductionBOMLine.ISEMPTY THEN
IF recProductionBOMLine.FINDFIRST THEN
strReferences := recProductionBOMLine.PositionReferences(optNotFittedFilter);
END;
EXIT(strReferences);

*This post is locked for comments

  • Suggested answer
    RockwithNav Profile Picture
    RockwithNav 6,562 on at
    RE: Str lenght

    As suggested by Mohana, I believe you should enable the debugger and cross check the Integer value coming in strReferences.

  • Verified answer
    Rajasekhar@MS Profile Picture
    Rajasekhar@MS 5,567 on at
    RE: Str lenght

    Hi

    Change your code ,check the length of strReferences using STRLEN and if the length greater than 3 execute the copystr statement and the dependent code.

  • Verified answer
    Mohana Yadav Profile Picture
    Mohana Yadav 59,139 Super User 2024 Season 2 on at
    RE: Str lenght

    it seems STRLEN(strReferences)-3 in COPYSTR function is returning -1 which is causing error.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Str lenght

    When I removed the commented out section and attempted to print the report I get this error

    98.PNG

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans