Columns

Columns is used to limit the number of columns associated with a table:
* Loaded in the class [F] when reading the data by a For, Readlock or Read instruction.
* Updated from the class [F] when writing the data by a Rewrite or RewriteByKey instruction.

Syntax

Columns CLASS (FIELD_LIST)Columns CLASS (FIELD_LIST) ExtendedColumns CLASS

Examples

 # Read then rewrite limited to 2 fields, code and file nameLocal File BPARTNER [BPR]# Position of the filter on the code and client nameColumns [BPR](BPRNUM,BPRNAM)For [BPR]...Rewrite [BPR]Next# Filter deletion: all the columns are now available againColumns [BPR]# Column filter on the class derived from the linkLocal File ORDERS [ORD]Local File ITMMASTER [ITM]Link [ORD] with [ITM]ITM0=[F:ORD]ITMREF as [ORI]# Position of the filter on the product ref., the product dest., the order no.Columns [ORI]([ITM]ITMREF,[ITM]ITMDES1,[ORD]WIPNUM)For [ORI]...Next# Filter deletion: all the columns are now available againColumns [ORI]# Column filter on the class that applies also on Read instructionLocal File ORDERS [ORD]Columns [ORD] (ORDNUM,CUSTOMER) ExtendedRead [ORD]ORD0=MY_ORDERIf [ORD]CUSTOMER=MY_CUSTOMER...Endif# Column filters that excludes some columns# - those having some data types (Clob, Blob, strings with a max length over 50 characters)# - for columns having a dimension greater than 1, we will only include the 2 first indexesLocal File ORDERS [ORD]# Let's first build the INCLUDE_LIST array by using the meta data stored in [G:ORD] classLocal Char INCLUDE_LIST(250)Local Integer I,J,KINCLUDE_LIST=""For I=1 to dim([G:ORD]nbzon-1J=evalue("type([G:ORD]adxfname("+num$(I)+"))"K=evalue("dim([G:ORD]adxfname("+num$(I)+"))"If (J<=60 or J>265) and (J<>522) and (J<>523)INCLUDE_LIST+=string$(INCLUDE_LIST<>"",",")+[G:ORD]adxfname(I)+string$(K>2,"(0..1)")EndifNext I# Now the Columns can be done by evaluating a string constant that contains the listColumns [ORD] (=evalue('"'+INCLUDE_LIST+'"'))

Description and comments

 # Read data in a loop with a filter on propertiesLocal File BPARTNER [BPR]# Position of the filter on the code and client nameColumns [BPR](BPRNUM,BPRNAM)For [BPR]...Next# Call another subprogramCall MY_SUB# Read again the data# The data read is still restricted here to the BPRNUM and BPRNAM columnsFor [BPR] Where......NextEndSubprog MY_SUB# Read data in the same table, but restricted on other propertiesLocal File BPARTNER [BPR]# Position of the filter on the code and client nameColumns [BPR](FCY,CRY,CRN)For [BPR]...NextEnd

Errors

CodeDescription
6Column does not exist in the table.
7Class does not exist (table not opened).
8Dimension given exceeds maximum dimension of the column.

See also

File, Link, For, Read, Rewrite, RewriteByKey.