Hi Question On Alv Report

Hi Abapers,
                     I am having a requirement that having  Check boxe in REUSE_ALV_GRID_DISPLAY ,so i need to select the records Required using the check box.  how to Track the records selected using the check box......
Thanks & Regards
Bhaskar Rao.M

hi
good
go through this
tables used -
tables: mkpf,
        mseg,
        lfa1,
        makt.
global hashed tables used
data: begin of wa_mkpf, "header
      mblnr like mkpf-mblnr,
      mjahr like mkpf-mjahr,
      budat like mkpf-budat,
      xblnr like mkpf-xblnr,
      end of wa_mkpf.
data: ht_mkpf like hashed table of wa_mkpf
      with unique key mblnr mjahr
      with header line.
data: st_mkpf like standard table of wa_mkpf
      with header line.
data: begin of wa_mseg, " line items
      mblnr like mseg-mblnr,
      mjahr like mseg-mjahr,
      zeile like mseg-zeile,
      bwart like mseg-bwart,
      charg like mseg-charg,
      matnr like mseg-matnr,
      lifnr like mseg-lifnr,
      erfmg like mseg-erfmg,
      erfme like mseg-erfme,
      end of wa_mseg.
data ht_mseg like hashed table of wa_mseg
      with unique key mblnr mjahr zeile
      with header line.
data st_mseg like standard table of wa_mseg
      with header line.
cache structure for lfa1 records
data: begin of wa_lfa1,
      lifnr like lfa1-lifnr,
      name1 like lfa1-name1,
      end of wa_lfa1.
data ht_lfa1 like hashed table of wa_lfa1
      with unique key lifnr
      with header line.
cache structure for material related data
data: begin of wa_material,
      matnr like makt-matnr,
      maktx like makt-maktx,
      end of wa_material.
data: ht_material like hashed table of wa_material
        with unique key matnr
        with header line.
result table
data: begin of wa_lst, "
      budat like mkpf-budat,
      mblnr like mseg-mblnr,
      lifnr like mseg-lifnr,
      name1 like lfa1-name1,     
      xblnr like mkpf-xblnr,
      zeile like mseg-zeile,
      charg like mseg-charg,
      matnr like mseg-matnr,
      maktx like makt-maktx,
      erfmg like mseg-erfmg,
      erfme like mseg-erfme,
      mjahr like mseg-mjahr,
      end of wa_lst.
data: ht_lst like hashed table of wa_lst
        with unique key mblnr mjahr zeile
        with header line.
data: begin of wa_lst1, " sumary by material
      matnr like mseg-matnr,
      maktx like makt-maktx,
      erfmg like mseg-erfmg,
      erfme like mseg-erfme,
      color_line(4) TYPE c,           " Line color
      color_cell    TYPE lvc_t_scol,  " Cell color
      celltab type LVC_T_STYL,
      end of wa_lst1.
data: ht_lst1 like hashed table of wa_lst1
        with unique key matnr
        with header line.
structures for alv grid display.
itabs
type-pools: slis.
data: it_lst            like standard table of wa_lst with header line,
      it_fieldcat_lst   type slis_t_fieldcat_alv with header line,
      it_sort_lst       type slis_t_sortinfo_alv,
      it_lst1           like standard table of wa_lst1 with header line,
      it_fieldcat_lst1  type slis_t_fieldcat_alv with header line,
      it_sort_lst1      type slis_t_sortinfo_alv.
structures
data: wa_sort         type slis_sortinfo_alv,
      ls_layout       type slis_layout_alv.
color management.
DATA  : wa_color    TYPE lvc_s_scol.
Internal table for color management.
DATA : it_color    TYPE TABLE          OF lvc_s_scol.
itab for input enabling.
DATA: lt_celltab TYPE lvc_t_styl. "
global varialbes
data: g_lines type i.
data: g_repid like sy-repid,
      ok_code       like sy-ucomm.
selection-screen
"text: Dates:
select-options: so_budat for mkpf-budat default sy-datum.
"text: Material numbers.
select-options: so_matnr for mseg-matnr.
selection-screen uline.
selection-screen skip 1.
"Text: show summary by material.
parameters: gp_bymat as checkbox default ''.
parameters: gp_hier  as checkbox default 'X'.
start-of-selection.
  perform get_data.
  perform show_data.
end-of-selection.
      FORM get_data                                                 *
form get_data.
       select mblnr mjahr budat xblnr
            into table ht_mkpf
           from mkpf
          where budat in so_budat. " make use of std index.
have we retrieved data from mkpf?
  describe table ht_mkpf lines g_lines.
  if g_lines > 0.
if true then retrieve all related records from mseg.
Doing this way we make sure that the access is by primary key
of mseg.
The reason is that is faster to filter them in memory
than to allow the db server to do it.
    select mblnr mjahr zeile bwart charg
             matnr lifnr erfmg erfme
      into table ht_mseg
      from mseg
        for all entries in ht_mkpf
     where mblnr = ht_mkpf-mblnr
       and mjahr = ht_mkpf-mjahr.
  endif.
fill t_lst or t_lst1 according to user's choice.
  if gp_bymat = ' '.
    perform fill_ht_lst.
  else.
    perform fill_ht_lst1.
  endif.
endform.
form fill_ht_lst.
  refresh ht_lst.
Example: how to discard unwanted data in an efficient way.
  loop at ht_mseg.
  filter unwanted data
    check ht_mseg-bwart = '101' or ht_mseg-bwart = '901'.
    check ht_mseg-matnr in so_matnr.
  read header line.
    read table ht_mkpf with table key mblnr = ht_mseg-mblnr
    mjahr = ht_mseg-mjahr.
    clear ht_lst.
* note : this may be faster if you specify field by field.
    move-corresponding ht_mkpf to ht_lst.
    move-corresponding ht_mseg to ht_lst.
    perform read_lfa1 using ht_mseg-lifnr changing ht_lst-name1.
    perform read_material using ht_mseg-matnr changing ht_lst-maktx.
    insert table ht_lst.
  endloop.
endform.
form fill_ht_lst1.
data: colorear.
  refresh ht_lst1.
Example: how to discard unwanted data in an efficient way.
         hot to simulate a collect in a faster way
  loop at ht_mseg.
  filter unwanted data
    check ht_mseg-bwart = '101' or ht_mseg-bwart = '901'.
    check ht_mseg-matnr in so_matnr.
