guide for ibm i programming - systemobjects guide for ibm i programming.pdf · guide for ibm i...

75
SmartPad4i © SystemObjects 2015 Release version 2.1 Page: 1/75 Guide for IBM i programming

Upload: truongkhanh

Post on 30-Aug-2018

235 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 1/75

Guide for IBM i programming

Page 2: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75

Introduction

Edit box

Label

Image component

Hyperlink

Combo box

Check box

Radio button

Push button

Table component o Header and footer o Body

Example 1 - Simple Record o Example 1 - part 1 Data Structures o Example 1 - part 2 RPG Program o Example 1 - part 3 COBOL Program

Example 2 - Output Subfile Record o Example 2 - part 1 Data Structures o Example 2 - part 2 RPG Program

Example 3 - Input/Output Subfile Record o Example 3 - part 1 Data Structures o Example 3 - part 2 RPG Program

API SP4IPHONE

Define Menu

Run your program without Menu

Open your Menu

Page 3: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 3/75

Introduction

Before to work with this document, please read the following documents:

Guide for HTML components.

Develop with SmartPad4i Designer.

With SmartPad4i Designer, when asking the generation of IBM i program, you are invited to input the name of the library of your choice and a program name. The name of the program you input cannot exceed 7 characters.

The library must exist on the IBM i. SmartPad4i will create physical source files if they don't exist. The physical source files concern QCLSRC, QDDSSRC, QRPGSRC, QRPGLESRC and QLBLSRC.

SmartPad4i will create a CLP program named SETENV of which the content is:

PGM

CHGLIBL LIBL(yourlib SP4I QTEMP QGPL)

ENDPGM

If the SETENV source member exists already in the QCLSRC file, the program creation is omitted.

This program is useful when you compile and run the generated program.

SmartPad4i Designer will generate for each HTML document the following objects:

For each record found in the HTML document, there will be one physical file to define input fields and another physical file for output fields. If there is no input field then the concerned physical file will not be created. This is the same for output field. These physical files are used in the RPG or COBOL program to define the external data structures. The source code of each physical file is located in QDDSSRC file and the compiled object is located in the library you have input in the SmartPad4i Designer.

For each language you ask (RPG, ILE RPG, COBOL), SmartPad4i will create one source member in the corresponding source file QRPGSRC, QRPGLESRC and QLBLSRC.

Generally, SmartPad4i Designer defines records in the HTML document as follows:

SmartPad4i Designer analyzes the HTML code between <FORM> and </FORM> tags, and consider only objects defined with an ID tag, the records are defined as follows:

If there is no <TABLE ID=...>, the HTML document will have only one record. When there is one <TABLE ID=...> tag, then the HTML part before the <TABLE

ID=...> tag is defined in one record and SmartPad4i Designer will create new

Page 4: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 4/75

record or records for the HTML part between <TABLE ID=...> and </TABLE>. SmartPad4i Designer creates one record for the HTML part between <THEAD> and </THEAD>, one record for the HTML part between <TBODY> and </TBODY> and one record for the HTML part between <TFOOT> and </FOOT>,

SmartPad4i Designer continue to create new record (s) with the HTML part after </TABLE> tag with the same way as described above.

There are two types of records, like defined in the display files, the record defines for the HTML part between <TBODY> and </TBODY> tags is a multi-line record or a SUBFILE record. The records defined for other HTML parts are NORMAL record.

Each record has a number from 01 to 99. SmartPad4i gives 01 to the first record found in the top of the document and increase the number until the end of file.

Each record found in the HTML document can contain input and output fields. Input fields mean the IBM i program will receive these information and output fields mean the IBM i program will send these information to display on the browser. SmartPad4i will create one physical file for input fields and one physical file for output fields. A record can have from zero up to two physical files. The names of these files are codified as follows:

For input field, the name is composed of the program name, the number of the record and the letter I,

For output field, the name is composed of the program name, the number of the record and the letter O.

For example, if you names your program MYPGM then the physical files for the first record should be MYPGM01I and MYPGM01O.

Some HTML components such as Image, Push Button, Link and Area can be associated an Action Code that will be sent to the IBM i program. This Action Code is seen as a function key or a processing code and does not defined in the physical files.

Remember that SmartPad4i Designer gets only components defined with an ID in the HTML document.

In the following sections, you will see how each kind of HTML component is defined in the data structure.

As said above, these physical files are used in the RPG or COBOL program to define the external data structures. For normal record, the data structure is one occurrence structure. For sub file record, the data structure is multiple occurrence one.

The generated IBM i program does the following actions:

Initiates the program environment. This is equivalent to the Opening of the display file,

Sends to the browser all output field values to display. Before the SEND function is done, you have to set the values of these fields.

Receives and Action Code and input field information, updates input field data structures,

Page 5: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 5/75

At this step, you should analyze the action code, input field information and process.

In the source code, you have to put your code between the <YOURCODE> and </YOURCODE> tags. This rule is to permit to save your code the next time when you will call SmartPad4i Designer to generate the program again.

The program is generated with a main that calls the following sub-routines:

SPINIT: Do not change this routine. This routine is called at the beginning of the program to initialize communication area.

YRINIT: This is your routine. Normally you use this routine to initialize your variables at the beginning of the program. Put your code inside the routine and don't change the calling instruction of this routine in the Main program.

YRDATA: This is your routine. Normally you use this routine to set the value of the output fields before the SPSEND routine is called. Put your code inside the routine and don't change the calling instruction of this routine in the Main program.

SPSEND: Do not change this routine. This routine is called to send output fields values to the Web. This function is equivalent to the WRITE operation code in RPG or in COBOL.

YRERRS: This is your routine. This routine is call if error occurs in the SPSEND, variable SPRETN not equal "00". You can prepare in this routine what you decide to do if an error occurs. Put your code inside the routine and don't change the calling instruction of this routine in the Main program.

SPRECV: Do not change this routine. This routine is called to receive the Action Code and the value of input fields. It's this routine to set the received values in the data-structures for input fields. This function is equivalent to the READ operation code in RPG or in COBOL.

YRERRR: This is your routine. This routine is call if error occurs in the SPRECV, variable SPRETN not equal "00". You can prepare in this routine what you decide to do if an error occurs. Put your code inside the routine and don't change the calling instruction of this routine in the Main program.

GTDATA: This is your routine. Do what you want with the value of the input fields after the SPRECV routine. Put your code inside the routine and don't change the calling instruction of this routine in the Main program.

After the SPRECV and GTDATA routine callings, you have the possibilities to put your code in the Main program in order to change the program logic. There are two blocs <YOURCODE> ... </YOURCODE> after each routine in which you will put your code.

In the SmartPad4i Designer, for each component you have to set a name, a length, a type and an usage for the component. The name you give in the Designer cannot exceed 5

Page 6: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 6/75

characters. SmartPad4i will add to the name the prefix "I" for input field and the prefix "O" for output field.

Page 7: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 7/75

Edit box

Edit Box can be defined as input and/or output field.

In the SmartPad4i Designer, you have to set a name, a length, character type and an usage for the component. The name you give in the Designer cannot exceed 5 characters.

For usage "Input", one field is defined in the physical file for input fields. The name of field is composed of the letter "I" and the 5 character name you set. The field length and field type are what you define.

For usage "Output", one field is defined in the physical file for output fields. The name of field is composed of the letter "O" and the 5 character name you set. The field length and field type are what you define.

For usage "Both", one field is defined in the physical file for input fields and one field is defined in the physical file for output fields.

Page 8: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 8/75

Label

Labels are used to display data coming from your IBM i program. It cannot be input field but only output field.

In the SmartPad4i Designer, you have to set a name, a length, a type and an usage "Output" for the component. The name you give in the Designer cannot exceed 5 characters.

One field is defined in the physical file for output fields. The name of field is composed of the letter "O" and the 5 character name you set. The field length and field type are what you define.

Page 9: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 9/75

Image component

An image component can be of usage "Input" or "Both". “Both” means "Input” and “Output".

Usage "Input" is used if the component will send an “Action Code” to the IBM i program when the component is clicked on.

Usage "Output" is used if the IBM i program must send the image name to be displayed.

Usage "Both" is used if the IBM i program must send the image name to be displayed and receive an “Action Code”.

In the SmartPad4i Designer, you have the possibility to define the usage of the component. If the usage has the value Input/Both then the “Action code” is processed. If the usage is Output then the action code is ignored.

In the SmartPad4i Designer, when defining this component, you have to do the following:

Type 1, static image: the image is defined in the HTML document. In this case don't define an IBM i name, just check the value of the “Action code” that will be sent to the program when the component is clicked on. Set the Usage to "Input".

Type 2, dynamic image: the IBM i program will send an image name to change the display of the component. In this case define an IBM i name that is character field.

If you don't want to send an “Action code” to your program then define usage as "Output".

If you want to send an “Action code” to your program then define usage as "Both" and check the value of the “Action code” that will be sent to the program when the component is clicked on.

Usage "Input" in this case is equivalent to the Type 1, static image.

You will then set the value of the field in your program. Remember the field will contain only the "name.extension" of the image, with eventually sub-directories. The first part of the path of the image is always the one defined by yourself in the HTML document. The path you define is the relative one relative to the directory where the HTML document stays. The HTML must reside always in the ..htdocs\smartpad4i\html\ IBM i library \ or ..webapps\smartpad4i\html\IBM i library\ directory. “htdocs” represents the Document Root directory of your IBM HTTP server. . “webapps” represents the Document Root directory of your Apache Tomcat server.

You can define your image by one of the two following ways:

o Definition 1: < IMG src="test.gif" ...>: your image file stays in the ..htdocs\smartpad4i\html\ IBM i library \ directory,

Page 10: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 10/75

o Definition 2: < IMG src="mydir\test.gif" ...>: your image file stays in the ..htdocs\smartpad4i\html\ IBM i library \mydir directory, in this case mydir is a sub-directory of the \html directory,

What your program sends will replace the test.gif expression. For example, you are using the Definition 2: < IMG src="mydir\test.gif" ...> : and your program send myimage.gif then the final difinition will be src="mydir\myimage.gif" ...>

Another example, your program send myanotherdir\myimage.gif then the final difinition will be src="mydir\myanotherdir\myimage.gif" ...>

For usage "OUTPUT" and "BOTH", one field is defined in the physical file for output fields. The name of field is composed of the letter "O" and the 5 character name you set. The field length and field type are what you define.

For usage "INPUT", no field is defined. This usage is used for the “Action Code” only.

Page 11: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 11/75

Hyperlink

An hyperlink can be used to make different type of actions:

1. Display a static text to the user and generate an action code to your program, 2. Display a dynamic text sent by your program and generate an action code to

your program, 3. Display a dynamic text sent by your program and generate the display of a new

browser directed to the url sent by your program.

For those three types you need to declare the id tag.

If you want the hyperlink component to send an action code to your program then you have to define the url address as "href="#". This is the convention and "#" will not be processed.

In runtime when the user click on this link, the IBM i program will receive or not an action code that permits the program to act consequently. The action code can be considered as a function key.

In the SmartPad4i Designer, you have the possibility to define the usage of the component. If the usage has the value Input/Both then the action code is processed. If the usage is Output then the action code is ignored.

In the SmartPad4i Designer, when defining this component, you have to do the following:

For type 1: don't define an IBM i name, just check the value of the action code that will be sent to the program when the component is clicked on. Set the Usage to "Input".

For type 2: define an IBM i name that is character field. Check the value of the action code that will be sent to the program when the component is clicked on. Set the Usage to "Both". Your program will set in this field the text to be displayed as an hyperlink.

For type 3: define an IBM i name that is character field. Set the Usage to "Output". Your program will set in this field the text to be displayed as an hyperlink and the url, the two information are separated by the character "|". (pipe). “Action code” is ignored for this type of link.

For usage "OUTPUT" and "BOTH", one field is defined in the physical file for output fields. The name of field is composed of the letter "O" and the 5 character name you set. The field length and field type are what you define.

For usage "INPUT", no field is defined. This usage is used for the “Action Code” only.

Page 12: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 12/75

Combo box

Different types of combo box can be used by SmartPad4i in your HTML page:

1. Constant values put in your page to let the user choose one or multiple values to send back to your program,

2. Dynamic values coming from your program to let the user choose one or multiple values to send back to your program.

For both types you can choose to send back to your program a predefined value or the text displayed in the combo box itself. You need to define an id tag for each component of these.

Here is a sample:

<select id="D1"> <option selected value="1">Choose value one</option> <option value="2">Choose value 2</option> </select>

In this sample with only two lines in the combo, the value returned to your program will be the character 1 or 2, and if you don't specify value="1", the value returned will be Choose value one.

Here is another sample and for multiple selection:

<select id="D1" multiple> <option value="1">Choose value 1</option> <option selected value="2">Choose value 2</option> <option value="3">Choose value 3</option> </select>

In the SmartPad4i Designer, you have the possibility to define this kind of component as follows:

For type 1: Your IBM i program doesn't send anything but receives the value. Define the component as follows:

don't define an IBM i name, set the Usage to "Input". edit « Additional Information » to set

o the number of values. This will define the maximum number of values that the IBM i program can receive. If there is no property "multiple" in the <select> tag, then the user can select only one value and so the number of values should be 1. If the property "multiple" in the <select> tag is defined, then the user can select several values. In this case if the user

Page 13: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 13/75

selects more than the number defined here then your program will receives only the number of values you define here and the remainder of selected values will be ignored.

o the length in characters for field that receives the selected value (s).

