Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to store string in db table?

alejiandro_sensejl
Active Participant
0 Likes
3,489

Hello gurus,

how can I store a string field (user input) in a database table (r 4.6c)?

Thanks in advance,

Alej!

PS: * Points will be rewarded * !

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,739

Hi Alej,

Just remember the maximum length a single field in a DB table can be defined to is 255, hence you will have to guess the maximum length the user can enter and create those many number of fields of length 255 in your DB table and then break up the data when updating in DB from string and reverse, build back the string when retrieving from DB.

Regards,

Aditya

Hello gurus,

how can I store a string field (user input) in a database table (r 4.6c)?

Thanks in advance,

Alej!

PS: * Points will be rewarded * !

5 REPLIES 5
Read only

divya_nayudu
Participant
0 Likes
1,739

you can create data element with char type and define its length (equivalent to max. length ur string can hold).

Read only

Former Member
0 Likes
1,739

Hi,

you can do this way,

just create the table field with string,so that you can use it

to have string values in it.

DATA: text_buffer TYPE string VALUE `Text`,

value assigns it a default value to it ,in the above statement

it gives TEXT to text_buffer string.

plz reward if helpful,

regards,

srikanth tulasi.

Edited by: srikanth tulasi on Jan 15, 2008 10:14 AM

Read only

Former Member
0 Likes
1,740

Hi Alej,

Just remember the maximum length a single field in a DB table can be defined to is 255, hence you will have to guess the maximum length the user can enter and create those many number of fields of length 255 in your DB table and then break up the data when updating in DB from string and reverse, build back the string when retrieving from DB.

Regards,

Aditya

Read only

0 Likes
1,739

Thanks Aditya,

that's how I've done it in the end!

Read only

Former Member
0 Likes
1,739

Hi,

Kindly refer the sample program for the same.

Here yff_test is a table with three fields fname (char15), lname (char15) and year (char4).

Sample code:

REPORT ynrd_test_text_move.

TABLES yff_test.

PARAMETER: p_name TYPE char15.

START-OF-SELECTION.

UPDATE yff_test SET lname = p_name.

This program would set the last name to the string entered on the screen by user.

The direct updation of tables is not recommeded. We need to update tables via BAPI or FM.

Pls Reward if useful.

Regards,

Farheen.