Check this function
PROCEDURE SplitComments@1240060000(CommentText@1240060000 : Text);
VAR
SpaceLeft@1240060001 : Integer;
Word@1240060002 : Text;
CommentLine@1240060003 : Record 44;
LineNo@1240060004 : Integer;
TempWord@1240060005 : Text[50];
Pos@1240060006 : Integer;
BEGIN
CommentLine.RESET;
CommentLine.SETRANGE("Document Type","Document Type");
CommentLine.SETRANGE("No.","No.");
CommentLine.SETRANGE("Document Line No.","Document Line No.");
IF CommentLine.FINDLAST THEN
LineNo := CommentLine."Line No.";
CommentLine.INIT;
CommentLine."Document Type" := "Document Type";
CommentLine."No." := "No.";
CommentLine.Date := TODAY;
CommentLine."Document Line No." := "Document Line No.";
CommentLine.Code := COPYSTR(USERID,1,10);
SpaceLeft := MAXSTRLEN(CommentLine.Comment);
WHILE STRLEN(CommentText) > 0 DO BEGIN
Pos := STRPOS(CommentText,' ');
IF Pos > 50 THEN
Pos := 50 - 1;
IF Pos > 0 THEN BEGIN
Word := COPYSTR(CommentText, 1, Pos);
CommentText := COPYSTR(CommentText, Pos + 1);
END ELSE BEGIN
IF STRLEN(CommentText) >= 50 THEN BEGIN
Word := COPYSTR(CommentText, 1, 50 - 1);
Comment := COPYSTR(CommentText, 50);
END ELSE BEGIN
Word := CommentText;
CLEAR(CommentText);
END;
END;
IF (STRLEN(Word) > SpaceLeft) THEN BEGIN
LineNo += 10000;
CommentLine."Line No." := LineNo;
CommentLine.INSERT(TRUE);
CommentLine.Comment := '';
END;
TempWord := COPYSTR(Word, 1);
CommentLine.VALIDATE(Comment,CommentLine.Comment + TempWord);
SpaceLeft := 50 - STRLEN(CommentLine.Comment);
IF STRLEN(CommentText) = 0 THEN BEGIN
LineNo += 10000;
CommentLine."Line No." := LineNo;
CommentLine.INSERT(TRUE);
END;
END;
END;
I have added this in Sales Comment Sheet Page to copy a large text into multiple text lines on the sales comment line.