The following figures show additional property page of the SmartPad4i Designer for type 1.

For type 2: Your IBM i program sends the selected indicators, the values and the descriptions to be displayed on the browser and receives the selected value (s). Define the component as follows:

define an IBM i name as character field, set the Usage to "Both". "Both" means Input/Output. edit « Additional Information » to set

o the number of values. This is the number of occurrences of the combo box of which IBM i program will send values and description to be displayed. In the case when the property "multiple" in the <select> tag is defined, this value define also the maximum number of values that the IBM i program can receive. If there is no property "multiple" in the <select> tag, then the IBM i program will receive only one value.

o the length in characters for field containing the value of each occurrence. o the length in characters for field containing the description of each

occurrence.

The following shows additional property page of the SmartPad4i Designer for type 2.

Page 14: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 14/75

For usage "Input" (Type 1), two fields are defined in the physical file for input fields:

The first field defines a zoned 4,0 decimal field in which the IBM i program will receive the number of values it receives. For example if the user selects one value then the value in this field should be 1. If the combo box is a multiple selected option combo box then if the user selects two values then value in this field should be 2. The name of this field is composed of the letter "I", the number of the record and the field order number in the record. For example, I01003.

The second field contains the selected values. The name of the field is the letter "I" and the 5 character name you set in the SmartPad4i Designer. The length of this field is the multiplication of the "number of values" and the "Select Value length" defined in the SmartPad4i Designer. For single selected value combo box, the number of values is 1. The values are ranged in the field from the beginning of the field. Each value takes the length of the defined selected valued length.

For usage "Both" (Type 2):

Two fields are defined in the physical file for input fields: o The first field defines a zoned 4,0 decimal field in which the IBM i program

will receive the number of values it receives. For example if the user selects one value then the value in this field should be 1. If the combo box is a multiple selected option combo box then if the user selects two values then value in this field should be 2. The name of this field is composed of the letter "I", the number of the record and the field order number in the record, for example I01003.

o The second field contains the selected values. The name of the field is the letter "I" and the 5 character name you set in the SmartPad4i Designer. The length of this field is the multiplication of the "number of values" and the "Select Value length" defined in the SmartPad4i Designer. For single selected value combo box, the number of values is

Page 15: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 15/75

1. The values are ranged in the field from the beginning of the field. Each value takes the length of the defined selected valued length.

Two fields are defined in the physical file for output fields: o The first field defines a zoned 4, 0 decimal field in which the IBM i

program will set the number of combo box <option> tag (value + description) that will be sent. The name of this field is composed of the letter "O", the number of the record and the field order number in the record, for example I01003.

o The second field contains the combo box <option> tags. Each <option> tag is composed of a flag for selected or not, the value and the description. The name of the field is the letter "O" and the 5 character name you set in the SmartPad4i Designer. The length of this field is the multiplication of the "number of values" and the sum of the "flag length" + "Select Value length" + "Select Description length" defined in the SmartPad4i Designer. "The flag length" is one character for character field and two characters for J, E, O, G type fields. If the option is wanted to be displayed selected then the IBM i must set the value to "1" or "01", otherwise "0" or "00" depending on the length of the flag. The values are ranged in the field from the beginning of the field. Each value takes the length defined above.

Page 16: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 16/75

Check box

A check box field is displayed with two elements. The first is a square on which you can click with the mouse. Each time you click on the element, you will change the value from 1 to 0 and vice versa. The second element is the associated text that is the description. For example,

<td><input type="checkbox" id ="C1" >You are in this category</td>

<td><input type="checkbox" id ="C2" value="ON" >You are checked</td>

You must define a check box field with an id tag.

You can declare any number of check box fields in your page, and when the user clicks on this field your program will receive 0 or 1 for each of them.

There are two ways to define a check box:

type 1: You define a check box in the HTML file and the IBM i program will receive the value 1 or 0 of the clicked on component,

type 2: Your IBM i program send the checked indicator and the description of the check box to display on the browser and will receive the value 1 or 0 of the clicked on component. Even in this case, you define normally the check box in the HTML file. The description will be overridden by the program description.

In the SmartPad4i Designer, you have the possibility to define this kind of component as follows:

For type 1: Your IBM i program doesn't send anything but receives the value. Define the component as follows:

define an IBM i name, field type is one character, set the Usage to "Input".

For type 2: Your IBM i program send the description to display and receives the value. Define the value as follows:

define an IBM i name, field type is chacracter, field length is the length of the description, set the Usage to "Both". Both means Input/Output.

For usage "Input" (Type 1), one field is defined in the physical file for input fields. The name of the field is the letter "I" and the 5 character name you set in the SmartPad4i Designer. The length of this field is one character that you have defined. The IBM i program receives the value " 0" for unchecked status and "1" for checked status.

Page 17: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 17/75

For usage "Both" (Type 2):

One field is defined in the physical file for input fields The name of the field is the letter "I" and the 5 character name you set in the SmartPad4i Designer. The length of this field is one character for A type field or 2 characters for J, G, E, O type field. The IBM i program receives the value "0" or "00" for unchecked status and "1" or "01" for checked status, depending on the length of the field.

One field is defined in the physical file for output fields. The name of the field is the letter "O" and the 5 character name you set in the SmartPad4i Designer. The length of this field is the one you have defined for the description plus the length for checked status. The checked status length can be one character for A type field or 2 characters for J, G, E, O type field. The value of this field is to be set in the IBM i program and the value is composed of the checked status and the description.

Page 18: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 18/75

Radio button

A radio button field can have only two states, pushed or not pushed.

In general radio button is used in group to let the user choose one between multiple options.

In any case, when the user pushes a radio button, SmartPad4i will send the value of the pushed button. This value must be different for each button in order to identify what is the choice of the user.

You must define for each group of radio button an id tag and a Name tag.

Example:

<td><input type="radio" checked id="R1" name="R1" value="V1">text <p><input type="radio" id="R1" name="R1" value="V2">other text</td>

In this sample we have two buttons named R1 (attention all the buttons of a group must have the same name and the same ID), and the values returned are either V1 or V2. For type 1, the text is a constant.

There are two ways that you can define radio buttons:

type 1: You define a radio button or a group of radio button in the HTML file and the IBM i program will receive one value of the pushed radio button,

type 2: Your IBM i program sends the checked indicator, the value and the description of the radio buttons to display on the browser and will receive the value of the pushed radio button. Even in this case, you define normally a group of radio buttons in the HTML file, the description and the value of each button will be overridden by the program values.

In the SmartPad4i Designer, you have the possibility to define this kind of component as follows:

For type 1: Your IBM i program doesn't send anything but receives the value of the pushed radio button. Define the component as follows:

define an IBM i name as character field, set the Usage to "Input". edit Additional Information to set the field length to receive the value.

The following shows additional property page of the SmartPad4i Designer for type 1.

Page 19: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 19/75

For type 2: Your IBM i program sends the description to display and receives the value. Define the value as follows:

define an IBM i name as a character field, set the Usage to "Both". “Both" means Input/Output. edit Additional Information to set

o the number of values. This is the number of radio buttons of which the IBM i program will send checked indicators, values and description to be displayed,

o the length in characters for field containing the value of each radio button,

o the length in characters for field containing the description of each radio button.

The following shows additional property page of the SmartPad4i Designer for type 2.

Page 20: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 20/75

For usage "Input" (Type 1), one field is defined in the physical file for input fields. The name of the field is the letter "I" and the 5 character name you set in the SmartPad4i Designer. The length of this field is the length of the "Radio Value Length" you have defined in the SmartPad4i Designer.

For usage "Both" (Type 2):

One field is defined in the physical file for input fields. The name of the field is the letter "I" and the 5 character name you set in the SmartPad4i Designer. The length of this field is the length of the "Radio Value Length" you have defined in the SmartPad4i Designer.

Two fields are defined in the physical file for output fields: o The first field defines a zoned 4,0 decimal field in which the IBM i program

will set the number of radios that will be sent. The name of this field is composed of the letter "O", the number of the record and the field order number in the record, for example I01003.

o The second field contains the radio contents. Each content is composed of a flag for selected or not, the value and the description. The name of the field is the letter "O" and the 5 character name you set in the SmartPad4i Designer. The length of this field is the multiplication of the "number of values" and the sum of the "flag length" + "Radio Value length" + "Radio Description length" defined in the SmartPad4i Designer. "The flag length" is one character for character field and two characters for J, E, O, G type fields. If the option is wanted to be displayed selected then the IBM i must set the value to "1" or "01", otherwise "0" or "00" depending on the length of the flag. The values are ranged in the field from the beginning of the field. Each value takes the length defined above.

Page 21: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 21/75

Push button

A push button field can be used to trigger a communication exchange between the user and your IBM i program.

You must define for each button an id tag.

Example:

<TD><input id="BT1" name="BT1" type="button" value="OK"></TD>

You can define a number of buttons you need in your HTML page.

What you see on the browser is the value of the button. This value can be the one defined in the HTML page as above or it can be overridden by the value sent by your program. In two cases, the program will receive an action code when the button is clicked on.

In the SmartPad4i Designer, you have the possibility to define this kind of component as follows:

type 1: Your IBM i program doesn't send the value of the button to display but receives only the action code. Define the component as follows:

don't define any IBM i name for the component, set the Usage to "Input". edit the Action code property page and set the action code value.

type 2: Your IBM i program send the value of the button to display and receives only the action code. Define the component as follows:

define an IBM i name as character field, set the Usage to "Both". Both means "Input" and "Output", edit the Action code property page and set the action code value.

The following figure shows the Action code property page:

Page 22: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 22/75

For usage "INPUT", no field is defined. This usage is used for the Action Code only.

For usage "BOTH", one field is defined in the physical file for output fields. The name of field is composed of the letter "O" and the 5 character name you set. The field length and field type are what you define.

Page 23: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 23/75

Table component

A table component is used to display multiple identical lines, like a sub file.

SmartPad4i Designer will see the table as a sub file if there is ID tag in the <TABLE> tag.

A table is composed of a header; a body and a footer. The header and footer are optional.

You create the body with only one record of the table and in the IBM i program you will set the number of records to work with. A record is composed of one or several rows. <TR> .....</TR> tags define one row.

A general declaration for a table looks like the following code:

<TABLE id="table1">

<THEAD> <TR> '1st line of the header <TD> '1st cell of the 1st line of the header ... ... 'a header can have any number of cells </TR> 'end of the first line of the header <TR> 'a header can have any number of lines .... .... </TR> </THEAD> 'end of the header

<TBODY> <TR> '1st line of the body <TD> '1st cell of the 1st line or the body .... .... 'a body can have any number of cells </TR> 'end of the first line of the body <TR> 'at design you can create any number of .... 'lines to see how your table will look .... 'like, all these lines will be replaced .... 'by SmartPad4i at the run time </TR> </TBODY> 'end of the body <TFOOT> <TR> '1st line of the footer <TD> '1st cell of the 1st line of the footer ... ... 'a footer can have any number of cells

Page 24: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 24/75

</TR> 'end of the first line of the footer <TR> 'a footer can have any number of lines .... .... </TR> </TFOOT> 'end of the footer </TABLE>

SmartPad4i will create 3 records, one for the header, one for the body and one for the footer.

Each record can have input and/or output fields so for each record there can be one physical files created for the data structure of input fields and one physical file for the data structure of output fields.

The physical files created for the header and the footer contains all fields found in the header or in the footer.

The physical files created for the body contains all fields found in the body. In RPG and COBOL programs, the data structures for the body are of multiple occurrences. In the RPG and COBOL program, you have to set, for each transaction, the number of the first row and the number of the last row the program will work with.

The table contains the same components as those defined out of the table, such as Edit box, Label, Combo box, Radio button, push button. Therefore the rules for fields are the same as defined above.

Page 25: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 25/75

Example 1 – Simple record Part 1 data structures

Suppose you want to work with the following document:

The HTML code is the following:

<HTML>

<HEAD>

</HEAD>

<BODY>

<FORM method="POST">

<br>

Please type information for search

<br><br><br>

<table>

<tr>

Page 26: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 26/75

<TD ID=LAB1>Customer code</TD>

<TD><input ID="EDT1" name = "" type="text" value="" maxlength=10></TD>

</tr>

<tr>

<TD>or Customer name </TD>

<TD><input ID="EDT2" name = "EDT2" type="text" value="" maxlength=10></TD>

</tr>

<tr>

<TD>and click on </TD>

<TD><input ID="BT1" name = "BT1" type="button" value="SEARCH"></TD>

</tr>

</table>

</BODY>

</HTML>

In this example, SmartPad4i Designer will see 1 record and 4 components because of 4 ID.

The first component is a label with ID=lab1. This has as value "Customer Code". Then there are 2 edit components with ID=EDT1 and ID=EDT2 The last component is the button with ID=BT1.

The record here is not a sub file type record even if the components are between <TABLE> and </TABLE> tags. The record is not a sub file type record because the <TABLE> tag has no ID.

Suppose now you want your IBM i program to change the label and the value of the button and you would like the 2 Edit boxes as Input fields. You will work with the SmartPad4i Designer and you define:

for the label, the name you give is "LAB1", usage=output, character field and length=10,

for first edit box, the name you give is "EDT1", usage=both, decimal field and length=7,0 ,

for second edit box, the name you give is "EDT2", usage=both, character field and length=30,

for the button, the name you give is "BT1", usage=both, character field and length=10.

