introduction to function in synon

31
SYNON – Day 3 Agenda 1. Introduction to Functions 2. Built in functions 3. Message functions 4. Introduction to Action Diagram 5 User points 6. Parameter Usage/Roles 7. Defining Parameter 8. Arrays 9. Handson - Arrays/ Parameters/ Simple program

Upload: vijay-kumar

Post on 12-Feb-2016

408 views

Category:

Documents


14 download

DESCRIPTION

Basic function types in synon.How to create the array in Synon

TRANSCRIPT

Page 1: Introduction to Function in Synon

SYNON – Day 3

Agenda 1. Introduction to Functions

2. Built in functions3. Message functions

4. Introduction to Action Diagram 5 User points

6. Parameter Usage/Roles 7. Defining Parameter

8. Arrays 9. Handson - Arrays/ Parameters/ Simple program

Page 2: Introduction to Function in Synon

Part 1 -Reference Material

Page 3: Introduction to Function in Synon

Introduction to Functions

• ‘Building blocks' or 'templates' that are linked together to form programs.

• Programs may comprise of subroutines/ messages/ as low-level arithmetic operations or as combinations of these elements

• Function is a process that operates on files & fields• Functions are implemented in two ways– External - the function is implemented as a separate HLL

program– Internal - the function is implemented as source code

inside the calling function

Page 4: Introduction to Function in Synon

Functions types– Standard Functions– Built-In Functions– Functions Fields– Message Functions

Standard Functions• The standard functions consist of a variety of function types,

each of which performs a specific process• Divided into 3 categories– Database Functions– Device Functions– User Functions

Page 5: Introduction to Function in Synon

Database Function• Basic routines for accessing the database• All are internal functions• There are 4 database functions

1) CRTOBJ - Create Object2) CHGOBJ - Change Object3) DLTOBJ - Delete Object4) RTVOBJ - Retrieve Object

Device Functions• Used in interactive & report programs• Consist of panel/report design & action diagram• All device functions are external functions except for PRTOBJ

function• Implemented as programs that operate over databases• Device Design specifies the layouts of fields and constants on

the panels or report designs for a function

Page 6: Introduction to Function in Synon

• The Device Functions are1) DSPRCD - Display Record2) DSPRCD2 - Display Record 2 panels3) DSPRCD3 - Display Record 3 panels4) PMTRCD - Prompt Record5) EDTRCD - Edit Record6) EDTRCD2 - Edit Record 2 panels7) EDTRCD3 - Edit Record 3 panels8) DSPFIL - Display File9) EDTFIL - Edit File10) SELRCD - Select Record11) DSPTRN - Display Transaction12) EDTTRN - Edit Transaction13) PRTFIL - Print File14) PRTOBJ - Print Object

Page 7: Introduction to Function in Synon

User Functions• Means of incorporating user programs or subroutines into

Advantage:2E generated applications• Processing steps can be specified with action diagrams or

user-written HLL• Implemented as inline code (internal functions) or call to

programs (external functions)• The User Functions are

1) EXCINTFUN - Execute Internal Function2) EXCEXTFUN - Execute External Function3) EXCUSRPGM - Execute User Program4) EXCUSRSRC - Execute User Source

Page 8: Introduction to Function in Synon

Built-in Functions• Execute functions like arithmetic operations, string

manipulation, control operations like commitment control & program exit.

• Specified within action diagrams• Implemented as in-line source code within calling functions• The Built-in functions are

1) Add 2) Commit3) Compute 4) CONCAT -Concatenation5) CVTVAR - Convert Variable6) DIV - Divide 7) DIV WITH REMAINDER8) Exit Program 9) Modulo10) Move 11) Move All12) MULT - Multiply 13) Quit14) RTVCND - Retrieve Condition15) Rollback 16) Set Cursor17) Substring 18) SUB - Subtract

Page 9: Introduction to Function in Synon

Lovit Tyagi and Deepika Gulati 9

Message Functions• Define workstation messages• Implemented using OS/400 message descriptions• Sent by a call to a CL subroutine• Can make direct references to fields in the data model• The Message functions are

1) SNDERRMSG - Send Error Message2) SNDINFMSG - Send Information Message3) SNDCMPMSG - Send Complete Message4) SNDSTSMSG - Send Status Message5) RTVMSG - Retrieve Message6) EXCMSG - Execute Message

Page 10: Introduction to Function in Synon

Action Diagram/ User Points

• An action diagram contains the processing steps that make up a function.

• The sequence in which actions are executed is controlled by three simple constructs: sequential, conditional, and iterative.

