Try OpenEdge Now
skip to main content
ABL Essentials
Running ABL Procedures : Using external and internal procedures

Using external and internal procedures

A separate source procedure, such as h-CustSample.p, is known as an external procedure. This is to distinguish it from another kind of the procedure that you'll write as the next step in your sample. you can define one or more named entry points within an external procedure file, and these are called internal procedures. You run internal procedures in almost exactly the same way that you run external procedures, except that there is no .p filename extension on the internal procedure.
For your sample, you will run a procedure called calcDays that calculates the number of days between the ShipDate for each Order and today's date. In order for calcDays to do the calculation, you need to pass the ShipDate to the procedure, and get the count of days back out. ABL supports parameters for its procedures to let you do this. Follow these guidelines:
*In a RUN statement, you specify the parameters to the RUN statement in parentheses, following the procedure name. Use commas to separate multiple parameters.
*An INPUT parameter can be a constant value, an expression, or a variable or field name. An INPUT parameter is made available by value to the procedure you are running. This means that the procedure can use the value, but it cannot modify the value in a way that is visible to the calling procedure.
*An OUTPUT parameter must be a variable or field name. Its value is not passed to the called procedure, but is returned to the calling procedure when the called procedure completes.
*You can also define a parameter as INPUT-OUTPUT. This means that its value is passed in to the procedure, which can modify the value and pass it back when the procedure ends. An INPUT-OUTPUT parameter must also be a field or variable.
For each parameter in the RUN statement, you specify the type of parameter and the parameter itself. The default is INPUT, so you can leave off the type for INPUT parameters. You cannot have optional parameters in an ABL procedure. You must pass in a parameter name or value for each parameter the called procedure defines. They must be in the same order, and they must be of the same data type.
To run the calcDays procedure from your sample procedure:
1. Add the following RUN statement to your h-CustSample.p procedure, inside the FOR EACH Order OF Customer block, just before the END statement. Pass in the ShipDate field from the current Order and get back the calculated number of days, iDays:
RUN calcDays (INPUT Order.ShipDate, OUTPUT iDays).
2. Following this, still inside the FOR EACH Order block, write another statement to display the value you got back along with the rest of the Order information:
* Writing internal procedures
* Assigning a value to a variable
* When to use internal and external procedures
* RETURN statement and RETURN-VALUE