2012 May 04 8:53 PM
Hi Experts,
I am changing the below code in user exit,because select single always fetch the first record from database and in my ZTABLE there can be more than 1 entry:
IF I_KNA1-VBUND <>.
DATA L_VAR LIKE ZTAB.
SELECT SINGLE * FROM ZTAB INTO
L_VAR WHERE RCOMP = I_KNA1-VBUND. (RCOMP and EFF_TO are key field)
IF SY-SUBRC = 0.
IF SY-DATUM LT L_VAR-EFF_FROM OR SY-DATUM > L_VAR-EFF_TO.
Error message
ENDIF.
ENDIF.
ENDIF.
Since there can be more than 1 entry in ZTAB the above logic wont work, my logic:
(If you guys can advice on a better logic than the below ?)
IF i_kna1-vbund <>.
select * from ZTAB into itabwhere RCOMP = Ikna1-vbund.
if sy-subrc = 0.
loop at itab where EFF_FROM LE SY-DATUM and EFF_TO GE SY-DATUM.
endloop.
if sy-subrc <> 0.
error message.
endif.
endif.
endif.
Please advice if there is a better logic to do this?
Hi Experts,
I am changing the below code in user exit,because select single always fetch the first record from database and in my ZTABLE there can be more than 1 entry:
IF I_KNA1-VBUND <>.
DATA L_VAR LIKE ZTAB.
SELECT SINGLE * FROM ZTAB INTO
L_VAR WHERE RCOMP = I_KNA1-VBUND. (RCOMP and EFF_TO are key field)
IF SY-SUBRC = 0.
IF SY-DATUM LT L_VAR-EFF_FROM OR SY-DATUM > L_VAR-EFF_TO.
Error message
ENDIF.
ENDIF.
ENDIF.
Since there can be more than 1 entry in ZTAB the above logic wont work, my logic:
(If you guys can advice on a better logic than the below ?)
IF i_kna1-vbund <>.
select * from ZTAB into itabwhere RCOMP = Ikna1-vbund.
if sy-subrc = 0.
loop at itab where EFF_FROM LE SY-DATUM and EFF_TO GE SY-DATUM.
endloop.
if sy-subrc <> 0.
error message.
endif.
endif.
endif.
Please advice if there is a better logic to do this?
2012 May 04 9:04 PM
Moderator message - this has been discussed many times before. Please search before asking.
Press F1 on SELECT UP TO N ROWS ... ORDER BY
Locked.
Rob
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |