|
![]() |
#1 |
Участник
|
Цитата:
Цитата:
FINDSET (Record)
Use this function to find a set of records in a table based on the current key and filter. The records can only be retrieved in ascending order. Ok := Record.FINDSET([ForUpdate][, UpdateKey]) Ok Data type: boolean If you omit this optional return value, a run-time error occurs if the system cannot find a record. If you include a return value, the system assumes you will handle any errors. Ok can have these values: If Ok is... It means the record set was... TRUE Found FALSE Not found Record Data type: record If the record was... Then... Found The system returns the record in Record and sets any FlowField in the record to zero. You must update them using CALCFIELDS. Not found A run-time error occurs, if you omitted the return value Ok. ForUpdate Data type: boolean Set this to FALSE if you don't intend to modify any records in the set. Set this to TRUE if you want to modify some records in the set. If you set this parameter to TRUE, a LOCKTABLE is immediately performed on the table before the records are read. UpdateKey Data type: boolean This only applies if ForUpdate is set to TRUE. If you are going to modify any field value within the current key, set this parameter to TRUE. Comments You should only use this function when you explicitly want to loop through a recordset. You should ONLY use this function in combination with REPEAT .. UNTIL. Furthermore, FINDSET only supports descending loops. If you want to loop from the bottom up, you should use FIND(‘+’). The general rules for using FINDSET are: • FINDSET(FALSE,FALSE)- read-only. This uses no server cursors and the record set is read with a single server call. • FINDSET(TRUE,FALSE)- is used to update non-key fields. This uses a cursor with a fetch buffer similar to FIND(‘-’). • FINDSET(TRUE,TRUE)- is used to update key fields. Note This function is designed to optimize finding and updating sets. If you set any or both of the parameters to FALSE, you can still modify the records in the set but these updates will not be performed optimally. Example The following C/AL code examples show how to use the FINDSET function: Example 1 // Looping through a set without updating it. SalesLine.SETFILTER("Purch. Order Line No.",'<>0'); IF SalesLine.FINDSET THEN BEGIN REPEAT CopyLine(SalesLine); UNTIL SalesLine.NEXT = 0; END; Example 2 // Looping through a set and updating a field that is not within the current key. SalesLine.SETRANGE("Document Type",DocumentType); SalesLine.SETRANGE("Document No.",DocumentNo); IF SalesLine.FINDSET(TRUE, FALSE) THEN BEGIN REPEAT SalesLine."Location Code" := GetNewLocation(SalesLine); SalesLine.MODIFY; UNTIL SalesLine.NEXT = 0; END; Example 3 // Looping through a set and updating a field that is within the current key. SalesShptLine.SETRANGE("Order No.",SalesLine."Document No."); SalesShptLine.SETRANGE("Order Line No.",SalesLine."Line No."); SalesShptLine.SETCURRENTKEY("Order No.","Order Line No."); IF SalesShptLine.FINDSET(TRUE, TRUE) THEN BEGIN REPEAT SalesShptLine."Order Line No." := SalesShptLine."Order Line No." + 10000; SalesShptLine.MODIFY; UNTIL SalesShptLine.NEXT = 0; END; |
|
![]() |
#2 |
Участник
|
Спасибо Kadawrik за цитирование справки из своего навика, у меня примерно такая же, но т.к. есть отличия, мне пришлось перечитать ее еще раз... Вопрос актуален, с какими параметрами по умолчания вызывается FINDSET? Мне не по глазам или просто с первого раза был непонятен мой вопрос?) Я так и не нашел этого...
|
|
![]() |
#3 |
Участник
|
|
|
![]() |
#4 |
Участник
|
|
|