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

error: Invalid interrupting of a database selection

Former Member
0 Likes
1,039

Hi,

I use the following code to retrieve data from another system to internal table and lock the selected objects. An error popped up (screen capture is attached below). How to resolve it?

Best regards,

ts

DATA: LS_ZPDMI_HDR TYPE ZPDMI_HDR.

SELECT *

   INTO CORRESPONDING FIELDS OF LS_ZPDMI_HDR

   FROM ZPDMI_HDR

        CLIENT SPECIFIED

        CONNECTION T15

        UP TO 3 ROWS

  WHERE MANDT = '280'.

   CALL FUNCTION 'ENQUEUE_EZPDMI_HDR'

     DESTINATION 'T15'

    EXPORTING

      MODE_ZPDMI_HDR      = 'E'

      MANDT               = '280'

      AUFNR               = LS_ZPDMI_HDR-AUFNR

      ISSUE_DATE          = LS_ZPDMI_HDR-ISSUE_DATE

      ISSUE_SEQ           = LS_ZPDMI_HDR-ISSUE_SEQ

*     X_AUFNR             = ' '

*     X_ISSUE_DATE        = ' '

*     X_ISSUE_SEQ         = ' '

*     _SCOPE              = '2'

*     _WAIT               = ' '

*     _COLLECT            = ' '

    EXCEPTIONS

      FOREIGN_LOCK        = 1

      SYSTEM_FAILURE      = 2

      OTHERS              = 3

             .

ENDSELECT.


1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,009

Hi TS,

As the error analysis itself says, you cannot call an RFC between a SELECT..ENDSELECT.

From your source code I interpret that you just want to lock the table entries.

Instead of reading and then locking entries separately what you can do is create an RFC function module and place the source code mentioned above in that RFC (without giving any destination) and then call this RFC.

For example,

FUNCTION z_test.

SELECT *

   INTO CORRESPONDING FIELDS OF LS_ZPDMI_HDR

   FROM ZPDMI_HDR

        CLIENT SPECIFIED

        UP TO 3 ROWS

  WHERE MANDT = '280'.

   CALL FUNCTION 'ENQUEUE_EZPDMI_HDR'

    EXPORTING

      MODE_ZPDMI_HDR      = 'E'

      MANDT               = '280'

      AUFNR               = LS_ZPDMI_HDR-AUFNR

      ISSUE_DATE          = LS_ZPDMI_HDR-ISSUE_DATE

      ISSUE_SEQ           = LS_ZPDMI_HDR-ISSUE_SEQ

*     X_AUFNR            = ' '

*     X_ISSUE_DATE        = ' '

*     X_ISSUE_SEQ        = ' '

*     _SCOPE              = '2'

*     _WAIT               = ' '

*     _COLLECT            = ' '

    EXCEPTIONS

      FOREIGN_LOCK        = 1

      SYSTEM_FAILURE      = 2

      OTHERS              = 3

             .

ENDSELECT.

ENDFUNCTION.

Now you can call this FM z_test specifying the destination 'T15'.

Thanks,

Ajay Bose

Hi,

I use the following code to retrieve data from another system to internal table and lock the selected objects. An error popped up (screen capture is attached below). How to resolve it?

Best regards,

ts

DATA: LS_ZPDMI_HDR TYPE ZPDMI_HDR.

SELECT *

   INTO CORRESPONDING FIELDS OF LS_ZPDMI_HDR

   FROM ZPDMI_HDR

        CLIENT SPECIFIED

        CONNECTION T15

        UP TO 3 ROWS

  WHERE MANDT = '280'.

   CALL FUNCTION 'ENQUEUE_EZPDMI_HDR'

     DESTINATION 'T15'

    EXPORTING

      MODE_ZPDMI_HDR      = 'E'

      MANDT               = '280'

      AUFNR               = LS_ZPDMI_HDR-AUFNR

      ISSUE_DATE          = LS_ZPDMI_HDR-ISSUE_DATE

      ISSUE_SEQ           = LS_ZPDMI_HDR-ISSUE_SEQ

*     X_AUFNR             = ' '

*     X_ISSUE_DATE        = ' '

*     X_ISSUE_SEQ         = ' '

*     _SCOPE              = '2'

*     _WAIT               = ' '

*     _COLLECT            = ' '

    EXCEPTIONS

      FOREIGN_LOCK        = 1

      SYSTEM_FAILURE      = 2

      OTHERS              = 3

             .

ENDSELECT.


5 REPLIES 5
Read only

hemanth_kumar21
Contributor
0 Likes
1,009

Hi,

Please use the below code.

After the FM execution.

  CALL FUNCTION 'ENQUEUE_EZPDMI_HDR'

put a check

if sy-subrc eq 0.

commit work.

else.

rollback work.

endif.

Read only

0 Likes
1,009

Hi Modadugu,

Thank you for your prompt reply but it doesn't work.

Regards,

ts

Read only

0 Likes
1,009

Please remove this RFC function lock...Do it after fetching the data

Read only

Former Member
0 Likes
1,010

Hi TS,

As the error analysis itself says, you cannot call an RFC between a SELECT..ENDSELECT.

From your source code I interpret that you just want to lock the table entries.

Instead of reading and then locking entries separately what you can do is create an RFC function module and place the source code mentioned above in that RFC (without giving any destination) and then call this RFC.

For example,

FUNCTION z_test.

SELECT *

   INTO CORRESPONDING FIELDS OF LS_ZPDMI_HDR

   FROM ZPDMI_HDR

        CLIENT SPECIFIED

        UP TO 3 ROWS

  WHERE MANDT = '280'.

   CALL FUNCTION 'ENQUEUE_EZPDMI_HDR'

    EXPORTING

      MODE_ZPDMI_HDR      = 'E'

      MANDT               = '280'

      AUFNR               = LS_ZPDMI_HDR-AUFNR

      ISSUE_DATE          = LS_ZPDMI_HDR-ISSUE_DATE

      ISSUE_SEQ           = LS_ZPDMI_HDR-ISSUE_SEQ

*     X_AUFNR            = ' '

*     X_ISSUE_DATE        = ' '

*     X_ISSUE_SEQ        = ' '

*     _SCOPE              = '2'

*     _WAIT               = ' '

*     _COLLECT            = ' '

    EXCEPTIONS

      FOREIGN_LOCK        = 1

      SYSTEM_FAILURE      = 2

      OTHERS              = 3

             .

ENDSELECT.

ENDFUNCTION.

Now you can call this FM z_test specifying the destination 'T15'.

Thanks,

Ajay Bose

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,009

As explicitly written in the dump you cannot use such a call in a SELECT / ENDSELECT so either select whole data in an internal table and then loop at it or use some CURSOR (WITH HOLD) and FETCH statements.

From SELECT/ ENDSELECT online documentation

Within a SELECT loop, you cannot execute any statements that lead to a database commit or database rollback, causing the corresponding database cursor to be closed as a result.

Regards,

Raymond