How to Fix Error in module RSQL of the database interface

keywords
Error in module RSQL of the database interface error key: RFC_ERROR_SYSTEM_FAILUREdbtran ERROR (set_input_da_spec): statement too big[dbtran.c#4854] marker count = 18655 > max. marker count = 16000 [dbtran.c#4854] sap note:13607


Problem description
[Problem] After EP was tested by the development machine, the EP was executed after it was released to the production machine, and this Problem occurred:

Error message:
Error in module RSQL of the database interface, Error key: RFC_ERROR_SYSTEM_FAILURE
Problem analysis
You can first try the following operations:
1, check, test the RFC, and transfer the related requests to the production environment; 2. Reimport RFC in NWDS and republish the project (note that the operation of production environment release is different from that of development machine); 3. Restart EP;
if the problem is still unresolved, read on.
Check the ABAP Runtime Error log

through the transport code ST22. Double-click the corresponding Error log to enter the Runtime Error Long Text interface, where there are detailed Error reports.
Some of the error messages I picked:
Kategorie (category) : ABAP Programming Error
Laufzeitfehler (runtime Error) : DBIF_RSQL_INVALID_RSQL
Ausnahme (exception) : CX_SY_OPEN_SQL_DB
ABAP Programm: SAPLZEWM_RFC2
【Kurztext】 (German, meaning category)
Error in module RSQL of the database interface

Error in the ABAP Application Program
the current ABAP Program “SAPLZEWM_RFC2” had to be terminated because it has come across a statement that unfortunately cannot be executed.

An exception that is explained in detail below once again occurred.
The Exception, which is assigned to class ‘CX_SY_OPEN_SQL_DB’, was not caught in procedure “ZTM_RFC_YSQSD_GETORDER_V2” (FUNCTION) “, nor was it propagated by a RAISING clause.
Since the caller of the procedure could not have anticipated that the exception would occur, the current program is terminated.
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.
You can generally find details in the system log (SM21) and in the developer trace of the relevant work process (ST11).
Cause analysis,
1. In the ABAP Select statement, when range Table is used in the WHERE clause, the type of range Table exceeds the maximum limit of the database (the maximum value is determined by DB).
2. The source code location is already listed above the error message:

The solution
1. Search SAP Note: 13607. Extract the contents of Note


2. So I modified my code:

DATA r_so LIKE RANGE OF vbak-vbeln WITH HEADER LINE. 
DATA lines LIKE LINE OF r_so.
DESCRIBE TABLE r_so LINES lines.
IF lines EQ 0.
    SELECT
      vbak~vbeln AS vbeln
      adrc~name1 AS name1 
      vbpa~kunnr AS kunnr
      vbpa~parvw AS parvw
      adrc~city1 AS city1
      FROM vbpa
      INNER JOIN vbak ON vbak~vbeln EQ vbpa~vbeln
      INNER JOIN adrc ON vbpa~adrnr EQ adrc~addrnumber
      INTO CORRESPONDING FIELDS OF TABLE gt_display_vbpa_ag
      WHERE adrc~name1 IN r_shippername 
        AND vbpa~kunnr IN r_shipper     
        AND vbpa~parvw EQ 'AG'.
...
ELSE.
    TRY.
      SELECT
         vbak~vbeln AS vbeln
         adrc~name1 AS name1
         vbpa~kunnr AS kunnr
         vbpa~parvw AS parvw
         adrc~city1 AS city1
         FROM vbpa
         INNER JOIN vbak ON vbak~vbeln EQ vbpa~vbeln
         INNER JOIN adrc ON vbpa~adrnr EQ adrc~addrnumber
         INTO CORRESPONDING FIELDS OF TABLE gt_display_vbpa_ag
         FOR ALL ENTRIES IN r_so 
         WHERE vbak~vbeln EQ r_so-low
           AND adrc~name1 IN r_shippername 
           AND vbpa~kunnr IN r_shipper     
           AND vbpa~parvw EQ 'AG'.

   CATCH cx_sy_open_sql_db.
   ENDTRY.
...
ENDIF.

3. After modifying the RFC, it is necessary to re-import Model
in WD4J
4. Re-transmit the Request to production and re-publish it to EP. Problem solved
Summarize the ideas for solving THE SAP problem
1, do not do hand party, do not ask a mistake, be sure to read the error message, analysis of the possible part of the error, is RFC error or WD4J error; 2. Error messages can be viewed through Tcode ST22 or ST11 or sm21; 3. About search engines:
SAP search: http://search.sap.com/ (this SAP note the number 13607 is found in the above) SAP note: https://websmp206.sap-ag.de/NOTES (search keywords are provided in the error log)

SAP custom Google search engine, https://cse.google.com/cse/home?cx=013447253335410278659:k8ob9ipscwg

Read More: