cancel
Showing results for 
Search instead for 
Did you mean: 

How to use Copy From/Copy To function to UDO

Former Member
0 Kudos

Hi all,

Is it possible to use copy to or copy from function in UDO?

my situation is, I have 2 UDOs, and both structure are very similar (header and rows tables). just like Sales Quotation and Sales Order. and i want a function to copy an object data, based on a primary key from UDO1 into UDO2 (or the other way around). Is there any way to do that? Please help. this is my first addon.

Thanks in advance,

Azif

Accepted Solutions (0)

Answers (1)

Answers (1)

Trinidad
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Azif,

There is no object representing a UDO in the SDK DI or UI API and writing into UDO tables is not allowed.

The only way to save UDO information is through the UI API by opening the corresponding form and filling the information directly in the form.

You could do something similar of what B1 does by opening the UDO form when the Copy from button is pressed, then filling the information in the form with UI API. The user only has to press the Add button at the end of you can also do it with the UI API.

Hope it helps

Trinidad.

Former Member
0 Kudos

I'm thinking to do that actually, maybe my way of explaining was a bit unclear. how to use function like Copy From button in SAP B1?

i tried :

- getting the primary key from CFL

- and do query to retrieve all the data, and populate into edittexts, matrix etc.

somehow i got an error "cant get focus" when entering the value in second edittext. thats why i want to know how B1 do it.

Thanks

Trinidad
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi,

Maybe you can share the code were you have the problem, this way we will better understand what can be the reason.

Regards

Trinidad.

Former Member
0 Kudos

Here's the code:

Private Sub ChooseFromList(ByVal FormUID As String, ByRef pVal As SAPbouiCOM.ItemEvent)
        Dim oEdit As SAPbouiCOM.EditText
        Dim oForm As SAPbouiCOM.Form
        Dim oCFLEvento As SAPbouiCOM.IChooseFromListEvent
        Dim sCFL_ID As String
        Dim oCFL As SAPbouiCOM.ChooseFromList
        Dim oDataTable As SAPbouiCOM.DataTable
        Dim val_CFL As String

        oForm = SBO_Application.Forms.Item(FormUID)
        oCFLEvento = pVal
        sCFL_ID = oCFLEvento.ChooseFromListUID
        oCFL = oForm.ChooseFromLists.Item(sCFL_ID)
        oDataTable = oCFLEvento.SelectedObjects

        Try
            val_CFL = oDataTable.GetValue("Code", 0) ' Get Code

            ' Query
            oRecSet = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
            oRecSet.DoQuery("SELECT * FROM [@PACH] WHERE Code = '" & val_CFL & "'")
            oRecSet.MoveFirst()

            ' Input into fields
            oEdit = SBO_Application.Forms.Item(FormUID).Items.Item("txtCode").Specific
            oEdit.Value = oRecSet.Fields.Item(0).Value

            oEdit = SBO_Application.Forms.Item(FormUID).Items.Item("txtName").Specific
            oEdit.Value = oRecSet.Fields.Item(1).Value
        Catch ex As Exception
            SBO_Application.MessageBox(ex.Message)
        End Try
End Sub

This function is called when Choose from list triggered (pressing the tab button in txtCode edittext.

the CFL window opened, I clicked/choose one record and

I got this error for 2nd edittext (txtName):

Item - Can't set value on item because the item can't get focus [66000-153]

Thanks.

Azif

Trinidad
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Azif,

I think the problem happens because of beeing inside the ChooseFromList event.

I suppose if you do the same thing inside another event type (you can test for example to do the same action but after pressing a button in the form) it works...

Please open a message to support asking for it. They will let you know if it is something like that by design or if they plan to fix it.

Regards

Trinidad.

Former Member
0 Kudos

Hi Trinidad,

Actually I already tried using button. when i was trying to put a value into edittext after formload event, i got error "....not instance of an object" (forgot all the error string). so i use a button instead and it worked.

I was asking this question because in SAP B1 can do it, so i thought there wont be any problem, if we know how to do it.

To solve this problem, i am trying to get primary key value from previous form an put into new form.

Thanks

Message was edited by:

Mohd Azif Syazwan Mohamad Sanusi

Former Member
0 Kudos

Hello Mohd Azif Syazwan Mohamad Sanusi ,

I've also done the same thing i.e. copy all data from one UDO to another.And

I'm having the same problem.

Item - Can't set value on item because the item can't get focus 66000-153

I've tried a lot but failed.

Have u solved the problem.

How?

Plz. inform me at subratac@wdc.in

Rgds

Subrata