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

Similar Messages

  • How to read and write data to a user defined table?

    I have created a srf with 2 edit box and a ok buttin, I want to insert data to the user defined table i created using sql query while i press OK button..
    Please provide the complete code to insert and select da from the user defined table.

    Hi,
    You can use the code below.
    Dim ret As Long
    d
    Private Sub Add_Table_Click()
        Dim oUserTablesMD As SAPbobsCOM.UserTablesMD
        Set oUserTablesMD = oCompany.GetBusinessObject(oUserTables)
        ' When adding user tables or fields, use a prefix
        ' identifying your partner name space. This will
        ' prevent collisions from different partner add-ons
        ' SAP's name space prefix is "BE_"
        'Set the two mandatory fields
        oUserTablesMD.TableName = "T1"
        oUserTablesMD.TableDescription = "Table1"
        'Add the table (which contains 2 default, mandatory fields, 'Code' and 'Name')
        ret = oUserTablesMD.Add
        If ret <> 0 Then
            oCompany.GetLastError ret, Str
            MsgBox Str
        Else
            MsgBox "Table: " & oUserTablesMD.TableName & " was added successfully"
        End If
    End Sub
    Private Sub Add_UDF_Click()
        Dim oUserFieldsMD As SAPbobsCOM.UserFieldsMD
        Set oUserFieldsMD = oCompany.GetBusinessObject(oUserFields)
        oUserFieldsMD.TableName = "T1"
        oUserFieldsMD.Name = "AlbUDF"
        oUserFieldsMD.Description = "Albert UDF"
        'Add the field to the table
        lRetCode = oUserFieldsMD.Add
        If lRetCode <> 0 Then
            oCompany.GetLastError ret, Str
            MsgBox Str
        Else
            MsgBox "Field: '" & oUserFieldsMD.Name & "' was added successfuly to " & oUserFieldsMD.TableName & " Table"
        End If
    End Sub
    Private Sub Add_Data_Click()
        Dim oUserTable As SAPbobsCOM.UserTable
        Set oUserTable = oCompany.UserTables.Item(1)
        oUserTable.GetByKey ("T1")
        'Set default, mandatory fields
        oUserTable.Code = "A"
        oUserTable.Name = "Albert"
        'Set user field
        oUserTable.UserFields.Fields.Item("U_AlbUDF").Value = "1"
        oUserTable.Add
        If ret <> 0 Then
            oCompany.GetLastError ret, Str
            MsgBox Str
        Else
            MsgBox "Value to field: '" & oUserTable.UserFields.Fields.Item("U_AlbUDF").Name & "' was updated successfuly to " & oUserTable.TableName & " Table"
        End If
    End Sub
    Regards,
    Noor

  • Uploading Data in a User Defined table

    Hello Experts,
    I have a user defined table YFEED_TABLE_2 as a local object in the System. i want to upload some data from TEXT file to the table using LSMW TCode..
    But after selecting  u201CMaintain Object Attributesu201D in LSMW transaction...in the "STANDARD BATCH/INPUT METHOD", I have select an Object like Vendor master, material master,...few more are there...
    i don't know which object to Choose...how could i know that object is mapped to the target table  YFEED_TABLE_2 ...
    Please Help....
    Anupam...

    >
    Ankur Parab wrote:
    > Hi,
    > Use BDC recording method in LSMW and do a recording of SM30 transaction to maintain data in your Z table.
    >
    > Regards,
    > Ankur Parab
    Please tell me the procedure to perform BDC recording in LSMW & do a recording of SM 30 transaction???
    COuld please also tell me how to perform a new recording in transaction SHDB???
    Please Help...
    Anupam.,...

  • Mapping conversion help needed for date

    Hi Experts,
    I need help in message mapping convesion for date field
    The source date field can have value '2010-06-04T02:09:59.610-07:00' or 2010-06-04T02:09:60.610-07:00
    I have to change it to '2010-06-04T02:09:59.000-07:00'. ie, if the seconds are 59.XXX, or 60.XXX, then change to 59.000.
    Please let me know the best way to do this
    Thanks
    Mike

    Again, to make it more clear
    The source date field can have any date value such as
      2010-06-04T02:09:59.610-07:00 -
    This needs to be changed to 2010-06-04T02:09:59.000-07:00
      2010-06-04T02:09:60.610-07:00 -- This needs to be changed to 2010-06-04T02:09:59.000-07:00
    2010-06-04T02:09:60.000-07:00 -- This needs to be changed to 2010-06-04T02:09:59.000-07:00
    2010-06-04T02:09:59.000-07:00  - This need not be changed
    2010-06-04T02:09:58.610-07:00 -- This need not be changed
    2010-06-04T02:09:57.610-07:00  etc etc - These need not be changed.
    The only change using date function is for the first two dates, in which 59.XXX and 60.XXX need to be replaced with  59.000
    Using the above date function, all the seconds 59.XXX, 58.XXX, 60.XXX, etc etc,,, are converted to 59.000, 58.000 and 60.000
    I dont need this as per the requirement. So looks like the UDF needs to be altered a little to accomodate my requirement.
    Please help me.
    Thanks
    Mike

  • Query help needed for Sales order panel user field query.

    I have a user defined form field on sales order row level called = U_DEPFEEAMT
    1, I would like this field to get the value from a field on this sales order row level multiplied by what is in point 2 below. The details of field in point 1 is :
    Form=139, item=38, pane=1, column=10002117, and row=1
    2. The contents in field 1 should be multiplied  by a value coming from another user field linked to OITM master item.
    The details of user field attached to OITM is :
    OITM.U_DepositFeeON
    Appreciate your help.
    Thank you.

    Try this one:
    SELECT T0.U_DepositFeeON*$[$38.10002117.number\]
    FROM dbo.OITM T0
    WHERE T0.ItemCode = $[$38.1.0\]
    Thanks,
    Gordon

  • Help needed for dynamic update form

    I could really use some advice - I've been asked to build a time tracking application (basically a timesheet) and I have a fair bit done but the part I am really struggling with is the best way to accommodate some of the specifications. I am NOT a programmer (I have some coldfusion experience but nothing really advanced) so I have not managed to sucessfully integrate the various methods I've found on the web so far. The database is created and so are all the queries, and I have also written a cfc to handle the drop-down menu logic needed but I don't really know how to integrate it with the form.
    Our production server has ColdFusion MX7 so all the great functionality in the CF8 examples I can't use.
    The issue is the user should ideally be able to add/edit/delete multiple rows at once- I like CFGRID, and the HTML version seems best. The main issue with the Flash version is the scrolling to get to the insert/delete buttons- I couldn't see how to get rid of that. A separate add and edit form could be ok depending on how easy it is to use.
    One problem I have is that I can't work out how to have default values with the grid (the userID which is a session variable, and the date which is constantly changing- there is a cfcalendar for the user to change date).
    The biggest hurdle is the related select drop-downs I need- it's not quite as simple as the city,state,postcode examples. For the first drop down the pick an option- and for only 2 of those options there is a second drop-down. Anything else and it stops there. For the second drop-down, there are 2 options, and depending on which one of these they pick the 3rd drop-down pulls a query from one or another table in the database (2 entirely different things). The three  options have different database tables. The main timesheet table just stores the id number from those tables (so I also need to display the names on the drop-down from the options tables not the number).
    I played with simple and complicated javascript and coldfusion solutions as well, but because it's a form to update records and also because of the above specs I just couldn't get anything to work right. I tried binding with the cfc and nothing would bind, plus I don't know how to make all happen without a page reload.
    Does anyone have any advice for the best approach to this? As I mentioned I've got tables, queries and even a cfc but I'm not too clear on how to put it all together properly within the constraints of MX7.
    PS I also can't post a lot of code because of where I work- I know that's not helpful but am looking for the best approach to this, then I can work on the details. Right now I am jumping from solution to solution and not getting anywhere.

    Well, a lot of code has come and gone because I couldn't make it work, where I'm currently at is:
    <cfform name="updateform" id="updateform" action="#CurrentPage#?#CGI.QUERY_STRING#">
      <cfgrid name="MainData" height="400" insertbutton="add" deletebutton="remove" query="getMainData" insert="yes" delete="yes" rowheight="20"  selectmode="edit" format="html">
      <cfgridcolumn name="id" display="no">
    <cfgridcolumn name="userID" display="no">
    <cfgridcolumn name="entrydate" display="no">
    <cfgridcolumn name="activityID" >
    <cfgridcolumn name="typeID">
    <cfgridcolumn name="projectID" values="#ValueList(getProjects.id)#" valuesdisplay="#ValueList(getProjects.name)#">
    <cfgridcolumn name="time" width="10">
    <cfgridcolumn name="comment" width="150">
    </cfgrid>
    <cfinput type="hidden" name="entrydate" value="#Session.username#">
    <cfinput type="hidden" name="entrydate" value="#editdate#">
    <cfinput name="update" type="Submit" value="Update">
    </cfform>
    ** for some reason getProjects.name doesn't work and causes an error. I haven't worked out how to get the default inputs for the date and user ID to work either. I also tried binding and a flash form somewhere along the way.
    ** the CFC is below, #ds# didn't work and I had to put in the actual DSN name, not sure why, but anyway this is the logic of the thing. Ideally I would like to use this logic with the cfgrid, but I'm not sure if that is possible? It seems like it would be the most user friendly approach.
    The CFC so far is:
    <cfcomponent>
       <cffunction name="getActivities" access="remote" returnType="query">
            <cfquery name="getActivities" datasource="#ds#">
    SELECT * FROM timesheet_activities
    </cfquery>
            <cfreturn getActivities>
        </cffunction>
        <cffunction name="getTypes" access="remote" returnType="query">
        <cfargument name="Activity" type="any" required="true">
        <cfif ARGUMENTS.Activity EQ "">
            <cfset getType = "">
        <cfelse>
            <cfquery name="getTypes" datasource="#ds#">
            SELECT * FROM timesheet_type
            </cfquery>
        </cfif>
        <cfreturn getTypes>
        </cffunction>
        <cffunction name="GetProjects" access="remote" returnType="query">
        <cfargument name="Activity" type="any" required="true">
        <cfargument name="Type" type="any" required="true">
        <cfif ARGUMENTS.Activity EQ "" OR ARGUMENTS.Type EQ "">
            <cfset LstProjects = "">
        <cfelseif ARGUMENTS.Activity EQ "1" OR "3">
        <cfquery name="getProjects" datasource="#ds#">
    SELECT id,name FROM projectsa
    WHERE completed = 'false'
    </cfquery>
    <cfelse>
    <cfquery name="getEProjects" datasource="#dse#">
    SELECT id,name FROM projectsb
    WHERE statusID = '6'
    </cfquery>
        </cfif>
        <cfreturn getProjects>
        </cffunction>
    </cfcomponent>
    Any attempts to actually use the cfc didn't work. I tried to use it with a normal html update form and got the message- failed to bind, Activity didn't exist. I also tried to bind it to a flash grid. The argument for Activity needs to come from the drop-down Activity type selected. Maybe I'm missing something.
    ETA:
    just moved everything to the live MX7 server (because my dev server is Coldfusion8) and I get the following:
    Attribute validation error for tag CFGRID. The tag does not allow the attribute(s) BINDONLOAD,BIND.
    Does this mean I definitely can't use the CFC with the cfgrid on MX7? Or is there a way to do it?
    Any advice would be greatly appreciated.

  • Help needed for a new Mac user with his photo and video librarys

    after swopping my Ericson for an iphone a year ago. then taking delivery of an iPad on launch day. I have finally taken the plunge and swopped my windows pc for a lovely 27" iMac... what have I been doing all these years using windows? using the Mac is a joy.
    As I get more involved with their products I am constantly fascinated (and frustrated) by Apples way of doing things. this situation is no exception and I need Apple people with Apple experience to help me make a decision. 
    I am looking at software to organise my photos and videos. I have approximately 7000 photos residing on a windows home server. in addition to that there are some 200 or so HD videos taken with either my Sanyo Xacti camcorder or Sony DSC W300 camera. both cameras I think produce MPEG format
    my first experience was iPhoto. great for the `price' but not very flexible. single libraries, poor editing facilities. and because I have files referenced and not copied to my iPhoto library, if I deleted from the library its not deleted from the server (and vice versa). this leads to images being displayed in the library that don't exist etc.
    then I downloaded the Aperture 3 trial. great until I came across the `Unsupported file format' situation with the MPEG videos that strangely enough, iPhoto will recognise and play (the Apple way of doing things).
    1. should I put the photos on the Mac instead of the server?
    2. Is there a better way of managing the images for deletions etc
    3. should I stick with Aperture because of the editing
    4. is there a better software or way of managing the videos
    sorry for the ramble but its all new to me

    had a good session on all three of the recommended programs and now have a better understanding of the excellent advice I have been given.
    iPhoto
    great `free' program that is easy to use but somewhat limited on features. think I would always be looking to upgrade from here (feels a bit boring)
    Aperture
    really enjoyed using this but at £170! a hefty price tag considering its limited file support. fortunately its only my camera video clips (MPEG) that it wont view. my camcorder files (MP4) are fine so this is looking better as a one stop solution.
    Elements
    much more than just a image touch up. considering what it can do.. very good value at around £60. teamed with iPhoto it becomes even more attractive.
    My issue still remains with the masters file location.
    I would prefer to keep all my media on the external server to ensure I have a fail safe recovery option. its a 4TB 5 disk affair which contains all the family music, video images and DVD's etc (likely to change to a Mac server in the future!)
    one feature that I cant find, (even in Aperture which surprises me), is the ability to automatically manage deletions from referenced locations? i.e. delete a file from the server and when aperture opens up the thumbnails are updated. or, delete a referenced master in Aperture and an option comes up to delete the referenced file on the external drive.
    how would a professional photographer or studio using Aperture manage this process (or would they use something else?)
    forgot to mention that through our student facilities i can get a discounted copy of Photoshop CS5 for around £175 which is close to Aperture. is this a worthwhile option or overkill
    Message was edited by: buttons129

  • ASAP Help needed for iOS4 - Updating without syncing to iTunes

    Right, I'm currently unavailable to access the computer that I sync my iPhone with and cannot access it for the forseeable future as I'm going away from home for a while tomorrow. I need to know if I can sync my iPhone with a computer that is not my standard syncing one that has iOS4 downloaded on it without my iPhone syncing and losing all of my data - and if this is possible how to do it.
    Thanks
    Message was edited by: Wrigle

    You should be ok to update your phone on any pc or mac.
    When you update iTunes will back up your phone to that computer, and will update only the os.
    If you restore though you won't be able to sync your music, photos, podcasts, or apps but your contacts, email accounts and setting will be restored.

  • Help needed for Data Pump.

    Hi,
    I am using oracle 11g release2 and I am not able to find data pump utility in SQL developer.
    Please let me know, if I need to install it. I am new to this utility.
    Thanks.

    I do not believe SQL Developer would have DataPump utility.
    As the name implies, SQL Developer is intended to be used as a tool to facilitate development (typically of SQL code), as well as provide additional features to assist developers in their daily routines.
    DataPump, is more of a DBA tool used for extracting logical copies of data from an existing database and/or port to another database. To use this utility, you would typically need to be in the dba group (although not necessary if configured properly). But at least on the same server as the datapump utility software resides.
    There are many options and features to using datapump, including network_link which allows extraction of data from a remote database to another database on a different server without ever creating a file on the operating system.
    If I recall correctly, I believe in older versions of Oracle client (e.g., 8.x), the Oracle client provided the export/import utility. But those days are long gone now. With datapump, it is primary a DBA tool.

  • Little help needed for a poor pc user

    Okay, I just started using mac and I'm having a few problems that I cant figure out myself. When I downloaded a codec pack, the computer didnt recognize the .exe file and im just wondering why that is. This isnt the first time I have encountered this problem either. So, I'm just thinking that this is something that happens becuase not everybody makes mac friendly software. Can Someone please make me understand how to fix this problem?

    You're not entirely stuck, if you decide to install Windows either along side Mac OS X (Boot Camp Beta) or on a virtual machine (Parallels Desktop).
    Yang

  • Help needed for making a copy of a table .

    Hi ,
    I have a table , which is consisting for nearly 20 columns .
    I want to make a Copy of that table with data or without data anything will be fine .
    Please tell me how can i make that ??
    Is there any option available for that ??
    Thank you .

    CREATE TABLE MY_COPY AS SELECT * FROM ORIG_TABLE WHERE 1=2;will create a copy of ORIG_TABLE without rows,indexes,constraints.
    CREATE TABLE MY_COPY AS SELECT * FROM ORIG_TABLE ;will create a copy of ORIG_TABLE with rows but without indexes and constraints. This would be acceptable if the table is small. Else, create an empty table (as above) and then use
    ALTER TABLE MY_COPY NOLOGGING;
    INSERT /*+ APPEND */ INTO MY_COPY SELECT * FROM ORIG_TABLE ;(Optionally, add PARALLEL Hints to the INSERT and SELECT.
    You can use Export and Import utilities to create a copy of table with options to include or exclude rows, constraints, indexes.
    Hemant K Chitale
    http://hemantoracledba.blogspot.com

  • Insert to User Defined Table

    Guys.. How can i insert my data to my user defined table (Master Document), i have write code:
    Set oUserTable = oCompany.UserTables.Item("TR_MD_FAKPAJAK")
    oUserTable.Code = "1"
    oUserTable.Name = "TORO"
    oUserTable.UserFields("U_field1").Value = "toro"
    oUserTable.UserFields("U_field2").Value = "toro"
    oUserTable.UserFields("U_field3").Value = "toro"
    oUserTable.UserFields("U_field4").Value = "toro"
    oUserTable.UserFields("U_field5").Value = "toro"
    Dim retval As Long
    retval = oUserTable.Add
    If retval <> 0 Then
        oCompany.GetLastError lErrCode, sErrMsg
        MsgBox lErrCode & " " & sErrMsg
    Else
        MsgBox "Masuk"
    End If
    my question is, when i run always display error "-4002 To Generate This Document, first defined the numbering series in Administration Module",
    any idea guys ??
    Thx

    Hi Ria,
    Unfortunately you cannot insert data in to a UDO table using the DI API (by marking your table as a 'Master Document' table you have made your UDT part of a UDO). It is one of the current limitations with working with UDOs. All data must be entered through the UI (ie manually).
    If you just want to store data in a UDT then it is best to create the table as 'No object'. You can then use the DI API to read and write data to your table. However, you do lose the UDO functionality (eg no automatic saving or searching etc).
    Kind Regards,
    Owen

  • Update the data in user-defined table

    Dear All,
    Is there anyway we can insert / update the data in user-defined table in a batch instead of update it from the interface one by one? Our customer has 1,000+ data need to be imported.
    They are on SAP2007A SP00 PL45, SQL 2005, CA localization. Thanks a lot.
    Regards,
    yuka

    Dear Yuka,
    If it is UDT, you may use any SQL query to insert, update it. It is not under SAP support anyway.
    Thanks,
    Gordon

  • Hi help needed. Just updated my I phone 4 for first time since I bought it (I know, I know). Lost everything. What I really want back is my notes. Any ideas. Please. Somewhat desperate!!!!

    Help needed. Just updated my I phone 4 and lost all my notes, and no I didn't put them in the I cloud. Please help. Need those notes!

    You could always check to make sure itunes is updated to 10.7 but im sure gdgmacdude is
    right.
    thanks
    gdgmacdude
    Hey dude
    are there anymore hardware failure errors u know of
    im kinda a novice apple man and could use all the help i can get
    capp

  • Get Error while update the User defined row table through DSK Code

    Hi experts,
    I have got an error while updating the user row defined table.
    Error is - "Invalid row"
    I have created one master table "@CBF_FARM " and Child table "@CBF_FAR1"
    First i inserted 5 record in the child table so in my my child table there are 5 Line id (1,2,3,4,5 one for each row).
    after that i delete 2 rows (3rd & 4th row) from child table now in my child table there are 3 rows( Line id 1, 2, 5). Please See attachment.
    Now i am updating  the last record of child table through Code  (Line id is 5)  from other form, then i got error  invalid row.
    Following Code used for updating the user defined child table.
      SAPbobsCOM.GeneralService oGeneralService1 = null;
                                    SAPbobsCOM.GeneralData oGeneralData1 = null;
                                    SAPbobsCOM.GeneralDataParams oGeneralParams1 = null;
                                    SAPbobsCOM.CompanyService sCmp1 = null;
                                    SAPbobsCOM.GeneralData oChild1 = null;
                                    SAPbobsCOM.GeneralDataCollection oChildren1 = null;
                                    sCmp1 = clsAddOn.LDNA_Company.GetCompanyService();
                                    oGeneralService1 = sCmp1.GetGeneralService("CBF_FARM");
                                    // Get UDO record
                                    oGeneralParams1 = ((SAPbobsCOM.GeneralDataParams)(oGeneralService1.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralDataParams)));
                                    oGeneralParams1.SetProperty("Code", oForm.Items.Item("edtFarmCd").Specific.Value);
                                    oGeneralData1 = oGeneralService1.GetByParams(oGeneralParams1);
                                    // Add lines on UDO Child Table
                                    oChildren1 = oGeneralData1.Child("CBF_FAR1");
                                    // Create data for rows in the child table
                                    SAPbouiCOM.Item oItem = oForm.Items.Item("cmbShed");
                                    oCombo = oItem.Specific;
                                    string ShedCode = oCombo.Selected.Value;
                                    ldna_Rec = clsAddOn.LDNA_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
                                    string strQuery1 = "select LineId from [@CBF_FAR1] where U_ShedCd = " + ShedCode;
                                    ldna_Rec.DoQuery(strQuery1);
                                    oChild1 = oChildren1.Item(ldna_Rec.Fields.Item("LineId").Value - 1);
                                    oChild1.SetProperty("U_Status", "Ready For Schedule");
                                    //Update the UDO Record
                                    oGeneralService1.Update(oGeneralData1);
    Please Help me it is an urgent requirement,
    -Regards
    Vikas

    hi.
    Error is - "Invalid row"
    Now i am updating  the last record of child table through Code  (Line id is 5)  from other form, then i got error  invalid row.
    As per my knowledge
    What i understood is you have 5 lines and you are going to be update 5th line
    am i correct..
    while u are updating the line in child table
    you have to consider like this..
    line number         u have to update like
    1                                        0
    2                                        1
    3                                        2
    4                                        3
    5                                        4
    which means in child table treat
    line 1  as 0
    line 2 as  1
    line 5 as 4
    If you want to update the line 5 u have to mention 4 th line

Maybe you are looking for