2009 Mar 24 1:07 PM
Hi all,
This is the standard report (CS12). I copied this report and added some addidtional fields to standard report.
I added this *Extended * field . I want to display this total value for this field. For that i add this logic.
But it is not working .... Plz Help me ASAP.
LOOP AT stb.
stb-index = sy-tabix.
modify stb.
PERFORM alv_stb_prep.
perform cs12_alv1.
ENDLOOP.
PERFORM stb_fields_tb_prep.
alvlo_stb-info_fieldname = 'INFO'.
alvvr-handle = '1'. "note 877609
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = report_name
i_structure_name = 'STPOX_ALV'
is_layout = alvlo_stb
i_save = alvvr_sav_all
is_variant = alvvr
it_events = alv_evnt_tb_cmpl
it_fieldcat = stb_fields_tb
it_sort = it_sort
i_default = 'X'
i_save = 'A'
TABLES
t_outtab = alv_stb
.
IF sy-subrc = 0.
IF exit_by_caller = 'X'.
Forced Exit by calling program
<do_something>.
ELSE.
User left list via F3, F12 or F15
IF exit_by_user-back = 'X'. "F3
<do_something>.
ELSE.
IF exit_by_user-exit = 'X'. "F15
<do_something>.
ELSE.
IF exit_by_user-cancel = 'X'. "F12
<do_something>.
ELSE.
should not occur!
<do_Abnormal_End>.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ELSE.
Fatal error callin ALV
MESSAGE AXXX(XY) WITH ...
ENDIF.
IF sy-subrc <> 0.
MESSAGE s513 WITH 'E: '.
EXIT.
ENDIF.
ENDFORM. "cs13_alv
FORM stb_fields_tb_prep.
CALL FUNCTION 'DDIF_FIELDINFO_GET' "uc 070302
EXPORTING "uc 070302
LANGU = SY-LANGU "uc 070302
TABNAME = 'STPOX_ALV' "uc 070302
UCLEN = '01' "uc 070302
TABLES "uc 070302
DFIES_TAB = ftab "uc 070302
EXCEPTIONS "uc 070302
OTHERS = 1. "uc 070302
*READ TABLE FTAB INTO FTAB INDEX 1.
CLEAR FTAB.
FTAB-TABNAME = 'STPOX_ALV'.
FTAB-FIELDNAME = 'ZLIFNR'.
FTAB-POSITION = '641'.
FTAB-LANGU = 'E'.
FTAB-DOMNAME = 'TEXT40'.
FTAB-LENG = '100'.
FTAB-INTLEN = 100.
FTAB-OUTPUTLEN = 100.
FTAB-DATATYPE = 'CHAR'.
FTAB-INTTYPE = 'C'.
FTAB-PRECFIELD = 'STPOX_ALV'.
FTAB-HEADLEN = '1'.
FTAB-DYNPFLD = 'X'.
FTAB-FIELDTEXT = 'VENDOR'.
FTAB-SCRTEXT_S = 'VENDOR'.
FTAB-SCRTEXT_M = 'VENDOR'.
FTAB-SCRTEXT_L = 'VENDOR'.
APPEND FTAB.
CLEAR FTAB.
FTAB-TABNAME = 'STPOX_ALV'.
FTAB-FIELDNAME = 'ZMFPNR'.
FTAB-POSITION = '640'.
FTAB-LANGU = 'E'.
FTAB-DOMNAME = 'TEXT40'.
FTAB-LENG = '250'.
FTAB-INTLEN = 250.
FTAB-OUTPUTLEN = 250.
FTAB-DATATYPE = 'CHAR'.
FTAB-INTTYPE = 'C'.
FTAB-PRECFIELD = 'STPOX_ALV'.
FTAB-HEADLEN = '1'.
FTAB-DYNPFLD = 'X'.
FTAB-FIELDTEXT = 'MANUFACATURER MPN'.
FTAB-SCRTEXT_S = 'MANUFACATURER MPN'.
FTAB-SCRTEXT_M = 'MANUFACATURER MPN'.
FTAB-SCRTEXT_L = 'MANUFACATURER MPN'.
APPEND FTAB.
CLEAR FTAB.
FTAB-TABNAME = 'STPOX_ALV'.
FTAB-FIELDNAME = 'PRICE'.
FTAB-POSITION = '642'.
FTAB-LANGU = 'E'.
FTAB-DOMNAME = 'TEXT40'.
FTAB-LENG = '250'.
FTAB-INTLEN = 250.
FTAB-OUTPUTLEN = 250.
FTAB-DATATYPE = 'CHAR'.
FTAB-INTTYPE = 'C'.
FTAB-PRECFIELD = 'STPOX_ALV'.
FTAB-HEADLEN = '1'.
FTAB-DYNPFLD = 'X'.
FTAB-FIELDTEXT = 'PRICE'.
FTAB-SCRTEXT_S = 'PRICE'.
FTAB-SCRTEXT_M = 'PRICE'.
FTAB-SCRTEXT_L = 'PRICE'.
APPEND FTAB.
CLEAR FTAB.
FTAB-TABNAME = 'STPOX_ALV'.
FTAB-FIELDNAME = 'MENGE'.
FTAB-POSITION = '643'.
FTAB-LANGU = 'E'.
FTAB-DOMNAME = 'TEXT40'.
FTAB-LENG = '250'.
FTAB-INTLEN = 250.
FTAB-OUTPUTLEN = 250.
FTAB-DATATYPE = 'QUAN'.
FTAB-INTTYPE = 'P'.
FTAB-PRECFIELD = 'STPOX_ALV'.
FTAB-HEADLEN = '1'.
FTAB-DYNPFLD = 'X'.
FTAB-FIELDTEXT = 'Quantity'.
FTAB-SCRTEXT_S = 'Quantity'.
FTAB-SCRTEXT_M = 'Quantity'.
FTAB-SCRTEXT_L = 'Quantity'.
APPEND FTAB.
CLEAR FTAB.
FTAB-TABNAME = 'STPOX_ALV'.
FTAB-FIELDNAME = 'PRICEUNIT'.
FTAB-POSITION = '644'.
FTAB-LANGU = 'E'.
FTAB-DOMNAME = 'TEXT40'.
FTAB-LENG = '250'.
FTAB-INTLEN = 250.
FTAB-OUTPUTLEN = 250.
FTAB-DATATYPE = 'CHAR'.
FTAB-INTTYPE = 'C'.
FTAB-PRECFIELD = 'STPOX_ALV'.
FTAB-HEADLEN = '1'.
FTAB-DYNPFLD = 'X'.
FTAB-FIELDTEXT = 'PRICEUNIT'.
FTAB-SCRTEXT_S = 'PRICEUNIT'.
FTAB-SCRTEXT_M = 'PRICEUNIT'.
FTAB-SCRTEXT_L = 'PRICEUNIT'.
APPEND FTAB.
CLEAR FTAB.
FTAB-TABNAME = 'STPOX_ALV'.
FTAB-FIELDNAME = 'PRICEEACH'.
FTAB-POSITION = '665'.
FTAB-LANGU = 'E'.
FTAB-DOMNAME = 'TEXT40'.
FTAB-LENG = '250'.
FTAB-INTLEN = 250.
FTAB-OUTPUTLEN = 250.
FTAB-DATATYPE = 'CHAR'.
FTAB-INTTYPE = 'C'.
FTAB-PRECFIELD = 'STPOX_ALV'.
FTAB-HEADLEN = '1'.
FTAB-DYNPFLD = 'X'.
FTAB-FIELDTEXT = 'PRICEEACH'.
FTAB-SCRTEXT_S = 'PRICEEACH'.
FTAB-SCRTEXT_M = 'PRICEEACH'.
FTAB-SCRTEXT_L = 'PRICEEACH'.
APPEND FTAB.
CLEAR FTAB.
FTAB-TABNAME = 'STPOX_ALV'.
FTAB-FIELDNAME = 'EXTENDED'.
FTAB-do_sum = 'X'.
FTAB-POSITION = '695'.
FTAB-LANGU = 'E'.
FTAB-DOMNAME = 'TEXT40'.
FTAB-LENG = '250'.
FTAB-INTLEN = 250.
FTAB-OUTPUTLEN = 250.
FTAB-DATATYPE = 'NUMC'.
FTAB-INTTYPE = 'N'.
FTAB-PRECFIELD = 'STPOX_ALV'.
FTAB-HEADLEN = '1'.
FTAB-DYNPFLD = 'X'.
FTAB-FIELDTEXT = 'EXTENDED'.
FTAB-SCRTEXT_S = 'EXTENDED'.
FTAB-SCRTEXT_M = 'EXTENDED'.
FTAB-SCRTEXT_L = 'EXTENDED'.
APPEND FTAB.
CLEAR FTAB.
FTAB-TABNAME = 'STPOX_ALV'.
FTAB-FIELDNAME = 'EKGRP1'.
FTAB-do_sum = 'X'.
FTAB-POSITION = '720'.
FTAB-LANGU = 'E'.
FTAB-DOMNAME = 'TEXT40'.
FTAB-LENG = '250'.
FTAB-INTLEN = 250.
FTAB-OUTPUTLEN = 250.
FTAB-DATATYPE = 'CHAR'.
FTAB-INTTYPE = 'C'.
FTAB-PRECFIELD = 'STPOX_ALV'.
FTAB-HEADLEN = '1'.
FTAB-DYNPFLD = 'X'.
FTAB-FIELDTEXT = 'PURCHASE GROUP'.
FTAB-SCRTEXT_S = 'PURCHASE GROUP'.
FTAB-SCRTEXT_M = 'PURCHASE GROUP'.
FTAB-SCRTEXT_L = 'PURCHASE GROUP'.
APPEND FTAB.
wa_sort-spos = 1.
wa_sort-fieldname = 'EXTENDED'.
wa_sort-tabname = 'ALV_STB'.
wa_sort-up = 'X'.
wa_sort-subtot = 'X'. "subtotal by this field
APPEND wa_sort TO it_sort.
CLEAR wa_sort.
LOOP AT ftab.
CLEAR: wa_stb_fields_tb.
CASE ftab-fieldname.
WHEN 'DGLVL'.
wa_stb_fields_tb-fieldname = 'DGLVL'.
wa_stb_fields_tb-col_pos = 1.
wa_stb_fields_tb-fix_column = 'X' .
wa_stb_fields_tb-key = ' '. "SUBTOTAL KEY
wa_stb_fields_tb-Do_sum = 'X'.
wa_stb_fields_tb-outputlen = 11.
wa_stb_fields_tb-just = 'L' .
APPEND wa_stb_fields_tb TO stb_fields_tb.
WHEN 'DOBJT'.
wa_stb_fields_tb-fieldname = 'DOBJT'.
wa_stb_fields_tb-col_pos = 4.
wa_stb_fields_tb-fix_column = 'X' .
wa_stb_fields_tb-outputlen = 23 .
APPEND wa_stb_fields_tb TO stb_fields_tb.
WHEN 'OJTXP'.
wa_stb_fields_tb-fieldname = 'OJTXP'.
wa_stb_fields_tb-col_pos = 5.
wa_stb_fields_tb-outputlen = 19.
APPEND wa_stb_fields_tb TO stb_fields_tb.
WHEN 'EXTENDED'.
wa_stb_fields_tb-fieldname = 'EXTENDED'.
wa_stb_fields_tb-col_pos = 15.
wa_stb_fields_tb-outputlen = 20.
wa_stb_fields_tb-do_sum = 'X'.
WA_STB_FIELDS_TB-SELTEXT_L = 'Extended'.
WA_STB_FIELDS_TB-SELTEXT_M = 'TOTAL'.
WA_STB_FIELDS_TB-SELTEXT_S = 'Extended'.
APPEND wa_stb_fields_tb TO stb_fields_tb.
WHEN OTHERS.
wa_stb_fields_tb-fieldname = ftab-fieldname.
wa_stb_fields_tb-no_out = 'X'.
wa_stb_fields_tb-no_sum = 'X'.
APPEND wa_stb_fields_tb TO stb_fields_tb.
ENDCASE.
ENDLOOP.
ENDFORM. "stb_fields_tb_prep
2009 Mar 24 1:39 PM
for a character file you want to do a SUM "TEXT40". check the fields properties?
2009 Mar 24 2:05 PM
Thanks for reply. this are the field properties:
CLEAR FTAB.
FTAB-TABNAME = 'STPOX_ALV'.
FTAB-FIELDNAME = 'EXTENDED'.
FTAB-do_sum = 'X'.
FTAB-POSITION = '695'.
FTAB-LANGU = 'E'.
FTAB-DOMNAME = 'TEXT40'.
FTAB-LENG = '250'.
FTAB-INTLEN = 250.
FTAB-OUTPUTLEN = 250.
FTAB-DATATYPE = 'NUMC'.
FTAB-INTTYPE = 'N'.
FTAB-PRECFIELD = 'STPOX_ALV'.
FTAB-HEADLEN = '1'.
FTAB-DYNPFLD = 'X'.
FTAB-FIELDTEXT = 'EXTENDED'.
FTAB-SCRTEXT_S = 'EXTENDED'.
FTAB-SCRTEXT_M = 'EXTENDED'.
FTAB-SCRTEXT_L = 'EXTENDED'.
APPEND FTAB.
Thanks and Regards