Application Development and Automation 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: 
Read only

sub totals

Former Member
0 Likes
1,044

Hi,

i need net amount totals by vendor based.

for ex:

Vendor 10146.

Document No Net Amount

6000003 1,250.0

6260003 63,143.00

-


total

-


Vendor 11312

Document No Net Amount

6000001 4,000.00

6260000 465,874.00

-


total

-


Regards ,

K.Karthikeyan.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,009

HI,

You can use statement:

AT END OF Vendor number.

SUM (by your required fields name)

ENDAT.

Hope it helps

Regrds

Mansi

Hi,

i need net amount totals by vendor based.

for ex:

Vendor 10146.

Document No Net Amount

6000003 1,250.0

6260003 63,143.00

-


total

-


Vendor 11312

Document No Net Amount

6000001 4,000.00

6260000 465,874.00

-


total

-


Regards ,

K.Karthikeyan.

8 REPLIES 8
Read only

dev_parbutteea
Active Contributor
0 Likes
1,009

Hi,

I think that you already have all data in 1 internal table. So, why don't you just add up all values being printed in a variable above the total...

Read only

Former Member
0 Likes
1,009

Use control break statements.

sort ur internal table by vendor number befour loop stmt....

wit in loop endloop use control break stmt..

AT END of <vendor>.

sum.

ENDAT>

Read only

Former Member
0 Likes
1,010

HI,

You can use statement:

AT END OF Vendor number.

SUM (by your required fields name)

ENDAT.

Hope it helps

Regrds

Mansi

Read only

Former Member
0 Likes
1,009

Hi,

try this.

sort itab by vendor.

loop at itab into fs.

at new vendor.

write 😕 fs-vendor.

sum.

endat.

at end of vendor.

write : fs-amount.

endat.

endloop.

Read only

qamar_javed
Participant
0 Likes
1,009

Hi Karthikeyan,

Use this code :

Sort int_table By vendor.

LOOP AT int_table INTO wa_table.

AT NEW vendor.

Write : 'Vendor' , wa_table-vendor.

SKIP.

Write : / 1(20) 'Document No', 22(20) 'Net Amount'.

ENDAT.

Write : / 1(20) wa_table-document , 22(20) wa_table-netamt.

AT END OF vendor.

SUM.

ULINE.

Write : / 'Total', wa_table-netamt UNDER wa_table-netamt.

ULINE.

ENDAT.

ENDLOOP.

Hope this helps.

Regards,

Qamar.

Read only

Former Member
0 Likes
1,009

Use Control Break Statement.

AT END OF Vendor No.

SUM.

END AT.

Regards,

Joan

Read only

Former Member
0 Likes
1,009

hI ,

You can use

at end of vendor.

sum.........

endat.

at end of vendor

write sum.

endat.

Read only

Former Member
0 Likes
1,009

Hi Karthick,

Here is a sample code to display subtotals on alv grid control,

U hv to create a screen & set pf-status



data:
begin of t_itab occurs 0.
     include structure sflight.
data end of t_itab.

**declaring the container & grid for output table display**
data:
r_container type ref to cl_gui_custom_container,
r_grid type ref to cl_gui_alv_grid.

**structure of layout**
data:
  fs_lay type lvc_s_layo.

**Field Catalog**
data:
 t_fcat type lvc_t_fcat,
 fs_fcat type lvc_s_fcat.

**Sort table**
data: t_sort type lvc_t_sort,
      fs_sort type lvc_s_sort.

select * from sflight into corresponding fields of table t_itab.



  fs_fcat-fieldname = 'PRICE'.
  fs_fcat-do_sum = 'X'.
  append fs_fcat to t_fcat.

  fs_sort-spos = 1.
  fs_sort-fieldname = 'CONNID'. " here give fieldname as VENDOR, it gives u total amt based on vendor
  fs_sort-up = 'X'.
  fs_sort-subtot = 'X'.
  append fs_sort to t_sort.

*--------------------------------------------------------------------------------
call screen 100.
*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module status_0100 output.
  set pf-status 'SCREEN1'.

endmodule.                 " STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module user_command_0100 input.
  case sy-ucomm.
    when 'BACK'.
      leave to screen 0.
    when 'EXIT'.
    leave program.
  endcase.
endmodule.                 " USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*&      Module  LIST  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module list output.
  create object r_container
    exporting
      container_name = 'CCONTAINER2'.

  create object r_grid
    exporting
      i_parent = r_container.
*passing the layout structure, fieldcatalog and output table for display*
  call method r_grid->set_table_for_first_display
    exporting
      i_structure_name = 'SFLIGHT'
      IS_LAYOUT = fs_lay
    changing

      it_fieldcatalog  = t_fcat
      it_sort          = t_sort
      it_outtab        = t_itab[].



endmodule.                 " LIST  OUT

Regards,

Mdi.Deeba