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

reg select statement

Former Member
0 Likes
683

hi i have a problem.

i want to extract records from three fields in a table using select statement.after extraction.

if there is no records in the three fields i had to give another condition.can any body provide code for this

1 ACCEPTED SOLUTION
Read only

gopi_narendra
Active Contributor
0 Likes
662

select field1 field2 field3 from TAB_NAME

into tab itab

where condition.

if sy-subrc NE 0.

select ....

endif.

Regards

- Gopi

7 REPLIES 7
Read only

gopi_narendra
Active Contributor
0 Likes
663

select field1 field2 field3 from TAB_NAME

into tab itab

where condition.

if sy-subrc NE 0.

select ....

endif.

Regards

- Gopi

Read only

Former Member
0 Likes
662

Write a select statement to fetch the data into internal table.

Get the number of records in the internal table using DESCRIBE statement.

describe itab lines n.

if n = 0.

*write next piece of code.

endif.

I hope it helps.

Best Regards,

Vibha

*Please mark all the helpful answers

Read only

former_member404244
Active Contributor
0 Likes
662

Hi Siva,

want to extract records from three fields in a table using select statement.after extraction.

if there is no records in the three fields i had to give another condition.can any body provide code for this

select field1 field2 field3 from <dbtable> into table itab

where = ...........

if sy-subrc ne 0.

give ur comdition here and proceed

endif.

Regards,

nagaraj

Read only

Former Member
0 Likes
662

Hi Siva,

You can check the field sy-subrc to verify if your selection returns any records? if sy-subrc = 0, it means the selection is successful.

Is this what you required?

Best regards,Junwen

Read only

santhosh_patil
Contributor
0 Likes
662

HI,

try with this

select field1 field1 field 1

from <tablename>

into itab1

where

condition1...

now u check for

if sy-subrc ne 0. OR itab1[] is initial.

select field1 field1 field 1

from <tablename>

into itab1

where

condition1...

condition2...

endif.

If i am not clear ... reply back

-


Santhosh

Read only

Former Member
0 Likes
662

SELECT F1 F2 F3 FROM DBTAB INTO ITAB........

IF SY-SUBRC NE 0.

CONDITION.

ENDIF.

ENDSELECT.

SHIBA PRASAD DUTTA

Read only

Former Member
0 Likes
662

Hi

1. load data to internal table

2.use DESCRIBE TABLE it_mat_dtl LINES w_dbcnt.

w_dbcnt is no of records in the internal table

3. IF w_dbcnt > 0.

<< YOUR STATMENT>>

ENDIF.

Note,

Please add maks for useful ans.