Try OpenEdge Now
skip to main content
ABL Essentials
Procedure Blocks and Data Access : Language statements that define blocks : FOR blocks : Qualifying a FOR statement with a frame reference
 
Qualifying a FOR statement with a frame reference
This most recent example also has an explicit frame reference in it:
FOR EACH Customer NO-LOCK WHERE Customer.State = "NH" WITH FRAME f:
  DISPLAY Customer.CustNum Customer.Name.
  FOR EACH Order OF Customer NO-LOCK BY OrderDate:
    DISPLAY Order.OrderNum Order.OrderDate WITH FRAME f.
    LEAVE.
  END. /* FOR EACH Order */
END. /* FOR EACH Customer */
Why is this necessary? A FOR EACH block scopes a frame to the block. By default, this is an unnamed frame. Without the specific frame reference, you get two nested frames, one for the Customer and one for its Orders. You saw this already in the sample procedure in UsingBasic ABL Constructs.
In this case, that isn't what you want. Because there's only one Order of interest for each Customer, you want to display all the fields together in the Customer frame. To get this effect, you have to override the default behavior and tell the AVM to use the frame from the Customer block to display the Order fields. That is what these two references to WITH FRAME f do for you. The AVM just keeps making room for new fields in the frame as it encounters them.