Skip to content

Docs/chandra explain1#8

Open
Chandra-IBM1 wants to merge 36 commits intomainfrom
docs/chandra_explain1
Open

Docs/chandra explain1#8
Chandra-IBM1 wants to merge 36 commits intomainfrom
docs/chandra_explain1

Conversation

@Chandra-IBM1
Copy link
Collaborator

No description provided.

Matta Chandrashekar added 2 commits May 15, 2025 13:18
- Required preconditions
- Unsupported input types

- `Outcomes`

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we have removed Output sections, I feel that outcomes will be a valuable section to keep as this will provide the user an overall view of what result will be produce after code execution. @bmorris1 @edmundreinhardt . Could you please suggest on this point ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Side Effects and Return Values and Output Parameters should be sufficent to document that.


- `Outcomes`
- `Usage Example`
Define the expected outcomes of the procedure’s execution.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usage Example: This should provide an example on how we can utilize or call the procedure instead of defining the expected outcomes. fyi @bmorris1, @edmundreinhardt, @Chandra-IBM1

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anandsha20 I agree that it should show how to call the procedure.

It should show an example of all aspects of calling the procedure

  • The /copy statement with the prototype
  • any setup needed for parameters
  • the call to the procedure
  • if it returns a value or modifies a parameter, it should either show or describe how the caller would use those values.

But for cases where the caller would not do any further coding related to that call, I don't think anything is needed in the Usage section. For example, if the procedure did something related to files, that's not really part of the Usage, it's a Side Effect.

- Example: The load all subfile can load only up to 9999 records.

6. `Outcomes`: List possible major outcomes or scenarios resulting from the code execution. This section can include an optional `usage example` to illustrate the expected outcome.
6. `Usage Example`: Define the expected outcomes of the program execution.
Copy link

