Edit Total line in ALV

Hi,
I want to display the total of lines on the subtotal line of my grid.
As I don't have this field on my catalog, I think I would have to edit the total line to set the total of regs above...
Could someone help me?
Tks.
Regards,
Flavio.

You can do that using the event SUBTOTAL_TEXT .
REPORT ZTEST_ALV_TEXT .
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 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
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 USING I_LISTHEAD STRUCTURE tab
I_SUBTOTAL TYPE SLIS_SUBTOT_TEXT.
*criteria type slis_fieldname,
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 = 'Sub total'.
endif.
ENDFORM.
*& 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'
I_END_OF_LIST_GRID =
endform. "TOP_OF_PAGE
*& Form fill_layout
text
-->P_S_LAYOUT text
form fill_layout .
ls_layout-zebra = 'X'.
ls_layout-detail_popup = 'X'.
ls_layout-key_hotspot = 'X'.
ls_layout-window_titlebar = 'Dharma'.
ls_layout-detail_titlebar = 'Jasti'.
ls_layout-totals_text = 'GRAND TOTAL'.
ls_layout-subtotals_text = 'SUB'.
endform. " fill_layout
*& Form display
text
--> p1 text
<-- p2 text
form display .
call function 'REUSE_ALV_LIST_DISPLAY'
exporting
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
i_callback_program = sy-repid
i_callback_pf_status_set = 'STATUS'
i_callback_user_command = 'USER_COMMAND'
I_STRUCTURE_NAME =
is_layout = ls_layout
it_fieldcat = t_fcat
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
it_sort = it_sort[]
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
it_events = t_events
IT_EVENT_EXIT =
IS_PRINT =
IS_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 =
ES_EXIT_CAUSED_BY_USER =
tables
t_outtab = itab
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
if sy-subrc 0.
MESSAGE ID SY-MSGI D TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
endform. " display
*& Form status
text
-->EXTAB text
form status using extab type slis_t_extab.
set pf-status 'PFSA' excluding extab.
endform. "STATUS
*& Form user_command
text
-->R_UCOMM text
-->RS_SELFIELDtext
form user_command using r_ucomm like sy-ucomm
rs_selfield type slis_selfield.
case r_ucomm.
when '&ETA'.
select * from eket into corresponding fields of itab1
where ebeln = rs_selfield-value.
write:/ itab1-ebeln,
itab1-ebelp,
itab1-etenr,
itab1-eindt,
itab1-menge.
endselect.
when 'BACK' or 'EXIT' or 'CANC'.
leave .
endcase.
endform. "USER_COMMAND

