cancel
Showing results for 
Search instead for 
Did you mean: 

How can I save a value of a editfield in SQL database

Former Member
0 Kudos

Hi,

I have build a webdynpro with a editview. I want to save the date in to a SQL table. The column in the table has the data type Long. Can someone give me a sample how to convert the text of the editview in to a Long data type.

Kind regards,

Richard

Accepted Solutions (0)

Answers (6)

Answers (6)

Former Member
0 Kudos

Hi Gregor,

Thanks for your support. Can you give me a good sample, I'm not a very experience java developer.

In my table I copied de column description form KCM_WF_WFTask. do I need to do more with my own Table? .

I trying to use your information into my source, but I have not figure out how!

Kind Regards,

Richard

former_member184385
Active Participant
0 Kudos

Hi Richard,

now I got you!

Having a db table like

CREATE TABLE "TMP_MEETING" (

..

"PROTOCOL" LONG BYTE ,

.. )

you would insert a row to it, having the long column protocol as follow

...

Meeting meeting; // getProtocol() returns a string!

PreparedStatement ps = // ps poiting to your "insert into tmp_meeting( protocol, ...) values ( ?, ..)

ps.setBytes( 1, meeting.getProtocol().toBytes() )

...

Regards

Gregor

Ps. Sorry for the misunderstanding in the first place.

Former Member
0 Kudos

Hi Gregor,

No they are no numbers, It is text in a editView, like a description of a task or note from a meeting. The text can be more than 1000 characters, so a can not save them in String DataType. SAP uses also the Long DataType to store the Description of task in a Long DataType. I do not know how to convert this.

Kind Regards,

Richard

former_member184385
Active Participant
0 Kudos

Richard,

your input is not exactly a number, is it?

You have the option to define a calculated value attribute of type long and reference in the getter/setter to your original text model attribute.

Base your edit field on the new attriute. WD will then take care of the validation and prevent passing "sdsd" or whatever as long to your model ...

Regards

Gregor

Former Member
0 Kudos

Hi Gregor,

I tried your statement, but I get the following Error:

com.sap.tc.webdynpro.services.exceptions.WDRuntimeException: For input string: "ddffadsfddfsasd

df

adsf

asdf

"

Do you know how to solve this.

Kind Regards,

Richard

former_member184385
Active Participant
0 Kudos

Hi Richard,

this will do the trick:

String yourEditFieldtext = wdContext.current<YourContextNode>Element().get<YourEditField>()

Long yourEditFieldLong = Long.parseLong( yourEditFieldtext );

Regards

Gregor