Creating a User Table via DI API

Hi all,
I'm using
SAP Business One 2004A (6.70.185) SP: 00 PL: 07
and corresponding SAP Business One DI API 2004
I want to create a user table.
I try to create it this way:
I have two functions
First function to create the table
Private Function AP_AddOn_CreateTable() As Boolean
   AP_AddOn_CreateTable = True
   Dim oUDT As SAPbobsCOM.UserTablesMD
   Dim sErrMsg As String
   Dim iErrCode As Integer
   Dim iReturn As Integer
   oUDT = oDIComp.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables)
   oUDT.TableName = "AP_tbItemCalc"
   oUDT.TableDescription = "ItemCalculation"
   iReturn = oUDT.Add
   If iReturn <> 0 Then
      oDIComp.GetLastError(iErrCode, sErrMsg)
      Message…
      AP_AddOn_CreateTable = False
   End If
   oUDT = Nothing
End Function
This works fine
Then I call a second function to create the user fields
Private Function AP_AddOn_CreateFields() As Boolean
   AP_AddOn_CreateFields = False
   Dim oUDF As SAPbobsCOM.UserFieldsMD
   Dim sErrMsg As String
   Dim iErrCode As Integer
   Dim iReturn As Integer
   oUDF = oDIComp.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserFields)
   oUDF.TableName = "@AP_tbItemCalc"
   'Field1
   oUDF.Name = "ItemCode"
   oUDF.Description = "ItemCode"
   oUDF.Type = SAPbobsCOM.BoFieldTypes.db_Alpha
   oUDF.Size = 20
   iReturn = oUDF.Add()
   If iReturn <> 0 Then
      oDIComp.GetLastError(iErrCode, sErrMsg)
      Message…
      Exit Function
   End If
   'Field2
   oUDF.Name = "ItemName"
   oUDF.Description = "ItemName"
   oUDF.Type = SAPbobsCOM.BoFieldTypes.db_Alpha
   oUDF.Size = 100
   iReturn = oUDF.Add()
   If iReturn <> 0 Then
      oDIComp.GetLastError(iErrCode, sErrMsg)
      Message
      Exit Function
   End If
      next fields …
   AP_AddOn_CreateFields = True
End Function
The second function returns on adding the first field, an error, errCode -1120, errMsg ‚Ref count for this object is higher than 0’
If i close the application after creating the table and then restart the application only executing the second function it works.
I also tried the example as provided in ‚MetaDataOperations’ and it shows the same behaviour.
Besides, I’m the only user on the system and no other application is running.
Kind regards,
Eduard

Hi,
See Add  userfield to usertable 1120 Error  SOLUTION
HTH
Ribeiro Santos

