cancel
Showing results for 
Search instead for 
Did you mean: 

How to display the output of multiple line item into single line item.

Former Member
0 Kudos

How to display the output of multiple line item into single line item.In smartforms

eg: I have

material desc          color      date                       qty          amount.

aaaa                         red      15/05/2012              3                55

aaaa                         red      15/05/2012              4                500

aaaa                         red      15/05/2012              10                45

now i nedd the answer like

aaaa                         red      15/05/2012              17                600

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

You can do this using Control Break in Smartforms.

In the LOOP Node, add your field, Say material desc in the Sort criteria.

Click on Event on Sort End check box.

A new event will be created under the LOOP Node.

There you can write the subtotal.

Make sure you have program lines to get the subtotal before the event is executed.

Former Member
0 Kudos

hi shabu can u plz give me any example for that query.

Former Member
0 Kudos

Check in SAPTECHNICAL under Smartform tutorials.

Answers (2)

Answers (2)

Former Member

HI,

loop at t_final into x_final.

read table lt_final into lx_final with key matnr = x_final-matnr

                                                        colour = x_final-colour

                                                        date   = x_final-date.

if sy-subrc eq 0.

lx_final-qty = lx_final-qty + x_final-qty.

lx_final-amount = lx_final-amount + x_final-amount.

modify lt_final from lx_final

          transporting qty

                            amount

                  where  matnr  = x_final-matnr

                             colour = x_final-colour

                             date    = x_final-date.

else.

append x_final to lt_final.

endif.

endloop.

finally your T_FINAL will have 3 records whereas LT_FINAL have 1 record and use LT_FINAL to display the data or assign LT_FINAL to T_FINAL.

(Create LT_FINAL & LX_FINAL in global definition of your form)

try this code by creating a program lines above your main window or in your driver program.

Jshree

naresh_bammidi
Contributor
0 Kudos

Hi,

Loop your internal table ,and inside the loop use Collect statement to combine all quantity fields.

For Eg:

LOOP AT ITAB.

COLLECT itab into itab1.

ENDLOOP.

Best regards

Naresh

Former Member
0 Kudos

I tryed the above code but its throwing an error like

You can only use the collect command in a table if all of is non-key field are numeric(type I,P or F).

plz help me sinc its a new issue to me.

naresh_bammidi
Contributor
0 Kudos

What are the data types of your internal table fields.?..i tried by creating sample test case by using the following code.in my case it is working fine.

data:it_collect type table of ty_collect,
      ls_collect type ty_collect.

ls_collect-maktx = 'aaaa'.
ls_collect-color = 'red'.
ls_collect-date  = '20120303'.
ls_collect-qty       = '6'.
ls_collect-amt       = '500'.

collect ls_collect into it_collect.

ls_collect-maktx = 'aaaa'.
ls_collect-color = 'red'.
ls_collect-date  = '20120303'.
ls_collect-qty       = '4'.
ls_collect-amt       = '500'.

collect ls_collect into it_collect.

loop at it_collect into ls_collect.
   write:ls_collect-maktx,
ls_collect-color,
ls_collect-date,
ls_collect-qty,
ls_collect-amt.
   endloop.

Please check your data types with above code and let me know if any issue.

Thanks

Naresh

Message was edited by: Naresh Bammidi

Former Member
0 Kudos

thanks for relpying me bammidi,

here in my case the final internal table name is.

t_final.

sort t_final by sl_no and matdec_I.

then directly the t_final is called to smartform.

now tell me hw i will apply this logic.

naresh_bammidi
Contributor
0 Kudos

After getting the data into the t_final internal table write the following code in driver program.

LOOP AT t_final into <WA>.

COLLECT <WA> into t_final.

ENDLOOP.

Please revert back if any issues.

Thanks

Naresh