Using external and internal procedures
- Last Updated: March 30, 2020
- 2 minute read
- OpenEdge
- Version 12.2
- Documentation
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
RUNstatement, you specify the parameters to theRUNstatement in parentheses, following the procedure name. Use commas to separate multiple parameters. - An
INPUTparameter can be a constant value, an expression, or a variable or field name. AnINPUTparameter 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
OUTPUTparameter 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. AnINPUT-OUTPUTparameter must also be a field or variable.For each parameter in the
RUNstatement, you specify the type of parameter and the parameter itself. The default isINPUT, so you can leave off the type forINPUTparameters. 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:
- Add the following
RUNstatement to your h-CustSample.p procedure, inside theFOR EACH Order OF Customerblock, just before theENDstatement. 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). - Following this, still inside the
FOR EACH Orderblock, write another statement to display the value you got back along with the rest of the Order information:DISPLAY iDays LABEL "Days" FORMAT "ZZZ9".