cancel
Showing results for 
Search instead for 
Did you mean: 

Inserting data into document type tables

Former Member
0 Kudos

Hi All,

Is there any way to insert records in document and document line type user defined tables other than using recordset (insert SQL )? the columns of these tables are bound to my user form's matrix columns and other edit text fields.

thanks in advance,

Regards,

Binita

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi David,

I have followed all the steps given by you (much before) and this is what I face. have gone thru number of threads on this but, cud not find much so posting back.

1) created two tables with type document and document rows resp.

2) created UDO out of them

3) generted form with B1DE UDO form generator

4) have 'add' and 'cancel' button on the form thru screen painter

have three columns namely itemcode, UOM and Quantity in detail table.

now, when I add row to this matrix which is bound to lines UDT, and copy or type data in the column, and click 'add' , it adds the data perfectly in each column, generates the docentry and docnum as u said, without my writing any code.

problem arises when I load the matrix with datasource. this is how my code looks like:

 Form = sbo_Application.Forms.Item("UDO_MASTER_")
                Matrix = Form.Items.Item("mt").Specific
                Matrix.AddRow()

                Form.DataSources.DataTables.Add("DBDS")
                strquery = "select rowc,it,uom,qty from ....."
                Form.DataSources.DataTables.Item("DBDS").ExecuteQuery(strquery)
                Matrix.Columns.Item("col_f").DataBind.Bind("DBDS", "rowc")
                Matrix.Columns.Item("col_0").DataBind.Bind("DBDS", "it")
                Matrix.Columns.Item("col_1").DataBind.Bind("DBDS", "uom")
                Matrix.Columns.Item("col_2").DataBind.Bind("DBDS", "qty")
                Matrix.LoadFromDataSource() 

even my first column '#' is bound to LineId of detail table. on 'Add' click, it does create the rows in data base table equal to the number of records in matrix but the user defined columns remain null.

please help me out on what cud be missing

thanks and regards,

Binita Joshi

Edited by: Binita Joshi on May 19, 2008 1:15 PM

Also, I tried again binding the matrix columns with the columns of UDT after I do LoadFromDataSource() on matrix but, with no luck.

Nussi
Active Contributor
0 Kudos

Hi Binita,

because you said this in the other thread:

iam still here sorry for the late answer.

ok, now back to topic:

in my opionion you're doing it wrong.

the reason - you use a query and you use loadfromdatasource.

i'll show you vb6 sample how i bind the document_lines object.


    Set oItem = oForm.Items("mtxList1")
    Set oMatrix = oItem.Specific
    oMatrix.SelectionMode = ms_None
    
    Set oColumns = oMatrix.Columns
    oColumns("LineId").DataBind.SetBound True, "@B1C_PRJ1", "LineId" 'First Column
    oColumns("ColStueck").DataBind.SetBound True, "@B1C_PRJ1", "U_Stueck"
    oColumns("ColEinheit").DataBind.SetBound True, "@B1C_PRJ1", "U_Einheit"

that's it, no datatable necessary, but it is important you registered your object correctly

regards

David

Former Member
0 Kudos

Hi David,

relieved to find u still here.

I do need datatable as I mentioned in my previous thread, because I am loading the matrix with the output of a complex query.

But, As U suggested, the problem must have been with my registering the UDO. I recreated the UDO and tables too. Now, its working. thanks.

regards,

Binita

Nussi
Active Contributor
0 Kudos

Binita,

great that recreating helped !

i forgot that you need the query, iam answering too many threads )

we'll see again

regards

David

Answers (8)

Answers (8)

Former Member
0 Kudos

thts a good news. but, do we have to generate docentry on our own (by fetching max(docentry) from master table and adding one ) or the object takes care of generating or replacing the docentries when they are colliding?

regards,

BInita

Nussi
Active Contributor
0 Kudos

the docentry is generated from sap

i'll do it always so

i have a disabled edittext field where you see the docentry - i bind it to a edit text:

oEditText.DataBind.SetBound True, "@B1C_TEST", "DocEntry"

in the end i say that i want to browse this field

oForm.DataBrowser.BrowseBy = "txtDocE"

thats it - you should face no problems

regards

David

Former Member
0 Kudos

Dear Binita,

No not at all.

If you use master and Masterlines then only for code field you have to assign.

But if you use documents and documents and documnetlines then dont worry SAP will take care of it....

The above thing wil happen if you use UDO.

Regards

Sanjay

Former Member
0 Kudos

Hi David,

