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

need help on Internal tables.

Hi All,

I am facing a problem in processing Internal Tables.

Suppose I have a list of PL ID’s in a table ZPL. I have a list of employees in another table ZEMP.

Name details in NAME Table.

ZPL

-


PL ID

PLEMPKEY

ZEMP

-


PLEMPKEY

EMP

NAME

-


ID

NAME

Output structure

-


PLID

EMP

EMPNAME

Now if user gives 4* as input parameter.

Then I need to retrieve all PL ID’s starting with 4 and for each pl id I need to show them the employees under him and also emp name.

First I have retrieved data from ZPL & ZEMP by joining these two tables using PLEMPKEY and stored the data in ITAB1.

Now to get the name I am reading Name table. By doubt is

ITAB1 Structure is similar to ouput structure and is PLID, EMP details are filled. EMP NAME is vacant after the query.

Can we write a select query against the table NAME

SELECT NAME INTO CORRESPONDING FIELDS OF ITAB1 FROM NAME

WHERE ID = ITAB1-PLID.

I tried it is not working. Is this not possible.

Merging internal tables.

One more thing, if I have an internal table ITAB1 with 4 fields f1,f2,f3,f4 and

ITAB2 with F3 F5 F6 F7

Now I need to move F2 value to f7 for all MATCHING F3 entries.

I tried this using Loop at ITAB1 and Read at ITAB2 and moved the needed fields to a new internal table.

My doubt is can we directly update itab2 f7 field.

Please pass on your suggestions.

Thanks,

Eureka.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Oct 18, 2006 at 05:04 AM

    SELECT NAME INTO CORRESPONDING FIELDS OF ITAB1 FROM NAME

    WHERE ID = ITAB1-PLID.

    You cannot write select query like this.

    Define another internal table ITAB_NAME of structure similar to NAME and then write select query as below:

    SELECT ID NAME INTO TABLE ITAB_NAME FROM NAME FOR ALL ENTRIES IN TABLE ITAB1

    WHERE ID = ITAB1-PLID.

    Here you will get names of all the employees.

    Sort ITAB1 by ID.

    SORT ITAB_NAME by ID.

    Loop at ITAB1 into WA_ITAB1.

    l_index = sy-tabix.

    read table ITAB_NAME into wa_itab_name

    with key id = wa_itab1-id.

    wa_itab1-id = wa_itab_name-id.

    modify itab1 from wa_itab1 index l_index.

    Endloop.

    I hope this will solve your problem.

    Best Regards,

    Vibha

    *Please mark all the helpful answers

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 18, 2006 at 04:45 AM

    u have to join all three table .

    then only u will get.

    <b>select zpl~plid

    zpl~plempkey

    zemp~emp

    name~name

    into corresponding fields of table itab

    from zpl innner join zemp on

    zpl-plempkey = zemp-plempkey

    inner join name on

    zpl-pl-id = name-id

    where zpl~plid = s_plid(selections) </b>

    Regards

    Prabhu

    no sytax checks please

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 18, 2006 at 04:53 AM

    Hi

    Hope this can give you some idea:

    select plid pleempkey name
           into table it_out
           from zpl as a 
           inner join zemp
           on a~plempkey = b~plempkey
           inner join name as c
           on a~plid = c~id
           where a~plid like '4%'.

    I guess PLID of table ZPL and ID of table NAME are same.

    If ID of Name is same as EMP of table ZEMP, you select query should be some thing like below.

    select plid pleempkey name
           into table it_out
           from zpl as a 
           inner join zemp
           on a~plempkey = b~plempkey
           inner join name as c
           on b~emp = c~id
           where a~plid like '4%'.

    Kind Regards

    Eswar

    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.