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

On change on

former_member251546
Participant
0 Likes
2,575

Hi,

good day guys

a small doudt. if i need to get the iteams and then total. can we use on change on .

First we need to display iteams then then total.. Next second iteam and then total.

Can we use on change statement? plz any one advice me

CLEAR: lwa_out5.

LOOP AT lt_machine_sales INTO lwa_out5.

ON CHANGE OF lwa_out5-ktgrm_d.

lwa_out5-act_cos_p = lwa_out5-act_cos_p * -1.

sum.

Append lwa_out5 to lt_machine_sales4.

clear:lwa_out5.

ENDON.

ENDLOOP.

1 ACCEPTED SOLUTION
Read only

former_member251546
Participant
0 Likes
2,538

Hi,

plz Can any one tell me How to show first items and subtotal..next second items and subtotal..

i been trying with At last event but i didnt get thourgh..

Can any one tell me with out using Control Break events.

REgards

Hi,

good day guys

a small doudt. if i need to get the iteams and then total. can we use on change on .

First we need to display iteams then then total.. Next second iteam and then total.

Can we use on change statement? plz any one advice me

CLEAR: lwa_out5.

LOOP AT lt_machine_sales INTO lwa_out5.

ON CHANGE OF lwa_out5-ktgrm_d.

lwa_out5-act_cos_p = lwa_out5-act_cos_p * -1.

sum.

Append lwa_out5 to lt_machine_sales4.

clear:lwa_out5.

ENDON.

ENDLOOP.

28 REPLIES 28
Read only

former_member206377
Active Contributor
0 Likes
2,538

ON CHANGE OF should not be used. It is obsolete. It is present only to provide compatibilty with releases older than ECC 6.

Read only

Former Member
0 Likes
2,538

hi,

on change of is an obselete functioanlity so its beter if u use AT NEW or AT END OF within the loop,

here you can work with AT END OF

thanks

shivraj

Edited by: ShivrajSinha on Feb 9, 2010 10:33 AM

Read only

Former Member
0 Likes
2,538

hi,

do you want to display the grand total or sub total.

if you want to display the grand total then use at last.

and for sub total use at new.

regards,

sakshi.

Read only

0 Likes
2,538

hi,

Thank you for reply.

I need to display Item display and total.. next iteam display and total

Can u tell me. how to do it.

I dont want to use At New or At End of control statements.

Plz send sample code

regards

Read only

0 Likes
2,538

hi,

you are using ALV or classical report?

regards

Read only

0 Likes
2,538

Hi Balaji,

In one post your query says- first it should display total and then items

In another your query is - first it should diplay items and then totals?

Both your queries are different or are you duplicating the posts? if so, dont do that.

Also may we know why dont you want to use at new or at end of?

Regards,

Swarna Munukoti

Read only

0 Likes
2,538

Hi,

Good day swarna

Sorry to say.. Just now my pm has changed the spec. bcoz we r upgrading the spec. He forgot to say to me about this spec.

Iam really sorry.

He changed the spec. First report display the item then next total.. Second item .. total

once again iam really sorry

Read only

0 Likes
2,538

hi,

good day swarna

for the getting subtotal for every iteam. iam using the below code. but iam getting the -ve values in qty.. and acutal price level.

thats why in the subtotal level. iam not getting right values.

How to overcome , if i get a -ve values.

like

---

QTY

-


10

-10

20

-20

-


60 " Here the tot is 60... but instead of -ve values its shows 0.. bcoz of -ve values.. i need to sum the tot

-


how to over come.

CLEAR: lwa_out5.

LOOP AT lt_machine_sales INTO lwa_out5.

append lwa_out5 to lt_machine_sales4.

at end of ktgrm_d.

sum.

********************************************************

lwa_out5-act_cos_p = lwa_out5-act_cos_p * -1.

lwa_machine_sales-act_gross_p = lwa_out5-act_sales_p - lwa_out5-act_cos_p.

IF lwa_out5-act_sales_p NE 0.

lwa_out5-act_gross_perc_p = ( lwa_out5-act_gross_p / lwa_out5-act_sales_p ) * 100.

ENDIF.

WRITE lwa_out5-act_gross_perc_p TO lwa_out5-act_gross_perc NO-SIGN LEFT-JUSTIFIED DECIMALS 1.

