The replace statement generates a DL/I REPL statement. In DL/I, you must get and hold a segment before you can overwrite it. The EGL keywords get...forUpdate, get next...forUpdate, and get next inParent...forUpdate all hold the requested segment for replacement.

// define DLI Segment records using the hostVarQualifier property
Record CustomerRecordPart type DLISegment
{ segmentName="STSCCST", keyItem="customerNo", hostVarQualifier="myCustomer" }
...
end
Record LocationRecordPart type DLISegment
{ segmentName="STSCLOC", keyItem="locationNo", hostVarQualifier="myLocation" }
...
end
Record OrderRecordPart type DLISegment
{ segmentName="STPCORD", keyItem="orderDateNo", hostVarQualifier="myOrder" }
...
end
//create variables for the records
myCustomer CustomerRecordPart;
myLocation LocationRecordPart;
myOrder OrderRecordPart;
//build a segment search argument
myCustomer.customerNo = "5001";
myLocation.locationNo = "22";
myOrder.orderDateNo = "20050730A003";
//hold the requested order segment
try
get myOrder forUpdate;
onException(dex DLIException)
myErrorHandler(dex);
end
//update the information
changeOrder(myOrder);
//rewrite the order
try
replace myOrder;
onException(dex DLIException)
myErrorHandler(dex);
end
The get...forUpdate statement
generates qualified SSAs for customer, location, and order:GHU STSCCST (STQCCNO = :myCustomer.customerNo)
STSCLOC (STQCLNO = :myLocation.locationNo)
STPCORD (STQCODN = :myOrder.orderDateNo)
The replace statement
then simply generates the following:REPL STPCORD