Skip to Content
author's profile photo
Former Member

Reading internal tables

Hi experts,

I have 2 internal tables i_sddoc, i_konv. In one internal table (i_sddoc) I have 10 rows with identical knumw and posnr.

I need to get the lines from the other internal table (i_konv), when 2 fields are the same (knumw and posnr). In i_konv there are multiply records with the same knumw and kposn.

I'm not allowed to use embedded loops because the table have a size category 4 with thousands of items. So have can I select the lines from i_konv?

If you have further question to be able to answer me, please let me know.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

5 Answers

  • Posted on Sep 28, 2007 at 07:43 AM

    Hi,

    Use this for ref...

    loop at i_sddoc.

    read table i_konv with key posnr = i_sddoc-posnr

    knumv = i_sddoc-knumv.

    if sy-subrc = 0.

        • do ur procvessing

        endif.

        endloop.

        reward if helpful,

        Karthik

        Add comment
        10|10000 characters needed characters exceeded

        • Former Member Former Member

          Hi White Stripes,

          Without embedded loop i do not think your requirement is possibel.

          For better performance you can use INDEX in your inner loop.

          SORT i_konv

          BY knumw

          posnr.

          LOOP AT i_sddoc

          INTO wa_sddoc.

          READ TABLE i_konv

          INTO wa_konv

          with key knumw = wa_sddoc-knumw

          AND posnr = wa_sddoc-posnr

          BINARY SEARCH.

          z_tabix = sy-tabix.

          loop at i_konv

          into wa_konv

          from z_index.

          APPEND wa_konv TO it_output.

          endloop.

          ENDLOOP.

      • author's profile photo
        Former Member
        Posted on Sep 28, 2007 at 07:43 AM

        Hi

        fetch the data from VBAK and VBAP into ITAB1

        Take the VBAK-KNUMV and VBAP-POSNR and pass to

        KONV-KNUMV and KONV-KPOSN and fetch the data from KONV

        and separate the data based on the required KSCHL field

        Regards

        Anji

        Add comment
        10|10000 characters needed characters exceeded

      • author's profile photo
        Former Member
        Posted on Sep 28, 2007 at 07:45 AM

        Refer the below code.

        SORT i_konv

        BY knumw

        posnr.

        LOOP AT i_sddoc

        INTO wa_sddoc.

        loop at i_konv

        into wa_konv.

        where knumw = wa_sddoc-knumw

        AND posnr = wa_sddoc-posnr.

        READ TABLE i_konv

        INTO wa_konv.

        APPEND wa_konv TO it_output.

        endloop.

        ENDLOOP.

        Check this code

        Regards,

        Mukesh Kumar

        Message was edited by:

        mukesh kumar

        Add comment
        10|10000 characters needed characters exceeded

      • Posted on Sep 28, 2007 at 08:08 AM

        I am sorry but have to be a bit harsh, so many answers not one which is useful!

        The last one is on the right track but still wrong:

        SORT i_konv BY knumw posnr.

        LOOP AT i_sddoc INTO wa_sddoc.

        READ TABLE i_konv INTO wa_konv

        with key knumw = wa_sddoc-knumw

        AND posnr = wa_sddoc-posnr

        BINARY SEARCH.

        z_tabix = sy-tabix.

        • the loop from index is the trick for several hits !!!

        loop at i_konv into wa_konv from z_index.

        • the exit is missing, then it will still loop half of the table !!!!!

        IF NOT ( wa_konv-knumw = wa_sddoc-knumw

        AND wa_konv-posnr = wa_sddoc-posnr ).

        EXIT.

        ENDIIF

        • there is a loop why another read ???

        • READ TABLE i_konv INTO wa_konv

        APPEND wa_konv TO it_output.

        ENDLOOP.

        ENDLOOP.

        For more information please read my recent blog:

        /people/siegfried.boes/blog/2007/09/12/runtimes-of-reads-and-loops-on-internal-tables

        > allowed to use embedded loops because the table have a size category 4

        internal table don't have size categories, if you have a lot of data, more than

        you can put into memory, then you must process in packages.

        But then you must take care, that both packages contain the lines which belong together.

        Siegfried

        Add comment
        10|10000 characters needed characters exceeded

      • author's profile photo
        Former Member
        Posted on Sep 28, 2007 at 08:51 AM

        The solution is the following. I have to sort all two tables according to knumv and posnr. Then I have to make a loop at konv, then read the table sddoc with key knumv and kposn. So Without sorting the 2 table it doesn't give right results.

        Add comment
        10|10000 characters needed characters exceeded