Application Development 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: 

select

Former Member
0 Kudos

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.

1 ACCEPTED SOLUTION

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

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

7 REPLIES 7

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

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

Former Member
0 Kudos

Hi Eliana,

You can also use the 'Select count(*)' variant which does not need you to retrieve any field.

Karthik

Former Member
0 Kudos

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*************

jayanthi_jayaraman
Active Contributor
0 Kudos

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.

Former Member
0 Kudos

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.

Former Member
0 Kudos

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

Former Member
0 Kudos

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