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: 

how to get sum of quantity column in table control

Former Member
0 Kudos

Hi, expert ,

Someone can guide me how to get som of qty column in table control ?

I created a screen with a table control and has a qty quantity field .

I want to show total of qty in a field .

my code like this ...

PROCESS AFTER INPUT.

LOOP AT I_tab.

CHAIN.

FIELD I_tab-COUNTQTY MODULE caculate_total_qty .

endchain.

MODULE UPDATE_TOTAL_QTY .

ENDLOOP.

but, when I Back to the previous screen

It's caculate again so I always get wrong Total quantity .

anyone can help me ...

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

In the PBO event only we have to right the code like below.


PROCESS BEFORE OUTPUT.
  MODULE STATUS_0100.
LOOP AT ITAB INTO wa WITH CONTROL FLIGHTS.
module cal_qty."call the module here 
  ENDLOOP.

MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'SCREEN_100'.
  DESCRIBE TABLE ITAB LINES LINES.
  FLIGHTS-LINES = LINES.
clear tot_qty screen field name."here you should clear the Total qty screen field name
ENDMODULE.

Module cal_qty.
tot_qty screen field name  = tot_qty screen field name + wa-qty .
endmodule.

regards,

Dhina..

5 REPLIES 5

Former Member
0 Kudos

Hi,

In the PBO event only we have to right the code like below.


PROCESS BEFORE OUTPUT.
  MODULE STATUS_0100.
LOOP AT ITAB INTO wa WITH CONTROL FLIGHTS.
module cal_qty."call the module here 
  ENDLOOP.

MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'SCREEN_100'.
  DESCRIBE TABLE ITAB LINES LINES.
  FLIGHTS-LINES = LINES.
clear tot_qty screen field name."here you should clear the Total qty screen field name
ENDMODULE.

Module cal_qty.
tot_qty screen field name  = tot_qty screen field name + wa-qty .
endmodule.

regards,

Dhina..

0 Kudos

Dear Dhina ,

Thanks for your reply

It's work

I have Solved my problem .

Edited by: TitusFang on Jun 16, 2011 2:41 AM

Edited by: TitusFang on Jun 16, 2011 2:49 AM

0 Kudos

Hi , Dhina

I have another question .

I use internal table data in table control to update database table .

The data in the db will be change ,

but each record I want to delete in table control , it's still exist in database .

my code is

WHEN 'SAVE'
     MODIFY YDSGBT53 FROM TABLE I_YDSGBT53 .
     COMMIT WORK .
  END CASE

How to fix my code and let it can change and delete data in database ?

or

when I delete record in table control I must to delete data in the database too .

Edited by: TitusFang on Jun 16, 2011 3:21 AM

0 Kudos

Hi,

once you press the delete button append wht record your deleting in one internal table. then while saving

just check wherether the internal table is not initial write loop the internal table use


DELETE ztable FROM TABLE del_itab.

Regards,

Dhina..

0 Kudos

Thanks for your help ...