The QUOTER utility formats character data in a file to the standard format so it can be used by an ABL (Advanced Business Language) procedure. By default, QUOTER does the following:
Takes the name of a file as an argument
Reads input from that file
Places quotes (") at the beginning and end of each line in the file
Replaces any already existing quotes (") in the data with two quotes (" ")
You can use the QUOTER utility directly from the operating system using the operating system statement, as appropriate, to reformat data from a file that is not in the standard ABL input format:
You use QUOTER to put this file into standard format. Use commands shown in the following table to run QUOTER from the Procedure Editor.
Table 84. QUOTER examples
Operating system
Using QUOTER—Examples
Windows
DOS quoter i-dat12.d >i-dat12.q
UNIX
UNIX quoter i-datf12.d >i-datf12.q
In the following figure, i-datfl2.d is the name of the data file you supply to QUOTER while i-datfl2.q is the name of the file in which you want to store QUOTER's output.
Now this file is in the appropriate format to be used as input to an ABL procedure.
What if each of the field values in your data file is not on a separate line (unlike i-datfl2.d) and without quotes (unlike i-datf1.d)? That is, your data file looks like i-datfl3.d.
Suppose you wanted to use this file as the input source to create customer records for customers 90, 91, and 92. You need to make each line of the file into a character string and then assign a substring of this value to each field. The procedure i-chgin3.p does that.
i-chgin3.p
DEFINE VARIABLE data AS CHARACTER NO-UNDO FORMAT "x(78)".
2. The INPUT FROM statement redirects the input stream to get input from the i-datfl3.q file.
3. The CREATE statement creates an empty customer record.
4. The SET statement uses the first quoted line in the i-datfl3.q file as input and puts that line in the data variable. Once that line of data is in the line variable, the next statements break it up into pieces that get stored in individual customer fields.
5. The SUBSTRING functions take the appropriate pieces of the data in the line variable and store the data in the cust–num, name, and sales–rep fields, as shown in the following figure.
Figure 70. Extracting QUOTER input with SUBSTRING
Because ABL assumes that all the data in the i-datfl3.q file is character data, you must use the INTEGER function to convert the cust–num data to an integer value.
6. The INPUT CLOSE statement closes the input stream coming from the i-datfl3.q file and redirects the input stream to the terminal.
Note: With this method, all trailing blanks are stored in the database. To avoid this problem, use the –c or –d option of QUOTER.
You can use QUOTER to prepare files formatted in other ways as well. For example, suppose the field values in your data file are separated by a specific character, such as a comma (,), as in i-datfl4.d.
You can use a special option, -d, (on UNIX) to tell QUOTER what character separates fields. The procedure i-chgin4.p reads the comma-separated data from i-datfl4.d.
INPUT FROM i-datfl4.q NO-ECHO.
REPEAT:
CREATE Customer.
SET Customer.CustNum Customer.Name Customer.SalesRep.
END.
INPUT CLOSE.
Here, the -d option or the DELIMITER qualifier tells QUOTER that a comma (,) is the delimiter between each field in the data file. The output of QUOTER is shown in i-datfl4.q.
This data file is in the standard blank-delimited ABL format. If your data file does not use a special field delimiter that you can specify with the –d QUOTER option or the /DELIMITER qualifier, but does have each data item in a fixed column position, you can use another special option, –c, on Windows and UNIX.
You use the –c option or /COLUMNS to identify the columns in which fields begin and end. For example, suppose your file looks like i-datfl5.d.
INPUT FROM i-datfl5.q NO-ECHO.
REPEAT:
CREATE Customer.
SET Customer.CustNum Customer.Name Customer.SalesRep.
END.
INPUT CLOSE.
Because you used the –c option, this procedure produces a data file without trailing blanks.
You can also use QUOTER interactively to reformat your data. You can access QUOTER interactively through the Administration Tool or, in character interfaces, the Data Dictionary. From the main menu, choose Utilities.