You now ask SmartPad4i Designer to generate the IBM i program. Suppose you name the program MYPGM. In this case SmartPad4i Designer will create two physical files for

Page 27: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 27/75

the data structures. The name of these files will be MYPGM01I and MYPGM01O, the DDS are the following:

MYPGM01I 0001.00 * HTML FILE: example1.html 0002.00 A R MYPGM 0003.00 A IEDT1 00007S00 0004.00 A IEDT2 00030

MYPGM01O 0001.00 * HTML FILE: example1.html 0002.00 A R MYPGM 0003.00 A OLAB1 00010 0004.00 A OEDT1 00007S00 0005.00 A OEDT2 00030 0006.00 A OBT1 00010

Page 28: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 28/75

Example 1 – part 2 RPG program

In this example, lines in gray color are generated by SP4i Designer and lines in blue are manually added.

* SMARTPAD4I DEVELOPMENT.

*

* HTML FILE: example1.html

*

* NB. SEARCH "--->" IN COLUMMS 1 TO 6 FOR YOUR CHANGES

* YOUR CODE MUST BE BETWEEN TAGS <YOURCODE> AND </YOURCODE>

* PLEASE DON'T ALTER THESE TAGS.

H010 * <YOURCODE>

---> * YOUR COMMENTS

H010 * </YOURCODE>

*----------------------------------------------------------------

* DATABASE FILE DEFINITION

*----------------------------------------------------------------

F010 * <YOURCODE>

---> * YOUR FILES

F010 * </YOURCODE>

*

E010 * <YOURCODE>

---> * YOUR ARRAYS

E010 * </YOURCODE>

*

I SDS

I 81 90 SPLIBC

*

* DATA STRUCTURES

I010 * <YOURCODE>

---> * YOUR INPUT SPECIFICATIONS

I010 * </YOURCODE>

ISOOF01 E DSMYPGM01O

ISOIF01 E DSMYPGM01I

* API FIELDS

ISODEFN DS

I 1 50 SPHNDL

I 51 60 SPLIB

I 61 70 SPFILE

I 71 72 SPRETN

I 73 82 SPRCDN

I 83 83 SPMULT

I P 84 860SPRCDL

I 87 96 SPCSRF

I P 97 990SPCSRL

I 100 100 SPFLGS

I P 101 1030SPNBRL

I P 104 1060SPLOOP

I P 107 1090SPTIMO

I 110 111 SPACTN

I P 112 1140SPACTL

I P 115 1170SPSFLS

I P 118 1200SPSFLR

I 121 121 SPDUMY

I 122 123 SPTABN

*

* CONSTANTS

I 'MYPGM ' C SPFILC

* WORKING BUFFER

Page 29: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 29/75

ISPBUFF DS

I 1 250 SPBUF1

I 251 500 SPBUF2

I 501 750 SPBUF3

I 7511000 SPBUF4

* FIELDS FOR ATTRIBUTES SETTINGS

ISPDSAT DS

I 1 10 SPFLDN

I 11 14 SPORDF

I 15 18 SPORD1

I 19 20 SPATRC

I 21 30 SPCLAS

I 31 32 SPRETC

I 33 34 SPELEM

ISPATRB DS

I 1 250 SPATB1

I 251 500 SPATB2

I 501 750 SPATB3

I 7511000 SPATB4

I 10011250 SPATB5

I 12511500 SPATB6

I 15011750 SPATB7

I 17512000 SPATB8

I 20012250 SPATB9

I 22512500 SPATBA

I 25012600 SPATBB

I 26012800 SPATBC

*----------------------------------------------------------------

* MAIN PROGRAM

*----------------------------------------------------------------

*

C010 * <YOURCODE>

---> * YOUR CODE

C010 * </YOURCODE>

C INIT TAG

* INITIALIZATION (RESERVED)

C EXSR SPINIT

*

* YOUR INITIALIZATION

C EXSR YRINIT

*

C T100 TAG

* UPDATE YOUR DATA BEFORE SEND

C EXSR YRDATA

*

C T200 TAG

* SEND (RESERVED)

C EXSR SPSEND

C SPRETN IFNE '00'

C EXSR YRERRS

C GOTO ENDPGM

C ENDIF

*

* RECEIVE (RESERVED)

C EXSR SPRECV

C SPRETN IFNE '00'

C EXSR YRERRR

C GOTO ENDPGM

C ENDIF

*

C050 * <YOURCODE>

---> * CHECK ACTION CODE SPACTN HERE AND PROCESS.

---> * YOUR CODE

Page 30: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 30/75

C050 * </YOURCODE>

*

* GET YOUR DATA

C EXSR GTDATA

C060 * <YOURCODE>

---> * YOUR CODE

C060 * </YOURCODE>

* END PGM

C ENDPGM TAG

C SETON LR

* ---------------------------------------------------------------

C SPINIT BEGSR

* ---------------------------------------------------------------

* INITIALIZATION - CALL ONLY ONE TIME AT THE BEGINNING OF THE

* PROGRAM.

* PARAMETERS:

* - SPHNDL: HANDLE 50 CHARACTERS I/O CLEAR BEFORE INIT

* - SPLIB : LIBRARY 10 " I

* - SPFILE: IBM I HTML FILENAME 10 " I

* - SPRETN: RETURN CODE 2 O

*

* RETURN CODES :

* 00 : OK

* 01 : SP4IINIT ALREADY CALLED

* 02 : LIBRARY EMPTY

* 03 : FILE EMPTY

*

C MOVEL*BLANK SPHNDL

C MOVELSPLIBC SPLIB

C MOVELSPFILC SPFILE

C MOVEL*BLANK SPRETN

C CALL 'SP4IINIT'

C PARM SPHNDL HANDLE

C PARM SPLIB LIBRARY NAME

C PARM SPFILE IBM I HTML FILENAME

C PARM SPRETN RETURN CODE

*

C MOVEL*BLANK SPATRB

C ENDSR

* ---------------------------------------------------------------

C SPSEND BEGSR

* ---------------------------------------------------------------

* SEND : THIS FUNCTION ACTS AS WRITE IN RPG

* FOR N LINE RECORD, SEND N TIMES AS N WRITE SFL RECORDS

*

* PAREMETERS:

* - SPHNDL: HANDLE 50 CHARACTERS I/O DO NOT CHANGE

* - SPRCDN: RECORD NAME 10 " I

* - SPMULT: MULTILINE RECORD IND 1 " I Y/N

* - SPRCDL: RECORD LENGTH PACKED 5,0 I ONE LINE IF SUBFILE

* - DATA TO SEND N BYTES I ONE LINE IF SUBFILE

* - SPFLGS: FLAG TO SEND 1 CHARACTER I 'S'= SEND, OTHERWISE

* BUFFERIZE.

* - SPCSRF: CURSOR FIELD 10 CHARACTERS I FIELD NAME TO PUT THE

* CURSOR. USED IF FLAG

* TO SEND EQUAL TO 'S'.

* - SPCSRL: CURSOR LINE PACKED 4,0 I IF MULTIPLE-LINE

* RECORD. USED IF FLAG

* TO SEND EQUAL TO 'S'.

* - SPRETN: RETURN CODE 2 O

* - SPTABN: HTML TAB NUMBER 2 I =' ','01','02',...

*

* RETURN CODES :

Page 31: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 31/75

* 00 : OK

* 11 : CALL FIRST SP4IINT

* 12 : YOU MAY CALL SP4IRECV

* 13 : RECORD NAME FIELD IS BLANK

* 14 : BAD RECORD LENGTH

*

C SPATRB IFNE *BLANK

C CALL 'SP4ISEND'

C PARM SPHNDL

C PARM '*ATR 'SPRCDN

C PARM SPMULT

C PARM SPRCDL

C PARM SPATRB

C PARM SPFLGS

C PARM SPCSRF

C PARM SPCSRL

C PARM SPRETN

C PARM SPTABN

C ENDIF

*

C 'MYPGM ' CAT '01':0 SPRCDN

C MOVEL'N' SPMULT

C Z-ADD00057 SPRCDL

C MOVEL*BLANK SPRETN

C MOVEL'S' SPFLGS

*

C CALL 'SP4ISEND'

C PARM SPHNDL HANDLE

C PARM SPRCDN RECORD NAME

C PARM SPMULT Y=MULTILINES

C PARM SPRCDL RECORD LENGTH

C PARM SOOF01 DATA TO SEND

C PARM SPFLGS S=SEND DATA

C PARM SPCSRF CURSOR FIELD

C PARM SPCSRL CURSOR LINE

C PARM SPRETN RETURN CODE

C PARM SPTABN HTML TAB NUMBER

C SPRETN CABNE'00' ENDSND

*

C ENDSND ENDSR

* ---------------------------------------------------------------

C SPRECV BEGSR

* ---------------------------------------------------------------

* RECV : THIS FUNCTION ACTS AS READ AND CHAIN SFL IN RPG

* FOR N LINE RECORD, READ N TIMES AS N CHAIN SFL RECORDS

*

* PARAMETERS:

* - SPHNDL: HANDLE 50 CHARACTERS I/O DO NOT CHANGE

* - SPRCDN: RECORD NAME 10 " I

* - SPTIMO: TIMEOUT IN SECONDS PACKED 5,0 I

* - SPACTN: ACTION CODE 2 CHARACTERS O

* - SPACTL: SFL LINE NUMBER WHERE THERE IS AN ACTION CODE AND

* THE ACTION CODE IS ACTIVATED PACKED 4,0.

* - SPCSRF: CURSOR FIELD 10 CHARACTERS O WHERE THE CURSOR IS

* - SPCSRL: CURSOR LINE PACKED 4,0 O IF MULTIPLE-LINE

* RECORD.

* - DATA N BYTES O ONE LINE IF SUBFILE

* - SPSFLS: NUMBER OF LINES PACKED 4,0 O IF MULTIPLE-LINE

* - SPSFLR: RETURNED LINE NUMBER PACKED 4,0 O IF MULTIPLE-LINE

* - SPRETN: RETURN CODE 2 O

* - SPTABN: HTML TAB NUMBER 2 O =' ','01','02',...

*

* RETURN CODES :

Page 32: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 32/75

* 00 : OK

* 21 : CALL FIRST SP4IINT

* 22 : YOU MAY CALL SP4ISEND

* 23 : RECORD HAS NO DATA

* 25 : NO DATA RECEIVED (PERHAPS TIMEOUT)

* LR : NO MORE DATA

*

C 'MYPGM ' CAT '01':0 SPRCDN

*

C MOVEL*BLANK SPRETN

*

C CALL 'SP4IRECV'

C PARM SPHNDL HANDLE

C PARM SPRCDN RECORD NAME

C PARM SPTIMO READ TIMEOUT

C PARM SPACTN ACTION CODE

C PARM SPACTL ACTION CODE LINE NBR

C PARM SPCSRF CURSOR FIELD

C PARM SPCSRL CURSOR LINE

C PARM SOIF01 RECEIVED DATA

C PARM SPSFLS NUMBER OF LINES

C PARM SPSFLR RETURNED LINE NUMBER

C PARM SPRETN RETURN CODE

C PARM SPTABN HTML TAB NUMBER

*

C SPRETN IFNE '00'

C SPRETN ANDNE'23'

C SPRETN ANDNE'LR'

C GOTO ENDRCV

C ENDIF

*

C MOVEL'00' SPRETN

C ENDRCV ENDSR

*----------------------------------------------------------------

* SET CSS CLASS AND ATTRIBUTES OF A FIELD

*----------------------------------------------------------------

C SETATR BEGSR

*

* SPFLDN : HTML ID, 10 CHARACTERS

* SPORDF : TABLE (SUBFILE) ROW NUMBER, 4 CHARACTERS

* SPECIAL VALUES : '0000' OR *BLANK IF FIELD UNIQUE

* 'ALL ' : ALL LINES OF THE TABLE

* 'ODD ' : ODD LINES OF THE TABLE

* 'EVEN' : EVEN LINES OF THE TABLE

* SPORD1 : FIRST ROW OF THE TABLE TO BE DISPLAYED (= SPL1XX)

* 4 CHARACTERS . *BLANK IF NOT A TABLE

* SPELEM : 2 CHARACTERS. ORDER NUMBER OF RADIO BUTTON,01, 02, ...

* SPECIAL VALUES: '00' OR SPACES FOR ALL BUTTONS.

* SPATRC : ATTRIBUTE CODE, 2 CHARCATERS

* ' ' : NO ATTRIBUTE OR CANCEL THE PREVIOUS SETTING

* 'D ' : DISABLE

* 'E ' : ENABLE

* 'H ' : HIDDEN

* 'R ' : READONLY

* SPCLAS : CSS CLASS, 10 CHARCATERS

* *BLANK : CANCEL THE PREVIOUS SETTING

* SPATRB BUFFER, DON'T CHANGE THIS FIELD CONTENT

* SPRETC : RETURN CODE, 2 CHARCATERS, '00' IF OK

*

* EXAMPLE: THIS EXAMPLE SET CSS CLASS RED TO FIELD OCODE

* CLEARSPFLDN

* MOVEL'CODE' SPFLDN

* CLEARSPORDF

Page 33: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 33/75

* CLEARSPORD1

* CLEARSPELEM

* MOVEL*BLANK SPATRC

* CLEARSPCLAS

* MOVEL'RED' SPCLAS

* EXSR SETATR

*

C CALL 'SP4ISATR'

C PARM SPFLDN

C PARM SPORDF

C PARM SPORD1

C PARM SPELEM

C PARM SPATRC

C PARM SPCLAS

