This document contains information about using Natural Construct in the Natural development environment. It is intended for Natural programmers who are not familiar with the product and want to know how it can help them develop Natural applications. This document shows how to take advantage of Natural Construct as a development aid without creating entire applications. The information is especially useful for maintenance programmers.
This document covers the following topics:
When developing Natural programs, you often require data to test your programs. Did you know you can use the Maint model to generate a maintenance program for a file associated with your program? This allows you to quickly add data to test new Natural programs. For example, you can generate a maintenance program for the NCST-CUSTOMER file to supply data to test a new customer browse program.
For a more detailed description of the Maint model, see Maint Model in Natural Construct Generation.
To generate a maintenance program
Enter "ncstg" at the Natural Next prompt. The Generation main menu is displayed.
Specify the following:
M | Function field |
MYMAINT | Module field |
Maint | Model field |
Note:
If you do not specify a model name, Natural Construct displays a
selection window.
Press Enter. The Standard Parameters panel is displayed:
CUFMMA MAINT Program CU--MA0 Oct 23 Standard Parameters 1 of 3 Module ............. MYMAINT_ System ............. MYLIB___________________________ Global data area ... CDGDA___ With block ......... ________________________________ Title .............. Maintain...______________ Description ........ This program is used to maintain the...._______________ _______________________________________________________ _______________________________________________________ _______________________________________________________ First heading ...... ________________________________________________ Second heading ..... ______________________________________________________ Command ............ _ Message numbers .... _ Password ........... _ Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9---PF10--PF11--PF12--- right help retrn quit right main |
Enter "Test Maintenance Program" in the First header field. The Additional Parameters panel is displayed:
CUFMMB MAINT Program CUFMMB0 Oct 24 Additional Parameters 2 of 3 Predict view ............. ________________________________ * Natural (DDM) .......... ________________________________ Primary key .............. ________________________________ * Record description ....... _______________ Log file name ............ ________________________________ * Natural (DDM) .......... ________________________________ Input using map .......... ________ * Minimum key value ........ __________________________________________________ Maximum key value ........ __________________________________________________ Single prompt ............ _ Multiple prompts ......... _ Mark cursor field ........ __________________________________________________ #ACTION field length ..... 1 Add ...... X Browse ... ________ * Clear .... X Display .. X Modify ... X Next ..... X Purge .... X Recall ... _ Former ... _ Push-button support ...... _ Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9---PF10--PF11--PF12--- right help retrn quit left right main |
Select the following:
"NCST-CUSTOMER" from the Predict view field
"CUSTOMER-NUMBER" from the Primary key field
Press Enter. The Secondary File Parameters panel is displayed.
Press Enter again. You are returned to the Generation main menu.
Enter "G" in the Function field. When generation is completed, a confirmation message is displayed.
Enter "W" in the Function field. Another confirmation message is displayed. You can now use the maintenance program to enter test data for the browse program.
Note:
For more information, see Generate Source
Function and Stow Generated Source Function in
Natural Construct Generation.
To see the code generated by the Maint model, enter "E" in the Function field.
To test Natural subprograms and helproutines, you require a program to call the modules. Use the Driver model to create a driver program to test and debug subprograms and helproutines.
The Driver model determines the parameters in a subprogram, defines the parameters in a simple driver program, and generates an input screen. This allows you to easily test the module without the complex logic of programs that typically call the subprogram. The Driver model also supplies headings and PF-keys in the language of your choice.
Tip:
Using a driver program can eliminate the complexity of debugging a
subprogram that runs in a GUI, client/server environment.
In the following example, you'll create a driver program to test the NCOSODET browse subprogram, which displays details about order lines.
Note:
Before beginning the procedure, ensure that the required modules have
been copied to the current library. For a list of modules, see
Before You
Begin.
To generate a driver program
Enter "ncstg" at the Natural Next prompt. The Generation main menu is displayed.
Specify the following:
M | Function field |
MYDRIVER | Module field |
Driver | Model field |
Press Enter. The Driver Program window is displayed:
CUDRMA DRIVER Program CUDRMA0 Dec 04 Standard Parameters 1 of 1 Module ............. MYDRIVER System ............. MYLIB___________________________ Title .............. Driver Program___________ Description ........ Driver program for ...________________________________ ______________________________________________________ ______________________________________________________ ______________________________________________________ Source Object Called Module ...... ________ * Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9---PF10--PF11--PF12--- main help retrn quit userX main |
Select "NCOSODET" from the Called Module field.
Press Enter. The names of the library containing the source and object code for the NCOSODET subprogram are displayed.
Press Enter again. You are returned to the Generation main menu.
Enter "G" in the Function field. A confirmation window is displayed, indicating that generation was successful.
Enter "W" in the Function field. The driver program is stowed.
Note:
You cannot regenerate a driver program.
Enter "T" in the Function field. The Driver Program window is displayed:
MYDRIVER Natural Construct Dec 04 Driver Program 1 of 1 Subprogram ......... NCOSODET Input Parameters ... #PDA-KEY ______0 SELECTED-FUNCTION __________ ##COMMAN ____________________________________________________________ ##MAIN _______ ##QUIT ________ ##MSG ___________________________________________________________________________ ##MSG-NR ____0 ##MSG-DATA ________________________________ ________________________________ ________________________________ ##RETURN- _ ##ERROR-FIELD ________________________________ ##ERROR-FIELD-INDEX1 ___0 ##ERROR-FIELD-INDEX2 ___0 ##ERROR-FIELD-INDEX3 ___0 ##USER ________ Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9---PF10--PF11--PF1 help quit bkwrd frwrd right left |
Enter "111" in the #PDA-KEY field. The NCOSODET subprogram is processed for order number 111:
NCOSODET ***** ORDER SUBSYSTEM ***** Dec 4,01 - ORDER DETAIL - 1 more > Ln Prod Id Quantity Unit Cost Total Cost -- ------- --------- ---------- ------------ 1 199210 5 100.00 500.00 2 111111 2 555.00 1110.00 3 745977 1 7.00 7.00 4 777208 20 55.00 1100.00 *** End of Data *** Line Order Number: 000111 Line Number: __ Direct command...: ________________________________ Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8 help retrn quit flip bkwrd frw |
Tip:
When you enter "111" in the #PDA-KEY
field, ensure that you remove the "0".
For a description of the Driver model, see Driver Model in Natural Construct Generation.
Natural Construct supplies various utilities to help you develop Natural applications. This section describes two of these utilities:
CSGCMPL utility, which you can use to compare a range of Natural objects in one library to the same objects in another library
CSGCMPS utility, which you can use to compare the code in two programs
Note:
For information about other utilities, see
Utilities Supplied with Natural
Construct.
To compare the Natural objects in different libraries
Enter "CSGCMPL" at the Next prompt. The Source Range Compare Facility is displayed:
Source Range Compare Facility Library Database File Dominant ======== ======== ====== ======== Old library............... ________ ___196 _____4 X New Library............... ________ ___196 _____4 _ Program range............. ________ thru ________ Summary only.............. _ Only report if different.. _ Ignore comment lines...... _ Ignore trailing comments.. _ Ignore leading spaces..... _ Only compare object types __________ (ACGHLMNPST) |
Specify the following:
MYLIB | Library field for the Old library |
SYSCSTDE | Library field for the New library |
A* | 1st portion of the Program range field |
Z* | 2nd portion of the Program range field |
The dominant library (MYLIB) identifies which objects are compared. Only objects that exist in the MYLIB and SYSCSTDE libraries are compared. Objects that only exist in the SYSCSTDE library are not included in the results.
Notes:
Press Enter. The Library Compare Facility window is displayed:
Library Compare Facility Page 1 Dec 04,01 08:03 PM Program Matching Name lines lines lines Comments -------- -------- -------- -------- ---------------------- Input parameters... Library Database File Dominant ======== ======== ==== ======== Old library............... MYLIB 196 4 X New Library............... SYSCSTDE 196 4 Program range............. A* thru Z* Summary only.............. Only report if different.. Ignore comment lines...... Ignore trailing comments.. Ignore leading spaces..... Compare all types |
Press Enter again. The results of the comparison are displayed:
Library: MYLIB **** N A T U R A L C O N S T R U C T ***** CSGCMPS1 Object.: MYBROWSE - SOURCE COMPARE FACILITY - Dec 04,01 Page...: 1 08:05 PM Line Source Text ---- ---------------------------------------------------------------------- = 10 **SAG GENERATOR: BROWSE VERSION: n.n.n - 20 **SAG TITLE: Summary browse Ords - 30 **SAG SYSTEM: SACADB - 40 **SAG GDA: NCGDA - 50 **SAG DESCS(1): This program is used to browse the ... Orders - 60 **SAG HEADER1: Order Entry System - 70 **SAG HEADER2: Order display by order number + 20 **SAG TITLE: Summary Browse for Orders + 30 **SAG SYSTEM: SYSCSTDE + 40 **SAG GDA: NCGDA + 50 **SAG DESCS(1): This program will display all the orders in order + 60 **SAG DESCS(2): number sequence. + 70 **SAG HEADER1: Order Entry System + 80 **SAG HEADER2: Order Display by Order Number = 80 **SAG DIRECT-COMMAND-PROCESS: Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9---PF10--PF11--PF12--- retrn quit print top |
Notice the signs displayed to the left of the line numbers. These signs indicate whether the corresponding line is the same in both libraries (=), contains less characters (), or contains more characters (+).
Continue pressing Enter until the results for all modules have been displayed. The following window is displayed:
Library Compare Facility Page 55 Dec 04,01 08:07 PM Program MYLIB SYSCSTDE Matching Name lines lines lines Comments -------- -------- -------- -------- ---------------------- NCTFWHS1 89 89 89 Exact match NYORDSUB 100 0 0 NYORMSA 39 0 0 NYORMSR 12 0 0 OFACTORY 100 0 0 SUPRDREW 25 0 0 VB-DREW 65 0 0 VEHLBCPV 100 0 0 VEHLBKEY 13 0 0 VEHLBPRI 8 0 0 VEHLBROW 17 0 0 VEHLBSO 100 0 0 VEHLBSP 100 0 0 VEHLMCDV 100 0 0 VEHLMCPV 100 0 0 |
Press Enter. The Source Range Compare Facility window is redisplayed:
Source Range Compare Facility Library Database File Dominant ======== ======== ====== ======== Old library............... MYLIB___ ___196 _____4 X New Library............... SYSCSTDE ___196 _____4 _ Program range............. A*______ thru Z*______ Summary only.............. _ Only report if different.. _ Ignore comment lines...... _ Ignore trailing comments.. _ Ignore leading spaces..... _ Only compare object types __________ (ACGHLMNPST) 4 members match; 41 members don't match |
The message at the bottom of the window indicates that 4 members match and 41 do not.
To compare the Natural objects in different libraries
Enter "CSGCMPS" at the Next prompt. The Compare Criteria window is displayed:
Compare Criteria Library Object Database File or Source Area ======== ======== ======== ====== =========== Old version ===> SYSCSTDE ________ __196 ____4 _ New version ===> SYSCSTDE ________ __196 ____4 _ Options... Ignore comment lines...... _ Ignore trailing comments.. _ Ignore leading spaces..... _ Summary only.............. _ Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9---PF10- quit |
Specify the following:
MYLIB | Library field for the Old version |
MYBROWSE | Object field for the Old version |
MYBROWSE | Object field for the New version |
Note:
The "Old" and
"New" designation is for identification purposes
only; it does not indicate older or newer versions of the objects.
Press Enter. The Source Compare Facility window is displayed:
Library: MYLIB **** N A T U R A L C O N S T R U C T ***** CSGCMPS1 Object.: MYBROWSE - SOURCE COMPARE FACILITY - Dec 04,01 Page...: 1 08:16 PM Line Source Text ---- ---------------------------------------------------------------------- = 10 **SAG GENERATOR: BROWSE VERSION: n.n.n - 20 **SAG TITLE: Summary browse Ords - 30 **SAG SYSTEM: SACADB - 40 **SAG GDA: NCGDA - 50 **SAG DESCS(1): This program is used to browse the ... Orders - 60 **SAG HEADER1: Order Entry System - 70 **SAG HEADER2: Order display by order number + 20 **SAG TITLE: Summary Browse for Orders + 30 **SAG SYSTEM: SYSCSTDE + 40 **SAG GDA: NCGDA + 50 **SAG DESCS(1): This program will display all the orders in order + 60 **SAG DESCS(2): number sequence. + 70 **SAG HEADER1: Order Entry System + 80 **SAG HEADER2: Order Display by Order Number = 80 **SAG DIRECT-COMMAND-PROCESS: Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9---PF10--PF11--PF12--- quit print top < > |
The signs displayed to the left of the line numbers indicate whether the corresponding line is the same in both libraries (=), contains less characters (), or contains more characters (+).
Continue pressing Enter until the last line is displayed. The Comparison Results window is displayed:
Comparison Results Number of lines in lib MYLIB ...: 775 Number of lines in lib SYSCSTDE ...: 755 Number of matching source lines ...: 724 |
The results indicate that the MYBROWSE object in MYLIB has 20 more lines than the same object in the demo system, and that 724 source lines match in both objects.
For more information about the CSGCMPS utility, see CSGCMPS Utility in Natural Construct Administration and Modeling.
Part of your job as a programmer is to create online reports. Did you know you can use the Browse model to quickly create multi-panel reports? Although you can easily write a browse program yourself, it's not always easy to include some of the functions users want, such as:
Scrolling up and down through data, as well as left and right
Printing the report
Using wildcard characters to specify starting points, such as < or >
Drilling down to display additional details
When you use the Browse model to create reports, you can provide all these functions. In addition, you can regenerate the report if the database changes (from DB2 to Adabas, for example) and the model will supply the appropriate database code.
Note:
If the report produces large volumes of output, use the Batch model.
For more information, see Batch Model in Natural
Construct Generation.
To build fields for display, Natural Construct defaults the display value to the specified browse key. This functionality is ideal for generating quick browse routines to check the records in a file. For example, you can specify Customer-Name as the key field and the generated program will browse the Customer file by customer name.
If you want to display information about more than one field, you can use the WRITE-FIELDS user exit. The code in this exit defines additional logic to write information to each screen based on the contents of the #PANEL variable.
Another powerful feature of the Browse model is the PROCESS-SELECTED-RECORD user exit. You can use this exit to specify processing performed on a selected record based on the record's unique key. For more information about the user exits, see WRITE-FIELDS and PROCESS-SELECTED-RECORD in Natural Construct Generation.
The following sections describe how to use the Browse model to create different reports. For more detailed information about the Browse model, see Browse Models in Natural Construct Generation.
Note:
Before beginning the procedure, ensure that the required modules
have been copied to the current library. For a list of modules, see
Before You
Begin.
To create a report for a key field
Enter "ncstg" at the Natural prompt. The Generation main menu is displayed.
Specify the following:
M | Function field |
MYBROWSE | Module field |
Browse | Model field |
Press Enter. The Standard Parameters panel is displayed:
CUSCMA BROWSE Program CU--MA0 Oct 23 Standard Parameters 1 of 4 Module ............. MYBROWSE System ............. MYLIB___________________________ Global data area ... CDGDA___ With block ......... ________________________________ Title .............. Browse ..._______________ Description ........ This program is used to browse the ..._________________ _______________________________________________________ _______________________________________________________ _______________________________________________________ First heading ...... ________________________________________________ Second heading ..... ______________________________________________________ Command ............ _ Message numbers .... _ Password ........... _ Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9---PF10--PF11--PF12--- right help retrn quit right main |
Specify the following:
NCGDA | Global data area field |
Summary Browse for Orders | Title field |
This program will display all the orders in order number sequence | Description field |
Order Entry System | First header field |
Order Display by Order Number | Second header field |
Note:
For more information about this panel, see General Model
Specifications, Natural Construct Generation.
Press Enter. The Additional Parameters panel is displayed:
CUSCMB BROWSE Program CUSCMB0 Oct 23 Additional Parameters 2 of 4 Predict view ............. ________________________________ * Natural (DDM) .......... ________________________________ Program view ........... ________________________________ Primary key .............. ________________________________ * Horizontal panels ........ 1_ Backward scroll pages .... 10 Input using map .......... ________ * Reserved input lines ..... _ Minimum key value ........ ________________________________________________ Maximum key value ........ ________________________________________________ Single prompt ............ _ Multiple prompts ......... _ Wildcard support ......... _ Export data support ...... _ Hardcopy support ......... _ Window support ........... _ Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9---PF10--PF11--PF12--- help retrn quit windw left right main |
Select the following:
"NCST-ORDER-HEADER" from the Predict view field
"ORDER-NUMBER" from the Primary key field
The report will browse the NCST-ORDER-HEADER file by order number.
Mark the following:
Wildcard support field
Marking this field enables wildcard processing in the generated program. Users can enter wildcard characters, such as < or *, to limit the query.
Window support field
This enables the output to be displayed in a window, instead of on a full screen.
Press Enter. The Window Parameters window is displayed:
CU--DWM Natural Construct CU--DWM0 Oct 23 Window Parameters 1 of 1 Size ......... Height ....... ___ Width ........ ___ Position ..... Line ......... ___ Column ....... ___ Frame OFF .... _ Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8--- help retrn quit test |
Note:
You can also display this window by pressing PF5 (windw).
Specify the following:
24 | Height field |
10 | Line field |
10 | Column field |
Press Enter twice. The Additional INPUT Parameters panel is displayed.
Press Enter. The Restriction Parameters panel is displayed.
Note:
For more information about these panels, see Additional
INPUT Parameters Panel and Restriction Parameters
Panel in Natural Construct Generation.
Press Enter. You are returned to the Generation main menu.
Enter "G" in the Function field.
Enter "W" in the Function field. Your browse program is now generated and stowed.
To see the code generated by the Browse model, enter "E" in the Function field.
Tip:
To browse the orders by customer number, you can select
Customer-Number as the primary key.
To see what the window will look like to users, enter "T" in the Function field. The following window is displayed:
MYBROWSE ***** Order Entry System ***** Oct 25 - Order Display by Order Number - 9:47 PM Order Number ------------ Order Number: ______ Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9--- help retrn quit flip bkwrd frwrd |
To display the order numbers, press Enter or PF8 (frwrd).
Press PF2 (retrn). You are returned to the Generation main menu.
You've successfully created a report, but it only displays details about one field. To add the logic to display details about additional fields, you must select and define the WRITE-FIELDS user exit. The following section describes how to do this.
You can create a report for more than one field by selecting and defining the WRITE-FIELDS user exit. This user exit helps you create the WRITE or DISPLAY statements required to display the additional fields on the report.
If you regenerate the report, the user exit code is not touched. You must select and define the user exit again and re-create the user exit code.
Tip:
Because this user exit is invoked after each record in the primary
file is read, you can also include the code to perform calculations if
desired.
To create a report for more than one field
Enter "U" in the Function field. The first User Exit panel is displayed:
CSGSAMPL NATURAL CONSTRUCT CSGSM0 Oct 23 User Exits 1 of 1 User Exit Exists Sample Required Conditional -------------------------------- -------- ---------- -------- ------------ _ CHANGE-HISTORY Subprogram _ PARAMETER-DATA Example X _ HE-PARAMETER-INDEXES Example X _ BUILD-REPORT-LOCAL-VARS _ LOCAL-DATA Subprogram _ START-OF-PROGRAM Example _ SELECT-STATEMENT Subprogram X _ AFTER-READ Example _ REJECT-AFTER-MAX-KEY-CHECK _ EXPORT-DATA Subprogram X _ WRITE-FIELDS Subprogram _ TOP-OF-PAGE Example _ BEFORE-INPUT Example _ BEFORE-STANDARD-KEY-CHECK Example _ AFTER-INPUT Example _ HARDCOPY-EDITS Example X Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9---PF10--PF11--PF12--- frwrd help retrn quit bkwrd frwrd |
Tip:
If this panel is not displayed, enter
"SAMPLE" on the command line.
Mark the WRITE-FIELDS user exit.
Press Enter twice. The WRITE-FIELDS Data Parameters window is displayed:
CSUSELFV NATURAL CONSTRUCT CSUSELF0 Oct 23 WRITE-FIELDS Data Parameters 1 of 1 Label Type PREDICT Views or Data Areas Select All -------- ---------- ------------------------------------ ------ ------ 1 View NCST-ORDER-HEADER_______________ * _ _ 2 ________________________________ * _ _ 3 ________________________________ * _ _ 4 ________________________________ * _ _ 5 ________________________________ * _ _ 6 ________________________________ * _ _ Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9---PF10--PF11 help retrn |
This panel determines whether you want to use all the fields in the file or only a subset. Based on your previous specifications, Natural Construct supplies the name of the file you're using. NCST-ORDER-HEADER is displayed in the first Predict Views or Data Areas field.
Mark the Select field following NCST-ORDER-HEADER. This indicates that you want to select the fields.
Press Enter. The Select NCST-ORDER-HEADER Field window is displayed:
CSGSELFD Natural Construct CSGSELF0 Oct 23 Select NCST-ORDER-HEADER Field 1 of 1 Type Level Field name Format Length Desc ------ ------ -------------------------------- ------ ------ ------ 1 _ ORDER-NUMBER N 6.0 D 1 _ ORDER-AMOUNT P 13.2 1 _ ORDER-DATE N 8.0 1 _ ORDER-CUSTOMER-NUMBER N 5.0 D 1 _ ORDER-WAREHOUSE-ID A 3.0 D 1 _ INVOICE-NUMBER N 6.0 1 _ ORDER-TIMESTAMP T MC 1 _ DELIVERY-INSTRUCTIONS A 60.0 N Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9---PF10--PF11-- help retrn |
This window shows the fields in the NCST-ORDER-HEADER file.
Mark the following fields:
ORDER-NUMBER
ORDER-AMOUNT
ORDER-DATE
ORDER-CUSTOMER-NUMBER
ORDER-WAREHOUSE-ID
INVOICE-NUMBER
Press Enter. The first BROWSE Program Build Report panel is displayed:
CSUBLDRP Natural Construct CSUBLD10 Oct 23 BROWSE Program Build Report 1 of 2 1_ Panel(*) Order Label Field name Format AL= >> ------- -------- -------- ------------------------------ ---------- ----- 1 __ ___ 1 * ORDER-NUMBER__________________ N 6.0__ _____ 2 __ ___ 1 * ORDER-AMOUNT__________________ P 13.2_ _____ 3 __ ___ 1 * ORDER-DATE____________________ N 8.0__ _____ 4 __ ___ 1 * ORDER-CUSTOMER-NUMBER_________ N 5.0__ _____ 5 __ ___ 1 * ORDER-WAREHOUSE-ID____________ A 3.0__ _____ 6 __ ___ 1 * INVOICE-NUMBER________________ N 6.0__ _____ 7 __ ___ _ * ______________________________ _ _____ _____ 8 __ ___ _ * ______________________________ _ _____ _____ 9 __ ___ _ * ______________________________ _ _____ _____ 10 __ ___ _ * ______________________________ _ _____ _____ 11 __ ___ _ * ______________________________ _ _____ _____ 12 __ ___ _ * ______________________________ _ _____ _____ 13 __ ___ _ * ______________________________ _ _____ _____ 14 __ ___ _ * ______________________________ _ _____ _____ Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9---PF10--PF11--PF12--- help retrn deflt test gen selfd frwrd bkwrd reord right proto |
This panel displays the fields selected for the report and allows you to define where and how the fields are displayed. The second panel (displayed when you press PF11) allows you to change the default values for the selected fields, such as the field prompt name or the field length and format.
Note:
For more information, see the online help or Build
Report Panel 1 and Build Report Panel 2 in
Natural Construct Generation.
Press PF12 (proto). Natural Construct fills in a panel number and order (sequence) for each field:
CSUBLDRP Natural Construct CSUBLD10 Oct 25 BROWSE Program Build Report 1 of 2 1_ Panel(*) Order Label Field name Format AL= >> ------- -------- -------- ------------------------------ ---------- ----- 1 01 010 1 * ORDER-NUMBER__________________ N 6.0__ _____ 2 01 020 1 * ORDER-AMOUNT__________________ P 13.2_ _____ 3 01 030 1 * ORDER-DATE____________________ N 8.0__ _____ 4 01 040 1 * ORDER-CUSTOMER-NUMBER_________ N 5.0__ _____ 5 01 050 1 * ORDER-WAREHOUSE-ID____________ A 3.0__ _____ 6 02 010 1 * INVOICE-NUMBER________________ N 6.0__ _____ 7 __ ___ _ * ______________________________ _ _____ _____ 8 __ ___ _ * ______________________________ _ _____ _____ 9 __ ___ _ * ______________________________ _ _____ _____ 10 __ ___ _ * ______________________________ _ _____ _____ 11 __ ___ _ * ______________________________ _ _____ _____ 12 __ ___ _ * ______________________________ _ _____ _____ 13 __ ___ _ * ______________________________ _ _____ _____ 14 __ ___ _ * ______________________________ _ _____ _____ Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9---PF10--PF11--PF12--- help retrn deflt test gen selfd frwrd bkwrd reord right proto |
Note:
When ordering fields on the reports, Natural Construct uses 10,
20, 30, etc., instead of 1, 2, 3, etc. This allows you to easily insert fields
later if necessary. For example, to insert a new field in the second position,
you can type 15.
Press PF4 (test). The Test Display window is displayed:
CSGBLDTE BROWSE Program Oct 25 Test Display Panel .. 01 ------------------------------------------------ Order Customer Warehouse Number Order Amount Order Date Number ID ------ ---------------- ---------- -------- --------- 999999 9999999999999999 99999999 99999 XXX Panel .. 02 ------------------------------------------------ Invoice Number -------------- 999999 Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9--- test test test test test test test test test |
Notice that the Invoice Number field is displayed on the second panel by itself. This will make it difficult for a user to determine what order the invoice is associated with. Also, the first panel appears to be crowded so you may want to remove one of the fields from the first panel and place it on the second panel.
Press Enter. You are returned to the Build Report panel.
Specify the following:
* (asterisk) | Panel field preceding ORDER-NUMBER |
2 | Panel field preceding ORDER-WAREHOUSE-ID |
30 | Order field for ORDER-WAREHOUSE-ID |
The order number will appear as the first field on all panels of the report and the warehouse ID will now appear as the third field on the second panel.
Press PF9 (reord). Natural Construct reorders the fields on the panels.
Press PF4 (test) again. The Test Display window is displayed:
CSGBLDTE BROWSE Program Oct 25 Test Display Panel .. 01 ------------------------------------------------ Order Customer Number Order Amount Order Date Number ------ ---------------- ---------- -------- 999999 9999999999999999 99999999 99999 Panel .. 02 ------------------------------------------------ Order Warehouse Number Invoice Number ID ------ -------------- --------- 999999 999999 XXX Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9--- test test test test test test test test test |
Press Enter. You are returned to the Build Report panel.
Press PF5 (gen). The code is generated into the User Exit editor:
0010 DEFINE EXIT WRITE-FIELDS 0020 DECIDE ON FIRST VALUE #PANEL 0030 VALUE 01 0040 WRITE(0) 0050 NCST-ORDER-HEADER.ORDER-NUMBER 0060 NCST-ORDER-HEADER.ORDER-AMOUNT 0070 2X NCST-ORDER-HEADER.ORDER-DATE 0080 3X NCST-ORDER-HEADER.ORDER-CUSTOMER-NUMBER 0090 VALUE 02 0100 WRITE(0) 0110 NCST-ORDER-HEADER.ORDER-NUMBER 0120 5X NCST-ORDER-HEADER.INVOICE-NUMBER 0130 8X NCST-ORDER-HEADER.ORDER-WAREHOUSE-ID 0140 NONE 0150 WRITE(0) 23X 'No fields to display on this panel' 0160 END-DECIDE 0170 END-EXIT 0180 DEFINE EXIT TOP-OF-PAGE 0190 ** 0200 DECIDE ON FIRST VALUE #PANEL 0210 VALUE 01 0220 WRITE(0) 0230 'Order' (I) 0240 30X 'Customer' (I) 0250 WRITE(0) 0260 'Number' (I) 0270 3X 'Order' (I) 0280 1X 'Amount' (I) 0290 3X 'Order' (I) 0300 1X 'Date' (I) 0310 2X 'Number' (I) 0320 WRITE(0) 0330 '------' (I) 0340 1X '----------------' (I) 0350 1X '----------' (I) 0360 1X '--------' (I) 0370 VALUE 02 0380 WRITE(0) 0390 'Order' (I) 0400 17X 'Warehouse' (I) 0410 WRITE(0) 0420 'Number' (I) 0430 1X 'Invoice' (I) 0440 1X 'Number' (I) 0450 4X 'ID' (I) 0460 WRITE(0) 0470 '------' (I) 0480 1X '--------------' (I) 0490 1X '---------' (I) 0500 NONE 0510 WRITE(0) 23X 'No fields to display on this panel' 0520 END-DECIDE 0530 SKIP(0) 1 0540 END-EXIT
If there's more than one panel, Natural Construct automatically generates the required WRITE statements and provides default column headings in the TOP-OF-PAGE user exit (see the example above).
Note:
If there is only one panel, Natural Construct generates a DISPLAY
statement.
Enter "." on the command line. You are returned to the Generation main menu.
Enter "G" in the Function field.
Enter "W" in the Function field. Your browse program is now generated and stowed.
Enter "T" in the Function field. The following panel is displayed:
MYBROWSE ***** Order Entry System ***** Oct 25 - Order Display by Order Number - 1 more > Order Customer Number Order Amount Order Date Number ------ ---------------- ---------- -------- Order Number: ______ Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9--- help retrn quit flip bkwrd frwrd |
Press Enter. The order data is displayed. Use the PF-keys to scroll left and right, up and down.
Press PF11 (right). The next panel of the report is displayed:
MYBROWSE ***** Order Entry System ***** < 1 more - Order Display by Order Number - 10:00 PM Order Warehouse Number Invoice Number ID ------ -------------- --------- 323232 332323 222 323456 123 544 332222 10294 111 333333 231201 111 422222 190123 111 *** End of Data *** Order Number: ______ Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9--- help retrn quit flip bkwrd frwrd |
Press PF2 (retrn). You are returned to the Generation main menu.
You've successfully created an online report with additional fields. If desired, you can also create a drill-down report to display details about a selected record. See the following section, Creating a Drill-Down Report, for information.
Note:
If you have any problems creating the report, see
Troubleshooting and
Debugging for possible reasons.
You can create a drill-down report that displays additional details about a record by selecting and defining the PROCESS-SELECTED-RECORD user exit. The code in this exit calls a browse subprogram when a user selects a record displayed on a report.
To create a drill-down report
Enter "U" in the Function field. The User Exit editor is displayed.
Enter "SAMPLE" on the command line. The first User Exit panel for the Browse model is displayed.
Press Enter again. The second User Exit panel is displayed:
CSGSAMPL NATURAL CONSTRUCT CSGSM0 Oct 25 User Exits 1 of 1 User Exit Exists Sample Required Conditional -------------------------------- -------- ---------- -------- ------------ _ HARDCOPY-TERMINATING-PROCESS Example X _ PROCESS-SELECTED-RECORD Subprogram X _ END-OF-PROGRAM Example _ ASSIGN-PREFIX-VALUE Subprogram X _ SET-PF-KEYS Example _ MISCELLANEOUS-SUBROUTINES Example Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9---PF10--PF11--PF12--- help retrn quit bkwrd frwrd |
Mark the PROCESS-SELECTED-RECORD user exit.
Press Enter. The User Exit editor is displayed, showing the default code generated for the PROCESS-SELECTED-RECORD user exit:
Module ............. MYBROWSE Title .............. Summary Browse for Orders > > + ABS: _ X-Y: _ S 69 L 52 Bot ....+....1....+....2....+....3....+....4....+....5....+....6....+....7.. 0520 END-DECIDE 0530 SKIP(0) 1 0540 END-EXIT 0550 DEFINE EXIT PROCESS-SELECTED-RECORD 0560 * 0570 * Processing to be performed after a record has been selected. 0580 IF *PF-KEY = 'ENTR' THEN 0590 /* 0600 /* Process #SELECTED-KEY record here. 0610 IGNORE 0620 ELSE 0630 /* PF8 will just reposition the selected value to the top of 0640 /* the screen OR you may wish to use PF8 to perform different 0650 /* OR you may wish to use PF8 to perform 0660 /* record processing. 0670 IGNORE 0680 END-IF 0690 END-EXIT |
The Natural Construct-defined variable, #SELECTED-KEY, identifies the selected record. In this case, the order number is the selected key.
Change the default code as follows:
Module ............. MYBROWSE Title .............. Summary Browse for Orders > > + ABS: _ X-Y: _ S 69 L 52 Bot ....+....1....+....2....+....3....+....4....+....5....+....6....+....7.. 0520 END-DECIDE 0530 SKIP(0) 1 0540 END-EXIT 0550 DEFINE EXIT PROCESS-SELECTED-RECORD 0560 * 0570 * Processing to be performed after a record has been selected. 0580 IF *PF-KEY = 'ENTR' THEN 0590 CALLNAT 'NCOSODET' 0600 #SELECTED-KEY 0610 'select fun' /* Note NCOSODET has a 10-character parm 0620 /* field in case a function needs to be passed. 0630 /* In this example we don't need it, but we must 0640 /* pass something. 0650 DIALOG-INFO 0660 MSG-INFO 0670 PASS 0680 END-IF 0690 END-EXIT |
Notice that the syntax calls the NCOSODET module, which displays order lines for a selected order.
Enter "." on the command line. You are returned to the Generation main menu.
Enter "G" in the Function field.
Enter "W" in the Function field. Your browse program is now generated and stowed.
Enter "T" in the Function field. The following panel is displayed:
MYBROWSE ***** Order Entry System ***** Oct 25 - Order Display by Order Number - 1 more > Order Customer Number Order Amount Order Date Number ------ ---------------- ---------- -------- Order Number: ______ Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9--- help retrn quit flip bkwrd frwrd |
Press Enter to display the orders.
Select an order. The order lines for the selected order are displayed in a window:
NCOSODET ***** ORDER SUBSYSTEM ***** Oct 25 - ORDER DETAIL - 1 more > Ln Prod Id Quantity Unit Cost Total Cost -- ------- --------- ---------- ------------ 1 654070 40 100.00 4000.00 2 222222 100 50.00 5000.00 *** End of Data *** Line Order Number: 234234 Line Number: __ Direct command...: ________________________________ Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8 help retrn quit flip bkwrd frw |
Press PF2 (retrn) twice. You are returned to the Generation main menu.
You've successfully created a drill-down report.
The following section describes the NCOSODET subprogram used in this example.
Note:
If you have any problems creating the report, see
Troubleshooting and
Debugging for possible reasons.
NCOSODET is a subprogram that displays additional details about a selected record. To learn more about the module, look at the information specified on the specification panels and in the user exits.
To see the specifications and user exits for NCOSODET
Enter "ncstg" at the Natural Next prompt. The Generation main menu is displayed.
Specify the following:
R | Function field |
NCOSODET | Module field |
Press Enter. Natural Construct reads the module into the edit buffer and displays a confirmation message.
Enter "M" in the Function field. The Standard Parameters panel is displayed:
CUSCMA BROWSE-SUBP Subprogram CU--MA0 Oct 23 Standard Parameters 1 of 5 Module ............. NCOSODET System ............. MYLIB___________________________ Global data area ... ________ With block ......... ________________________________ Title .............. Order Header Detail______ Description ........ This subprogram will display all the lines associated__ with the selected order entry._________________________ _______________________________________________________ _______________________________________________________ First heading ...... ORDER SUBSYSTEM_________________________________ Second heading ..... ORDER DETAIL__________________________________________ Command ............ X Message numbers .... _ Password ........... _ Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9---PF10--PF11--PF12--- right help retrn quit right main |
As indicated by the title, the NCOSODET module is a browse subprogram. Because it is a subprogram, and not a program, a GDA is not required.
Press Enter. The Additional Parameters panel is displayed.
Press Enter again. The Additional INPUT Parameters panel is displayed. These two panels are similar to the panels for a browse program.
Press Enter again. The Specific Parameters panel for a browse subprogram is displayed:
CUSCMF BROWSE-SUBP Subprogram CUSCMF0 Oct 23 Specific Parameters 4 of 5 Parameter Override Note: Format and Length defaults to ORDER-LINE-KEY key Field Name ......... #PDA-KEY Natural format ..... N 6.0__ * Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9---PF10--PF11--PF12--- right help retrn quit left right main |
When the key for the browse subprogram differs from the key for the calling program, you specify the format and length of the passed key (#SELECTED-KEY) on this panel. Since the format and length defaults to the ORDER-LINE-KEY key, which contains the order number and order line sequence number, the format and length has been changed to that of the ORDER-NUMBER key (N6).
Note:
If the key for the browse subprogram is the same size as that of
the calling program, you do not need to specify the format and length on this
panel.
Press Enter. The Restriction Parameters panel is displayed:
CUSCMG BROWSE-SUBP Subprogram CUSCMG0 Oct 23 Restriction Parameters 5 of 5 Prefix Options Restrict browse with prefix .. X Number of characters (bytes) . 6__ Number of components ......... __ Protect prefix ............... X Suppress prefix .............. _ Field Name ............... ________________________________________________ Prefix Helproutine Specifications Component Helproutine Parameter Name 1 ________ * ________________________________ 2 ________ * ________________________________ Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9---PF10--PF11--PF12--- main help retrn quit left userX main |
Because the default key contains the order number and the line sequence number, the first 6 digits (which represent the order number) must be protected. This allows the calling program to determine which order is browsed; the user cannot change the order number.
Press Enter. You are returned to the Generation main menu.
At this point, you can read the MYBROWSE module back into the editor and re-test your report. Drill down to the order lines and see if you can change the order number.
The following section describes how to create a drill-down report when the calling program and the subprogram use different keys.
This section describes the NCOSCSTO module, which browses the NCST-ORDER-HEADER file by customer date. When a user selects a customer, details about the customer's orders are displayed.
To see how this is done, read the NCOSCSTO module into the editor and display the user exits:
0010 DEFINE EXIT LOCAL-DATA 0020 LOCAL 0030 01 ORDER-DETAIL VIEW OF NCST-ORDER-HEADER 0040 02 ORDER-NUMBER 0050 END-EXIT /* LOCAL-DATA 0060 DEFINE EXIT WRITE-FIELDS 0070 DISPLAY 0080 1X 'Order Date'(I) NCST-ORDER-HEADER.ORDER-DATE 0090 (AD=I EM=9999/99/99) 0100 'Order No'(I) NCST-ORDER-HEADER.ORDER-NUMBER 0110 (LC=^) 0120 'Invoice No'(I) NCST-ORDER-HEADER.INVOICE-NUMBER 0130 (LC=^^) 0140 'WH ID'(I) NCST-ORDER-HEADER.ORDER-WAREHOUSE-ID 0150 (LC=^) 0160 'Order Amount'(I) NCST-ORDER-HEADER.ORDER-AMOUNT 0170 END-EXIT 0180 DEFINE EXIT BEFORE-INPUT 0190 * 0200 * Processing to be performed just before the input statement. 0210 /* Change standard message to indicate that selection can be done 0220 /* ONLY by positioning the cursor (not entering key value since 0230 /* input is protected. 0240 ASSIGN MSG-INFO.##MSG = 'Position cursor to select.' 0250 END-EXIT 0260 DEFINE EXIT PROCESS-SELECTED-RECORD 0270 * 0280 * Processing to be performed after a record has been selected. 0290 IF *PF-KEY = 'ENTR' THEN 0300 GET ORDER-DETAIL #SELECTED-ISN 0310 RESET MSG-INFO 0320 CALLNAT 'NCOSODET' 0330 ORDER-DETAIL.ORDER-NUMBER 0340 CDSELPDA.SELECTED-FUNCTION 0350 DIALOG-INFO 0360 MSG-INFO 0370 PASS 0380 END-IF 0390 END-EXIT /* PROCESS-SELECTED-RECORD
Notice that the LOCAL-DATA user exit has been defined. Because the NCOSCSTO module browses by customer date, the customer date is available in the #SELECTED-KEY variable.
When a user drills down to display additional details, the module must have access to the NCST-ORDER-HEADER file to display the order details. To do this with Adabas, you can use the #SELECTED-ISN variable to retrieve the order header file and find the order number.
Also notice the GET statement in the PROCESS-SELECTED-RECORD user exit. When a user selects a record, the order header file is retrieved and the order number is passed to the NCOSODET module.
Another way Natural Construct can save you time and effort is by using the statement models. These models generate individual Natural statements or functions (blocks of code). Some of the benefits of using the statement models are:
Reduces your dependency on the Natural documentation to recall syntax
Reduces the number of keystrokes required to code Natural statements, since keywords are generated automatically
Produces statement code that:
has a consistent indentation scheme
programmatically performs tedious calculations
accesses your system files to retrieve Predict views, etc.
The following sections describe some of the ways you can use the statement models to save time and effort.
For more information, see Statement Models in Natural Construct Generation.
Notes:
You can use the View statement model to generate a Predict view. The following sample procedure generates a view for the NCST-CUSTOMER file.
To generate a Predict view for the NCST-CUSTOMER file
Enter "e p" at the Next prompt. The Natural editor is displayed.
Press the Tab key twice. The cursor should be in the first position of the first line in the editor. This is where you enter the .g line command.
Enter ".g". Because you didn't specify a model name, the Select Model window is displayed:
CSGDLIST Natural Construct CSGDLST0 Oct 25 Select Model 1 of 1 Model Type -------------------------------- ------------ ADD Statement ARBITRARY-FIELD-PROCESSING Statement AT-TOP-OF-PAGE Statement CALLNAT Statement CLOSE Statement COMPRESS Statement DECIDE-FOR Statement DECIDE-ON Statement DEFINE-PRINTER Statement DEFINE-SUBROUTINE Statement DEFINE-VARIABLE Statement Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9--- help retrn bkwrd frwrd Model .. ________________________________ All models ... _ |
Enter "V" in the Model field. The list of models is repositioned to model names beginning with "V".
Select the View model. The VIEW Function window is displayed:
VIEW Function Predict view ............. ________________________________ * Program view ............. ________________________________ C* variables ................... X Redefined components ........... X Superdescriptor fields ......... _ Natural format specifications .. _ |
Select "NCST-CUSTOMER" from the Predict view name field.
Press Enter. The following view is generated:
0010 /* 0020 /* 0030 01 NCST-CUSTOMER VIEW OF NCST-CUSTOMER 0040 02 CUSTOMER-NUMBER 0050 02 BUSINESS-NAME 0060 02 PHONE-NUMBER 0070 02 MAILING-ADDRESS 0080 03 M-STREET 0090 03 M-CITY 0100 03 M-PROVINCE 0110 03 M-POSTAL-CODE 0120 02 SHIPPING-ADDRESS 0130 03 S-STREET 0140 03 S-CITY 0150 03 S-PROVINCE 0160 03 S-POSTAL-CODE 0170 02 CONTACT 0180 02 CREDIT-RATING 0190 02 CREDIT-LIMIT 0200 02 DISCOUNT-PERCENTAGE 0210 02 CUSTOMER-WAREHOUSE-ID 0220 02 CUSTOMER-TIMESTAMP
When you use the statement models to generate Natural statements, you don't need to remember the statement syntax.
To generate a DECIDE-ON statement
Enter ".g(do)" at the beginning of a line in the Natural editor. The following window is displayed:
DECIDE ON FIRST X EVERY _ VALUE OF #NUMBER_______________________ >> 1 VALUE 1_______________________________________________________ ASSIGN ...__________________________________________________ ____________________________________________________________ ____________________________________________________________ ____________________________________________________________ ANY VALUE ____________________________________________________________ ____________________________________________________________ ALL VALUE ____________________________________________________________ ____________________________________________________________ NONE VALUE IGNORE______________________________________________________ ____________________________________________________________ END-DECIDE |
Specify the following:
*PF-KEY | VALUE OF field |
'PF1' | 1 VALUE field |
PERFORM ROUTINE-UPD | Over "ASSIGN" |
Press Enter. The following code is generated:
0010 /* 0020 /* 0030 DECIDE ON FIRST *PF-KEY 0040 VALUE 'PF1' 0050 PERFORM ROUTINE-UPD 0060 NONE 0070 IGNORE 0080 END-DECIDE
When using subprograms, you may want to generate a CALLNAT statement to supply the parameters. You can do this easily using the Callnat statement model. For example, you can generate a CALLNAT statement in the PROCESS-SELECTED-RECORD user exit to pass the selected key to an object PDA. This PDA then passes the data to an object maintenance subprogram for processing.
The following example shows how to use the CALLNAT statement within the PROCESS-SELECTED-RECORD user exit to supply the parameters for MYORDSUB (described in Generating the Object Maintenance Subprogram).
Note:
The source code for the specified subprogram must exist in the
current library or steplib.
To generate a CALLNAT statement for the MYORDSUB subprogram
Enter ".g(cn)" at the beginning of a line in the Natural editor. The following window is displayed:
CALLNAT ________ * |
Note:
For more information, see Using the Callnat Statement
Window in Natural Construct Generation.
Select "MYORDSUB" from the Callnat field.
Press Enter. The following code is generated:
0010 /* 0020 CALLNAT 'MYORDSUB' 0030 ORDER 0040 MYORMSA-ID 0050 MYORMSR 0060 CDAOBJ2 0070 MSG-INFO
Notice that all the parameters from the subprogram are added to the CALLNAT statement. Although you may need to change the names to correspond with the program names, this list helps you determine which parameters are required.
Not all statement models generate Natural statements. The Sequence model generates a block of code that repeats a given line, with some variations, as many times as specified. The changes are applied to each variation.
To generate a repeating sequence with variations
Enter ".g(sq)" at the beginning of a line in the Natural editor. The following window is displayed:
Repeat 3__ > Assign initial-value = my-array(&1&:&2&)________________________________ > ________________________________________________________________________ > ________________________________________________________________________ > ________________________________________________________________________ > ________________________________________________________________________ &n& FROM STEP &1& 001 1__ &2& 001 1__ &3& ___ ___ &4& ___ ___ &5& ___ ___ &6& ___ ___ &7& ___ ___ &8& ___ ___ &9& ___ ___ |
Specify the following:
7 | Repeat field |
WRITE '&1&' | Over "Assign initial-value ..." |
002 | FROM field for &1& |
003 | STEP field for &1& |
Press Enter. The following code is generated:
0010 /* 0020 /* 0030 WRITE 'LINE 2' 0040 WRITE 'LINE 5' 0050 WRITE 'LINE 8' 0060 WRITE 'LINE 11' 0070 WRITE 'LINE 14' 0080 WRITE 'LINE 17' 0090 WRITE 'LINE 20'