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

Not appending

Former Member
0 Likes
2,733

hi experts

i have strucked up with at End of usage in my report,

which i already posted and i have tried with another

way,

and its almost solved,,,,,only problem is that

Iam getting the output for the first liine alone rest its coming as 0.00 and 0.00

When i debugged ....the entire first loop is executed

and then it goes to the second loop aappending all values except my wa_final-gross and wa_final-net

i think i have gone somewhere wrong in loopin or i dont know where

please do help me out

My code

sort it_AMOUNT by belnr.

LOOP AT IT_AMOUNT INTO WA_AMOUNT.

If wa_AMOUNT-hkont = '0000500100'.

wa_final-gross = wa_amount-dmbtr.

eNDIF.

If wa_AMOUNT-koart = 'D'.

wa_final-net = wa_amount-dmbtr.

eNDIF .

Endloop.

loop at it_bseg into wa_bseg .

wa_final-kunnr = wa_bseg-kunnr.

wa_final-xref1 = wa_bseg-xref1.

wa_final-xref2 = wa_bseg-xref2.

read table it_bkpf into wa_bkpf with key belnr = wa_bseg-belnr.

if sy-subrc = 0.

wa_final-xblnr = wa_bkpf-xblnr.

wa_final-bldat = wa_bkpf-bldat.

endif.

At end of belnr.

WA_final-gross = wa_amount-gross.

wa_final-net = wa_amount-net.

Endat.

Clear wa_amount.

append wa_final to it_final.

clear wa_final.

Endloop.

OUTPUT

4552 13.07.2006 Entrepreneurshi Bharat 200,600.00 225,153.00

4552 13.07.2006 ge 0.00 0.00

4552 13.07.2006 test 0.00 0.00

;

;

;

;

;

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,693

write append statement into at end....endat

At end of belnr.

WA_final-gross = wa_amount-gross.

wa_final-net = wa_amount-net.

append wa_final to it_final.

Clear wa_amount.

*clear wa_final.

Endat.

Endloop.

hi experts

i have strucked up with at End of usage in my report,

which i already posted and i have tried with another

way,

and its almost solved,,,,,only problem is that

Iam getting the output for the first liine alone rest its coming as 0.00 and 0.00

When i debugged ....the entire first loop is executed

and then it goes to the second loop aappending all values except my wa_final-gross and wa_final-net

i think i have gone somewhere wrong in loopin or i dont know where

please do help me out

My code

sort it_AMOUNT by belnr.

LOOP AT IT_AMOUNT INTO WA_AMOUNT.

If wa_AMOUNT-hkont = '0000500100'.

wa_final-gross = wa_amount-dmbtr.

eNDIF.

If wa_AMOUNT-koart = 'D'.

wa_final-net = wa_amount-dmbtr.

eNDIF .

Endloop.

loop at it_bseg into wa_bseg .

wa_final-kunnr = wa_bseg-kunnr.

wa_final-xref1 = wa_bseg-xref1.

wa_final-xref2 = wa_bseg-xref2.

read table it_bkpf into wa_bkpf with key belnr = wa_bseg-belnr.

if sy-subrc = 0.

wa_final-xblnr = wa_bkpf-xblnr.

wa_final-bldat = wa_bkpf-bldat.

endif.

At end of belnr.

WA_final-gross = wa_amount-gross.

wa_final-net = wa_amount-net.

Endat.

Clear wa_amount.

append wa_final to it_final.

clear wa_final.

Endloop.

OUTPUT

4552 13.07.2006 Entrepreneurshi Bharat 200,600.00 225,153.00

4552 13.07.2006 ge 0.00 0.00

4552 13.07.2006 test 0.00 0.00

;

;

;

;

;

27 REPLIES 27
Read only

Former Member
0 Likes
2,693

Hi.

It seems that ur this part of code is wrong

sort it_AMOUNT by belnr.
LOOP AT IT_AMOUNT INTO WA_AMOUNT.

