07-02-2007 1:17 AM
hi,
may i know if i just want to check if the entry is exist (not to get the data from database table), say ekko,
can i write as below? i must use select? i must have if statement to check sy-subrc?
select single * where ebeln = wa_pono and
ebelp = wa_poitem.
if sy-subrc = 0
perform found.
else.
perform not found.
endif.
07-02-2007 1:24 AM
Yes, you must use select. But you can also minmize the data retreival by specifying a field.
data: wa_ebeln type ekko-ebeln.
clear wa_ebeln.
select single ebeln into wa_ebeln
where ebeln = wa_pono and
ebelp = wa_poitem.
if sy-subrc = 0
perform found.
else.
perform not found.
endif.
Regards,
Rich Heilman
07-02-2007 1:24 AM
Yes, you must use select. But you can also minmize the data retreival by specifying a field.
data: wa_ebeln type ekko-ebeln.
clear wa_ebeln.
select single ebeln into wa_ebeln
where ebeln = wa_pono and
ebelp = wa_poitem.
if sy-subrc = 0
perform found.
else.
perform not found.
endif.
Regards,
Rich Heilman
07-02-2007 1:49 AM
Hi Eliana,
You can also use the 'Select count(*)' variant which does not need you to retrieve any field.
Karthik
07-02-2007 5:25 AM
Hi,
you can use the select *
select single
for ex:
TABLES SPFLI.
SELECT * FROM SPFLI
WHERE
CITYFROM = 'FRANKFURT' AND
CITYTO = 'NEW YORK'.
WRITE: / SPFLI-CARRID, SPFLI-CONNID.
ENDSELECT.
for ex:
TABLES SFLIGHT.
DATA SEATSFREE TYPE I.
SELECT SINGLE * FROM SFLIGHT
WHERE
CARRID = 'LH ' AND
CONNID = '0400' AND
FLDATE = '19950228'.
SEATSFREE = SFLIGHT-SEATSMAX - SFLIGHT-SEATSOCC.
WRITE: / SFLIGHT-CARRID, SFLIGHT-CONNID,
SFLIGHT-FLDATE, SEATSFREE.
you can use following return code in your program
SY-SUBRC = 0 At least one line was read.
SY_SUBRC = 4 No lines were read.
SY-SUBRC = 8 The search key was not fully qualified.
*******please reward points if the information is helpful to you*************
07-02-2007 5:31 AM
Hi,
In select statement, you need to specify the database table name.
data v_ebeln type ebeln.
select single ebeln into v_ebeln from <b>EKBE</b> where ebeln = wa_pono and
ebelp = wa_poitem.
if sy-subrc = 0
perform found.
else.
perform not found.
endif.
07-02-2007 5:38 AM
hi
your query should have DB table name.
select single * from ekpo where ebeln = wa_pono and
ebelp = wa_poitem.
if sy-subrc = 0
perform found.
else.
perform not found.
endif.
reward if useful.
07-02-2007 8:00 AM
Hi Elina,
Your view is correct but you should modify your coding.
select single * where ebeln = wa_pono and ebelp = wa_poitem.
if sy-subrc = 0
perform found.
else.
perform notfound.
endif.
form found.
Write: 'The record is found'.
endform.
form notfound.
Write: 'The record is not found'.
endform.
IF HELPFULL REWARD
07-02-2007 8:06 AM
hi.
refer this code.
data: it_ebeln type ekko-ebeln.
clear it_ebeln.
select single ebeln into it_ebeln
where ebeln = it_ebeln-pono and
ebelp = it_ebeln-poitem.
if sy-subrc = 0
perform found.
else.
perform not found.
endif.
Reward all helpfull answers.
Regards.
Jay