IF lwa_out5-act_gross_p < 0.

CONCATENATE lwa_out5-act_gross_perc '%-' INTO lwa_out5-act_gross_perc.

ELSE.

CONCATENATE lwa_out5-act_gross_perc '%' INTO lwa_out5-act_gross_perc.

ENDIF.

lwa_out5-bud_gross_p = lwa_out5-bud_sales_p - lwa_out5-bud_cos_p.

lwa_out5-bud_gross_perc_p = ( lwa_out5-bud_gross_p / lwa_out5-bud_sales_p ) * 100.

WRITE lwa_out5-bud_gross_perc_p TO lwa_out5-bud_gross_perc NO-SIGN LEFT-JUSTIFIED DECIMALS 1.

IF lwa_out5-bud_gross_p < 0.

CONCATENATE lwa_out5-bud_gross_perc '%-' INTO lwa_out5-bud_gross_perc.

ELSE.

CONCATENATE lwa_out5-bud_gross_perc '%' INTO lwa_out5-bud_gross_perc.

Endif.

***************************************************

Append lwa_out5 to lt_machine_sales4.

clear:lwa_out5.

endat.

ENDLOOP.

Read only

0 Likes
2,538

Hi Balaji,

Can you tell from where these values are coming?

---

QTY

-


10

-10

20

-20

-


Regards,

Swarna Munukoti.

Read only

0 Likes
2,538

Hi,

thank you for reply.

plz see the qty value where i was marked is getting

LOOP AT lt_alvitems1 INTO lwa_alvitems1

WHERE vtweg_auft = '10'

AND poper IN r_poper.

lwa_machine_sales-bukrs = lwa_alvitems1-rbukrs.

lwa_machine_sales-gjahr = lwa_alvitems1-gjahr.

lwa_machine_sales-poper = lwa_alvitems1-poper.

lwa_machine_sales-werks = lwa_alvitems1-werks.

lwa_machine_sales-vtweg = lwa_alvitems1-vtweg_auft.

lwa_machine_sales-mtpos = lwa_alvitems1-mtpos.

lwa_machine_sales-matkl_d = lwa_alvitems1-matkl_d.

lwa_machine_sales-ktgrm_d = lwa_alvitems1-ktgrm_d.

lwa_machine_sales-matnr = lwa_alvitems1-matnr.

lwa_machine_sales-netwr = lwa_alvitems1-netwr.

  • If sales item

IF lwa_alvitems1-racct(5) = '00005'.

lwa_machine_sales-sales_qty = lwa_alvitems1-msl. "QTY VALUE"

WRITE lwa_machine_sales-netwr TO lwa_machine_sales-act_sales_c ROUND 3 DECIMALS 0 NO-GROUPING.

MOVE lwa_machine_sales-act_sales_c TO lwa_machine_sales-act_sales_p.

CLEAR lwa_machine_sales-act_sales_c.

  • Else if COS item

ELSE .

lwa_machine_sales-cos_qty = lwa_alvitems1-msl. " QTY VALUE

WRITE lwa_machine_sales-netwr TO lwa_machine_sales-act_cos_c ROUND 3 DECIMALS 0 NO-GROUPING.

MOVE lwa_machine_sales-act_cos_c TO lwa_machine_sales-act_cos_p.

CLEAR lwa_machine_sales-act_cos_c.

ENDIF.

APPEND lwa_machine_sales TO lt_machine_sales.

CLEAR lwa_machine_sales.

ENDLOOP.

regards

Edited by: balaji kiran on Feb 9, 2010 11:21 AM

Read only

0 Likes
2,538

Hi Balaji,


 If sales item
IF lwa_alvitems1-racct(5) = '00005'.
lwa_machine_sales-sales_qty = lwa_alvitems1-msl. "QTY VALUE"