C PARM SPATRB

C PARM SPRETC

C ENDSR

C510 * <YOURCODE>

*----------------------------------------------------------------

* YOUR INITIALIZATION

*----------------------------------------------------------------

C YRINIT BEGSR

C ENDSR

*----------------------------------------------------------------

* UPDATES YOUR DATA BEFORE SEND

*----------------------------------------------------------------

C YRDATA BEGSR

*

---> C MOVEL' ' SPTABN HTML TAB NUMBER

---> C MOVEL' 'SPCSRF CURSOR FIELD

---> C Z-ADD0 SPCSRL CURSOR LINE

---> C Z-ADD-1 SPTIMO READ TIMEOUT SEC.

*

---> * UPDATE YOUR FIELDS OF EACH DATA STRUCTURE

* SEE SR SETATR FOR CHANGING FIELD ATTRIBUTES

*

* WE ADD THE FOLLOWING LINES

C MOVEL'My Lab1' OLAB1

C Z-ADD125 OEDT1

C MOVEL'My EDT2' OEDT2

C MOVEL' OK ' OBT1

*

C510 * </YOURCODE>

C520 * <YOURCODE>

*

C ENDSR

*----------------------------------------------------------------

* GET YOUR DATA AFTER RECEIVE

*----------------------------------------------------------------

C GTDATA BEGSR

C ENDSR

*

*----------------------------------------------------------------

* WHAT YOU WANT TO DO IF SEND FUNCTION RESULTS ERROR

* SPRETN FIELD NOT = "00"

*----------------------------------------------------------------

C YRERRS BEGSR

C ENDSR

*

*----------------------------------------------------------------

* WHAT YOU WANT TO DO IF RECEIVE FUNCTION RESULTS ERROR

* SPRETN FIELD NOT = "00"

*----------------------------------------------------------------

Page 34: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 34/75

C YRERRR BEGSR

C ENDSR

C520 * </YOURCODE> THIS TAG AND ONLY THIS TAG CAN BE DELETED.

Page 35: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 35/75

Example 1 – part 3 COBOL program

In this example, lines in gray color are generated by SP4i Designer and lines in blue are manually added. IDENTIFICATION DIVISION.

*

* HTML FILE: example1.html

*

* NB. SEARCH "--->" IN COLUMNS 1 TO 6 FOR YOUR CHANGES

* YOUR CODE MUST BE BETWEEN TAGS <YOURCODE> AND </YOURCODE>

* PLEASE DON'T ALTER THESE TAGS.

H010 * <YOURCODE>

*

PROGRAM-ID. MYPGM .

AUTHOR. SMARTPAD4I DEVELOPMENT.

INSTALLATION.

DATE-WRITTEN.

DATE-COMPILED.

ENVIRONMENT DIVISION.

CONFIGURATION SECTION.

SOURCE-COMPUTER. IBM-I.

OBJECT-COMPUTER. IBM-I.

INPUT-OUTPUT SECTION.

FILE-CONTROL.

DATA DIVISION.

FILE SECTION.

WORKING-STORAGE SECTION.

H010 * </YOURCODE>

*

* DATA STRUCTURES

01 SOOF01.

COPY DDS-ALL-FORMATS OF MYPGM01O .

01 SOIF01.

COPY DDS-ALL-FORMATS OF MYPGM01I .

* API FIELDS

01 SODEFN.

05 SPHNDL PIC X(50).

05 SPLIB PIC X(10) VALUE "SP4ITEMP " .

05 SPFILE PIC X(10) VALUE "MYPGM " .

05 SPOBJTYPE PIC X(07) VALUE "*PGM ".

05 SPRETN PIC X(02).

05 SPRCDN PIC X(10).

05 SPMULT PIC X.

05 SPRCDL PIC S9(5) COMP-3.

05 SPCSRF PIC X(10).

05 SPCSRL PIC S9(4) COMP-3.

05 SPFLGS PIC X.

05 SPNBRLOOP PIC S9(5) COMP-3.

05 SPLOOP PIC S9(5) COMP-3.

05 SPTIMO PIC S9(5) COMP-3.

05 SPACTN PIC X(02).

05 SPACTL PIC S9(4) COMP-3.

05 SPSFLS PIC S9(4) COMP-3.

05 SPSFLR PIC S9(4) COMP-3.

05 SPDUMY PIC XX.

05 SPTABN PIC X(02).

Page 36: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 36/75

* FIELDS FOR ATTRIBUTES SETTINGS

01 SPATTRIB.

05 SPFLDN PIC X(10).

05 SPORDF PIC X(4).

05 SPORD1 PIC X(4).

05 SPELEM PIC X(2).

05 SPATRC PIC X(2).

05 SPCLAS PIC X(10).

05 SPATRB PIC X(2800).

05 SPRETC PIC X(2).

P010 * <YOURCODE>

*----------------------------------------------------------------

* MAIN PROGRAM

*----------------------------------------------------------------

PROCEDURE DIVISION.

MAIN-PGM.

P010 * </YOURCODE>

* INITIALIZATION (RESERVED)

PERFORM SPINIT.

*

* YOUR INITIALIZATION

PERFORM YRINIT THRU YRINIT-EXIT.

T100.

*

* UPDATE YOUR DATA BEFORE SEND

PERFORM YRDATA THRU YRDATA-EXIT.

T200.

*

* SEND (RESERVED)

PERFORM SPSEND THRU SPSEND-EXIT.

IF SPRETN NOT = "00"

MOVE 09999 TO SPLOOP

PERFORM YRERR-SND THRU YRERR-SND-EXIT

STOP RUN

END-IF.

*

* RECEIVE (RESERVED)

PERFORM SPRECV THRU SPRECV-EXIT.

IF SPRETN NOT = "00"

MOVE 09999 TO SPLOOP

PERFORM YRERR-RCV THRU YRERR-RCV-EXIT

STOP RUN

END-IF.

*

P050 * <YOURCODE>

---> * CHECK ACTION CODE SPACTN HERE AND PROCESS.

---> * YOUR CODE

P050 * </YOURCODE>

*

* GET YOUR DATA

PERFORM GTDATA THRU GTDATA-EXIT.

P060 * <YOURCODE>

---> * YOUR CODE

P060 * </YOURCODE>

* END PGM

STOP RUN.

* ---------------------------------------------------------------

SPINIT.

* ---------------------------------------------------------------

* INITIALIZATION - CALL ONLY ONE TIME AT THE BEGINNING OF THE

* PROGRAM.

* PARAMETERS:

Page 37: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 37/75

* - SPHNDL: HANDLE 50 CHARACTERS I/O CLEAR BEFORE INIT

* - SPLIB : LIBRARY 10 " I

* - SPFILE: IBM I HTML FILENAME 10 " I

* - SPRETN: RETURN CODE 2 O

*

* RETURN CODES :

* 00 : OK

* 01 : SP4IINIT ALREADY CALLED

* 02 : LIBRARY EMPTY

* 03 : FILE EMPTY

*

CALL "SORTVOBJD" USING SPFILE,

SPLIB,

SPOBJTYPE.

*

MOVE SPACES TO SPHNDL.

MOVE SPACES TO SPRETN.

CALL "SP4IINIT" USING SPHNDL,

SPLIB,

SPFILE,

SPRETN.

MOVE SPACES TO SPATRB.

*

* ---------------------------------------------------------------

SPSEND.

* ---------------------------------------------------------------

* SEND : THIS FUNCTION ACTS AS WRITE IN RPG

* FOR N LINE RECORD, SEND N TIMES AS N WRITE SFL RECORDS

*

* PAREMETERS:

* - SPHNDL: HANDLE 50 CHARACTERS I/O DO NOT CHANGE

* - SPRCDN: RECORD NAME 10 " I

* - SPMULT: MULTILINE RECORD IND 1 " I Y/N

* - SPRCDL: RECORD LENGTH PACKED 5,0 I ONE LINE IF SUBFILE

* - DATA TO SEND N BYTES I ONE LINE IF SUBFILE

* - SPFLGS: FLAG TO SEND 1 CHARACTER I 'S'= SEND, OTHERWISE

* BUFFERIZE.

* - SPCSRF: CURSOR FIELD 10 CHARACTERS I FIELD NAME TO PUT THE

* CURSOR. USED IF FLAG

* TO SEND EQUAL TO 'S'.

* - SPCSRL: CURSOR LINE PACKED 4,0 I IF MULTIPLE-LINE

* RECORD. USED IF FLAG

* TO SEND EQUAL TO 'S'.

* - SPRETN: RETURN CODE 2 O

* - SPTABN: HTML TAB NUMBER 2 I =' ','01','02',...

*

* RETURN CODES :

* 00 : OK

* 11 : CALL FIRST SP4IINT

* 12 : YOU MAY CALL SP4IRECV

* 13 : RECORD NAME FIELD IS BLANK

* 14 : BAD RECORD LENGTH

*

IF SPATRB NOT = SPACES

MOVE "*ATR " TO SPRCDN

CALL "SP4ISEND" USING SPHNDL,

SPRCDN,

SPMULT,

SPRCDL,

SPATRB,

SPFLGS,

SPCSRF,

SPCSRL,

Page 38: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 38/75

SPRETN,

SPTABN

END-IF.

*

*

MOVE "MYPGM01 " TO SPRCDN.

MOVE "N" TO SPMULT.

MOVE 00057 TO SPRCDL.

MOVE SPACES TO SPRETN.

MOVE "S" TO SPFLGS.

CALL "SP4ISEND" USING SPHNDL,

SPRCDN,

SPMULT,

SPRCDL,

SOOF01,

SPFLGS,

SPCSRF,

SPCSRL,

SPRETN,

SPTABN.

*

IF SPRETN NOT = "00"

GO TO SPSEND-EXIT

END-IF.

*

*

SPSEND-EXIT.

EXIT.

* ---------------------------------------------------------------

SPRECV.

* ---------------------------------------------------------------

* RECV : THIS FUNCTION ACTS AS READ AND CHAIN SFL IN RPG

* FOR N LINE RECORD, READ N TIMES AS N CHAIN SFL RECORDS

*

* PARAMETERS:

* - SPHNDL: HANDLE 50 CHARACTERS I/O DO NOT CHANGE

* - SPRCDN: RECORD NAME 10 " I

* - SPTIMO: TIMEOUT IN SECONDS PACKED 5,0 I

* - SPACTN: ACTION CODE 2 CHARACTERS O

* - SPACTL: SFL LINE NUMBER WHERE THERE IS AN ACTION CODE AND

* THE ACTION CODE IS ACTIVATED PACKED 4,0.

* - SPCSRF: CURSOR FIELD 10 CHARACTERS O WHERE THE CURSOR IS

* - SPCSRL: CURSOR LINE PACKED 4,0 O IF MULTIPLE-LINE

* RECORD.

* - DATA N BYTES O ONE LINE IF SUBFILE

* - SPSFLS: NUMBER OF LINES PACKED 4,0 O IF MULTIPLE-LINE

* - SPSFLR: RETURNED LINE NUMBER PACKED 4,0 O IF MULTIPLE-LINE

* - SPRETN: RETURN CODE 2 O

* - SPTABN: HTML TAB NUMBER 2 O =' ','01','02'...

*

* RETURN CODES :

* 00 : OK

* 21 : CALL FIRST SP4IINT

* 22 : YOU MAY CALL SP4ISEND

* 23 : RECORD HAS NO DATA

* 25 : NO DATA RECEIVED (PERHAPS TIMEOUT)

* LR : NO MORE DATA

*

MOVE "MYPGM01 " TO SPRCDN.

MOVE SPACES TO SPRETN.

*

CALL "SP4IRECV" USING SPHNDL,

SPRCDN,

Page 39: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 39/75

SPTIMO,

SPACTN,

SPACTL,

SPCSRF,

SPCSRL,

SOIF01,

SPSFLS,

SPSFLR,

SPRETN,

SPTABN.

*

IF SPRETN NOT = "00" AND

SPRETN NOT = "23" AND

SPRETN NOT = "LR"

GO TO SPRECV-EXIT

END-IF.

*

*

MOVE "00" TO SPRETN.

*

SPRECV-EXIT.

EXIT.

*----------------------------------------------------------------

SETATR.

*----------------------------------------------------------------

* SET CCS CLASS AND ATTRIBUTES OF A FIELD

*

* SPFLDN : HTML ID, 10 CHARACTERS

* SPORDF : TABLE (SUBFILE) ROW NUMBER, 4 CHARACTERS

* SPECIAL VALUES : '0000' OR *BLANK IF FIELD UNIQUE

* 'ALL ' : ALL LINES OF THE TABLE

* 'ODD ' : ODD LINES OF THE TABLE

* 'EVEN' : EVEN LINES OF THE TABLE

* SPORD1 : FIRST ROW OF THE TABLE TO BE DISPLAYED (= SPL1XX)

* 4 CHARACTERS . *BLANK IF NOT A TABLE

* SPELEM : 2 CHARACTERS. ORDER NUMBER OF RADIO BUTTON,01, 02, ...

* SPECIAL VALUES: '00' OR SPACES FOR ALL BUTTONS.

* SPATRC : ATTRIBUTE CODE, 2 CHARCATERS

* ' ' : NO ATTRIBUTE OR CANCEL THE PREVIOUS SETTING

* 'D ' : DISABLE

* 'E ' : ENABLE

* 'H ' : HIDDEN

* 'R ' : READONLY

* SPCLAS : CSS CLASS, 10 CHARCATERS

* *BLANK : CANCEL THE PREVIOUS SETTING

* SPATRB BUFFER, DON'T CHANGE THIS FIELD CONTENT

* SPRETC : RETURN CODE, 2 CHARCATERS, "00' IF OK .

*

* EXAMPLE: THIS EXAMPLE SET CSS CLASS 'RED' TO FIELD OCODE

* MOVE "CODE" TO SPFLDN.

* MOVE SPACES TO SPORDF

* MOVE SPACES TO SPORD1

* MOVE SPACES TO SPELEM

* MOVE SPACES TO SPATRC

* MOVE "RED" TO SPCLAS

* PERFORM SETATR THRU SETATR-EXIT.

*

CALL "SP4ISATR" USING SPFLDN,

SPORDF,

SPORD1,

SPELEM,

SPATRC,

SPCLAS,

Page 40: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 40/75

SPATRB,

SPRETC.

*

SETATR-EXIT.

EXIT.

P510 * <YOURCODE>

* ---------------------------------------------------------------

YRINIT.

* ---------------------------------------------------------------

* YOUR INITIALIZATION

*

YRINIT-EXIT.

EXIT.

*

* ---------------------------------------------------------------

YRDATA.

* ---------------------------------------------------------------

* UPDATES YOUR DATA BEFORE SEND

*

---> * CHANGE CURSOR FIELD NAME, LINE NUMBER IF SUB-FILE.

---> MOVE SPACES TO SPCSRF.

---> MOVE SPACES TO SPTABN.

MOVE ZEROES TO SPCSRL.

---> * ADJUST READ TIMEOUT IN SECONDS IF NECESSARY.

---> MOVE -00001 TO SPTIMO.

*

---> * UPDATE YOUR FIELDS OF EACH DATA STRUCTURE

* SEE SR SETATR FOR CHANGING FIELD ATTRIBUTES

*

* WE ADD THE FOLLOWING LINES

MOVE "MY LAB1" TO OLAB1.

MOVE 125 TO OEDT1.

MOVE "MY EDT2" TO OEDT2.

MOVE " OK " TO OBT1.

P510 * </YOURCODE>

P520 * <YOURCODE>

*

YRDATA-EXIT.

EXIT.

*----------------------------------------------------------------

GTDATA.

*----------------------------------------------------------------

* GET YOUR DATA AFTER RECEIVE

*

GTDATA-EXIT.

EXIT.

*

*----------------------------------------------------------------

YRERR-SND.

*----------------------------------------------------------------

* WHAT YOU WANT TO DO IF SEND FUNCTION RESULTS ERROR

* SPRETN FIELD NOT = "00"

*

YRERR-SND-EXIT.

EXIT.

*

*----------------------------------------------------------------

YRERR-RCV.

*----------------------------------------------------------------

* WHAT YOU WANT TO DO IF RECEIVE FUNCTION RESULTS ERROR

* SPRETN FIELD NOT = "00"

*

YRERR-RCV-EXIT.

Page 41: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 41/75

EXIT.

*

P520 * </YOURCODE> THIS TAG AND ONLY THIS TAG CAN BE DELETED.

Page 42: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 42/75

Example 2 – Output sub file record Part 1 data structures

Suppose you want to work with the following document:

This will represent on the browser a document with a header "Customer List", a table with several rows and the button labeled "Finish" on the bottom of the document. The above image shows only one row because you need to define only one row in the html file. In reality, your IBM i program will send the number of rows to display. SmartPad4i will repeat the number of rows according to the number determined in the program.

The HTML code is the following:

<HTML> <HEAD> </HEAD> <BODY> <FORM method="POST"> Customers List <TABLE id="tbl1" cellpadding=1 border=1>

Page 43: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 43/75

<THEAD> <TR> <TD> Selection </TD> <TD> Customer Code</TD> <TD> Customer Name </TD> </TR> </THEAD> <TBODY> <TR> <TD> <input type="button" id="bt1" value="Select"> </TD> <TD id="ccode">123456</TD> <TD id="cname">My Name</TD> </TR> </TBODY> </TABLE> <br> <br> <input type="button" id="bt2" value="Finish"> </FORM> </BODY> </HTML>

In this example, SmartPad4i Designer will see 2 records. The first one is a sub file-type record because of the id="tbl1". This record has 3 components because there are 3 ID.

The first component is a button with ID=bt1. This component has as value "Select".

Then there are 2 label components with ID=ccode and ID=cname

The second record is a normal (non sub file) record containing only one component with ID=bt2 and the value is "Finish".

Suppose now you want your IBM i program to fill and to send 10 rows of customer codes and customer names. You may want define these information as output field and the button with ID=bt1 as input field that will return to your program an "Action Code". The same way is defined for the button with ID=bt2. You will work with the SmartPad4i Designer and you define:

for the customer code , the name you give is "CCODE", usage=output, character field and length=7,

for the customer name , the name you give is "CNAME", usage=output, character field and length=50,

for the first button, the name you give is "BT1", usage=input, code action = "1 ". for the second button, the name you give is "BT2", usage=input, code action = "2

".

Because there are only two output fields and two buttons with usage input so there is only one data structure for output fields.

Page 44: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 44/75

You now ask SmartPad4i Designer to generate the IBM i program. Suppose you name the program SFL. In this case SmartPad4i Designer will create one physical file for the data structure. The name of this file will be SFL01O and the DDS is the following:

SFL01O

0001.00 * HTML FILE: test.html

0002.00 A R SFL

0003.00 A OCCODE 00007

0004.00 A OCNAME 00050

Page 45: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 45/75

Example 2 – part 2 RPG program

In this example, lines in gray color are generated by SP4i Designer and lines in blue are manually added. * SMARTPAD4I DEVELOPMENT.

*

* HTML FILE: subfile1.html

*

* NB. SEARCH "--->" IN COLUMMS 1 TO 6 FOR YOUR CHANGES

* YOUR CODE MUST BE BETWEEN TAGS <YOURCODE> AND </YOURCODE>

* PLEASE DON'T ALTER THESE TAGS.

H010 * <YOURCODE>

---> * YOUR COMMENTS

H010 * </YOURCODE>

*----------------------------------------------------------------

* DATABASE FILE DEFINITION

*----------------------------------------------------------------

F010 * <YOURCODE>

---> * YOUR FILES

FCUSTOMERIF E K DISK

F010 * </YOURCODE>

*

E010 * <YOURCODE>

---> * YOUR ARRAYS

E010 * </YOURCODE>

*

I SDS

I 81 90 SPLIBC

*

* DATA STRUCTURES

I010 * <YOURCODE>

---> * YOUR INPUT SPECIFICATIONS

* THE FOLLOWING DATA-STRUCTURE IS USED TO SIMULATE SUB-FILE

* SOOF01 IS THE OUTPUT BUFFER, THIS DATA-STRUCTURE IS

* COMPOSED OF TWO FIELDS: OCCODE AND OCNAME.

I010 * </YOURCODE>

ISOOF01 E DSSFL101O 9999

* API FIELDS

ISODEFN DS

I 1 50 SPHNDL

I 51 60 SPLIB

I 61 70 SPFILE

I 71 72 SPRETN

I 73 82 SPRCDN

I 83 83 SPMULT

I P 84 860SPRCDL

I 87 96 SPCSRF

I P 97 990SPCSRL

I 100 100 SPFLGS

I P 101 1030SPNBRL

I P 104 1060SPLOOP

I P 107 1090SPTIMO

I 110 111 SPACTN

I P 112 1140SPACTL

I P 115 1170SPSFLS

I P 118 1200SPSFLR

I 121 121 SPDUMY

I 122 123 SPTABN

Page 46: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 46/75

*

* CONSTANTS

I 'SFL1 ' C SPFILC

* WORKING BUFFER

ISPBUFF DS

I 1 250 SPBUF1

I 251 500 SPBUF2

I 501 750 SPBUF3

I 7511000 SPBUF4

* FIELDS FOR ATTRIBUTES SETTINGS

ISPDSAT DS

I 1 10 SPFLDN

I 11 14 SPORDF

I 15 18 SPORD1

I 19 20 SPATRC

I 21 30 SPCLAS

I 31 32 SPRETC

I 33 34 SPELEM

ISPATRB DS

I 1 250 SPATB1

I 251 500 SPATB2

I 501 750 SPATB3

I 7511000 SPATB4

I 10011250 SPATB5

I 12511500 SPATB6

I 15011750 SPATB7

I 17512000 SPATB8

I 20012250 SPATB9

I 22512500 SPATBA

I 25012600 SPATBB

I 26012800 SPATBC

*----------------------------------------------------------------

* MAIN PROGRAM

*----------------------------------------------------------------

*

C010 * <YOURCODE>

---> * YOUR CODE

C010 * </YOURCODE>

C INIT TAG

* INITIALIZATION (RESERVED)

C EXSR SPINIT

*

* YOUR INITIALIZATION

C EXSR YRINIT

*

C T100 TAG

* UPDATE YOUR DATA BEFORE SEND

C EXSR YRDATA

*

C T200 TAG

* SEND (RESERVED)

C EXSR SPSEND

C SPRETN IFNE '00'

C EXSR YRERRS

C GOTO ENDPGM

C ENDIF

*

* RECEIVE (RESERVED)

C EXSR SPRECV

C SPRETN IFNE '00'

C EXSR YRERRR

C GOTO ENDPGM

C ENDIF

Page 47: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 47/75

*

C050 * <YOURCODE>

---> * CHECK ACTION CODE SPACTN HERE AND PROCESS.

---> * YOUR CODE

*

* NB. IF THE ACTION CODE JCACTN = '1 ', IT MEANS THE BUTTON

* WITH ID='ID1' OF ONE ROW IS CLIKED ON. IN THIS CASE YOUR

* PROGRAM SHOULD WORK ALSO WITH JCACTL THAT IS THE NUMBER OF THE

* ROW ON WHICH THE BUTTON IS CLICKED ON. BECAUSE THE ROWS IS

* NUMMBERED FROM 1 TO 10, THE NUMBER OF THE CORRESPONDING

* OCCURENCE OF THE DATA STRUCTURE SOOF01 SHOULD BE

* JCACTL + JC1L01 - 1.

*

C050 * </YOURCODE>

*

* GET YOUR DATA

C EXSR GTDATA

C060 * <YOURCODE>

---> * YOUR CODE

C060 * </YOURCODE>

* END PGM

C ENDPGM TAG

C SETON LR

* ---------------------------------------------------------------

C SPINIT BEGSR

* ---------------------------------------------------------------

* INITIALIZATION - CALL ONLY ONE TIME AT THE BEGINNING OF THE

* PROGRAM.

* PARAMETERS:

* - SPHNDL: HANDLE 50 CHARACTERS I/O CLEAR BEFORE INIT

* - SPLIB : LIBRARY 10 " I

* - SPFILE: IBM I HTML FILENAME 10 " I

* - SPRETN: RETURN CODE 2 O

*

* RETURN CODES :

* 00 : OK

* 01 : SP4IINIT ALREADY CALLED

* 02 : LIBRARY EMPTY

* 03 : FILE EMPTY

*

C MOVEL*BLANK SPHNDL

C MOVELSPLIBC SPLIB

C MOVELSPFILC SPFILE

C MOVEL*BLANK SPRETN

C CALL 'SP4IINIT'

C PARM SPHNDL HANDLE

C PARM SPLIB LIBRARY NAME

C PARM SPFILE IBM I HTML FILENAME

C PARM SPRETN RETURN CODE

*

C MOVEL*BLANK SPATRB

C ENDSR

* ---------------------------------------------------------------

C SPSEND BEGSR

* ---------------------------------------------------------------

* SEND : THIS FUNCTION ACTS AS WRITE IN RPG

* FOR N LINE RECORD, SEND N TIMES AS N WRITE SFL RECORDS

*

* PAREMETERS:

* - SPHNDL: HANDLE 50 CHARACTERS I/O DO NOT CHANGE

* - SPRCDN: RECORD NAME 10 " I

* - SPMULT: MULTILINE RECORD IND 1 " I Y/N

* - SPRCDL: RECORD LENGTH PACKED 5,0 I ONE LINE IF SUBFILE

Page 48: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 48/75

* - DATA TO SEND N BYTES I ONE LINE IF SUBFILE

* - SPFLGS: FLAG TO SEND 1 CHARACTER I 'S'= SEND, OTHERWISE

* BUFFERIZE.

* - SPCSRF: CURSOR FIELD 10 CHARACTERS I FIELD NAME TO PUT THE

* CURSOR. USED IF FLAG

* TO SEND EQUAL TO 'S'.

* - SPCSRL: CURSOR LINE PACKED 4,0 I IF MULTIPLE-LINE

* RECORD. USED IF FLAG

* TO SEND EQUAL TO 'S'.

* - SPRETN: RETURN CODE 2 O

* - SPTABN: HTML TAB NUMBER 2 I =' ','01','02',...

*

* RETURN CODES :

* 00 : OK

* 11 : CALL FIRST SP4IINT

* 12 : YOU MAY CALL SP4IRECV

* 13 : RECORD NAME FIELD IS BLANK

* 14 : BAD RECORD LENGTH

*

C SPATRB IFNE *BLANK

C CALL 'SP4ISEND'

C PARM SPHNDL

C PARM '*ATR 'SPRCDN

C PARM SPMULT

C PARM SPRCDL

C PARM SPATRB

C PARM SPFLGS

C PARM SPCSRF

C PARM SPCSRL

C PARM SPRETN