Similar Messages

  • How To avoid column heading for only total line in ALV list Display

    Hi,
    How To avoid column heading for only total line in ALV list Display.

    Hi,
    to change colunm header field catlog is built
    look at the example below
    Changing column text headers
    use this to change, hide, or alter the ALV columns
    CLEAR: gt_fcat.
    READ TABLE gt_fcat WITH KEY fieldname = 'TEXT1' " ***
    *TEXT1 is your field name
       ASSIGNING <gtfcat>.
    IF sy-subrc = 0.
       <gtfcat>-coltext   = 'Date Type'.
       <gtfcat>-no_out    = ' '.
       <gtfcat>-tooltip   = 'Date Type Text from IT0019'.
       <gtfcat>-seltext   = 'IT0019'.
    keep seltext to '' if u want to hide
    ENDIF.
    regards
    austin

  • Check condition on sub total line of ALV list

    Hi All ,
    Is it possible to check  condition on the value of subtotal line in ALV list ,
    I,e If the value of subtotal line is say greator than 100 I need to change the color of that line or change the text on the subtotal line .
    I know how to change the subtotal text but i want to change with respect to value of the subtotal ,
    Any input if this can be achieved will be great .
    Thanks in adv .
    Vinay
    Edited by: vinay kolla on Jul 29, 2009 4:43 AM

    Hi,
    I donu2019t think there is any direct way to check  the subtotal value in LIST display, try the following logic.
    1. Use the event BEFORE_LINE_OUTPUT to check the subtotal value and accordingly change the text or colour of the line.
    2. To use events in ALV, first get the events into a table through the FM REUSE_ALV_EVENTS_GET as shown
         CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
          EXPORTING
          i_list_type = 0
         IMPORTING
          et_events   = z_i_events.
      SORT z_i_events BY name.
      CLEAR z_wa_events.
      READ TABLE z_i_events WITH KEY name = slis_ev_before_line_output
                            INTO z_wa_events BINARY SEARCH.
      IF sy-subrc = 0.
        MOVE 'BEFORE_LINE_OUTPUTu2019 TO z_wa_events-form.
        MODIFY z_i_events FROM z_wa_events INDEX sy-tabix.
      ENDIF.
    3. Create a form with the name BEFORE_LINE_OUTPUT and do the coding to check the subtotals there.
    Form BEFORE_LINE_OUTPUT USING RS_LINEINFO TYPE SLIS_LINEINFO.
    *The structure RS_LINEINFO will have u2018Xu2019 in the field rs_lineinfo-subtot for subtotals.
    If RS_LINEINFO-SUBTOT = u2018Xu2019.
    *Here try to find the totals by looping at your final internal table till rs_lineinfo-tabindex.
    *Then based on this u can give the colour to the line.
    *I think there is no other way to check the subtotal value.
    Endif.
    Endform.
    Edited by: venkatesh PH on Jul 29, 2009 5:31 AM

  • Total and non-total lines in ALV grid

    Hi all,
    Does anyone know if there is any standard SAP functionality for retrieving the non-total/raw item lines that lies beneath a total line in an ALV grid (after the user has selected the total line)?
    All helpful answers will be rewarded!
    Best regards,
    MV

    Try the ALV event AFTER-LINE-OUTPUT may be it can help u to achieve ur requirement.
    Append  AFTER-LINE-OUTPUT event to the internal table T_EVENT.
    CLEAR W_EVENT.
    W_EVENT-FORM = SLIS_EV_AFTER_LINE_OUTPUT.
    W_EVENT-NAME = SLIS_EV_AFTER_LINE_OUTPUT.u201CAFTER_LINE_OUTPUT event
    APPEND W_EVENT TO T_EVENT.
    FORM AFTER_LINE_OUTPUT
      USING P_RS_LINEINFO TYPE SLIS_LINEINFO.
    Here you have to write the logic to retrieve the 'total' line
    ENDFROM.
    Now call the alv FM
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
       EXPORTING
          I_CALLBACK_PROGRAM = L_REPID    "Program Name
          IS_LAYOUT          = W_LAYOUT   "Layout of the Report
          IT_FIELDCAT        = T_FIELDCAT "Field Catalog for Report
          IT_EVENTS          = T_EVENT    "For setting the events
       TABLES
          T_OUTTAB           = T_OUTPUT   "Report data Internal Table
       EXCEPTIONS
          PROGRAM_ERROR      = 1
          OTHERS             = 2.

  • Total line in ALV grid

    Hi,
    Can I use a total line in an ALV grid and hide part of the columns, so that only the total line will be presented for some of the columns ?

    Hi,
    Yes u can use a total column in the ALV Grid.
    Check the code below:
    AT LAST.
          WA_ALV_CAT1-FIELDNAME = 'TOTAL'(004).
          WA_ALV_CAT1-COL_POS = L_I.
          WA_ALV_CAT1-COLTEXT = 'TOTAL'(004).
          WA_ALV_CAT1-JUST =  C_CENTER.   " 'C'.
          APPEND WA_ALV_CAT1 TO L_ALV_CAT1_TAB.
          CLEAR  WA_ALV_CAT1.
        ENDAT.
    Regards
    Kannaiah

  • Identify selection of sub-total line in ALV grid

    Hi folks,
    Is there a way to identify in the report if the user has selected any sub-total line in an ALV grid? Both for REUSE_ALV_GRID_DISPLAY and CL_GUI_ALV_GRID.
    Thanks
    Sagar

    Sagar,
    1. I don't think its good design, if you want to process those three lines, you should ask the user to select those 3 rows and process them.
    2. If you have no choice, tyr these methods, these might give you some info
    GET_SORT_CRITERIA
    GET_SUBTOTALS
    These methods might give you the info you are looking for. Try it out.
    regards,
    Ravi

  • How to See Total line in Alv Table

    hi friends,
             i write all code for totaling in WDDOINIT() Method of my View , but i can not see the total line .
             pls help me

    Hai Shah,
    In the settings tab of alv,you will find <b>Calculation</b>, select that tab
    in that u select the column for which u want the total.
    And u also have one option whethe to display the total at the start of table,
    or at the end of table.
    inorder ot get that calculation tab in settings ,you need to write the follwing code when instantiating the ALV,
    l_value = l_ref_interfacecontroller->get_model(
    l_value->if_salv_wd_std_functions~set_aggregation_allowed( ).
    Cheers,
    Madhu

  • How to grey out ( make it non editable ) one line in ALV

    hi i am working on a report which is ALV o/p report .the report has some editable and some non editable fields. based on the value of 1 column field i need to make the full line non editable . how is this possible.
    please guide me.
    Thanks,
    Shiva.
    Edited by: Alvaro Tejada Galindo on Mar 19, 2008 5:07 PM

    Hi,
        Try using the structure LVC_S_STYLE.
    Declare a field of type LVC_S_STYLE in ur internal table,
    Now,in ur new PERFORM chk this code:
    ls_stylerow type LVC_S_STYLE.
    LOOP AT it_itab INTO wa_itab.
    IF wa_itab-field1(this will be the field by which u will validate) =  'X'.
    ls_stylerow-fieldname = 'FIELD2' .   "Field which you want to grey
    ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled.  "set field to disabled
    APPEND ls_stylerow TO wa_itab-field_style.
    MODIFY it_itab FROM wa_itab.
    ENDIF.
    ENDLOOP.

  • Edit a line in ALV

    Hi.
    I need to set a line editable and chanching its contents, using the FM REUSE_ALV_GRID_DISPLAY.
    How can i do that?
    Best regards,
    Rui

    Hi Rui,
    To make the ALV fields editable, when you create the ALV layout using:-
    DATA : it_field TYPE slis_t_fieldcat_alv, "internal table
           wa_field TYPE slis_fieldcat_alv. "work area
    Now while defining the field catalogs:-
    wa_field-fieldname = 'MATNR'. "field name from internal table(in which the data is present)
    wa_field-tabname = 'ITAB'. "name of the field of the internal table
    wa_field-seltext_l = 'Material'. "name to be displayed in the header of ALV grid
    wa_field-input = 'X'. "to make field to accept input
    wa_field-edit = 'X'.
    append wa_field to it_field. "append it_field
    clear wa_field. "clear work area
    You can use this for other fields as well, for which you want to edit text.
    Now when you call the FM REUSE_ALV_GRID_DISPLAY, pass this internal table for field catalogs.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
        i_callback_program                = sy-repid "report id
        i_grid_title                      = wa_title "for title of ALV Grid
        it_fieldcat                       = it_field "field catalogs
      TABLES
        t_outtab                          = itab "the internal table which is to be displayed in ALV Grid
      EXCEPTIONS
       program_error                     = 1
       OTHERS                            = 2.
    Hope this solves your problem.
    Thanks & Regards
    Tarun Gambhir

  • ALV grid total line customizing

    Dear Masters,
    I need a solution for my problem. I need to modify sorting of subtotal and grand total based on currency which criteria i create  myself. The standard alv output sort total by currency based on alpahabetical order, e.g: AUD,  EUR, IDR, USD. I need to change the sorting into IDR, USD, AUD, EUR. How can i do it in alv grid?
    I also like to add new line after grand total line, which is grand total in Local Currency, in this case, in IDR, which rate given. I can get the figure of subtotal, but i don't know how to append new line after grand total line output in alv standard.
    Need your suggestion.
    Many thanks,
    Tiara

    Hi,
    I have used object oriented ALV. You can remove final total line and have sub total lines. Code below can help you.
    1) Fieldcatalog you can do sum for currency values
    2) Sort Build you can have sub totals.
    3) layout_init you can remove final total line.
    4) CALL METHOD grid->set_table_for_first_display you can pass above structure for excepted Result.
    fieldcatalog_init
    FORM fieldcatalog_init USING lt_fieldcatalog TYPE lvc_t_fcat
                           value(field_name) value(field_type) value(field_text) value(field_key).
      DATA: ls_fieldcatalog TYPE lvc_s_fcat.
      CLEAR ls_fieldcatalog.
      ls_fieldcatalog-fieldname = field_name.
      ls_fieldcatalog-datatype  = field_type.
      ls_fieldcatalog-reptext   = field_text.
      ls_fieldcatalog-coltext   = field_text.
      ls_fieldcatalog-seltext   = field_text.
      ls_fieldcatalog-tooltip   = field_text.
      ls_fieldcatalog-key       = field_key.
      IF field_type = 'CURR'.
        ls_fieldcatalog-do_sum    = 'X'.
      ENDIF.
      APPEND ls_fieldcatalog TO lt_fieldcatalog.
    ENDFORM.                    "fieldcatalog_init
    sort_build
    FORM sort_build USING lt_sort TYPE lvc_t_sort.
      DATA: ls_sort TYPE lvc_s_sort.
      ls_sort-fieldname = 'BUKRS'. "Fieldname on which to sort
      ls_sort-subtot    = 'X'.
      ls_sort-up        = 'X'.     "Sort Ascending
      APPEND ls_sort TO lt_sort.
      IF p_comp <> 'X'.
        ls_sort-fieldname = 'LIFNR'. "Fieldname on which to sort
        ls_sort-subtot    = 'X'.
        ls_sort-up        = 'X'.     "Sort Ascending
        APPEND ls_sort TO lt_sort.
      ENDIF.
      ls_sort-fieldname = 'WAERS'. "Fieldname on which to sort
      ls_sort-subtot    = 'X'.
      ls_sort-up        = 'X'.     "Sort Ascending
      APPEND ls_sort TO lt_sort.
    ENDFORM.                    "sort_build
    layout_init
    FORM layout_init USING ls_layout TYPE lvc_s_layo.
      DATA lv_date(10) TYPE c.
      WRITE sy-datum TO lv_date.
      IF p_line = 'X'.
        CONCATENATE 'Line Item wise Report as on' lv_date INTO w_string2 SEPARATED BY space.
      ELSEIF p_vend = 'X'.
        CONCATENATE 'Vendor Summary Report as on' lv_date INTO w_string2 SEPARATED BY space.
      ELSEIF p_comp = 'X'.
        CONCATENATE 'Company Summary Report as on' lv_date INTO w_string2 SEPARATED BY space.
      ENDIF.
      ls_layout-zebra      = 'X'.
      ls_layout-grid_title =  w_string2.
      ls_layout-sel_mode   = 'A'.
    ls_layout-no_merging = 'X'.
      ls_layout-cwidth_opt = 'X'.
      ls_layout-no_totline = 'X'.
      IF p_line = 'X'.
        ls_layout-ctab_fname = 'COLINFO'.
      ENDIF.
    ENDFORM.                    "layout_init
          CALL METHOD grid->set_table_for_first_display
            EXPORTING
              is_layout       = gs_layout
              is_variant      = va_layout "&see below
              i_save          = 'A'     "&see below
              i_default       = ''
            CHANGING
              it_outtab       = it_apout[]
              it_fieldcatalog = gt_fieldcatalog
              it_sort         = gt_sort.
    Edited by: Himanshu Dave on May 11, 2009 2:33 PM

  • Insert a new total line - ALV GRID

    Hi Experts!
    I need to insert a new total line in a ALV. I'm using the class CL_GUI_ALV_GRID. The total's line "normal" is displayed right, but I want to insert a new total line and that line will receive the total entries number.
    Can u help me, please?
    I'll reward points!
    Best Regards,
    Caíque Escaler
    Edited by: Caíque Escaler on Feb 8, 2008 6:07 PM

    Please check program BCALV_GRID_VERIFY
    May this will help you out.

  • Merge the total line about header and item in the Hierarchical Seq ALV

    Hello guys,
    Now i used CL_SALV_HIERSEQ_TABLE to create a Hierarchical Sequential ALV. but there are two total lines, one is to calculate the numerical fields in the header(main) and another is calculate the numerical fields in the item(slave).
    my requirement doesn't contain the calculation for header line, so the first line is unuseful and i want to merge these two  line. 
    how i should do with it?
    Any clues is appreciated.
    Thanks a lot

    could anyone help me? i am very urgent!

  • Total on First Line in ALV...........

    Hi Experts,
    I was written a ALV report and it works fine but the user want the total should be appear on first line.
    How to bring All Totals on First Line in ALV default...?
    Thanks,
    Yusuf

    Hi,
    Use do_sum in the field catlog .
    For displaying the summ u want for the field, Use do_sum.
    Regards,
    Jagadish

  • How to edit line (In ALV )

    Hi all.
    this is  alv data display ,
    how cai I edit one of line , in alv .
    Regards.

    Hi Ly,
    Check out the sample code for the Editable ALV.
    REPORT  ZDEMO_ALVGRID_EDIT                 .
    TABLES:     ekko.
    TYPE-POOLS: slis.                                 "ALV Declarations
    *Data Declaration
    TYPES: BEGIN OF t_ekko,
      ebeln TYPE ekpo-ebeln,
      ebelp TYPE ekpo-ebelp,
      statu TYPE ekpo-statu,
      aedat TYPE ekpo-aedat,
      matnr TYPE ekpo-matnr,
      menge TYPE ekpo-menge,
      meins TYPE ekpo-meins,
      netpr TYPE ekpo-netpr,
      peinh TYPE ekpo-peinh,
      field_style  TYPE lvc_t_styl, "FOR DISABLE
    END OF t_ekko.
    DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
          wa_ekko TYPE t_ekko.
    *ALV data declarations
    DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE.
    DATA: it_fieldcat TYPE lvc_t_fcat,     "slis_t_fieldcat_alv WITH HEADER LINE,
          wa_fieldcat TYPE lvc_s_fcat,
          gd_tab_group TYPE slis_t_sp_group_alv,
          gd_layout    TYPE lvc_s_layo,     "slis_layout_alv,
          gd_repid     LIKE sy-repid.
    *Start-of-selection.
    START-OF-SELECTION.
      PERFORM data_retrieval.
      PERFORM set_specific_field_attributes.
      PERFORM build_fieldcatalog.
      PERFORM build_layout.
      PERFORM display_alv_report.
    *&      Form  BUILD_FIELDCATALOG
    *       Build Fieldcatalog for ALV Report
    FORM build_fieldcatalog.
      wa_fieldcat-fieldname   = 'EBELN'.
      wa_fieldcat-scrtext_m   = 'Purchase Order'.
      wa_fieldcat-col_pos     = 0.
      wa_fieldcat-outputlen   = 10.
      wa_fieldcat-emphasize   = 'X'.
      wa_fieldcat-key         = 'X'.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR  wa_fieldcat.
      wa_fieldcat-fieldname   = 'EBELP'.
      wa_fieldcat-scrtext_m   = 'PO Item'.
      wa_fieldcat-col_pos     = 1.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR  wa_fieldcat.
      wa_fieldcat-fieldname   = 'STATU'.
      wa_fieldcat-scrtext_m   = 'Status'.
      wa_fieldcat-col_pos     = 2.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR  wa_fieldcat.
      wa_fieldcat-fieldname   = 'AEDAT'.
      wa_fieldcat-scrtext_m   = 'Item change date'.
      wa_fieldcat-col_pos     = 3.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR  wa_fieldcat.
      wa_fieldcat-fieldname   = 'MATNR'.
      wa_fieldcat-scrtext_m   = 'Material Number'.
      wa_fieldcat-col_pos     = 4.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR  wa_fieldcat.
      wa_fieldcat-fieldname   = 'MENGE'.
      wa_fieldcat-scrtext_m   = 'PO quantity'.
      wa_fieldcat-col_pos     = 5.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR  wa_fieldcat.
      wa_fieldcat-fieldname   = 'MEINS'.
      wa_fieldcat-scrtext_m   = 'Order Unit'.
      wa_fieldcat-col_pos     = 6.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR  wa_fieldcat.
      wa_fieldcat-fieldname   = 'NETPR'.
      wa_fieldcat-scrtext_m   = 'Net Price'.
      wa_fieldcat-edit        = 'X'. "sets whole column to be editable
      wa_fieldcat-col_pos     = 7.
      wa_fieldcat-outputlen   = 15.
      wa_fieldcat-datatype     = 'CURR'.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR  wa_fieldcat.
      wa_fieldcat-fieldname   = 'PEINH'.
      wa_fieldcat-scrtext_m   = 'Price Unit'.
      wa_fieldcat-col_pos     = 8.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR  wa_fieldcat.
    ENDFORM.                    " BUILD_FIELDCATALOG
    *&      Form  BUILD_LAYOUT
    *       Build layout for ALV grid report
    FORM build_layout.
    * Set layout field for field attributes(i.e. input/output)
      gd_layout-stylefname = 'FIELD_STYLE'.
      gd_layout-zebra             = 'X'.
    ENDFORM.                    " BUILD_LAYOUT
    *&      Form  DISPLAY_ALV_REPORT
    *       Display report using ALV grid
    FORM display_alv_report.
      gd_repid = sy-repid.
    *  call function 'REUSE_ALV_GRID_DISPLAY'
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
           EXPORTING
                i_callback_program      = gd_repid
    *            i_callback_user_command = 'USER_COMMAND'
                is_layout_lvc               = gd_layout
                it_fieldcat_lvc             = it_fieldcat
                i_save                  = 'X'
           TABLES
                t_outtab                = it_ekko
           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.
    ENDFORM.                    " DISPLAY_ALV_REPORT
    *&      Form  DATA_RETRIEVAL
    *       Retrieve data form EKPO table and populate itab it_ekko
    FORM data_retrieval.
      SELECT ebeln ebelp statu aedat matnr menge meins netpr peinh
       UP TO 10 ROWS
        FROM ekpo
        INTO  CORRESPONDING FIELDS OF TABLE it_ekko.
    ENDFORM.                    " DATA_RETRIEVAL
    *&      Form  set_specific_field_attributes
    *       populate FIELD_STYLE table with specific field attributes
    form set_specific_field_attributes .
      DATA ls_stylerow TYPE lvc_s_styl .
      DATA lt_styletab TYPE lvc_t_styl .
    * Populate style variable (FIELD_STYLE) with style properties
    * The NETPR field/column has been set to editable in the fieldcatalog...
    * The following code sets it to be disabled(display only) if 'NETPR'
    * is gt than 10.
      LOOP AT it_ekko INTO wa_ekko.
        IF wa_ekko-netpr GT 10.
          ls_stylerow-fieldname = 'NETPR' .
          ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled.
                                                 "set field to disabled
          APPEND ls_stylerow  TO wa_ekko-field_style.
          MODIFY it_ekko FROM wa_ekko.
        ENDIF.
      ENDLOOP.
    endform.                    " set_specific_field_attributes
    v
    Thanks,
    Chidanand

  • Modify percentage total in Blocklist ALV

    Hi Experts,
    I want to modify the percentage total in the grand totals line.
    for eg: 
    A        B       C
    5        10      50 %
    3         5       40%
    Total
    8        15      90%
    Instead I want it to display   : C  = ( (15 - 8) / 15 ) * 100  =  46%    .
    The below code is working fine in case of ALV grid.
    But how can I achieve the same in ALV BLOCKLIST .  Please help.
    FORM top_of_page .
    *get global reference.
    CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
    IMPORTING
        E_GRID                           = lo_grid.
      ET_FIELDCAT_LVC                  =
    *get the subtotal
    call method lo_grid->get_subtotals
          importing
          ep_collect00 = it_00.
    change the data
      ASSIGN it_00->* TO <ft_tab>.
      LOOP AT <ft_tab> ASSIGNING <fs_tab>.
        ASSIGN COMPONENT 'VAR_PCT' OF STRUCTURE <fs_tab> TO <ff_field>.
        ASSIGN COMPONENT 'TOT_PLAN' OF STRUCTURE <fs_tab> to <fs_value1>.
        ASSIGN COMPONENT 'TOT_ACTUAL' OF STRUCTURE <fs_tab> to <fs_value2>.
        IF NOT <fs_value2> IS INITIAL.
        <ff_field> = ( ( <fs_value2> - <fs_value1> ) / <fs_value2> ) * 100.
        ENDIF.
      ENDLOOP.
    **Refresh the table display
    CALL METHOD lo_grid->refresh_table_display
    EXPORTING
          i_soft_refresh = 'X'.
    ENDFORM.
    Thanks,
    Kiran

    Hi Experts,
    I want to modify the percentage total in the grand totals line.
    for eg: 
    A        B       C
    5        10      50 %
    3         5       40%
    Total
    8        15      90%
    Instead I want it to display   : C  = ( (15 - 8) / 15 ) * 100  =  46%    .
    The below code is working fine in case of ALV grid.
    But how can I achieve the same in ALV BLOCKLIST .  Please help.
    FORM top_of_page .
    *get global reference.
    CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
    IMPORTING
        E_GRID                           = lo_grid.
      ET_FIELDCAT_LVC                  =
    *get the subtotal
    call method lo_grid->get_subtotals
          importing
          ep_collect00 = it_00.
    change the data
      ASSIGN it_00->* TO <ft_tab>.
      LOOP AT <ft_tab> ASSIGNING <fs_tab>.
        ASSIGN COMPONENT 'VAR_PCT' OF STRUCTURE <fs_tab> TO <ff_field>.
        ASSIGN COMPONENT 'TOT_PLAN' OF STRUCTURE <fs_tab> to <fs_value1>.
        ASSIGN COMPONENT 'TOT_ACTUAL' OF STRUCTURE <fs_tab> to <fs_value2>.
        IF NOT <fs_value2> IS INITIAL.
        <ff_field> = ( ( <fs_value2> - <fs_value1> ) / <fs_value2> ) * 100.
        ENDIF.
      ENDLOOP.
    **Refresh the table display
    CALL METHOD lo_grid->refresh_table_display
    EXPORTING
          i_soft_refresh = 'X'.
    ENDFORM.
    Thanks,
    Kiran

Maybe you are looking for