* note : this may be faster if you specify field by field.
    read table ht_lst1 with table key matnr = ht_mseg-matnr
    transporting erfmg.
    if sy-subrc <> 0. " if matnr doesn't exist in sumary table
    " insert a new record
      clear ht_lst1.
      ht_lst1-matnr = ht_mseg-matnr.
      perform read_material using ht_mseg-matnr changing ht_lst1-maktx.
      ht_lst1-erfmg = ht_mseg-erfmg.
      ht_lst1-erfme = ht_mseg-erfme.
      if colorear = ''.
        colorear = 'X'.
        refresh it_color.
        ht_lst1-color_cell[] = it_color[].
        MOVE 'C410' TO ht_lst1-color_line.
      else.
        colorear = ' '.
        refresh it_color. clear it_color.
        MOVE 'MATNR' TO wa_color-fname.
        MOVE '6'         TO wa_color-color-col.
        MOVE '1'         TO wa_color-color-int.
        MOVE '1'         TO wa_color-color-inv.
        APPEND wa_color TO it_color.
        MOVE 'MAKTX' TO wa_color-fname.
        MOVE '3'         TO wa_color-color-col.
        MOVE '1'         TO wa_color-color-int.
        MOVE '1'         TO wa_color-color-inv.
        APPEND wa_color TO it_color.
        MOVE 'ERFMG' TO wa_color-fname.
        MOVE '5'         TO wa_color-color-col.
        MOVE '1'         TO wa_color-color-int.
        MOVE '1'         TO wa_color-color-inv.
        APPEND wa_color TO it_color.
        ht_lst1-color_cell[] = it_color[].
        clear ht_lst1-color_line.
      endif.
      insert table ht_lst1.
    else." a record was found.
    " collect erfmg.  To do so, fill in the unique key and add
    " the numeric fields.
      ht_lst1-matnr = ht_mseg-matnr.
      add ht_mseg-erfmg to ht_lst1-erfmg.
      modify table ht_lst1 transporting erfmg.
    endif.
  endloop.
endform.
implementation of cache for lfa1.
form read_lfa1 using p_lifnr changing p_name1.
       read table ht_lfa1 with table key lifnr = p_lifnr
        transporting name1.
  if sy-subrc <> 0.
    clear ht_lfa1.
    ht_lfa1-lifnr = p_lifnr.
    select single name1
       into ht_lfa1-name1
      from lfa1
    where lifnr = p_lifnr.
    if sy-subrc <> 0. ht_lfa1-name1 = 'n/a in lfa1'. endif.
    insert table ht_lfa1.
  endif.
  p_name1 = ht_lfa1-name1.
endform.
implementation of cache for material data
form read_material using p_matnr changing p_maktx.
  read table ht_material with table key matnr = p_matnr
  transporting maktx.
  if sy-subrc <> 0.
    ht_material-matnr = p_matnr.
    select single maktx into  ht_material-maktx
      from makt
     where spras = sy-langu
       and matnr = p_matnr.
    if sy-subrc <> 0. ht_material-maktx = 'n/a in makt'. endif.
    insert table ht_material.
  endif.
  p_maktx = ht_material-maktx.
endform.
form show_data.
  if gp_hier = 'X'. "no anda.
   perform show_hierarchicalALV.
  else.
    if gp_bymat = ' '.
      perform show_ht_lst.
    else.
      perform show_ht_lst1.
    endif.
  endif.
endform.
form show_hierarchicalALV.
st_mkpf[] = ht_mkpf[].
st_mseg[] = ht_mseg[].
call function 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
exporting
  I_INTERFACE_CHECK              = ' '
  I_CALLBACK_PROGRAM             =
  I_CALLBACK_PF_STATUS_SET       = ' '
  I_CALLBACK_USER_COMMAND        = ' '
  IS_LAYOUT                      =
  IT_FIELDCAT                    =
  IT_EXCLUDING                   =
  IT_SPECIAL_GROUPS              =
  IT_SORT                        =
  IT_FILTER                      =
  IS_SEL_HIDE                    =
  I_SCREEN_START_COLUMN          = 0
  I_SCREEN_START_LINE            = 0
  I_SCREEN_END_COLUMN            = 0
  I_SCREEN_END_LINE              = 0
  I_DEFAULT                      = 'X'
  I_SAVE                         = ' '
  IS_VARIANT                     =
  IT_EVENTS                      =
  IT_EVENT_EXIT                  =
   i_tabname_header               =
   i_tabname_item                 =
  I_STRUCTURE_NAME_HEADER        =
  I_STRUCTURE_NAME_ITEM          =
   is_keyinfo                     =
  IS_PRINT                       =
  IS_REPREP_ID                   =
  I_BUFFER_ACTIVE                =
  I_BYPASSING_BUFFER             =
IMPORTING
  E_EXIT_CAUSED_BY_CALLER        =
  ES_EXIT_CAUSED_BY_USER         =
  tables
    t_outtab_header                = st_mkpf
    t_outtab_item                  = st_mseg
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.
form show_ht_lst.
  "needed because the FM can't use a hashed table.
  it_lst[] = ht_lst[].
  perform fill_layout using 'full display'
                       changing ls_layout.
  perform fill_columns_lst.
perform sort_lst.
  g_repid = sy-repid.
  call function 'REUSE_ALV_GRID_DISPLAY'
       exporting
            i_callback_program       = g_repid
            i_callback_pf_status_set = 'SET_PF_STATUS'
            is_layout                = ls_layout
            it_fieldcat              = it_fieldcat_lst[]
           it_sort                  = it_sort_lst
       tables
            t_outtab                 = it_lst
       exceptions
            program_error            = 1
            others                   = 2.
endform.
form show_ht_lst1.
  "needed because the FM can't use a hashed table.
  it_lst1[] = ht_lst1[].
  perform fill_layout using 'Sumary by matnr'
                       changing ls_layout.
  perform fill_columns_lst1.
perform sort_lst.
  g_repid = sy-repid.
  call function 'REUSE_ALV_GRID_DISPLAY'
       exporting
            i_callback_program       = g_repid
            i_callback_pf_status_set = 'SET_PF_STATUS'
            is_layout                = ls_layout
            it_fieldcat              = it_fieldcat_lst1[]
           it_sort                  = it_sort_lst
       tables
            t_outtab                 = it_lst1
       exceptions
            program_error            = 1
            others                   = 2.
