Substring Example

LANSA for i

Substring Example

This screen demonstrates the use of the "Substring of a field/record" option and how it may be used in breaking down a field/record after input from a file.

Using the example of the accounting file ACCMST and the chart of accounts field CHTACC described in the last section, the "virtual" field COMPNO can be derived from the "real" field CHTACC as follows:

 

 

 DC@P201605          Substringing of a Field/Record                    

                                                                       

 File: ACCMST     Accounts Master file                                 

                                                                       

 Virtual field: COMPNO     Company number (first 2 digits of CHTACC)   

                                                                       

 Derive "virtual" field on input from file . . : YES  YES, NO          

 Setup "real" field before output to file  . . : NO   YES, NO          

                                                                       

 Field to substring from . . . . . . . . . . . . CHTACC                

                                                                       

 Start position  . . . . . . . . . . . . . . . . 1                     

                                                                       

                                                                       

 Fnn=Help  Fnn=Exit  Fnn=Cancel  Fnn=Messages  Fnn=Change  Fnn=Delete  

                                                                       

 

 

 

A similar substringing operation could be performed on CHTACC to derive virtual fields DIVNUM and COSTCT simply by specifying a start position of 3 for DIVNUM and 5 for COSTCT.