If wa_AMOUNT-hkont = '0000500100' . " Suppose ur next record does not have HKONT = 0000500100
" then wa_final-gross is assigend the value zero. so include ELSE also here
wa_final-gross = wa_amount-dmbtr.
 ELSE.
" Coding if HKONT NE 0000500100 then what will be wa_final-gross.

eNDIF.

If wa_AMOUNT-koart = 'D'. " Same here if any record does not have KOART = D
" then wa_final-net will be assigened zero.so include ELSE also here
wa_final-net = wa_amount-dmbtr.
Else.
" if KOART NE D then what will be wa_final-net.
eNDIF .
Endloop.

Plz make changes what i mentioned. hope it will solve out

Read only

0 Likes
2,693

HI

thanx

and i hope this is wat u mention

LOOP AT IT_AMOUNT INTO WA_AMOUNT.

If wa_AMOUNT-hkont = '0000500100'.

wa_final-gross = wa_amount-dmbtr.

ELSE.

eNDIF.

If wa_AMOUNT-koart = 'D'.

wa_final-net = wa_amount-dmbtr.

ELSE.

eNDIF .

*append wa_final to it_Final.

Endloop.

*

i tried but still its the same...and no effect

i think the problem is in getting appended cos when i debugged , only one value iam getting in the first loop.........

its not showing the rest of the values for

wa_final-net = wa_amount-dmbtr.

wa_final-gross = wa_amount-dmbtr.

Read only

0 Likes
2,693

Hi Rachel.

u have added the ELSE class but did not mention yet that what will be the value assigend to

wa_final-gross and wa_final-net in ELSE class

LOOP AT IT_AMOUNT INTO WA_AMOUNT.

If wa_AMOUNT-hkont = '0000500100'.
wa_final-gross = wa_amount-dmbtr.
ELSE.
" Here u will have to assign the value accroding to ur need
wa_final-gross = '?
eNDIF.
If wa_AMOUNT-koart = 'D'.
wa_final-net = wa_amount-dmbtr.
ELSE.
wa_final-net = "?
eNDIF .
*append wa_final to it_Final.
Endloop.

Read only

0 Likes
2,693

sorry tahir

i was wrong since i saw the outoput alone

i debugged and saw where the values are getting changed

means previous it was going inside the loop but only one value it showed

now the problem is its not appending in my final table.....thou the value

gets changed in my first loop.....

Read only

0 Likes
2,693

Hi Rachel

The code which u paste in that only values are coming when HKONT = '00005011...'

The problem is that in final table how it will assign the value to wa_final-net and wa_final-gross.

u are assigning only in as

loop at it_amount into wa_amount.

if wa_amount-hknot = '00050000'.

wa_final-gross = wa_amount-field.

now suppose if wa_amount-hknot NE '00050000 then what will be assigend to wa_final-gross.

according to your coding wa_final-gross will be assigned 0 if wa_amount-hknot NE '00050000 .

u have to assign it sum value. ur append is working well for final.

dnt change that. u will have to just code in esle statement.

i.e.

loop at it_amount into wa_amount.
  if wa_amount-hknot = '00050000'.
    wa_final-gross = wa_amount-field.
  esle.
   wa_final-gross = " according to ur desire.
 endif.
endloop.

Read only

0 Likes
2,693

Hi tahir

hey thanx for helpin me out....

i tried the way u told but

u have asked me to give 'what i desire'

in my else stmt.....

i need only the gross for hkont cond

and net for koart conditon

and one more thing wat u hav said if

it is NE '000500100' and 'D' it will

return 0

but the input which i have given to check

willl definitely satisfy the condition

and has values for gross and net....and values are there in table

When i debuggged now

1. First its finish the entire loop for it_Amount

for all the doc no...it comes out in output,

2. Next when it goes inside the second loop for it_bseg

it fetches all the value but when it goes to

at end of belnr stmet...

only for first time it gets the value for gross and net

rest it brings 0.00

How can i change.....???PLS DO HELP

-


If wa_amount-hkont = '0000500100'.

