2008 Dec 24 4:31 AM
hello dear,
how can i calculate total from a fields to get value,i am using table bset and i have to calculate total of fields fwste in according to hkont and belnr to get exice amount please refer some related programs.
hello dear,
how can i calculate total from a fields to get value,i am using table bset and i have to calculate total of fields fwste in according to hkont and belnr to get exice amount please refer some related programs.
2008 Dec 24 4:37 AM
Hi,
If you are using ALV Grid display, you will get all the options in the output of the report display for adding the values, for sorting the values and also for the download of the data to the local pc.
2008 Dec 24 4:39 AM
i didn't got your reply clearly can you please give me some examples.
2008 Dec 24 4:44 AM
Hello
Please use the FM 'REUSE_ALV_GRID_DISPLAY' instead of 'REUSE_ALV_LIST_DISPLAY'.
2008 Dec 24 4:43 AM
2008 Dec 24 5:40 AM
Hi,
If you use function madule 'REUSE_ALV_GRID_DISPLAY' or 'REUSE_ALV_LIST_DISPLAY' then all the options (colum alignment, sorting, filtering, totals, sub totals & etc) you will get .
Regards
Md.MahaboobKhan
2008 Dec 24 6:34 AM
Hi ,
If you want total for a particular column at the end , the
WA_FLD_CATALOG-FIELDNAME = P_FIELDNAME.
WA_FLD_CATALOG-TABNAME = P_REF_TABLE.
WA_FLD_CATALOG-SELTEXT_S = P_SCRTEXT.
WA_FLD_CATALOG-SELTEXT_M = P_SCRTEXT.
WA_FLD_CATALOG-SELTEXT_L = P_SCRTEXT.
WA_FLD_CATALOG-OUTPUTLEN = 15.
WA_FLD_CATLOG_DO_SUM = 'X' "<=======Display column total
APPEND WA_FLD_CATALOG TO IT_FLD_CATALOG.
-
or if you want to sum two or more field to generate the thierd field , then you need to add one more field in your internal table , then loop thrue the table and add the field you want to generate the resultant field , change field catalog for the added column.
i.e. you need to write the login to do the some of field's
2008 Dec 24 6:55 AM
Moderator message: do not type message in ALL CAPITALS
YA THIS ANSWER CAN SOLVE MY PROBLEM BUT IF YOU PLEASE GIVE ME SOME EXAMPLE TO CALCULATE SUM OF TWO OR MORE FIELDS TO GENERATE THIRD FIELDS THEN PLEASE REFER ME.
Edited by: Matt on Dec 25, 2008 7:36 AM
2008 Dec 25 7:16 AM
how can i calculate sum two or more field to generate the third field i am using table bset and i have to calculate total of fields HWSTE so please give me some related program for this solution.
2008 Dec 24 6:56 AM
Hi,
You just try this FM 'REUSE_ALV_GRID_DISPLAY' or 'REUSE_ALV_LIST_DISPLAY' and you will get the same.
Regards,
Anki.
2008 Dec 24 6:58 AM
Moderator message: do not type message in ALL CAPITALS
ALREADY I AM DOING LIKE THAT ONLY BUT IT NOT COMING SO IF THERE IS ANY RELATED PROGRAM THEN PLZ REFER ME.
Edited by: Matt on Dec 25, 2008 7:37 AM
2008 Dec 24 8:33 AM
2008 Dec 24 8:54 AM
Hi,
Find the code below which souits your requirement.
TYPE-POOLS : slis.
TYPES : BEGIN OF itab_t,
ebeln LIKE ekpo-ebeln,
lifnr LIKE ekko-lifnr,
ekorg LIKE ekko-ekorg,
ekgrp LIKE ekko-ekgrp,
werks LIKE ekpo-werks,
ebelp LIKE ekpo-ebelp,
matnr LIKE ekpo-matnr,
menge LIKE ekpo-menge,
netpr LIKE ekpo-netpr,
d, "Dummy field to fire the Subtotal text event
END OF itab_t.
DATA: itab TYPE TABLE OF itab_t.
DATA: tab TYPE itab_t.
DATA : itab1 LIKE eket OCCURS 0 WITH HEADER LINE.
DATA: t_fcat TYPE slis_t_fieldcat_alv,
it_sort TYPE slis_t_sortinfo_alv,
t_events TYPE slis_t_event,
listhead TYPE slis_t_listheader,
ls_layout TYPE slis_layout_alv.
START-OF-SELECTION.
SELECT a~ebeln
a~lifnr
a~ekorg
a~ekgrp
b~werks
b~ebelp
b~matnr
b~menge
b~netpr
UP TO 100 ROWS
INTO CORRESPONDING FIELDS OF TABLE itab
FROM ekko AS a INNER JOIN ekpo AS b
ON a~ebeln = b~ebeln.
END-OF-SELECTION.
PERFORM fill_fcat USING t_fcat.
PERFORM fill_event USING t_events.
PERFORM fill_layout.
PERFORM display.
*&---------------------------------------------------------------------*
*& Form fill_fcat
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_T_FCAT text
*----------------------------------------------------------------------*
FORM fill_fcat USING p_t_fcat TYPE slis_t_fieldcat_alv.
DATA : lfcat TYPE slis_fieldcat_alv,
colpos TYPE i VALUE '0'.
DATA : ls_sort TYPE slis_sortinfo_alv.
colpos = colpos + 1.
lfcat-col_pos = colpos.
lfcat-fieldname = 'EBELN'.
lfcat-tabname = 'ITAB'.
lfcat-ref_fieldname = 'EBELN'.
lfcat-ref_tabname = 'EKKO'.
lfcat-hotspot = 'X'.
APPEND lfcat TO p_t_fcat.
CLEAR lfcat.
colpos = colpos + 1.
lfcat-col_pos = colpos.
lfcat-fieldname = 'LIFNR'.
lfcat-tabname = 'ITAB'.
lfcat-ref_fieldname = 'LIFNR'.
lfcat-ref_tabname = 'EKKO'.
APPEND lfcat TO p_t_fcat.
CLEAR lfcat.
colpos = colpos + 1.
lfcat-col_pos = colpos.
lfcat-fieldname = 'EKORG'.
lfcat-tabname = 'ITAB'.
lfcat-ref_fieldname = 'EKORG'.
lfcat-ref_tabname = 'EKKO'.
APPEND lfcat TO p_t_fcat.
CLEAR lfcat.
colpos = colpos + 1.
lfcat-col_pos = colpos.
lfcat-fieldname = 'EKGRP'.
lfcat-tabname = 'ITAB'.
lfcat-ref_fieldname = 'EKGRP'.
lfcat-ref_tabname = 'EKKO'.
APPEND lfcat TO p_t_fcat.
CLEAR lfcat.
colpos = colpos + 1.
lfcat-col_pos = colpos.
lfcat-fieldname = 'WERKS'.
lfcat-tabname = 'ITAB'.
lfcat-ref_fieldname = 'WERKS'.
lfcat-ref_tabname = 'EKPO'.
APPEND lfcat TO p_t_fcat.
CLEAR lfcat.
colpos = colpos + 1.
lfcat-col_pos = colpos.
lfcat-fieldname = 'EBELP'.
lfcat-tabname = 'ITAB'.
lfcat-ref_fieldname = 'EBELP'.
lfcat-ref_tabname = 'EKPO'.
APPEND lfcat TO p_t_fcat.
CLEAR lfcat.
colpos = colpos + 1.
lfcat-col_pos = colpos.
lfcat-fieldname = 'MATNR'.
lfcat-tabname = 'ITAB'.
lfcat-ref_fieldname = 'MATNR'.
lfcat-ref_tabname = 'EKPO'.
APPEND lfcat TO p_t_fcat.
CLEAR lfcat.
colpos = colpos + 1.
lfcat-col_pos = colpos.
lfcat-fieldname = 'MENGE'.
lfcat-tabname = 'ITAB'.
lfcat-ref_fieldname = 'MENGE'.
lfcat-ref_tabname = 'EKPO'.
lfcat-do_sum = 'X'.
APPEND lfcat TO p_t_fcat.
CLEAR lfcat.
colpos = colpos + 1.
lfcat-col_pos = colpos.
lfcat-fieldname = 'NETPR'.
lfcat-tabname = 'ITAB'.
lfcat-ref_fieldname = 'NETPR'.
lfcat-ref_tabname = 'EKPO'.
lfcat-do_sum = 'X'.
APPEND lfcat TO p_t_fcat.
CLEAR lfcat.
colpos = colpos + 1.
lfcat-col_pos = colpos.
lfcat-fieldname = 'D'.
lfcat-tabname = 'ITAB'.
lfcat-ref_fieldname = 'EBELN'.
lfcat-ref_tabname = 'EKKO'.
lfcat-no_out = 'X'.
APPEND lfcat TO p_t_fcat.
CLEAR lfcat.
ls_sort-spos = 1.
ls_sort-fieldname = 'EBELN'.
ls_sort-tabname = 'ITAB'.
ls_sort-up = 'X'.
ls_sort-group = 'UL'.
APPEND ls_sort TO it_sort.
CLEAR ls_sort.
ls_sort-spos = 2.
ls_sort-fieldname = 'D'.
ls_sort-tabname = 'ITAB'.
ls_sort-up = 'X'.
ls_sort-group = 'UL'.
ls_sort-subtot = 'X'.
APPEND ls_sort TO it_sort.
ENDFORM. " fill_fcat
*&---------------------------------------------------------------------*
*& Form fill_event
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_T_EVENTS text
*----------------------------------------------------------------------*
FORM fill_event USING p_t_events TYPE slis_t_event.
DATA : ls_event TYPE slis_alv_event.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = p_t_events
EXCEPTIONS
list_type_wrong = 1
OTHERS = 2.
IF sy-subrc NE 0.
ENDIF.
READ TABLE p_t_events WITH KEY name = slis_ev_top_of_page
INTO ls_event.
IF sy-subrc = 0.
MOVE 'TOP_OF_PAGE' TO ls_event-form.
APPEND ls_event TO p_t_events.
ENDIF.
READ TABLE p_t_events WITH KEY name = slis_ev_subtotal_text
INTO ls_event.
IF sy-subrc = 0.
MOVE 'SUBTOTAL' TO ls_event-form.
APPEND ls_event TO p_t_events.
ENDIF.
ENDFORM. " FILL_EVENT
*&---------------------------------------------------------------------*
*& Form subtotal
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->I_LISTHEAD text
* -->I_SUBTOTAL text
*----------------------------------------------------------------------*
FORM subtotal USING i_listhead STRUCTURE tab
i_subtotal TYPE slis_subtot_text.
*criteria type slis_fieldname,
DATA: keyword LIKE dd03p-reptext,
criteria_text(255) TYPE c,
max_len LIKE dd03p-outputlen,
display_text_for_subtotal(255) TYPE c.
IF i_subtotal-criteria = 'D'.
i_subtotal-display_text_for_subtotal = 'Test Subtotal text'.
"here you need to do some calculations and assing the data
"back to total line
ENDIF.
ENDFORM. "SUBTOTAL
*&---------------------------------------------------------------------*
*& Form top_of_page
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM top_of_page.
DATA : s_listhead TYPE slis_listheader.
CLEAR s_listhead.
s_listhead-typ = 'H'.
s_listhead-info = 'SIMPLE REPORT'.
APPEND s_listhead TO listhead.
s_listhead-typ = 'S'.
s_listhead-key = 'EBELN'.
s_listhead-info = 'ALV'.
APPEND s_listhead TO listhead.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = listhead
i_logo = 'ENJOYSAP_LOGO'.
ENDFORM. "TOP_OF_PAGE
*&---------------------------------------------------------------------*
*& Form fill_layout
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM fill_layout .
ls_layout-zebra = 'X'.
ls_layout-detail_popup = 'X'.
ls_layout-key_hotspot = 'X'.
ls_layout-window_titlebar = 'Test Title'.
ls_layout-totals_text = 'GRAND TOTAL'.
ls_layout-subtotals_text = 'SUB'.
ENDFORM. " fill_layout
*&---------------------------------------------------------------------*
*& Form display
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM display .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
it_sort = it_sort[]
it_events = t_events
it_fieldcat = t_fcat
TABLES
t_outtab = itab
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc NE 0.
ENDIF.
ENDFORM. " displayHope this helps,
Murthy.
2008 Dec 24 10:11 AM
yes it help me lot but not totally i want to calculate exise and vat in respect to purchse invoice number from me23n as i am doing alv reports so how can i get the solution plz refer some program like before so i can solve my problem.
2008 Dec 24 10:23 AM
2008 Dec 24 11:34 AM
again i get stuck because i have to put matnr mblnr maktx menge meins belnr excise vat and netvalue with mseg makt bseg and ekpo tables.i have to calculate excise and vat in respect to purchase invoice document number so please refer some related program which include all these functionality.
2008 Dec 24 10:25 AM
If you want to calculate th e third filed based on other two, you would need to do it programatically using control break statements like AT NEW / AT END OF ect ..
Below is sample program which does summary based on mrp controllers and other parameeters.
2008 Dec 24 11:05 AM
again i get stuck because i have to put matnr mblnr maktx menge meins belnr excise vat and netvalue with mseg makt bseg and ekpo tables.i have to calculate excise and vat in respect to purchase invoice document number so please refer some related program which include all these functionality.
2008 Dec 24 11:26 AM
2008 Dec 24 11:32 AM
2009 May 22 2:18 PM
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |