Query regarding row in ALV

Hi all,
        Please clarify this query of mine in alv.
I am displaying an output in ALV format which has 10 rows.
I want to add a eleventh row to the above output .
The eleventh row must contain the sum of the above 10 rows .
Please guide me how to achieve this.
Kindly reply as fast as possible.
Regards,
Vijay

Hi,
see following code :
REPORT ZALVTEST1 .
TYPE-POOLS: SLIS.
Data: v_temp type p decimals 2.
Data: v_f1_sum type i,
v_f2_sum type i.
dATA: BEGIN OF struct_customer,
CUSTOMER LIKE KNA1-KUNNR,
FIELD1 TYPE I,
FIELD2 TYPE I,
field3 type i,
END OF struct_customer.
DATA: I_LAYOUT TYPE SLIS_LAYOUT_ALV,
I_FIELDTAB TYPE SLIS_T_FIELDCAT_ALV,
I_HEADING TYPE SLIS_T_LISTHEADER,
I_EVENTS TYPE SLIS_T_EVENT.
DATA: RS_SORT TYPE SLIS_T_SORTINFO_ALV.
DATA: V_CUST TYPE KNA1-KUNNR.
DATA: BEGIN OF ITAB OCCURS 0,
CUSTOMER LIKE KNA1-KUNNR,
FIELD1 TYPE I,
FIELD2 TYPE I,
field3 type i,
END OF ITAB.
DATA: BEGIN OF ITAB1 OCCURS 0,
CUSTOMER LIKE KNA1-KUNNR,
FIELD1 TYPE I,
FIELD2 TYPE I,
field3 type i,
END OF ITAB1.
DATA: FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE'.
DATA: FORMNAME_SUBTOTAL_TEXT TYPE SLIS_FORMNAME VALUE 'SUBTOTAL_TEXT'.
DATA: FORMNAME_END_OF_PAGE TYPE SLIS_FORMNAME VALUE 'END_OF_PAGE'.
DATA: FORMNAME_END_OF_LIST TYPE SLIS_FORMNAME VALUE 'END_OF_LIST'.
DATA: FORMNAME_AFTER_LINE_OUTPUT TYPE SLIS_FORMNAME VALUE 'LINE_OUTPUT'.
START-OF-SELECTION.
PERFORM FILL_ITAB.
PERFORM FILL_CAT.
PERFORM SET_SORT.
PERFORM FILL_EVENT.
PERFORM DISPLAY_DATA.
END-OF-SELECTION.
*& Form FILL_ITAB
text
--> p1 text
<-- p2 text
FORM FILL_ITAB .
DATA: L_CTR TYPE I.
ITAB-CUSTOMER = 1.ITAB-FIELD1 = 1.ITAB-FIELD2 = 2.APPEND ITAB.
CLEAR ITAB.
ITAB-CUSTOMER = 2.ITAB-FIELD1 = 3.ITAB-FIELD2 = 4.APPEND ITAB.
CLEAR ITAB.
ITAB-CUSTOMER = 3.ITAB-FIELD1 = 2.ITAB-FIELD2 = 5.APPEND ITAB.
CLEAR ITAB.
ITAB-CUSTOMER = 4.ITAB-FIELD1 = 1.ITAB-FIELD2 = 10.APPEND ITAB.
CLEAR ITAB.
LOOP AT ITAB.
v_temp = itab-field1 / itab-field2.
itab-field3 = v_temp * 100.
modify itab.
V_f1_sum = v_f1_sum + itab-field1.
V_f2_sum = v_f2_sum + itab-field2.
ENDLOOP.
ENDFORM. " FILL_ITAB
*& Form FILL_CAT
text
--> p1 text
<-- p2 text
FORM FILL_CAT .
DATA: L_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
CLEAR L_FIELDCAT.
L_FIELDCAT-COL_POS = 1.
L_FIELDCAT-TABNAME = 'ITAB'.
L_FIELDCAT-FIELDNAME = 'CUSTOMER'.
L_FIELDCAT-REF_TABNAME = 'KNA1'.
L_FIELDCAT-REF_FIELDNAME = 'KUNNR'.
L_FIELDCAT-KEY = 'X'.
APPEND L_FIELDCAT TO I_FIELDTAB.
CLEAR L_FIELDCAT.
CLEAR L_FIELDCAT.
L_FIELDCAT-COL_POS = 3.
L_FIELDCAT-TABNAME = 'ITAB'.
L_FIELDCAT-FIELDNAME = 'FIELD1'.
L_FIELDCAT-DO_SUM = 'X'.
L_FIELDCAT-No_zero = 'X'.
L_FIELDCAT-seltext_l ='VALUE1'.
L_FIELDCAT-seltext_M ='VALUE1'.
L_FIELDCAT-seltext_S ='VALUE1'.
L_FIELDCAT-KEY = 'X'.
APPEND L_FIELDCAT TO I_FIELDTAB.
CLEAR L_FIELDCAT.
L_FIELDCAT-COL_POS = 4.
L_FIELDCAT-TABNAME = 'ITAB'.
L_FIELDCAT-FIELDNAME = 'FIELD2'.
L_FIELDCAT-DO_SUM = 'X'.
L_FIELDCAT-No_zero = 'X'.
L_FIELDCAT-seltext_l ='VALUE2'.
L_FIELDCAT-seltext_M ='VALUE2'.
L_FIELDCAT-seltext_S ='VALUE2'.
L_FIELDCAT-KEY = 'X'.
APPEND L_FIELDCAT TO I_FIELDTAB.
CLEAR L_FIELDCAT.
L_FIELDCAT-COL_POS = 5.
L_FIELDCAT-TABNAME = 'ITAB'.
L_FIELDCAT-FIELDNAME = 'FIELD3'.
L_FIELDCAT-DO_SUM = 'X'.
L_FIELDCAT-No_zero = 'X'.
L_FIELDCAT-seltext_l ='VALUE3'.
L_FIELDCAT-seltext_M ='VALUE3'.
L_FIELDCAT-seltext_S ='VALUE3'.
APPEND L_FIELDCAT TO I_FIELDTAB.
ENDFORM. " FILL_CAT
*& Form DISPLAY_DATA
text
--> p1 text
<-- p2 text
FORM DISPLAY_DATA .
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = 'ZALVTEST2'
IS_LAYOUT = I_LAYOUT
IT_FIELDCAT = I_FIELDTAB
I_DEFAULT = 'X'
I_SAVE = ' '
IT_EVENTS = I_EVENTS[]
TABLES
T_OUTTAB = ITAB
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_DATA
*& Form SET_SORT
text
--> p1 text
<-- p2 text
FORM SET_SORT .
I_LAYOUT-ZEBRA = 'X'.
DATA: LS_SORT TYPE SLIS_SORTINFO_ALV.
CLEAR LS_SORT.
LS_SORT-SPOS = 1.
LS_SORT-FIELDNAME = 'CUSTOMER'.
LS_SORT-TABNAME = 'ITAB'.
LS_SORT-UP = 'X'.
APPEND LS_SORT TO RS_SORT.
ENDFORM. " SET_SORT
*& Form FILL_EVENT
text
--> p1 text
<-- p2 text
FORM FILL_EVENT .
DATA: L_I_EVENT TYPE SLIS_ALV_EVENT.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = I_EVENTS.
READ TABLE I_EVENTS WITH KEY NAME = SLIS_EV_AFTER_LINE_OUTPUT
INTO L_I_EVENT.
IF SY-SUBRC = 0.
MOVE FORMNAME_AFTER_LINE_OUTPUT TO L_I_EVENT-FORM.
MODIFY I_EVENTS FROM L_I_EVENT INDEX SY-TABIX.
ENDIF.
ENDFORM. " FILL_EVENT
*& Form AFTER_LINE_OUTPUT
text
FORM LINE_OUTPUT using RS_LINEINFO TYPE SLIS_LINEINFO.
DATA: L_TABIX LIKE SY-TABIX.
DATA: L_TABIX1 LIKE SY-TABIX.
data: str_kunnr like struct_customer.
check RS_LINEINFO-tabindex ne 0.
L_TABIX = RS_LINEINFO-tabindex.
read table itab index l_tabix.
l_tabix1 = RS_LINEINFO-tabindex + 1.
struct_customer-customer = itab-customer.
read table itab into str_kunnr index l_tabix1 transporting customer.
if sy-subrc <> 0.
v_temp = ( v_f1_sum / v_f2_sum ) * 100.
uline at (45).
skip.
uline at (45).
write: / sy-vline , 'Total',
12 sy-vline , (9) v_f1_sum,
23 sy-vline , (9) v_f2_sum,
34 sy-vline , (9) v_temp decimals 0,
45 sy-vline.
*uline at (46).
endif.
ENDFORM. " AFTER_LINE_OUTPUT
Reward points if helpful.
Regards.
Srikanta Gope

