Hi Experts,
I have SQL query like this.
loop at itab into wa. concatenate 'PR' wa-f1 into wa_range-low. wa_range-sign = 'I'. wa_range-option = 'EQ'. append wa_range to r_range. clear wa_range. endloop. if r_range[] is not initial. sort r_range by low. delete adjascent duplicates from r_range. select <fields> from <db table> into jtab where f1 in r_range. endif.
This statement causing Runtime Error. Because r_range filling with 12,000 records.
And the Runtime Error saying following solution:
Error analysis An exception occurred that is explained in detail below. The exception, which is assigned to class 'CX_SY_OPEN_SQL_DB', was not caught and therefore caused a runtime error. The reason for the exception is: The SQL statement generated from the SAP Open SQL statement violates a restriction imposed by the underlying database system of the ABAP system. Possible error causes: o The maximum size of an SQL statement was exceeded. o The statement contains too many input variables. o The input data requires more space than is available. o ... You can generally find details in the system log (SM21) and in the developer trace of the relevant work process (ST11). In the case of an error, current restrictions are frequently displayed in the developer trace. How to correct the error The SAP Open SQL statement concerned must be divided into several smaller units. If the problem occurred due to the use of an excessively large table in an IN itab construct, you can use FOR ALL ENTRIES instead. When you use this addition, the statement is split into smaller units according to the restrictions of the database system used. If the error occures in a non-modified SAP program, you may be able to find an interim solution in an SAP Note. If you have access to SAP Notes, carry out a search with the following keywords: "DBIF_RSQL_INVALID_RSQL" "CX_SY_OPEN_SQL_DB" "ZEM_UPDATE_ZEMCATSFI" or "ZEM_UPDATE_ZEMCATSFI"
So I have modified above SQL like this:
loop at itab into wa. concatenate 'PR' wa-f1 into wa_range-low. wa_range-sign = 'I'. wa_range-option = 'EQ'. append wa_range to r_range. clear wa_range. endloop. if r_range[] is not initial. sort r_range by low. delete adjascent duplicates from r_range. select <fields> from <db table> into jtab FOR ALL ENTRIES IN R_RANGE where f1 = r_range-f1. endif.
But,
I Can't test this scenario in my Development System. So not sure if its resolves the problem or not.
Because there are no duplicates entries in R_RANGE, where FOR ALL ENTRIES can make difference.
Please suggest me your Ideas.
Thanks,
Naveen Inuagnti.