• The Action Diagram Editor’s Subfile selector provides options for editing an action diagram, including options for inserting and manipulating user-defined actions

Page 11: Introduction to Function in Synon

• The action diagram is initially shown at a summary level, with many hidden constructs.

• This allows you to see the entire action diagram in outline form on a single panel.

• Only certain parts of the action diagram may be altered. • The areas that you can modify are called user points and

are indicated by an angle bracket (<) in the right margin of the panel.

• The rest of the default action diagram is protected to ensure that you do not accidentally change essential function processing.

• Within a user point, each user-defined action is indicated by three chevrons (<<<) in the right margin of the panel.

Page 12: Introduction to Function in Synon

Inserting New Constructs

Page 13: Introduction to Function in Synon

Parameter Usage/Roles

• Parameters define the values to be communicated between functions at execution time

• How a parameter is used in the called function will depend on the type of the called function, the processing specified for that function, or both

• Usage Type– Input only, Output only, Both, Neither

• Flag Error Status– specifies error in the called function

• Every function takes the fields in the attached access path as its default parameters of functions

Page 14: Introduction to Function in Synon

Return Code Parameter– Informs the calling program of the state under which

called program was exited– All functions except EXCUSRPGM & EXCUSRSRC have

implicit return code parameter as first parameter– The values of Return Code parameter are

*DBF error; *Normal; *Record already exists;*Record does not exist; *Substring error;*User Quit requested

Page 15: Introduction to Function in Synon

Parameter Roles• Specifies the use of parameter in function• Following are the parameter rolesMap Parameter - the parameter is added automatically to the

corresponding field on the receiving function’s panel design. Map Neither parameter adds field to panel design without passing a value

Restrictor Parameter - the parameter restricts the updation of field by making it input only field

Positioner Parameter - the parameter is used to position a function to start reading records from a particular record

Vary Parameter - the parameter can have a varying length. Useful for interfacing with user-written functions

Page 16: Introduction to Function in Synon

Parameter Context

• Parameter context specifies how a field is used in a function1. The "DB1" (DATABASE FILE 1) Context• The DB1 context contains the fields which are in the first, or

only, format of the AllFusion 2E access path to which An AllFusion 2E function attaches.

• Any field on the access path format will be available in the DB1 context.

• The DB1 context is available in the action diagram of all function types which update the database, both after reading a database file and before writing to the database.

Page 17: Introduction to Function in Synon

2. The "PGM" (PROGRAM) Context• The PGM context contains AllFusion 2E system fields that control

The execution of An AllFusion 2E function, such as the '*Program mode‘

• The PGM context is fixed and additional fields may not be added to it

• The fields that appear in the PGM context are defined by An AllFusion 2E system file called '*Program data'

3. The "JOB" (JOB) Context• The JOB context contains system fields that supply run time

information about the job executing the HLL program• for example, the user name, the job name and the job

start time. • The JOB context is fixed and additional fields may not be

added to it.• Fields in the JOB context may be used only for input to other

functions. They cannot be changed.

Page 18: Introduction to Function in Synon

4. The "PAR" (PARAMETER) Context• The PAR context contains the fields that have been defined as

parameters for the current function, i.e. the function whose actiondiagram you are editing.

• Function parameters are specified using the 'EDIT FUNCTION PARAMETERS’ display.

• Defining a field as An AllFusion 2E function parameter automatically adds it to the PAR context of the function.

• Input parameters to the current function will only be available inthe PAR context where they can be input parameters to other functions,and output parameters will only be available as output parameters inother functions.

5. The "WRK" (WORK) Context• The WRK context contains program variables not described by any

other context • required for calculations within a program.• Any field in the field dictionary may be used as a work field.

Page 19: Introduction to Function in Synon

• Additional user-defined fields may be added to the WRK context byadding the field to the field dictionary, using the AllFusion 2E'DEFINE OBJECTS' display.

6. The 'LCL' (Local) Context• The LCL context contains program variables which can be used in a

similar way to the 'WRK' (Work) context, which is for the temporarystorage and retrieval of data, for calculations, for program control,etc.

• The difference between LCL and WRK is that the LCL context has alocal scope to the function in which it is used (that is, each individualfunction whether internal of external has its own separate sequenceof LCL fields independently of all other functions), whereas the WRKcontext has global scope within an external function (that is, there isonly one sequence per program).

• Any field in the field dictionary may be used as a local field.• Additional user-defined fields may be added to the LCL context by

adding the field to the field dictionary, using the AllFusion 2E'DEFINE OBJECTS' display.

Page 20: Introduction to Function in Synon

7. The 'NLL' (Null) Context• The NLL context is a convenient target for output parameters from a