wa_final-gross = wa_amount-dmbtr.

ElseIf wa_amount-koart = 'D'.

wa_final-net = wa_amount-dmbtr.

eNDIF .

Endloop.

loop at it_bseg into wa_bseg .

wa_final-kunnr = wa_bseg-kunnr.

read table it_bkpf into wa_bkpf with key belnr = wa_bseg-belnr.

if sy-subrc = 0.

wa_final-xblnr = wa_bkpf-xblnr.

wa_final-bldat = wa_bkpf-bldat.

endif.

At end of belnr.

WA_final-gross = wa_amount-gross.

wa_final-net = wa_amount-net.

Endat.

append wa_final to it_final.

Endloop.

Clear wa_amount.

clear wa_final.

Read only

0 Likes
2,693

Hi Rachel.

I have got u now more clearly.

problem is here.


loop at it_bseg into wa_bseg .
  wa_final-kunnr = wa_bseg-kunnr.
  read table it_bkpf into wa_bkpf with key belnr = wa_bseg-belnr.
  if sy-subrc = 0.
    wa_final-xblnr = wa_bkpf-xblnr.
    wa_final-bldat = wa_bkpf-bldat.
 endif.
 At end of belnr. " At end is executed when the one BELNR is ended.
" Means if it_bseg table contains enteries against only one BELNR then AT END will execute once.
" if it_bseg table contains enteries against Two different BELNR's then AT END will execute two time,
"  right after end of each BELNR.
  WA_final-gross = wa_amount-gross.
  wa_final-net = wa_amount-net.
Endat.
append wa_final to it_final.
Endloop.

" It seems that IT_BSEG contains enteries against one BELNR. That is why AT END is being

executed once.Plz check it

Read only

0 Likes
2,693

Hi Rachel.

plz provide me the a little bit detail of it_amount and it_bseg table and then tell how u want

to display these two tables data in it_final. And also check ur program by removing AT END OF BELNR.

Because output u provided told that there is only one BELNR enteries. So check ur program by removing

AT END OF BELNR.

Read only

0 Likes
2,693

Hi tahir ,,,,

THanx alot for helping

In table bseg

If i give input for Belnr(document no say 90038)

it has 4 line items .... like

CCode BEKNR KOART DMBTR HKONT

2000 90038 S 200.00 0000500100

2000 90038 S 45.00 0000300100

2000 90038 S 21,00 0000400100

2000 90038 D 225.00 0000200100

I need only the gross whcih is (200) -gross and net(225) so i have

taken it by hkont '500100' for taking gross and koart = 'D' for taking net....

But now my problem is....after do all changes as below....

in my output first line alone iam getting the answer , but from second line on

its showing 0.00 ..........

is it now clear.....PLS help me out

i have changed by commenting AT end of belnr....

but by doing so....all my net and gross is becoming 0.0.

;

;

;

;

if it_bkpf[] is not initial.

select bukrs belnr gjahr xref1 xref2 kunnr buzei dmbtr hkont koart from bseg into corresponding fields of table it_bseg

for all entries in it_bkpf

where bukrs = it_bkpf-bukrs

and belnr = it_bkpf-belnr

and gjahr = it_bkpf-gjahr.

  • and ( hkont = '000500100' or koart = 'D').

  • and kunnr = it_bseg-kunnr.

Endif.

IF it_bseg[] is not initial.

select bukrs belnr gjahr dmbtr hkont koart from bseg into corresponding fields of table it_amount

for all entries in it_bseg

where bukrs = it_bseg-bukrs

and belnr = it_bseg-belnr.

*delete it_bseg where hkont = '.0000301500' and hkont = '0000300450'.

*delete it_bseg where kunnr = ' '. " for deleting document details with blank customer number .

endif.

;

;

;

;

LOOP AT IT_AMOUNT INTO WA_AMOUNT.

IF wa_amount-hkont = '0000500100'.

wa_final-gross = wa_amount-dmbtr.

