cancel
Showing results for 
Search instead for 
Did you mean: 

Re : subTotals

Former Member
0 Kudos

HI experts,

I am using smartforms, i want to the subtotals for customer wise,

example :

i have an internal table itab..

Cust NO I Name I Amount

100 I Ram I 111

100 I Ram I 222

100 I Ram I 444

*100 I Ram I 777 ( is the sub total for cust no '100' )

200 I Ravi I 011

200 I Ravi I 112

*200 I Ravi I 123 ( is the sub total for cust no '200 ).

and thi ssub totals i want in bold.

i am using smartforms..

can any one pleas suggestion me...

Thanks & Best Regards,

Praveen.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Praveen.

Ist use an extra field in itab to inform the smart from that it is total line.

Here is sample code according to ur need.

data: begin of it_tab occurs 10,
      custno(20),
      name(30),
      amount type i,
      sform(1), " Smartform indicator to bold this line
      end of it_tab .

data: wa_it_tab like it_tab.
data: itab2 like standard table of it_tab with header line,
      wa_itab2 like it_tab.

 it_tab-custno = '100'.  it_tab-name = 'Ram'. it_tab-amount = 111 .append it_tab.
 it_tab-custno = '100'.  it_tab-name = 'Ram'. it_tab-amount = 222 .append it_tab.
 it_tab-custno = '100'.  it_tab-name = 'Ram'. it_tab-amount = 444 .append it_tab.
 it_tab-custno = '200'.  it_tab-name = 'Ravi'. it_tab-amount = 11 .append it_tab.
 it_tab-custno = '200'.  it_tab-name = 'Ravi'. it_tab-amount = 112 .append it_tab.


 sort it_tab by custno.

 data: count type i.
 loop at it_tab into wa_it_tab.
    wa_itab2 = wa_it_tab.
    append wa_itab2 to itab2.
    at end of custno.
      sum.
         wa_it_tab-sform = 'X'.
         wa_it_tab-name = wa_itab2-name.
         append wa_it_tab to itab2.
    endat.
endloop.

Copy paste this code and execute it.

Now u will get total of customer also in itab2.Now pass this itab2 to smartform.

in smartform as u make the line to show the simple record , on this table line apply the following

condition.

condition can be applied in Condition Tab of table line.

display one line when itab-sform neq 'X'. then display this as normal line.

and when itab-sform eq 'X' , then bold this line.

reply if any query

Former Member
0 Kudos

HI tahir,

i have done up to subtotal in the intarnal table 2,

but i am not getting how to pass these itab 2 into smart forms, and how to use conditions in the table control area.

can u please explain me in detail.

Thanks & Best Regards,

Praveen.

Former Member
0 Kudos

Hi

There is wiki about totals form nameesh

read this wiki

Link: [subtotals|https://wiki.sdn.sap.com/wiki/display/ABAP/SUBTOTALINSAP+SMARTFORMS]

i'm sure this will help you

Gr., Frank

Former Member
0 Kudos

Hi praveen.

Have u use smartforms before.

Former Member
0 Kudos

hi tahir,

ya i wa use smartforms,

but here i am little bit confussion about form interface and global definitions codition type ,

if u can give me an idea then i can do it...

Thanks & best Regards

praveen.

Former Member
0 Kudos

Hi.

Then it will be easy for u if u have created smart forms b4.

Now conidtion have to give there in global definitions.

just in form interface in Tables tab u have to pass the structure which u have to created to pass data to smartforms.

steps are as follows.

1) When u open the smart from , right click on the Main Window -> Create -> Table. It will create HEADER,Main Area & Footer Sections.

2) Create Table Line which have to show four fields of ur internal table.

3) Now Right Click on the main area -> Create -> Table Line.

4) Give the Line type name which u created in 2nd step.

5) Now Place the cursor on table line u created.

6) see in side window that it have two tabs . One of OutPut Options and 2nd of Conditions Tab.

7) Now go in conditions tab. In Field Name tab write itab-sform and comparison value NE 'X'. Which is for simple records

😎 now create again table line of the same line type and give here condition itab-sform EQ 'X'. which is for subtotal. And make bold the contents of this table line

Former Member
0 Kudos

Hi tahir,

i have desinged the smartform also with your suggestion,

while calling the smartform function module in the driver program..

tables

itab = itab2.

is it correct ?

if i give like this i am gettin the erroer messgae that, " itab2 is unknowm it is neither in one of the specified tables nor defined by data statements ".

but i have declreard the itab2 in data statements.

can u please sugget me how to over come this problem.

Thanks & Best Regards,

Praveen.

Former Member
0 Kudos

HI friends,

Thankks a lot my problem has been solved.

Thanks & Best Regards,

Praveen

Former Member
0 Kudos

HI tahir,

i did according to u , i didn't get the subtotal BOLD , i written the codition also in the condition tab also...

can u please explai me what i have to do..

Thanks & Best Regards,

Praveen.

Answers (7)

Answers (7)

Former Member
0 Kudos

Hi Praveen.

To bold a line u will have to create the style of bold type by using t-code 'SMARTSTYLES'.

It is very easy to create ur own customized style and while creating style u can bold it. when u create a style

it will appear in smartfroms too. there u can assign this style to ur subtotal line & other style which u are already using to other records lines

Former Member
0 Kudos

Hi Praveen

see this link.It explains you the subtotaling in SMARTFORM with example ans screen shots.

[https://wiki.sdn.sap.com/wiki/display/ABAP/SUBTOTALINSAP+SMARTFORMS]

Regards

Hareesh Menon

Former Member
0 Kudos

Hi Hareesh,

I did already gave him the link to your wiki. Because that is the best detailed explanation i have ever seen how to achieve the sub totals he wants.

But i think he has not read it.

Gr., Frank

Former Member
0 Kudos

Hi,

Create the Event on sort Begin for the customer number .

-


>Create Program lines---->Calculate Subtotal i.e Sub_tot = Subtot+Amount.

-


>Create Text node Dispaly &Sub_tot&

Dont Forget to Clear The Value of Sub_tot Before Sort of Begin event.

Former Member
0 Kudos

HI Mr venkat,

after i caluculate the subtotal i am gettin the erroer message that " sub_tot has no defined value ".

can u please tell me how to do this..

Thanks & Best Regards,

Praveen.

venkateswarareddy_medam
Active Participant
0 Kudos

Hi Praveen,

U can decalre like this your problem will solve.

RG ,, Kunnr,,name1,, <F1>&G_SUBTOTAL+4(14R)&</>

Here <F1> characterformat should be in Bold.

Regards,

Venkat

Former Member
0 Kudos

Hi,

1.Sort the internal table on the basis of Cust no.

2.AT NEW CUST NO

sum "this will add up the amount for all the cust no

End at.

3.write sum.

Or append the sum into a new column in the internal table

Pooja

Former Member
0 Kudos

Hi

If you are using SAP 6.0, U need not write any calculation for that..

Go to main window-> table-> calculation tab ->

Put Operation as Total

Put field name in column field name like wa_tab-fname

and put any variable in target field name

You can choose after loop in time

Then you can print the variable which will have subtotal

Regards

P

Former Member
0 Kudos

Hi Praveen

Create the Event on sort Begin for the customer number .Create the text node and after create the program lines for the subtotals

For the subtotals to be bold create the smart styles character format and include in the smart forms output options and display the text bold

Regards,

Sravanthi

Former Member
0 Kudos

Hi sravanthi,

i have created event on customer number , can u tell me what is the logic i have to implement in the program lines can u explian me a little bit more...

Thanks & Best Regards,

Praveen.