C PARM SPTABN

C ENDIF

*

C 'SFL1 ' CAT '01':0 SPRCDN

C MOVEL'Y' SPMULT

C Z-ADD00057 SPRCDL

C MOVEL*BLANK SPRETN

*

* THIS LOOP WILL SEND N OCCURENCES IN THE DATA-STRUCTURE.

*

* YOU HAVE TO SET SPL101 : FIRST LINE OF THE DATA STRUCTURE TO SEND

* AND SPL901 : LAST LINE TO SEND IN YRDATA SUB-ROUTINE

*

* EACH CALL WILL BUFFERIZE ONE LINE DATA IN THE COMMUNICATION

* BUFFER.

* AT THE LAST LINE PROCESSING, THE BUFFER WILL BE SENT TO THE

* WEB.

*

C SETOF 50

C Z-ADDSPL101 SPNBRL

C *IN50 DOWEQ'0'

*

C SPNBRL IFGT SPL901

C SPNBRL OREQ *ZERO

C SETON 50

C ENDIF

*

C N50 DO

C MOVEL' ' SPFLGS

C SPNBRL OCUR SOOF01

C ADD 1 SPNBRL

*

C MOVELSOOF01 SPBUFF

Page 49: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 49/75

C ENDDO

*

C *IN50 IFEQ '1'

C Z-ADD0 SPRCDL

C ENDIF

*

C CALL 'SP4ISEND'

C PARM SPHNDL HANDLE

C PARM SPRCDN RECORD NAME

C PARM SPMULT Y=MULTILINES

C PARM SPRCDL RECORD LENGTH

C PARM SPBUFF DATA TO SEND

C PARM SPFLGS S=SEND DATA

C PARM SPCSRF CURSOR FIELD

C PARM SPCSRL CURSOR LINE

C PARM SPRETN RETURN CODE

C PARM SPTABN HTML TAB NUMBER

C SPRETN CABNE'00' ENDSND

C ENDDO

*

C 'SFL1 ' CAT '02':0 SPRCDN

C MOVEL'N' SPMULT

C Z-ADD00000 SPRCDL

C MOVEL*BLANK SPRETN

C MOVEL'S' SPFLGS

*

C CALL 'SP4ISEND'

C PARM SPHNDL HANDLE

C PARM SPRCDN RECORD NAME

C PARM SPMULT Y=MULTILINES

C PARM SPRCDL RECORD LENGTH

C PARM SPDUMY DATA TO SEND

C PARM SPFLGS S=SEND DATA

C PARM SPCSRF CURSOR FIELD

C PARM SPCSRL CURSOR LINE

C PARM SPRETN RETURN CODE

C PARM SPTABN HTML TAB NUMBER

C SPRETN CABNE'00' ENDSND

*

C ENDSND ENDSR

* ---------------------------------------------------------------

C SPRECV BEGSR

* ---------------------------------------------------------------

* RECV : THIS FUNCTION ACTS AS READ AND CHAIN SFL IN RPG

* FOR N LINE RECORD, READ N TIMES AS N CHAIN SFL RECORDS

*

* PARAMETERS:

* - SPHNDL: HANDLE 50 CHARACTERS I/O DO NOT CHANGE

* - SPRCDN: RECORD NAME 10 " I

* - SPTIMO: TIMEOUT IN SECONDS PACKED 5,0 I

* - SPACTN: ACTION CODE 2 CHARACTERS O

* - SPACTL: SFL LINE NUMBER WHERE THERE IS AN ACTION CODE AND

* THE ACTION CODE IS ACTIVATED PACKED 4,0.

* - SPCSRF: CURSOR FIELD 10 CHARACTERS O WHERE THE CURSOR IS

* - SPCSRL: CURSOR LINE PACKED 4,0 O IF MULTIPLE-LINE

* RECORD.

* - DATA N BYTES O ONE LINE IF SUBFILE

* - SPSFLS: NUMBER OF LINES PACKED 4,0 O IF MULTIPLE-LINE

* - SPSFLR: RETURNED LINE NUMBER PACKED 4,0 O IF MULTIPLE-LINE

* - SPRETN: RETURN CODE 2 O

* - SPTABN: HTML TAB NUMBER 2 O =' ','01','02',...

*

* RETURN CODES :

Page 50: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 50/75

* 00 : OK

* 21 : CALL FIRST SP4IINT

* 22 : YOU MAY CALL SP4ISEND

* 23 : RECORD HAS NO DATA

* 25 : NO DATA RECEIVED (PERHAPS TIMEOUT)

* LR : NO MORE DATA

*

C 'SFL1 ' CAT '01':0 SPRCDN

*

C MOVEL*BLANK SPRETN

*

C CALL 'SP4IRECV'

C PARM SPHNDL HANDLE

C PARM SPRCDN RECORD NAME

C PARM SPTIMO READ TIMEOUT

C PARM SPACTN ACTION CODE

C PARM SPACTL ACTION CODE LINE NBR

C PARM SPCSRF CURSOR FIELD

C PARM SPCSRL CURSOR LINE

C PARM SPDUMY RECEIVED DATA

C PARM SPSFLS NUMBER OF LINES

C PARM SPSFLR RETURNED LINE NUMBER

C PARM SPRETN RETURN CODE

C PARM SPTABN HTML TAB NUMBER

*

C SPRETN IFNE '00'

C SPRETN ANDNE'23'

C SPRETN ANDNE'LR'

C GOTO ENDRCV

C ENDIF

*

C 'SFL1 ' CAT '02':0 SPRCDN

*

C MOVEL*BLANK SPRETN

*

C CALL 'SP4IRECV'

C PARM SPHNDL HANDLE

C PARM SPRCDN RECORD NAME

C PARM SPTIMO READ TIMEOUT

C PARM SPACTN ACTION CODE

C PARM SPACTL ACTION CODE LINE NBR

C PARM SPCSRF CURSOR FIELD

C PARM SPCSRL CURSOR LINE

C PARM SPDUMY RECEIVED DATA

C PARM SPSFLS NUMBER OF LINES

C PARM SPSFLR RETURNED LINE NUMBER

C PARM SPRETN RETURN CODE

C PARM SPTABN HTML TAB NUMBER

*

C SPRETN IFNE '00'

C SPRETN ANDNE'23'

C SPRETN ANDNE'LR'

C GOTO ENDRCV

C ENDIF

*

C MOVEL'00' SPRETN

C ENDRCV ENDSR

*----------------------------------------------------------------

* SET CSS CLASS AND ATTRIBUTES OF A FIELD

*----------------------------------------------------------------

C SETATR BEGSR

*

* SPFLDN : HTML ID, 10 CHARACTERS

Page 51: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 51/75

* SPORDF : TABLE (SUBFILE) ROW NUMBER, 4 CHARACTERS

* SPECIAL VALUES : '0000' OR *BLANK IF FIELD UNIQUE

* 'ALL ' : ALL LINES OF THE TABLE

* 'ODD ' : ODD LINES OF THE TABLE

* 'EVEN' : EVEN LINES OF THE TABLE

* SPORD1 : FIRST ROW OF THE TABLE TO BE DISPLAYED (= SPL1XX)

* 4 CHARACTERS . *BLANK IF NOT A TABLE

* SPELEM : 2 CHARACTERS. ORDER NUMBER OF RADIO BUTTON,01, 02, ...

* SPECIAL VALUES: '00' OR SPACES FOR ALL BUTTONS.

* SPATRC : ATTRIBUTE CODE, 2 CHARCATERS

* ' ' : NO ATTRIBUTE OR CANCEL THE PREVIOUS SETTING

* 'D ' : DISABLE

* 'E ' : ENABLE

* 'H ' : HIDDEN

* 'R ' : READONLY

* SPCLAS : CSS CLASS, 10 CHARCATERS

* *BLANK : CANCEL THE PREVIOUS SETTING

* SPATRB BUFFER, DON'T CHANGE THIS FIELD CONTENT

* SPRETC : RETURN CODE, 2 CHARCATERS, '00' IF OK

*

* EXAMPLE: THIS EXAMPLE SET CSS CLASS RED TO FIELD OCODE

* CLEARSPFLDN

* MOVEL'CODE' SPFLDN

* CLEARSPORDF

* CLEARSPORD1

* CLEARSPELEM

* MOVEL*BLANK SPATRC

* CLEARSPCLAS

* MOVEL'RED' SPCLAS

* EXSR SETATR

*

C CALL 'SP4ISATR'

C PARM SPFLDN

C PARM SPORDF

C PARM SPORD1

C PARM SPELEM

C PARM SPATRC

C PARM SPCLAS

C PARM SPATRB

C PARM SPRETC

C ENDSR

C510 * <YOURCODE>

*----------------------------------------------------------------

* YOUR INITIALIZATION

*----------------------------------------------------------------

C YRINIT BEGSR

C ENDSR

*----------------------------------------------------------------

* UPDATES YOUR DATA BEFORE SEND

*----------------------------------------------------------------

C YRDATA BEGSR

*

---> C MOVEL' ' SPTABN HTML TAB NUMBER

---> C MOVEL' 'SPCSRF CURSOR FIELD

---> C Z-ADD0 SPCSRL CURSOR LINE

---> C Z-ADD-1 SPTIMO READ TIMEOUT SEC.

*

---> * UPDATE YOUR FIELDS OF EACH DATA STRUCTURE

* SEE SR SETATR FOR CHANGING FIELD ATTRIBUTES

*

C510 * </YOURCODE>

C510B * <YOURCODE>

* PLEASE REMOVE THIS BLOC C510B IF YOU ARE BUILDING A TEMPLATE

Page 52: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 52/75

---> C Z-ADD1 SPL101 40 FIRST LINE TO SEND

---> C Z-ADD9 SPL901 40 LAST LINE TO SEND

* CODE MANUALLY ADDED AS FOLLOWS

* HERE YOU WANT TO SEND 10 RECORDS.

* READ 10 RECORDS AND FILL THEM IN 10 OCCURENCES OF THE

* DATE-STRUCTURE FROM OCCURENCE 1 TO OCCURENCE 10.

* THEN SETTING JCL101=1 AND JCL901=10 MEANS THE PROGRAM

* WILL SEND 10 OCCURENCES FROM 1 TO 10 TO THE WEB

C DO 10 LOOP 40

C READ FCUSTOMR 50

C 50 LEAVE

C Z-ADDLOOP JCL901

C LOOP OCUR SOOF01

C MOVELFCCODE OCCODE

C MOVELFCNAME OCNAME

C ENDDO

*

*

C510B * </YOURCODE>

C520 * <YOURCODE>

*

C ENDSR

*----------------------------------------------------------------

* GET YOUR DATA AFTER RECEIVE

*----------------------------------------------------------------

C GTDATA BEGSR

C ENDSR

*

*----------------------------------------------------------------

* WHAT YOU WANT TO DO IF SEND FUNCTION RESULTS ERROR

* SPRETN FIELD NOT = "00"

*----------------------------------------------------------------

C YRERRS BEGSR

C ENDSR

*

*----------------------------------------------------------------

* WHAT YOU WANT TO DO IF RECEIVE FUNCTION RESULTS ERROR

* SPRETN FIELD NOT = "00"

*----------------------------------------------------------------

C YRERRR BEGSR

C ENDSR

C520 * </YOURCODE> THIS TAG AND ONLY THIS TAG CAN BE DELETED.

Page 53: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 53/75

Example 3 – Input/Output sub file record Part 1 data structures

Suppose you want to work with the following document:

This will represent on the browser a document with a header "Customer Maintenance", a table with several rows and the button labeled "Finish" on the bottom of the document. The above image shows only one row because you need to define only one row in the html file. In reality, your IBM i program will send the number of rows to display. SmartPad4i will repeat the number of rows according to the number determined in the program.

Page 54: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 54/75

The final document will look like a sub file with a number of rows sent first by the IBM i program then when the user clicks on the Finish button, the data will be sent back to the IBM i program.

The HTML code is the following:

<HTML> <HEAD> </HEAD> <BODY> <FORM method="POST"> Customers Maintenance <TABLE id="tbl1" cellpadding=1 border=1> <THEAD> <TR> <TD> Customer Code</TD> <TD> Customer Name </TD> </TR> </THEAD> <TBODY> <TR> <TD align=center><input type="text" id="ccode" maxlength = 7 size=7 ></TD> <TD><input type="text" id="cname" maxlength = 50 size=50></TD> </TR> </TBODY> </TABLE> <br> <br> <input type="button" id="bt2" value="Finish"> </FORM> </BODY> </HTML>

In this example, SmartPad4i Designer will see 2 records. The first one is a sub file-type record because of the id="tbl1". This record has 2 components because there are 2 ID.

The first component is the text field ID=ccode. The second one is the text field ID=cname

In the de Designer you have defined the above fields as Input/Output fields.

The second record is a normal (non sub file) record containing only one component with ID=bt2 and the value is "Finish".

Suppose now you want your program to fill and to send 10 rows of customer codes and customer names then these fields will be changed and sent back to the program. You may want define these information as input/output fields. Then for Finish button, you will

Page 55: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 55/75

define it as input field and attribute to it an action code = "1 ". You will work with the SmartPad4i Designer and you define:

for the customer code , the name you give is "CCODE", usage=both, character field and length=7,

for the customer name , the name you give is "CNAME", usage=both, character field and length=50,

for the button, usage=input, code action = "1 ".

Because there are input and output fields and one button with usage input so there are two data structures, one for input fields and another for output fields.

