05-28-2009 10:20 AM
Hi all,
i have this ready alv report in abap code.
I want to add field omeng from table vbbe. In this table this field has multiple lines according to field vbtyp which has the values j and c.
I want to print in the report a field which will add all values from vbbe-omeng when vbtyp=j and print the sum
Could you give me the small code which I have to add in the report?
I have done everythink else needed (added vbbe, omeng in the report etc) all I want is the code to make the sum and print it in the report
05-28-2009 10:47 AM
Hi theodoros,
Can you plz tell in detail....
U are displaying all OMENG (i.e, VBTYP = 'J' and 'C') or only VBTYP = 'J'.
and when VBTYP = 'J' , sum u want to display as total at end of report column 'OMENG'?
05-28-2009 10:36 AM
Hi,
You can LOOP on your internal table and calculate the sum.
LOOP AT ITAB INTO WA WHERE VBTYP = j.
SUM_FIELD = SUM_FIELD + WA-OMENG.
ENDLOOP.
If you can show your code it would be more helpful in understanding your requirment.
Regards,
Ankur Parab
05-28-2009 10:45 AM
thanks for reply.
OK i have done the code and if I put a break point in the porgram I take the sum, but when I print and add the field the field says 0,
can you tell me what should I do to print the sum in the field i created??
Thank you
05-28-2009 10:46 AM
05-28-2009 10:40 AM
05-28-2009 10:47 AM
Hi theodoros,
Can you plz tell in detail....
U are displaying all OMENG (i.e, VBTYP = 'J' and 'C') or only VBTYP = 'J'.
and when VBTYP = 'J' , sum u want to display as total at end of report column 'OMENG'?
05-28-2009 10:50 AM
I want to add in a sum the omeng when vbtyp=j, and print this sum in a column in the report,
I have done the sum, but the field I added in the report print 0. What should I do to print the sum?
ASny ideas???
Thank you
05-28-2009 10:57 AM
Hi,
In Which field are you calculating the sum?
Can you post your code so that people out here can have a look?
Regards,
Ankur PArab
05-28-2009 10:59 AM
Its very difficult to tell without seeing that part of code.
is it possible to paste it here?
05-28-2009 11:20 AM
i have added in form select_data the following code.
data zsum like VBBE-OMENG.
zsum = 0.
DATA: BEGIN OF test OCCURS 0,
OMENG LIKE VBBE-OMENG,
END OF test.
SELECT *
FROM VBBE
INTO CORRESPONDING FIELDS OF TABLE test
WHERE VBTYP = 'J' AND MATNR = IT_MATERIALS-MATNR.
LOOP AT test.
ZSUM = ZSUM + test-OMENG.
ENDLOOP.
ta_list-zomeng = ZSUM.
tta_list-zomeng = ta_list-zomeng.
I want to print ZSUM. I cannot copy here the whole report because it is 2000 lines
05-28-2009 11:27 AM
Hi,
You have your code as follows:-
data zsum like VBBE-OMENG.
zsum = 0.
DATA: BEGIN OF test OCCURS 0,
OMENG LIKE VBBE-OMENG,
END OF test.
SELECT *
FROM VBBE
INTO CORRESPONDING FIELDS OF TABLE test
WHERE VBTYP = 'J' AND MATNR = IT_MATERIALS-MATNR.
LOOP AT test.
ZSUM = ZSUM + test-OMENG.
ENDLOOP.
ta_list-zomeng = ZSUM.
tta_list-zomeng = ta_list-zomeng.
Just debug and check if your select statement is successful.
Is your internal table 'TEST' having any records?
Regards,
Ankur Parab
05-28-2009 11:32 AM
Select statement looking fine and ZSUM is collecting sum correctly.
U need to check your fieldcat and table field u r passing in REUSE_***** . its a problem in ur display.
05-28-2009 11:41 AM
the internal table has record, the zsum has the final sum correctly.
What should I do exactly to print this zsum in my report???
05-28-2009 11:46 AM
Hi,
It depends upon how you are displaying the output.
You have given the code as
ta_list-zomeng = ZSUM.
tta_list-zomeng = ta_list-zomeng.
Incase you are using WRITE statement then you simply have to code
WRITE:/ tta_list-zomeng
Incase you are using ALV then you will have to pass it into an internal table and then display theoutput
using REUSE_ALV_LIST_DISPLAY FM.
regards,
Ankur Parab
05-28-2009 12:08 PM
this is th reuse_alv_list_display code in my report
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_interface_check = space "
i_bypassing_buffer = space "
i_buffer_active = space "
i_callback_program = tp_repid_this
i_callback_pf_status_set = co_rout_pf_stat "
i_callback_user_command = co_rout_ucomm "
i_structure_name = co_struc "
is_layout = lst_layout
it_fieldcat = lta_fcat[]
it_excluding = lta_extab[] "
it_special_groups = lta_spec_groups[] "
it_sort = lta_sort_alv[] "
it_filter = lta_filter[] "
is_sel_hide = lst_sel_hide "
i_default = abap_true
i_save = co_save "
is_variant = st_s_variant
it_events = lta_events[] "
it_event_exit = lta_event_exit[] "
is_print = lst_is_print
is_reprep_id = ltp_reprep_id "
i_screen_start_column = 0 "
i_screen_start_line = 0 "
i_screen_end_column = 0 "
i_screen_end_line = 0 "
IMPORTING
e_exit_caused_by_caller = ltp_exit_caller "
es_exit_caused_by_user = lst_exit_user "
TABLES
t_outtab = tta_list
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
in the above lines we can see the table tta_list which I fill with the zsum, stilll i get 0 in the report.
05-28-2009 12:20 PM
Hi,
How many records are there inyour internal table TTA_List?
Is you fieldcatalog correclty created?
Regards,
Ankur Parab
05-28-2009 12:52 PM
I added line
append tta_list in the of the code that makes the sum.
In the results of the alv report, instead of printing the result in the field I want, the result is printed in a new line above the one with all the contents, where only this result exists, and still the field writes 0.
eg.
zomeng plant stock etc matnr
0 ..... ... 1000 .......10pc ...... 1111
12pc.........0..........0.......0
changing the place of my small code for calculating the sum, within the alv report code, i keep on getting different results where it print 2 lines with all data and in one line zomeng is 0 and in other line it contains value.
Where should I put the code for calculating sum within the report code???
Edited by: Theodoros Vourvachis on May 28, 2009 1:53 PM
Edited by: Theodoros Vourvachis on May 28, 2009 1:53 PM
Edited by: Theodoros Vourvachis on May 28, 2009 1:54 PM
Edited by: Theodoros Vourvachis on May 28, 2009 1:54 PM