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 properly

Former Member
0 Likes
2,321

I have a problem in my report where

i have made a loop at it_pos into wa_pos

;

;

;

;

in my Read statment

READ TABLE it_bseg INTO wa_bseg WITH KEY belnr = wa_pos-belnr.

IF sy-subrc = 0.

wa_final-gross = wa_bseg-dmbtr.

endif.

iF WA_BSEG-HKONT = '0000500100'.

WA_FINAL-NET = WA_BSEG-DMBTR.

Endif.

if wa_bseg-hkont = '0000301500 '.

wa_final-sertax = wa_bseg-dmbtr.

Endif.

APPEND wa_final TO it_final.

CLEAR: wa_final, wa_kna1, wa_bseg, wa_adv, wa_brand.

ENDLOOP.

.............

my problem is while debugging iam getting all the Gl(hkont) correctly but all the amount

gets updated in wa_final-gross field itself.

i.e for every gl(hkont) it has to corresponding get into that field

ie if hkont = '000301500'

it has to be filled in my wa_final-sertax and so....

but instead it gets filled in my wa_Final-gross itself .

so therefore

gross and net is getting filled in the alv but it is shatered and comes alternatively jumbled.

what to do ... help me out

tjhanx in advance

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,291

Hi,

Plz check in your work area whether the values are coming properly or not, And accordingly you can change your logic, And if the values are proper then plz cross check the structure of your table and work area.

Hi,

Plz check in your work area whether the values are coming properly or not, And accordingly you can change your logic, And if the values are proper then plz cross check the structure of your table and work area.

24 REPLIES 24
Read only

Former Member
0 Likes
2,291

Hi,

I think you have some duplicate entries in the table it_bseg. If you need to read the duplicate entries as well, you have to use only the following code:

loop at it_bseg into wa_bseg where belnr = wa_pos-belnr.

wa_final-gross = wa_bseg-dmbtr.

iF WA_BSEG-HKONT = '0000500100'.

WA_FINAL-NET = WA_BSEG-DMBTR.

Elseif wa_bseg-hkont = '0000301500 '.

wa_final-sertax = wa_bseg-dmbtr.

Endif.

APPEND wa_final TO it_final.

clear: wa_bseg.

endloop.

CLEAR: wa_final, wa_kna1, wa_adv, wa_brand.

ENDLOOP.

If your issue cannot be solved with this, then please show your full code. That is the code having loop and endloop. Then it helps you solve the problem easily.

Best Regards,

Suresh

Read only

Former Member
0 Likes
2,291

Hi,

According to me conditions handled in IF conditions are not proper, try this way:

############################

loop at it_pos into wa_pos

;

;

;

;

READ TABLE it_bseg INTO wa_bseg WITH KEY belnr = wa_pos-belnr.

IF sy-subrc = 0.

IF WA_BSEG-HKONT = '0000500100'.

WA_FINAL-NET = WA_BSEG-DMBTR.

ELSEIF wa_bseg-hkont = '0000301500 '.

wa_final-sertax = wa_bseg-dmbtr.

ELSE.

wa_final-gross = wa_bseg-dmbtr.

EndIF.

ENDIF.

APPEND wa_final TO it_final.

CLEAR: wa_final, wa_kna1, wa_bseg, wa_adv, wa_brand.

ENDLOOP.

############################

This should work according to what is been described as expected output.

Hope this solves your problem.

Regards,

Brajvir

Read only

0 Likes
2,291

hi thanks for helping out ....but its not fetching the value ....its still the same

i have modified as

READ TABLE it_bseg INTO wa_bseg WITH KEY belnr = wa_pos-belnr.

IF sy-subrc = 0.

iF WA_BSEG-HKONT = '0000500100'.

WA_FINAL-NET = WA_BSEG-DMBTR.

elseif wa_bseg-hkont ='0000300450'.

wa_Final-Educess = wa_bseg-dmbtr.

elseif wa_bseg-hkont = '0000300455'.

wa_final-cesspay = wa_bseg-dmbtr.

elseif wa_bseg-hkont = '0000209800'.

. wa_final-gross = wa_bseg-dmbtr.

endif.

ENDIF.

Read only

0 Likes
2,291

Hi,

Please mention your code correctly.

In the new code mentioned by you, there is no sertax field.

Please check the code.

Best Regards,

Suresh

Read only

Former Member
0 Likes
2,291

Hi,

I do agree with Brajveer.. if conditions are not properly handled. Please make changes as suggested by him and then post if issue persist.

Regards,

Gaurav

Read only

Former Member
0 Likes
2,291

Hey Rachel...

Can you give.. the part of the code where you are populating WA_FINAL-GROSS .. and also the codes which are above that and below that.......

Read only

0 Likes
2,291

hi subzero....

F it_pos[] 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_pos

WHERE bukrs = it_pos-bukrs

AND belnr = it_pos-belnr

AND gjahr = it_pos-gjahr.

ENDIF.

;

;

;

;

SORT it_bseg BY belnr.

LOOP AT it_pos INTO wa_pos.

READ TABLE it_kna1 INTO wa_kna1 WITH KEY kunnr = wa_pos-konto.

IF sy-subrc = 0.

wa_final-name1 = wa_kna1-name1 .

ENDIF.

wa_final-kunnr = wa_pos-konto.

    • wa_final-ktokd = wa_pos-ktokd.

wa_final-xref1 = wa_pos-xref1.

                                            • COMMENTED SINCE VALUE NOT GETTING STORED IN POS TABLE

  • wa_final-net = wa_pos-bwwrt.

