Skip to Content
author's profile photo
Former Member

Ranges

Hi,

Iam declaring the ranges like

r_fkart_line-sign = 'I'.

r_fkart_line-option = 'EQ'

r_fkart_line-low = c_b1.

APPEND r_fkart_line TO r_fkart.

r_fkart_line-sign = 'I'

r_fkart_line-option = 'EQ'.

r_fkart_line-low = c_b1e.

APPEND r_fkart_line TO r_fkart.

r_fkart_line-sign = 'I'.

r_fkart_line-option = 'EQ'.

r_fkart_line-low = c_b2.

APPEND r_fkart_line TO r_fkart.

r_fkart_line-sign = 'I'.

r_fkart_line-option = 'EQ'.

r_fkart_line-low = c_b2e.

APPEND r_fkart_line TO r_fkart.

r_fkart_line-sign = 'I'..

r_fkart_line-option = 'EQ'..

r_fkart_line-low = c_b3.

APPEND r_fkart_line TO r_fkart.

r_fkart_line-sign = 'I'.

r_fkart_line-option = 'EQ'..

r_fkart_line-low = c_b3e.

APPEND r_fkart_line TO r_fkart.

r_fkart_line-sign = 'I'.

r_fkart_line-option = 'EQ'..

r_fkart_line-low = c_b4.

APPEND r_fkart_line TO r_fkart.

Sign, and option is common for declaration.I want reduce my code.How can i give the single statement for all ranges declaration.

Give me suggestions.

Thanks & Regads,

sudhakar

Add comment
10|10000 characters needed characters exceeded

4 Answers

  • Posted on Aug 23, 2007 at 08:14 AM

    I have created a procedure to reduce a size of a ranges to not go in short dump.

    It's for MATNR, but that the same, my ranges is S_MATNR.

    
    *---------------------------------------------------------------------*
    *   Form P_OPTIMIZE_MATNR.                                            *
    *---------------------------------------------------------------------*
    *---------------------------------------------------------------------*
    FORM p_optimize_matnr USING it_mast TYPE tt_mast.
    
    
      DATA : is_mast  TYPE ts_mast ,
             w_matnr  TYPE matnr   ,
             w_matnr2 TYPE matnr   ,
             w_lines  TYPE i       .
    
    
    * Add the material of the selection.
      IF NOT s_matnr[] IS INITIAL.
        SELECT matnr
               APPENDING TABLE it_mast
               FROM mast
               WHERE matnr IN s_matnr.
      ENDIF.
    
    * Sort.
      SORT it_mast BY matnr.
      DELETE ADJACENT DUPLICATES FROM it_mast COMPARING matnr.
    
    * Clear ranges.
      REFRESH s_matnr.
      CLEAR   s_matnr.
    
    * Add new range.
      LOOP AT it_mast
           INTO is_mast.
        w_matnr2 = is_mast-matnr + 0.
        IF w_matnr2 EQ w_matnr.
          MOVE is_mast-matnr TO s_matnr-high.
        ELSE.
          IF NOT w_matnr IS INITIAL.
            IF s_matnr-high IS INITIAL.
              MOVE : 'I'  TO s_matnr-sign ,
                     'EQ' TO s_matnr-option.
            ELSE.
              MOVE : 'I'  TO s_matnr-sign ,
                     'BT' TO s_matnr-option.
            ENDIF.
            APPEND s_matnr.
            CLEAR s_matnr.
          ENDIF.
          MOVE is_mast-matnr TO s_matnr-low.
        ENDIF.
        w_matnr = is_mast-matnr + 1.
      ENDLOOP.
    
    
    * Append the last line.
      IF s_matnr-high IS INITIAL.
        MOVE : 'I'  TO s_matnr-sign ,
               'EQ' TO s_matnr-option.
      ELSE.
        MOVE : 'I'  TO s_matnr-sign ,
               'BT' TO s_matnr-option.
      ENDIF.
      APPEND s_matnr.
      CLEAR s_matnr.
    
    
    * Check dangerous usage.
      DESCRIBE TABLE s_matnr LINES w_lines.
      IF w_lines GT 2900.
        MESSAGE i398(00) WITH text-e03.
        LEAVE TO SCREEN 0.
      ENDIF.
    
    
    
    
    ENDFORM.                    " P_OPTIMIZE_MATNR.

    Add comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 23, 2007 at 08:19 AM

    Hi,

    Try this, it will not reduce the code to be executed but code that appears in program atleast.

    DEFINE append_range.

    r_fkart_line-sign = 'I'.

    r_fkart_line-option = 'EQ'

    r_fkart_line-low = &1.

    APPEND r_fkart_line TO r_fkart.

    END-OF-DEFINITION.

    and use

    append_range c_b1.

    append_range c_b1e.

    append_range c_b2.

    append_range c_b2e.

    append_range c_b3.

    append_range c_b3e.

    append_range c_b4.

    Regards,

    Sesh

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on Aug 23, 2007 at 09:01 AM

    Sudhakar,

    If you want to reduce the amount of code you have to write, you can use macros which would be quite simple....

    You can define a macro add_range like

    DEFINE add_range.

    R_FKART-SIGN = 'i'.

    R_FKART-OPTION = 'EQ'.

    R_FKART-LOW = &1.

    APPEN R_FKART.

    END-OF-DEFINITION.

    AND THEN USE

    add_range c_b1.

    add_range c_b1e.

    add_range c_b2.

    add_range c_b2e.

    add_range c_b3.

    add_range c_b3e.

    add_range c_b4.

    Give reward points if you find this helpful.

    Balaji

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on Aug 23, 2007 at 09:04 AM

    clear: r_fkart,r_fkart[].

    r_fkart_line-sign = 'I'.

    r_fkart_line-option = 'EQ'

    r_fkart_line-low = c_b1.

    perform append_range.

    r_fkart_line-low = c_b1e.

    perform append_range.

    r_fkart_line-low = c_b2.

    perform append_range.

    r_fkart_line-low = c_b2e.

    perform append_range.

    r_fkart_line-low = c_b3.

    perform append_range.

    r_fkart_line-low = c_b3e.

    perform append_range.

    r_fkart_line-low = c_b4.

    perform append_range.

    form append_range.

    APPEND r_fkart_line TO r_fkart.

    endform.

    Reward points if useful, get back in case of query...

    Cheers!!!

    Add comment
    10|10000 characters needed characters exceeded