Concatenate tableBASE libraries

The tableBASE test library is concatenated in front of the production library. If the test version of a table is present, it will be used.

In COBOL
 01  LIB-LIST.
     05  LIB-LIST-1                PIC X(8) VALUE SPACES.
     05  LIB-LIST-2                PIC X(8) VALUE SPACES.
     05  LIB-LIST-3-10             PIC X(64) VALUE SPACES.

 PROCEDURE DIVISION.
 HOUSE-KEEPING.
     MOVE 'TESTLIB'                TO LIB-LIST-1
     MOVE 'PRODLIB'                TO LIB-LIST-2
     MOVE 'ML'                     TO xxxx-COMMAND
     CALL 'TBLBASE' USING          TB-PARM
                                   xxxx-COMMAND-AREA
                                   LIB-LIST
In C
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "dkh.h"

/*
 * DK1TEX7C
 *
 * Concatenate tableBASE libraries. The test library is
 * put in front of the production library. If the test
 * version of a table is present, it will be used.
 */
 
/*
 * Assume these are user inputs.
 */
static char szTableName[6] = "AARON";
static char szStatus[6] = "NYYYN";
/*
 * Assume you have these DDName defined in your JCL.
 */
static char szTestLib[8] = "TESTLIB";
static char szProLib[7] = "PROLIB";

int main(void)
{
    TbParmStruct tbParm;
    TbCommandAreaStruct tbCommArea;
    TbLibListStruct tbLibList;
    char sTestLib[8];
    char sProLib[8];
    char sTableName[8];
    char sStatus[8];
        
    /*
     * Initialize the parameters.
     */
    fixStringLength( szTableName, sTableName, 8 );
    InitTbParm( &tbParm );
    InitTbCommandArea( &tbCommArea, sTableName );
    InitLibList( &tbLibList );
    
    /*
     * Initialize tableBASE with CS, ChangeStatus.
     */
    fixStringLength( szStatus, sStatus, 8 );
    memcpy( tbCommArea.tbCommand, "CS", 2 );
    TBLBASE( &tbParm, &tbCommArea, sStatus );
    if( tbCommArea.tbError != TB_SUCCESS )
    {
        printf( "CS\n");
        printf( "Found code: %c\n", tbCommArea.tbFound );
        printf( "Error code: %d\n", tbCommArea.tbError );
        printf( "Sub code: %d\n", tbCommArea.tbErrorSubcode );
        return tbCommArea.tbError;
    }
    
    /*
     * Modify the library search order with ML.
     */
    fixStringLength( sTestLib, szTestLib, 8 );
    fixStringLength( sProLib, szProLib, 8 );
    memcpy( tbLibList.lib1, sTestLib, 8 );
    memcpy( tbLibList.lib2, sProLib, 8 );
    memcpy( tbCommArea.tbCommand, "ML", 2 );
    TBLBASE( &tbParm, &tbCommArea, &tbLibList );
    if( tbCommArea.tbError != TB_SUCCESS )
    {
        printf( "ML\n");
        printf( "Found code: %c\n", tbCommArea.tbFound );
        printf( "Error code: %d\n", tbCommArea.tbError );
        printf( "Sub code: %d\n", tbCommArea.tbErrorSubcode );
        return tbCommArea.tbError;
    }
    
    return TB_SUCCESS;
}