Function SET220A Write 1000 X filled records to S220PFL

LANSA

Function SET220A Write 1000 X filled records to S220PFL

* =======================================================
* Process ........: SET_220
* Function .......: SET220A
* Created on .....: 05/12/2001 at 12:12:37
* Description ....: Access a file with a
* variable length field.
* Version.........: 1
*
* Full Description: The purpose of this function is to
* demonstrate that LANSA functions can work with
* OS/400 files that have VARLEN fields.
*
* VARLEN fields can have a variable length
* up to a specified maximum length.
*
* See also the definition of LANSA file S220PFL
* and the DDS for S220PFL (in source file
* SETCLSRC)
* This example requires LANSA
* data area DC@OSVEROP to contain:
* *OTHER_VARCHAR
*
* Disclaimer: The following material is supplied as
* sample material only. No warranty concerning the
* material or its use in any way whatsoever is
* expressed or implied.
*
* Minimum LANSA release: 8.0
*
* =======================================================
* Function control options
Function Options(*DIRECT)
Open Use_Option(OND)
*
* Group and field definitions
*
Define Field(#S_220INS1) Type(*CHAR) Length(075) Input_Atr(LC)
Define Field(#S_220INS2) Type(*CHAR) Length(075) Input_Atr(LC)
*
*
* Lists
*
Def_List Name(#S_LSTBRW) Fields((#S_220ID1 *HIDDEN) #S_220TXV) Entrys(0000010)
*
*
* Mainline
*
*
Def_Cond Name(*AS400) Cond('*CPUTYPE = AS400')
If Cond(*AS400)
Else
Message Msgtxt('Not available on PC')
Menu
Endif
*
* Create 1000 X filled browselist entries
Use Builtin(FILLSTRING) With_Args(X) To_Get(#S_220TXV)
Begin_Loop Using(#S_220ID1) To(1000)
Add_Entry To_List(#S_LSTBRW)
End_Loop
*
Message Msgtxt('Press enter to see the resulting file size')
*
* Clear out the file first
Exec_Os400 Command('CLRPFM FILE(S220PFL)')
* Save to file
* update or insert records as appropriate
* Note how no special processing is required as long
* as the virtual field S_220TXV is used
*
*
Selectlist Named(#S_LSTBRW)
Insert Fields(#S_220ID1 #S_220TXV) To_File(S220PFL)
Endselect
* Now reload the browselist from the file to demonstrate
* that the read/write to the file is ok
*
Clr_List Named(#S_LSTBRW)
* Read any existing records from file
Change Field(#S_220ID1) To(0)
Select Fields(#S_220ID1 #S_220TXV) From_File(S220PFL)
Add_Entry To_List(#S_LSTBRW)
Endselect
*
Change Field(#S_220INS1) To('''1000 X filled records have been written to file S220PFL''')
Change Field(#S_220INS2) To('''Press enter to see the resulting size of the file''')
Display Fields((#S_220INS1 *L3 *P2 *NOID *NC) (#S_220INS2 *L4 *P2 *NOID *NC)) Design(*DOWN) Identify(*LABEL) Down_Sep(001) Across_Sep(001) Browselist(#S_LSTBRW)
*
* Display the size of the file
Exec_Os400 Command('DSPOBJD OBJ(S220PFL) OBJTYPE(*FILE)')
*
*
Menu