endform.
form fill_layout using p_window_titlebar
               changing cs_layo type slis_layout_alv.
  clear cs_layo.
  cs_layo-window_titlebar        = p_window_titlebar.
  cs_layo-edit                   = 'X'.
  cs_layo-edit_mode              = space.
  MOVE 'COLOR_LINE' TO cs_layo-info_fieldname.
Field that identify cell color in inetrnal table
  MOVE 'COLOR_CELL' TO cs_layo-coltab_fieldname.
move 'CELLTAB' TO cs_layo-stylefname.
endform.                    " armar_layout_stock
form set_pf_status using rt_extab type slis_t_extab.
create a new status
and then select extras -> adjust template -> listviewer
  set pf-status 'VISTA'.
endform.        "set_pf_status
define add_lst.
  clear it_fieldcat_lst.
  it_fieldcat_lst-fieldname     = &1.
  it_fieldcat_lst-outputlen     = &2.
  it_fieldcat_lst-ddictxt       = 'L'.
  it_fieldcat_lst-seltext_l       = &1.
  it_fieldcat_lst-seltext_m       = &1.
  it_fieldcat_lst-seltext_m       = &1.
  if &1 = 'MATNR'.
    it_fieldcat_lst-emphasize = 'C111'.
  endif.
  append it_fieldcat_lst.
end-of-definition.
define add_lst1.
  clear it_fieldcat_lst.
  it_fieldcat_lst1-fieldname     = &1.
  it_fieldcat_lst1-outputlen     = &2.
  it_fieldcat_lst1-ddictxt       = 'L'.
  it_fieldcat_lst1-seltext_l       = &1.
  it_fieldcat_lst1-seltext_m       = &1.
  it_fieldcat_lst1-seltext_m       = &1.
  append it_fieldcat_lst1.
end-of-definition.
form fill_columns_lst.
set columns for output.
  refresh it_fieldcat_lst.
  add_lst 'BUDAT' 10.
  add_lst   'MBLNR' 10.
  add_lst  'LIFNR' 10.
  add_lst  'NAME1' 35.
  add_lst  'XBLNR' 15.
  add_lst    'ZEILE' 5.
  add_lst    'CHARG' 10.
  add_lst   'MATNR' 18.
  add_lst   'MAKTX' 30.
  add_lst   'ERFMG' 17.
  add_lst   'ERFME' 5.
  add_lst   'MJAHR' 4.
endform.
form fill_columns_lst1.
set columns for output.
  refresh it_fieldcat_lst1.
  add_lst1 'MATNR' 18.
  add_lst1 'MAKTX' 30.
  add_lst1 'ERFMG' 17.
  add_lst1 'ERFME' 5..
endform.
thanks
mrutyun^

