cancel
Showing results for 
Search instead for 
Did you mean: 

Losing data in fields after a validation

Former Member
0 Kudos

Hi !!

When i update a qty field in my udo i do a validation with a balance field so it dosent go below 0.000 .

CalRslt = (CalQty - (CalCdn + CalUs + CalAdj + CalFin))
            

            If CalRslt < 0 Then
                SBO_Application.StatusBar.SetText("Adjustment Quantity is Higher then Balance", SAPbouiCOM.BoMessageTime.bmt_Medium, SAPbouiCOM.BoStatusBarMessageType.smt_Error)
                f.Items.Item("34").Specific.String = 0
                CalRslt = 0
                f.ActiveItem = "34"
                
            End If

The problem is that after the message in the status bar i lose my values in my fields and even if i retype my data it dosent stay, if i leave the fields it returns blank ????

What should i do ??

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

former_member184566
Active Contributor
0 Kudos

Hi Alain

The reason it does this is because you have no datasource. You must link a datasource to the edit box.

Here is a sample

Dim oEdit As SAPbouiCOM.EditText

oForm.DataSources.UserDataSources.Add("BPC", SAPbouiCOM.BoDataType.dt_SHORT_TEXT, 100)

oEdit = oForm.Items.Item("BPCode").Specific

oEdit.DataBind.SetBound(True, "", "BPC")

Hope this helps

former_member184566
Active Contributor
0 Kudos

By the way, a datasource is like a container. You get two types of datasources in 2004.

Userdatasource : This is the one i'm using in my example, it basicaly holds the data of the item it's linked to.

DBdatasource: This is also a datasource that links directly to the table, use it load matrixes instantly.

Then in 2005 they have made a new called datagrid which is used with grids.

Hope this helps

Former Member
0 Kudos

Hi Louis !!!

That goes even if i'm using UDO ? I'm a little confused. I use the same way in another form in this addon for calculated fields and it keeps the data ... could it be because of my error message ? or maybe should i re freeze the form ??

Anyway , i will go with your answer and try it out !

Thanks again for your time !

Alain

former_member184566
Active Contributor
0 Kudos

Hi Alain

Sorry, i didn't read it properly. For the udo you must do it the same way as you have been doing it for your UDO. But if it is not retaining the data the table and field you said in the screen painter is most proberly not correct. (You are setting them in the screen painter??) When your form loads does it give an error??? Use try block to catch any possible errors.

Hope this helps

Former Member
0 Kudos

By the way CONGRATULATIONS LOUIS !!!! for your 1000 points in the forum !!!

For my problem if i enter the data without forcing an error it keeps the data and updates my fields in my table . It goes funny if it goes through my error check and prints the message in the status bar...

Bravo again for your points !!!

Alain

Former Member
0 Kudos

Hi Alain,

Maybe it is because you set the value directly to the edit text box. You should try to set the value on the dbdatasource rather than the edit text box.

oForm.DataSources.DBDataSources.Item("UDOTABLE").SetValue("MYFIELD", 0, 0)

Hope it helps,

Adele

former_member184566
Active Contributor
0 Kudos

Hi Alain

Thanks, took a while but i got to a 1000.

The code at the top you set it back to zero....is that not what you want. Another thing that could be the problem is. If you have the cursor in the edit box, then minimize and then maximize SBO, you'll see the contents of that edit box will be in blue and if you type it gets lost.....but this on the error message is very unlikely. But from experience i've found it more reliable to add the data through the datasource then do a oform.update so it refreshes the contents on the form.

Hope this helps

former_member184566
Active Contributor
0 Kudos

I see adele has beaten me by a millisecond. Yes, just like that.

Answers (0)