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

Select query

Former Member
0 Likes
1,147

Hi Experts,

I have a table YBILL. I want to fetch all data from this table in which primary key YBILL_INDEX is ended with a number 9.

Thanks...

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,107

Hi,

try this short example:

TYPES: BEGIN OF TY_ITAB,

X1(10),

X2(10),

END OF TY_ITAB.

*

DATA: IT_ITAB TYPE TABLE OF TY_ITAB.

DATA: WA_ITAB TYPE TY_ITAB.

*

WA_ITAB-X1 = '1239'. WA_ITAB-X2 = 'Test1'. APPEND WA_ITAB TO IT_ITAB.

WA_ITAB-X1 = '1234'. WA_ITAB-X2 = 'Test2'. APPEND WA_ITAB TO IT_ITAB.

WA_ITAB-X1 = '1926'. WA_ITAB-X2 = 'Test3'. APPEND WA_ITAB TO IT_ITAB.

WA_ITAB-X1 = '1222'. WA_ITAB-X2 = 'Test4'. APPEND WA_ITAB TO IT_ITAB.

WA_ITAB-X1 = '1221'. WA_ITAB-X2 = 'Test5'. APPEND WA_ITAB TO IT_ITAB.

WA_ITAB-X1 = '12x9'. WA_ITAB-X2 = 'Test6'. APPEND WA_ITAB TO IT_ITAB.

*

LOOP AT IT_ITAB INTO WA_ITAB WHERE X1 CP '*9'.

WRITE: / WA_ITAB.

ENDLOOP.

Regards, Dieter

10 REPLIES 10
Read only

Former Member
0 Likes
1,107

Select fields from table YBILL into your internal table where YBILL_INDEX like '%9'.

Regards

MD

Read only

0 Likes
1,107

Hi Madhan,

It selects only one (first) record, i want to populate all records which ended with a particular number 9.

Thanks...

Read only

0 Likes
1,107

Hi...

data: itab like mara occurs 0 with header line.

  select * from mara into corresponding fields of table itab where matnr like '%9'.

it will fetches all records which are ends with 9,

Check your declarartion part and entries in your table.

Thanks,

Naveen.I

Read only

0 Likes
1,107

HI SHIRISH,

SELECT ALL THE RECORDS AND WRITE THE CONDITION FOR PRIMARY KEY AS LIKE '%' AND CHECK.

Read only

0 Likes
1,107

try this

RANGES s_YBILL FOR YBILL-YBILL_INDEX .

s_ybill-sign = 'I'.

s_ybill-option = 'CP'.

s_ybill-low = '*9'.

APPEND s_ybill.

Select fields from table YBILL into your internal table where YBILL_INDEX in s_ybill.

Regards

MD

Read only

former_member217544
Active Contributor
0 Likes
1,107

Hi,

Try this one.

if v_ybill is the input



data: it_ybill type standard table of ybill.

  IF v_ybill is INITIAL.
    MOVE '%' to P_generic.
  ELSE.
    TRANSLATE v_ybill USING '%**%'.
  ENDIF.

select *  from ybill 
into corresponding fields of table it_ybill
   where ybill_index like v_ybill.

Hope this wil help you.

Reagrds,

Swarna Munukoti.

Edited by: Swarna Munukoti on Sep 16, 2008 9:12 AM

Read only

Subhankar
Active Contributor
0 Likes
1,107

Hi...

See the test code ..

I think it will solve your problem

REPORT z_test_subha3.

DATA: i_mara TYPE STANDARD TABLE OF mara INITIAL SIZE 0,

wa_mara TYPE mara.

SELECT * FROM mara INTO TABLE i_mara

WHERE matnr LIKE '%2'.

IF sy-subrc = 0.

loop at i_mara INTO wa_mara .

WRITE: / wa_mara-matnr.

ENDLOOP.

ENDIF.

Read only

Former Member
0 Likes
1,108

Hi,

try this short example:

TYPES: BEGIN OF TY_ITAB,

X1(10),

X2(10),

END OF TY_ITAB.

*

DATA: IT_ITAB TYPE TABLE OF TY_ITAB.

DATA: WA_ITAB TYPE TY_ITAB.

*

WA_ITAB-X1 = '1239'. WA_ITAB-X2 = 'Test1'. APPEND WA_ITAB TO IT_ITAB.

WA_ITAB-X1 = '1234'. WA_ITAB-X2 = 'Test2'. APPEND WA_ITAB TO IT_ITAB.

WA_ITAB-X1 = '1926'. WA_ITAB-X2 = 'Test3'. APPEND WA_ITAB TO IT_ITAB.

WA_ITAB-X1 = '1222'. WA_ITAB-X2 = 'Test4'. APPEND WA_ITAB TO IT_ITAB.

WA_ITAB-X1 = '1221'. WA_ITAB-X2 = 'Test5'. APPEND WA_ITAB TO IT_ITAB.

WA_ITAB-X1 = '12x9'. WA_ITAB-X2 = 'Test6'. APPEND WA_ITAB TO IT_ITAB.

*

LOOP AT IT_ITAB INTO WA_ITAB WHERE X1 CP '*9'.

WRITE: / WA_ITAB.

ENDLOOP.

Regards, Dieter

Read only

Former Member
0 Likes
1,107

use this code.

RANGES INDEX FOR YBILL-YBILL_INDEX.

Here put as many '*' as your field length-1.

INDEX-LOW = '********9'.

INDEX-OPTION = 'CP'.

INDEX-SIGN = 'I'.

APPEND INDEX .

DATA : ITAB TYPE TABLE OF YBILL WITH HEADER LINE.

SELECT * FROM YBILL INTO TABLE ITAB

WHERE YBILL_INDEX IN INDEX.

Regards

Alpesh

Read only

Former Member
0 Likes
1,107

It is easy to perorm this requirement on an internal table, get the entire data into an internal table,

get the string length of the field value YBILL_INDEX using command STRLEN into a variable v_count

v_count = v_count - 1.

c2 = v_count(1) + YBILL_INDEX .

check for c2 is 9 or not.

Hope this will help you,

Murthy.