Similar Messages

  • Can somebody give some real time questions for alv report

    hi guru
    can somebody give some real time questions for alv report.
    answers also.
    regards
    subhasis.

    hi,
    The ALV is a set of function modules and classes and their methods which are added to program code. Developers can use the functionality of the ALV in creating new reports,  saving time which might otherwise have been spent on report enhancement
    The common features of report are column    alignment, sorting, filtering, subtotals, totals etc. <b>To implement these, a lot of coding and logic is to be put. To avoid that we can use a concept called ABAP List Viewer (ALV).</b>
    Using ALV, we can have three types of reports:
       1. Simple Report
       2. Block Report
       3. Hierarchical Sequential Report
    <b>Reward useful points</b>
    Siva

  • Question on ALV report

    Moved by moderator to correct forum.  Also, please use a meaningful subject in future.
    I need to have an ALV report where at least one of three checkboxes need to be diaplayed.
    My question is that when one of the checkboxes is selected - it works fine no problem.
    How to design it for two or more checkboxes,
    I am using I_CALLBACK_TOP_OF_PAGE in FM REUSE_ALV_GRID_DISPLAY, if there are two checkboxes, it should display two reports each with header information et cetera.
    Edited by: Matt on Nov 7, 2008 12:04 PM

    Hi,
    Use the FM
    'REUSE_ALV_BLOCK_LIST_DISPLAY'
    OR use OO
    Custom container with docking container
    Regards,
    Nandha

  • Questions on ALV report

    Hello,
    I have a report that is showing data by company code and vendor number. I have the file sorted by company code and vendor number. when I run the report for 1 company, the company code prints on the first line.all of the other lines have the company code blank. but about halfway down the report, the same company code prints again on 1 line and from there to the end the company code is blank. I would expect that only the first line would have the company code and all others would be blank. Also for the total line on a vendor break, the vendor number is appearing in 1 of  the total lines. all of the other total lines have blanks in the vendor number field. I have looked at my code and I am not sure what is causing this printing problem. 
    thanks in advance for the help

    Hi,
    Most prob u have used group by company code syntax
    Remove the group by syntax.
    Regards

  • ALV report - copy layout to another user

    Hello,
    I have a question about ALV reports.
    In ALV we have option to select layout and save it by user-specific.
    How to copy this layout to another user?
    Is there some function/Bapi?
    Thanks in advance,
    Michal

    Hi Michael,
    Here are the steps I documented for managing this procedure:
    First Step is to READ the Layout into the Program
         The parameters for the layout can be found in table LTDX
    Goto SE37 and enter: LT_DBDATA_READ_FROM_LTDX
    When (READ) you will input information for the following parameters:
    Report Name
    Handle
    Log Group
    User
    Variant
    Type
    An example is shown below:
    <screen shots didn't load in my response> email if you'd like the document with screen shots>
    Execute.
    Now our next step is to WRITE the information from the program into table: LTDX
    While at the Function Builder Screen enter the new function module: LT_DBDATA_WRITE_TO_LTDX
    When you (WRITE) you will input information for the following parameters:
    Report Name
    Handle
    Log Group
    User
    Variant
    Type
    When completed, your input screen for (WRITE) should look like the screen below:
      <screen shots didn't load in my response> email if you'd like the document with screen shots>
    IMPORTANT     When entering information for IS_VARKEY, remember to use the u201Cnew useru201D ID
    When entering information for IS_VARIANT, remember to enter information exactly as found in table LTDX and remember that the parameter:  DEPENDVARS may be needed to complete your entry
    Now Execute the Function Module.  When completed go to table: LTDX and confirm that your new entry has been added.
    Pre Checklist:
    1.)     Capture entries (users) you want to copy from table: LTDX
    2.)     Make sure you have access to execute function modules/eCATT scripts
    3.)     Make sure you have table display access (needed to find and validate updates)
    If you'd like the documentation with screen shots please reply with your email address.
    Cheers,
    Robert

  • When 'PRINT' in ALV report using FM

    Hi
    I am getting an error when trying to execute and print option in the selection screen. my client system version is 4.6C
    in the dump  the error at :
    I am using FM at my report.
    set_auto_redraw(cl_gui_alf_grid_base)
    can you provide code for when 'PRINT' rs_selfild (dynamic form) for resue*grid_display
    Thanks

    Hi Dana,
    This thread answers ur question..
    alv REPORT PRINTING
    cheers,
    Prashanth
    P.S Please mark helpful answers

  • Some doubts in alv report

    how can i page breakin alv report ?
    what are the types of variants and events in alv report?
    how to hide field in alv?
    how to change standard pf status in alv reports?
    plz give me sample program for how to use variants in alv?
    <THREAD LOCKED. Please stop asking interview questions. There is already a lot of information out there, refer to the [Rules of Engagement|https://wiki.sdn.sap.com/wiki/display/HOME/RulesofEngagement] on how to ask a good question and learn to search>
    Edited by: Mike Pokraka on Oct 15, 2008 4:52 PM

    how can i page breakin alv report ?
    - Yes... using NEW-PAGE
    what are the types of variants and events in alv report?
    - DATA: g_variant LIKE disvariant.
    - DATA: gt_eventos          TYPE slis_t_event.
    how to hide field in alv?
    - When you define the field catalog mark this field ls_fieldcat-no_out = 'X'.
    how to change standard pf status in alv reports?
    CLEAR ls_extab.
    ls_extab-fcode = 'ZASSIG'.
    APPEND ls_extab TO extab.
    SET PF-STATUS 'Z09_STATUS' EXCLUDING extab.

  • Insert extra field in ALV report

    Hi All,
    I’ve requirement like … need to add Vendor’s ‘Country Code’ very next to ‘Tax code’ field in standard SAP standard ALV report S_ALR_87012357 .
    I’ve copied program (RFUMSV00) into z-program.
    But I’m not getting any idea how can I add extra field in field catalogue and corresponding value in internal table.
    Any ideas please…..
    Full points will be rewarded for useful answers…

    I didn´t understand the question very well, but if i am in certain, you will have to modify the internal table to add the field. If the table which shows the alv is like a data base type, you will have to modify this in this way:
    data: begin of gt_table occurs 0,
         include structure ,
         new_field type XXXX.
    data: end of gt_table.
    Then, you will have to add this new field to the field catalogue, in this form:
    ls_catalogue-fialdname = 'NEW_FIELD'.
    ls_catalogue-tabname  = 'GT_TABLE'.
    etc...
    Luck in your requeriment.
    ls_catalogue-tabname  = 'GT_TABLE'.
    etc...
    Luck in your travel.

  • ALV Report not getting displayed in Background

    Hi All,
    I am using Object Oriented approach of ALV to display the Report, in foreground it works fine but in background I don't get the Report.
    I am using the below piece of code but doesn't seems to be working well.
    CALL METHOD cl_gui_alv_grid=>offline
        RECEIVING
    e_offline = OFF.
    if OFF is initial.
    *----Creating custom container instance
        CREATE OBJECT gr_ccontainer
         EXPORTING
           container_name = gc_custom_control_name
         EXCEPTIONS
           cntl_error = 1
           cntl_system_error = 2
           create_error = 3
           lifetime_error = 4
           lifetime_dynpro_dynpro_link = 5
           others = 6 .
        IF sy-subrc <> 0.
    *--Exception handling
        ENDIF.
        CREATE OBJECT gr_alvgrid
         EXPORTING
           i_parent = gr_ccontainer.
    Its not working. If anyone of you could let me know what can be done to get the ALV report with all the fields in the background.
    Thanks.

    Hi Geeta,
    I was about to say this...
    If that is the case u don hav to design a custom control in ur screen, instead use ur screen as a
    dummy container which will work well in fore/back ground
      CREATE OBJECT go_grid
        EXPORTING
          i_parent = cl_gui_container=>default_screen. "Default scrren taken as dummy container
    But u got the answer in previous post : )..
    For ur second question:
    goto SP01->give spool no->exec->select the spool no(check)-> press shift+F4...
    Cheers,
    Jose.

  • ALV report for 5 Grids using Objects and Method

    I have few questions in ALV 5Grids ,could you please correct me in the following program logic...
    Using this program logic i am able to generate the five Grids and able to populate Header details from VBAK into Grid1,If you click in the Grid 1 and it is populating item details in Grid2 from VBAP,parallally populating the customer data in Grid5 from KNA1.
    Now the pending issue is ,
    if you click in the Grid2 then we should populate the shipping details in Grid3 and
    if you click in the Grid3 then we should populate the billing details in Grid4.
    Program Logic;
    REPORT  ZAREPAS20.
    Tables : vbak,vbap,likp,lips,vbrk,vbrp,kna1.
    DATA : OK_CODE              LIKE        SY-UCOMM,
           G_CONTAINER          TYPE SCRFNAME VALUE 'BCALV7_GRID_DEMO_0100_VASU',
           DOCKING              TYPE REF TO CL_GUI_DOCKING_CONTAINER,
           SPLITTER_1           TYPE REF TO CL_GUI_SPLITTER_CONTAINER,
           SPLITTER_2           TYPE REF TO CL_GUI_SPLITTER_CONTAINER,
           splitter_3           TYPE REF TO CL_GUI_SPLITTER_CONTAINER,
           CELL_TOP1            TYPE REF TO CL_GUI_CONTAINER,
           CELL_BOTTOM1         TYPE REF TO CL_GUI_CONTAINER,
           CELL_TOP2            TYPE REF TO CL_GUI_CONTAINER,
           CELL_BOTTOM2         TYPE REF TO CL_GUI_CONTAINER,
           CELL_LEFT            TYPE REF TO CL_GUI_CONTAINER,
           CELL_middle          TYPE REF TO CL_GUI_CONTAINER,
           CELL_RIGHT           TYPE REF TO CL_GUI_CONTAINER,
           GRID1                TYPE REF TO CL_GUI_ALV_GRID,
           GRID2                TYPE REF TO CL_GUI_ALV_GRID,
           GRID3                TYPE REF TO CL_GUI_ALV_GRID,
           GRID4                TYPE REF TO CL_GUI_ALV_GRID,
           GRID5                TYPE REF TO CL_GUI_ALV_GRID.
    DATA : GT_VBAK              TYPE STANDARD TABLE OF VBAK,
           GT_VBAP              TYPE STANDARD TABLE OF VBAP,
           GT_LIKP              TYPE STANDARD TABLE OF likp,
           GT_LIPS              TYPE STANDARD TABLE OF lips,
           GT_VBRK              TYPE STANDARD TABLE OF vbrk,
           GT_VBRP              TYPE STANDARD TABLE OF vbrp,
           GT_KNA1              TYPE STANDARD TABLE OF kna1.
    DATA:begin of itab1 occurs 0,
         vbeln type likp-VBELN,                            
         erzet type likp-ERZET,                             
         lfart type likp-LFART,                             
         posnr type lips-POSNR,
         END OF ITAB1.
    DATA:begin of itab2 occurs 0,
         vbeln like vbrk-vbeln,                            
         posnr like vbrk-fktyp,                            
         fkart like vbrk-fkart,                             
         fklmg like vbrp-fklmg,                             
         end of itab2.
    *selection screen for selecting range of values
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE text-001.
    select-options: S_vbeln for VBAK-vbeln.     
    selection-screen end of block b1.
          CLASS lcl_eventhandler DEFINITION
    CLASS lcl_eventhandler DEFINITION.
      PUBLIC SECTION.
        CLASS-METHODS:
          handle_double_click FOR EVENT double_click OF cl_gui_alv_grid
            IMPORTING
              e_row
              e_column
              es_row_no
              sender.  " sending control, i.e. ALV grid that raised event
    ENDCLASS.                    "lcl_eventhandler DEFINITION
          CLASS lcl_eventhandler IMPLEMENTATION
    CLASS lcl_eventhandler IMPLEMENTATION.
    METHOD HANDLE_DOUBLE_CLICK.
    *DEFINE LOCAL DATA.
    DATA : itab_vbak type VBAK,
           itab_vbap type VBAP,
           itab_likp type likp,
           itab_lips type lips,
           itab_vbrk type vbrk,
           itab_vbrp type vbrp,
           itab_kna1 type kna1.
    *DISTINGUISH ACCORDING TO SENDING GRID INSTANCE
    CASE SENDER.
    WHEN GRID1.
       READ TABLE gt_VBAK INTO itab_vbak INDEX e_row-index.
           CHECK ( itab_vbak-vbeln IS NOT INITIAL ).
            CALL METHOD GRID1->set_current_cell_via_id
              EXPORTING
                 is_ROW_ID    =
                 is_COLUMN_ID =
                is_row_no    = es_row_no.
            Triggers PAI of the dynpro with the specified ok-code
            CALL METHOD cl_gui_cfw=>set_new_ok_code( 'ORDER_DETAILS' ).
    WHEN GRID2.
            READ TABLE gt_VBAP INTO itab_vbap INDEX e_row-index.
            CHECK ( itab_vbap-vbeln IS NOT INITIAL ).
            CALL METHOD GRID2->set_current_cell_via_id
              EXPORTING
                 is_ROW_ID    =
                 is_COLUMN_ID =
                is_row_no    = es_row_no.
            Triggers PAI of the dynpro with the specified ok-code
            CALL METHOD cl_gui_cfw=>set_new_ok_code( 'ORDER_DETAILS' ).
    WHEN GRID3.
            READ TABLE gt_LIPS INTO itab_LIPS INDEX e_row-index.
            CHECK ( itab_lips-vgbel IS NOT INITIAL ).
            CALL METHOD GRID3->set_current_cell_via_id
              EXPORTING
                 is_ROW_ID    =
                 is_COLUMN_ID =
                is_row_no    = es_row_no.
            Triggers PAI of the dynpro with the specified ok-code
            CALL METHOD cl_gui_cfw=>set_new_ok_code( 'DELIVERY_DETAILS' ).
    WHEN GRID4.
            READ TABLE gt_VBRP INTO itab_VBRP INDEX e_row-index.
            CHECK ( itab_vbrp-vgbel IS NOT INITIAL ).
            CALL METHOD GRID4->set_current_cell_via_id
              EXPORTING
                 is_ROW_ID    =
                 is_COLUMN_ID =
                is_row_no    = es_row_no.
            Triggers PAI of the dynpro with the specified ok-code
            CALL METHOD cl_gui_cfw=>set_new_ok_code( 'BILLING_DETAILS' ).
    WHEN GRID5.
            READ TABLE gt_KNA1 INTO itab_KNA1 INDEX e_row-index.
            CHECK ( itab_kna1-kunnr IS NOT INITIAL ).
          SET PARAMETER ID 'KUN' FIELD itab_KNA1-KUNNR.
           CALL TRANSACTION 'MM02' AND SKIP FIRST SCREEN.
          WHEN OTHERS.
            RETURN.
        ENDCASE.
    endmethod.
    endclass.    "lcl_eventhandler IMPLEMENTATION
    start-of-selection.
    *write :/ 'FEDEX INT''''L' .
    SELECT        * FROM  vbak INTO TABLE gt_VBAK
    where vbeln IN  S_VBELN.
    creating docking container
    create object docking
       exporting
        parent     = cl_gui_container=>screen0
        ratio      = 90
      exceptions
       others      = 6.
      if sy-subrc eq 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    Create splitter container
    CREATE OBJECT splitter_1
        EXPORTING
          parent            = docking
          rows              = 1
          columns           = 3
         NO_AUTODEF_PROGID_DYNNR =
         NAME              =
        EXCEPTIONS
          cntl_error        = 1
          cntl_system_error = 2
          OTHERS            = 3.
      IF sy-subrc  eq 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    Get cell container
      CALL METHOD splitter_1->get_container
        EXPORTING
          row       = 1
          column    = 1
        RECEIVING
          container = cell_left.
      CALL METHOD splitter_1->get_container
        EXPORTING
          row       = 1
          column    = 2
        RECEIVING
          container = cell_middle.
      CALL METHOD splitter_1->get_container
        EXPORTING
          row       = 1
          column    = 3
        RECEIVING
          container = cell_right.
    Create 2nd splitter container
      CREATE OBJECT splitter_2
      EXPORTING
          parent            = cell_left
          rows              = 2
          columns           = 1
         NO_AUTODEF_PROGID_DYNNR =
         NAME              =
        EXCEPTIONS
          cntl_error        = 1
          cntl_system_error = 2
          OTHERS            = 3.
      IF sy-subrc  eq 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    Get cell container
      CALL METHOD splitter_2->get_container
        EXPORTING
          row       = 1
          column    = 1
        RECEIVING
          container = cell_top1.
      CALL METHOD splitter_2->get_container
        EXPORTING
          row       = 2
          column    = 1
        RECEIVING
          container = cell_bottom1.
    Create 3rd splitter container
    CREATE OBJECT splitter_3
        EXPORTING
          parent            = cell_middle
          rows              = 2
          columns           = 1
         NO_AUTODEF_PROGID_DYNNR =
         NAME              =
        EXCEPTIONS
          cntl_error        = 1
          cntl_system_error = 2
          OTHERS            = 3.
      IF sy-subrc  eq 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    Get cell container
      CALL METHOD splitter_3->get_container
        EXPORTING
          row       = 1
          column    = 1
        RECEIVING
          container = cell_top2.
      CALL METHOD splitter_3->get_container
        EXPORTING
          row       = 2
          column    = 1
        RECEIVING
          container = cell_bottom2.
    Create ALV grids
      CREATE OBJECT grid1
        EXPORTING
          i_parent          = cell_top1
        EXCEPTIONS
          OTHERS            = 5.
      IF sy-subrc  eq 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      CREATE OBJECT grid2
        EXPORTING
          i_parent          = cell_bottom1
        EXCEPTIONS
          OTHERS            = 5.
      IF sy-subrc  eq 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      CREATE OBJECT grid3
        EXPORTING
          i_parent          = cell_top2
        EXCEPTIONS
          OTHERS            = 5.
      IF sy-subrc  eq 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      CREATE OBJECT grid4
        EXPORTING
          i_parent          = cell_bottom2
        EXCEPTIONS
          OTHERS            = 5.
      IF sy-subrc  eq 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      CREATE OBJECT grid5
        EXPORTING
          i_parent          = cell_right
        EXCEPTIONS
          OTHERS            = 5.
      IF sy-subrc  eq 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    Set event handler
      SET HANDLER: lcl_eventhandler=>handle_double_click FOR grid1.
      SET HANDLER: lcl_eventhandler=>handle_double_click FOR grid2.
      SET HANDLER: lcl_eventhandler=>handle_double_click FOR grid3.
      SET HANDLER: lcl_eventhandler=>handle_double_click FOR grid4.
      SET HANDLER: lcl_eventhandler=>handle_double_click FOR grid5.
    Display data
      CALL METHOD grid1->set_table_for_first_display
        EXPORTING
          i_structure_name = 'VBAK'
        CHANGING
          it_outtab        = gt_VBAK
        EXCEPTIONS
          OTHERS           = 4.
      IF sy-subrc  eq 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    REFRESH: gt_vbap.
      CALL METHOD grid2->set_table_for_first_display
        EXPORTING
          i_structure_name = 'VBAP'
        CHANGING
          it_outtab        = gt_VBAP    " empty !!!
        EXCEPTIONS
          OTHERS           = 4.
      IF sy-subrc  eq 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    REFRESH: gt_LIPS.
      CALL METHOD grid3->set_table_for_first_display
        EXPORTING
          i_structure_name = 'LIPS'
        CHANGING
          it_outtab        = gt_LIPS    " empty !!!
        EXCEPTIONS
          OTHERS           = 4.
      IF sy-subrc  eq 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    REFRESH: gt_VBRP.
      CALL METHOD grid4->set_table_for_first_display
        EXPORTING
          i_structure_name = 'VBRP'
        CHANGING
          it_outtab        = gt_VBRP    " empty !!!
        EXCEPTIONS
          OTHERS           = 4.
      IF sy-subrc  eq 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    REFRESH: gt_KNA1.
      CALL METHOD grid5->set_table_for_first_display
        EXPORTING
          i_structure_name = 'KNA1'
        CHANGING
          it_outtab        = gt_KNA1    " empty !!!
        EXCEPTIONS
          OTHERS           = 4.
      IF sy-subrc  eq 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    Link the docking container to the target dynpro
      CALL METHOD docking->link
        EXPORTING
          repid                       = syst-repid
          dynnr                       = '0100'
         CONTAINER                   =
        EXCEPTIONS
          OTHERS                      = 4.
      IF sy-subrc  eq 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    NOTE: dynpro does not contain any elements (ok_code -> GD_OKCODE)
      CALL SCREEN '0100'.
    Flow logic of dynpro:
    *PROCESS BEFORE OUTPUT.
    MODULE STATUS_0100.
    *PROCESS AFTER INPUT.
    MODULE USER_COMMAND_0100.
    end-of-selection.
    *&      Module  STATUS_0100  OUTPUT
          text
    MODULE STATUS_0100 OUTPUT.
      SET PF-STATUS 'STATUS_0100'.
    SET TITLEBAR 'xxx'.
    Refresh display of detail ALV list
      CALL METHOD grid2->refresh_table_display
       EXPORTING
         IS_STABLE      =
         I_SOFT_REFRESH =
        EXCEPTIONS
          OTHERS         = 2.
      IF sy-subrc  eq 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    Refresh display of detail ALV list
      CALL METHOD grid3->refresh_table_display
       EXPORTING
         IS_STABLE      =
         I_SOFT_REFRESH =
        EXCEPTIONS
          OTHERS         = 2.
      IF sy-subrc  eq 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    Refresh display of detail ALV list
      CALL METHOD grid4->refresh_table_display
       EXPORTING
         IS_STABLE      =
         I_SOFT_REFRESH =
        EXCEPTIONS
          OTHERS         = 2.
      IF sy-subrc  eq 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    Refresh display of detail ALV list
      CALL METHOD grid5->refresh_table_display
       EXPORTING
         IS_STABLE      =
         I_SOFT_REFRESH =
        EXCEPTIONS
          OTHERS         = 2.
      IF sy-subrc  eq 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
          text
    MODULE USER_COMMAND_0100 INPUT.
    CASE SY-UCOMM.
    WHEN 'BACK' OR
         'EXIT'  OR
         'CANCEL'.
         SET SCREEN 0.LEAVE SCREEN.
    USER HAS PUSHED BUTTON "DISPLAY OREDERS"
         WHEN 'ORDER_DETAILS'.
          PERFORM ORDER_SHOW_DETAILS.
          when 'DELIVERY_DETAILS'.
            PERFORM DELIVERY_SHOW_DETAILS.
          WHEN 'BILLING_DETAILS'.
             PERFORM BILLING_SHOW_DETAILS.
         WHEN OTHERS.
    ENDCASE.
    CLEAR : OK_CODE.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Form  ORDER_SHOW_DETAILS
          text
    -->  p1        text
    <--  p2        text
    FORM order_show_details .
    define local data
      DATA:
        ld_row      TYPE i,
        itab_VBAK     TYPE VBAK.
      CALL METHOD grid1->get_current_cell
        IMPORTING
          e_row = ld_row.
      READ TABLE gt_VBAK INTO itab_VBAK INDEX ld_row.
      CHECK ( syst-subrc = 0 ).
      SELECT        * FROM  KNA1 INTO TABLE gt_KNA1
             WHERE  KUNNR  = itab_VBAK-KUNNR.
      SELECT        * FROM  VBAP INTO TABLE gt_VBAP
             WHERE  VBELN  = ITAB_VBAK-VBELN.
    *REFRESH: gt_LIPS.
    ENDFORM.                    " ORDER_SHOW_DETAILS
    *&      Form  DELIVERY_SHOW_DETAILS
          text
    -->  p1        text
    <--  p2        text
    FORM DELIVERY_SHOW_DETAILS .
    define local data
      DATA:
        ld_row      TYPE i,
        itab_VBAP     TYPE VBAP.
      CALL METHOD grid1->get_current_cell
        IMPORTING
          e_row = ld_row.
      READ TABLE gt_VBAP INTO itab_VBAP INDEX ld_row.
      CHECK ( syst-subrc = 0 ).
      SELECT LIKPVBELN LIKPERZET LIKPLFART LIPSVBELN
           INTO CORRESPONDING FIELDS OF TABLE ITAB1
           FROM ( LIKP INNER JOIN LIPS ON LIKPVBELN = LIPSVBELN )
           WHERE LIKP~VBELN IN S_VBELN.
    *REFRESH: gt_LIPS.
    ENDFORM.                    " DELIVERY_SHOW_DETAILS
    *&      Form  BILLING_SHOW_DETAILS
          text
    -->  p1        text
    <--  p2        text
    FORM BILLING_SHOW_DETAILS .
    define local data
      DATA:
        ld_row      TYPE i,
        itab_LIPS     TYPE LIPS.
      CALL METHOD grid1->get_current_cell
        IMPORTING
          e_row = ld_row.
      READ TABLE gt_LIPS INTO itab_LIPS INDEX ld_row.
      CHECK ( syst-subrc = 0 ).
      SELECT VBRKVBELN VBRKFKTYP VBRKFKART VBRPFKLMG
           INTO CORRESPONDING FIELDS OF TABLE ITAB2
           FROM ( VBRK INNER JOIN VBRP ON VBRKVBELN = VBRPVBELN )
           WHERE VBRK~VBELN IN S_VBELN.
    ENDFORM.                    " BILLING_SHOW_DETAILS

    Hi,
    ALV means ABAP List Viewer. Most convenient way to use it is through reuse library (cf.
    transaction se83) available from release 4.6 of SAP R/3.
    ALV is available in two modes: list and grid. List mode is good old list processing with
    standard functionnalities, and grid mode is using a new OCX object displaying grids.
    Classical reports needs more coding to set the horizontal and vertical lines.we need to adjust
    the lines manually.Even interactive also takes lot of code.
    ALV reports reduces the code when compared to classical reports.we use function modules to
    generate the output.
    that r REUSE_ALV_LIST_DISPLAY,REUSE_ALV_GRID_DISPLAY,REUSE_ALV_HIERSEQ_LIST_DISPLAY etc..
    the following threads will give some examples of the functions which you are expecting
    Header
    regarding function module
    hide ALV field
    Simply Display selection parameter values in the ALV OUTPUT
    Drag and drop in a report
    https://www.sdn.sap
    Reprots
    http://www.sapgenie.com/abap/reports.htm
    http://www.allsaplinks.com/material.html
    http://www.sapdevelopment.co.uk/reporting/reportinghome.htm
    ALV
    1. Please give me general info on ALV.
    http://www.sapfans.com/forums/viewtopic.php?t=58286
    http://www.sapfans.com/forums/viewtopic.php?t=76490
    http://www.sapfans.com/forums/viewtopic.php?t=20591
    http://www.sapfans.com/forums/viewtopic.php?t=66305 - this one discusses which way should you
    use - ABAP Objects calls or simple function modules.

  • OOP ALV report custom control performance problem

    HI
    how to write OOP ALV report without custom control.. Actually with custom control which taking long time... and time out happens for huge selection of data..
    Regards
    Roops.

    timeout is not an alv problem. If you try to display a "huge" amount of data, any display technology will fail. Even sap programs fail, their wise solution is to ask user to restrict data to be displayed. Or reduce database selection time, or display amount. Or propose the user to download data as a spool, or output to a file on server.
    Otherwise, read some advices about how to handle timeout in [Note 25528 - Parameter rdisp/max_wprun_time|http://service.sap.com/sap/support/notes/25528].
    About your question, if you still want to try, look at [example code with alv class cl_salv_table for simple display|http://help.sap.com/saphelp_nw2004s/helpdata/en/f9/1ab54099de3726e10000000a1550b0/frameset.htm]

  • Average of the column in ALV report

    Hi,
      I am working on an ALV report and for one of the column, i am calculating the average with fieldcatalog property do_sum = 'C'.
    I am sorting the output table for 2 fields and whenever I am expanding/compressing the sorted fields the average of the column is changing. Please let me know how do I get this average calculated constant. It should not change when the user collapses/expands on the sorted field.
    Regards
    Rashmi

    The same question has been asked in this thread:
    Compute average of a report column
    I have offered a solution but as I've said it's not great but it may meet your needs.
    Or another forum user may review and be able to suggest a better solution.
    Does the average need to be part of the report?
    Could you calculate it and display it within a page item below the report instead?

  • Add a row after Total row in ALV report

    Hi Experts,
    I have a report is displayed by  ALV format(not use function module to display it but use Class cl_gui_custom_container),I want to add a row after the total row. for example,
    Customer   amount1    amount2    amount3 
    10000         1,234        1,000         2,000
    10001         4,000        2,000         1,000
    10002         1,300        1,000         3,000
    11000         1,200        4,000         3,000
         Total:     7,734        8,000         9,000
    Ratio%        31.27       32.34          36.39
    the row of 'Total' is calculated by fieldcat-do_sum = 'X' But after the Total row we need a Ratio row to display the ratio. Yes we can calculate the total amout and ratio and then append it into the output itab, but we don't like this solution.We want to keep the total function in the ALV report.Any experts can poit me a direction. Thanks in advance.
    Joe

    Djoe,
    First you need to handle the user command,in order to capture the button action. For this you need to implment a class, i  am attaching sample codes here
    In top include write the following code
    CLASS lcl_event_handler DEFINITION .
      PUBLIC SECTION .
        METHODS:
         handle_toolbar  FOR EVENT toolbar                   " To add new functional buttons to the ALV toolbar
                         OF        cl_gui_alv_grid
                         IMPORTING e_object,
         handle_user_command FOR EVENT user_command          " To implement user commands
                            OF cl_gui_alv_grid
                            IMPORTING e_ucomm .
      PRIVATE SECTION.
    ENDCLASS.                                               " Lcl_event_handler DEFINITION
    Now   <b>Class implementation</b>
    CLASS lcl_event_handler IMPLEMENTATION .
      METHOD handle_toolbar.                                " Handle Toolbar
        PERFORM f9500_handle_toolbar USING e_object.
    ENDMETHOD .                                            " Handle_toolbar
      METHOD handle_user_command .                          " Handle User Command
        PERFORM f9600_handle_user_command USING e_ucomm .
      ENDMETHOD.
    ENDCLASS .                                              " lcl_event_handler IMPLEMENTATION
    FORM f9600_handle_user_command USING p_e_ucomm TYPE sy-ucomm.
      CONSTANTS:c_newl(4) TYPE c
                          VALUE 'NEWL',               " New line
                c_copy(4) TYPE c
                          VALUE 'COPY',               " Copy
                c_corr(4) TYPE c
                          VALUE 'CORR'.               " Correction
      CASE p_e_ucomm .
        WHEN c_newl.
    Create a new line
          PERFORM f9610_insert_new_line.
    ENDFORM.                                          " f9600_handle_user_command
    FORM f9610_insert_new_line .
    *Data Declarations
      DATA: lt_rows     TYPE lvc_t_row,                 " Itab for row property
            ls_rows     TYPE lvc_s_row,                 " Work area for row
            lv_cntid    TYPE i.                         " Counter
      DATA: gv_index TYPE sy-index.
      CLEAR gs_last.
      CALL METHOD gr_alvgrid->get_selected_rows
        IMPORTING
          et_index_rows = lt_rows.
      READ TABLE lt_rows INTO ls_rows INDEX 1.
      IF sy-subrc EQ 0.
        gv_index = ls_rows-index + 1.
      ELSE.
        gv_index = 1.
      ENDIF.
      DESCRIBE TABLE gt_last LINES lv_cntid.
      lv_cntid = lv_cntid + 1.
      gs_last-cntid = lv_cntid.
      INSERT gs_last INTO gt_last INDEX gv_index.
      LOOP AT gt_last INTO gs_last FROM gv_index TO gv_index.
    Make the new line editable
        PERFORM f9611_style.
      ENDLOOP.
      CALL METHOD gr_alvgrid->refresh_table_display
        EXCEPTIONS
          finished = 1
          OTHERS   = 2.
    ENDFORM.                    " f9610_insert_new_line
    You can ask questions doubts if any!
    regards
    Antony Thomas

  • Subtracting in ALV report

    i have a FI report where i am showing Assets and liabilities value in ALV format, i m using ALV grid layout. there i can easily add those values, but my problem is i have to subtract liabilities value from Assets value, but in ALV i do not find any option to Subtract values between those criteria. so my question is: Is there any option or function in ALV report where we can Subtract, multiply, division between the values in the table?

    hiiiiiiiiiiiiiii
    try to do this
    multiply any one of field by -1
    for ex: 
    loop at itab.
          multiply  itab_field  by -1.
        endloop
    and then add in alv report may this subtracted
    or
    initialize substraction field in itab
    do substracion of these tow fields append the result to itab and display it
    if u want substraction at last
    write in loop
    at last of itab
    do substraction
    i think ,
    may this solve ur problenm

  • Doubt in Alv Report Coloumn Heading

    Hi Gurus
    I want to print 2 coloumn headings in ALv Report.
    For eg: 1st line coloumn heading contains
                  Name   Number        Date      status
                2nd line coloumn heading contains under status
                              Active      Incative            
    Then if my list size is not enough to show the full details. so i can cut it in 2 lines
        if my list contains 20 coloumns
        i have to put 10 coloumns in first line
        then remaning 10 coloums in second line.
    i want the solution for both the questions.
    Help me.
    Regards.
    Bhuvana.

    For the first issue
    Use Top of Page Event to write a simple list which will act as a header for the alv list.
    Second issue:
    In the fieldcat,
    Position all the first 10 coloums row_pos = 1
    Position all the next 10 coloums row_pos = 2
    Regards,
    Lijo Joseph
    <REMOVED BY MODERATOR>
    Edited by: Alvaro Tejada Galindo on Feb 14, 2008 12:35 PM

Maybe you are looking for