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.

See Also:
Help on Conversion From Numbers to Text Amount

More Function Module
Functions / SAP Script / ALV

Tables
Database Table

ABAP Books List
ABAP/4 Certification, Programming, Smartforms, Sapscripts and Object Oriented Programming Books

Smart Forms
SAP Smartforms

ABAP Menu:
ABAP Example Hints and Tips

Return to Index:-
SAP ABAP/4 Programming, Basis Administration, Configuration Hints and Tips

(c) www.gotothings.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.gotothings.com is in no way affiliated with SAP AG.
Any unauthorised copying or mirroring is prohibited.