martes, 3 de mayo de 2016

[JD Edwards] Loop All Grid Rows

A lot of times we'll need looping all grid rows, for example, for update a grid column, save the rows in a auxiliar table, etc. It's easy if we use system functions:

Get Max Grid Rows(FC Grid, Total_Rows) -> This system function returns total grid rows in the second parameter for the grid indicated as the first parameter.

Get Grid Row(FC Grid, RowId) -> This system function returns the GC values for the line id number indicated as the second parameter.


And with this functions, we'll doing a loop to iterate above all rows, and a variable for current row where we initialized to 1 and increase by 1 on each iteration (previously checking that there are lines in grid)






Example:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
VA frm_55_CurrentRow_MATH01 = 1
Get Max Grid Rows(FC Grid, VA frm_55_TotalRows_MATH01)
If VA frm_55_TotalRows_MATH01 is not equal to <Zero>
While VA frm_55_CurrentRow_MATH01 is less than or equal to VA frm_55_TotalRows_MATH01
  Get Grid Row(FC Grid, VA frm_55_CurrentRow_MATH01)
  //
  // Works with row
  //
  GC CatCod1 = FC CatCod1
  //
  F4211.Update
  GC Order Co = TK Order Company (Order Number)
  GC Order Number = TK Document (Order No, Invoice, etc.)
  GC Or Ty = TK Order Type
  GC Line Number = TK Line Number
  VA frm_55_SecuencialFiltro_JOBN -> TK Work Station ID
  //
  VA frm_55_CurrentRow_MATH01 = [VA frm_55_CurrentRow_MATH01]+1
 End While
End If

2 comentarios: