메뉴 건너뛰기

SAP 한국 커뮤니티

How to read same field from D.Base into two fields of ITAB

sapjoy 2006.12.12 21:16 조회 수 : 3690 추천:44

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.