************************************************************* * TBTEST - sample RPGLE program showing the following: * * - receive Net.Data table variable as input parameter * - add 1 row, 3 columns to table variable * - assign column headers to the 3 rows * - put edited values into the row * - return table variable to Net.Data * * Program compile commands: * * crtrpgmod module(netdata/tbtest) * srcfile(netdata/qrpglesrc) * * crtpgm pgm(netdata/tbtest) * bndsrvpgm(qhttpsvr/qtmjle) ************************************************************* * Copyright (c) 2000, Craig Pelkie * ALL RIGHTS RESERVED * craig@web400.com ************************************************************* D************************************************************* D* dtw_table_AppendRow - add one or more rows to end of table D************************************************************* Ddtw_table_AppendRow... D pr 10I 0 extproc('dtw_table_AppendRow') D table * D rows 10I 0 value D************************************************************* D* dtw_table_SetCols - set number of columns for a table D************************************************************* Ddtw_table_SetCols... D pr 10I 0 extproc('dtw_table_SetCols') D table * D cols 10I 0 value D************************************************************* D* dtw_table_SetN - assign a name to a column heading D************************************************************* Ddtw_table_SetN... D pr 10I 0 extproc('dtw_table_SetN') D table * D src * value options(*string) D col 10I 0 value D************************************************************* D* dtw_table_SetV - assign a value in a table D************************************************************* Ddtw_table_SetV... D pr 10I 0 extproc('dtw_table_SetV') D table * D src * value options(*string) D row 10I 0 value D col 10I 0 value D************************************************************* D* SetTable - set a table column heading or table value D************************************************************* DSetTable... D pr D table * D value 256 value varying D type 1 value D col 10I 0 value D row 10I 0 value options(*nopass) D************************************************************* D* Work fields and Constants for testing D************************************************************* D amtField s 11 D charField s 20 D dateField s 8 D rc s 10I 0 D table s * D COLHDG1 c 'Amount Field' D COLHDG2 c 'Character Field' D COLHDG3 c 'Date Field' ************************************************************* * Receive table variable from Net.Data macro ************************************************************* C *entry plist C parm table ************************************************************* * Create a 1 x 3 (rows x columns) table ************************************************************* C eval rc = dtw_table_SetCols(table : 3) C eval rc = dtw_table_AppendRow(table : 1) ************************************************************* * Set column headings ************************************************************* C callp SetTable(table : COLHDG1: 'N' : 1) C callp SetTable(table : COLHDG2: 'N' : 2) C callp SetTable(table : COLHDG3: 'N' : 3) ************************************************************* * Set values for each column ************************************************************* C eval amtField = %editw(12345.67 : '$ , 0. ') C eval charField = 'Test Net.Data tables' C eval dateField = %editc(udate: 'Y') C callp SetTable(table : amtField : 'V' : 1 : 1) C callp SetTable(table : charField : 'V' : 2 : 1) C callp SetTable(table : dateField : 'V' : 3 : 1) C eval *inlr = *on C************************************************************* C* SetTable - set a table column heading or table value C* C* table - Net.Data table to work with C* value - column heading or column value C* type - type of function call C* N = dtw_table_SetN C* V = dtw_table_SetV C* col - column number to work with C* row - row number to work with C************************************************************* PSetTable b D pi D table * D value 256 value varying D type 1 value D col 10I 0 value D row 10I 0 value D options(*nopass) D n s 5 0 D ptr s * D rc s 10I 0 C eval n = %len(value) + 1 C alloc n ptr C eval %str(ptr : n) = value C if type = 'N' C eval rc = dtw_table_setN(table : ptr : col) C endif C if type = 'V' C eval rc = dtw_table_setV(table : ptr : row : col) C endif C dealloc ptr PSetTable e