I m not worried about the status bar message. I know, its a system behaviour tht doesn't happen for user forms. but, all I want to know is , are concurrent entries supported in database tables without loosing the data integrity when more than one users are inserting data at the same time? I have never used UDO bound forms. I m using standard SQL DML statments to insert the data and so, I have to manually lock the tables when one user is modifying it. otherwise, there is a complete mess-up with the generated doc numbers and data saved against it.

and thanks for trying .

regards,

Bintia

Nussi
Active Contributor
0 Kudos

Binita,

when 2 persons add a document (udo) at the same problem you have no problem -

at least i never had one. for udo only the docentry is relevant.

regards

David

Former Member
0 Kudos

Hi David.

m little late in replying. I wanted to know, by attaching a form with UDOs of type document and document rows, does the insertion work the same way as it does in standard forms? for example, when more than one users are adding the data in sales order form simultaneously, a status bar message is displayed stating that, "your document has been saved with so..ans so.. number". and there is no ambiguity. is the scenario same with using UDOs bound forms? I had raised this query to SAP support and I was replied that with the current release, DI API objects for document type tables are not exposed. and so transactions can not take place the standard way it happens for standard SAP forms and objects.

(Hope my question is clear.)

regards,

Binita

Nussi
Active Contributor
0 Kudos

Hi Binita,

i'll try it - i understand what you wanna - you want to know the real number that was added.

i try it

regards

David

Nussi
Active Contributor
0 Kudos

ok Binita,

there's no StatusBar Message for the "creation".

Make a hidden timestamp field in your udo - than it works

regards

David

Former Member
0 Kudos

If you are using screen painter to design the form , enter the UDO code in the object Type property of the form.

I hope it may work...

Former Member
0 Kudos

HI David,

Thanks for replying.

One last question. u said , for UDO forms, u don't need to write any code. system saves the data on its own. by UDO forms, wht do u mean to imply? are these forms which are created thru some B1DE tools, like User-Defined Objects Form Generator?

thanks and regards,

Binita

Nussi
Active Contributor
0 Kudos

Binita,

my steps are:

1. create a user table with type document.

2. create a userdefined object. (Wizard in SBO or via DIAPI)

3. create a form in screen painter

4. use the code which i posted

thats it

iam not developing with B1DE

regards

David

Former Member
0 Kudos

Hi David,

Many thanks for replying. I just want to confirm what I m doing is technically the same as what you have sent. I am creating a form using screen painter. I create the controls and bind them with the columns of user defined tables of type document and document rows(with the matrix).I change the extention of this .srf file to .xml and load it through standard LoadFromXml function. The browse by key works in the update mode. but, in add mode, when I click 'Add' button (with unique ID '1' in screen painter), the data do not get added to the bound table automatically.I have to catch the click event of add button and write the code for insertion through recordset doquery method. does the code sent by you precisely do the same thing? or Is it different? and also let me know if I can insert/update the data in UDTs of document type any other way which is more efficient than this.

Thanks for all the efforts in advance :)....

regards,

Binita

Nussi
Active Contributor
0 Kudos

hi Binita,

well - when i use a udo form i don't need to save the data.

also for the matrix - the only thing i do is to use flushtodatasource.

when the user presses add sap adds the content - iam not saving the data.

regards

David

Former Member
0 Kudos

Hi David,

Thanks for replying. the question may sound trivial but, will you please let me know how can I bind the UDOs with the form, after I have registered them?

regards,

Binita

Nussi
Active Contributor
0 Kudos

ok Binita,

i post a sample here


Set creationPackage = oSBO.appl.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_FormCreationParams)

creationPackage.UniqueID = "B1C_CRYM"
creationPackage.ObjectType = "B1C_CRYM"
creationPackage.FormType = 20009004 '"MyFormType"
'creationPackage.BorderStyle = SAPbouiCOM.BoFormBorderStyle.fbs_Fixed
    
Set oXMLDoc1 = New MSXML2.DOMDocument

'// load the content of the XML File
oXMLDoc1.Load (FileName)

creationPackage.XmlData = oXMLDoc1.xml     '// You can load the form with XML
    
'// Add the form to the SBO application
Set frm = oSBO.appl.Forms.AddEx(creationPackage)
                
frm.Items("DocEntry").Specific.DataBind.SetBound True, "@B1C_CRYM", "DocEntry"
frm.Items("txtName").Specific.DataBind.SetBound True, "@B1C_CRYM", "U_Name"
            
frm.DataBrowser.BrowseBy = "DocEntry"

this should help you

lg

David

Nussi
Active Contributor
0 Kudos

Hi Binita,

in your situation i recommend you to register the tables as UDO and bind your user form to it.

regards

David