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: 

header is getting over write

Former Member
0 Kudos

hi friends,

in internal table header entries are coming properly

but next time that entries are getting over written by

another entry and last record value is repeated in all

values.

what is the pboblem can any one give me solution.

thanks

10 REPLIES 10

Former Member
0 Kudos

if u loop at internal table everytime the loop is processed ...header will be populated with the current record.....that is index sy-tabix.

if itab has 5 records....

if u loop at itab....

first time ( sy-tabix = 1) header will be populated with 1 st record ....next with 2 and so on....

so header will be overwritten....

and finally at the end of loop......the last populated record..i.e last record will be stored in header....

Regards

vasu

Former Member
0 Kudos

can u pls paste ur code if possible

0 Kudos

itab[] = ibsis[].

sort itab by belnr.

DELETE ADJACENT DUPLICATES FROM itab COMPARING belnr.

DATA:indx LIKE sy-tabix.

LOOP AT itab.

indx = sy-tabix.

LOOP AT ibsis WHERE xblnr = itab-xblnr.

CASE ibsis-hkont.

WHEN '0030100244'.

MOVE ibsis-dmbtr TO itab-entr.

WHEN '0030100227'.

MOVE ibsis-dmbtr TO itab-load.

WHEN '0030100167'.

MOVE ibsis-dmbtr TO itab-ful.

WHEN '0030100200'.

MOVE ibsis-dmbtr TO itab-othr.

WHEN '0030100206'.

MOVE ibsis-dmbtr TO itab-park.

WHEN '0030100182'.

MOVE ibsis-dmbtr TO itab-kata.

WHEN '0030100221'.

MOVE ibsis-dmbtr TO itab-rto.

WHEN '0030100229'.

MOVE ibsis-dmbtr TO itab-spar.

WHEN '0030100266'.

MOVE ibsis-dmbtr TO itab-tyr.

WHEN '0030100199'.

MOVE ibsis-dmbtr TO itab-octr.

WHEN '0030100239'.

MOVE ibsis-dmbtr TO itab-toll.

WHEN '0030100165'.

MOVE ibsis-dmbtr TO itab-fret.

WHEN '0030100163'.

MOVE ibsis-dmbtr TO itab-cran.

WHEN '0030100250'.

MOVE ibsis-dmbtr TO itab-wegh.

ENDCASE.

MODIFY itab INDEX indx.

ENDLOOP.

CLEAR: itab,ibsis.

ENDLOOP.

DATA: index1 TYPE sy-tabix.

sort it_final by belnr.

LOOP AT it_final.

index1 = sy-tabix.

READ TABLE itab WITH KEY xblnr = it_final-xblnr.

MOVE itab-entr TO it_final-entr.

MOVE itab-load TO it_final-load.

MOVE itab-ful TO it_final-ful.

MOVE itab-othr TO it_final-othr.

MOVE itab-park TO it_final-park.

MOVE itab-kata TO it_final-kata.

MOVE itab-rto TO it_final-rto.

MOVE itab-spar TO it_final-spar.

MOVE itab-tyr TO it_final-tyr.

MOVE itab-octr TO it_final-octr.

MOVE itab-toll TO it_final-toll.

MOVE itab-fret TO it_final-fret.

MOVE itab-cran TO it_final-cran.

MOVE itab-wegh TO it_final-wegh.

MODIFY it_final INDEX index1.

it_final-rev = it_final-rev + it_final-entr + it_final-load +

it_final-ful + it_final-othr + it_final-park +

it_final-kata + it_final-spar + it_final-tyr +

it_final-octr + it_final-toll + it_final-rto +

it_final-fret + it_final-cran + it_final-wegh.

it_final-ptrf = it_final-tot - it_final-rev.

MODIFY it_final INDEX index1.

CLEAR: it_final.

ENDLOOP.

0 Kudos

Sonu,

Clear Internal Table after every modify statement.

Reward if it helps,

