Application Development and Automation 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: 
Read only

ABAP Loop Correction to pick data in one line

Former Member
0 Likes
494

HI Friends. I want to insert the records in Table /BIC/AZDBREB_000, What I am Doing is I have data in table /BIC/AZDBREB_000 now I am loading some more data to this table /BIC/AZDBREB_000 from /BIC/AZDAREB_000 where ever Internal Number ZINTRENO in Table /BIC/AZDBREB_000 matches with table /BIC/AZDAREB_000 so that it comes in one line. Please help me modify the below <b>ABAP Code</b>.

First get the data from /BIC/AZDAREB_000 to internal table with condition ZINTRENO ( Do not write inner join )

now keep the loop /BIC/AZDAREB_000 ( Internal table ).

Now get the data from /BIC/AZDBREB into internal table.

append the data one more internal table.

endloop.

here insert the data

modify /BIC/AZDBREB from table int_table.

<b>ABAP Code below in start routine </b>

TABLES DATA_PACKAGE STRUCTURE DATA_PACKAGE.

DATA: l_s_dp_line TYPE data_package_structure.

types: begin of comp,

ZINTRENO type /BIC/AZDBREB_000-/BIC/ZINTRENO,

ZYEAR type /BIC/AZDBREB_000-/BIC/ZYEAR,

ZINSTYP type /BIC/AZDBREB_000-/BIC/ZINSTYP,

ZINSVAL type /BIC/AZDBREB_000-/BIC/ZINSVAL,

ZBBAUW13 type /BIC/AZDBREB_000-/BIC/ZBBAUW13,

REOBJECT type /BIC/AZDAREB_000-REOBJECT,

BUSENTITY type /BIC/AZDAREB_000-BUSENTITY,

end of comp.

Data: l_s_comp type comp.

Statics: l_th_comp type hashed table of comp with unique key ZINTRENO.

If l_th_comp{} is initial.

SELECT * from /BIC/AZDBREB_000 appending CORRESPONDING FIELDS OF table l_th_comp.

endif.

Loop at DATA_PACKAGE INTO l_s_dp_line

Read table l_th_comp into l_s_comp with table key ZINTRENO = l_s_dp_line-zintreno.

If sy-subrc = 0.

L_s_dp_line-/BIC/REOBJECT = l_s_comp-/BIC/REOBJECT.

L_s_dp_line-/BIC/ BUSENTITY = l_s_comp-/BIC/ BUSENTITY.

MODIFY DATA_PACKAGE from l_s_dp_line

endif.

Endloop.

Please send me email at soniyakv@hotmail.com if you have any detail ABAP code.

Thanks

Soniya Kapoor

3 REPLIES 3
Read only

sreenivasa_reddy1
Participant
0 Likes
452

1)Select the data from /BIC/AZDAREB_000 into---->it_AREB

2)

if not it_areb is initial

after that select the data from /BIC/AZDBREB into some -


>it_BREB

for all entries in it_AREB

where ZINTRENO = it_areb-ZINTRENO.

now u will have matching data in it_breb from both tables.

loop it_breb into wa_breb.

modify /BIC/AZDAREB_000 from wa_breb.

endloop.

Hope this will help you.

Award points if its useful.

Regards

Sreenivasa Reddy

Read only

0 Likes
452

Hi Sreenivasa, I did the code below as per your recommendation can you 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.

Read only

sreenivasa_reddy1
Participant
0 Likes
452

Please check this ,, I have commeneted some unnecessary code

REPORT ZTEST_GM.

FIELD-SYMBOLS:

<SOURCE_FIELDS> TYPE any.

*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.

*****Is for all entries is required here ?

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

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

**Select all without any condition

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

if not itab[] is initial.

select * from /BIC/AZDBREB_000 into table itab_b

for all entries in itab where /BIC/ZINTRENO = itab-/BIC/ZINTRENO.

*****Now the internal table itab_b contains common entries

endif.

loop at itab_b into wa_b.

modify /BIC/AZDBREB_000 from wa_zdtg.

endloop.

*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.