about STRSUBSTNO features

nikeman77nikeman77 Member Posts: 517
hi all,

i have 1 purchase order which had multiple purchase receipt, in a report user will input original purchaser order document, and report will list down all related Purch. Rcpt. Line items and their information. so I tried to get all purchase receipt document no, and filter the documents using PurchRcptNoFilter = item ledger entry.document no.

(eg: PR001 | PR002 | PR005 | PR006 = item ledger entry.document no. )

PROBLEM: I tried to use STRSUBSTNO in following way:
PurchRcptHDR.setrange("order no.", POFilter);

IF PurchRcptHDR.FindSET THEN BEGIN
REPEAT

IF PurchRcptNoFilter = '' THEN
PurchRcptNoFilter := PurchRcptHDR."No." + '|'
ELSE
PurchRcptNoFilter := STRSUBSTNO('%1|%2, PurchRcptHDR."No.");

UNTIL PurchRcptHDR.Next=0;
END;

Output :

PR001 || PR002 || PR005 | PR006 ](*,)

Comments

  • ara3nara3n Member Posts: 9,256
    try this
    IF PurchRcptHDR.FindSET THEN BEGIN
    REPEAT
    
    IF PurchRcptNoFilter = '' THEN
    PurchRcptNoFilter := PurchRcptHDR."No."
    ELSE
    PurchRcptNoFilter := PurchRcptNoFilter + '|'+ PurchRcptHDR."No.";
    
    UNTIL PurchRcptHDR.Next=0;
    END;
    
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • kinekine Member Posts: 12,562
    PurchRcptNoFilter := STRSUBSTNO('%1|%2, PurchRcptHDR."No.");
    

    You need to use 3 parameters if you have two placeholders in the string... %2 is replaced by nothing...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • nikeman77nikeman77 Member Posts: 517
    kine,
    thanks for replying.. its typo error.. :oops:
    i check my code PurchRcptNoFilter := STRSUBSTNO('%1|%2,PurchRcptNoFilter, PurchRcptHDR."No.");

    but still i got an error:
    A value in the filter "PR001|PR002||PR003||PR004" in the Document No. field in the Item Ledger Entry table is too long for the field type.
    Type: Code20

    NOTE: The double '||' in the error message above is what I actually saw.
  • kinekine Member Posts: 12,562
    I recommend to use debugger and step through the code. You will see, that didn't create the code very well. Watching the value of your variable will tell you more... ;-)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • ara3nara3n Member Posts: 9,256
    follow my suggestion...
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
Sign In or Register to comment.