Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

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

Former Member
0 Kudos


REPORT  Z_EMPL_PERSONAL.

TABLES : zemployees , zpersonal_detail.

TYPESBEGIN 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"  )

12 REPLIES 12

VenkatRamesh_V
Active Contributor
0 Kudos

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.

0 Kudos

hi , venkat


error occures over here


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

regards.

0 Kudos

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.

former_member183607
Contributor
0 Kudos

Hi Yash,

     U have forgot to add word Table in both Select Query

     into corresponding fields of table

    

Regards:

Somendra

0 Kudos

hey ,

thanks a lot!

former_member182915
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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

0 Kudos

SELECT */<f1>, <f2>....... FROM <DBTABLE> INTO COREESPONDING FIELDS OF

     TABLE      it_details1/it_details2/it_details3.....

is the correct syntax.    

0 Kudos

Hi Ranjana,

Seems like you addressed the wrong person.

Regards,

Kannan

0 Kudos

sorry Kannan..

i'll repost it.

Thanks.

0 Kudos

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

is the correct syntax.

0 Kudos

thanks..!