Skip to Content

Ranges as customizing table

Hi,

I am using a table to define STAWNs (as interval and fuzzy entries [1234*]) that should be handled in a specific way .

PLANT | STAWN_FROM | STAWN_TO

----------+----------------------+----------------

0100     |  1234*                 | 124*

0100     |  12345678           |

0100     |  12345*               | 12346*

Now I want to lookup if the value 12345785 is in the table or not. What is the best way to archive this?

Thanks a lot, Vanessa

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Dec 29, 2014 at 05:28 PM

    Hi Vanessa,

    You have to use ranges to lookup any value.

    You can see this example which has defined ranges for lookup.

    ----------------

    TYPES: range_type TYPE RANGE OF fieldname.

    DATA: range_table1 TYPE range_type,
           range_wa1 TYPE LINE of range_type.

    DATA: found type c.

    PARAMETERS: fvalue TYPE C LENGTH 8 DEFAULT '12345678'.

    range_wa1-sign = 'I'.
    range_wa1-option = 'BT'.
    range_wa1-low = '1234*'.
    range_wa1-high = '124*'.
    APPEND range_wa1 to range_table1.
    CLEAR range_wa1.

    range_wa1-sign = 'I'.
    range_wa1-option = 'EQ'.
    range_wa1-low = '12345678'.
    APPEND range_wa1 to range_table1.
    CLEAR range_wa1.

    range_wa1-sign = 'I'.
    range_wa1-option = 'BT'.
    range_wa1-low = '12345*'.
    range_wa1-high = '12346*'.
    APPEND range_wa1 to range_table1.
    CLEAR range_wa1.

    START-OF-SELECTION.

    loop at range_table1 into range_wa1.
       If fvalue BETWEEN range_wa1-low AND range_wa1-high.
         Write: / fvalue, ' in between ', range_wa1-low, range_wa1-high.
         found = 1.
       ENDIF.
    ENDLOOP.

    If found = 0.
       Write: / fvalue, ' not found!'.
    ENDIF.

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 29, 2014 at 06:12 PM

    Hi,

    No need to create tables (Or create something like setleaf ) you can use FI sets (Ask your FI consultants)

    For example:

    TYPES: tp_kstar_range TYPE RANGE OF kstar .

    DATA: setname TYPE setnamenew ,

            rg_kstar TYPE tp_kstar_range .

         

    PERFORM get_cost_element_range

        USING

          setname

        CHANGING

          rg_kstar.

       

    To use the range we can use IN :

      SELECT * FROM covp INTO TABLE it_covp_2

         WHERE

           lednr  EQ '00'     AND

           objnr  EQ <wa_covp_1>-parob1 AND

           gjahr  IN p_gjahr  AND

           perio  IN p_perbl  AND

           kokrs  IN p_kokrs  AND

           kstar  IN rg_kstar AND

           versn  IN p_versn .

    FORM get_cost_element_range

    USING

      setname TYPE setnamenew

    CHANGING

      rg_kstar TYPE tp_kstar_range .

      DATA: wa_kstar LIKE LINE OF rg_kstar .

      DATA: it_setleaf TYPE TABLE OF setleaf .

      FIELD-SYMBOLS: <wa_setleaf> LIKE LINE OF it_setleaf .

      SELECT * FROM setleaf INTO TABLE it_setleaf

        WHERE setname = setname .

      LOOP AT it_setleaf ASSIGNING <wa_setleaf> .

        wa_kstar-sign    = <wa_setleaf>-valsign    .

        wa_kstar-option  = <wa_setleaf>-valoption  .

        wa_kstar-low     = <wa_setleaf>-valfrom .

        wa_kstar-high    = <wa_setleaf>-valto   .

        APPEND wa_kstar TO rg_kstar .

      ENDLOOP .

    ENDFORM .                    "get_Cost_Element_range

    regards.    

    Add comment
    10|10000 characters needed characters exceeded