2013 Nov 07 9:27 AM
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.
2013 Nov 07 9:49 AM
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 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
2013 Nov 07 9:45 AM
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.
2013 Nov 07 9:49 AM
Hi Modadugu,
Thank you for your prompt reply but it doesn't work.
Regards,
ts
2013 Nov 07 9:59 AM
Please remove this RFC function lock...Do it after fetching the data
2013 Nov 07 9:49 AM
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
2013 Nov 07 12:24 PM
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
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |