Dictionary

FieldLabel
ListOfFields
Table dictionary
Label
Tables with a special configurationKey
makeRecord

FieldLabel

	SysDictField dict = new SysDictField(tableId, fieldId);
	str label = dict.label(); 		// -> "Total energy production" //take from edt if edt
	info(dict.labelLabel());  		// -> "@SPL946"                 //take from edt if edt
	info(dict.labelDefined());		// -> "@SPL946"                 //dn't take from edt.

List of fields

static void SPL_SBE_Test(Args _args)
{
    Dictionary      dictionary;
    TableId         tableId;
    tableName       tableName;
    fieldid          fieldid;
    DictTable dicttable;
    
    ;

    //dictionary = new Dictionary();

    //tableId = dictionary.tableNext(0);
    //tableName = dictionary.tableName(tableId);
    TableId = tableNum(SPLLoadPlan);

    while (tableId)
    {
        info(strfmt("%1 - %2",int2str(tableId), tableName));
        
        dicttable=new DictTable(tableid);
        
        fieldid=dicttable.fieldNext(0);
        
        while(fieldid)
        {
            info(strfmt("%1-%2",tableName,dicttable.fieldName(fieldid)));
            fieldid=dicttable.fieldNext(fieldid);
            //
        }

        tableId = dictionary.tableNext(tableId);
        tableName = dictionary.tableName(tableId);
    }
}

sysDictTable

    SysDictTable sysDictTable = new SysDictTable(tablenum(LedgerJournalTrans));
    Set fieldsSet;
    Set systemFieldIds = new Set(Types::Integer);
    SetEnumerator fieldSetEnumerator;
    ;

    // Generate the list of system fields contained by this table.
    systemFieldIds.add(fieldnum(LedgerJournalTrans, RecId));
    systemFieldIds.add(fieldnum(LedgerJournalTrans, RecVersion));
    systemFieldIds.add(fieldnum(LedgerJournalTrans, DataAreaId));


    // Copy the non-system fields from this buffer to the destination buffer.
    fieldsSet = sysDictTable.fields();
    fieldSetEnumerator = fieldsSet.getEnumerator();
    while(fieldSetEnumerator.moveNext())
    {
        field = fieldSetEnumerator.current();
        fieldId = field.id();
        if (!systemFieldIds.in(fieldId))
        {
            // This is not a system field, so copy the value across.
            _destination.(fieldId) = this.(fieldId);
        }
    }

Label

static void Job40(Args _args)
{
	str label; 
	;
	//Get label of field
	label = fieldPName(EmplTable, EmplId);
	info('Field name: '+label);

	//Get label of EDT:
	label = new SysDictType(extendedTypeNum(EmplId)).label();
	info('EDT name: '+label);

	//Get label of table
	label = tablePName(EmplTable);
	info('Table name: '+label);
}

Tables with a special configurationKey

static void FindTablesFromConfigKey(Args _args)
{
	// The name of the configuration key to be specified here
	str                     configKeyName   = "Prod";
	Dictionary              dictionary      = new Dictionary();
	ConfigurationKeyId      configKeyId     = dictionary.configurationKeyName2Id(configKeyName);
	TableId                 tableId;
	DictConfigurationKey    dictConfigurationKey;
	DictTable               dictTable;
	container               keyIds;
	int                     i;
	;
	if (configKeyId)
	{
		// Find all children of the specified configuration key
		for (i = dictionary.configurationKeyNext(0); i; i = dictionary.configurationKeyNext(i))
		{
			dictConfigurationKey = new DictConfigurationKey(i);

			while (dictConfigurationKey.parentConfigurationKeyId())
				dictConfigurationKey = new DictConfigurationKey(dictConfigurationKey.parentConfigurationKeyId());

			if (dictConfigurationKey.id() == configKeyId)
				keyIds += i;
		}

		// Find all tables that have an appropriate configuration key
		i = 0;
		for (tableId = dictionary.tableNext(0);tableId;tableId = dictionary.tableNext(tableId))
		{
			dictTable = new DictTable(tableId);
			if (!dictTable.isMap() && !dictTable.isTmp() && !dictTable.isView())
			{
				if (confind(keyIds, dictTable.configurationKeyId()))
				{
					i++;
					info(dictTable.name());
				}
			}
		}
	}

	info(strfmt("%1 tables have configuration key '%2'", i, configKeyName));

makeRecord

static void SPL_Upd_AddressFromFormat(Args _args)
{
	DataArea          company;
	int               i,j;
	TableId           tableId;
	Common            common;
	DictTable         dictTable;

	container TableName = ["Address","BankAccountTable","BankGroup","CompanyInfo","ContactPerson","CustBankAccount",
						   "CustCollectionLetterJour","CustConfirmJour", "CustInterestJour", "CustInvoiceJour",
						   "CustInvoiceTable","CustPackingSlipJour","CustQuotationJour","CustTable",
						   "InventTransferTable","PurchLine","PurchReqLine","PurchReqTable","PurchRFQCaseLine",
						   "PurchRFQCaseTable","PurchRFQLine","PurchRFQTable","PurchTable",
						   "SalesLine","SalesQuotationBasket","SalesQuotationLine","SalesQuotationTable","SalesTable","SMAServiceOrderTable",
						   "smmBusRelTable","smmImportContactPersonJournal","smmImportRelationJournal",
						   "VendBankAccount","VendPackingSlipJour","VendPurchOrderJour","VendReceiptsListJour","VendRFQJour","VendTable"]

	;
	while select company
		where company.IsVirtual == false
	{
		changecompany(company.Id)
		{
			Warning(company.Id);
			for (i = 1 ; i <= conLen(TableName) ; i++)
			{
				ttsbegin;

				tableId = tablename2id(conPeek(TableName, i));
				dictTable = new DictTable(tableId);

				//common = null;
				common = dictTable.makeRecord();                      //create a common according to the table.
				j=0;
				while select forupdate common
				{
					common.AddressMap::formatAddress();
					common.doUpdate();
					j++;
				}

				ttscommit;
				Info(strfmt("%1 %2", conPeek(TableName, i), j));
			}
		}
	}
	Info("Done.");
}