@anandsha20 anandsha20 May 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usage Example: This should provide an example on how we can utilize the program instead of defining the expected outcomes. Please check for other scopes as well. fyi @bmorris1, @edmundreinhardt, @Chandra-IBM1

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. It should be similar to the Usage section for a procedure in a module, although depending on the nature of the program it might be better to show a ```clle call which could also represent a call from the command line.

But if there is a /copy file with an RPG prototype for the program, the Usage should be similar to the Usage for a procedure

  • The /copy statement
  • Any setup for parameters
  • The call
  • Code or discussion saying what to do with any output variables

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that this should be an example of calling the program. The outcomes should have been discussed in side effects .
In fact for programs, I think we should rename Side Effects to Outcomes
What do you think @bmorris1 @anandsha20 @Chandra-IBM1

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure.

Any procedure or program could have both outcomes and side effects, although I'm not always sure which is which.

How about having a more general name for both outcomes and side effects such as "Outside effects", although I don't really like that name. For procedures and subroutines, it could have a subsection about "Global variables".

- Global variables
- Shared resources
- Logs or external states
- Dataaera updates
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should not discuss Global variables unless they are defined with the IMPORT or EXPORT keyword.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Data area or DATARA

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Data area or DTAARA

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think "Data area" is better


- `Initialization`: Describe the initial setup required for the procedure. Include all local variables and parameters.
- `Definitions`: This section covers all declarations and setup required before the main logic of the procedure begins. It includes the definition of local variables, data structures, and any constants or initial values needed to support the procedure’s execution
- `Main Logic`: Explain the core logic of the procedure, detailing the steps taken to achieve the procedure's purpose.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should list any subroutines within the procedure with a brief description of each subroutine.

3. `Global Components`: The Global Variables section includes all variables, prototypes for external program calls, data structures, arrays, constants, and keywords used in the variable declarations (example`LIKE`, `INZ`, `N` data type)

Provide a step-by-step description of the logic for each procedure.
4. `Procedures` : Provide a step-by-step description of the logic for each procedure.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For each procedure, state whether it is exported or internal to the module.


3. `Return Values` : List the return value accepted by the procedure, specifying whether it is an output

4. `Dependencies`: This section outlines all components that the procedure or subroutine depends on in order to run successfully. Dependencies include physical and logical files used for data access, external procedures for business logic, and display files for user interface interactions.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Git would not let me put this comment on the "Return values" line.

It should say

  1. Return value: List the value returned by the procedure. Specify the data type and the meaning of the return value.

- Example: The caller cannot update records it is only input. This means the procedure or subroutine is designed to read data but not modify it.

7. `Outcomes`: List possible major outcomes or scenarios resulting from the code execution. This section can include an optional usage example to illustrate the expected outcome.
7. `Usage Example`: List possible major outcomes or scenarios resulting from the code execution. This section can include an optional usage example to illustrate the expected outcome.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should show a call to the procedure, with any setup required for parameters, and either an example or a description of what the caller would do with the return value or any output parameters.


2. `Field Mapping`: If the procedure or subroutine relates to any display file or printer file, create a clear table or list to show how physical/logical file fields are mapped to display fields or printer file. This includes field names and display fields.

3. `Indicators`: If the procedure or subroutine uses indicators, explain their purpose and how they are set or cleared during execution in table format.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clarify that this is only the *IN indicators or any indicators in an INDDS data structure.

It should not be about any ordinary variables that happen to have the indicator data type.

@@ -94,27 +94,16 @@ The `GetActInf` module provides reusable subprocedures to retrieve account-relat
#### Return Value
| -Return Value- | Output | `char(10)` | The account number associated with the given ID |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the Return Value, The first two columns are not needed.

Data Type Description
char(10) The account number associated with the given ID

If it is a data structure, list the subfields.

- The returned value will be blank.
- Calling code must ensure the returned value is not reused inappropriately in future calls.

#### Usage Example
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For small snippets, I don't think it would be good to put **free at the top. But without **free, free-form code has to start in column 8. So, I think any little snippet like this should have 7 blanks before the code.

This version has the code starting in column 1. The formatter thinks the 'd' in userid is the D of a fixed-form D spec and it doesn't "see" the "dcl-s" part of the declarations so it doesn't colour them red.

dcl-s userid char(10);
dcl-s account_number char(10);
/copy getactinfcpy;

userid = 'TEST01';
account_number = GetAccNo(userid);

This version has 7 blanks preceding each line of code.

       dcl-s userid char(10);
       dcl-s account_number char(10);

       /copy getactinfcpy;

       userid = 'TEST01';
       account_number = GetAccNo(userid);

@@ -141,28 +130,17 @@ account_number = GetAccNo(userid);
| `P_UserId` | Input | `char(10)` | Customer ID to search for in the `AccPf` file |
| -Return Value- | Output | `char(50)` | The account description associated with the input `CustId` |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix this information about the return value to be in the same format as for GetAccNo above.

- If no match is found:
`account_desc` will be blank. The calling logic should handle such cases to avoid misinterpretation.


Copy link
Collaborator

@bmorris1 bmorris1 May 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Git would not let me add a comment on the line about the purpose.

It currently says

The RPGLE program provides reusable subprocedures to retrieve account-related information from the AccPf physical file based on a given customer ID (CustId). Specifically, it allows external programs to obtain:

It should say

The RPGLE module provides reusable subprocedures to retrieve account-related information from the AccPf physical file based on a given customer ID (CustId). Specifically, it contains exported procedures to obtain:


The RPGLE program is designed to retrieve the account number (`AccNo`) for a given user ID (`P_UserId`) from the `AccPf` file. It reads through the records in the `AccPf` file and searches for a match with the provided user ID. Once a match is found, it sets the corresponding account number in the output parameter `P_AccNo`.

### Parameters
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Git would not let me add a comment at the beginning of this file. The code sample for the program must have the **free right at the beginning of the line.

This is what the code looks like with the **free starting in column 5. It thinks the code is column-limited, so it interprets column 6 as being the spec type.

    **free
    ctl-opt dftactgrp(*no) actgrp(*new);

    dcl-f AccPf if e k disk;

This is what it looks like with the **free in column 1:

**free
    ctl-opt dftactgrp(*no) actgrp(*new);

    dcl-f AccPf if e k disk;

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment was not addressed yet.

- If the same program runs again without resetting `P_AccNo`, it retains the previous value, leading to incorrect or unintended output.

#### Usage Example
### 6. Usage Example
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Git would not let me add a comment in the File Specifications section.

It has this bit of sample code for a fixed-form statement. This would not be helpful for someone who does not know RPG.

FAccPf IF E K Disk

Please correct all such samples of fixed-form statements in all these documents to show the actual statement, surrounded by the two lines rpgle and and with 5 leading blanks.

     FAccPf     IF   E      K      Disk 

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be good to have a page about how to format code snippets, and link to the page from each document.

  • For small free-form snippets, don't put **free, but instead have 7 leading spaces
  • For large free-form snippets, make sure the **free is in column 1.
  • For fixed-form snippets, always have the correct fixed-format of the lines

Copy link
Collaborator

@bmorris1 bmorris1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of my comments apply to all the documents, such as my comments about formatting code snippets.

Also, some of my comments are not positioned against the line they apply to, because Git would not let me make a comment for some lines in large unchanged sections. I hope I made it clear what I was actually referring to ... :-)

Example:
| Parameter Name | Data Type | Description |
|----------------|------|--------|
| `pOrderId` | `char(10)` | The unique identifier for the order being processed |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a column after the Data Type column for whether it is input or output.

  • If CONST or VALUE is specified, it is input-only
  • If CONST or VALUE is not specified, it is input and output

- APIs or external libraries
- Data areas
- Data queues
- Any other external modules or systems
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change the last one to just "etc"

List all external components the program relies on to function correctly. This includes:
- Called programs
- Service programs (SRVPGMs)
- APIs or external libraries
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be two separate points

| Component Name | Type | Description |
|-----------------|----------|-------------|
| `CALC_SERVICE` | Service | Performs complex calculations for order processing |
| `DATA_AREA_1` | Data Area| Stores configuration settings for the program |
Copy link
Collaborator

@bmorris1 bmorris1 May 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this example library qualified since the library should be listed if it is known

| LIB1/DATA_AREA_1 | Data Area| Stores configuration settings for the program |

This section should illustrate all relevant aspects of calling the procedure, including:

1. The `/COPY` Statement
- Show how the caller includes the prototype using a `/COPY` directive (if applicable).
Copy link
Collaborator

@bmorris1 bmorris1 May 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is always applicable for an rpgle example for scope=module, since the caller is expected to be in a different module.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add this:

When there is no /COPY file with the prototypes, it is a problem in the application, especially if the other programs in the application define their own prototypes so they can call the procedures.

In that case, the issue with the missing /COPY with the prototypes should be mentioned in the "Problems" section.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@edmundreinhardt @Chandra-IBM1 @jiatianzhong How should usage samples be handled when the module doesn't have a copy file with the prototypes for its procedures?

  • Should the sample just make up the name of a /COPY file?
  • Should the sample actually code the prototype (which would add to the problem of the prototype being coded in multiple modules)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I started a Slack thread about this in the #wca4i-tcs-datagen channel: https://my.slack.com/archives/C08FGHCDT26/p1750425339221139

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am unable to follow that slack link but my opinion is that if no copybook is present/known, the prototype should be in the usage example. The developer can then copy it into a copybook
@bmorris1 @Chandra-IBM1 @jiatianzhong

- Show how the caller includes the prototype using a `/COPY` directive (if applicable).

2. Parameter Setup
- Define and initialize all input and output parameters required for the call.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

input and output parameters and any return value


3. The Procedure Call
- Demonstrate the call using:
- `CALLP` if using a procedure with a prototype.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CALLP opcode is not necessary. It is very rare that CALLP is used for a prototyped call in free form.

DCL-S orderTotal PACKED(9:2);
DCL-S statusCode CHAR(2);

CALLP CalculateOrderTotal(customerId : orderTotal : statusCode);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the CALLP. Just do the procedure call.

       CalculateOrderTotal(customerId : orderTotal : statusCode);

bmorris1 added 20 commits June 3, 2025 14:53
Removed extra sections for different types of data structures. Will later move the examples to a separate file
Examples of data structure explanations
Most of the information was moved into other files.
Minor change
The main change is to remove the Side Effects section since that should be covered by the global variables, file I/O, and dependencies.
Fix formatting
Some formatting changes.
Code-formatting corrections, some content corrections. 

More changes are needed for it to conform to the required output format.
Code formatting changes, some general output-format changes, more needed.
Add the parameter-number column to the parm tables
- Otherwise, use a clle snippet to represent a call from the command line.
```clle
call mypgm parm(parameters)
```
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question (@edmundreinhardt @Chandra-IBM1 @jiatianzhong )

If it is a fixed-form program with no prototype for the call, and the parameters in the *ENTRY PLIST form, would it be better to show a fixed form RPGLE CALL rather than showing a clle-style call from the command line?

     C                   call      'MYPGM'
     C                   parm                    parameter

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, use the fixed-form RPGLE CALL with PARM to match the style and parameter-passing method of the program. It is clearer and more accurate for understanding how the program expects to be called.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, thanks. I changed it to have 3 possibilities:

  • free-form call if there is a prototype
  • else fixed-form CALL+PARM if there is a *ENTRY PLIST
  • otherwise clle call

bmorris1 added 2 commits June 7, 2025 05:43
Fixed the algorithm for determining the number of bytes in packed fields with an even number of digits
Suggest to use a fixed-form CALL if the parameters are in *ENTRY PLIST format
- External APIs or modules
2. Parameter Setup
- Define and initialize all input, output parameters and any return values required for the call.
- Include declarations for any necessary constants, variables, or data structures.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be sections with "Possible Problems with this Code" and "Possible Improvements to this Code"

The parameters are described in a table with columns for the parameter number, `Data Type`, `Usage`, `Description`, and possibly `Attributes`.

The column for the parameter number does not have a heading.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add this:

If it is an unnamed parameter in a prototype, put not named in the name column. Also, add a point in the "Possible Improvements to this Code" that it's a good idea to give names to the parameters in a prototype

| * | PROCPTR | pointer(*proc) |
| O | CLASS(*java ...) | object(*java ... ) |
| D | DATFMT(fmt) | date(fmt) |
| T | TIMFMT(fmt) | time(fmt) |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add some information about data structure subfields that don't have any data type. See this Slack thread in #wca4i-tcs-datagen: https://my.slack.com/archives/C08FGHCDT26/p1750425339221139

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry. The correct link for the Slack thread about subfields with no data type is https://my.slack.com/archives/C08FGHCDT26/p1750441642809399


2. `Exported Procedures`

2. #### Exported Procedures
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the general part of api_output before the procedures should have the global dependencies (files and other objects)

Copy link
Collaborator

@bmorris1 bmorris1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made several new comments but I haven't finished my review yet.


##### Variables
This section documents all variables used in the program, module, or procedure. It should be described in tabular format with columns for Name, Data Type, Description, and Attributes.
Only include the Attributes column if necessary.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add the following information about how to describe externally-described fields that are implicitly defined by the compiler:

If it is a field that was defined by the compiler from an externally described file, mention that in the description. For example if you have this file:

     A          R ORDERFMT
     A            ORDERID        6A
     A            QUANTITY       5P 0
     A            PRICE          9P 2
     A          K ORDERID

and this rpgle code

       dcl-f orders;
       dcl-s total int(10);

       begsr add_to_total;
          total += quantity * price;
       endsr;

Put this for the description when describing the global variables used by the subroutine:

Name Data Type Description
Price packed(9:2), (5 bytes) Externally-described field from file 'ORDERS', likely set by a READ operation from the file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants