cancel
Showing results for 
Search instead for 
Did you mean: 

SQ02 infoset - aditional field calculation for total

Former Member
0 Kudos

Hi,

I have  made a simple infoset in SQ02 with billing document header table VBRK and item  VBRP.  In item table I have VBRP-VOLUM which displays  item volume.

The task is to get total volume per invoice VBRK-VBELN

To get total volume per invoice I can simply use subtotals functions directly in SQ01 queary, but instead I want to :

1) add aditional field  in  infoset - this I can do it through infoset extras -ok

2) in code section for this field  whrite abap code that would calculate  total sum of VBRP-VOLUM per invoice. Here I need help - what codes lines should I enter ?

probably this simple code but I am not Abaper so ask for help

Accepted Solutions (0)

Answers (3)

Answers (3)

Jelena
Active Contributor
0 Kudos

@Satyen - there is actually SELECT ... SUM() available, look it up.

@OP - if you don't actually need any fields from VBRP then not including it in the join and reading data directly instead would be an option (although not the most efficient one).

If you do need to see VBRP data but are expecting the field to have total value just once per invoice (and other lines would have a blank value) then you could make some assumptions and fill in the field. But if the users change the layout (e.g. sort by a date) then this solution goes out the window because it requires data to be sorted by invoice.

Someone has already asked a similar question on SCN not long ago, search for 'custom total query' or something like that.

Former Member
0 Kudos

This message was moderated.

Former Member
0 Kudos

hi,

Create infoset with direct table vbrk.

then Declar field lv_total for total in infoset.

In Extra code,

Write below logic.

clear Lv_total.

Select data from vbrp base on billing document coming from vbrk.

then Sum the total from vbrp using loop statement.

like...

loop at vbrp.

lv_total = lv_total + vbrp-(ur field).

endloop.


Regards,

Satyen Trivedi

Former Member
0 Kudos

Nobody has any comment on this  ?