cancel
Showing results for 
Search instead for 
Did you mean: 

Reg: Subtotal and final total in smartform?

Former Member
0 Kudos

Hi Experts,

I'm working on a smartform where i need to display the line items from lips table.

This is my final internal table.

TYPES : BEGIN OF it_final,

matnr TYPE lips-matnr, "Article

vbeln TYPE likp-vbeln, "Delivery Number

arktx TYPE lips-arktx, "Article Description

vrkme TYPE lips-vrkme, "Unit of Measure

lfimg TYPE lips-lfimg, "Delivery Quantity

kunag TYPE kunag, " Sold To

name TYPE name1, " Name

charg TYPE lips-charg, "Batch Number

vfdat TYPE lips-vfdat, "Expiry Date

lgort TYPE lips-lgort, "Storage Location

matkl TYPE lips-matkl, "Merchandise Category

wgbez TYPE t023t-wgbez, "Merchandise Category Desc

lgpbe TYPE lips-lgpbe, "BIN Number

pikmg(20) TYPE c, "Picking Quantity

route TYPE likp-route, "Route

END OF it_final,


For one material number, there will be many line items, I need to have a subtotal for a particular material and at the end i need afinal total for all the material number.

I have sorted my internal table as sort it_final ascending by matnr vbeln.
Then this internal table is moved to smartform. 
In smartform i'm using table to display the complete data. Here i need to segregate into subtotal and total.

Please help me to display the data in below format. 
For Ex:

MATNR DESC QTY VBELN

1000001 tea 12 3500000012

1000001 tea 02 3500000013

subtotal 14

1000006 salt 01 3500000013

subtotal 01

1000008 sugar 02 3500000015

1000008 sugar 02 3500000012

1000008 sugar 02 3500000013

1000008 sugar 02 3500000016

subtotal 08

Total 23

Thanks in advance.

Guys, The data is not getting displayed in Preview properly. Please edit and read it or copy in the notepad and read it.

Regards,

Abdur Rafique

Edited by: abdur rafique on Aug 8, 2009 3:38 PM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi ABDUR,

you can achive this in 2 ways. I had done the same when i made a P.O using smartform.

1. get total and sub-total in your print program and send it to smartform but better use separate variables insted to internal table.

2. u can add the values in ur smartform it self.

for this create a program line when the loop start to print line items.

then

for sub-totals

field a = field a + field b.

print the sub -total.

on-change of matnr.

clear field a.

end.

fieldx = fieldx + fieldy. -- This will give you the total

Hope this will solve your problem.

Former Member
0 Kudos

Hi Naseerudin,

If i get the subtotal and total in the print program, How will i display the same in the smartform within the loop.

Please help me in this.

Thanks and Regards,

Abdur Rafique

Former Member
0 Kudos

Hi,

You can create program lines before you create your table in the smartform and in the program lines loop on the table data and calculate the totals and subtotals that you wan to print and pass those values to global variables defined in the smartforms and then print them in the tables.

Regards,

Himanshu

Former Member
0 Kudos

Hi Himanshu,

Thanks for the reply.

I need to display the subtotal, exactly at the end of that particular article (material), How can i do that? At the same time i need to display all the line items of that particular article (material).

Please help me on this?

Thanks in advance.

Abdur Rafique

Former Member
0 Kudos

Hi,

In order to achieve this you have to create an internal table that has all the materials and after each material it has it subtotal that has to be defined at as global data and then using your internal table which has data you have to fill the new internal table.

This you can do by looping on the origial internal tabla and appending lines to the new internal tabla and then at the end of material you can more then subtotal with text 'subtotal' in the material number column. Then you can loop on this internal table to print on the smartform as table.

Regards,

Himanshu

Former Member
0 Kudos

Hi Himanshu,

I could not get you.

I have the complete data in the final internal table.

I have used the table option in the smartform to display data. In table option, you have a loop statement in the data tab.

After assigning the variables in the text, the data gets displayed.

I have declared a global variable for the sub total.

I need to display the sub total in the screen on every change of material. where do i need to write this code.

Please help me on this.

Thanks in advance.

Regards,

Abdur Rafique

former_member555112
Active Contributor
0 Kudos

HI,

for the total it is easy.

Just calculate the total in a variable just before the table in the smartforms.

Display the total variable in the FOOTER section of the table.

