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

select statement - Where Condition not possible

Former Member
0 Likes
2,490

Hi,

I am trying to extract data from sap standard table CFX_COL.I want extract based on a field which is of type string.I can see that in the table but when I code below I am getting error.Any other alterantives?

REPORT x.

TABLES:proj.


DATA: it_proj TYPE STANDARD TABLE OF proj.
DATA:wa_proj TYPE  proj.



DATA: it_cfol TYPE STANDARD TABLE OF CFX_COL.
DATA:wa_cfol TYPE  CFX_COL.

data:v_name type STRING.


PARAMETERS: p_pspid LIKE proj-pspid.


SELECT * FROM proj INTO CORRESPONDING FIELDS OF TABLE it_proj
WHERE pspid = p_pspid.


READ TABLE it_proj INTO wa_proj INDEX 1.

concatenate wa_proj-pspid '-' wa_proj-post1 into v_name.

select * from CFX_COL into CORRESPONDING FIELDS OF TABLE it_cfol
where name in v_name.

Error:The Field "NAME" is a long string , so it cannot be used in WHERE, ON or HAVING conditions.

Rgds

Vara

1 ACCEPTED SOLUTION
Read only

apoorva_singh
Active Participant
0 Likes
1,327

Hi Vara.

Select will not work if you are trying to search based on the name field as in the table CFX_COL it has data type String which basically is not content but a reference to a storage area and internally it is stored in a different format not searchable. Even , if you try to find the number of entries in the table you can not put any value in this field as it will not be available for input as it doesn't contain any value.

STRING: 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' . In ABAP, this type is implemented as a reference to a storage area of variable size. As default for the output length 132 characters are proposed. You cannot attach search helps to components of this type.

http://help.sap.com/saphelp_40b/helpdata/en/cf/21f2e5446011d189700000e8322d00/content.htm

Regards

Apoorva

6 REPLIES 6
Read only

jaideepsharma
Active Contributor
0 Likes
1,327

Hi,

Can you please tell me if the table name is correct or are you using different version of SAP?? I can't see this table in ECC 5.0.

KR Jaideep,

Read only

Former Member
0 Likes
1,327

try to use a range.

RANGES: R_NAME FOR CFX_COL-NAME.

CLEAR R_NAME.

R_NAME-SIGN = 'I'.
R_NAME-OPTION = 'EQ'.

concatenate wa_proj-pspid '-' wa_proj-post1 into R_NAME-LOW.

APPEND R_NAME.

select * from CFX_COL into CORRESPONDING FIELDS OF TABLE it_cfol
where name in R_NAME.

Read only

Former Member
0 Likes
1,327

Hi,

Check this code..

REPORT x.
 
TABLES:proj.
 
 
DATA: it_proj TYPE STANDARD TABLE OF proj.
DATA:wa_proj TYPE  proj.
 
 
 
DATA: it_cfol TYPE STANDARD TABLE OF CFX_COL.
DATA:wa_cfol TYPE  CFX_COL.
 
* data:v_name type STRING.
RANGE : R_NAME FOR CFX_COL-NAME.
 
 
PARAMETERS: p_pspid LIKE proj-pspid.
 
 
SELECT * FROM proj INTO CORRESPONDING FIELDS OF TABLE it_proj
WHERE pspid = p_pspid.
 
 
READ TABLE it_proj INTO wa_proj INDEX 1.

R_NAME-SIGN = 'I'.
R_NAME-OPTION = 'EQ'.
concatenate wa_proj-pspid '-' wa_proj-post1 into R_NAME-LOW.
APPEND R_NAME. CLEAR R_NAME.
 
select * from CFX_COL into CORRESPONDING FIELDS OF TABLE it_cfol
where name in r_name.

Read only

Former Member
0 Likes
1,327

HI vara,

when ever you use variables in where condition the fields should be of same type and lenght..

so try to declare the v_name also same type of CFX_COL-Name.

or move the v_name to CFX_COL-Name type field and check it will owrk..

Regards,

Prabhudas

Read only

apoorva_singh
Active Participant
0 Likes
1,328

Hi Vara.

Select will not work if you are trying to search based on the name field as in the table CFX_COL it has data type String which basically is not content but a reference to a storage area and internally it is stored in a different format not searchable. Even , if you try to find the number of entries in the table you can not put any value in this field as it will not be available for input as it doesn't contain any value.

STRING: 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' . In ABAP, this type is implemented as a reference to a storage area of variable size. As default for the output length 132 characters are proposed. You cannot attach search helps to components of this type.

http://help.sap.com/saphelp_40b/helpdata/en/cf/21f2e5446011d189700000e8322d00/content.htm

Regards

Apoorva

Read only

0 Likes
1,327

Thank you all for your replies.

I had to follow a different approach reason being I realised from Apoorva singh that where statement will not work at all.Thank you!!!

Plus I have few entries in my tables CFX_COL.

REPORT x.

TABLES:proj.


DATA: it_proj TYPE STANDARD TABLE OF proj.
DATA:wa_proj TYPE  proj.



DATA: it_cfol TYPE STANDARD TABLE OF CFX_COL.
DATA:wa_cfol TYPE  CFX_COL.

data:v_name type STRING.

data: v_name1 type string.

data: v_colid type cfx_col-col_id.


PARAMETERS: p_pspid LIKE proj-pspid.


SELECT * FROM proj INTO CORRESPONDING FIELDS OF TABLE it_proj
WHERE pspid = p_pspid.


READ TABLE it_proj INTO wa_proj INDEX 1.

concatenate wa_proj-pspid '-' wa_proj-post1 into v_name separated by space.

select * from CFX_COL into CORRESPONDING FIELDS OF TABLE it_cfol.

read table it_cfol into wa_cfol with key name = v_name.

move wa_cfol-name to  v_name1.
move wa_cfol-COL_ID to v_colid.

write: /10 v_name1 , 70 v_colid.

*where name in v_name.