READ TABLE it_bseg INTO wa_bseg WITH KEY belnr = wa_pos-belnr.

IF sy-subrc = 0.

iF WA_BSEG-HKONT = '0000500100'.

WA_FINAL-NET = WA_BSEG-DMBTR.

elseif wa_bseg-hkont ='0000300450'.

wa_Final-Educess = wa_bseg-dmbtr.

elseif wa_bseg-hkont = '0000300455'.

wa_final-cesspay = wa_bseg-dmbtr.

elseif wa_bseg-hkont = '0000209800'.

. wa_final-gross = wa_bseg-dmbtr.

  • endif.

ENDIF.

APPEND wa_final TO it_final.

Endif.

CLEAR: wa_final, wa_kna1, wa_bseg, wa_adv, wa_brand.

ENDLOOP.

Read only

0 Likes
2,291

Hi...rachel..

The problem may be because of the fact that you are not passing all the key fields which reading the table IT_BSEG.

Change the below read statement..as given and check out..


READ TABLE it_bseg INTO wa_bseg WITH KEY bukrs = wa_pos-bukrs belnr = wa_pos-belnr gjahr = wa_pos-gjahr.

If possible, include BUZEI also in the condition.....

Check out and see if this works..

Read only

0 Likes
2,291

hi

i specified the condition as u said but then its fetching value only for gross nothing else.....

buzei is not present in it_pos

and one more thing is that when i debugg in it_pos only one hkont is there ie for Gross , is it why its getting value for only gross...wat ele can be done

Read only

0 Likes
2,291

sorry i have specified buzei too in the condition

Read only

0 Likes
2,291

Rachel...

What is the HKONT value comeing for different iterations of the looop..

is the same value comin for each iteration or are you getting different values for HKONT.....

Read only

0 Likes
2,291

corresponding value for 209800(hkont) value for gross is getting filled

rest no values is getting populated

for eg

WA_BSEG-HKONT 0000209800

wa_final-gross 20989.00

other than this other Hkont and amt r not populating

Read only

Former Member
0 Likes
2,291

Hi,

Instead of reading, loop at internal table. BSEG has four primary key but you are reading only by Doument number.

Regards,

Prashant.

Read only

0 Likes
2,291

yes prashant but now i have corrected and added all my primary key in the coditon but then iam getting value only for one field(Gross) rest not getting filled

Read only

Former Member
0 Likes
2,292

Hi,

Plz check in your work area whether the values are coming properly or not, And accordingly you can change your logic, And if the values are proper then plz cross check the structure of your table and work area.

Read only

0 Likes
2,291

hmm.....

jus check whether CESSPAY.. EDUTAX...SERTAX ..fields etc...are of the same type as DMBTR...?

Read only

0 Likes
2,291

as read stmet will read only single record i am using loop inside loop but value is not populating in

where condition where belnr = it_pos-belnr

LOOP AT it_pos INTO wa_pos.

READ TABLE it_kna1 INTO wa_kna1 WITH KEY kunnr = wa_pos-konto.

IF sy-subrc = 0.

wa_final-name1 = wa_

;

;

;

;loop at it_bseg into wa_bseg where belnr = it_pos-belnr.

iF WA_BSEG-HKONT = '0000500100'.

WA_FINAL-NET = WA_BSEG-DMBTR.

elseif wa_bseg-hkont ='0000300450'.

wa_Final-Educess = wa_bseg-dmbtr.

elseif wa_bseg-hkont = '0000300455'.

wa_final-cesspay = wa_bseg-dmbtr.

elseif wa_bseg-hkont = '0000209800'.

. wa_final-gross = wa_bseg-dmbtr.

endif.

Endloop.

APPEND wa_final TO it_final.

CLEAR: wa_final, wa_kna1, wa_bseg, wa_adv, wa_brand.

ENDLOOP.

Read only

0 Likes
2,291

hey.... rachel..

you are doing a mistake..

you are populating the WA_FINAL inside a loop... but you are appending it outside that loop.....

thats where its going wrong..... !!.....

Read only

0 Likes
2,291

Try changing the code..as given below


;loop at it_bseg into wa_bseg where belnr = it_pos-belnr.

iF WA_BSEG-HKONT = '0000500100'.
WA_FINAL-NET = WA_BSEG-DMBTR.

elseif wa_bseg-hkont ='0000300450'.
wa_Final-Educess = wa_bseg-dmbtr.

elseif wa_bseg-hkont = '0000300455'.
wa_final-cesspay = wa_bseg-dmbtr.

elseif wa_bseg-hkont = '0000209800'.
. wa_final-gross = wa_bseg-dmbtr.
endif.

APPEND wa_final TO it_final. " Add this statement

Endloop.

*APPEND wa_final TO it_final.---comment this

Cheers..

Read only

0 Likes
2,291

in this where belnr = it_pos-belnr. value not populating

loop at it_bseg into wa_bseg where belnr = it_pos-belnr.

Read only

0 Likes
2,291

Rachel..

another silly mistake..

I think you have declared IT_POS as an internal table with header line...

But you looping and putting the value in WA_POS...

So change the below statement


where belnr = wa_pos-belnr.

Cheers

Read only

0 Likes
2,291

thank you very much....my problem is solved

Read only

0 Likes
2,291

rachel...

where was the mistake exactly...

wa_pos was written as it_pos...

here only right...??

Regards,

Subash R

Read only

0 Likes
2,291

yes subash....declared int tab instead of work area.....:)