ElseIf wa_amount-koart = 'D'.

wa_final-net = wa_amount-dmbtr.

eNDIF .

*delete it_amount where hkont <> '0000500100'.

*delete it_amount where koart <> 'D'.

*

Endloop.

loop at it_bseg into wa_bseg .

wa_final-kunnr = wa_bseg-kunnr.

wa_final-xref1 = wa_bseg-xref1.

wa_final-xref2 = wa_bseg-xref2.

read table it_bkpf into wa_bkpf with key belnr = wa_bseg-belnr.

if sy-subrc = 0.

wa_final-xblnr = wa_bkpf-xblnr.

wa_final-bldat = wa_bkpf-bldat.

endif.

split wa_final-xblnr at '-' into itab-s1 itab-s2.

move itab-s2 to wa_Final-xblnr.

At end of belnr.

WA_final-gross = wa_amount-gross.

wa_final-net = wa_amount-net.

Clear wa_amount.

Endat.

append wa_final to it_final.

clear wa_final.

Endloop.

Input

Company code

ID

ORigin

Date

output which i getting for my report

Bilno DAte name prod GROSS NET

4552 13.07.2006 (TN) Bharat 200 225

4552 13.07.2006 (TN) Bharat 0.00 0.00

4552 13.07.2006 (TN) Bharat 0.00 0.00

4552 13.07.2006 (TN) Bharat 0.00 0.00

4554 13.07.2006 (TN) Bharat 0.00 0.00

4554 13.07.2006 (TN) Bharat 0.00 0.00

4554 13.07.2006 (TN) Bharat 0.00 0.00

4554 13.07.2006 (TN) Bharat 0.00 0.00

4555 13.07.2006 (TN) Bharat 0.00 0.00

4555 13.07.2006 (TN) Bharat 0.00 0.00

4555 13.07.2006 (TN) Bharat 0.00 0.00

4555 13.07.2006 (TN) Bharat 0.00 0.00

;

;

;

;

;

4573 13.07.2006 test .Com 0.00 0.00

Read only

0 Likes
2,693

Hi tahir ,,,,

THanx alot for helping

In table bseg

If i give input for Belnr(document no say 90038)

it has 4 line items .... like

CCode BEKNR KOART DMBTR HKONT

2000 90038 S 200.00 0000500100

2000 90038 S 45.00 0000300100

2000 90038 S 21,00 0000400100

2000 90038 D 225.00 0000200100

I need only the gross whcih is (200) -gross and net(225) so i have

taken it by hkont '500100' for taking gross and koart = 'D' for taking net....

But now my problem is....after do all changes as below....

in my output first line alone iam getting the answer , but from second line on

its showing 0.00 ..........

is it now clear.....PLS help me out

i have changed by commenting AT end of belnr....

but by doing so....all my net and gross is becoming 0.0.

;

;

;

;

if it_bkpf[] is not initial.

select bukrs belnr gjahr xref1 xref2 kunnr buzei dmbtr hkont koart from bseg into corresponding fields of table it_bseg

for all entries in it_bkpf

where bukrs = it_bkpf-bukrs

and belnr = it_bkpf-belnr

and gjahr = it_bkpf-gjahr.

  • and ( hkont = '000500100' or koart = 'D').

  • and kunnr = it_bseg-kunnr.

Endif.

IF it_bseg[] is not initial.

select bukrs belnr gjahr dmbtr hkont koart from bseg into corresponding fields of table it_amount

for all entries in it_bseg

where bukrs = it_bseg-bukrs

and belnr = it_bseg-belnr.

*delete it_bseg where hkont = '.0000301500' and hkont = '0000300450'.

*delete it_bseg where kunnr = ' '. " for deleting document details with blank customer number .

endif.

;

;

;

;

LOOP AT IT_AMOUNT INTO WA_AMOUNT.

IF wa_amount-hkont = '0000500100'.

wa_final-gross = wa_amount-dmbtr.

ElseIf wa_amount-koart = 'D'.

wa_final-net = wa_amount-dmbtr.

eNDIF .

*delete it_amount where hkont <> '0000500100'.

*delete it_amount where koart <> 'D'.

*

Endloop.

loop at it_bseg into wa_bseg .

wa_final-kunnr = wa_bseg-kunnr.

wa_final-xref1 = wa_bseg-xref1.

wa_final-xref2 = wa_bseg-xref2.

read table it_bkpf into wa_bkpf with key belnr = wa_bseg-belnr.

if sy-subrc = 0.

wa_final-xblnr = wa_bkpf-xblnr.

wa_final-bldat = wa_bkpf-bldat.

endif.

split wa_final-xblnr at '-' into itab-s1 itab-s2.

move itab-s2 to wa_Final-xblnr.

At end of belnr.

WA_final-gross = wa_amount-gross.

wa_final-net = wa_amount-net.

Clear wa_amount.

Endat.

append wa_final to it_final.

clear wa_final.

Endloop.

Input

Company code

ID

ORigin

Date

output which i getting for my report

Bilno DAte name prod GROSS NET

4552 13.07.2006 (TN) Bharat 200 225

4552 13.07.2006 (TN) Bharat 0.00 0.00

4552 13.07.2006 (TN) Bharat 0.00 0.00

4552 13.07.2006 (TN) Bharat 0.00 0.00

4554 13.07.2006 (TN) Bharat 0.00 0.00

4554 13.07.2006 (TN) Bharat 0.00 0.00

4554 13.07.2006 (TN) Bharat 0.00 0.00

4554 13.07.2006 (TN) Bharat 0.00 0.00

4555 13.07.2006 (TN) Bharat 0.00 0.00

4555 13.07.2006 (TN) Bharat 0.00 0.00

4555 13.07.2006 (TN) Bharat 0.00 0.00

4555 13.07.2006 (TN) Bharat 0.00 0.00

;

;

;

;

;

4573 13.07.2006 test .Com 0.00 0.00

Read only

0 Likes
2,693

Hi rachel.

have u just removed AT END OF BELNR & ENDAT.

At end of belnr. " Just remove this

WA_final-gross = wa_amount-gross." do not remove this

wa_final-net = wa_amount-net. " do not remove this
Clear wa_amount. " do not remove this
Endat. " And remove this

have u checked it so

Read only

0 Likes
2,693

yes tahir...

i have just commented AT end of belnr

and Endat...

the result is.....

its showing 0.00 0.00 for all Gross and net

Read only

0 Likes
2,693

Bilno DAte name prod GROSS NET

4552 13.07.2006 (TN) Bharat 200 225

4552 13.07.2006 (TN) Bharat 0.00 0.00 " What will Gross & Net Values here u want. 200 & 225 is it?

4552 13.07.2006 (TN) Bharat 0.00 0.00 " What will Gross & Net Values here u want. 200 & 225 is it?

4552 13.07.2006 (TN) Bharat 0.00 0.00 . . . . . . .

4554 13.07.2006 (TN) Bharat 0.00 0.00 . . . . . . .

4554 13.07.2006 (TN) Bharat 0.00 0.00 . . . . . . .

4554 13.07.2006 (TN) Bharat 0.00 0.00 . . . . . . .

4554 13.07.2006 (TN) Bharat 0.00 0.00 . . . . . . .

4555 13.07.2006 (TN) Bharat 0.00 0.00 . . . . . . .

4555 13.07.2006 (TN) Bharat 0.00 0.00 . . . . . . .

4555 13.07.2006 (TN) Bharat 0.00 0.00 . . . . . . .

4555 13.07.2006 (TN) Bharat 0.00 0.00 . . . . . . .

;

;

;

;

;

4573 13.07.2006 test .Com 0.00 0.00 " What will Gross & Net Values here u want. 200 & 225 is it?

if it is so then made some changes where mentioned and execute

LOOP AT IT_AMOUNT INTO WA_AMOUNT.
  IF wa_amount-hkont = '0000500100'.
 grossvalue = wa_amount-dmbtr. " Declare grossvalue variable : Change here


