Prerequisites for This Example Create a Report Using the Report Wizard

Building a Check Printing Report with Spelled-Out Cash Amounts 31-5 the numerical value in the designated currency. In this case, we will use dollars and cents.

31.3.1 Create a PLSQL function

In this section, you will create a function that simply returns the check amount in word format, such as twenty-four sixty-five. The formula column you create in the next section will use the information retrieved by this function to spell out the cash amounts on your checks. To create a PLSQL function:

1. In the Object Navigator, under your report name, double-click Program Units.

2. In the New Program Unit dialog box, type Spell in the Name box.

3. Select Function, then click OK.

4. In the PLSQL Editor, type the following code: FUNCTION Spell val number RETURN CHAR IS sp varchar2100; BEGIN if val 0 then returninitcapto_charto_dateval, SSSSS, SSSSSSP; else return; end if; END;

5. Click Compile. If you see any errors, compare your code against the code shown

in the image below: Figure 31–3 PLSQL Editor displaying the SPELL function

6. When your code successfully compiles, click Close.

Your new function now displays in the Object Navigator: Note: You can enter this code by copying and pasting it from the provided text file called spellcash_code.txt into the PLSQL Editor. 31-6 Oracle Reports Users Guide to Building Reports Figure 31–4 Object Navigator with SPELL PLSQL function 7. Save your report.

31.3.2 Create a formula column in your data model

In this section, you will create a formula column that uses the information retrieved by the Spell function you created in Section 31.3.1, Create a PLSQL function . This formula column will use the verbal values of the check amounts and combine the words with the correct currency. For example, the twenty-four sixty-five returned by the Spell function will be turned into twenty-four dollars and sixty-five cents. To create a formula column: 1. In the Object Navigator, under your report name, double-click the view icon next to the Data Model node to display the Data Model view. Your data model should look like this: Figure 31–5 Data Model view

2. Resize the G_ORDER_ID box by clicking at the top, then dragging the bottom

center resize handle downwards. Your data model should now look something like this: