Possible to pass the column source?

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
atostaine
Posts: 565
Joined: Wed Jan 20, 2016 7:38 am

Possible to pass the column source?

Post by atostaine » Tue Feb 16, 2021 4:48 am

I want to create a reusable part where I can pass any type of column (tree,grid,list) and retrieve the column heading.

The column heading may be Description, caption, etc. If it's description, I want to use FieldAttributeAsString( Description ) to return the description. To do that I think I need to pass the column source by reference. Is that possible?
Art Tostaine

User avatar
Dino
Posts: 95
Joined: Fri Jul 19, 2019 7:49 am
Location: Tail of the Dragon, Robbinsville, NC
Contact:

Re: Possible to pass the column source?

Post by Dino » Wed Feb 17, 2021 10:32 am

I can get to the objective using GET_FIELD and doing this code but not using the FieldAttributeAsString( Description ) as that requires to have a field (#PRIM_ILIB) and I cant find how to pass the field, because source returns an PRIM_OBJT:

Code: Select all

Evtroutine Handling(#com_owner.CreateInstance)
#COM_OWNER.ShowColumnHeading Nameofthecolumn(#LVCL4.Source)
* #COM_OWNER.ShowColumnHeading Nameofthecolumn(#GridColumn1.Source)
Endroutine

Mthroutine Name(ShowColumnHeading)
Define_Map For(*INPUT) Class(#PRIM_OBJT) Name(#NameOfTheColumn) Mandatory(*NULL) Pass(*BY_REFERENCE)

Define Field(#FIELDDESC) Type(*CHAR) Length(40) Decimals(0)
#STD_CHAR := #NameOfTheColumn.Name
Use Builtin(get_field) With_Args(#STD_CHAR) To_Get(#IO$STS #BLANK #STD_NUM #STD_NUM #BLANK #FIELDDESC)
#STD_TEXTL := #FIELDDESC
Endroutine
End_Com
full code here:

Code: Select all

Function Options(*DIRECT)
Begin_Com Role(*EXTENDS #PRIM_FORM) Clientwidth(1032) Clientheight(366) Componentversion(2) Left(677) Top(222)
Define_Com Class(#PRIM_LTVW) Name(#ListView1) Componentversion(2) Displayposition(2) Fullrowselect(True) Keyboardpositioning(SortColumn) Left(43) Parent(#COM_OWNER) Showsortarrow(True) Tabposition(2) Top(98) Columnbuttonheight(14)
Define_Com Class(#PRIM_LVCL) Name(#LVCL4) Displayposition(1) Parent(#ListView1) Source(#STD_MONTH)
Define_Com Class(#PRIM_LVCL) Name(#LVCL5) Displayposition(2) Parent(#ListView1) Source(#STD_NAME)

Define_Com Class(#PRIM_LTVW) Name(#ListView2) Componentversion(2) Displayposition(3) Fullrowselect(True) Keyboardpositioning(SortColumn) Left(283) Parent(#COM_OWNER) Showsortarrow(True) Tabposition(3) Top(105)
Define_Com Class(#PRIM_LVCL) Name(#LVCL1) Displayposition(1) Parent(#ListView2) Source(#STD_IDNO)
Define_Com Class(#PRIM_LVCL) Name(#LVCL2) Displayposition(2) Parent(#ListView2) Source(#STD_IDNOL)
Define_Com Class(#PRIM_LVCL) Name(#LVCL3) Displayposition(3) Parent(#ListView2) Source(#STD_IDNOS)

Define_Com Class(#STD_TEXTL.Visual) Name(#STD_TEXTL) Componentversion(1) Displayposition(1) Height(21) Left(31) Parent(#COM_OWNER) Tabposition(1) Top(53) Usepicklist(False) Width(951) Caption('Description of the field')

Define_Com Class(#PRIM_GRID) Name(#Grid1) Captionnoblanklines(True) Columnscroll(False) Componentversion(1) Displayposition(4) Left(519) Parent(#COM_OWNER) Showselection(True) Showselectionhilight(False) Showsortarrow(True) Tabposition(4) Top(107)
Define_Com Class(#PRIM_GDCL) Name(#GridColumn1) Displayposition(1) Parent(#Grid1) Source(#STD_INST2)
Define_Com Class(#PRIM_GDCL) Name(#GridColumn2) Displayposition(2) Parent(#Grid1) Source(#STD_INSTR)

Evtroutine Handling(#com_owner.CreateInstance)
#COM_OWNER.ShowColumnHeading Nameofthecolumn(#LVCL4.Source)
* #COM_OWNER.ShowColumnHeading Nameofthecolumn(#GridColumn1.Source)
Endroutine

Mthroutine Name(ShowColumnHeading)
Define_Map For(*INPUT) Class(#PRIM_OBJT) Name(#NameOfTheColumn) Mandatory(*NULL) Pass(*BY_REFERENCE)

Define Field(#FIELDDESC) Type(*CHAR) Length(40) Decimals(0)
#STD_CHAR := #NameOfTheColumn.Name
Use Builtin(get_field) With_Args(#STD_CHAR) To_Get(#IO$STS #BLANK #STD_NUM #STD_NUM #BLANK #FIELDDESC)
#STD_TEXTL := #FIELDDESC
Endroutine
End_Com


atostaine
Posts: 565
Joined: Wed Jan 20, 2016 7:38 am

Re: Possible to pass the column source?

Post by atostaine » Wed Feb 17, 2021 11:06 am

Thanks I did try that too. Do you know if that BIF work on end user windows pc’s or does it require a repository?

I am going to submit an RFE. We’ve wanted stuff like this forever.
Art Tostaine

User avatar
Dino
Posts: 95
Joined: Fri Jul 19, 2019 7:49 am
Location: Tail of the Dragon, Robbinsville, NC
Contact:

Re: Possible to pass the column source?

Post by Dino » Wed Feb 17, 2021 11:19 am

I tried running it from outside the development environment, from LANSA / Execute Applications / Exec Form and it worked fine.

The DLT_FIELD builtin have a note that says "This is a Specialized Built-In Function for use in a Development Environment only."
https://docs.lansa.com/14/en/lansa015/c ... _field.htm

but the GET_FIELD does not says anything...
https://docs.lansa.com/14/en/lansa015/c ... _field.htm

atostaine
Posts: 565
Joined: Wed Jan 20, 2016 7:38 am

Re: Possible to pass the column source?

Post by atostaine » Wed Feb 17, 2021 11:54 am

Thanks Dino. You know your stuff.
Art Tostaine

Post Reply