ElseIf wa_amount-koart = 'D'.
netvalue = wa_amount-dmbtr. " Declare netvalue variable : Change here

eNDIF .

*delete it_amount where hkont '0000500100'.
*delete it_amount where koart 'D'.
*
Endloop.


loop at it_bseg into wa_bseg .



wa_final-kunnr = wa_bseg-kunnr.
wa_final-xref1 = wa_bseg-xref1.
wa_final-xref2 = wa_bseg-xref2.


read table it_bkpf into wa_bkpf with key belnr = wa_bseg-belnr.

if sy-subrc = 0.

wa_final-xblnr = wa_bkpf-xblnr.
wa_final-bldat = wa_bkpf-bldat.

endif.



split wa_final-xblnr at '-' into itab-s1 itab-s2.
move itab-s2 to wa_Final-xblnr.

At end of belnr.

WA_final-gross = grossvalue. " Make change here
wa_final-net = netvalue. " Make change here
Clear wa_amount.
Endat.

append wa_final to it_final.

clear wa_final.


Endloop.

Edited by: tahir naqqash on Mar 2, 2009 12:44 PM

Read only

0 Likes
2,693

hi

thanx for replying......

you have asked me to declare net value and gross value varibal e

but i have already told u that one document number has 4 to 5 line itemns

and the amount(net gross tax etc) has the same field as DMBTR

thats y iam fetching with the condition hkont and koart....according to that

hkont = '500100'

and koart = 'D' it should fetch the gross and net value

so now i realized that i shud put one read stmt inside bseg loop (i.e)

;

;

;

Read table it_amount into wa_amount with key belnr = wa_bseg-belnr.

At end of belnr.

if Sy-subrc = 0.

WA_final-gross = wa_amount-gross.

wa_final-net = wa_amount-net.

Endif.

Endat.

append wa_final to it_final.

clear wa_amount.

clear wa_final.

Endloop.

but still the same problem exist

Read only

0 Likes
2,693

Yes Rachel.

U should use read statement to get GROSS & NET Values and dnt use AT END OF BELNR.

I can only say that the mistake which u are doing is that u have get GROSS & NET Values once in

wa_final-gross & wa_final-net in ist loop. then in second loop u are appending these values in it_final.

after append u are making clear wa_final. so when the loop is executed next time u have no values

for GROSS & NET which u have calculated in ist loop. that is why it is showing for only ist record not for

others.

So in second loop use read table statement to get the values of GROSS & NET from it_amount, then in

each iterartion of loop read table statement will be executed and u will get the value for GROSS & NET.

Read table it_amount into wa_amount with key belnr = wa_bseg-belnr.

At end of belnr." Dnt use this now
if Sy-subrc = 0 ." Dnt use this now
WA_final-gross = wa_amount-gross.
wa_final-net = wa_amount-net.
Endif." Dnt use this now
Endat." Dnt use this now

Read only

0 Likes
2,693

hi

sorry for troubling...and thanx for helping me out

Read table it_amount into wa_amount with key belnr = wa_amount-belnr.

WA_final-gross = wa_amount-gross.

wa_final-net = wa_amount-net.

append wa_final to it_final.

clear wa_amount.

clear wa_final.

Endloop.

Now wat happens is that...when i debugged

when goin inside wa_final-gross its getting the value next

when it comes to wa_Final-bet , wa_final-gross becomes 0.00 and next net becomes 0.00

and there after rest gross and net is becoming zero

Read only

0 Likes
2,693

hi

one more thing i noticed now when debugging is

my it_amount has belnr starting from

900078

;

;

;

900098

now in this

Read table it_amount into wa_amount with key belnr = wa_bseg-belnr -> has the last belnr(90098)therefore shows the value for gross and net for last belnr and thereafter it shows 0.00

when i take of At end of belnr

and endat

it shows 0.00 from first gross and net to last one

Read only

