Skip to Content
0

working with ranges

Nov 14, 2016 at 03:08 PM

38

avatar image

I am working on an issue where I have the below internal table:

Vendor_num_from vendor_num_to Rec_acc_from rec_acc_to

100678 100680 200100 200102

100703 100705 200121 200122

I need the data in another internal table in the below format:

Vendor_Num Rec_acc

100678 200100

100678 200101

100678 200102

100679 200100

100679 200101

100679 200102

100680 200100

100680 200101

100680 200102

100703 200121

100703 200122

100704 200121

100704 200122

100705 200121

100705 200122

Can you please let me know the best way of getting this, so that it's not that time consumin?

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

max bianchi Nov 14, 2016 at 04:20 PM
0

Hi

This could be a solution, It's very hard to say if it's the faster one:

DATA: BEGIN OF IT_TAB1 OCCURS 0,
        VEND_FROM TYPE LIFNR,
        VEND_TO   TYPE LIFNR,
        ACCT_FROM TYPE SAKNR,
        ACCT_TO   TYPE SAKNR,
      END  OF IT_TAB1.

DATA: BEGIN OF IT_TAB2 OCCURS 0,
        VEND TYPE LIFNR,
        ACCT TYPE SAKNR,
      END  OF IT_TAB2.



IT_TAB1-VEND_FROM  = '0000100678'.
IT_TAB1-VEND_TO    = '0000100680'.
IT_TAB1-ACCT_FROM  = '0000200100'.
IT_TAB1-ACCT_TO    = '0000200102'.
APPEND IT_TAB1.

IT_TAB1-VEND_FROM  = '0000100703'.
IT_TAB1-VEND_TO    = '0000100705'.
IT_TAB1-ACCT_FROM  = '0000200121'.
IT_TAB1-ACCT_TO    = '0000200122'.
APPEND IT_TAB1.


LOOP AT IT_TAB1.

  IT_TAB2-VEND = IT_TAB1-VEND_FROM.

  DO.
    IT_TAB2-ACCT = IT_TAB1-ACCT_FROM.

    DO.
      APPEND IT_TAB2.

      IT_TAB2-ACCT = IT_TAB2-ACCT + 1.

      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
        EXPORTING
          INPUT  = IT_TAB2-ACCT
        IMPORTING
          OUTPUT = IT_TAB2-ACCT.

      IF IT_TAB2-ACCT > IT_TAB1-ACCT_TO.
        EXIT.
      ENDIF.
    ENDDO.

    IT_TAB2-VEND = IT_TAB2-VEND + 1.

      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
        EXPORTING
          INPUT  = IT_TAB2-VEND
        IMPORTING
          OUTPUT = IT_TAB2-VEND.

    IF IT_TAB2-VEND > IT_TAB1-VEND_TO.
      EXIT.
    ENDIF.
  ENDDO.
ENDLOOP.

SORT IT_TAB2 BY VEND.

LOOP AT IT_TAB2.
  WRITE: / IT_TAB2-VEND, IT_TAB2-ACCT.
ENDLOOP.
Share
10 |10000 characters needed characters left characters exceeded