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

internal table

hi experts,

i have three intrnal tables like itab1 ,itab2 . itab1 have EMPID, EMPNAME and Itab2 have EMPID ,EMPSAL. now i want to creat third internal table like ITAB3 with EMPID,EMPNAME,EMPSAL using itab1 itab2. it is urgent\

thanks in advance

radhakrishna

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Posted on Sep 09, 2007 at 07:34 AM

    Hi,

    loop at  itab1.
       read table itab2 with key empid = itab1-empid.
       if sy-subrc eq 0.
         move-corresponding itab1 to itab3.
         move-corresponding itab2 to itab3.
         append itab3.
       endif.
    endloop.
    
    

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Or, of course, to reverse a@s' logic:

      sort itab1 by empid.
      loop at itab2.
        clear: itab3.
        read table itab1
          with key empid = itab2-empid
          binary search.
        if sy-subrc is initial.
          move-corresponding itab1 to itab3.
          move-corresponding itab2 to itab3.
          append itab3.
        endif.
      endloop.

      One question - are both list unique on empid, or can someone have 2 salary records?

      Jonathan

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

    Hi,

    If you have multiple records against same empid in table itab2 then,

    loop at itab1.

    loop at itab2 where empid = itab1-empid.

    itab3-empid = itab1-empid.

    itab3-empname = itab1-empname.

    itab3-empsal = itab2-empsal.

    append itab3.

    endloop.

    endloop.

    Regards,

    Hema

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.