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

Problem with data type 'STRING'

Former Member
0 Likes
3,289

Hi All,

I have created a table named as zproject_mat and there is a field 'LONG_D' for long description and its size is not limited, so i used 'STRING' data type for this field. But the problem is: when i use this field in where condition with 'SELECT QUERY' in my abap program , it throws me an error..'The field long_d is a long string , so it cannot be used in WHERE, ON, or having conditions'.

Can anyone help me regarding this. I dont know which data type will be suitable in both conditions, LONG DESC AND SELECT QUERY.

Regards

Rahul

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,682

HI,

REPORT ztest_94test.

DATA :it_itab TYPE STANDARD TABLE OF Ztable,

wa TYPE Ztable.

*Ztable will have a string field.

SELECT * FROM Ztable INTO TABLE it_itab.

LOOP AT it_itab into wa WHERE z_long = 'string'.

ENDLOOP.

Hope this will be helpful.

Regards

Aravind.

5 REPLIES 5
Read only

former_member222709
Contributor
0 Likes
1,682

Hi Rahul,

If a variable with 220 characters can suffice your requirement, then, you can use the Data Element 'BAPI_MSG'. A select query can be made against such a variable using WHERE condition.

Conversely, if you still need to have a select query, you will have to define the length of your variable by creating a ZDATA_ELEMENT with length as 1024 and then use the same in your table and Select query.

Regards,

Pranav.

Read only

0 Likes
1,682

Hi Pranav,

I am not getting. Can yo please explain it. Which data type should i use if i want to give its length around 1500.

Can you please answer me with helpful answer.

Regards,

Rahul

Read only

Former Member
0 Likes
1,683

HI,

REPORT ztest_94test.

DATA :it_itab TYPE STANDARD TABLE OF Ztable,

wa TYPE Ztable.

*Ztable will have a string field.

SELECT * FROM Ztable INTO TABLE it_itab.

LOOP AT it_itab into wa WHERE z_long = 'string'.

ENDLOOP.

Hope this will be helpful.

Regards

Aravind.

Read only

0 Likes
1,682

Hi Aravind,

I am using this query with 'LIKE'.

CONCATENATE '%' MATERIAL_CODE '%' INTO LV_3.

CONCATENATE '%' SHORT_DES '%' INTO LV_4.

CONCATENATE '%' LONG_DES '%' INTO LV_5.

CONCATENATE '%' PLANT '%' INTO LV_6.

SELECT *

FROM ZPROJ_MATERIAL

INTO TABLE IT_MATERIAL

WHERE MATNR LIKE LV_3

AND SHORT_D LIKE LV_4

AND LONG_D LIKE LV_5 'Problem in this field.'

AND PLANT LIKE LV_6.

So how do i write 'where' condition in Loop with 'LIKE'.

Regards,

Rahul

Read only

former_member222709
Contributor
0 Likes
1,682

Hi Rahul,

As mentioned your Table name is 'zproject_mat' and there is a field 'LONG_D'.

The field 'LONG_D' will have a Data Element associated with it. Create a new input Data Element & Domain 'ZLONG' of Type CHAR with Length = 1100. This will used in the code.

For the Table 'zproject_mat', you need to need to break up your field as 'LONG_D1', 'LONG_D2', ........, 'LONG_D5' with Data Element as 'BAPI_MSG'.

To INSERT data in table:

In your code, you need to write your logic where the field 'LONG_D' is SPLIT into 5 words and saved in your table against the 5 fields.

To SELECT data from table:

In your code, again you need to write your logic where the field 'LONG_D' is SPLIT into 5 words as abaove and pass them to your SELECT query...

SELECT SINGLE *
FROM zproject_mat
INTO wa_zproject_mat
WHERE long_d1 = v_split1
      AND long_d2 = v_split2........
     AND long_d3 = v_split3.
 

The limitation of a table length is 4096 whereas of a field is 255 to make it RFC compatible. Table/Structure fields that are passed via RFC for integration have this limitation and to maintain database standards, these limitations exist.

Hope this helps.

Regards,

Pranav.