You now ask SmartPad4i Designer to generate the IBM i program. Suppose you name the program SFL2. In this case SmartPad4i Designer will create one physical file for each data structure. The name of these two files will be SFL201I and SFL201O and the DDS are the following:

SFL201I

0001.00 * HTML FILE: test2.html

0002.00 A R SFL2

0003.00 A ICCODE 00007

0004.00 A ICNAME 00050

SFL201O

0001.00 * HTML FILE: test.html

0002.00 A R SFL2

0003.00 A OCCODE 00007

0004.00 A OCNAME 00050

Page 56: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 56/75

Example 3 – part 2 RPG program

In this example, lines in gray color are generated by SP4i Designer and lines in blue are manually added.

* SMARTPAD4I DEVELOPMENT.

*

* HTML FILE: subfile2.html

*

* NB. SEARCH "--->" IN COLUMMS 1 TO 6 FOR YOUR CHANGES

* YOUR CODE MUST BE BETWEEN TAGS <YOURCODE> AND </YOURCODE>

* PLEASE DON'T ALTER THESE TAGS.

H010 * <YOURCODE>

---> * YOUR COMMENTS

H010 * </YOURCODE>

*----------------------------------------------------------------

* DATABASE FILE DEFINITION

*----------------------------------------------------------------

F010 * <YOURCODE>

---> * YOUR FILES

FCUSTOMERUF E K DISK

F010 * </YOURCODE>

*

E010 * <YOURCODE>

---> * YOUR ARRAYS

E010 * </YOURCODE>

*

I SDS

I 81 90 SPLIBC

*

* DATA STRUCTURES

I010 * <YOURCODE>

---> * YOUR INPUT SPECIFICATIONS

*

* TWO FOLLOWING DATA-STRUCTURES ARE USED TO SIMULATE SUB_FILE.

* SOOF01 IS THE OUTPUT BUFFER, EACH OCCURRENCE IS COMPOSED OF

* TWO FIELDS OCCODE AND OCNAME.

*

* SOIF01 IS THE INPUT BUFFER, EACH OCCURRENCE IS COMPOSED OF

* TWO FIELDS ICCODE AND ICNAME.

* EACH OCCURRENCE REPRESENTS ONE ROW.

I010 * </YOURCODE>

ISOOF01 E DSSFL201O 9999

ISOIF01 E DSSFL201I 9999

* API FIELDS

ISODEFN DS

I 1 50 SPHNDL

I 51 60 SPLIB

I 61 70 SPFILE

I 71 72 SPRETN

I 73 82 SPRCDN

I 83 83 SPMULT

I P 84 860SPRCDL

I 87 96 SPCSRF

I P 97 990SPCSRL

I 100 100 SPFLGS

I P 101 1030SPNBRL

I P 104 1060SPLOOP

I P 107 1090SPTIMO

Page 57: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 57/75

I 110 111 SPACTN

I P 112 1140SPACTL

I P 115 1170SPSFLS

I P 118 1200SPSFLR

I 121 121 SPDUMY

I 122 123 SPTABN

*

* CONSTANTS

I 'SFL2 ' C SPFILC

* WORKING BUFFER

ISPBUFF DS

I 1 250 SPBUF1

I 251 500 SPBUF2

I 501 750 SPBUF3

I 7511000 SPBUF4

* FIELDS FOR ATTRIBUTES SETTINGS

ISPDSAT DS

I 1 10 SPFLDN

I 11 14 SPORDF

I 15 18 SPORD1

I 19 20 SPATRC

I 21 30 SPCLAS

I 31 32 SPRETC

I 33 34 SPELEM

ISPATRB DS

I 1 250 SPATB1

I 251 500 SPATB2

I 501 750 SPATB3

I 7511000 SPATB4

I 10011250 SPATB5

I 12511500 SPATB6

I 15011750 SPATB7

I 17512000 SPATB8

I 20012250 SPATB9

I 22512500 SPATBA

I 25012600 SPATBB

I 26012800 SPATBC

*----------------------------------------------------------------

* MAIN PROGRAM

*----------------------------------------------------------------

*

C010 * <YOURCODE>

---> * YOUR CODE

C010 * </YOURCODE>

C INIT TAG

* INITIALIZATION (RESERVED)

C EXSR SPINIT

*

* YOUR INITIALIZATION

C EXSR YRINIT

*

C T100 TAG

* UPDATE YOUR DATA BEFORE SEND

C EXSR YRDATA

*

C T200 TAG

* SEND (RESERVED)

C EXSR SPSEND

C SPRETN IFNE '00'

C EXSR YRERRS

C GOTO ENDPGM

C ENDIF

*

Page 58: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 58/75

* RECEIVE (RESERVED)

C EXSR SPRECV

C SPRETN IFNE '00'

C EXSR YRERRR

C GOTO ENDPGM

C ENDIF

*

C050 * <YOURCODE>

---> * CHECK ACTION CODE SPACTN HERE AND PROCESS.

---> * YOUR CODE

C050 * </YOURCODE>

*

* GET YOUR DATA

C EXSR GTDATA

C060 * <YOURCODE>

---> * YOUR CODE

C060 * </YOURCODE>

* END PGM

C ENDPGM TAG

C SETON LR

* ---------------------------------------------------------------

C SPINIT BEGSR

* ---------------------------------------------------------------

* INITIALIZATION - CALL ONLY ONE TIME AT THE BEGINNING OF THE

* PROGRAM.

* PARAMETERS:

* - SPHNDL: HANDLE 50 CHARACTERS I/O CLEAR BEFORE INIT

* - SPLIB : LIBRARY 10 " I

* - SPFILE: IBM I HTML FILENAME 10 " I

* - SPRETN: RETURN CODE 2 O

*

* RETURN CODES :

* 00 : OK

* 01 : SP4IINIT ALREADY CALLED

* 02 : LIBRARY EMPTY

* 03 : FILE EMPTY

*

C MOVEL*BLANK SPHNDL

C MOVELSPLIBC SPLIB

C MOVELSPFILC SPFILE

C MOVEL*BLANK SPRETN

C CALL 'SP4IINIT'

C PARM SPHNDL HANDLE

C PARM SPLIB LIBRARY NAME

C PARM SPFILE IBM I HTML FILENAME

C PARM SPRETN RETURN CODE

*

C MOVEL*BLANK SPATRB

C ENDSR

* ---------------------------------------------------------------

C SPSEND BEGSR

* ---------------------------------------------------------------

* SEND : THIS FUNCTION ACTS AS WRITE IN RPG

* FOR N LINE RECORD, SEND N TIMES AS N WRITE SFL RECORDS

*

* PAREMETERS:

* - SPHNDL: HANDLE 50 CHARACTERS I/O DO NOT CHANGE

* - SPRCDN: RECORD NAME 10 " I

* - SPMULT: MULTILINE RECORD IND 1 " I Y/N

* - SPRCDL: RECORD LENGTH PACKED 5,0 I ONE LINE IF SUBFILE

* - DATA TO SEND N BYTES I ONE LINE IF SUBFILE

* - SPFLGS: FLAG TO SEND 1 CHARACTER I 'S'= SEND, OTHERWISE

* BUFFERIZE.

Page 59: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 59/75

* - SPCSRF: CURSOR FIELD 10 CHARACTERS I FIELD NAME TO PUT THE

* CURSOR. USED IF FLAG

* TO SEND EQUAL TO 'S'.

* - SPCSRL: CURSOR LINE PACKED 4,0 I IF MULTIPLE-LINE

* RECORD. USED IF FLAG

* TO SEND EQUAL TO 'S'.

* - SPRETN: RETURN CODE 2 O

* - SPTABN: HTML TAB NUMBER 2 I =' ','01','02',...

*

* RETURN CODES :

* 00 : OK

* 11 : CALL FIRST SP4IINT

* 12 : YOU MAY CALL SP4IRECV

* 13 : RECORD NAME FIELD IS BLANK

* 14 : BAD RECORD LENGTH

*

C SPATRB IFNE *BLANK

C CALL 'SP4ISEND'

C PARM SPHNDL

C PARM '*ATR 'SPRCDN

C PARM SPMULT

C PARM SPRCDL

C PARM SPATRB

C PARM SPFLGS

C PARM SPCSRF

C PARM SPCSRL

C PARM SPRETN

C PARM SPTABN

C ENDIF

*

C 'SFL2 ' CAT '01':0 SPRCDN

C MOVEL'Y' SPMULT

C Z-ADD00057 SPRCDL

C MOVEL*BLANK SPRETN

*

* THIS LOOP WILL SEND N OCCURENCES IN THE DATA-STRUCTURE.

*

* YOU HAVE TO SET SPL101 : FIRST LINE OF THE DATA STRUCTURE TO SEND

* AND SPL901 : LAST LINE TO SEND IN YRDATA SUB-ROUTINE

*

* EACH CALL WILL BUFFERIZE ONE LINE DATA IN THE COMMUNICATION

* BUFFER.

* AT THE LAST LINE PROCESSING, THE BUFFER WILL BE SENT TO THE

* WEB.

*

C SETOF 50

C Z-ADDSPL101 SPNBRL

C *IN50 DOWEQ'0'

*

C SPNBRL IFGT SPL901

C SPNBRL OREQ *ZERO

C SETON 50

C ENDIF

*

C N50 DO

C MOVEL' ' SPFLGS

C SPNBRL OCUR SOOF01

C ADD 1 SPNBRL

*

C MOVELSOOF01 SPBUFF

C ENDDO

*

C *IN50 IFEQ '1'

Page 60: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 60/75

C Z-ADD0 SPRCDL

C ENDIF

*

C CALL 'SP4ISEND'

C PARM SPHNDL HANDLE

C PARM SPRCDN RECORD NAME

C PARM SPMULT Y=MULTILINES

C PARM SPRCDL RECORD LENGTH

C PARM SPBUFF DATA TO SEND

C PARM SPFLGS S=SEND DATA

C PARM SPCSRF CURSOR FIELD

C PARM SPCSRL CURSOR LINE

C PARM SPRETN RETURN CODE

C PARM SPTABN HTML TAB NUMBER

C SPRETN CABNE'00' ENDSND

C ENDDO

*

C 'SFL2 ' CAT '02':0 SPRCDN

C MOVEL'N' SPMULT

C Z-ADD00000 SPRCDL

C MOVEL*BLANK SPRETN

C MOVEL'S' SPFLGS

*

C CALL 'SP4ISEND'

C PARM SPHNDL HANDLE

C PARM SPRCDN RECORD NAME

C PARM SPMULT Y=MULTILINES

C PARM SPRCDL RECORD LENGTH

C PARM SPDUMY DATA TO SEND

C PARM SPFLGS S=SEND DATA

C PARM SPCSRF CURSOR FIELD

C PARM SPCSRL CURSOR LINE

C PARM SPRETN RETURN CODE

C PARM SPTABN HTML TAB NUMBER

C SPRETN CABNE'00' ENDSND

*

C ENDSND ENDSR

* ---------------------------------------------------------------

C SPRECV BEGSR

* ---------------------------------------------------------------

* RECV : THIS FUNCTION ACTS AS READ AND CHAIN SFL IN RPG

* FOR N LINE RECORD, READ N TIMES AS N CHAIN SFL RECORDS

*

* PARAMETERS:

* - SPHNDL: HANDLE 50 CHARACTERS I/O DO NOT CHANGE

* - SPRCDN: RECORD NAME 10 " I

* - SPTIMO: TIMEOUT IN SECONDS PACKED 5,0 I

* - SPACTN: ACTION CODE 2 CHARACTERS O

* - SPACTL: SFL LINE NUMBER WHERE THERE IS AN ACTION CODE AND

* THE ACTION CODE IS ACTIVATED PACKED 4,0.

* - SPCSRF: CURSOR FIELD 10 CHARACTERS O WHERE THE CURSOR IS

* - SPCSRL: CURSOR LINE PACKED 4,0 O IF MULTIPLE-LINE

* RECORD.

* - DATA N BYTES O ONE LINE IF SUBFILE

* - SPSFLS: NUMBER OF LINES PACKED 4,0 O IF MULTIPLE-LINE

* - SPSFLR: RETURNED LINE NUMBER PACKED 4,0 O IF MULTIPLE-LINE

* - SPRETN: RETURN CODE 2 O

* - SPTABN: HTML TAB NUMBER 2 O =' ','01','02',...

*

* RETURN CODES :

* 00 : OK

* 21 : CALL FIRST SP4IINT

* 22 : YOU MAY CALL SP4ISEND

Page 61: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 61/75

* 23 : RECORD HAS NO DATA

* 25 : NO DATA RECEIVED (PERHAPS TIMEOUT)

* LR : NO MORE DATA

*

C 'SFL2 ' CAT '01':0 SPRCDN

C MOVEL*BLANK SPRETN

C Z-ADD1 SPSFLS

C Z-ADD0 SPSFLR

C Z-ADDSPL101 SPLOOP

*

C SPSFLR DOWLTSPSFLS

*

C CALL 'SP4IRECV'

C PARM SPHNDL HANDLE

C PARM SPRCDN RECORD NAME

C PARM SPTIMO READ TIMEOUT

C PARM SPACTN ACTION CODE

C PARM SPACTL ACTION CODE LINE NBR

C PARM SPCSRF CURSOR FIELD

C PARM SPCSRL CURSOR LINE

C PARM SPBUFF RECEIVED DATA

C PARM SPSFLS NUMBER OF LINES

C PARM SPSFLR RETURNED LINE NUMBER

