‎2007 Jun 18 11:13 AM
Hi all,
i have creted a ztable and in that for one field the length is to be more than 300 chars.
so i am using the data type directly as STRING. i tried to check the table but i am getting warning as 'data type string not allowed in DB tables'.
plz help what to do.
regards,
siri.
‎2007 Jun 18 11:17 AM
Hi,
you can use the data element DSTRING for your table.
Kostas
‎2007 Jun 18 11:17 AM
Hi
Use the datat Type
LCHR
LRAW
for more number of CHAR fields like 500 and 1000
see the EDID4-SDATA field as an example
We can declare in a program as STRING
but in tables it gives error.
so better use the above data types
Reward points for useful Answers
Regards
Anji
‎2007 Jun 18 11:17 AM
Hi,
you can use the data element DSTRING for your table.
Kostas
‎2007 Jun 18 11:39 AM
Thanks Anji and Kostas,
ACTUALLY THE MAIN PROBLEM THE LENGTH THAT THE FIELD IS GOING TO TAKE IS LESS THAN 256 AND SOME TIMES MORE THAN 256.
which is better DSTRING or lraw.
regards,
siri.
Message was edited by:
sireesha yalamanchili
‎2007 Jun 18 11:55 AM
If your field is not going to be bigger than 1000 characters it won't be a problem whatever field you choose. If your field is bigger than 1000 character you have to use dstring.I have worked with type dstring and it is very useful to store big info( i had used it for storing text history ) but it will be a little problem if you want to display it in an alv or something. You choose.
Kostas
‎2007 Jun 18 12:09 PM
Kostas,
But when i use DSTRING as field type i am getting message data element DSTRING not available?
regards,
siri.
‎2007 Jun 18 12:18 PM
Siri,
I work on 4.7 and i can use dstring as data element without problems.Which version do you work on?
Kostas
‎2007 Jun 18 12:54 PM
‎2007 Jun 18 1:00 PM
I don't know if it is going to work in 4.6 but give it a try. Create a z data element and in the domain enter string. If this won't work in 4.6 maybe you should consider the solutions mentioned from the other people.
Kostas
‎2007 Jun 18 11:18 AM
Hi,
SAP wont allow declare field of string in the DB table and you can use char length of 300 CHAR300 instead of the same
Regards
Shiva
‎2007 Jun 18 11:20 AM
Hi,
Here is the sample code to store the xml file into ABAP DB table.
First create a table called YTEST_BIN with following fileds.
Filed Nmae Data Elemen type
MANDT MANDT CLNT
DESCRIPTION HTTPBODY RAWSTRING
Now create a program to read the XML file from your desktop and load it into the table.
Below given is the code for loading the table.
REPORT y_store_xml.
DATA: wf_filetab TYPE filetable .
DATA: wf_filerc TYPE i ,
wf_filename TYPE string ,
wf_path TYPE string ,
wf_full_path TYPE string ,
wf_file_length TYPE i .
DATA: wf_extension TYPE string ,
wf_fname TYPE string .
DATA: BEGIN OF int_tab1 OCCURS 0,
int_txt(1000) TYPE x ,
END OF int_tab1.
DATA: upd_tab TYPE STANDARD TABLE OF ytest_bin .
DATA: wa_upd_tab LIKE LINE OF upd_tab .
DATA: temp_xstring TYPE xstring .
PARAMETERS: p_file LIKE file_table-filename LOWER CASE VISIBLE LENGTH 80 .
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file .
PERFORM browse_file CHANGING p_file .
AT SELECTION-SCREEN ON p_file .
IF p_file IS INITIAL .
MESSAGE e398(00) WITH
'Enter Filename and path' .
ENDIF.
START-OF-SELECTION .
CLEAR wf_filename .
MOVE: p_file TO wf_filename .
PERFORM load_file USING wf_filename .
PERFORM save_file_contents .
&----
*& Form browse_file
&----
text
----
<--P_P_FILE text
----
FORM browse_file CHANGING p_p_file.
CLEAR wf_filename .
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
window_title = 'Select the File'
DEFAULT_EXTENSION = cl_gui_frontend_services=>FILETYPE_TEXT
DEFAULT_FILENAME =
FILE_FILTER = cl_gui_frontend_services=>FILETYPE_EXCEL
INITIAL_DIRECTORY =
MULTISELECTION =
CHANGING
file_table = wf_filetab
rc = wf_filerc
USER_ACTION =
EXCEPTIONS
file_open_dialog_failed = 1
cntl_error = 2
error_no_gui = 3
not_supported_by_gui = 4
OTHERS = 5
.
IF sy-subrc <> 0.
MESSAGE e398(00) WITH 'Error Opening File' .
ELSE .
READ TABLE wf_filetab INDEX 1 INTO p_file .
ENDIF.
ENDFORM. " browse_file
&----
*& Form load_file
&----
text
----
-->P_WF_FILENAME text
----
FORM load_file USING p_wf_filename.
CLEAR int_tab1 .
REFRESH int_tab1 .
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = p_wf_filename
filetype = 'BIN'
IMPORTING
filelength = wf_file_length
HEADER =
TABLES
data_tab = int_tab1
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17
.
IF sy-subrc <> 0.
MESSAGE e398(00) WITH 'File may be open - Error loading' .
ENDIF.
ENDFORM. " load_file
&----
*& Form save_file_contents
&----
text
----
--> p1 text
<-- p2 text
----
FORM save_file_contents .
CLEAR :wa_upd_tab , temp_xstring .
LOOP AT int_tab1 .
CONCATENATE temp_xstring int_tab1-int_txt INTO temp_xstring IN BYTE MODE.
ENDLOOP .
IF NOT temp_xstring IS INITIAL .
optional
TRY.
CALL METHOD cl_abap_gzip=>compress_binary
EXPORTING
raw_in = temp_xstring
IMPORTING
gzip_out = wa_upd_tab-description.
CATCH cx_parameter_invalid_range .
CATCH cx_sy_buffer_overflow .
CATCH cx_sy_compression_error .
ENDTRY.
APPEND wa_upd_tab TO upd_tab .
ENDIF .
IF NOT upd_tab IS INITIAL .
MODIFY ytest_bin FROM TABLE upd_tab .
IF sy-subrc EQ 0 .
MESSAGE i398(00) WITH wf_filename ` Saved!`.
ENDIF .
ENDIF.
ENDFORM. " save_file_contents
<b>Reward points</b>
Regards
‎2007 Jun 18 11:35 AM
Hi,
the dictionary type STRING can only be used in DATAELEMENT, STRUCTURE and DOMAIN. ABAP doesn't support to allowing STRING data type directly to the table fields.
Character string with variable length This data type can only be used in types (data elements, structures, table types) and domains. In the Dictionary a length can be specified for this type (at least 256 characters). It may be used in database tables, however, only with restrictions. For a description of them refer to the documentation of the ABAP statement 'STRING'
regards,
Ashokreddy.