Help define table

Hi All,
I've asked this before, but did not get the answer I was hoping for; maybe I didn't state my problem clear enough. Let me ask again. If I have a table as below(format is: int, string, string):
1, Todd, Smith
10, Chris, Lee
5, Sue, Wilson
How can I define it in Java as a look-up table? I started to code up this and is running to problems:
class myTable
private myTable() { }
class myRecord
int id;
String lastName;
String firstName;
public myRecord(int id, String last, String first)
this.id = id;
this.lastName = last;
this.firstName = first;
myRecord [] record =
(1 "Todd", "Smith"),
(10 "Chris" "Lee"),
(5 "Sue" "Wilson")
Because I don't want to instantiate this class and want to use it as a constant class, I can't create an array of myRecord without instantiating it. I want to be able to access this table by doing:
for(int i=0;i<myTable.record.lenght;i++)
System.out.println(myTable.record.id+myTable.record[i].lastName+myTable.record[i].firstName);
Am I even on the right track or totally lost? Any suggestion? Thanks in advance!

Is this more or less what you had in mind?class MyTable {
     static final MyTable instance = new MyTable();
     private MyTable() { }     //  defines a singleton
     class MyRecord {
          int id;
          String lastName;
          String firstName;
          public MyRecord(int id, String last, String first) {
               this.id = id;
               this.lastName = last;
               this.firstName = first;
          void displayRecord() {
               System.out.println(id + "\t" + firstName + "\t" + lastName);
     }     // end of class MyRecord
     MyRecord [] record = {      new MyRecord(1, "Todd", "Smith"),
                                   new MyRecord(10, "Chris", "Lee"),
                                   new MyRecord(5, "Sue", "Wilson")
     static MyTable getInstance() { return instance; }
     void displayTable() {
          for (int x=0; x<record.length; x++) {
               record[x].displayRecord();
}     // end of class MyTable
// TableDriver class is used for testing purposes
public class TableDriver {
     TableDriver() {
          MyTable mt = MyTable.getInstance();
          mt.displayTable();
     public static void main(String[] args) {
          new TableDriver();
}Mark

Similar Messages

  • Help needed for data updation in User Defined Tables

    Hello Experts,
    I am developing one add-on in SAP B1 8.8 to input data in a User Defined Table described as under
    Table Name
    DriverMst UDT Type is No Object
    Description
    Stores the Driver master data which are used to get reference in Sale Delivery Form and Driver data management activity
    User defined fields
    Data Name
    Data source
    Size
    Pane Level
    Description
    Driver Code
    Code
    Alphanumeric
    0
    No object table fixed field
    System Name
    Name
    Alphanumeric
    30
    0
    No object table fixed field
    Full Name
    FullName
    Text
    50
    0
    Father Name
    FatherName
    Text
    50
    0
    Birth Date
    BirthDate
    Date
    0
    Phone Number
    PhoneNo
    Alphanumeric
    50
    0
    Mobile No
    MobileNo
    Alphanumeric
    13
    0
    I have created one form using screen painter displaying text boxes and bind them to the table.
    This form is working absolutely fine when there are some data in table (i.e. Browse using navigation)
    My problem is, when I click add button from tool bar the "OK" button turn to "Add" that means the form is set to Add mode, but when I click "Add" button after entering some data nothing happens and input data is not stored in Table. The same "OK" Button turned to "Update" when I do changes in loaded data, but my changes are not reflected to table after I click "Update".

    Thanks Nagarajan,
    None.
    There is no such query. The table fields is directly linked to Edit Box or Combo Box in form.
    From the examples I learned that I have to do something like this to get my table updated
    Dim oUsrTbl As SAPbobsCOM.UserTable
    Dim Res As Integer
    oUsrTbl = oCompany.UserTables.Item("DRIVERMST")
    oUsrTbl.Code = oBPC.Value 'Item Specific of Driver Code Edit Box
    oUsrTbl.Name = Left(oBPN.Value, 30) 'Item Specific of Name Edit Box
    oUsrTbl.UserFields.Fields.Item("U_FullName").Value = oMFN.Value
    oUsrTbl.UserFields.Fields.Item("U_FatherName").Value = oFTHN.Value
    oUsrTbl.UserFields.Fields.Item("U_BirthDate").Value = oDOB.Value
    oUsrTbl.UserFields.Fields.Item("U_PhoneNo").Value = oPHN.Value
    (Similar For rest ofthe fields)
    Res = oUsrTbl.Add()
    Just let me know that is this necessary to do like above.. To be frank there are few more fields and matrices on the form which I didn't mentioned. I am just trying to get recovered from first step to proceed further.
    Regards

  • Print Layout to User Defined Table

    Hello guyz..
    I want a make preprinted for my user query from user defined table where the header information is from another query.
    I guess, the base template User Report (system) can only show the repetitve data from one query but the header area is not,
    could you help, showing the header information from another query ??
    Thanks Regards

    Ria
    The word is that you cannot use the PLD with user defined tables (i wish it was possible).  So in any case to do that you have to use third party tools such as Crystal Reports and Reporting Services

  • How to create a Foreign key relationship between 2 user defined tables...

    Hi Folks,
    I have created two user defined tables... Where in i want to create foriegn key relationship between the 2 tables.... Can anyone guide the step by step procedure to do this scenario...
    Any help would be highly appreciated...
    Thanks

    Hi
    1.  In the 2nd table call the field of the 1st table which is a primary key.
    2.  Give the same field and dataelement name.
    3.  Select that field and then click on the foreign key field icon which is beside Search Help button.
    4. Then give short text, and the 1st table name.
    5. Then in the below box give the 2nd table name and 2nd table field name which you have called from 1st table.
    6. Then click on copy, then u will be able to see Check table name and check table field name beside foreign key table name.
    7. Then again click on copy.
    Regards
    Haritha.

  • How to fill the records from a User Define Table to PO item Grid

    Hi To all,
    I need to fill data from User Define table records into Purchase Order Item Grid.
    I created an UDF Filed in PO - Header Part - "PRS"(Filed Name)
    By using Formatted Search in itemcode column, i called a query,
    "Select itemcode, qty from (@user define tablename) where PRS = $http://OPOR.U_PRS"
    For eg:
    Output from querry
    ItemCode Qty
    ABC 1
    DEF 2
    DFG 7
    SDGD 9
    By using formatted search it is filling only first data in to itemcode column in PO Grid.
    Please help, how can i fill ALL the data in to my PO Grid?
    Thanks in Advance
    SAGAR

    The easisest way is to create datasource and the result bind to grid.
    Datasource:
               oDBDataSource = oForm.DataSources.DBDataSources.Add("@usertablename")
                Dim xoConditions As SAPbouiCOM.Conditions
                Dim xoCondition As SAPbouiCOM.Condition
                xoConditions = New SAPbouiCOM.Conditions
                xoCondition = xoConditions.Add
                xoCondition.BracketOpenNum = 1
                xoCondition.Alias = "u_zn"
                xoCondition.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL
                xoCondition.CondVal = "cond"
                xoCondition.BracketCloseNum = 1
                oDBDataSource.Query(xoConditions)
    binding (example for matrix, in grid is simillar)
                oMatrix.Clear()
                Dim cols As SAPbouiCOM.Columns
                Dim column As SAPbouiCOM.Column
                cols = oMatrix.Columns
                column = cols.Item("colX")
                column.DataBind.SetBound(True, "@usertable", "u_x")
    oMatrix.LoadFromDataSource()
    hoep it helps
    Petr

  • Error creating user defined tables: Ref count (-1120)

    Hi all !
    I have to create user defined tables per code, so I wrote <b>2 main functions</b>, first <i>to create a table</i> (with TableName,TableType and TableDescription properties)and  and <i>second to add fields</i> (to a certain table which is sent as parameter).
    I call these functions to create multiple tables. For the first 6 tables it works totally ok. But beginning from the 7th table it gives that "<b>Ref count for this object is higher then 0.</b> " (-1120) error. All parameters are ok just as the first 6 tables.
    Found such an explanation like below in help files.
    <i>The DI API allows only one instance of a meta data object at a time. This maintains data integrity by preventing any manipulation of a business object while modifying the object's user fields. Therefore, verify that no other DI object is active except the meta data object.</i>
    But why do I get such an error after sixth call of the function (but not beginning from the second table )?

    Gül,
    Have you tried doing some grbage collection?
    Search for a topic: "Add Usertables and Fields while having a recordset"
    HTH
    Juha

  • DI error when binding user defined table

    Hi,
    I am using matrix. Im binding a User defined table '@NEW' to a Datasource
    oForm.DataSources.DBDataSources.Add("@NEW")
    I also bind the fields to column of the matrix as given below
    oColumn = oColumns.Item("CodeNo")
    oColumn.DataBind.SetBound(True, "@NEW", "U_CodeNo")
    When the table @New contains no records i get error while binding the fields to the matrix.
    I tried the same using STANDARD SAP tables.I am not getting any error and it works fine.
    Can anyone help me?

    Hi,
    I am using matrix. Im binding a User defined table '@NEW' to a Datasource
    oForm.DataSources.DBDataSources.Add("@NEW")
    I also bind the fields to column of the matrix as given below
    oColumn = oColumns.Item("CodeNo")
    oColumn.DataBind.SetBound(True, "@NEW", "U_CodeNo")
    When the table @New contains no records i get error while binding the fields to the matrix.
    I tried the same using STANDARD SAP tables.I am not getting any error and it works fine.
    Can anyone help me?

  • Error while linking user defined table to user defined field using vb6.0

    Hi,
    I am creating a userdefined field on a SAPB1 table(PDN1) using vb 6.0
    I am trying to link this field to a user defined table.
    When i do that i get the following error:
    "The field 'Related table' should consist of 8 alphanumeric chracters with no valid or default values"
    When i try to do the same thing from SAPB1(not using code) there is no such problem.
    My vb code is as follows:
    Set oUserFieldsMD = oCmp.GetBusinessObject(oUserFields)
    oUserFieldsMD.TableName = "PDN1"
    oUserFieldsMD.Name = "OB_Locn"
    oUserFieldsMD.Description = "WH Location"
    oUserFieldsMD.Type = db_Alpha
    oUserFieldsMD.EditSize = 30
    lRetCode = oUserFieldsMD.Add
    If lRetCode <> 0 Then
        oCmp.GetLastError lErrCode, sErrMsg
        MsgBox sErrMsg
        GoTo Err_
    End If
    If Not oUserFieldsMD.GetByKey("PDN1", 0) Then
        MsgBox "Error"
        GoTo Err_
    End If
    oUserFieldsMD.LinkedTable = "OB_TEST"
    lRetCode = oUserFieldsMD.Update
    Your help will be much appreciated.
    Thanks.

    Great Sébastien!
    Looks like we could not survive here one day without your contribution
    Best regards,
    Frank
    PS: For readers of this thread who don't understand why
    EditSize
    must be "8":
    This is the size of the
    Code
    field in the user-defined table to which the new field OB_Locn (in the DB it will be U_OB_Locn) is linked to...
    So, it should be preferrably of the same size.

  • Syntax error when creating a user-defined table type in SQL Server 2012

    Why am I getting a syntax error when creating a user-defined table type in SQL Server 2014?
    CREATE TYPE ReportsTableType AS TABLE 
    ( reportId INT
    , questionId INT
    , questionOrder INT );
    Results:
    Msg 156, Level 15, State 1, Line 1
    Incorrect syntax near the keyword 'AS'.

    Hope these posts could help, 
    https://social.msdn.microsoft.com/Forums/sqlserver/en-US/37a45a9a-ed8c-4655-be93-f6e6d5ef44be/getting-incorrect-syntax-while-creating-a-table-type-in-sql-server-2008-r2?forum=transactsql
    Regards, Dineshkumar,
    Please Mark as Answer if my post answers your question and
    Vote as Helpful if it helps you

  • User defined table types sometimes show up a unknown data type in Profiler

    A couple of our users have a problem when using user defined table types. Calls are made using UDTT as variables and these are then passed to a stored procedure as parameters. Sometimes the application returns a timeout. In such situations a Profiler-Trace
    shows the following:
    declare @p4 unknown
    whereas the correct trace (that is sometimes displayed) should be:
    declare @p4 dbo.ReportFilterTableType
    ReportFilterTableType is a UDTT. The users do have correct permissions for the UDTT (otherwise they would never be usable for the user). What could be the reason that the data types for the variable
    @p4 in the example are sometimes returned as unknown and at other times are returned correctly as
    ReportFilterTableType? Could this possibly be a network related issue?
    Thank you.
    Graham Goodwin Email: [email protected]

    I know this is a old post, but i am also facing the same issue that too in my production server. Did you find any workarround for this issue. Please do reply. Critical problem we are facing.
    Alka, Is your problem timeouts when passing TVP parameters, or is it that a Profiler Trace shows type "unknown" for the TVP data type name?
    If your problem is timeouts, be aware that TVPs do not have statistics so the optimizer might not be able to generate an optimal plan for non-trivial queries. Declaring a primary key or unique constraint on the table type may help since that will provide
    useful cardinality information.  You may need to resort to hints in some cases.
    I suggest you start a new thread with details of your specific situation if the information in this thread doesn't help.
    Dan Guzman, SQL Server MVP, http://www.dbdelta.com

  • Item Code Auto Generation Based on User defined Tables

    I need the Item code like
    PRODUCT TYPE-ITEMGROUP-ITEMCODE-SUBITEM-BRAND-COLOR  e.g .FG-01-01-00-001-00.
    I created the following User define Tables and link to Item Master data
    U_PRO             - FOR PRODUCT TYPE
    U_GROUP        - FOR  ITEM GROUP
    U_ITEMCODE    - FOR ITEMCODE
    U_SUBITEM       - FOR SUB ITEM
    U_BRD              - FOR BRAND NAME
    U_COLOR         - FOR COLOR
    i need a formatted search in Item code to fetch the codes from the user defined  table
    i tried with the following
    SELECT T5.[Code]'-'T2.[Code]'-'T3.[Code]'-'T4.[Code]'-'T0.[Code]'-'T1.[Code] FROM [dbo].[@BRD]  T0 , [dbo].[@COLOR]  T1, [dbo].[@GROUP]  T2, [dbo].[@ITEMCODE]  T3, [dbo].[@SUBITEM]  T4, [dbo].[@PRO]  T5 INNER JOIN OITM T6 ON T5.Code = T6.U_PRO WHERE
    T5.[Code] = T6.[$U_PRO] AND 
    T2.[Code] = T6.[$ U_GROUP] AND
    T3.[Code] = T6.[$U_ITEMCODE] AND
    T4.[Code] = T6.[$U_SUBITEM] AND
    T0.[Code]  = T6.[$U_BRD] AND
    T1.[Code]  = T6.[$U_COLOR]
    showing errors. Can any one help me regarding this. I badly need the query for Auto generation of Itemcode

    Hi,
    How can you assign those UDF value without ItemCode in the first place?
    Thanks,
    Gordon

  • User Defined Table Setting

    Hello Experts,
    I created the User Defined Table in the name of SR NO where i entered the Docment No in Code Field (System generated default field).When i add the Document Number serially when i saved the UDT table then my serial sequence has changed.Could anyone help me out from these problem.
    Regards
    Amol

    Hi Suraj,
    These is my Query when i tried to run @PPC Table then it will not sort the Code & Name the details contain all the information.
    If u have any query please ask.
    SELECT T0.[Code], T0.[Name], T0.[U_0001] as 'Purchase Order No',T0.[U_0002] as 'Sr No', T0.[U_0003] as 'Item Code', T0.[U_0004] as 'Item Description' , T0.[U_9999] as 'Plan Qty', T0.[U_0005] as 'P O Qty', T0.[U_0006] as 'GRN No', T0.[U_0007] as 'GRN Date' , convert(varchar,T0.[U_0008]) as 'Batch Num',convert(varchar,T0.[U_0009]) as ' Heat Num', T0.[U_0010] as 'GRN Qty', convert(varchar,T0.[U_0011]) as 'RM Size',convert(varchar,T0.[U_0012]) as 'Length' , convert(varchar,T0.[U_0013]) as 'Pieces' , convert(varchar,T0.[U_0014]) as 'SO Num' , T0.[U_0015] as 'SO ROWNUM' , T0.[U_0016] as 'SO ItemCode' , T0.[U_0017] as 'SO Item Description' , T0.[U_0018] as 'SO Qty' , T0.[U_0019] as 'SUPP Name'  , T0.[U_0020] as 'Cust Name', T0.[U_0021] as 'Open PO Qty' ,convert(varchar,T0.[U_0022]) as 'SO Tol Size' , T0.[U_0023] as 'SO Condition' , T0.[U_0024] as 'SO Size' , T0.[U_0025] as 'SO Length' , T0.[U_0026] as 'Remarks' , T0.[U_0027] as 'Planning Date' , convert(varchar,T0.[U_0028]) as 'SO Dia MM' , T0.[U_0029] as 'Plan Pieces' , T0.[U_0030] as 'Stock Condition' FROM [dbo].[@PPC]  T0 ORDER BY T0.[U_0008]
    Regards
    Amol

  • How do i declare a user defined table type sproc parameter as a local variable?

    I have a procedure that uses a user defined table type.
    I am trying to redeclare the @accountList parameter into a local variable but it's not working and says that i must declare the scalar variable @accountList.this is the line that is having the issue: must declare the scalar variable @accountListSET @local_accountList = @accountListALTER PROCEDURE [dbo].[sp_DynamicNumberVisits] @accountList AS integer_list_tbltype READONLY
    ,@startDate NVARCHAR(50)
    ,@endDate NVARCHAR(50)
    AS
    BEGIN
    DECLARE @local_accountList AS integer_list_tbltype
    DECLARE @local_startDate AS NVARCHAR(50)
    DECLARE @local_endDate AS NVARCHAR(50)
    SET @local_accountList = @accountList
    SET @local_startDate = @startDate
    SET @local_endDate = @endDate
    CREATE TYPE [dbo].[integer_list_tbltype] AS TABLE(
    [n] [int] NOT NULL,
    PRIMARY KEY CLUSTERED
    [n] ASC
    )WITH (IGNORE_DUP_KEY = OFF)
    GO

    Why are you asking how to be an awful SQL programmer??  Your whole approach to SQL is wrong.
    We have a DATE data type so your insanely long NVARCHAR(50) of Chinese Unicode strings is absurd. Perhaps you can post your careful research on this? Can you post one example of a fifty character date in any language? 
    The use of the "sp_" prefix has special meaning in T-SQL dialect. Good SQL programmers do not use CREATE TYPE for anything. It is dialect and useless. It is how OO programmers fake it in SQL. 
    The design flaw of using a "tbl-" prefix on town names is called "tibbling" and we laugh at it. 
    There are no lists in RDBMS; all values are shown as scalar values. First Normal Form (1NF)? This looks like a set, which would have a name. 
    In any -- repeat any -- declarative programming language, we do not use local variables. You have done nothing right at any level. You need more help than forum kludges. 
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • Search Help on Table Control - Fill more than one field in the table?

    Hey everyone,
    I have built a screen with a Table Control on it... the fields of the table control are linked to an internal table...  The internal table has the line type of a structure I've defined in the data dictionary.  Within that structure in the data dictionary, I've linked some fields to search helps (For example, a MATNR and CUSTOMER search help)...  I've defined in the structure definition which fields from the search help are to be returned to which fields in the structure.
    The problem is, even though I have the search help set to export both the customer number and location when using the search help on the customer field, it still does not fill the location field within the table.  Is this a limitation of using search helps within table controls?
    I'm also finding that by defining the search help through the structure, instead of directly within the screen, the search help round button does not show up on the field, yet I can still press F4 to bring up the search help.  Is there a reason why it's not showing the search help clickable button even though it works fine using F4?
    For doing search helps in Table Controls, is it better to just build the search help, attach it directly to the field in the table, and then after the user picks the single field, use the PAI to run a select and fill the rest of the fields required?
    Thanks,
    Dallas

    Hi Dallas,
    (1)
    What  i understood is that you added a search help by defining it in the internal table type for a field customer number..in the search help you have 2 fields customer number and location...user press the search help ..then you need to fill 2 different fields or 1 field?
    if you need to fill the customer location or location (only one) then you need to set the "import" in the search help for whichever is required.....
    if you need to fill 2 or more different fields..then you can use the technique you have mentioned last , to do a select in PAI and fill the fields....but this you can use if the combination for the fields is unique...eg: u have customer number and location..if customer X can be mapped to location X and location Y..when a select statement is done there are 2 options..so in such cases it is better to leave the option to the user otherwise if there is a clear mapping like customer X can be mapped only to location X then you can use the select..
    (2)
    usually when you define it as a type in the internal table the icon doesn't show up..but you can do alternative like mentioned..go to the table,find the search help for the required field if present or create a new one if required and place the search help mentioned in the screen itself..so as to see the icon...sometimes users are adamant that they need the search help icon to be seen..so it depends on if your user
    (3)
    as in the example of customer number and location mentioned we can provide them different search helps and do the needful processing in PAI to fill the fields
    Table controls may be used for different purposes and requirements....even a checkbox,push button can be placed as a field in table control and used,but yes most of the time requirements are like what is mentioned in your case...
    Regards
    Byju

  • Import data in user define table through DTW.

    Hi experts,
    Can any one tell me how can i import data from excle in User define tables through DTW. Is any other way/tool avaliable to
    import data from excel sheet to User define tables
    BR,
    Hari

    Hi Hari,
    I suppose u did not do the following..
    1. Open DTW, in the menu click on advanced and clik on maintain interface...
    2. Now here select the UDT which u want to impot the data.
    3. right click on the UDT and click on Create template for structure
    4. NOw u use this tempalte and try.
    Please inform of the outcome  so that i can think of another soluton.
    Hope it helps,
    Vasu Natari.

Maybe you are looking for

  • Multiple devices + 1 BBID - Playbook and Smartphone

    Based on the answers provided in the thread below; http://supportforums.blackberry.com/t5/BlackBerry-PlayBook-2-0-Insider/Multiple-devices-1-BBID/td-p/... I do not understand the following statement; App World supports one simultaneous BBOS device an

  • Camera RAW not appearing in Photo Downloader

    Hello, Since moving to a new PC (from Windows XP to Windows Vista 32-bit), the Elements Photo Downloader never shows the RAW files just .jpg files. I'll try and describe my setup in detail: Windows Vista 32-bit Photoshop Elements 5.0 (applied the 5.0

  • Xorg 7.0 upgraders read this

    http://wiki.archlinux.org/index.php/Xorg7

  • Contextual Menu Layer Selection for CS4 and 5.x

    Hi all, I'm looking for a way to get contextual menu layer selection functioning better in Photoshop. Right clicking on a layer provides a menu but does not necessarily select the top layer automatically. If the layer is grouped, it will generally sh

  • CS6 Disk Cache reporting as full when it's not

    I put a 120GB Samsung Pro 840 Pro SSD on a Sonnet Tempo Card into my 4,1 Mac Pro to use a AE's Disk Cache, I set the disk cache to 100GB Recently AE often reports that there is not enough available space on the drive for the cache when I start it up.