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: 

alternative of "into corresponding fields of table"

Former Member
0 Kudos
1,936

Hi guys,

I have sth like this:

SELECT A B C

FROM DBTAB1 INTO CORRESPONDING FIELDS OF TABLE ITAB2

for all entries in ITAB1

WHERE xxxxx.

I know into corresponding is not the most efficient way. How do I rectify this in this case?

Thanks!

1 ACCEPTED SOLUTION

Former Member
0 Kudos
238

Define table ITAB2 with the three fields A, B and C of table DBTAB1 as the first fields (there may be any fields right to these 3).

Then your statement would be:

SELECT A B C

FROM DBTAB1 INTO TABLE ITAB2

for all entries in ITAB1

WHERE xxxxx.

Regards,

John.

7 REPLIES 7

Former Member
0 Kudos
239

Define table ITAB2 with the three fields A, B and C of table DBTAB1 as the first fields (there may be any fields right to these 3).

Then your statement would be:

SELECT A B C

FROM DBTAB1 INTO TABLE ITAB2

for all entries in ITAB1

WHERE xxxxx.

Regards,

John.

Former Member
0 Kudos
238

Hi,

use the following statement.

SELECT A B C

FROM DBTAB1

I NTO TABLE ITAB2

for all entries in ITAB1

WHERE xxxxx.

ITAB1 and ITAB2 should be of same structure.

Regards,

Jaya Vani

0 Kudos
238

Thanks.

What if my ITAB2 has more fields than ITAB1?

0 Kudos
238

"ITAB1 and ITAB2 should be of same structure."

What???

Former Member
0 Kudos
238

Hi,

Take the help of below code.

 TYPES: BEGIN OF typ_docln,
       belnr TYPE faglflexa-belnr,
       docln TYPE faglflexa-docln,
       racct TYPE faglflexa-racct,
       ryear TYPE faglflexa-ryear,
       poper TYPE faglflexa-poper,
       END OF typ_docln.

TYPES: BEGIN OF typ_faglflexa,
                       belnr TYPE faglflexa-belnr,
                       docln TYPE faglflexa-docln,
                       buzei TYPE faglflexa-buzei,
                       budat TYPE faglflexa-budat,
                       bschl TYPE faglflexa-bschl,
                       racct TYPE faglflexa-racct,
                       zzmpmfamil TYPE faglflexa-zzmpmfamil,
                       zzmpmprodu TYPE faglflexa-zzmpmprodu,
                       zzmpmissue TYPE faglflexa-zzmpmissue,
                       zzwerks TYPE faglflexa-zzwerks,
                       tsl TYPE faglflexa-tsl,
                       runit TYPE faglflexa-runit,
                    END OF typ_faglflexa.

DATA:  gt_faglflexa TYPE STANDARD TABLE OF typ_faglflexa,
         gs_faglflexa LIKE LINE OF gt_faglflexa,
  gt_docln TYPE STANDARD TABLE OF typ_docln,
      gs_docln LIKE LINE OF gt_docln.

SELECT  belnr
          docln
          racct
          ryear
          poper
  INTO TABLE gt_docln
  FROM faglflexa
  WHERE racct IN s_actno.

IF  NOT gt_docln IS INITIAL.

SELECT belnr
             docln
             buzei
             budat
             bschl
             racct
             zzmpmfamil
             zzmpmprodu
             zzmpmissue
             zzwerks
             tsl
             runit
       FROM faglflexa
       INTO TABLE gt_faglflexa
       FOR ALL ENTRIES IN gt_docln
       WHERE  belnr = gt_docln-belnr AND
              racct = gt_docln-racct AND
               rbukrs IN s_cocode  AND
               docln = gt_docln-docln AND
               rldnr  =  '0L'  AND
               zzmpmfamil IN s_mpmfam. 
ENDIF.

If the structure of itab1 and itab2 differ no probs, ie ur itab2 is having more fileds than itab1 , it will work

This will surely work.

plz reward if useful.

thanks,

dhanashri.

Edited by: Dhanashri Pawar on Jun 26, 2008 11:32 AM

Former Member
0 Kudos
238

hiii

simply use INTO TABLE ITAB..it will get data from dbtab for those fields only which is having same fields in internal table.so no need to use into corresponding...

regards

twinkal

Former Member
0 Kudos
238

Hi Bin Wang,

If you select only field A, B, C from the database table then you have to create your itab2 structure only field A, B, C.

Since now the structure of the itab2 is the same as the fields that you select, you can remove the corresponding syntax.

SELECT A B C

FROM DBTAB1 INTO TABLE ITAB2

for all entries in ITAB1

WHERE xxxxx.

Hopefully give you an idea.

Thanks,

Victor.