03-17-2014 4:57 PM
In my Program am using Select Statement which executes fine if less than 5000 Handling units are passed in where condition but throws an error dump if its more .The Issue has been mentioned in the SAP Note 13607 - Termination of an ABAP with DBIF_RSQL_INVALID_RSQL.
I Tried with Package size in Select statement still no luck . Need a logic to Dynamically split Handling Units into 5000 and pass it to the Select Statement using Loop INTO statement or using FOR all condition. Need to tweak the following Code :
SELECT EXIDV FROM VEKP INTO CORRESPONDING FIELDS OF TABLE ITAB_VEKP
package size 5000
WHERE
exidv IN arr_exidv[] AND "Need Logic to Split Handling Units into 5000 "
lgnum IN arr_lgnum[] AND
erdat IN arr_erdat[] .
ENDSELECT.
Thanks in Advance .
Best Regards,
Vicky
03-18-2014 7:52 AM
Hi,
If you are sure that ARR_EXIDV[] will have only multiple single values to be included (Sign = I, Option = EQ, low = value, high = initial ) you can use FOR ALL ENTRIES IN instead of IN in WHERE clause, Avoid select-end select.
SELECT EXIDV
FROM VEKP
INTO CORRESPONDING FIELDS OF TABLE ITAB_VEKP
FOR ALL ENTRIES IN arr_exidv[]
WHERE
exidv = arr_exidv-low AND
lgnum IN arr_lgnum[] AND
erdat IN arr_erdat[] .
Try the above code and check whether it is working fine or not.
Thanks,
Shajahan.
03-17-2014 6:16 PM
Hi Vicky,
Even i faced this issue, the dump is because of so many records in select option. Using For All Entries solved the issue. i had values only in low with equality operator so i looped and collected values in internal table and used FAE.
1. Another way is to fetch the exidv values from the table seperately for each entry in SO into an internal table, sort and delete adjascent duplicates and use it with FAE.
2. you can also use
append lines of SO into temp_so from 1 to 5000 in loop and
fetch the data from DB table and append to internal table
in this way you may get duplicate records, as each of the record in SO may be repeated.
03-17-2014 6:23 PM
There is something wrong with your query. You are using select options/ranges as part of the where clause, but at the same time using SELECT-ENDSELECT construct.
You need to step back and rethink what you are attempting here. FOR ALL ENTRIES (FAE) and a Select statement into internal table seems to be better approach.
03-18-2014 2:43 AM
Hi,
Use DO LOOP is a straightforward solution.
DATA: lt_arr_exidv like arr_exidv[].
lv_start = 1.
lv_end = 5000.
DO.
clear: lt_arr_exidv.
append lines of arr_exidv to lt_arr_exidv from lv_start to lv_end.
SELECT EXIDV
FROM VEKP
APPENDING CORRESPONDING FIELDS OF TABLE ITAB_VEKP
WHERE exidv IN lt_arr_exidv AND
lgnum IN arr_lgnum AND
erdat IN arr_erdat.
add 5000 to lv_start.
add 5000 to lv_end.
if lv_start > lines( arr_exidv ).
exit.
endif.
ENDDO.
03-18-2014 7:45 AM
Hi Vicky,
Have a look at this code (sql cursors):
RANGES:
arr_exidv FOR vekp-exidv,
arr_lgnum FOR vekp-lgnum,
arr_erdat FOR vekp-erdat.
DATA:
l_cur TYPE cursor,
lt_vekp_buf TYPE TABLE OF vekp,
lt_vekp TYPE TABLE OF vekp,
lv_flag TYPE char01.
lv_flag = 1.
REFRESH lt_vekp.
OPEN CURSOR WITH HOLD l_cur FOR
SELECT exidv FROM vekp
WHERE exidv IN arr_exidv
AND lgnum IN arr_lgnum
AND erdat IN arr_erdat.
DO.
FETCH NEXT CURSOR l_cur
INTO CORRESPONDING FIELDS OF TABLE lt_vekp_buf PACKAGE SIZE 2500.
IF sy-subrc <> 0.
EXIT.
ENDIF.
IF lv_flag = 2.
lv_flag = 1.
APPEND LINES OF lt_vekp_buf TO lt_vekp. " 5000
" do something here...
REFRESH lt_vekp. " clear the data
ELSE.
lv_flag = lv_flag + 1.
APPEND LINES OF lt_vekp_buf TO lt_vekp.
ENDIF.
CALL FUNCTION 'DB_COMMIT'. " optional
ENDDO.
CLOSE CURSOR l_cur.
Instead of that query, you may try to build an internal table to use it in the select statement (For all entries).
Regards,
Luis
03-18-2014 7:52 AM
Hi,
If you are sure that ARR_EXIDV[] will have only multiple single values to be included (Sign = I, Option = EQ, low = value, high = initial ) you can use FOR ALL ENTRIES IN instead of IN in WHERE clause, Avoid select-end select.
SELECT EXIDV
FROM VEKP
INTO CORRESPONDING FIELDS OF TABLE ITAB_VEKP
FOR ALL ENTRIES IN arr_exidv[]
WHERE
exidv = arr_exidv-low AND
lgnum IN arr_lgnum[] AND
erdat IN arr_erdat[] .
Try the above code and check whether it is working fine or not.
Thanks,
Shajahan.