Description:-
Or else you can achieve this functionality by other way.
Output:-
There are two main ways to do it I can think of offhand.
Reflection and using the
SysModelELements
table. The first way will give you the name
& label, the second will not give you labels reliably.
The first job demonstrates this with reflection. The second shows
it with the
SysModelElements
tables, and is faster, but won't give you
the label. You can use a DictField
object to enumerate the label (as shown in the second method).
The first method is the most reliable as the second could have
some cases I haven't thought about such as table views or maps.
Here what I will do I will take dict table and bind my table in
dict table then I will get table fieldname and fieldlabel.
Create
Job and Run and Assign your TableName in Str tablename Property in Job.
static void TableFieldLookup(Args _args) { strtableName = 'table name'; DictTable dictTable; DictField dictField; inti; dictTable = new DictTable(tableName2id(tableName)); if (dictTable) { for (i=1; i<=dictTable.fieldCnt(); i++) { dictField = new DictField(dictTable.id(), dictTable.fieldCnt2Id(i)); info(strFmt("Field Name: '%1'; Field Label: '%2'; IsSystem: %3",dictField.name(),dictField.label(),dictField.isSystem())); } } else { error(strFmt("Table '%1' not found!", tableName)); } }
Or else you can achieve this functionality by other way.
static void TableFieldLookup(Args _args) { tableName tableName = 'A_PurchaseOrder'; SysModelElement tables; SysModelElement fields; DictField dictField; while select tables where tables.ElementType == UtilElementType::Table && tables.Name == tableName join fields where fields.ElementType == UtilElementType::TableField && fields.ParentModelElement == tables.RecId { dictField = new DictField(tables.AxId, fields.AxId); info(strFmt("Field Name: '%1'; Field Label: '%2'; IsSystem: %3",dictField.name(),dictField.label(),dictField.isSystem())); } }
Output:-
Thanks for comments.....