Similar Messages

  • Query regarding row level calculations in Bex

    I have a scenario where I am creating a report on a multiprovider. This multiprovider is based on General Ledger and Profit Center Accounting cube. The PCA cube has accumulated balances at G/L account and profit center level, and GL cube has balances only at General Ledger account level.So when a report is created on this the data displayed looks like:
    Account Profit Center Balance
    1000             1234            100000  - From PCA cube
    1000              2345            200000  - From PCA cube
    1000              Not assigned 400000 - From GL cube
    There are some cases where the total balance at G/L account level does not match both the cubes ( as in the above example, as per PCA, balance for G/L account 1000 is 300000 whereas as per GL cube, balance at G/L account 1000 level is 400000.)
    Hence we require a separate row showing this difference ( not column)
    Therefore actual output required for the above scenario is:
    Account Profit Center Balance
    1000             1234            100000 
    1000              2345            200000 
    1000              DIFFERENCE           100000 - (400000 - sum of above 2 balances)
    Total                                 400000
    It would be very helpful if anyone can give inputs on how this can be achieved.

    Have you considered Virtual Key figure. This will allow you to do such complex calculations.
    Thanks
    Sharan

  • Query regarding SAP ABAP ALV List display

    Hi All,
    Have a requirement where in, when a user double clicks on a particular field as shown below, the particular cell where he has clicked has to be changed to editable and input mode. I am using ALV LIST DISPLAY.
    Please reply me if someone has worked on similar requirement.

    Hi Priya,
    Check this link: http://www.saptechnicl.com/Tutorials/ALV/Edit/demo.htm. I think this is exactly what you require.
    Hope this helps! Do let me know if you need anything else!!
    (rename "technicl" as "technical", my apologies for the typo).
    Cheers,
    Shailesh.

  • Query regarding updating rows in JTable

    Query regarding updating rows in JTable
    Hello,
    I have a JTable with 6 columns and 1000s of rows (which are data read from flat files)
    I can select 1 or more rows and change the values of the
    columns. each time I do this I need to update the values
    in the flat file.
    Currently I assign the updated Jtable values to a vector
    Vector rowVector = (Vector)defaultModel.getDataVector();
    then I iterate over the vector and compare the values with the (old) data
    in the JTable.
                for(int rowCount = 0; rowCount<rowVector.size(); rowCount++){
                    Vector v = (Vector)rowVector.elementAt(rowCount);
                        //smsList is the Vector that contains the old JTable values
                        for(int i=0; i<smsList.size(); i++){
                                //If colums values have been changed; add that
                                //vector value to another vector
                                selectedsmsList.add(smsList.get(i));
                for(int i=0; i<selectedsmsList.size(); i++){
                         //Update the values in the flat file
                }This works fine except that it takes ages to iterate over the updated vecor and un-updated,old vector; is there any way to directly get the list of rows that were updated in the jtable; so that I can directly do an I/O operation to update the jtablke values?

    Just a suggestion.
    You could add a listener and use a vector of booleans to keep track of the rows that have been changed. You could then iterate through this boolean vector and update the changed rows.
    See
    http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#modelchange
    Don't know whether this will be helpful.
    Regards, Darryl

  • Query regarding updation thru a Procedure

    Hi,I have a query regarding updation.
    1.I invoke a procedure in Oracle called submit thru my Java application.
    The submit procedure saves the XML data in the database
    and displays this data in a Front End GUI.
    2. Now,I make a change in my Java application by adding new elements to the same row.This row now contains additional XML elements.
    I would like to display the new row with the new elements in the GUI.
    What is a better option for doing the above?
    1.Delete the row being shown,save the new row with the changes in the database,and re display it?
    2.Or,Update the row dynamically and refresh?
    Any suggestions
    Thanks,

    Hi,I have a query regarding updation.
    1.I invoke a procedure in Oracle called submit thru
    my Java application.
    The submit procedure saves the XML data in the
    database
    and displays this data in a Front End GUI.
    2. Now,I make a change in my Java application by
    adding new elements to the same row.This row now
    contains additional XML elements.
    I would like to display the new row with the new
    elements in the GUI.
    What is a better option for doing the above?
    1.Delete the row being shown,save the new row with
    the changes in the database,and re display it?
    2.Or,Update the row dynamically and refresh?
    Any suggestions
    Thanks,If you delete (it seems to me yours this process is regular and frequent) and re insert the new updated one record then High water mark will cause to scan yours table which may cause to degrade the performance.AFAIK you should go with update.But hold down dont implement it as i suggested lets see what are others solution here which may be more precious then mine.
    Khurram

  • Insert a row in ALV

    Hi ,
    I need to insert a row in ALV output. On click of a Inser Row button a pop up should show with a parameter.Once the value in entered in the parameter enter is hit , the first column of the new row should have value put in that parameter as non editable field.
    The Insert row of standard toolbar inserts a blank row . Is there any way to incorporate the above logic in the standard toolbar?
    I'm using CL_GUI_ALV_GRID to display the ALV.
    It would be helpful if you provide sample coding.
    Thanks.
    Ajith
    Edited by: Ajith  Krishna on Oct 28, 2008 8:01 PM

    Hello Ajith
    The enhanced version of sample report ZUS_SDN_ALVGRID_EDITABLE_8A demonstrates how to implement your requirement.
    *& ZUS_SDN_ALVGRID_EDITABLE_8A
    *& Thread: Insert a row in ALV
    *& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1105097"></a>
    *& Thread: Blanking values on ALV Grid Row Duplicate
    *& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1057161"></a>
    *& Thread: Delete line event in ALV
    *& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="945471"></a>
    REPORT  zus_sdn_alvgrid_editable_8a.
    TYPES: BEGIN OF ty_s_outtab.
    INCLUDE TYPE knb1.
    TYPES: END OF ty_s_outtab.
    TYPES: ty_t_outtab    TYPE STANDARD TABLE OF ty_s_outtab
                          WITH DEFAULT KEY.
    DATA:
      gd_okcode        TYPE ui_func,
      gd_repid         TYPE syst-repid,
      gt_fcat          TYPE lvc_t_fcat,
      go_docking       TYPE REF TO cl_gui_docking_container,
      go_grid          TYPE REF TO cl_gui_alv_grid.
    DATA:
      gt_outtab        TYPE ty_t_outtab.
    *       CLASS lcl_eventhandler DEFINITION
    CLASS lcl_eventhandler DEFINITION.
      PUBLIC SECTION.
        CLASS-DATA:
          mt_sel_rows     TYPE lvc_t_row.
        CLASS-METHODS:
          handle_toolbar
            FOR EVENT toolbar OF cl_gui_alv_grid
            IMPORTING
              e_object
              sender,
          handle_user_command
            FOR EVENT user_command OF cl_gui_alv_grid
            IMPORTING
              e_ucomm
              sender.
    ENDCLASS.                    "lcl_eventhandler DEFINITION
    *       CLASS lcl_eventhandler IMPLEMENTATION
    CLASS lcl_eventhandler IMPLEMENTATION.
      METHOD handle_toolbar.
    * define local data
        DATA: ls_button     TYPE stb_button.
        LOOP AT e_object->mt_toolbar INTO ls_button.
          CASE ls_button-function.
            when cl_gui_alv_grid=>MC_FC_LOC_INSERT_ROW.
              ls_button-function = 'INSERT_ROW'.
              MODIFY e_object->mt_toolbar FROM ls_button INDEX syst-tabix.
            WHEN cl_gui_alv_grid=>mc_fc_loc_delete_row.
              ls_button-function = 'DELETE_ROW'.
              MODIFY e_object->mt_toolbar FROM ls_button INDEX syst-tabix.
            WHEN cl_gui_alv_grid=>mc_fc_loc_copy_row OR
                 cl_gui_alv_grid=>mc_fc_loc_copy.
              ls_button-function = 'COPY_ROW'.
              MODIFY e_object->mt_toolbar FROM ls_button INDEX syst-tabix.
            WHEN OTHERS.
              CONTINUE.
          ENDCASE.
        ENDLOOP.
      ENDMETHOD.                    "handle_toolbar
      METHOD handle_user_command.
    * define local data
        DATA: lt_rows       TYPE lvc_t_row,
              ls_row        TYPE lvc_s_row.
        REFRESH: mt_sel_rows.
        CASE e_ucomm.
          when 'INSERT_ROW'.
          WHEN 'DELETE_ROW'.
          WHEN 'COPY_ROW'.
          WHEN OTHERS.
            RETURN.
        ENDCASE.
        "   User wants to delete or copy rows => store them in class attribute
        "   and trigger PAI afterwards where we actually delete /copy the rows
        "   and do the recalculations (in case of deletion)
        CALL METHOD sender->get_selected_rows
          IMPORTING
            et_index_rows = mt_sel_rows
    *        et_row_no     =
    *   Trigger PAI
        CALL METHOD cl_gui_cfw=>set_new_ok_code
          EXPORTING
            new_code = e_ucomm
    *      IMPORTING
    *        rc       =
      ENDMETHOD.                    "user_command
    ENDCLASS.                    "lcl_eventhandler IMPLEMENTATION
    PARAMETERS:
      p_bukrs      TYPE bukrs  DEFAULT '2000'  OBLIGATORY.
    START-OF-SELECTION.
      SELECT  * FROM  knb1 INTO CORRESPONDING FIELDS OF TABLE gt_outtab
             UP TO 15 ROWS
             WHERE  bukrs  = p_bukrs.
      PERFORM init_controls.
      SET HANDLER:
        lcl_eventhandler=>handle_toolbar      FOR go_grid,
        lcl_eventhandler=>handle_user_command FOR go_grid.
      " Used to replace standard toolbar function code with custom FC
      go_grid->set_toolbar_interactive( ).
    * Link the docking container to the target dynpro
      gd_repid = syst-repid.
      CALL METHOD go_docking->link
        EXPORTING
          repid                       = gd_repid
          dynnr                       = '0100'
    *      CONTAINER                   =
        EXCEPTIONS
          OTHERS                      = 4.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * ok-code field = GD_OKCODE
      CALL SCREEN '0100'.
    END-OF-SELECTION.
    *&      Module  STATUS_0100  OUTPUT
    *       text
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'STATUS_0100'.
    *  SET TITLEBAR 'xxx'.
    **      CALL METHOD go_grid1->refresh_table_display
    ***        EXPORTING
    ***          IS_STABLE      =
    ***          I_SOFT_REFRESH =
    **        EXCEPTIONS
    **          FINISHED       = 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.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
    *       text
    MODULE user_command_0100 INPUT.
      CASE gd_okcode.
        WHEN 'BACK' OR
             'END'  OR
             'CANC'.
          SET SCREEN 0. LEAVE SCREEN.
        WHEN 'INSERT_ROW'.
          perform INSERT_ROW.
        WHEN 'DELETE_ROW'.
          PERFORM delete_rows.
        WHEN 'COPY_ROW'.
          PERFORM copy_rows.
        WHEN OTHERS.
      ENDCASE.
      CLEAR: gd_okcode.
      CALL METHOD go_grid->refresh_table_display
    *      EXPORTING
    *        IS_STABLE      =
    *        I_SOFT_REFRESH =
        EXCEPTIONS
          finished       = 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.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Form  BUILD_FIELDCATALOG_KNB1
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM build_fieldcatalog_knb1 .
    * define local data
      DATA:
        ls_fcat        TYPE lvc_s_fcat.
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
    *     I_BUFFER_ACTIVE              =
          i_structure_name             = 'KNB1'
    *     I_CLIENT_NEVER_DISPLAY       = 'X'
    *     I_BYPASSING_BUFFER           =
    *     I_INTERNAL_TABNAME           =
        CHANGING
          ct_fieldcat                  = gt_fcat
        EXCEPTIONS
          inconsistent_interface       = 1
          program_error                = 2
          OTHERS                       = 3.
      IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * Only non-key fields are editable
      ls_fcat-edit = 'X'.
      MODIFY gt_fcat FROM ls_fcat
        TRANSPORTING edit
        WHERE ( key NE 'X' ).
    ENDFORM.                    " BUILD_FIELDCATALOG_KNB1
    *&      Form  INIT_CONTROLS
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM init_controls .
    * Create docking container
      CREATE OBJECT go_docking
        EXPORTING
          parent = cl_gui_container=>screen0
          ratio  = 90
        EXCEPTIONS
          OTHERS = 6.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * Create ALV grid
      CREATE OBJECT go_grid
        EXPORTING
          i_parent = go_docking
        EXCEPTIONS
          OTHERS   = 5.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * Build fieldcatalog and set hotspot for field KUNNR
      PERFORM build_fieldcatalog_knb1.
    * Display data
      CALL METHOD go_grid->set_table_for_first_display
        CHANGING
          it_outtab       = gt_outtab
          it_fieldcatalog = gt_fcat
        EXCEPTIONS
          OTHERS          = 4.
      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.                    " INIT_CONTROLS
    *&      Form  delete_rows
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM delete_rows .
    * define local data
      DATA: ls_row    TYPE lvc_s_row.
      SORT lcl_eventhandler=>mt_sel_rows BY index DESCENDING. " !!!
      LOOP AT lcl_eventhandler=>mt_sel_rows INTO ls_row.
        DELETE gt_outtab INDEX ls_row-index.
      ENDLOOP.
      " After deleting rows do RE-CALCULATION
    *  perform RECALCULATION.
    ENDFORM.                    " delete_rows
    *&      Form  COPY_ROWS
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM copy_rows .
    * define local data
      DATA: ld_next   TYPE i,
            ls_row    TYPE lvc_s_row,
            ls_outtab TYPE ty_s_outtab.
      SORT lcl_eventhandler=>mt_sel_rows BY index DESCENDING. " !!!
      LOOP AT lcl_eventhandler=>mt_sel_rows INTO ls_row.
        READ TABLE gt_outtab INTO ls_outtab INDEX ls_row-index.
        CLEAR: ls_outtab-akont. " In your case: clear GUID
        ld_next = ls_row-index + 1.
        INSERT ls_outtab INTO gt_outtab INDEX ld_next.
      ENDLOOP.
    ENDFORM.                    " COPY_ROWS
    *&      Form  INSERT_ROW
    *       text
    *  -->  p1        text
    *  <--  p2        text
    form INSERT_ROW .
    * define local data
      DATA: ld_value1  type SPOP-VARVALUE1,
            ls_outtab  TYPE ty_s_outtab.
      CALL FUNCTION 'POPUP_TO_GET_ONE_VALUE'
        EXPORTING
          textline1            = 'Enter Value (4 Chars):'
    *     TEXTLINE2            = ' '
    *     TEXTLINE3            = ' '
          titel                = 'Enter Value'
          valuelength          = 4
        IMPORTING
    *     ANSWER               =
          VALUE1               = ld_value1
        EXCEPTIONS
          TITEL_TOO_LONG       = 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.
      ls_outtab-kunnr = ld_value1.
      ls_outtab-bukrs = ld_value1.
      append ls_outtab to gt_outtab.
    endform.                    " INSERT_ROW
    Regards
      Uwe

  • Deactivate the double click/ hot spot for a particular row in alv grid.

    Hello,
       As per a certain condition how to deactivate the double click/ hot spot for a particular row in alv grid.
    Regards,
    Saroj

    where u define layout there is a field hotspot.like
    data: var.
    if con is true
    var = 'X'. (show hotspot)
    else.
    var = ' '. (deactive hotspot)
    elseif ws_fieldcat-fieldname = 'DMBTR'
                    AND ws_fieldcat-tabname = 'T_MTAB'.
          ws_fieldcat-do_sum = C_X.
          <b>ws_fieldcat-hotsopts = var.</b>
          MODIFY Wt_fieldcat FROM ws_fieldcat
                  TRANSPORTING   DO_SUM.
    It is helpful for u. if any problen send me ur coding i will change it.
    Regards
    Manish Kumar

  • Deleting rows in alv report.

    Hi Experts,
                I want to delete a row in alv report output, It is duplicating  records in the report  and 'GRAND TOTAL' also be displayed . In under the report . <<removed_by_moderator>>
    Thanks,
    Dinesh.B
    Edited by: Vijay Babu Dudla on May 11, 2009 9:15 AM

    Hi,
    use the following code for deleting duplicate and adjacent records from itab
    delete ADJACENT DUPLICATES FROM itab.
    or
    sort itab by pernr.
    delete ADJACENT DUPLICATE FROM itab COMPARING pernr.
    Also, for grand total you can use fieldcat-do_sum    =  'X'  with the field catalog. It will give you total for the required column.
    Hope this solves your problem.
    Regards,
    Ibrar Munsif.

  • How to select multiple row in ALV report

    Hi friends,
    1. How to select multiple row in ALV report
                   ( How to set tab in ALV report and want to select multiple line.)
    Thanking you.
    Subash

    Hi Sahoo,
    If you are using the class CL_GUI_ALV_GRID. In methods SET_TABLE_FOR_FIRST_DISPLAY.
    in layout structure you will find field SEL_MODE
    pass :
    LS_LAYOUT-SEL_MODE = 'A'.
    In PAI.
      CALL METHOD GRID->GET_SELECTED_ROWS
        IMPORTING
          ET_INDEX_ROWS = T_ROWS
          ET_ROW_NO     = T_ROWID.
    Hope these will solve your problem.
    Regards,
    Kumar M.

  • How to delete a particular row in ALV table

    Hi,
    How to delete a particular row in ALV table based on some condition(by checking value for one of the columns in a row)
    Thanks
    Bala Duvvuri

    Hello Bala,
    Can you please be a bit more clear as to how you intend to delete the rows from your ALV? By the way deleting rows from an ALV is no different from deleting rows from a normal table. Suppose you have enabled selection property in ALV & then select multiple rows and click up on a button to delete the rows then below would be the coding: (Also keep in mind that you would have to maintain the Selection property of the context node that you are binding to your ALV to 0..n)
    data : lr_table_settings  TYPE REF TO if_salv_wd_table_settings,
                 lr_config          TYPE REF TO cl_salv_wd_config_table.
      lr_table_settings  ?= lr_config.
    ** Setting the ALV selection to multiple selection with no lead selection
      lr_table_settings->set_selection_mode( value = cl_wd_table=>e_selection_mode-multi_no_lead ).
    Next delete the selected rows in the action triggered by the button:
    METHOD onactiondelete_rows .
      DATA:  wd_node TYPE REF TO if_wd_context_node,
             lt_node1 TYPE ig_componentcontroller=>elements_node,
             wa_temp  TYPE REF TO if_wd_context_element,
             lt_temp  TYPE wdr_context_element_set,
             row_number TYPE i VALUE 0.
      wd_node = wd_context->get_child_node( name = 'NODE' ).
      CALL METHOD wd_node->get_selected_elements
        RECEIVING
          set = lt_temp.
      LOOP AT lt_temp INTO wa_temp.
        wd_node->remove_element( EXPORTING element = wa_temp ).
      ENDLOOP.
      CALL METHOD wd_node->get_static_attributes_table
        EXPORTING
          from  = 1
          to    = 2147483647
        IMPORTING
          table = lt_node1.
      wd_node->bind_table( new_items = lt_node1 ).
    ENDMETHOD.
    If in case this isn't your requirement please do let me know so that I can try come up with another analysis.
    Regards,
    Uday

  • How to change the colour of row in ALV depending on condition?

    Hi All,
    I want to change the color(from green to red )of perticular row in ALV depending on certain conditions like if amount in some field in row is more than 5000.
    Can anybody please tell me how to do that?
    expecting early reply.
    Thanks in advance,
    Rohini.

    Hi
    Check this sample report
    *& Report  ZALVCOLOR                                                   *
    REPORT  ZALVCOLOR                               .
    DATA : mara TYPE mara.                 " General Material Data
    TYPE-POOLS: slis.                      " ALV Global types
    FIELD-SYMBOLS :
      <data> TYPE table.                   " Data to display
    SELECT-OPTIONS :
      s_matnr FOR mara-matnr.              " Material number
    SELECTION-SCREEN :
      SKIP, BEGIN OF LINE,COMMENT 5(27) v_1 FOR FIELD p_max.    "#EC NEEDED
    PARAMETERS p_max(2) TYPE n DEFAULT '50' OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    INITIALIZATION.
      v_1 = 'Maximum of lines to display'.
    START-OF-SELECTION.
      PERFORM f_read_data.
      PERFORM f_display_data.
    *      Form  f_read_data
    FORM f_read_data.
      FIELD-SYMBOLS :
        <field>    TYPE ANY,
        <field2>   TYPE ANY,
        <header>   TYPE ANY,
        <header2>  TYPE ANY,
        <lt_data>  TYPE table.             " Data read from DB
      DATA:
        lp_struct  TYPE REF TO data,
        lp_struct2 TYPE REF TO data,
        lp_table   TYPE REF TO data,       " Pointer to dynamic table
        lp_table2  TYPE REF TO data,       " Pointer to dynamic table
        ls_lvc_cat TYPE lvc_s_fcat,
        lt_lvc_cat TYPE lvc_t_fcat.        " Field catalog
    * First column
      CLEAR ls_lvc_cat.
      ls_lvc_cat-fieldname = 'MATNR'.
      ls_lvc_cat-ref_table = 'MARA'.
      APPEND ls_lvc_cat TO lt_lvc_cat.
    * 2nd column
      CLEAR ls_lvc_cat.
      ls_lvc_cat-fieldname = 'MAKTX'.
      ls_lvc_cat-ref_table = 'MAKT'.
      APPEND ls_lvc_cat TO lt_lvc_cat.
    * 3rd column
      CLEAR ls_lvc_cat.
      ls_lvc_cat-fieldname = 'MATKL'.
      ls_lvc_cat-ref_table = 'MARA'.
      APPEND ls_lvc_cat TO lt_lvc_cat.
    * Create 1st internal table
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING it_fieldcatalog = lt_lvc_cat
        IMPORTING ep_table = lp_table.
      ASSIGN lp_table->* TO <lt_data>.
    * Read data into 1st internal table
      SELECT matnr maktx matkl
        INTO TABLE <lt_data>
        FROM v_matnr
          UP TO p_max ROWS
       WHERE matnr IN s_matnr.
    * Create 2nd internal table
    * Checkbox
      CLEAR ls_lvc_cat.
      ls_lvc_cat-fieldname = 'CHECKBOX'.
      APPEND ls_lvc_cat TO lt_lvc_cat.
    * Table color
      CLEAR ls_lvc_cat.
      ls_lvc_cat-fieldname = 'TABCOLOR'.
      ls_lvc_cat-ref_table = 'CALENDAR_TYPE'.
      ls_lvc_cat-ref_field = 'COLTAB'.
      APPEND ls_lvc_cat TO lt_lvc_cat.
    * Create 2nd internal table
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING it_fieldcatalog = lt_lvc_cat
        IMPORTING ep_table = lp_table2.
      ASSIGN lp_table2->* TO <data>.
    * Create structure = structure of the 1st internal table
      CREATE DATA lp_struct LIKE LINE OF <lt_data>.
      ASSIGN lp_struct->* TO <header>.
    * Create structure = structure of the 2nd internal table
      CREATE DATA lp_struct2 LIKE LINE OF <data>.
      ASSIGN lp_struct2->* TO <header2>.
    * Move data from 1st internal table --> 2nd internal table
      LOOP AT <lt_data> ASSIGNING <header>.
        DESCRIBE TABLE lt_lvc_cat.
        CLEAR <header2>.
    *   Fill the internal to display <data>
        DO sy-tfill TIMES.
          READ TABLE lt_lvc_cat INTO ls_lvc_cat INDEX sy-index.
    *     For each field of lt_lvc_cat.
          ASSIGN COMPONENT ls_lvc_cat-fieldname OF STRUCTURE <header>
                        TO <field>.
          IF sy-subrc NE 0. EXIT .ENDIF.
          ASSIGN COMPONENT ls_lvc_cat-fieldname OF STRUCTURE <header2>
                        TO <field2>.
          IF sy-subrc NE 0. EXIT .ENDIF.
          <field2> = <field>.
        ENDDO.
    *   Modify color
        ASSIGN COMPONENT 'TABCOLOR' OF STRUCTURE <header2>
                      TO <field2>.
        IF sy-subrc EQ 0.
          PERFORM f_modify_color USING 'MAKTX' <field2>.
          PERFORM f_modify_color USING 'MATKL' <field2>.
        ENDIF.
        APPEND <header2> TO <data> .
      ENDLOOP.
    ENDFORM.                    " f_read_data
    *      Form  F_DISPLAY_DATA
    FORM f_display_data.
    * Macro definition
      DEFINE m_sort.
        add 1 to ls_sort-spos.
        ls_sort-fieldname = &1.
        ls_sort-down      = 'X'.
        append ls_sort to lt_sort.
      END-OF-DEFINITION.
      DATA:
        ls_layout   TYPE slis_layout_alv,
        lt_sort     TYPE slis_t_sortinfo_alv,
        ls_sort     TYPE slis_sortinfo_alv,
        ls_fieldcat TYPE slis_fieldcat_alv,
        lt_fieldcat TYPE slis_t_fieldcat_alv.  " Field catalog
    * Build Fieldcatalog - First column
      CLEAR ls_fieldcat.
      ls_fieldcat-fieldname   = 'MATNR'.
      ls_fieldcat-ref_tabname = 'MARA'.
      ls_fieldcat-key  = 'X'.
      APPEND ls_fieldcat TO lt_fieldcat.
    * Build Fieldcatalog - 2nd column
      CLEAR ls_fieldcat.
      ls_fieldcat-fieldname   = 'MAKTX'.
      ls_fieldcat-ref_tabname = 'MAKT'.
      APPEND ls_fieldcat TO lt_fieldcat.
    * Build Fieldcatalog - 3rd column
      CLEAR ls_fieldcat.
      ls_fieldcat-fieldname   = 'MATKL'.
      ls_fieldcat-ref_tabname = 'MARA'.
      APPEND ls_fieldcat TO lt_fieldcat.
    * Layout
      ls_layout-zebra = 'X'.
      ls_layout-colwidth_optimize = 'X'.
      ls_layout-box_fieldname = 'CHECKBOX'.
      ls_layout-coltab_fieldname = 'TABCOLOR'.
      m_sort 'MATNR'.                      " Sort by creation date
    * Display data
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
           EXPORTING
                is_layout   = ls_layout
                it_fieldcat = lt_fieldcat
                it_sort     = lt_sort
           TABLES
                t_outtab    = <data>.
    ENDFORM.                               " F_DISPLAY_DATA
    *      Form  F_modify_color
    FORM f_modify_color USING u_fieldname TYPE lvc_fname
                              ut_tabcolor TYPE table.
      DATA:
        l_rnd_value TYPE datatype-integer2,
        ls_tabcolor TYPE lvc_s_scol.
    * Random value
      CALL FUNCTION 'RANDOM_I2'
           EXPORTING
                rnd_min   = 0
                rnd_max   = 3
           IMPORTING
                rnd_value = l_rnd_value.
      CLEAR ls_tabcolor.
      ls_tabcolor-fname = u_fieldname.
      CASE l_rnd_value.
        WHEN 0.
          ls_tabcolor-color-col = 1.       " Blue.
          ls_tabcolor-color-int = 0.
          ls_tabcolor-color-inv = 0.
        WHEN 1.
          ls_tabcolor-color-col = 3.       " Yellow.
          ls_tabcolor-color-int = 0.
          ls_tabcolor-color-inv = 0.
        WHEN 2.
          ls_tabcolor-color-col = 5.       " Green.
          ls_tabcolor-color-int = 0.
          ls_tabcolor-color-inv = 0.
        WHEN 3.
          ls_tabcolor-color-col = 6.       " Red.
          ls_tabcolor-color-int = 0.
          ls_tabcolor-color-inv = 0.
      ENDCASE.
      INSERT ls_tabcolor INTO TABLE ut_tabcolor.
    ENDFORM.                               " F_MODIFY_COLOR
    Reward all helpfull answers
    Regards
    Pavan

  • How to Gray out a row in ALV ?

    Hi Experts,
    I am having a requirement to gray a specific row in ALV . Is it possible through List Display  ? Or Is it possible through Grid Display ?
    If it is possible, please let me know how to achieve this .
    Thanks and regards,
    Kiran.

    Hello kiran kumar  ,
    you can colour a cell in AlV ie.  in turn you can colour entire row in one  Colour...just check out the blew given link
    http://wiki.sdn.sap.com/wiki/display/Snippets/ColorindividualcellsofanALVGRID
    Hope it helps.

  • How to query a row based on its rownum

    Dear all,
    what is the easiest way to query a row based on its rownum? Suppose I have the following query:
    select first_name from employees where rownum<5;
    FIRST_NAME
    Ellen
    Sundar
    Mozhe
    DavidSo Ellen has rownum 1, Sundar 2 and so on. How can I do it if I just want to query a row where Mozhe is the first_name, which is rownum 3?
    Best regards,
    Val

    JS1 wrote:
    Valerie Debonair wrote:
    I was thinking how oracle assign a rownum in a table is by how it populates the rows in the table.Hence a statement "based on its availability". Maybe my way of thinking it's not accurate?
    You are correct, your way of thinking is wholly innaccurate. Something that can easily be confirmed simply by reading the documentation:
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/pseudocolumns009.htm#i1006297
    okie doke... thanks for the correction

  • Query regarding the data type for fetcing records from multiple ODS tables

    hey guys;
    i have a query regarding the data type for fetcing records from multiple ODS tables.
    if i have 2 table with a same column name then in the datatype under parent row node i cant add 2 nodes with the same name.
    can any one help with some suggestion.

    Hi Mudit,
    One option would be to go as mentioned by Padamja , prefxing the table name to the column name or another would be to use the AS keyoword in your SQL statement.
    AS is used to rename the column name when data is being selected from your DB.
    So, the query  Select ename as empname from emptable will return the data with column name as empname.
    Regards,
    Bhavesh

  • How to display multiple lines of texts in a single rows in ALV

    Hi,
    I have a unique requirement in which i have to display multiple lines if texts for a single rows in ALV Grid. Right now in my output it is coming in single line which is not visible fully because that text is more than 255 character. So i want to display the test by splitting into multiple lines and show it on output. Please suggest some solution for this if this is possible in ALV.
    Thanks,
    Raghav

    Hi Raghavendra,
    Its not possible to display multiple line in one row of an alv, but i think you can acheive it by splitting the whole text into multiple sub-text.
    For example, if your requirement is as below:
    Field #1          Field #2
    1                    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(200 characters)
    2                    yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy(220 character)
    then you can break Field#2 value into say 50 character and then populate the internal table with repetative entries of Field#1 and the finally sort it by Field#1 value... as a result of which you output will be somewhat as below:
    Field#1          Field#2
    1                   xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
                         xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
                         xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
                         xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    2                   yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
                         yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
                         yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
                         yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
                         yyyyyyyyyyyyyyyyyyyy           
    Hope it will help you in meeting your requirement.
    Regards,
    Shradha

Maybe you are looking for

  • How can i install find my iphone on my iphone4

    hi all! So i bought two used/old Iphone 4 for my kids for our vacation at Disney..figured they could play them inline at rides and more importantly...i could use Find MY I phone to locate my kids when ( not if) they get lost in crowd /wander off. The

  • Passing result list from Contact search to Target group

    Hi, I have to pass the result list of Contact serch(BP_CONT_SEARCH) to Target group creation component(SEGED_TG). Can you give me the steps that I need to follow. Note: Here the contact structure is different in each component. Thanks.

  • USB weirdness

    When USB ports have 2.0 USB stuff plugged into their ports, MBP doesn't get past grey screen until I unplug USB cable that goes to iPod Video. All my other USB-powered (all 2.0 USB) stuff works fine and once I'm booted up, I can plug that iPod Video

  • ChaRM config  - system check error

    Hi All ,   I am working with the basis team to move forward with ChaRM - Solution Manager. We have a two system landscape with Development (DSM)  and Production (PSM) (domain is set up as DOMAIN_DSM - exists in STMS). We have most of the configuratio

  • Nokia N8 Album art

    I thought that the music player is supposed to recognize .jpeg files within the album folder as album art covers, doesn't work for me.. has anyone tried it on their N8 ?