Hi Guys,
I have created a small function to resolve Dynamic external datawindow issue. In the argument of that function I have received table attribute = (column name, datetype & size) and return DW syntax as string.
Here is the Export syntax of structure where I Assign table attribute value and pass into function
global type str_tableattribute from structure
string datatype
string size
string colname
end type
Declare instance: str_tableattribute istr_TableAttribute
Then call the function
String ls_DWSyntax, ls_error_create, ls_resp
Integer li_TotalIndex
//Assign table attribute into istr_TableAttribute
ls_DWSyntax = wf_CreateExtDWSyntax(istr_TableAttribute)
dw_bookdetails.Create(ls_DWSyntax, ls_error_create)
If Len(ls_error_create) > 0 Then
MessageBox("CreateError", ls_error_create)
Return
End If
Here is my function to create External DW Syntax
String ls_DWSystax = "", ls_TableAttribute, ls_DW_TextHeader, ls_DW_Column
String ls_ColName, ls_DataType, ls_Size
Integer li_index, li_TotalIndex, li_MeasurementPerChar, li_ColPixelDiff
Long ll_X, ll_Width
li_TotalIndex = UpperBound(astr_tableattribute)
If li_TotalIndex > 0 Then
ls_DW_TextHeader = ""
ls_DW_Column = ""
ll_X = 4
ll_Width = 0
li_MeasurementPerChar = 30
li_ColPixelDiff = 12
//Prepare Basic of DataWindow - Part 1
ls_DWSystax = "release 12.5;" + "~n~r" + &
"datawindow(color=1073741824 processing=1 )" + "~n~r" + &
"header(height=80 color=" + '"536870912"' + " )" + "~n~r" + &
"detail(height=92 color=" + '"536870912"' + " )" + "~n~r"
ls_TableAttribute = "table("
For li_index = 1 To li_TotalIndex
ls_ColName = astr_tableattribute[li_index].ColName
ls_DataType = astr_tableattribute[li_index].DataType
ls_Size = astr_tableattribute[li_index].Size
//Prepare DataWindow Table and column details - Part 2
ls_TableAttribute = ls_TableAttribute + "column=(type=" + ls_DataType
If Upper(ls_DataType) = 'CHAR' Or Upper(ls_DataType) = 'DECIMAL' Then
ls_TableAttribute = ls_TableAttribute + "(" + astr_tableattribute[li_index].Size + ") "
End If
If Upper(ls_DataType) <> "CHAR" Then
ls_Size = String(20)
End If
ls_TableAttribute = ls_TableAttribute + &
" name=" + ls_ColName + " " + &
"dbname=" + '"' + ls_ColName + '" )' + "~n~r"
ll_Width = li_MeasurementPerChar * Integer(ls_Size)
If li_index > 1 Then
ll_X = ll_X + li_ColPixelDiff + ll_Width
End if
//Prepare DataWindow Column Header details - Part 3
ls_DW_TextHeader = ls_DW_TextHeader + "text(band=header text=" + '"' + ls_ColName + '" color=' + '"33554432"' + &
" y=" + '"4"' + " x=" + '"' + String(ll_X) + '"' + " height=" + '"68"' + &
" width=" + '"' + String(ll_Width) + '"' + " name=" + ls_ColName + "_t" + &
" background.color=" + + '"536870912"' + " )" + "~n~r"
//Prepare DataWindow Column details - Part 4
ls_DW_Column = ls_DW_Column + "column(band=detail id=" + String(li_index) + " tabsequence= " + String(li_index * 10) + &
" color=" + '"33554432"' + " y=" + '"4"' + " x=" + '"' + String(ll_X) + '"' + " height=" + '"76"' + &
" width=" + '"' +String(ll_Width) + '"' + " name=" + ls_ColName + &
" background.color=" + + '"536870912"' + " )" + "~n~r"
Next
//Marge All 4 part
ls_TableAttribute = ls_TableAttribute + ")" + "~n~r"
ls_DWSystax = ls_DWSystax + ls_TableAttribute + ls_DW_TextHeader + ls_DW_Column
End If
Return ls_DWSystax
Can u tell us what pass by, argument type and argument value for the function ?
function wf_CreateExtDWSyntax ( Value structure astr_tableattribute)
Here structure as argument type is not working. What argument type to be used ?