WRITE lwa_machine_sales-netwr TO lwa_machine_sales-act_sales_c ROUND 3 DECIMALS 0 NO-GROUPING.
MOVE lwa_machine_sales-act_sales_c TO lwa_machine_sales-act_sales_p.
CLEAR lwa_machine_sales-act_sales_c.
* Else if COS item
ELSE .
lwa_machine_sales-cos_qty = lwa_alvitems1-msl. " QTY VALUE
WRITE lwa_machine_sales-netwr TO lwa_machine_sales-act_cos_c ROUND 3 DECIMALS 0 NO-GROUPING.
MOVE lwa_machine_sales-act_cos_c TO lwa_machine_sales-act_cos_p.
lwa_machine_sales-act_cos_p = lwa_machine_sales-act_cos_p * -1.  " include this here
CLEAR lwa_machine_sales-act_cos_c.
ENDIF.

APPEND lwa_machine_sales TO lt_machine_sales.

Make sure that it is not affecting any other functionality.

Regards,

Swarna Munukoti

Read only

0 Likes
2,538

Thank you for replying.

Yes it doesnt effect to other fuctionality.

Thank you.

Regards

Read only

0 Likes
2,538

Hi,

good day swarna

Iam doing the subtotal thourgh At End Of ktgrm_d .

Can we do subtotal with out using the Control Break Events.

Plz let me know? how to do it. if we have 'N' ITEMS.. then we need to display 'first iteams displays and then subtot and next second iteam

subtotll.........N items

how to do ?

plz let me know.

Regards

Read only

0 Likes
2,538

hi

u want output like

---

QTY

-


10

-10

20

-20

-


60 " Here the tot is 60... but instead of -ve values its shows 0.. bcoz of -ve values.. i need to sum the tot

see the following example