Satish

Former Member
0 Kudos

use this <b>REFRESH <itab>.</b>

Former Member
0 Kudos

Seee ur question is not clear

There are many chances...

From where u r getting values for that internal table,either u r getting from queries or hardcoding etc.,

May be the append will not be used properly in the code..Can u tell claerly means it will very effective

former_member223537
Active Contributor
0 Kudos

itab[] = ibsis[].
sort itab by belnr.

DELETE ADJACENT DUPLICATES FROM itab COMPARING belnr.
DATA:indx LIKE sy-tabix.
LOOP AT itab.

indx = sy-tabix.
LOOP AT ibsis WHERE xblnr = itab-xblnr.

CASE ibsis-hkont.
WHEN '0030100244'.
MOVE ibsis-dmbtr TO itab-entr.

WHEN '0030100227'.
MOVE ibsis-dmbtr TO itab-load.

WHEN '0030100167'.
MOVE ibsis-dmbtr TO itab-ful.

WHEN '0030100200'.
MOVE ibsis-dmbtr TO itab-othr.

WHEN '0030100206'.
MOVE ibsis-dmbtr TO itab-park.

WHEN '0030100182'.
MOVE ibsis-dmbtr TO itab-kata.

WHEN '0030100221'.
MOVE ibsis-dmbtr TO itab-rto.

WHEN '0030100229'.
MOVE ibsis-dmbtr TO itab-spar.

WHEN '0030100266'.
MOVE ibsis-dmbtr TO itab-tyr.

WHEN '0030100199'.
MOVE ibsis-dmbtr TO itab-octr.

WHEN '0030100239'.
MOVE ibsis-dmbtr TO itab-toll.

WHEN '0030100165'.
MOVE ibsis-dmbtr TO itab-fret.

WHEN '0030100163'.
MOVE ibsis-dmbtr TO itab-cran.
WHEN '0030100250'.
MOVE ibsis-dmbtr TO itab-wegh.

ENDCASE.
* MODIFY itab INDEX indx. " COmment this

ENDLOOP.

MODIFY itab INDEX indx. "Add this 
CLEAR: itab,ibsis.
ENDLOOP.

DATA: index1 TYPE sy-tabix.
sort it_final by belnr.
LOOP AT it_final.

index1 = sy-tabix.
READ TABLE itab WITH KEY xblnr = it_final-xblnr.
MOVE itab-entr TO it_final-entr.
MOVE itab-load TO it_final-load.
MOVE itab-ful TO it_final-ful.
MOVE itab-othr TO it_final-othr.
MOVE itab-park TO it_final-park.
MOVE itab-kata TO it_final-kata.
MOVE itab-rto TO it_final-rto.
MOVE itab-spar TO it_final-spar.
MOVE itab-tyr TO it_final-tyr.
MOVE itab-octr TO it_final-octr.
MOVE itab-toll TO it_final-toll.
MOVE itab-fret TO it_final-fret.
MOVE itab-cran TO it_final-cran.
MOVE itab-wegh TO it_final-wegh.

* MODIFY it_final INDEX index1. " Comment this line

it_final-rev = it_final-rev + it_final-entr + it_final-load +
it_final-ful + it_final-othr + it_final-park +
it_final-kata + it_final-spar + it_final-tyr +
it_final-octr + it_final-toll + it_final-rto +
it_final-fret + it_final-cran + it_final-wegh.

it_final-ptrf = it_final-tot - it_final-rev.
MODIFY it_final INDEX index1.
CLEAR: it_final.
ENDLOOP. 

0 Kudos

hi prashant

now it is getting overwritten in header it self.

i have to use clear statement for that.

thanks

Former Member
0 Kudos

HI,

The data after u r inserting in the internal tables,it is not made clear..So only it remains with the same error it seems

Former Member
0 Kudos

Hi Sonu,

Please use<b> Clear</b> before endloop.

reward points if useful.

Regards,

SHilpi