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

error:You cannot use an internal table as a work area


REPORT Z_EMPL_PERSONAL.

TABLES : zemployees , zpersonal_detail.

TYPES: BEGIN OF ty_details1,
employee TYPE zemployees-employee,
title TYPE zemployees-title,
forename TYPE zemployees-forename,
surname TYPE zemployees-surname,
gender TYPE zemployees-gender,
salary TYPE zemployees-salary,
END OF ty_details1,

BEGIN OF ty_details2,
employee TYPE zemployees-employee,
address2 TYPE zpersonal_detail-address2,
address3 TYPE zpersonal_detail-address3,
email TYPE zpersonal_detail-email,
contact TYPE zpersonal_detail-contact,
END OF ty_details2,

BEGIN OF ty_details3,
employee TYPE zemployees-employee,
title TYPE zemployees-title,
forename TYPE zemployees-forename,
surname TYPE zemployees-surname,
gender TYPE zemployees-gender,
salary TYPE zemployees-salary,
address2 TYPE zpersonal_detail-address2,
address3 TYPE zpersonal_detail-address3,
email TYPE zpersonal_detail-email,
contact TYPE zpersonal_detail-contact,
END OF ty_details3.


DATA: it_details1 TYPE TABLE OF ty_details1,
wa_details1 TYPE ty_details1,
it_details2 TYPE TABLE OF ty_details2,
wa_details2 TYPE ty_details2,
it_details3 TYPE TABLE OF ty_details3,
wa_details3 TYPE ty_details3.


SELECT-OPTIONS s_Emplye for zemployees-employee.

IF sy-subrc = 0.


SELECT employee title forename surname gender salary
from zemployees
into corresponding fields of it_details1
where zemployees-employee in s_Emplye.


select employee address2 address3 email contact
from zpersonal_detail
into corresponding fields of it_details2
FOR ALL ENTRIES IN it_details1
WHERE employee = zemployees-employee.
ENDIF.


LOOP AT it_details1 INTO wa_details1.
READ TABLE it_details2 into wa_details2 with KEY employee = wa_details1-employee.
IF sy-subrc = 0.
MOVE wa_details2-employee to wa_details3-employee .
MOVE wa_details2-address2 to wa_details3-address2.
MOVE wa_details2-address3 to wa_details3-address3.
MOVE wa_details2-email to wa_details3-email.
MOVE wa_details2-contact to wa_details3-contact.
ENDIF.

move wa_details1-title to wa_details3-title.
move wa_details1-forename to wa_details3-forename.
move wa_details1-surname to wa_details3-surname.
move wa_details1-gender to wa_details3-gender.
move wa_details1-salary to wa_details3-salary.

append wa_details3 to it_details3.

ENDLOOP.

LOOP AT it_details3 to wa_details3.
write: / wa_details2-employee,
wa_details3-title,
wa_details3-forename,
wa_details3-surname,
wa_details3-gender,
wa_details3-salary,
wa_details3-address2,
wa_details3-address3,
wa_details3-email,
wa_details3-contact.

ENDLOOP.

this program gives errors on select statement ( " You cannot use an internal table as a work area" )

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jul 20, 2014 at 06:15 PM

    Hi Shah,

    Replace your code like this.

    Understand you are using For all entries for fetching the respective details from second table not any details.

    SELECT employee title forename surname gender salary

    from zemployees

    into corresponding fields of table it_details1

    where zemployees-employee in s_Emplye.


    If you are using For all entries ensure sy-Subrc check.


    If sy-surc eq 0.


    select employee address2 address3 email contact

    from zpersonal_detail

    into corresponding fields of table it_details2

    FOR ALL ENTRIES IN it_details1

    WHERE employee = zemployees-employee it_details1-employee.


    Endif.

    Tip 😊 --> you can for inner joins as it can joins two tables in single select.Remember to add table in front of internal tables so that it can accommodate more values.

    If you specifically want only first record use Select single and pass it to work area in your select query.

    Hope it will make it clear for you. 😊

    Regards,

    Kannan

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 19, 2014 at 10:48 AM

    Hi Yash,

    Change the Syntex in the last loop.

    LOOP AT it_details3 into wa_details3.
    write: / wa_details3-employee,
    wa_details3-title,
    wa_details3-forename,
    wa_details3-surname,
    wa_details3-gender,
    wa_details3-salary,
    wa_details3-address2,
    wa_details3-address3,
    wa_details3-email,
    wa_details3-contact.

    ENDLOOP.


    Regards,

    Venkat.

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi Yash,

      Change your code for this one:

      SELECT employee title forename surname gender salary

      from zemployees

      into corresponding fields of TABLE it_details1

      where zemployees-employee in s_Emplye.

      select employee address2 address3 email contact

      from zpersonal_detail

      into corresponding fields of TABLE it_details2

      FOR ALL ENTRIES IN it_details1

      WHERE employee = zemployees-employee.

      Best regards.

  • Posted on Jul 19, 2014 at 10:57 AM

    Hi Yash,

    U have forgot to add word Table in both Select Query

    into corresponding fields of table

    Regards:

    Somendra

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 19, 2014 at 11:12 AM

    Hello Abaper,

    you can not use a workarea as table so this error comes.

    before table name use table key word.

    As in work area it hold only record at a time but as per select query more than one record should hold.

    hope this help you

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 20, 2014 at 07:09 PM

    Select * FROM <DBTABLE> INTO CORRESPONDING FIELD OF TABLE it_details1....

    is the correct syntax.

    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.