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

maximum permitted length for open dynamic sql

Former Member
0 Likes
2,939

Hi all

What is the maximum permitted length for open dynamic multitable sql for different database?

like we have open sql in this format

Select (op_list) from (join_tables) into itab where (where_crietria).

so

1-> what is the maximum length of total sql?

2-> what is the maximum length of op_list?

3-> what is the maximum length of jointables?

4-> what is the maximum length of where_criteria with diff operator like 'IN' ?

thanks,

Anuj

6 REPLIES 6
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,652

Hello,

Check this thread for details: .

BR,

Suhas

Read only

former_member194669
Active Contributor
0 Likes
1,652

If you done something this way i don't think you have limitation


DATA: V_CONDITION(72) TYPE C, 
           ITAB LIKE TABLE OF V_CONDITION. 

SELECTION-OPTIONS : S_MATNR FOR MARA-MATNR. 

DATA WA TYPE MARA-MATNR. 

LOOP AT S_MATNR.
IF SY-TABIX EQ 1.
CONCATENATE 'MATNR = ''' S_MATNR-LOW '''' INTO V_CONDITION. 
APPEND V_CONDITION TO ITAB. 
ELSE.
CONCATENATE 'OR MATNR = ''' S_MATNR-LOW '''' INTO V_CONDITION. 
APPEND V_CONDITION TO ITAB. 
ENDIF.
ENDLOOP.

SELECT MATNR 
INTO   WA 
FROM   MARA 
WHERE  (ITAB). 

  WRITE / WA. 

ENDSELECT.

a®

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,652

Hello aRs,

The restriction is on the total length of the dynamic SQL statement which is generated at the DB level during runtime.

You should check the OSS Note: Note 635318 - Open SQL: Size restrictions for commands.

Cheers,

Suhas

Edited by: Suhas Saha on Mar 10, 2010 11:16 AM

Read only

0 Likes
1,652

suhas,

You are right.

When the SQL statement is generated at runtime, you should check the following restrictions and divide or reduce the statement if necessary.

The static length (in the ABAP editor) of any ABAP command must not exceed 28672 characters.In Open SQL commands with dynamic subclauses (WHERE, GROUP BY, ORDER BY, and so on), the subclauses cannot contain more than 28672 characters

Thanks for pointing out.

a®

Read only

Former Member
0 Likes
1,652

Thanks suhas $ aRs,

"The static length (in the ABAP editor) of any ABAP command must not exceed 28672 characters.In Open SQL commands with dynamic subclauses (WHERE, GROUP BY, ORDER BY, and so on), the subclauses cannot contain more than 28672 characters"

But this is only realated to where_criteria ..... is there any limit for op_list ond join_tables and right now i

m able to run query more than 65k character....

regards,

Anuj

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,652

>

> But this is only realated to where_criteria ..... is there any limit for op_list ond join_tables and right now i

> m able to run query more than 65k character....

Can you elaborate on this statement please ?

I am not sure about the OP_LIST but for JOINs you have a limitation of 24 join expressions. (source: [http://help.sap.com/abapdocu_70/en/ABAPSELECT_JOIN.htm|http://help.sap.com/abapdocu_70/en/ABAPSELECT_JOIN.htm])

BR,

Suhas