Skip to Content
author's profile photo Former Member
Former Member

Internal table

I want to select recirds from internal table for all enteries of records in another internal table.

How can i do this?

Add comment
10|10000 characters needed characters exceeded

8 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Aug 03, 2006 at 09:39 AM

    loop at itab1.

    read table itab2 binary searh with key field1 = itab1-field1.

    itab2-field2 - itab1-field2.

    ...

    ...

    endloop.

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 03, 2006 at 09:38 AM

    hi do it in this way i.e, using for all entries statement

      select ba~ba_ba_no
             ba~ba_seq_no
             ba~ba_nm_1
             into table t_sum
         from oiuh_cm_ba    as ba inner join
              oiucm_ba_link as balink
         on ba~ba_ba_no = balink~ba_no and
            ba~ba_seq_no = balink~ba_seq
         where ba~ba_ba_no IN s_own and
               balink~ba_type = 'V'.
    
    if not t_sum[] is initial.
      select a~opsl_gl_sys_no
             a~opsl_ck_no
             a~opsl_own_no
             a~opsl_own_seq_no
             b~gl_gl_sys_no
             b~gl_acct_no
             b~gl_pr_no
             b~gl_doi_no
             b~gl_sa_dt
             b~gl_acct_perd_dt
             b~gl_trans_am
         into table t_det3
         from oiuh_rv_opsl as a inner join
              oiuh_rv_gl   as b
         on a~opsl_gl_sys_no = b~gl_gl_sys_no
    <b>     for all entries in t_sum</b>
         where a~opsl_own_no = t_sum-ba_ba_no and
               a~opsl_own_seq_no = t_sum-ba_seq_no and
               b~gl_trans_am in s_dol.

    endif.

    Regards,

    Santosh

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 03, 2006 at 09:41 AM

    assume IT_MARA is the internal table of MARA details & my intension is to fetch Material descriptions from MAKT for all the materials in IT_MARA.

    select matnr

    maktx

    into table it_makt

    from makt

    for all entries in it_mara

    where matnr = it_mara-matnr

    and spras = sy-langu.

    regards

    srikanth

    Message was edited by: Srikanth Kidambi

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 03, 2006 at 09:43 AM

    Hi,

    consider 2 itabs.

    select f1 f2 from db1 into itab1 where .....

    sort itab1 by f1.

    delete adjacent duplicates from itab1.

    if not itab1[] is initial.

    select f1 f2 from db2 into table itab2

    FOR ALL ENTRIES IN ITAB1 where f1 = itab1-f1.

    endif.

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 03, 2006 at 09:43 AM

    Hi,

    ITAB1 -> Source Internal Table.

    ITAB2 -> Records to be selected.

    itab3 -> Records to be Moved.

    Loop at ITab1.

    read table itab2 with key Key1 = itab1-key . . .

    if sy-subrc = 0.

    itab3 = itab2.

    append itab3.

    else.

    Code.

    endif.

    endloop.

    There might be some Syntax error.

    This might help you. Hope!

    Regards,

    Prashanth

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 03, 2006 at 09:46 AM

    hi,

    Try this code...

    DATA: IT1 TYPE SPFLI OCCURS 0,
          IT2 TYPE SFLIGHT OCCURS 0.
    
    SELECT * FROM SPFLI INTO TABLE IT1.
    
    SELECT * FROM SFLIGHT FOR ALL ENTRIES OF IT1 INTO TABLE IT2.

    Regards:-

    Santosh.

    P.S. Mark usefull answers

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 03, 2006 at 10:05 AM

    hi

    tables: mara, marc.

    select-options s_matnr for mara-matnr.

    data:

    begin of itab occurs 0,

    matnr type mara-matnr,

    ersda type mara-ersda,

    ernam type mara-ernam,

    end of itab,

    begin of itab2 occurs 0,

    matnr type marc-matnr,

    werks type marc-werks,

    dispr type marc-dispr,

    end of itab2.

    select matnr ersda ernam from mara into table itab where matnr in

    s_matnr.

    if itab[] is not initial.

    select matnr werks dispr from marc into table itab2 for all entries in

    itab where

    matnr = itab-matnr.

    endif.

    Reward points if helpful.

    Regards

    Swathi

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 03, 2006 at 10:14 AM

    There is no direct statement which can help you to retrive the information in another internal table while you are processing the first internal table.

    The only soln is to

    Loop at A.

    --either use Read or loop.

    REad table b with keys

    check sy-subrc = 0.

    ---OR

    loop at b where a-fields = b-fields.

    process

    endloop.

    check sy-subrc = 0.

    endloop.

    Add comment
    10|10000 characters needed characters exceeded