function call which are not required for further processing.• Only output parameters may be directed to the NLL context8. The "CND" (CONDITION) Context• The CND context enables you to specify that a particular AllFusion

2E field condition value is to be supplied as field value either:-a. As a parameter to An AllFusion 2E function.b. As the condition which controls a condition or iteration construct in the action diagram.

• All field conditions attached to An AllFusion 2E field will beavailable in the CND context for that field.

Page 21: Introduction to Function in Synon

9. The "CON" (CONSTANT) Context• The CON context contains any constant or literal values that you

wish to specify.• The CON context may only be used to specify input values to AllFusion

2E fields. • Furthermore, it may not be used for AllFusion 2E fields

of type 'Status' (STS) (you should use the CND context for STS fields).1. Numeric constants must be less than or equal to 10 characters in length, including the decimal point and sign, if any. 2. The maximum number of characters allowed to the right of the decimal point is 5.3. Alphanumeric constants must be less than or equal to 20 characters in length.

Page 22: Introduction to Function in Synon

10. The "DTL" (DETAIL) Context• The DTL context contains the fields which are either on the screen

display of An AllFusion 2E device function that has a single, non-subfile, detail screen display attached to it (e.g. 'Edit record' or'Prompt Record'), or on the first detail screen of An AllFusion 2Edevice function that has a multi-part screen design attached to it(e.g. 'Edit Record (2 screens)').

• All the fields from the AllFusion 2E Access path associated with theAllFusion 2E function will be available in the DTL context.

• Any parameters which are mapped to the screen (mapped or restrictor parameters) and the *CMD key field will also be available.

• If any function fields have been added to the first (or only) detail screen display, this field will be present in the DTL context.

Page 23: Introduction to Function in Synon

11. The "CTL" (SUBFILE CONTROL) Context• The CTL context contains the fields which are in the subfile control

record of AllFusion 2E device function types which have a subfilescreen display, for example 'Display file' or 'Edit transaction‘.

• The fields available in the CTL context depend on the type ofAllFusion 2E function type, the AllFusion 2E access path used by that function, and whether there are 'restrictor parameters' for the function.

Page 24: Introduction to Function in Synon

12. The "KEY" (KEY SCREEN) Context• The KEY context contains the fields which are on the key screen

display of AllFusion 2E device functions that have key screens; for example 'Edit record‘.

• All the key fields from the access path being processed by the AllFusion 2E function will be available in the KEY context, together with any associated virtual fields.

• Parameters which are mapped to the screen (mapped or restrictor parameters) will also be available in this context.

Page 25: Introduction to Function in Synon

13. The "RCD" (SUBFILE RECORD) Context• The RCD context contains the fields which are in the subfile

record of AllFusion 2E function types which have a subfile screen display; for example 'Display file' or 'Edit transaction'.

• The fields available in the RCD context depend on the type of AllFusion 2E access path to which the AllFusion 2E function is attached.

• In all cases, any parameters mapped to the screen (mapped or restrictor parameters) will be present in the RCD context, and the subfile selector field, *SFLSEL, will be present unless it has been dropped using the 'EDIT FUNCTION OPTIONS' display.

Page 26: Introduction to Function in Synon

14. Defaulting parameter values• If the function has any undefined parameters, you have

the option of pressing F10 to supply default values for those undefined parameters.

• The default values will be supplied as follows:1. The context used will be taken from the 'Default context' specified in the subfile control area2. Available default contexts are:

- 'LCL' - All parameters will use the LCL context.- 'WRK' - All parameters will use the WRK context.- 'NLL' - Output parameters will use the NLL

context.

Page 27: Introduction to Function in Synon

Arrays• The array provides a way of storing data, in memory, within a

function, which will persist across calls to that function providing the function does not close down

• Arrays may be used to define parameters for a function, thus avoiding the limit of 9 lines per function

• To read an array, simply call the RTVOBJ based over the array from the calling function.

• To delete all array elements, call a DLTOBJ based on the array, with no parameters specified.

• To load an array, build a RTVOBJ reading all required records over the appropriate file, and when each record is found call the CRTOBJ for the array.

Page 28: Introduction to Function in Synon

Compilation & Generation

• Use J for generating source and object in batch• Take F17 to navigate to DISPLAY SERVICES

MENU • Take option 1 and press enter• Press enter to confirm the compilation list

Page 29: Introduction to Function in Synon

Part 2 – Hands on

Page 30: Introduction to Function in Synon

• Create a program to – Accept Emp Code & Emp Marks as input– Based on Marks calculate Grade and Result– Update the file

Page 31: Introduction to Function in Synon

Thank You