C PARM SPRETN RETURN CODE

C PARM SPTABN HTML TAB NUMBER

*

C SPRETN IFEQ '00'

C SPLOOP OCUR SOIF01

C MOVELSPBUFF SOIF01

C ADD 1 SPLOOP

C ENDIF

C SPRETN IFEQ '23'

C SPRETN OREQ 'LR'

C LEAVE

C ENDIF

C SPRETN IFNE '00'

C GOTO ENDRCV

C ENDIF

C ENDDO

*

C 'SFL2 ' CAT '02':0 SPRCDN

*

C MOVEL*BLANK SPRETN

*

C CALL 'SP4IRECV'

C PARM SPHNDL HANDLE

C PARM SPRCDN RECORD NAME

C PARM SPTIMO READ TIMEOUT

C PARM SPACTN ACTION CODE

C PARM SPACTL ACTION CODE LINE NBR

C PARM SPCSRF CURSOR FIELD

C PARM SPCSRL CURSOR LINE

C PARM SPDUMY RECEIVED DATA

C PARM SPSFLS NUMBER OF LINES

C PARM SPSFLR RETURNED LINE NUMBER

C PARM SPRETN RETURN CODE

C PARM SPTABN HTML TAB NUMBER

*

C SPRETN IFNE '00'

C SPRETN ANDNE'23'

C SPRETN ANDNE'LR'

C GOTO ENDRCV

C ENDIF

Page 62: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 62/75

*

C MOVEL'00' SPRETN

C ENDRCV ENDSR

*----------------------------------------------------------------

* SET CSS CLASS AND ATTRIBUTES OF A FIELD

*----------------------------------------------------------------

C SETATR BEGSR

*

* SPFLDN : HTML ID, 10 CHARACTERS

* SPORDF : TABLE (SUBFILE) ROW NUMBER, 4 CHARACTERS

* SPECIAL VALUES : '0000' OR *BLANK IF FIELD UNIQUE

* 'ALL ' : ALL LINES OF THE TABLE

* 'ODD ' : ODD LINES OF THE TABLE

* 'EVEN' : EVEN LINES OF THE TABLE

* SPORD1 : FIRST ROW OF THE TABLE TO BE DISPLAYED (= SPL1XX)

* 4 CHARACTERS . *BLANK IF NOT A TABLE

* SPELEM : 2 CHARACTERS. ORDER NUMBER OF RADIO BUTTON,01, 02, ...

* SPECIAL VALUES: '00' OR SPACES FOR ALL BUTTONS.

* SPATRC : ATTRIBUTE CODE, 2 CHARCATERS

* ' ' : NO ATTRIBUTE OR CANCEL THE PREVIOUS SETTING

* 'D ' : DISABLE

* 'E ' : ENABLE

* 'H ' : HIDDEN

* 'R ' : READONLY

* SPCLAS : CSS CLASS, 10 CHARCATERS

* *BLANK : CANCEL THE PREVIOUS SETTING

* SPATRB BUFFER, DON'T CHANGE THIS FIELD CONTENT

* SPRETC : RETURN CODE, 2 CHARCATERS, '00' IF OK

*

* EXAMPLE: THIS EXAMPLE SET CSS CLASS RED TO FIELD OCODE

* CLEARSPFLDN

* MOVEL'CODE' SPFLDN

* CLEARSPORDF

* CLEARSPORD1

* CLEARSPELEM

* MOVEL*BLANK SPATRC

* CLEARSPCLAS

* MOVEL'RED' SPCLAS

* EXSR SETATR

*

C CALL 'SP4ISATR'

C PARM SPFLDN

C PARM SPORDF

C PARM SPORD1

C PARM SPELEM

C PARM SPATRC

C PARM SPCLAS

C PARM SPATRB

C PARM SPRETC

C ENDSR

C510 * <YOURCODE>

*----------------------------------------------------------------

* YOUR INITIALIZATION

*----------------------------------------------------------------

C YRINIT BEGSR

C ENDSR

*----------------------------------------------------------------

* UPDATES YOUR DATA BEFORE SEND

*----------------------------------------------------------------

C YRDATA BEGSR

*

---> C MOVEL' ' SPTABN HTML TAB NUMBER

---> C MOVEL' 'SPCSRF CURSOR FIELD

Page 63: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 63/75

---> C Z-ADD0 SPCSRL CURSOR LINE

---> C Z-ADD-1 SPTIMO READ TIMEOUT SEC.

*

---> * UPDATE YOUR FIELDS OF EACH DATA STRUCTURE

* SEE SR SETATR FOR CHANGING FIELD ATTRIBUTES

*

C510 * </YOURCODE>

C510B * <YOURCODE>

* PLEASE REMOVE THIS BLOC C510B IF YOU ARE BUILDING A TEMPLATE

---> C Z-ADD1 SPL101 40 FIRST LINE TO SEND

---> C Z-ADD9 SPL901 40 LAST LINE TO SEND

* CODE MANUALLY ADDED AS FOLLOWS

* HERE YOU WANT TO SEND 10 RECORDS.

* READ 10 RECORDS AND FILL THEM IN 10 OCCURENCES OF THE

* DATE-STRUCTURE FROM OCCURENCE 1 TO OCCURENCE 10.

* THEN SETTING JCL101=1 AND JCL901=10 MEANS THE PROGRAM

* WILL SEND 10 OCCURENCES FROM 1 TO 10 TO THE WEB

*

C DO 10 LOOP 40

C READ FCUSTOMR 50

C 50 LEAVE

C Z-ADDLOOP JCL901

C LOOP OCUR SOOF01

C MOVELFCCODE OCCODE

C MOVELFCNAME OCNAME

C ENDDO

*

C510B * </YOURCODE>

C520 * <YOURCODE>

*

C ENDSR

*----------------------------------------------------------------

* GET YOUR DATA AFTER RECEIVE

*----------------------------------------------------------------

C GTDATA BEGSR

*

* CODE MANUALLY ADDED AS FOLLOWS

* AT THIS POINT, AFTER THE USER HAS MADE CHANGES AND SENT BACK

* TO THE PROGRAM. THE INFORMATION IS NOW RECORDED IN THE DATA

* STRUCTURE SOIF01.

* READ THE DATA STRUCTURE SOIF01 AND UPDATE DATABASE FILE

* CUSTOMER.

*

C JCL101 DO JCL901 LOOP 40

C LOOP OCUR SOIF01

C ICCODE CHAINFCUSTOMR 50

C 50 ITER

C MOVELICCODE FCCODE

C MOVELICNAME FCNAME

C UPDATFCUSTOMR

C ENDDO

*

C ENDSR

*

*----------------------------------------------------------------

* WHAT YOU WANT TO DO IF SEND FUNCTION RESULTS ERROR

* SPRETN FIELD NOT = "00"

*----------------------------------------------------------------

C YRERRS BEGSR

C ENDSR

*

*----------------------------------------------------------------

* WHAT YOU WANT TO DO IF RECEIVE FUNCTION RESULTS ERROR

Page 64: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 64/75

* SPRETN FIELD NOT = "00"

*----------------------------------------------------------------

C YRERRR BEGSR

C ENDSR

C520 * </YOURCODE> THIS TAG AND ONLY THIS TAG CAN BE DELETED.

Page 65: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 65/75

API SP4IPHONE The library SP4I contains a program named SP4IPHONE. This program has three output parameters: WIDTH: 4 characters, specifies the screen width of the screen on which application is running. HEIGHT: 4 characters, specifies the screen height of the screen on which application is running. TYPE: 12 characters, specifies the phone type or browser type on which application is running. Actual returned values can be:

FF: Firefox

IE: Microsoft Internet Explorer (versions 7 , 8)

SF: Safari

OP : Opera (not tested)

CR : Chrome (not tested)

AD: Androïd

BB: Blackberry

PH: iPhone

PA: iPad

PO: iPod When your program needs the above information, you can call this API in your program. The following is a CLP example: PGM DCL &WIDTH *CHAR 4 DCL &HEIGHT *CHAR 4 DCL &TYPE *CHAR 12 CHGLIBL LIBL(YourLib SP4I QTEMP QGPL) CALL PGM(SP4IPHONE) PARM(&WIDTH &HEIGHT &TYPE) IF COND(%SST(&TYPE 1 2) *EQ 'PH') THEN(DO) CHGLIBL LIBL(Lib1 SP4I QTEMP QGPL) ENDDO IF COND(%SST(&TYPE 1 2) *EQ 'PA') THEN(DO) CHGLIBL LIBL(Lib2 SP4I QTEMP QGPL) ENDDO IF COND(%SST(&TYPE 1 2) *EQ 'BB') THEN(DO) CHGLIBL LIBL(Lib3 SP4I QTEMP QGPL) ENDDO IF COND(%SST(&TYPE 1 2) *EQ 'AD') THEN(DO) CHGLIBL LIBL(Lib4 SP4I QTEMP QGPL) ENDDO ………. ………. ENDPGM

Page 66: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 66/75

Define Menu

When a user, from his internet browser, connects to the IBM i, with his user profile and password, SmartPad4i extracts information from its database files, builds and displays the menu for the user.

This menu is configured on your IBM i, by SP4i Menu. To call the SP4I menu:

Be sure that SP4I is in the libraries list, Type command SP4I.

Select option 1 - WORK WITH MENU:

Press F6 to display "Add Menu Entry",

Type the name of the menu and press Enter,

The "Work with menu option" is displayed,

Press F6 to add an option and fill information:

Page 67: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 67/75

Option order number Type:

*PGM: IBM i program *MENU: define another menu. To create this menu, use the same option

2 - WORK WITH MENU *URL: A Web link address.

Description: Option name that will be displayed on the Menu Hint: Option Hint when the mouse is on the option Header Title: Header title of your program IBM i program: Your IBM i program (required for *PGM type) IBM i prog. Library: Your IBM i program library (required for *PGM type). It should be *LIBL if the user profile JOBD or the Set Env. Program contains all necessary libraries to run the program, including SP4I library. Set Env. Program: This program, if specified, will be run before your program. This is normally a CLP program that runs CHGLIBL to set the libraries list. It should be the same SETENV program described in Introduction chapter. Set Env. Prog. Library: Required if the Set Env. Program is specified.

Page 68: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 68/75

Menu Name: Required for *MENU type URL:

For *URL types, it’s a hyperlink. Example, http://www.systemobjects.com

For *PGM types, this field is used to pass parameters. Example, PARM(‘1’ ‘Company ABC’ x’12345F’).

Example:

Page 69: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 69/75

Select option 2 - WORK WITH USER PROFILE MENU:

Press F6 to display "Add user profile entry",

Type the user profile and press Enter. This is an IBM i user profile that must be created before by the CRTUSRPRF command,

The "Work with user profile major menu option" is displayed,

Press F6 to add an option and fill information:

Remark: - all the information for this option is the same as described above in the "Select option 1 - WORK WITH MENU". You can do the same thing for this major menu. With option 1, you define a menu that can be attached to any user profile. With option 2 here, you define the menu for a namely user profile.

Below, we are going to attach only the menu created with the option 1 to the user profile. This way is recommended for future menu updates.

Option order number: 1 Type: *MENU Description: Menu name that will be displayed on the Menu

Page 70: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 70/75

Hint: Menu Hint when the mouse is on the option Header Title: nothing here IBM i program: nothing here IBM i prog. Library: nothing here Set Env. Program: nothing here Set Env. Prog. Library: nothing here Menu Name: Menu name created with option 1 PC File: nothing here

Page 71: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 71/75

Run your program without Menu

You can run a program, developed with Smartpad4i, without define it in the menu. The following URL permits you to execute your program: http://123.456.95.68/smartpad4i/smartpad4i.SP4ILogon?USERID=myuserprofile&PASSWD=mypassword&PGMAPP=myprogram&LIBAPP=*LIBL&PGMENV=mysetenv&LIBENV=mylib&PARM=PARM(‘1’) http://123.456.95.68/ is your server address. smartpad4i/: context name of the smartpad4i application. smartpad4i.SP4ILogon: Smartpad4i Logon class. Not changed. ?USERID=myuserprofile: replace “myuserprofile” by your IBM i user profile. &PASSWD=mypassword: replace “mypassword” by your password. &PGMAPP=myprogram: replace “myprogram” by your program name. &LIBAPP=*LIBL: can be *LIBL or the program library name. &PGMENV=mysetenv: replace “mysetenv” by your CLP program name that set the libraries list. &LIBENV=mylib: replace “mylib” by your library containing your CLP &PGMENV name. &PARM=PARM(‘1’): can be omitted if your program doesn’t have parameter.

Page 72: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 72/75

Open your Menu

There are two ways to open your defined menu. The first way is running: http://your server/smartpad4i/exec/sp4ilogon.html Example: http://192.168.4.7:8080/smartpad4i/exec/sp4ilogon.html

Enter your user-profile and password. This user-profil must be already defined in SP4i Menu. You get your menu as the following :

Page 73: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 73/75

Page 74: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 74/75

The second way is running: http://your server/smartpad4i/APP_SP4i/start_logonjq.html Example: http://192.168.4.32:8080/smartpad4i/APP_SP4i/start_logonjq.html

Enter your user-profile and password. This user-profil must be already defined in SP4i Menu. You get your menu as the following :

Page 75: Guide for IBM i programming - SystemObjects Guide for IBM i programming.pdf · Guide for IBM i programming . SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 2/75 Introduction

SmartPad4i © SystemObjects 2015 – Release version 2.1 Page: 75/75

End of document.