Application Development 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: 

Problems with itab: subtotal

Former Member
0 Kudos

hi,

i've got some problems with the report which i should write.

1.

i have to move to the negative values of the itab-field betrh to the itab-field verb and the positiv to the itab-field ford, but i don't know how to do this.

2.

i have to make sub-totals for each gpart which should be displayed in the alv-grid in the itab-field Saldo.

DATA: BEGIN OF itab OCCURS 1000,

      gs       TYPE dimaiobpar-zgst,
      status   TYPE dimaiobpar-zstatus,
      bukrs    TYPE dfkkop-bukrs,
      betrh    TYPE dfkkop-betrh,
      verb     TYPE dfkkop-betrh,
      ford     TYPE dfkkop-betrh,
      saldo    TYPE dfkkop-betrh,
      gpart    TYPE dfkkop-gpart,
      vtref    TYPE dfkkop-vtref,
      mtyp     TYPE dimabroker-brostmtyp,
      n1       TYPE adrc-name1,
      n2       TYPE adrc-name2,
      n3       TYPE adrc-name3,
      abrtyp   TYPE dimaiobpar-zabrtyp,
      vertart  TYPE dimaiobpar-zvat,
      zrtyp    TYPE dimaiobpar-azawe_x,
      opbel    TYPE dfkkop-opbel,

      END OF itab.

regards,

Tobias

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Once data is populated into itab which -ve and +ve values .

Loop at itab.

if itab-betrh LT 0.
itab-verb = itab-betrh
else.
itab-ford = itab-betrh.
endif.
modify itab.
clear itab.
endloop.

before ALV display add the below code :

  DATA: ls_sort TYPE slis_sortinfo_alv,
             gt_sort       TYPE slis_t_sortinfo_alv.


  CLEAR ls_sort.
  ls_sort-fieldname = 'SALDO'.
  ls_sort-up        = 'X'.
  ls_sort-subtot    = 'X'.
  APPEND ls_sort TO gt_sort.

And pass gt_sort to it_sort of ALV grid display export parameter.

Thanks,

Sriram Ponna.

4 REPLIES 4

Former Member
0 Kudos

Hi,

Once data is populated into itab which -ve and +ve values .

Loop at itab.

if itab-betrh LT 0.
itab-verb = itab-betrh
else.
itab-ford = itab-betrh.
endif.
modify itab.
clear itab.
endloop.

before ALV display add the below code :

  DATA: ls_sort TYPE slis_sortinfo_alv,
             gt_sort       TYPE slis_t_sortinfo_alv.


  CLEAR ls_sort.
  ls_sort-fieldname = 'SALDO'.
  ls_sort-up        = 'X'.
  ls_sort-subtot    = 'X'.
  APPEND ls_sort TO gt_sort.

And pass gt_sort to it_sort of ALV grid display export parameter.

Thanks,

Sriram Ponna.

Former Member
0 Kudos

Hi,

1)

loop at itab.

if itab-betrh < 0.

itab-verb = itab-betrh.

else if itab-betrh > 0.

itab-ford = itab-betrh.

endif.

modify itab.

at end of (changing field name for which u want to add totals)

sum.

itab-saldo = itab-gpart.

endat.

modify itab.

endloop.

Try as above

Regards,

Subbu

Former Member
0 Kudos

Hi,

1.) You can loop the table itab and if the value of berth is negagive, move the same to itab-field VERB else move the values to the field Itab-field ford.

at the end of the loop modify your table itab.

2.) For Subtotal, while preparing sort table of your field catalaog, say subtotal = 'X'. If you are not able to find this read the documentation of the FM, to get details. You should get to know some more things tis way.

Hope this would help.

Regards,

Lalit

Former Member
0 Kudos

ok thx

the loop is working.

but the subtotal only makes a summary of the itab-field ford.

i need the subtotal of ford and verb so that i get the account balance for each gpart.