0 Likes
2,693

hi

thanx for replying and helping out

i have almost solved the problem

instead of 2 loops

i have used the REad it_amount.....

in loop at it_bseg itself.....

now the problem is

for both gross and net its bringing the same value

ie if gross is 200 net is also showing 200

if gross 600 net is also showing 600

loop at it_bseg into wa_bseg .

;

;

Read table it_amount into wa_amount with key belnr = wa_bseg-belnr .

If sy-subrc = 0.

IF wa_amount-hkont = '0000500100'.

WA_final-gross = wa_amount-dmbtr.

Endif.

If wa_amount-koart = 'D'.

wa_final-net = wa_amount-dmbtr.

Endif.

Endif.

At end of belnr.

WA_final-gross = wa_amount-dmbtr.

wa_final-net = wa_amount-dmbtr.

*Endat.

Append wa_final to it_final.

Endat.

clear wa_amount.

clear wa_final.

Endloop.

Read only

keerthy_k
Product and Topic Expert
Product and Topic Expert
0 Likes
2,693

Hi Rachel,

That is because of the code

At end of belnr.

WA_final-gross = wa_amount-dmbtr.

wa_final-net = wa_amount-dmbtr.

*Endat.

Append wa_final to it_final.

Endat.

See here u are moving the same value to the gross and net fields. Is this the required values to be moved??

keerthi

Read only

0 Likes
2,693

Hi Rachel.

Read table it_amount into wa_amount with key belnr = wa_bseg-belnr .
If sy-subrc = 0.
IF wa_amount-hkont = '0000500100'.
WA_final-gross = wa_amount-dmbtr. " u have calculated wa_final-gross here
Endif.
If wa_amount-koart = 'D'.
wa_final-net = wa_amount-dmbtr. " u have calculated wa_final-net here
Endif.
Endif.
At end of belnr.
WA_final-gross = wa_amount-dmbtr. " Y u calculating here again the wa_final-gross . So remove it
wa_final-net = wa_amount-dmbtr." Y u calculating here again the wa_final-net. so remove it

*Endat.

Append wa_final to it_final.
Endat.
clear wa_amount.
clear wa_final.
Endloop.

Read only

0 Likes
2,693

Yeah keerthi, i understood wat u have said....

hi keerthy ...

thank u so much

but my requirement is

if it encounter hkont = '500100'

it should get me the amount i.e wa_final-gross = wa_amount-dmbtr

and if it encounters koart = 'D'

it should get me the amount in that line , that will be my gross

so both gross and amount has the same field name as DMBTR

only with hkont and koart we can bring the amount as gross and net

for that particular belnr.......

now how do u think i can modify.....

Read table it_amount into wa_amount with key belnr = wa_bseg-belnr .

IF wa_amount-hkont = '0000500100'.

WA_final-gross = wa_amount-dmbtr.

ElseIf wa_amount-koart = 'D'.

wa_final-net = wa_amount-dmbtr.

Endif.

.

At end of belnr.

WA_final-gross = wa_amount-dmbtr.

wa_final-net = wa_amount-dmbtr.

Endat.

Append wa_final to it_final.

*clear wa_amount.

clear wa_final.

Endloop.

Read only

keerthy_k
Product and Topic Expert
Product and Topic Expert
0 Likes
2,693

Hi rachel,

The code is Read table it_amount into wa_amount with key belnr = wa_bseg-belnr .

IF wa_amount-hkont = '0000500100'.

WA_final-gross = wa_amount-dmbtr.

ElseIf wa_amount-koart = 'D'.

wa_final-net = wa_amount-dmbtr.

Endif.

.

At end of belnr.

WA_final-gross = wa_amount-dmbtr.--> here u can just check if WA_final-gross is initial if initial u can give the rquired value as

WA_final-gross = wa_amount-gross.

wa_final-net = wa_amount-net.

And if not initial , then leave as it is.

wa_final-net = wa_amount-dmbtr.--> same as here also

Endat.

Keerthi

