This document discusses the Header/Detail form based on test implementation, which can be categorized as below :
For this example, primary key is made up of :-
Intended for developers who have Advanced knowledge of the EnterpriseOne Development tools, specifically Form Design Aid and Event Rules Design.
Below routine explains general routine for Header/Detail form :
EVENT: Add Record to DB - Before
BC Order Type (F4201)(DCTO) = FC Order Type
BC Order Company (Order Number) (F4201)(KCOO) = FC Order Company
BC Document (Order No, Invoice, etc.) (F4201)(DOCO) = FC Order Number
EVENT: Update Record to DB - Before
BC Order Type (F4201)(DCTO) = FC Order Type
BC Order Company (Order Number) (F4201)(KCOO) = FC Order Company
BC Document (Order No, Invoice, etc.) (F4201)(DOCO) = FC Order Number
EVENT: Row is Exited
GC Order Number = FC Order Number
GC Or Ty = FC Order Type
GC Order Co = FC Order Company
CONTROL: GRID Grid
EVENT: Add Grid Rec to DB - Before
BC Document (Order No, Invoice, etc.) (F4211)(DOCO) = GC Order Number
BC Order Company (Order Number) (F4211)(KCOO) = GC Order Co
BC Order Type (F4211)(DCTO) = GC Or Ty
BC Line Number (F4211)(LNID) = GC Line Number
EVENT: Update Grid Rec to DB-Before
Below Event is to handle the increment of Line Number (LNID) in the Grid in both Add and Update Mode.
EVENT: Dialog is Initialized
VA frm_mnLineNumber_LNID = "0"
EVENT: Grid Record is Fetched
If BC Line Number (F4211)(LNID) is greater than VA frm_mnLineNumber_LNID
VA frm_mnLineNumber_LNID = BC Line Number (F4211)(LNID)
End If
EVENT: Row is Exited
If GC Line Number is less than or equal to VA frm_mnLineNumber_LNID
VA frm_mnLineNumber_LNID = [VA frm_mnLineNumber_LNID]+1
GC Line Number = VA frm_mnLineNumber_LNID
End If
To handle this, temporary columns are added and stored value before and after change.
EVENT: Write Grid Line-Before
GC Order Amount - Line = [GC Quantity Ordered]*[GC Unit Price]
GC OTOT - Before (Hidden) = [GC Quantity Ordered]*[GC Unit Price]
FC Order Gross Amount_edit = [FC Order Gross Amount_edit]+[GC OTOT - Before (Hidden)]
EVENT: Add Record to DB - Before
BC Amount - Order Gross (F4201)(OTOT) = FC Order Gross Amount_edit
EVENT: Update Record to DB - Before
BC Amount - Order Gross (F4201)(OTOT) = FC Order Gross Amount_edit
EVENT: Row is Exited
GC Order Amount - Line = [GC Quantity Ordered]*[GC Unit Price]
EVENT: Row Exit & Changed - Asynch
If GC OTOT - Before (Hidden) is not equal to GC Order Amount - Line
FC Order Gross Amount_edit = ([FC Order Gross Amount_edit]+[GC Order Amount - Line])-[GC OTOT - Before (Hidden)]
End If
GC OTOT - Before (Hidden) = GC Order Amount - Line
CONTROL: HYPITEM &Delete
EVENT: Button Clicked
FC Order Gross Amount_edit = [FC Order Gross Amount_edit]-[GC Order Amount - Line]
In case Delete button against a single row is clicked, the value has to be subtracted
In Header/Detail form, if you do not handle GC (Grid Column) or GB (Grid Buffer) in toggling mouse cursor up and down, it may add addtional grid row. The problem of this coding is that detail information can be created without having actual data.
To prevent this, review code which computes/assigns GC/GB variable and put this assignment only when mandatory grid column has a valid value.
For example,
To save off the maiumum value of a specific grid column into a specific header table column. In example below, it is the maximum value of Unit Cost.
EVENT: Add Record to DB - Before
VA frm_MAX_UNCS = "0" /* Initialize temp value */
VA frm_MaxRow = "0" /* Initialize MaxGridRow - this form level varilable is created based on DD Alias SEQ */
VA frm_CurrentRow = "1" /* Initialize CurrentGridRow - this form level varialble is created based on DD Alias SEQ */
Get Max Grid Rows(FC Grid, VA frm_MaxRow) /* Call System Function to get Max Grid Row. The value will be actual number of rows + 1 in the Header/Detail form */
While VA frm_CurrentRow is less than VA frm_MaxRow /* Note that relation key word is "is less than" not "is equal to or less than" not to handle the last row */
Get Grid Row(FC Grid, VA frm_CurrentRow) /* Call System Function to get current row, pointer */
If GC Unit Cost is greater than or equal to VA frm_MAX_UNCS /* To store the biggest number */
VA frm_MAX_UNCS = GC Unit Cost
End If
VA frm_CurrentRow = [VA frm_CurrentRow]+1 /* Increase current row number otherwise, it falls into infinite looping because WHILE test will be always success */
End While
BC UnitCost (HeaderTable)(UNCS) = VA frm_MAX_UNCS /* assign temporary value to Business View column */
EVENT: Update Record to DB - Before
Repeat same action as for EVENT: Add Record to DB - Before.
One of possible implementation is making use of system function for Grid Get Max Grid Rows(FC Grid, return value),
Try,
2-1. Call system function Get Max Grid Rows(FC Grid, FC mnNoOfRows_RCK7)
2-2. Subtract it by 1 because additional row is to be added automatically for both Headerless/Detail form and Header/Detail Form: FC mnNoOfRows_RCK7 = FC mnNoOfRows_RCK7 - 1
2-3. Validate FC mnNoOfRows_RCK7 and set error if it is greater than 2
3. Press Button when there is modification regardless Form Mode (e.g., Row Exit & Changed - Inline event) using system fuction "Press Button(FC Push Button)
4. Recalculate max row when user delete any rows at the event of Button Clicked against Hyper Button Delete by calling Press Button(FC Push Button)