cancel
Showing results for 
Search instead for 
Did you mean: 

Subtotal Using Event After Sort in Smartforms

Former Member
0 Kudos

Hi All,

i have used sort event in my smartform and found the subtotal of my line item,wat i need now is to obtain the subtotal of a character variabe,ie., in my sub-group line item i have variable values like

line item-1 name= ram

line item-2 name = richard

line item-3 name = khan

after the event i need t subtotal of the above as ram,richard,khan separated by comma. How to obtain this????

Edited by: Suhas Saha on Aug 25, 2011 12:52 PM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

For that table in DATA maintain the field name 'NAME' in Sort and activate start and end of control by checking the check boxes. Now declare variable for sum and total. Now for every Start clear the sum variable and create program line to add values. And at the end concatenate the sum to total. So at the end you will get all the values in total.

Edited by: 118775 on Aug 25, 2011 7:53 AM

Former Member
0 Kudos

hi friend,here i need the subtotal of the character variable 'NamE',so plz explain more in specific

Former Member
0 Kudos

Will you please ellaborate? You need how many times Ram occured in the table or your table contains another field for amount and you wanted to calculate total amount for Ram, total amount for Richard and display it in one line?

Edited by: 118775 on Aug 25, 2011 8:33 AM

Former Member
0 Kudos

dear freind,

i have sorted accordintg to my matnr field

Matnr = 001 Name = ram.

matnr = 001 Name = richard

matnr = 001 Name = khan

_________________________________________

i want subtotal of Name = ram,richard,khan

___________________________________________

Matnr = 002 Name = rani.

matnr = 002 Name = richy

matnr = 002 Name = kunthee

_________________________________________

i want subtotal of Name = rani,richy,kunthee

___________________________________________

Former Member
0 Kudos

Hi,

Yes so create one variable say 'TOTAL' type string in global declaration.

Now While displaying the table in DATA tab maintain fieldname in sort as 'MATNR' click on both the checkboxes which will enables 2 new folder/events in table. Now for these events create program lines. In first program line for start of new matnr clear the total. At in the event at end of matnr create text and display this variable 'TOTAL.

Now in between create a program line in table and write concatenate total wa_tab-name into total separated by ','.

It will solve your problem.

Edited by: 118775 on Aug 25, 2011 11:28 AM

Former Member
0 Kudos

Hi Raghav,

Use Events and tick event on sort END and give MATNR as field to be sorted on.

Right Click on event and create > Table Line and select line type used for MAIN AREA.

if you names:

Under table line create Program lines and in that write code and fetch names for that MATNR.

Next under Program lines create text node and display the names using below syntax:

CONCATENATE LINES OF itab INTO result SEPARATED BY ','.

if you want to add numeric fields at end of MATNR:

Under calculations tab:

Operation > SUM Total

Field Name > <f1> " which you want to be subtotalled.

Target field name > <f_sub> " value of subtotal

Time > A After Loop.

Now under the line type of EVENT > Cell > create a text and use <f_sub> to display subtotals.

BR

Dep

Edited by: DeepakNandikanti on Aug 25, 2011 11:49 AM

Answers (0)