Edited by: Keerthy K on Mar 2, 2009 12:27 PM

Edited by: Keerthy K on Mar 2, 2009 12:28 PM

Read only

Former Member
0 Likes
2,694

write append statement into at end....endat

At end of belnr.

WA_final-gross = wa_amount-gross.

wa_final-net = wa_amount-net.

append wa_final to it_final.

Clear wa_amount.

*clear wa_final.

Endat.

Endloop.

Read only

0 Likes
2,693

Hi,

You used 2 loops LOOP AT IT_AMOUNT INTO WA_AMOUNT.

LOOP AT IT_BSEG INTO WA_BSEG.

and you are appending the records to final internal table in the loop ita_bseg.

change your logic as write 2 loops one inside other with where condition.

Loop at it_amount ....

loop at it_bseg --- where ...

At end of .

....

endat.

append wa_final to itab_final.

endloop.

endloop.

And also when using Control break statemet declare another work area and append those records to final internal table.

I hope this will help you.

Reagrds,

Surendar Reddy.

Read only

keerthy_k
Product and Topic Expert
Product and Topic Expert
0 Likes
2,693

Hi Rachel,

I can figure out that , u are looping the it_bseg table but in this loop u re reading the values from it_AMOUNT table.

ie.

loop at it_bseg into wa_bseg .

wa_final-kunnr = wa_bseg-kunnr.

wa_final-xref1 = wa_bseg-xref1.

wa_final-xref2 = wa_bseg-xref2.

read table it_bkpf into wa_bkpf with key belnr = wa_bseg-belnr.

if sy-subrc = 0.

wa_final-xblnr = wa_bkpf-xblnr.

wa_final-bldat = wa_bkpf-bldat.

endif.

At end of belnr.

WA_final-gross = wa_amount-gross-----> before assigning these values..u need to read this entry from it_amount table.

wa_final-net = wa_amount-net.

Endat.

Clear wa_amount.

append wa_final to it_final.

clear wa_final.

Endloop.

Keerthi.

Edited by: Keerthy K on Mar 2, 2009 9:16 AM

Read only

Former Member
0 Likes
2,693

hi keerthy

Thanx alot for ur help....

just before i realized and tried like below

but problem is that , its still shows the same like

for first line, its getting the value ........rest as 0.00

LOOP AT IT_AMOUNT INTO WA_AMOUNT.

IF wa_amount-hkont = '0000500100'.

wa_final-gross = wa_amount-dmbtr.

Else.

Endif.

If wa_amount-koart = 'D'.

wa_final-net = wa_amount-dmbtr.

Else.

eNDIF .

Endloop.

Read table it_amount into wa_amount with key belnr = wa_bseg-belnr.

At end of belnr.

if Sy-subrc = 0.

WA_final-gross = wa_amount-gross.

wa_final-net = wa_amount-net.

Endif.

Endat.

append wa_final to it_final.

clear wa_amount.

clear wa_final.

Endloop.

Read only

keerthy_k
Product and Topic Expert
Product and Topic Expert
0 Likes
2,693

Hi,

This will be ur new code....

loop at it_bseg into wa_bseg .

wa_final-kunnr = wa_bseg-kunnr.

wa_final-xref1 = wa_bseg-xref1.

wa_final-xref2 = wa_bseg-xref2.

read table it_bkpf into wa_bkpf with key belnr = wa_bseg-belnr.

if sy-subrc = 0.

wa_final-xblnr = wa_bkpf-xblnr.

wa_final-bldat = wa_bkpf-bldat.

endif.

Read table it_amount into wa_amount with key belnr = wa_bseg-belnr.---> please put a break point here for the 2nd loop and just see if the value is read from the it_amount.

At end of belnr.-->y do u need this at end ??

if Sy-subrc = 0.

WA_final-gross = wa_amount-gross.

wa_final-net = wa_amount-net.

Endif.

Endat.

append wa_final to it_final.

clear wa_amount.

clear wa_final.

Endloop.

keerthi