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: 

select x x from Z appending table ITAB

Former Member
0 Kudos

Hi all,

SELECT bukrs

hkont

gjahr

belnr

FROM bsis

INTO TABLE itab

WHERE bukrs EQ p_bukrs.

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

SELECT bukrs

hkont

gjahr

belnr

budat

bldat

xblnr

wrbtr

FROM bsas

APPENDING TABLE itab

WHERE bukrs EQ p_bukrs.

what is this second select statement. I have checked the ITAB. in both the select statements ITAB Data is same ?

then why we are using this select ?

Thanks in advance

krupali.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Suppose in first select statement 20 records are selected in table 'itab' from table 'bsis'.

And you want to add further rows in table 'itab' from table 'bsas' then you have to use this second select ( using APPENDING TABLE itab)....

Check sy-subrc of the second select statement....it should be 4 as no data r getting selected...

Regards

Debarshi

5 REPLIES 5

Former Member
0 Kudos

Hi,

Suppose in first select statement 20 records are selected in table 'itab' from table 'bsis'.

And you want to add further rows in table 'itab' from table 'bsas' then you have to use this second select ( using APPENDING TABLE itab)....

Check sy-subrc of the second select statement....it should be 4 as no data r getting selected...

Regards

Debarshi

Former Member
0 Kudos

Hi,

I assume you checked only the first few lines and concluded that it will be the same...

See this is what happens..

In your first select statement data is selected from BSIS table in put into your itab based on bukrs....

In your second statement a few more records from a different table are selected based on BUKRS and are APPENDED at the end of the internal table.

So if you see the first few records it will be same after both operations have been performed.

Best thing is to check for the number of entries after both these operations have been performed... To further take this.... after each operation has been performed, download the table contents into an excel sheet and compare.

Regards,

Pramod

Former Member
0 Kudos

Hi,

Try Executing the below select stmts in the same program in debugging . You will find the difference.

SELECT bukrs
hkont
gjahr
belnr
FROM bsis
INTO TABLE itab
WHERE bukrs EQ p_bukrs.

SELECT bukrs
hkont
gjahr
belnr
FROM bsis
APPENDING TABLE itab
WHERE bukrs EQ p_bukrs.

Regards,

Former Member
0 Kudos

Hi,

You will know the difference if you run and check the values of the itabs on break-points.

SELECT bukrs
          hkont
          gjahr
          belnr
      FROM bsis
     INTO TABLE itab
    WHERE bukrs EQ p_bukrs.

  
 SELECT bukrs
          hkont
          gjahr
          belnr
          budat
          bldat
          xblnr
          wrbtr
     FROM bsas
     APPENDING TABLE itab1
 WHERE bukrs EQ p_bukrs.

Break-point.

 SELECT bukrs
          hkont
          gjahr
          belnr
      FROM bsis
     INTO TABLE itab
    WHERE bukrs EQ p_bukrs.

  
 SELECT bukrs
          hkont
          gjahr
          belnr
          budat
          bldat
          xblnr
          wrbtr
     FROM bsas
     APPENDING TABLE itab1
 WHERE bukrs EQ p_bukrs.

Break-point.

After the second select statements, if the result per select is 10 records then itab will have 10 records and itab1 will have 20 records.

Regards

Karthik D

Former Member
0 Kudos

Hi,

excute the program with first select statement(comment 2nd select statement) . Next time comment 1st select statement(uncomment the 2nd select statement) and see the difference of output.

PARAMETERS: p_bukrs LIKE bsis-bukrs.

TYPES: BEGIN OF ty_tab,

bukrs TYPE bsis-bukrs,

hkont TYPE bsis-hkont,

gjahr TYPE bsis-gjahr,

belnr TYPE bsis-belnr,

END OF ty_tab.

DATA: itab TYPE TABLE OF ty_tab,

wa TYPE ty_tab.

wa-bukrs = '0001'.

wa-hkont = '10000'.

wa-gjahr = '2008'.

append wa to itab.

SELECT bukrs

hkont

gjahr

belnr

FROM bsis INTO TABLE itab

WHERE bukrs EQ p_bukrs.

*SELECT bukrs

  • hkont

  • gjahr

  • belnr

  • FROM bsis

*APPENDING TABLE itab

*WHERE bukrs EQ p_bukrs.

loop at itab into wa.

write:/ wa-bukrs, wa-hkont,wa-gjahr,wa-belnr.

endloop.

Regards,

Suresh.