09-16-2008 7:51 AM
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...
09-16-2008 8:17 AM
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
09-16-2008 7:56 AM
Select fields from table YBILL into your internal table where YBILL_INDEX like '%9'.
Regards
MD
09-16-2008 8:02 AM
Hi Madhan,
It selects only one (first) record, i want to populate all records which ended with a particular number 9.
Thanks...
09-16-2008 8:08 AM
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
09-16-2008 8:09 AM
HI SHIRISH,
SELECT ALL THE RECORDS AND WRITE THE CONDITION FOR PRIMARY KEY AS LIKE '%' AND CHECK.
09-16-2008 8:12 AM
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
09-16-2008 8:11 AM
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
09-16-2008 8:12 AM
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.
09-16-2008 8:17 AM
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
09-16-2008 8:23 AM
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
09-16-2008 8:52 AM
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.