To display the subtotal you will have to do i bit of workaround.

In the table create 2 LINE TYPES.

The 1st line type will have the four columns to display MATNR DESC QTY VBELN.

The 2nd line type will be of single column which will be used to display the subtotal.

In the main section of the table create 2 rows of the above line types.

In the 1st row display the MATNR DESC QTY VBELN as normal.

In the 2nd row display the subtotal.

This should be done as follows:-

Add one more column in your internal table as follows:-

MATNR DESC QTY VBELN SUBTOTAL.

Now you have to do some coding to create your internal table as follows:-

MATNR DESC QTY VBELN SUBTOTAL.

1 test 10 100001

1 test 10 100002

1 test 20 100003 40

2 test2 10 100006 10

3 test3 50 100009

3 test3 60 100010 110

This internal table should be created before displaying the table in the smartforms.

Then this internal table should be used in the smartforms.

The subtotal column should be shown in the 2nd row of the main area of the TABLES.

Also add a condition to it that it should be shown only when the column SUBTOTAL of the table contains any value.

So in this way you will be able to achieve your required output.

i hope you understand my idea.

regards,

Ankur Parab

Former Member
0 Kudos

Hi Abdur,

You have to create another internal table on the basis of your final internal table which would have all the material lines and after all lines for one material it would have the totals for that material then looping on that table in you table in smartform and assign values to variable for text to display them so us would have data like below in the internal table:

1000001 tea 12 3500000012 1st line

1000001 tea 02 3500000013 2nd line

subtotal 14 1st subtotal this line would be there in the internal table which you are looping on to print

1000006 salt 01 3500000013

subtotal 01

1000008 sugar 02 3500000015

1000008 sugar 02 3500000012

1000008 sugar 02 3500000013

1000008 sugar 02 3500000016

subtotal 08 Total 23

Regards,

Himanshu

Former Member
0 Kudos

Hi Ankur,

How would u get the data in the format you mentioned.

MATNR DESC QTY VBELN SUBTOTAL.

1 test 10 100001

1 test 10 100002

1 test 20 100003 40

2 test2 10 100006 10

3 test3 50 100009

3 test3 60 100010 110

Please help me on this.

Regards,

Abdur Rafique

former_member555112
Active Contributor
0 Kudos

HI,

You can do like this.

DATA : LV_SUBTOTAL TYPE MENGE_D

SORT ITAB BY MATNR.


LOOP AT ITAB INTO WA.

LV_SUBTOTAL = LV_SUBTOTAL +  WA-QTY.

AT END OF MATNR.

WA-SUBTOTAL = LV_SUBTOTAL.
MODIFY ITAB FROM WA INDEX SY-TABIX TRANSPORTING SUBTOTAL.
CLEAR : LV_SUBTOTAL.
ENDAT

ENDLOOP.

Regards,

Ankur Parab

Former Member
0 Kudos

Hi Ankur,

Thanks for the information, I got the data as you told, Now i need to display this in smartform.

I created another line item in the main area, gave a condition. if w_subtotal is not initial , the i passed it to a global variable, that variable i passed to the text to display the data.

I'm getting subtotal as zero and its not getting displayed as we required.

Please help me on this.

Regards,

Abdur Rafique

former_member555112
Active Contributor
0 Kudos

Hi,

You should display the subtotal from the internal table.

Do not put it in any variable.

In the TABLE of your smartform use the newcly created table with the column subtotal.

In the 2nd row of the MAIN area add a text element and put the column subtotal.

&WA-SUBTOTAL&

Add the condtion to this row

WA-SUBTOTAL <> INITIAL.

I hope you get the point.

Regards,

Ankur Parab

Former Member
0 Kudos

Hi Ankur,

I have understood what you meant now, Main problem is in the driver program i have the subtotal data. When i pass the same data to smartform, subtotal data is not there. I have created a structure in the data dictionary, same structure i'm using in both driver program and smartform.

to check in the debugging mode in the smartform, i gave a break point before the loop, I dont see the subtotal data in the internal table.

But when i check in the driver program before sending it to the smartform , subtotal data is available.

How should i check this?

Thanks for helping me.

Regards,

Abdur Rafique

Former Member
0 Kudos

Thanks Ankur,

I got the output. Thanks for being so patience with me. Problem was i didnt not refresh the internal table.

Regards,

Abdur Rafique

Answers (0)