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: 

Update itab from an other one.

Former Member
0 Kudos
106

Hi,

I have two itab (itab1 and itab2) like

itab1 : (link to content of bkpf)

belnr

budat

bldat

itab2 : (linked to content of bseg finally)

belnr

budat

bldat

hkont

dmbtr

wrbtr

Itab1 is filling first by a select on bkpf according my selection-option like (due to cannot join between BKPF and BSEG)

SELECT * INTO CORRESPONDING FIELDS OF TABLE itab1

FROM bkpf WHERE bukrs IN s_bukrs

AND budat IN s_date

AND gjahr IN s_gjahr.

Itab2 is filling by the content of bseg and content of itab1 like :

SELECT * APPENDING CORRESPONDING FIELDS OF TABLE itab2

FROM bseg FOR ALL ENTRIES IN itab1

WHERE bukrs = t_bkpf-bukrs

AND belnr = itab1-belnr

AND gjahr = itab1-gjahr.

All is inserted correclty inside itab2 according the content of bseg and entries onb itab1.. but on itab2 field budat and bldat

are empty (logic..)

How to update (during my second select ? or after ?) itab2-budat/bldat from itab1 (without loop ?)

Thnx.

4 REPLIES 4

ravi_lanjewar
Contributor
0 Kudos
74

Hi,

loop at itab1.

SELECT * APPENDING CORRESPONDING FIELDS OF wa_itab2

FROM bseg

WHERE bukrs = itab1-bukrs

AND belnr = itab1-belnr

AND gjahr = itab1-gjahr.

check sy-subrc eq 0.

  • append data to your table

endselect.

endloop.

but above logic is give low performance.

another way you can apply join on both table.

Edited by: Ravishankar Lanjewar on May 25, 2010 4:50 PM

Former Member
0 Kudos
74

Dont think its possible to do without a loop. After the second select you can do this

sort itab2 by belnr.

loop at itab2.

read table itab1 with key belnr = itab2-belnr BINARY SEARCH.

if sy-subrc = 0.

MOVE-CORRESPONDING itab1 to itab2.

modify itab2.

endif.

endloop.

Vikranth

former_member434229
Active Participant
0 Kudos
74

Hi,

There are two ways to achieve this.

1. Loop second table and read corresponding entry from the first table and update the table with the date fields.

2. Re-write your second select statement to get desired fields joining (INNER JOIN) two DB tables.

Regards,

Ni3

0 Kudos
74

Thx a lot for all propositions...

For the last one, it's not possible to join BSEG to BKPF otherwise i will do it since the begining.