SAP FI, CO, MM, PP, SD, PM, PS, QM, SM, HR, WF, BW, APO, Basis,  ABAP/4, Certification, Books
How to read same field from D.Base into two fields of ITAB

Can any one help in how can we read data into 2 fields(like VBELN, VBELN1) in internal table from data base table(VBAK) of one field(VBELN)?

EX:
data: begin of itab occurs 0,
        vbeln like vbak-vbeln,
        vbeln1 like vbak-vbeln,
        end of itab.

For this how can we write select statement.

----------------------------------------------------------------------------------------

You can write select statment as follows,

select single vbeln vbeln from vbak
    into (itab-vbeln, itab-vbeln1 )
    where <condition>.

----------------------------------------------------------------------------------------

Try the following code:

tables vbak.
data: begin of itab occurs 0,
                vbeln like vbak-vbeln,
                vbeln1 like vbak-vbeln,
        end of itab.

select vbeln vbeln from vbak into (itab-vbeln,itab-vbeln1) .
     append itab.
endselect.

loop at itab.
      write : / itab-vbeln, itab-vbeln1.
endloop.

----------------------------------------------------------------------------------------

One of the possible way, try this:

data: begin of itab1,
             banfn1 like eban-banfn,
             banfn2 like eban-banfn,
             rest(800),
        end of itab1.

select * into itab1 from eban.
      itab1-banfn2 = itab1-banfn1.
      write:/ 'banfn 1', itab1-banfn1, ' banfn 2', itab1-banfn2.
endselect.

----------------------------------------------------------------------------------------

This should be better:

TABLES vbak.

DATA: BEGIN OF itab OCCURS 0,
                     vbeln LIKE vbak-vbeln,
                     vbeln1 LIKE vbak-vbeln,
             END OF itab.

SELECT vbeln vbeln FROM vbak INTO table itab.
 
LOOP AT itab.
       WRITE : / itab-vbeln, itab-vbeln1.
ENDLOOP.

Return to :-
SAP Hints and Tips on Configuration and ABAP/4 Programming

(c) www.sap-basis-abap.com All material on this site is Copyright.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
All product names are trademarks of their respective companies.  The site www.sap-basis-abap.com is in no way affiliated with SAP AG.
Any unauthorised copying or mirroring is prohibited.