Similar Messages

  • Adding new record in user table via DI API

    Dear all,
    I created in SAP B1 two user tables (Master data and master data rows)
    I need to add a new header record in my master data user table by DI code.
    This is my source code...
    Dim sboDestTable As SAPbobsCOM.UserTable = oCompany.UserTables.Item("MY_HEAD_TABLE")
    sboDestTable.Code = newCode
    sboDestTable.ArchiveDate = Now
    sboDestTable.UserFields.Fields.Item("u_userfield1").Value = "new value 1"
    Dim ErrCode As Integer = sboDestTable.Add()
    but I have an exception error message on the Add() command: "SAP B1 Cannot add rows to a MasterData type UserTable"
    Can someone help me, please?
    How can I add a new record in a user master data table?
    Best regards
       Emanuele

    Hi,
    Try this :
    SAPbobsCOM.GeneralService oGeneralService;
    SAPbobsCOM.GeneralData oGeneralData;
    SAPbobsCOM.GeneralData oChild;
    SAPbobsCOM.GeneralDataCollection oChildren;
    SAPbobsCOM.GeneralDataParams oGeneralParams;
    oCompService = SBO_Company.GetCompanyService();
    SBO_Company.StartTransaction();
    oGeneralService = oCompService.GetGeneralService("UDOCODE");
    oGeneralData = (SAPbobsCOM.GeneralData)oGeneralService.GetDataInterface(GeneralServiceDataInterfaces.gsGeneralData);
    //Setting Data to Master Data Table Fields
    oGeneralData.SetProperty("Code", CodeHeader);
    oGeneralData.SetProperty("U_ProjectC", ProjectCodeHeader);
    oGeneralData.SetProperty("U_ProjectN", ProjectNameHeader);
    oGeneralData.SetProperty("U_StartDate", StartDateHeader);
    oGeneralData.SetProperty("U_EndDate", EndDateHeader);
    //Setting Data to Child Table Fields
    oChildren = oGeneralData.Child("DETAILTABLENAMEWITHOUT@");
    oChild = oChildren.Add();
    oChild.SetProperty("U_Code", ActivityCodeRow);
    oChild.SetProperty("U_Name", NameRow);
    oChild.SetProperty("U_DESC", DescriptionRow);
    oChild.SetProperty("U_Building", NumberOfBuildings);
    oChild.SetProperty("U_STDT1", StartDateRow);
    oChild.SetProperty("U_ENDT1", EndDateRow);
    oChild.SetProperty("U_ESTMTDY1", DaysFinal);
    //Attempt to Add the Record
    oGeneralService.Add(oGeneralData);
    if (SBO_Company.InTransaction)
    {                                                                 SBO_Company.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_Commit);
    Hope it helps.
    Thanks & Regards
    Ankit Chauhan

  • How do I create new user table in program and then access it?

    I am writing an application where I check for the existence of user objects when the add on starts and run the setup if the objects do not exist. I can create the user tables and fields but after the setup completes these objects still are not visible.
    If the user objects exist when the add on is first run everything is detected correctly.
    When a user object is added in SAP the user is eventually prompted to restart so I suspect something needs to happen prior to the add on being able to use the new fields.
    Does the add on need to wait for the DI Server to perform some action? Do I need to just quit the add on's class and rerun it, disconnect and reconnect to the company, or get a new Application and/or company object?
    What I want to do is figure out a way for the add on to automatically run the configuration if the user tables and fields do not exist yet and then kick off the regular add on code. I haven't seen anyone else's code so I don't know what is recommended or required here.
    Thanks for any assistance!

    I found that the add on can validate the existance of the user fields if I disconnect from the company object, set the SAPbouiCOM.Application and SAPbobsCOM.Company objects to null, set the new application, context, and company objects, and reconnect once more.
    HOWEVER...
    I still have to wait for the client to be restarted manually before I can run any of the form I added to the menu.
    So, I'd still like to know what the best practice is here. Should I just exit after setting up the tables and tell the user to restart SAP?

  • Newly created Image not listed via REST API

    Hi,
    I have created a image in azure console .Its created successfully and i could see the created image under "Image" tab in console.Also, the image created with the name appending current date, it was not before.But when I am trying to list images by
    using the below REST API its listing images except the newly created images that have the  name appended with current date.
    https://management.core.windows.net/5f2fe4c3-23b3-45c0-a70c-9560b79dcf56/services/images
    header values:
    x-ms-version : 2012-03-01
    Content-Type : application/xml
    Host: management.core.windows.net
    This makes me fail to launch new VM via REST api.I got the response as follows
    <Error xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><Code>BadRequest</Code><Message>The image vmyffdd-20140605-813455l does not exist.</Message></Error>
    Please look into this.

    hi,
    From the error, your request parameter was incorrect. I guess your image name may be wrong. How did you write your Image name and url? I suggest you don't forget the '.VHD'. Also,if you use the
    VMImageName element which is only available using version 2014-02-01 or higher
    And I suggest you could try this code sample about how to using REST api to create VM :Simple Windows Azure REST API Sample Tool
    Please try it.
    Regards,
    Will
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Error -1116 when creating a Sales Order via DI API

    Hi All,
    We have an developed EDI AddOn that creates Sales Orders in SBO 2007 PL13, in one of our clients.
    This AddOn is responsible for the creation up to 100 orders each day on SBO.
    However, sometimes (3 to 4%) during the Sales Order creation, the system return an error -1116 when the Sales Order is created - via oSalesOrder.Add() method.
    The problem is that the order is created anyway, although this error is raised.
    I've searched in the forums and it seems the solution is somehow related with SBO transactions.
    However, the AddOn only created the Sales Order, nothing more.
    Does any body know a solution for this problem?
    Regards,
    Manuel Dias

    Hi,
    see this links,
    Error -1116 when creating delivery note
    Could not commit transaction, ReturnCode:-1116
    Regards,
    siva

  • Creating multiple user tables using script

    hi
    my requirement is i want to create multiple tables by running script . is it possible .how do i do that can any one suggest me and send sample code to solve this task.
    (i have to create 100 userTables it is very difficult to create using code or from B1 that is my requirement )and i think some good solution is there for my problem and inserting the tables into B1 by running script.

    Hi Om,
    Take a look at the SDK help files, or even better, the examples provided with the SDK, they give you a good example how to create a usertable.
    Tried that, you could programm a loop wich creates your usertables, or a function that progresses a input file containing all your usertables.
    <b>Pseudo code loop (C#)</b>
    for(int i = 1; i <=100; i++)
      /* Call you your function that creates a usertable with the given name */
      CreateUserTable("TBL_" + i.ToString());
    Hope it helps,
    Rowdy

  • Error while creating new user via new MDM API

    Hi
    I have two questions:
    1) Is it possible to create a user in MDM via MDM4J?
    2) I am trying to create a user through new MDM API (not the MDM4J). When I execute the command CreateUserCommand, I get following error:
    com.sap.mdm.commands.CommandException: com.sap.mdm.internal.protocol.manual.ServerException: MDM repository data is out-of-date or is locked by another MDM Server. Refresh the data and try the operation again. If the error persists, contact the system administrator.
         at com.sap.mdm.security.commands.CreateUserCommand.execute(CreateUserCommand.java:93)
         at demo.dm.GetRoleList.main(GetRoleList.java:206)
    Here is the code that I execute:
              CreateUserCommand createusercommand =
                   new CreateUserCommand(connections);
              createusercommand.setSession(repsessionId);
              UserProperties userpp = new UserProperties();
              userpp.setName("Vijendra");
              //userpp.setRoleIds(roleids);
              createusercommand.setUser(userpp);
              //createusercommand.setInChangeStamp(-1);
              //System.out.println(createusercommand.getOutChangeStamp());
              try {
                   createusercommand.execute();
              } catch (CommandException e) {
                   e.printStackTrace();
                   return;
    Thanks
    Vijendra
    Edited by: Vijendra Bhanot on Feb 22, 2008 6:42 PM
    Edited by: Vijendra Bhanot on Feb 22, 2008 6:49 PM

    Hi
    I am also getting same exception.
    com.sap.mdm.internal.protocol.manual.ServerException: MDM repository data is out-of-date or is locked by another MDM Server. Refresh the data and try the operation again. If the error persists, contact the system administrator.
    Please help me.
    Thanks & Regards
    Vinit

  • Create user via UME API/LDAP

    Hi,
    I'm trying to create a user using the UME Api
    IUserMaint umeUser = UMFactory.getUserFactory().newUser( uniqueId );
    .... set properties on umeUser...
    umeUser.commit;
    The user created ok in our ldap server (Tivoli DS) but on the root dn, i.e. ou=companyX,c=se
    Is there a way to create the user in another ldap-node, say ou=internetUsers, ou=companyX, c=se?

    Hello Mattias,
    You should set the property
    <b>ume.ldap.access.creation_path.uacc = ou=internetUsers, ou=companyX, c=se</b>
    Check this for more:
    http://help.sap.com/saphelp_nw2004s/helpdata/en/63/14f5b51a6eff429f2d8b2063400e82/content.htm
    This path is where new user accounts are created.
    This path must be relative to the path defined in
    ume.ldap.access.base_path.uacc
    If this property is not defined, user accounts are stored in the path defined in
    ume.ldap.access.base_path.uacc
    Greeting,
    Praveen Gudapati

  • Updating user table (type document) via api

    hi!
    i need to update an user table that is of type document.
    that table is also used as the client table in an udo.
    i have tried the following code, but that of course doesn't work as the table is not a plain table but is of document type:
      Dim objUserTable As SAPbobsCOM.UserTable
      Set objUserTable = objCom.UserTables.Item("MP_TABLE_LINE")
      If objUserTable.GetByKey(objMatrix.Columns.Item("U_MP_BEnt").Cells.Item(lngRow).Specific.Value) Then
          objUserTable.UserFields.Fields.Item("U_Qty").Value = _
               objUserTable.UserFields.Fields.Item("U_Qty").Value - dblDiff
          If Not objUserTable.Update() <> 0 Then
              Call objApp.SetStatusBarMessage(objCom.GetLastErrorDescription())
              Call objApp.MessageBox(objCom.GetLastErrorDescription())
          Else
              objMatrix.Columns.Item("U_MP_BQty").Cells.Item(lngRow).Specific.String = _
                   objMatrix.Columns.Item("11").Cells.Item(lngRow).Specific.String
          End If
      End If
      Set objUserTable = Nothing
    then i tried to use a dbdatasource which i would expect to work:
      Dim objDataSource As DBDataSource
      Set objDataSource = objForm.DataSources.DBDataSources.Item("@MP_TABLE_LINE")
      Dim objConditions As New SAPbouiCOM.Conditions
      Dim objCond As SAPbouiCOM.Condition
      <just setting up conditions here>
      Call objDataSource.Query(objConditions)
      Call objDataSource.SetValue("U_Qty", 0, objDataSource.GetValue("U_Qty", 0) - dblDiff)
    but this only results in an error code "-7006",  message:
    "Item - The item is not a user defined item"
    how can the update be done?
    regards,
       thomas

    Hi Thomas,
    U are using UserTabel Obejct , just try to Use UserTabelMD object
    i am sending to how to create the User Table,
    Hope it will help to
    oUTb = mobjCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables)
    If Not oUTb.GetByKey("SPH_FORMS") Then
       oUTb.TableName = "SPH_FORMS"
       oUTb.TableDescription = "Activity Forms"
       oUTb.TableType = SAPbobsCOM.BoUTBTableType.bott_MasterData
    If oUTb.Add <> 0 Then
        mobjCompany.GetLastError(lRet, sErrMsg)
    Else
       oUTb = Nothing
    end if
    be carefull before using MD object , bcoz at a time only one MD object should be in memory else it will give to Error
    Thanks
    Ankush Vachher

  • Cannot create AR Invoice negative amount with WithHolding Tax negative amount via DI API

    Hi All,
    I tried to create AR Invoice Document via DI API, but with negative amount and negative withholding tax amount.
    Document added successfully, but when i open the document in SAP, and i open WTax Table information, withholding tax amount become zero,
    Please see image below.
    But when i add the same document through SAP Screen, i can fill WTax Amount with negative amount.
    SAP Version 9.0 PL 5
    Please kindly help,
    Thanks
    Best Regards
    Siddharta

    Hello.
    If this is different to the behavior of the B1 application it should be considered a bug - like any such difference between DI API and app.
    HTH

  • Corrupt Credit Note created via DI API

    Hello,
    when i try to create a credit note via di api i get the error message "one of the base documents has been closed", even if the source document is not closed. But this is not the main problem. After this i have a corrupt credit memo in my system, that means a credit memo with out any detail lines. The error occurs only on one customer systems, on a lot of other systems the creation of credit notes works fine. Had anybody the same effect or clue what causes this problem.
    Regards

    Hello we found the problem, i can reproduce it on a belgium database.
    I want you to inform about a critical error in the SBO_SP_TransactionNotification.
    If you check the line data of a document and send an error for this data the front end works fine. But if you use the DI-API the header data of document will be saved and the lines will be not saved.
    if @object_type in ('14','19') and @transaction_type = 'A'
    begin
    declare @corrCRD as varchar(8)
    if @object_type = '14'
    set @corrCRD = (select distinct(correction) from ovtg where code in (select vatgroup from RIN1 where docentry = @list_of_cols_val_tab_del) and correction = 'N')
    else if @object_type = '19'
    set @corrCRD = (select distinct(correction) from ovtg where code in (select vatgroup from RPC1 where docentry = @list_of_cols_val_tab_del) and correction = 'N')
    if @corrCRD = 'N'
    begin
    set @error = 1
    set @error_message = 'You have entered a regular VAT Code on the document, this is not allowed'
    end
    end

  • Creating User Table, User Field ... with Script SQL in C#

    Hi every body,
    I wonder if we could create a user table, user field ... with script SQL in C#.
    Should I use the reference Microsoft.SqlServer.ScriptTask ??
    Thank you for your Help

    Haifa,
    I am not sure where your question is directed.  The forum that you have posted your question in is for questions related to the SAP Business One SDK.  Are you looking to create new user tables/fields in SAP Business One?  If so you can do this either through the SAP Business One SDK interface using Tools > User Defined Fields and/or Tools > User Defined tables.
    You can also create metadata objects in Business One programatically using the UserTablesMD and/or UserFields objects.
    SAP does not support direct SQL writes to the SAP Business One Db.
    HTH,
    Eddy

  • I need to view data from my user table in my UserForm

    Hi to all,
    I created a user table with fields(id,name,datem,time_from and time_to) and form for this usertable. This form has two edit box for code of employer and name of employer and matrix box with columns (Date,id,name,time_from,time_to). In    columns I want to browse data of user table and I want to add data to this table fromthis form. Is it possible and how can I make it? Im writing in C#.
    Thanks for your answer.
    P.S. Im sorry of my english

    Hello Vit,
    The easier way to do it, is to use the UDO (User Defined Object). You can check the documentation of how to create it using B1 interfase, or you can do ti also via the DI API.
    In the following thread you can check how to do it using the DI API.
    SAP Business One SDK
    There's also a sample delivered when installing the Sap Business One SDK.
    HTH,
    Felipe

  • Error adding new records in an user table

    Hi
    I'm trying to add a new record in an user table, and after calling the add method I get the next error message:
    "Generating this document requieres numbering to be determined for the document".
    I've defined my user table as Master Data, and the source code is as follows:
    dim m_UserTable as SAPbobsCOM.UserTable
    m_UserTable = SboCompany.UserTables.Item(UserTable)
    m_usertable.Code = NewValue
    m_usertable.UserFields.Fields.Item("U_FIELD1").Value = NewValue
    if m_userTable.add() <> 0 then
      SboCompany.GetLastError(lngError, strerror)
      SboApplication.MessageBox(strerror)
    end if
    Thanks and Best Regards
    Dani

    Hi Dani,
    when you create a user Table as "Master Data", this table becomes a part of a UDO (User Data Object) that you have to create too.
    In the version 2004A, you don't have the possibility to enter information in these kind of table using the DI. You can only do it thru the application.
    You can look at a post called "Access to UDO via DI" posted 16th December 2004
    Sebastien

  • How to create many user in the same database

    hi
    my question is "How to create many user in the same database(application)?"
    for example, i have students, teachers, and staffs user using my application.
    i can create many users to use the same application right?, how ^^''' ???
    (right now i can only create application and then it shows every data in my DB
    but i want it to show only the data for the user who login to that application)
    Thanks.
    ps. i'm newbie, please help T^T

    You need to create a user table within your application that maintains their privileges. If you have LDAP you could use this for authorisation otherwise the table would handle that as well (store passwords etc). Your reports etc would then be filtered on information from this table.
    Check out some of the sample applications to see how authorisation and access is implemented (Online store is one). The how-to on the issue tracking system should also have some useful pointers.
    http://download-west.oracle.com/docs/cd/B31036_01/doc/appdev.22/b28839/issue_track.htm#BABBGBJG
    cheers,
    Ron

Maybe you are looking for

  • Issue with MS SQL driver

    Experts! I am trying to add MSSQL driver so that weblogic can support MSSQL JDBC calls. I added the jar file to WL_HOME/server/lib and then added the same to classpath in commEnv.cmd file. Now when I try to create a connection in Data Sources it fail

  • Are fault messages applicable to synchronous messages also?

    Hi Experts,   I have been trying to understand FAULT messages in XI. The blogs I have seen so far discuss FAULT messages in Asynchronous scenarios only. This makes we wonder if it cannot be used for Synchronous RFC scenarios. Can somebody confirm thi

  • Problem with MessageFactory in jaxm

    I tried to creat a soap message. I used following code: MessageFactory mf = MessageFactory.newInstance();         SOAPMessage msg = mf.createMessage();         SOAPPart sp = msg.getSOAPPart();but I got following exception: Unable to create message fa

  • Handle WSDL data connection timeout during PDF generation

         I have created in LiveCycle Designer XDP template. In template i defined WSDL Data connection. For data loading i call xfa.connectionSet.WsDataConnection.execute(0).      For PDF generation i created LiveCylce process and use generatePDFOutput c

  • Not able to open TIFF files

    Photoshop is not able to open few TIFF files and I am not able to understand what's making these files different from the other TIFFs Attached the error box that's popping when trying to open the file in Photoshop. Here is the link of the TIFF file w