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: 

Simple Logic to merge two tables

Former Member
0 Kudos
91

Hi Friends I did the code below as per SDN recommendation but data is not coming in one line for all fields it is appending the fields that are updated from second table Please help me fix my code so that it works

METHOD start_routine.

*=== Segments ===

FIELD-SYMBOLS:

<SOURCE_FIELDS> TYPE tys_SC_1.

DATA:

MONITOR_REC TYPE rstmonitor.

$$ begin of routine - insert your code only below this line -

... "insert your code here

types: begin of tp_itab,

ZINTRENO type /BIC/AZDAREB_000-/BIC/ZINTRENO,

*ZYEAR type /BIC/AZDAREB_000-/BIC/ZYEAR,

*ZINSTYP type /BIC/AZDAREB_000-/BIC/ZINSTYP,

*ZINSVAL type /BIC/AZDAREB_000-/BIC/ZINSVAL,

*ZBBAUW13 type /BIC/AZDAREB_000-/BIC/ZBBAUW13,

*

REOBJECT type /BIC/AZDAREB_000-REOBJECT,

COMP_CODE type /BIC/AZDAREB_000-COMP_CODE,

BUSENTITY type /BIC/AZDAREB_000-BUSENTITY,

BUILD_TYPE type /BIC/AZDAREB_000-BUILD_TYPE,

MAINUSAGE type /BIC/AZDAREB_000-MAINUSAGE,

ZOWNSTAT type /BIC/AZDAREB_000-/BIC/ZOWNSTAT,

ASSDVALUE type /BIC/AZDAREB_000-ASSDVALUE,

BLDG_VAL type /BIC/AZDAREB_000-BLDG_VAL,

INSUREVAL type /BIC/AZDAREB_000-INSUREVAL,

COUNTRY type /BIC/AZDAREB_000-COUNTRY,

REGION type /BIC/AZDAREB_000-REGION,

PROFIT_CTR type /BIC/AZDAREB_000-PROFIT_CTR,

CO_AREA type /BIC/AZDAREB_000-CO_AREA,

end of tp_itab.

types: begin of typ_tgl.

include type /BIC/AZDBREB_000.

types: end of typ_tgl.

DATA:ITAB_Z TYPE STANDARD TABLE OF typ_tgl with key /BIC/ZINTRENO.

data: itab type table of tp_itab with key ZINTRENO.

data: zgltab type table of tp_itab with key ZINTRENO.

data: wa_itab type tp_itab.

data: wa_zdtg type typ_tgl.

select * from /BIC/AZDAREB_000 INTO CORRESPONDING FIELDS OF TABLE ITAB

FOR ALL ENTRIES IN ITAB_Z WHERE /BIC/ZINTRENO = ITAB_Z-/BIC/ZINTRENO.

loop at itab into wa_itab.

select * from /BIC/AZDBREB_000 into wa_zdtg where /BIC/ZINTRENO eq

wa_zdtg-/BIC/ZINTRENO.

if sy-subrc = 0.

wa_zdtg-/BIC/ZINTRENO = wa_itab-zintreno.

  • wa_zdtg-/bic/zyear = wa_itab-zyear.

  • wa_zdtg-/BIC/ZINSTYP = wa_itab-ZINSTYP.

  • wa_zdtg-/BIC/ZINSVAL = wa_itab-ZINSVAL.

  • wa_zdtg-/BIC/ZBBAUW13 = wa_itab-ZBBAUW13.

wa_zdtg-REOBJECT = wa_itab-REOBJECT.

wa_zdtg-COMP_CODE = wa_itab-COMP_CODE.

wa_zdtg-BUSENTITY = wa_itab-BUSENTITY.

wa_zdtg-BUILD_TYPE = wa_itab-BUILD_TYPE.

wa_zdtg-MAINUSAGE = wa_itab-MAINUSAGE.

wa_zdtg-/BIC/ZOWNSTAT = wa_itab-ZOWNSTAT.

wa_zdtg-ASSDVALUE = wa_itab-ASSDVALUE.

wa_zdtg-BLDG_VAL = wa_itab-BLDG_VAL.

wa_zdtg-INSUREVAL = wa_itab-INSUREVAL.

wa_zdtg-COUNTRY = wa_itab-COUNTRY.

wa_zdtg-REGION = wa_itab-REGION.

wa_zdtg-PROFIT_CTR = wa_itab-PROFIT_CTR.

wa_zdtg-CO_AREA = wa_itab-CO_AREA.

*append wa_zdtg to /BIC/AZDBREB_000

modify /BIC/AZDBREB_000 from wa_zdtg.

endif.

endselect.

endloop.

Thanks

2 REPLIES 2

dev_parbutteea
Active Contributor
0 Kudos
65

Hi,

select * from /BIC/AZDAREB_000

INTO CORRESPONDING FIELDS OF TABLE ITAB

FOR ALL ENTRIES IN ITAB_Z

WHERE /BIC/ZINTRENO = ITAB_Z-/BIC/ZINTRENO.

loop at itab into wa_itab.

select * from /BIC/AZDBREB_000 into wa_zdtg where /BIC/ZINTRENO eq

wa_zdtg-/BIC/ZINTRENO.

<b>put:

read table ITAB_Z

with key /BIC/ZINTRENO = wa_itab-/BIC/ZINTRENO

into wa_zdtg.</b>

if sy-subrc = 0.

<b>.

.

.</b>

Regards,

Sooness.

0 Kudos
65

Hi,

correction:

select * from /BIC/AZDAREB_000

INTO CORRESPONDING FIELDS OF TABLE ITAB

FOR ALL ENTRIES IN ITAB_Z

WHERE /BIC/ZINTRENO = ITAB_Z-/BIC/ZINTRENO.

<b>sort ITAB_Z by /BIC/ZINTRENO.</b>

loop at itab into wa_itab.

select * from /BIC/AZDBREB_000 into wa_zdtg where /BIC/ZINTRENO eq

wa_zdtg-/BIC/ZINTRENO.

put:

read table ITAB_Z

with key /BIC/ZINTRENO = wa_itab-/BIC/ZINTRENO

into wa_zdtg

<b>binary search</b>.

if sy-subrc = 0.

.

.

.

Regards,

Sooness.