cancel
Showing results for 
Search instead for 
Did you mean: 

Write invisible data to DB

Former Member
0 Kudos

Hello Forum,

I'm extending the service contract form. Behind the form my addin calculates some values. Now I want to save this values to DB. I have also extended the OCTM (table for the service contract) with some user defined columns. Currently I'm creating invisible Textboxes on the form and by saving the calculated values to the textbox.value property I can write them to db.

Is there a easier way? I could create a B1-independent table and write directly into it. But then I will have to rewrite lots of code.

Thanks

Mark

Accepted Solutions (1)

Accepted Solutions (1)

former_member185682
Active Contributor
0 Kudos

Hi Mark,

Do you want save your hide Textboxes values in user fields in OCTM table?

Regards,

Diego

former_member185682
Active Contributor
0 Kudos

Mark,

If I understand correctly your need, you can try something like this:

Catch the FormDataEvent when beforeAction is true, the eventType equals (et_FORM_DATA_ADD or et_FORM_DATA_UPDATE) and BusinessObjectInfo.Type equals service contract.

Then:

Catch the dbdatasource:  DBDataSource db = this.Form.DataSources.DBDataSources.Item("OCTM");

set the values in specific fields with : db.SetValue("yourField", 0, "yourValue");

then set BubleEvent = true;

Hope it helps.

Regards,

Diego

Former Member
0 Kudos

Oh, I made a mistake: The Service contract table is OCTR.

To answer the question: No.

I want to write calculated values to the OCTR table. The current workaround is to create hidden textboxes on the form, write the calculated values into the textbox and the textbox writes them to the OCTR table because the textbox is databound to my user defined columns in the OCTR table

EDIT: I will try the hint in your second posting.

pedro_magueija
Active Contributor
0 Kudos

Hi Mark,

You're not allowed to write to DBDataSources on system forms. Your current workaround is actually a good solution. Is there something wrong?


Best regards,

Pedro Magueija


View Pedro Magueija's profile on LinkedIn

former_member185682
Active Contributor
0 Kudos

Sorry Mark,

are correct.

You just read DBDataSources on system forms.

Thanks, Pedro.

Regards,

Diego

Former Member
0 Kudos

The error message is: "The item is not user defined item"

So I have to stick to this textbox workaround or use separate tables for storing my data

Former Member
0 Kudos

If I put my data in a user defined table and save there additional an ID that points to OCTR, then how can I write data to it? Is it allowed to use SQL Insert/Update Statements?

pedro_magueija
Active Contributor
0 Kudos

Hi Mark,

UDTs are under your control. SAP usually doesn't give you trouble (support wise) when using SQL with UDTs. However the official position is: no SQL.

But to add/update you have the UserTable object that allows you to do that with the SDK (SAP compliant way) and is less trouble (no changing of SQL statements if going to HANA).


Best regards,

Pedro Magueija


View Pedro Magueija's profile on LinkedIn

Former Member
0 Kudos

Thanks for the reply

I have found some example for UserTable implementations. I will try to get it running.

Answers (0)