Skip to Content
avatar image
Former Member

Select query

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

6 Answers

  • Best Answer
    avatar image
    Former Member
    Sep 16, 2008 at 07: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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 16, 2008 at 06:56 AM

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

    Regards

    MD

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      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

  • avatar image
    Former Member
    Sep 16, 2008 at 07: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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 16, 2008 at 07: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.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 16, 2008 at 07: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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 16, 2008 at 07: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.

    Add comment
    10|10000 characters needed characters exceeded