cancel
Showing results for 
Search instead for 
Did you mean: 

Inserting data into table using Business object

Former Member
0 Kudos

Hi,

I have a list tile, in which records are being populated properly. On this tile I have a button. When I click this button, these records have to be inserted into some other table (for making history table).

for this, I have created one Business object of history table (for inserting the records into the table). I have added code on "mcore_BeforeSave" event.

> anchorofHistoryTable.bo.setattribute("column1",value1)

> anchorofHistoryTable.bo.setattribute("column2",value2) ...

> anchorofHistory.bo.save()

But when I debug, I am getting "NullReference Exception"..

Is this a right way? Please help me out

thanks

Mateen

Accepted Solutions (1)

Accepted Solutions (1)

santosh_v
Active Participant
0 Kudos

Hi Mateen,

The "NullReference Exception" could be because of the fact that anchorofHistoryTable.bo is null. Since your main anchor is something else and you are creating the new objects there using the application. You can try doing a ISNULL check for anchorofHistoryTable.bo in mcore_BeforeSave and if ti is null, create a BO and assign it to the anchor and you can proceed with the existing code.

Thanks and Regards,

Santo.

Answers (2)

Answers (2)

former_member583013
Active Contributor
0 Kudos

Hi Mohammed,

I guess following is your requirement

List1 tile is attached to "BOList1". On button press you wanted the data to be persisted to Business object "BOList1History"

I assume that you have created "BOLIst1History" properly by associating a write Bdoc etc etc.

Write a method in Business object "BOList" called ZUpdateHistory. This new method should contain code for creating an instance of "BOLIST1History" and fill the property values as per your requirement. Call this method from the Button press event as follows

anchor.bo.ZUpdateHistory

Hope this helps

Regards

Ganesh Datta

Former Member
0 Kudos

Hi Mohammed,

Hav you created a write SBdoc for the table.

If not, then you have to create write sbdoc for the table

Using sbdoc create a Business Object

Use the Business Object to create the User Interface to get values (if not the on click event first get all the data in the Business Object attributes)

and fire .save event on Business Object to button click and you work is done.

All the required data would move to table.

Best Regards,

Pratik Patel

<b>Reward with Points!</b>