{DATA : BEGIN OF ITAB OCCURS 0,
          NAME(3),
          VALUE TYPE I,
       END OF ITAB.


ITAB-NAME = 'aaa'.
ITAB-VALUE = 10.
APPEND ITAB.

ITAB-NAME = 'aaa'.
ITAB-VALUE = -10.
APPEND ITAB.

ITAB-NAME = 'aaa'.
ITAB-VALUE = 20.
APPEND ITAB.

ITAB-NAME = 'aaa'.
ITAB-VALUE = -20.
APPEND ITAB.


SORT ITAB BY NAME.
break developer.
LOOP at ITAB.
*  AT END OF NAME.
  AT new name.
    SUM.
    write :/ itab-name , itab-value.
  ENDAT.
ENDLOOP.

Read only

0 Likes
2,538

Hi,

thankyou for replying

Ive tried like you. but i didn get..

Without using control break events.. how to get the iteams and subtotal.. Plz let me know

Regars

Read only

0 Likes
2,538

Hi

Good day

For getting Line items , subtotal... i did like as below as. but its not working.. some of Items getting up subtot top of the items, some of them last..

Plz let me know. is it right or nt?

REFRESH: lt_machine_sales4.

SORT lt_machine_sales BY ktgrm_d ascending.

CLEAR: lwa_out5.

LOOP AT lt_machine_sales INTO lwa_out5.

Append lwa_out5 to lt_machine_sales4. " is it wrong appending or not?

AT END OF ktgrm_d.

Sum.

lwa_out5-act_cos_p = lwa_out5-act_cos_p * -1.

lwa_machine_sales-act_gross_p = lwa_out5-act_sales_p - lwa_out5-act_cos_p.

IF lwa_out5-act_sales_p NE 0.

lwa_out5-act_gross_perc_p = ( lwa_out5-act_gross_p / lwa_out5-act_sales_p ) * 100.

ENDIF.

WRITE lwa_out5-act_gross_perc_p TO lwa_out5-act_gross_perc NO-SIGN LEFT-JUSTIFIED DECIMALS 1.

IF lwa_out5-act_gross_p < 0.

CONCATENATE lwa_out5-act_gross_perc '%-' INTO lwa_out5-act_gross_perc.

ELSE.

CONCATENATE lwa_out5-act_gross_perc '%' INTO lwa_out5-act_gross_perc.

ENDIF.

lwa_out5-bud_gross_p = lwa_out5-bud_sales_p - lwa_out5-bud_cos_p.

lwa_out5-bud_gross_perc_p = ( lwa_out5-bud_gross_p / lwa_out5-bud_sales_p ) * 100.

WRITE lwa_out5-bud_gross_perc_p TO lwa_out5-bud_gross_perc NO-SIGN LEFT-JUSTIFIED DECIMALS 1.

IF lwa_out5-bud_gross_p < 0.

CONCATENATE lwa_out5-bud_gross_perc '%-' INTO lwa_out5-bud_gross_perc.

ELSE.

CONCATENATE lwa_out5-bud_gross_perc '%' INTO lwa_out5-bud_gross_perc.

Endif.

clear:lwa_out5-MATKL_D,

lwa_out5-MATNR.

Append lwa_out5 to lt_machine_sales4.

clear:lwa_out5.

ENDAT.

ENDLOOP.

Read only

Former Member
0 Likes
2,538

I think for the required functionality you can easily use,


LOOP AT lt_machine_sales INTO lwa_out5.
*whole functionality

AT END OF ktgrm_d
*sum displayed in a field
end at.

endloop.

Regards,

Salil Sonam.

Read only

0 Likes
2,538

hi,

If i am getting the -ve values in the Qty field. how to over come

like

QTY

-


-1

6

7

-3

If we cal the tot of qty;; result is -9 instead of 17..

how to do the -ve value cal

Regards

Read only

0 Likes
2,538

hi,

check the values which are negative and then multiply by -1.

and then add them.

regards

Read only

former_member251546
Participant
0 Likes
2,539

Hi,

plz Can any one tell me How to show first items and subtotal..next second items and subtotal..

i been trying with At last event but i didnt get thourgh..

Can any one tell me with out using Control Break events.

REgards

Read only

0 Likes
2,538

Hi Balaji,

Check this without the events: try to map with your internal tables



select * FROM sflight INTO TABLE zsflight_out.
BREAK-POINT.

LOOP AT zsflight_out INTO wa_zsflight_out .
  wa_new = wa_zsflight_out-carrid.
  IF sy-tabix eq 1.
    wa_old = wa_zsflight_out-carrid.
  ELSE.
    IF wa_old ne wa_new.
      wa_sf1-price = wa_total.
      APPEND wa_sf1 to zs_sf1.
      clear wa_total.
    ENDIF.
  ENDIF.
  wa_total = wa_total + wa_zsflight_out-price.
  move wa_zsflight_out to wa_sf1.
  append wa_zsflight_out to zs_sf1.
  wa_old = wa_zsflight_out-carrid.
ENDLOOP.

Regards,

Swarna Munukoti

Read only

0 Likes
2,538

Really gr8 job.. Thank you very much.. iam debugging. if i get -ve values in the qty..then summing will be wrong.

then how to overcome the prob.

Thank you very much for outstanding supporting.

Read only

0 Likes
2,538

Hi Balaji,

You can keep a check for -ve value.

if lwa_machine_sales-act_cos_p LT 0.

lwa_machine_sales-act_cos_p = lwa_machine_sales-act_cos_p * -1. " include this here

endif.

Regards,

Swarna Munukoti

Read only

0 Likes
2,538

Thank you very much for lovely supporting.

If you dont mind,plz can u send me ur mail add. some times i can send attachment of the print screen.

Once again. thank you very much.

Regards

Read only

0 Likes
2,538

Hi,

Good day swarna. As u said ive done. but iam getting the total top of the item. As i told, today my client has changed. He needs the total after displaying the items.

like First iteams then Subtotal ... Second iteams ..then subtoall

plz help me.. where i need to change .

Data: lwa_out1 type zsalessm,

lwa_new type zsalessm,

lwa_old type zsalessm,

lv_tot type zsalessm-sales_qty,

lv_ACT_SALES_P type zsalessm-ACT_SALES_P,

lv_COS_QTY type zsalessm-cos_qty,

lv_ACT_COS_P type zsalessm-ACT_COS_P,

lv_ACT_GROSS_P type zsalessm-ACT_GROSS_P.

SORT lt_machine_sales BY ktgrm_d ascending.

Loop at lt_machine_sales into lwa_out5.

if lwa_out5-sales_qty LT 0.

lwa_out5-sales_qty = lwa_out5-sales_qty * -1.

endif.

lwa_new = lwa_out5-ktgrm_d.

if sy-tabix eq 1.

lwa_old = lwa_out5-ktgrm_d.

else.

if lwa_old ne lwa_new.

lwa_out1-sales_qty = lv_tot.

lwa_out1-act_sales_p = lv_act_sales_p.

lwa_out1-cos_qty = lv_cos_qty.

lwa_out1-act_cos_p = lv_act_cos_p.

lwa_out1-act_gross_p = lv_ACT_GROSS_P.

append lwa_out1 to lt_machine_sales4.

clear: lv_tot,

lv_act_sales_p,

lv_cos_qty,

lv_act_cos_p,

lv_ACT_GROSS_P.

endif.

endif.

lv_tot = lv_tot + lwa_out5-sales_qty.

lv_act_sales_p = lv_act_sales_p + lwa_out5-act_sales_p.

lv_cos_qty = lv_cos_qty + lwa_out5-cos_qty.

lv_act_cos_p = lv_act_cos_p + lwa_out5-act_cos_p.

lv_ACT_GROSS_P = lv_act_sales_p - lv_act_cos_p.

move lwa_out5 to lwa_out1.

append lwa_out5 to lt_machine_sales4.

lwa_old = lwa_out5-ktgrm_d.

endloop.

Read only

0 Likes
2,538

Hi,

Good Morning Swarna

thank you very much for supporting. Ur code was working. But my client has change the requirement as i yesterday told u. He need the sum after iteams display.. But here Summing display on top of the iteams..

Can i change appending anything in the code.

thank you

Regards

Read only

0 Likes
2,538

Hi Balaji,

As per the logic,

first : append lwa_out5 to lt_machine_sales4 will process first

and then at the end of each item: append lwa_out1 to lt_machine_sales4 will be processed.(this line appends total)

Check in debug mode how the records are arranged in the table lt_machine_sales4 after end of loop statement.

Regards,

Swarna Munukoti.

Read only

0 Likes
2,538

Hi,

100% right. I was debugging the logic. Iam sorry for the given trouble to u. Acutally iam new in abap. so a bit of confusse.

I have 7 agencies[ktgrm_d]... like First Agency gets the items and total..Second Agency total will come on the top of the second agency.. After total.. items displayed..

third & Forth Agency displays right. and Fifth Agency also same as like first agency..

Sixth agency sum displays in the middle of the items.. 7th agency doesnt dispalys the summing.

Data: lwa_out1 type zsalessm,

lwa_new type zsalessm,

lwa_old type zsalessm,

lv_tot type zsalessm-sales_qty,

lv_ACT_SALES_P type zsalessm-ACT_SALES_P,

lv_COS_QTY type zsalessm-cos_qty,

lv_ACT_COS_P type zsalessm-ACT_COS_P,

lv_ACT_GROSS_P type zsalessm-ACT_GROSS_P.

SORT lt_machine_sales BY ktgrm_d ascending.

Loop at lt_machine_sales into lwa_out5.

if lwa_out5-sales_qty LT 0.

lwa_out5-sales_qty = lwa_out5-sales_qty * -1.

endif.

lwa_new = lwa_out5-ktgrm_d.

if sy-tabix eq 1.

lwa_old = lwa_out5-ktgrm_d.

else.

if lwa_old ne lwa_new.

lwa_out1-sales_qty = lv_tot.

lwa_out1-act_sales_p = lv_act_sales_p.

lwa_out1-cos_qty = lv_cos_qty.

lwa_out1-act_cos_p = lv_act_cos_p.

lwa_out1-act_gross_p = lv_ACT_GROSS_P.

clear:lwa_out1-MATKL_D,

lwa_out1-MATNR.

append lwa_out1 to lt_machine_sales4.

clear: lv_tot,

lv_act_sales_p,

lv_cos_qty,

lv_act_cos_p,

lv_ACT_GROSS_P.

endif.

endif.

lv_tot = lv_tot + lwa_out5-sales_qty.

lv_act_sales_p = lv_act_sales_p + lwa_out5-act_sales_p.

lv_cos_qty = lv_cos_qty + lwa_out5-cos_qty.

lv_act_cos_p = lv_act_cos_p + lwa_out5-act_cos_p.

lv_ACT_GROSS_P = lv_act_sales_p - lv_act_cos_p.

move lwa_out5 to lwa_out1.

append lwa_out5 to lt_machine_sales4.

lwa_old = lwa_out5-ktgrm_d.

endloop.

Just i need , display the Items and summing...

Regards