Note that sample4 does not compile if executed from an HTML-mapping process-web-request procedure, because frames defined in an external procedure (Web object) do not scope to any of its internal procedures. As a result, the frame is invisible to the statements in the FOR block and the field object references, which are assumed to be in the Web object frame (FRAME {&FRAME-NAME}), have no recognized existence:
sample4
FOR EACH Customer FIELDS (Balance Name) NO-LOCK:
DEFINE VARIABLE fBalance AS DECIMAL NO-UNDO.
fBalance = fBalance + Customer.Balance.
{&DISPLAY} Customer.Name Customer.Balance.
END.
FIND FIRST Customer NO-LOCK NO-ERROR.
IF AVAILABLE Customer THEN
{&DISPLAY} Customer.Name Customer.Balance
WITH FRAME {&FRAME-NAME}.
The solution is to copy the WITH FRAME {&FRAME-NAME} reference to just before the colon terminator of the FOR EACH statement.