HELP!! OVERFLOW ERROR

pratyushapratyusha Member Posts: 14
I have to solve an overflow error which come in a report statment of accounts. here's the code:

"AppliedDocNo.":=''; //PM

IF("Cust. Ledger Entry"."Document Type"="Cust. Ledger Entry"."Document Type"::"Credit Memo") AND
("Cust. Ledger Entry"."Closed by Entry No." = 0 ) THEN BEGIN
recCLE.RESET;
//recCLE.SETRANGE(recCLE."Entry No.","Cust. Ledger Entry"."Closed by Entry No.");
recCLE.SETRANGE(recCLE."Closed by Entry No.","Cust. Ledger Entry"."Entry No.");
IF recCLE.FINDFIRST THEN BEGIN
//"AppliedDocNo.":=''; //PM
REPEAT
"AppliedDocNo." := "AppliedDocNo." + ','+ recCLE."Document No.";
UNTIL recCLE.NEXT = 0 ;
END;

END
ELSE
IF("Cust. Ledger Entry"."Document Type"="Cust. Ledger Entry"."Document Type"::"Credit Memo") AND
("Cust. Ledger Entry"."Closed by Entry No." <> 0 ) THEN BEGIN
//"AppliedDocNo.":=''; //PM
recCLE.RESET;
recCLE.SETRANGE(recCLE."Entry No.","Cust. Ledger Entry"."Closed by Entry No.");
IF recCLE.FINDFIRST THEN BEGIN
//"AppliedDocNo.":=''; //PM
REPEAT
"AppliedDocNo." := "AppliedDocNo." + ','+ recCLE."Document No.";
UNTIL recCLE.NEXT = 0 ;
END;
END

ELSE
IF("Cust. Ledger Entry"."Document Type"="Cust. Ledger Entry"."Document Type"::Invoice) AND
("Cust. Ledger Entry"."Closed by Entry No." <> 0)THEN BEGIN
//"AppliedDocNo.":=''; //PM
recCLE.RESET;
recCLE.SETRANGE(recCLE."Entry No.","Cust. Ledger Entry"."Closed by Entry No.");
IF recCLE.FINDFIRST THEN BEGIN
//"AppliedDocNo.":=''; //PM
REPEAT
"AppliedDocNo." := "AppliedDocNo." + ','+ recCLE."Document No.";
UNTIL recCLE.NEXT = 0 ;
END;
END

ELSE
IF("Cust. Ledger Entry"."Document Type"="Cust. Ledger Entry"."Document Type"::Invoice) AND
("Cust. Ledger Entry"."Closed by Entry No." = 0)THEN BEGIN
//"AppliedDocNo.":=''; //PM
recCLE.RESET;
recCLE.SETRANGE(recCLE."Closed by Entry No.","Cust. Ledger Entry"."Entry No.");
IF recCLE.FINDFIRST THEN BEGIN
//"AppliedDocNo.":=''; //PM
REPEAT
"AppliedDocNo." := "AppliedDocNo." + ','+ recCLE."Document No.";
UNTIL recCLE.NEXT = 0 ;
END;
END

ELSE
IF("Cust. Ledger Entry"."Document Type"="Cust. Ledger Entry"."Document Type"::" ") OR
("Cust. Ledger Entry"."Document Type"="Cust. Ledger Entry"."Document Type"::Payment)THEN BEGIN
//"AppliedDocNo.":=''; //PM
recDetailCustLedgerEntry.RESET;
recDetailCustLedgerEntry.SETRANGE(recDetailCustLedgerEntry."Applied Cust. Ledger Entry No.","Cust. Ledger Entry"."Entry No.");
IF recDetailCustLedgerEntry.FINDFIRST THEN BEGIN
//"AppliedDocNo.":=''; //PM
REPEAT
IF recDetailCustLedgerEntry."Cust. Ledger Entry No." <> recDetailCustLedgerEntry."Applied Cust. Ledger Entry No." THEN BEGIN
recCLE.GET(recDetailCustLedgerEntry."Cust. Ledger Entry No.");
"AppliedDocNo." := "AppliedDocNo." + ','+ recCLE."Document No.";
END;
UNTIL recDetailCustLedgerEntry.NEXT = 0 ;
END;
END;


StrLength := STRLEN("AppliedDocNo.");
"AppliedDocNo1." := COPYSTR("AppliedDocNo.",2,MAXSTRLEN("AppliedDocNo1."));

the excel displays applieddocno1.

please CAN ANYONE SUGGEST WHAT TO DO,.i have been trying it since three days. one of the recrds cotains 40 applied docs related to it.... ](*,)

Comments

  • vijay_gvijay_g Member Posts: 884
    On which line you are gettign error? i suppose it is because of "AppliedDocNo." variable so check var length.
  • pratyushapratyusha Member Posts: 14
    ITS IN THE LAST IF..ELSE LOOP'S APPLIEDDOCNO. ITS VAR LENGTH IS 1024. STILL IT SHOWS THE ERROR. :(
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    "AppliedDocNo." variable might have reached 1024 characters and still you re trying to concatenate value to it..
  • vaprogvaprog Member Posts: 1,141
    Since you truncate "AppliedDocNo." later on anyway, program a guard in the loop, not allowing the string to grow longer than MAXSTRLEN("AppliedDocNo."):
    IF (STRLEN("AppliedDocNo.") + STRLEN(recCLE."Document No.")) >= MAXSTRLEN("AppliedDocNo.") THEN
      recCLE.FINDLAST // abort the loop
    ELSE
      "AppliedDocNo." := "AppliedDocNo." + ','+ recCLE."Document No.";
    
Sign In or Register to comment.