Pack and Integer type in ALV grid

Hello,
Can anyone give a small example of how to display fields of type I and P in an ALV grid. Using the alv grid FM and manually filling the fieldcatalog.
Thanks for your help.

Hi Moussa Khelifi  ,
u can manually fill fieldcatalog like this..
form manual_filling_fieldcatalog.
X_FIELDCAT-FIELDNAME = 'ATWRT'.
X_FIELDCAT-TABNAME   = 'TB_FINAL'.
X_FIELDCAT-SELTEXT_L = 'Source of Supply'(001).
X_FIELDCAT-DDICTXT   =  L_DDICTXT.
X_FIELDCAT-FIELDNAME = 'MATNR'.
X_FIELDCAT-TABNAME   = 'TB_FINAL'.
X_FIELDCAT-SELTEXT_L = 'MATERIAL'(002).
X_FIELDCAT-DDICTXT   =  L_DDICTXT.
APPEND X_FIELDCAT TO TB_FIELDCAT .
endform.
u can directly pass the table to 'REUSE_ALV_GRID_DISPLAY'
regardless of type p or i fields in it.
Regards,
kiran B

Similar Messages

  • Need to add Header  and footer in an alv grid display output.

    How can I add header and footer in an alv grid dispay output.
    For the grid display, I am using the function module "REUSE_ALV_GRID_DISPLAY".

    HI,
    call function 'REUSE_ALV_GRID_DISPLAY'
           exporting
                i_callback_program      = gd_repid
                i_callback_top_of_page   = 'TOP-OF-PAGE'
                i_callback_html_end_of_list = 'END_OF_LIST_HTML'
                is_layout               = gd_layout
                it_fieldcat             = fieldcatalog[]
                i_save                  = 'X'
           tables
                t_outtab                = it_ekko
           exceptions
                program_error           = 1
                others                  = 2.
    FORM end_of_list_html USING end TYPE REF TO cl_dd_document.
      DATA: ls_text TYPE sdydo_text_element,
            l_grid     TYPE REF TO cl_gui_alv_grid,
            f(14) TYPE c VALUE 'SET_ROW_HEIGHT'.
      ls_text = 'Footer title'.
    adds and icon (red triangle)
      CALL METHOD end->add_icon
        EXPORTING
          sap_icon = 'IL'.
    adds test (via variable)
      CALL METHOD end->add_text
        EXPORTING
          text         = ls_text
          sap_emphasis = 'strong'.
    adds new line (start new line)
      CALL METHOD end->new_line.
    display text(bold)
      CALL METHOD end->add_text
        EXPORTING
          text         = 'Bold text'
          sap_emphasis = 'strong'.
    adds new line (start new line)
      CALL METHOD end->new_line.
    display text(normal)
      CALL METHOD end->add_text
        EXPORTING
          text         = 'Nor'.
    adds new line (start new line)
      CALL METHOD end->new_line.
    display text(bold)
      CALL METHOD end->add_text
        EXPORTING
          text         = 'Yellow '
          sap_emphasis = 'str'.
    adds and icon (yellow triangle)
      CALL METHOD end->add_icon
        EXPORTING
          sap_icon = 'IC''.
    display text(normal)
      CALL METHOD end->add_text
        EXPORTING
          text         = 'Mor'.
    *set height of this section
      CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
        IMPORTING
          e_grid = l_grid.
      CALL METHOD l_grid->parent->parent->(f)
        EXPORTING
          id     = 3
          height = 14.
    ENDFORM. "end_of_list_html.
    This will solve  it. Post if you need more help in this.
    Regards,
    Madhu.

  • Text after end of each type in ALV GRID DISPLAY

    Hi Experts,
    My Requirement is that after end of every order type I need to give the text to display how many records are there under that order type in ALV GRID DISPLAY.
    Sample internal table is shown below
    Ordertyp       date
    PM1            25/05/2010
    PM1            25/05/2010
    PM2            25/05/2010
    PM2            25/05/2010
    PM2            25/05/2010
    PM2           25/05/2010
    Out put should be as shown below
    PM1       25/05/2010
    PM1       25/05/2010
    Total PM1 order types are 2
    PM2     25/05/2010
    PM2     25/05/2010
    PM2    25/05/2010
    PM2    25/05/2010
    Total PM2 Order types are 4
    Total all order types are 6.
    Please note here I am not doing any subtotal, just I want to display how many records are there under that particular order
    Thanks
    Babumiya Mohammad

    Hi,
    whatever it may be you can very well use the given logic to build.
    Let say you are making the final table for display. While final table display make the process and append the data in final table itself and pass it to ALV.
    LOOP AT ITAB.
    ITAB1-FLD1 = ITAB-FLD1
    ITAB1-FLD2 = ITAB-FLD2
    APPEND ITAB1.
    *For making the count
    L_Cnt = L_cnt + 1.
    At end of OrdTYP
    L_ord_text = L_cnt.
    MOVE L_ORD_TEXT  to L_SUB_TEXT.
    L_TEXT1 = '' TOTAL"
    L_TEXT2 =  "Order types are"
    concatenate L_TEXT    ITAB-ORDTYP   L_TEXT2       L_ord_text      into            l_TOT1.
    ITAB1- FLD2 = L_TOT1.
    APPEDN ITAB1.
    clear : L_cnt, L_ord_text .
    ENDLOOP.
    L_TOT_TEXT = L_TOT_TEXT + L_SUB_TEXT  ( Here you will get total order type count)
    Do the conactenate
    L_TEXT3 = " Total all order types are"
    concatenate L_TEXT3    L_TOT_TEXT  INTo L_TOT2.
    ITAB1-FLD2 =  L_TOT2.
    APPEND IATB1.
    Here you will total text. Like above you can build the logic. It will work fine.
    You should not clear the L_SUB_TEXT.

  • Header(S) and Item(S) in ALV Grid

    Hi All,
    Is it possible to have multiple headers and its corresponding item details in ALV Grid Display?
    The requirement is to convert the display of MB51 in ALV Grid. Is it possible in ALV Grid to have this kind of display?
    Best Regards,
    Kumar.

    Hi.
    When i execute MB51,it displays in a hierarchical ALV format.
    Just have a look on the following code to display the Item and
    Header details.
    TYPE-POOLS: SLIS.
    DATA: BEGIN OF I_VBAK OCCURS 0,
          VBELN LIKE VBAK-VBELN,
          ERNAM LIKE VBAK-ERNAM,
          ERDAT LIKE VBAK-ERDAT,
          AUDAT LIKE VBAK-AUDAT,
          VAR1,
          END OF I_VBAK.
    DATA: BEGIN OF I_VBAP OCCURS 0,
          VBELN LIKE VBAP-VBELN,
          POSNR LIKE VBAP-POSNR,
          MATNR LIKE VBAP-MATNR,
          CHARG LIKE VBAP-CHARG,
          END OF I_VBAP.
    DATA: FLDCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,
          LAYOUT TYPE SLIS_LAYOUT_ALV,
          KEY TYPE SLIS_KEYINFO_ALV.
    DATA: IT_HEADER1 TYPE SLIS_T_LISTHEADER.
    DATA: WA_HEADER1 TYPE SLIS_LISTHEADER.
    DATA: IT_EVE1 TYPE SLIS_T_EVENT,
          WA_EVE1 TYPE SLIS_ALV_EVENT.
    SELECT VBELN ERNAM ERDAT AUDAT FROM VBAK
    INTO CORRESPONDING FIELDS OF TABLE I_VBAK
    UP TO 20 ROWS.
    SELECT VBELN POSNR MATNR CHARG FROM VBAP
    INTO CORRESPONDING FIELDS OF TABLE I_VBAP
    UP TO 20 ROWS.
    FLDCAT-FIELDNAME = 'VBELN'.
    FLDCAT-TABNAME = 'I_VBAK'.
    FLDCAT-REF_FIELDNAME = 'VBELN'.
    FLDCAT-REF_TABNAME = 'VBAK'.
    FLDCAT-SELTEXT_M = 'SALES DOC.'.
    FLDCAT-COL_POS = 0.
    FLDCAT-KEY = 'X'.
    APPEND FLDCAT.
    CLEAR FLDCAT.
    FLDCAT-FIELDNAME = 'ERNAM'.
    FLDCAT-TABNAME = 'I_VBAK'.
    FLDCAT-REF_FIELDNAME = 'ERNAM'.
    FLDCAT-REF_TABNAME = 'VBAK'.
    FLDCAT-SELTEXT_M = 'NAME OF PERSON'.
    FLDCAT-COL_POS = 1.
    APPEND FLDCAT.
    CLEAR FLDCAT.
    FLDCAT-FIELDNAME = 'ERDAT'.
    FLDCAT-TABNAME = 'I_VBAK'.
    FLDCAT-REF_FIELDNAME = 'ERDAT'.
    FLDCAT-REF_TABNAME = 'VBAK'.
    FLDCAT-SELTEXT_M = 'RECORD DATE'.
    FLDCAT-COL_POS = 2.
    APPEND FLDCAT.
    CLEAR FLDCAT.
    FLDCAT-FIELDNAME = 'AUDAT'.
    FLDCAT-TABNAME = 'I_VBAK'.
    FLDCAT-REF_FIELDNAME = 'AUDAT'.
    FLDCAT-REF_TABNAME = 'VBAK'.
    FLDCAT-SELTEXT_M = 'DOCUMENT DATE'.
    FLDCAT-COL_POS = 3.
    APPEND FLDCAT.
    CLEAR FLDCAT.
    FLDCAT-FIELDNAME = 'POSNR'.
    FLDCAT-TABNAME = 'I_VBAP'.
    FLDCAT-REF_FIELDNAME = 'POSNR'.
    FLDCAT-REF_TABNAME = 'VBAP'.
    FLDCAT-SELTEXT_M = 'SALES DOC ITEM'.
    FLDCAT-COL_POS = 4.
    APPEND FLDCAT.
    CLEAR FLDCAT.
    FLDCAT-FIELDNAME = 'MATNR'.
    FLDCAT-TABNAME = 'I_VBAP'.
    FLDCAT-REF_FIELDNAME = 'MATNR'.
    FLDCAT-REF_TABNAME = 'VBAP'.
    FLDCAT-SELTEXT_M = 'MATERIAL NO'.
    FLDCAT-COL_POS = 5.
    APPEND FLDCAT.
    CLEAR FLDCAT.
    FLDCAT-FIELDNAME = 'CHARG'.
    FLDCAT-TABNAME = 'I_VBAP'.
    FLDCAT-REF_FIELDNAME = 'CHARG'.
    FLDCAT-REF_TABNAME = 'VBAP'.
    FLDCAT-SELTEXT_M = 'BATCH NUMBER'.
    FLDCAT-COL_POS = 6.
    APPEND FLDCAT.
    CLEAR FLDCAT.
    LAYOUT-EXPAND_FIELDNAME = 'VAR1'.
    KEY-HEADER01 = 'VBELN'.
    KEY-ITEM01 = 'VBELN'.
      CLEAR WA_EVE1.
      WA_EVE1-NAME = 'TOP_OF_PAGE'.
      WA_EVE1-FORM = 'TOP-OF-PAGE1'.
      APPEND WA_EVE1 TO IT_EVE1.
    CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
      EXPORTING
       I_CALLBACK_PROGRAM             = SY-REPID
       IS_LAYOUT                      = LAYOUT
       IT_FIELDCAT                    = FLDCAT[]
       IT_EVENTS                      = IT_EVE1[]
        I_TABNAME_HEADER               = 'I_VBAK'
        I_TABNAME_ITEM                 = 'I_VBAP'
        IS_KEYINFO                     = KEY
      TABLES
        T_OUTTAB_HEADER                = I_VBAK
        T_OUTTAB_ITEM                  = I_VBAP
    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.
    FORM TOP-OF-PAGE1.                                          "#EC CALLED
      WA_HEADER1-TYP = 'H'.
      WA_HEADER1-INFO = 'Hierarchical Display'.
      APPEND WA_HEADER1 TO IT_HEADER1.
      CLEAR WA_HEADER1.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          IT_LIST_COMMENTARY       = IT_HEADER1[].
      REFRESH IT_HEADER1.
    ENDFORM.                    "TOP-OF-PAGE1
    Regards,
    Chandu.

  • Up and Down Buttons in ALV Grid

    Hi,
    If you open the Sorting Screen of an ALV Grid, you can select Columns you want to see and you can rearange them by clicking this Up and Down Buttons. Are these up and down buttons Standard or are they only available in this Sorting Screen? Because i also want to allow the user to sort entries in an own ALV Grid by rearranging the entries with Up and Down buttons. Do i have to add them by my own or is there a standard feature. I saw that there is an Move Row Function, but i did not found any documentation on that.
    Thanks,

    Jonhy:
    This is a little example with ALV,  you can see basically are tree things:
    1.- Create fieldcat
    2.-  Have internal table with informacion
    3.- CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    All buttons into ALV Tool Bar are standar,  and you can hide/show them, or in some case changed a lot of behavior.
    Documentation?
    TAW10_3   ALV Grid control Unit, is a excelent chapter to start.
    TYPE-POOLS: slis.
    TABLES: SPFLI.
    data: IT_SPFLI like spfli occurs 0 with header line.
    data: t_fieldcat TYPE slis_t_fieldcat_alv,
          fs_fieldcat LIKE LINE OF t_fieldcat.
    select-options: s_carrid for spfli-carrid,
                    s_connid for spfli-connid.
    SELECT * FROM SPFLI INTO TABLE it_spfli
      where CARRID in s_carrid and
            CONNID in s_connid .
    fs_fieldcat-fieldname = 'CARRID'.
    fs_fieldcat-ref_tabname = 'SPFLI'.
    fs_fieldcat-col_pos = 1.
    fs_fieldcat-key = 'X'.
    APPEND fs_fieldcat TO t_fieldcat.
    CLEAR fs_fieldcat .
    fs_fieldcat-fieldname = 'CONNID'.
    fs_fieldcat-ref_tabname = 'SPFLI'.
    fs_fieldcat-col_pos = 2.
    fs_fieldcat-key = 'X'.
    APPEND fs_fieldcat TO t_fieldcat.
    CLEAR fs_fieldcat .
    fs_fieldcat-fieldname = 'DISTANCE'.
    fs_fieldcat-ref_tabname = 'SPFLI'.
    fs_fieldcat-col_pos = 3.
    fs_fieldcat-key = ' '.
    APPEND fs_fieldcat TO t_fieldcat.
    CLEAR fs_fieldcat.
    fs_fieldcat-fieldname = 'CITYFROM'.
    fs_fieldcat-ref_tabname = 'SPFLI'.
    fs_fieldcat-col_pos = 4.
    fs_fieldcat-key = ' '.
    APPEND fs_fieldcat TO t_fieldcat.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
       I_CALLBACK_PROGRAM                = sy-repid
       IT_FIELDCAT                       = t_fieldcat
      TABLES
        t_outtab                          = it_spfli.
    Enjoy the example.
    Regards
    José Luis

  • Totals and Sub-Totals in ALV GRID

    Could anyone advice, how to display sub-totals and totals in ALV Grid(using FM).
    Ex:           value1    value2
                      100        50
                      200        50
        subtotal   300      100
        total                    400
    Thanks in advance...

    Refer below demo code and see perform Sort_list..
    it wil serve ur purpose.
    REPORT  ZGILL_ALV    message-id rp                           .
    type-pools slis.
    tables: zgill_main,zgill_details.
    data z_fieldcat type slis_t_fieldcat_alv.
    data begin of itab occurs 0.
    DATA ICON TYPE ICON-ID.
         include structure zgill_main.
    data salary like zgill_details-salary.
    data end of itab.
    *data itab1 like table of itab with header line.
    data : WA_SORT TYPE SLIS_SORTINFO_ALV,
           IT_SORT TYPE SLIS_T_SORTINFO_ALV,
           WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
           IT_FIELDTAB TYPE SLIS_T_FIELDCAT_ALV,
           WA_LAYOUT TYPE SLIS_LAYOUT_ALV.
    PARAMETERS: p_list  radiobutton group A1,
                P_GRID  RADIOBUTTON GROUP A1.
    SELECT-OPTIONS: S_PERNR FOR ZGILL_MAIN-PERNR.
    start-of-selection.
    perform fill_itab.
    perform sort_list.
    **************Start of scenario without container******************************************
    *********Method 1***********
    perform fill_fieldcat.  " Manuallly Preparing Fiedl Catalog
    *********Method 2***********
    *perform fill_fieldcat1 changing z_fieldcat.   "Preparing field catalog with merge function
    perform display_alv.
    *****************end of scenario without container*****************************************
    *&      Form  fill_itab
          text
    -->  p1        text
    <--  p2        text
    form fill_itab .
    *select * from zgill_main up to 20 rows INTO CORRESPONDING FIELDS OF TABLE itab.
    *ITAB1[] = ITAB[].
    select apernr aname aorg adob b~salary INTO CORRESPONDING FIELDS OF TABLE itab
           from zgill_main as a join zgill_details as b on apernr = bpernr
           WHERE A~PERNR IN S_PERNR.
    LOOP AT ITAB.
    IF ITAB-PERNR < 1111.
    ITAB-ICON = '@08@'.
    ELSEIF ITAB-PERNR > 1111 AND ITAB-PERNR < 11111111.
    ITAB-ICON = '@09@'.
    ELSEIF ITAB-PERNR GE 11111111.
    ITAB-ICON = '@0A@'.
    ENDIF.
    MODIFY ITAB INDEX SY-TABIX.
    ENDLOOP.
    endform.                    " fill_itab
    *&      Form  display_alv
          text
    -->  p1        text
    <--  p2        text
    form display_alv .
    data repid like sy-repid.
    REPID = SY-REPID.
    WA_LAYOUT-ZEBRA = 'X'.
    WA_LAYOUT-WINDOW_TITLEBAR = 'GRID DISPLAY'.
    WA_LAYOUT-SUBTOTALS_TEXT = 'SUBTOTAL'.
    WA_LAYOUT-TOTALS_TEXT = 'TOTAL'.
    IF P_GRID = 'X'.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
       I_CALLBACK_PROGRAM                = repid
       IT_FIELDCAT                       = IT_FIELDTAB
       IT_SORT                           = IT_SORT
       IS_LAYOUT                         = WA_LAYOUT
    TABLES
        t_outtab                          = itab[]
    EXCEPTIONS
       PROGRAM_ERROR                     = 1
       OTHERS                            = 2.
    IF sy-subrc <> 0.
       message e016 with 'Error in Display'.
    ENDIF.
    ELSEIF P_LIST = 'X'.
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
       I_CALLBACK_PROGRAM                = repid
       IT_FIELDCAT                       = IT_FIELDTAB
       IT_SORT                           = IT_SORT
       IS_LAYOUT                         = WA_LAYOUT
    TABLES
        t_outtab                          = itab[]
    EXCEPTIONS
       PROGRAM_ERROR                     = 1
       OTHERS                            = 2.
    IF sy-subrc <> 0.
       message e016 with 'Error in Display'.
    ENDIF.
    ENDIF.
    endform.                    " display_alv
    *&      Form  fill_fieldcat1
          text
    -->  p1        text
    <--  p2        text
    form fill_fieldcat1  changing d_fcat type slis_t_fieldcat_alv.
    data repid like sy-repid.
    data d_fcat1 type slis_t_fieldcat_alv with header line.
    REPID = SY-REPID.
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
       I_PROGRAM_NAME               = repid
       I_INTERNAL_TABNAME           = 'ITAB'
       I_STRUCTURE_NAME             = 'ZGILL_MAIN'
      I_CLIENT_NEVER_DISPLAY       = 'X'
      I_INCLNAME                   =
      I_BYPASSING_BUFFER           =
      I_BUFFER_ACTIVE              =
    CHANGING
        ct_fieldcat                  = d_fcat[]
    EXCEPTIONS
       INCONSISTENT_INTERFACE       = 1
       PROGRAM_ERROR                = 2
       OTHERS                       = 3.
    IF sy-subrc <> 0.
       message e016 with 'Error in preparing fiedl catalog'.
    ENDIF.
    loop at d_fcat into d_fcat1.
    case d_fcat1-fieldname.
    when 'NAME'.
    d_fcat1-reptext_ddic = 'Emp Name'.
    MODIFY D_FCAT FROM D_FCAT1.
    WHEN 'PERNR'.
    d_fcat1-reptext_ddic = 'Emp Num'.
    MODIFY D_FCAT FROM D_FCAT1.
    WHEN 'ORG'.
    d_fcat1-reptext_ddic = 'Org Unit'.
    MODIFY D_FCAT FROM D_FCAT1.
    endcase.
    clear d_fcat1.
    endloop.
    endform.                    " fill_fieldcat1
    *&      Form  sort_list
          text
    -->  p1        text
    <--  p2        text
    form sort_list .
    CLEAR WA_SORT.
    WA_SORT-FIELDNAME = 'DOB'.
    WA_SORT-SPOS = '1'.
    WA_SORT-UP = 'X'.
    WA_SORT-SUBTOT = 'X'.
    APPEND WA_SORT TO IT_SORT.
    CLEAR WA_SORT.
    WA_SORT-FIELDNAME = 'NAME'.
    WA_SORT-SPOS = '1'.
    WA_SORT-UP = 'X'.
    APPEND WA_SORT TO IT_SORT.
    CLEAR WA_SORT.
    endform.                    " sort_list
    *&      Form  fill_fieldcat
          text
    -->  p1        text
    <--  p2        text
    form fill_fieldcat .
    CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'ITAB'.
    WA_FIELDCAT-FIELDNAME = 'ICON'.
    WA_FIELDCAT-SELTEXT_L = 'TRAFFIC'.
    WA_FIELDCAT-ICON = 'X'.
    WA_FIELDCAT-ddictxt = 'l'.
    WA_FIELDCAT-COL_POS = 1.
    WA_FIELDCAT-OUTPUTLEN = 10.
    APPEND WA_FIELDCAT TO IT_FIELDTAB.
    CLEAR WA_FIELDCAT .
    WA_FIELDCAT-TABNAME = 'ITAB'.
    WA_FIELDCAT-FIELDNAME = 'PERNR'.
    WA_FIELDCAT-SELTEXT_L = 'EMP NUMBER'.
    WA_FIELDCAT-ddictxt = 'l'.
    WA_FIELDCAT-COL_POS = 2.
    WA_FIELDCAT-OUTPUTLEN = 10.
    APPEND WA_FIELDCAT TO IT_FIELDTAB.
    CLEAR WA_FIELDCAT .
    when 'maktx'.
    WA_FIELDCAT-TABNAME = 'ITAB'.
    WA_FIELDCAT-FIELDNAME = 'NAME'.
    WA_FIELDCAT-SELTEXT_L = 'EMP NAME'.
    WA_FIELDCAT-ddictxt = 'l'.
    WA_FIELDCAT-COL_POS = 3.
    WA_FIELDCAT-OUTPUTLEN = 15.
    APPEND WA_FIELDCAT TO IT_FIELDTAB.
    CLEAR WA_FIELDCAT .
    WA_FIELDCAT-TABNAME = 'ITAB'.
    WA_FIELDCAT-FIELDNAME = 'ORG'.
    WA_FIELDCAT-SELTEXT_L = 'ORG UNIT'.
    WA_FIELDCAT-COL_POS = 4.
    WA_FIELDCAT-OUTPUTLEN = 10.
    APPEND WA_FIELDCAT TO IT_FIELDTAB.
    CLEAR WA_FIELDCAT .
    WA_FIELDCAT-TABNAME = 'ITAB'.
    WA_FIELDCAT-FIELDNAME = 'DOB'.
    WA_FIELDCAT-SELTEXT_L = 'BIRTH DATE'.
    WA_FIELDCAT-COL_POS = 5.
    WA_FIELDCAT-OUTPUTLEN = 12.
    APPEND WA_FIELDCAT TO IT_FIELDTAB.
    CLEAR WA_FIELDCAT .
    WA_FIELDCAT-TABNAME = 'ITAB'.
    WA_FIELDCAT-FIELDNAME = 'SALARY'.
    WA_FIELDCAT-SELTEXT_L = 'SALARY'.
    WA_FIELDCAT-COL_POS = 6.
    WA_FIELDCAT-OUTPUTLEN = 25.
    WA_FIELDCAT-do_sum = 'X'.
    APPEND WA_FIELDCAT TO IT_FIELDTAB.
    endform.                    " fill_fieldcat

  • How to create command button called 'Remarks' and Check box in ALV GRID?

    Hi, Experts,
    Requirement is: in the ALVE GRID report output, user select a record by clicking the check box and pressing the button 'Remarks' it will take me into other transaction from the output list.
    Please help me out.
    Reward points.
    Sekhar

    Hi Chandra Shekar,
    Check the following sample program. 2 things to remember.
    1. Check the callback subroutine PF_STATUS_SET and create PF status for the program.and also ur REMARKS button in the application tool. Comments are made every where wherever those are needed. After creating Pf status execute the report.
    2.Once you select records by selecting checkboxes, u have to press on Refresh button( that is there on application toolbar), then only for selected records, CHECK field in the internal is updated. After that press on REMARKS button .
      REPORT zvenkat_alv_grid.
      TABLES:t001.
      "Types
      TYPES:
            BEGIN OF t_1001,
              check TYPE c,
              bukrs TYPE t001-bukrs,
              butxt TYPE t001-butxt,
              ort01 TYPE t001-ort01,
              land1 TYPE t001-land1,
            END OF t_1001.
      "Work area
      DATA:
            w_t001 TYPE t_1001.
      "Internal table
      DATA:
            i_t001 TYPE STANDARD TABLE OF t_1001.
      " ALV Declarations
    * Types Pools
      TYPE-POOLS:
         slis.
    * Types
      TYPES:
         t_fieldcat         TYPE slis_fieldcat_alv,
         t_events           TYPE slis_alv_event,
         t_layout           TYPE slis_layout_alv.
    * Workareas
      DATA:
         w_fieldcat         TYPE t_fieldcat,
         w_events           TYPE t_events,
         w_layout           TYPE t_layout.
    * Internal Tables
      DATA:
         i_fieldcat         TYPE STANDARD TABLE OF t_fieldcat,
         i_events           TYPE STANDARD TABLE OF t_events.
    *&    start of selection
      START-OF-SELECTION.
        PERFORM get_data.
    *&    end-of-selection.
      END-OF-SELECTION.
        PERFORM build_fieldcatlog.
        PERFORM build_events.
        PERFORM build_layout.
        PERFORM list_display.
    *&      Form  get_data
      FORM get_data .
        SELECT bukrs
               butxt
               ort01
               land1
          FROM t001
          INTO CORRESPONDING FIELDS OF TABLE i_t001
          UP TO 30 ROWS.
      ENDFORM.                    " get_data
    *&      Form  build_fieldcatlog
      FORM build_fieldcatlog .
        CLEAR:w_fieldcat,i_fieldcat[].
        PERFORM build_fcatalog USING:
                 'CHECK' 'I_T001' ' ',
                 'BUKRS' 'I_T001' 'BUKRS',
                 'BUTXT' 'I_T001' 'BUTXT',
                 'ORT01' 'I_T001' 'ORT01',
                 'LAND1' 'I_T001' 'LAND1'.
      ENDFORM.                    "BUILD_FIELDCATLOG
    *&      Form  BUILD_FCATALOG
      FORM build_fcatalog USING l_field l_tab l_text.
        w_fieldcat-fieldname      = l_field.
        w_fieldcat-tabname        = l_tab.
        w_fieldcat-seltext_m      = l_text.
        IF  l_field = 'CHECK'..
          w_fieldcat-checkbox = 'X'.
          w_fieldcat-edit     = 'X'.
        ENDIF.
        APPEND w_fieldcat TO i_fieldcat.
        CLEAR w_fieldcat.
      ENDFORM.                    " build_fieldcatlog
    *&      Form  build_events
    *       text
      FORM build_events.
        CLEAR :
              w_events, i_events[].
        w_events-name = 'TOP_OF_PAGE'."Event Name
        w_events-form = 'TOP_OF_PAGE'."Callback event subroutine
        APPEND w_events TO i_events.
        CLEAR  w_events.
        w_events-name = 'USER_COMMAND' .
        w_events-form = 'USER_COMMAND' .
        APPEND w_events TO i_events.
        CLEAR w_events.
        w_events-name = 'PF_STATUS_SET' .
        w_events-form = 'PF_STATUS_SET' .
        APPEND w_events TO i_events.
        CLEAR w_events.
      ENDFORM.                    "build_events
    *&      Form  build_layout
      FORM build_layout .
        w_layout-colwidth_optimize = 'X'.
        w_layout-zebra             = 'X'.
      ENDFORM.                    " build_layout
    *&      Form  list_display
      FORM list_display .
        DATA:
              l_program TYPE sy-repid.
        l_program = sy-repid.
        CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
          EXPORTING
            i_callback_program = l_program
            is_layout          = w_layout
            it_fieldcat        = i_fieldcat
            it_events          = i_events
          TABLES
            t_outtab           = i_t001
          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.                    " list_display
    *&      Form  top_of_page
      FORM top_of_page.
        DATA :
         li_header TYPE slis_t_listheader,
         w_header  LIKE LINE OF li_header.
        DATA:
              l_date TYPE char10.
        WRITE sy-datum TO l_date.
        w_header-typ  = 'H'.
        CONCATENATE sy-repid ':' 'From Date' l_date INTO w_header-info SEPARATED BY space.
        APPEND w_header TO li_header.
        CLEAR w_header.
        w_header-typ  = 'S'.
        w_header-info = sy-title.
        APPEND w_header TO li_header.
        CLEAR w_header.
        w_header-typ  = 'A'.
        w_header-info = sy-uname.
        APPEND w_header TO li_header.
        CLEAR w_header.
        CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
          EXPORTING
            it_list_commentary = li_header.
      ENDFORM.                    "top_of_page
    *&      Form  pf_status_set
      FORM pf_status_set    USING extab TYPE slis_t_extab.
        "Procedure to set own pf-status.
        "1.Goto Transaction code SE41
        "2.give program = SAPLKKBL and status = STANDARD_FULLSCREEN.
        "3.Click on Application toolbar STATUS button
        "4.Give ur program name Status name that is to be used in the program using SET pf-status statement
        "5.Create ur button REMARKS.
        SET PF-STATUS 'STATUS1' EXCLUDING extab.
      ENDFORM.                    "pf_status_set
    *&      Form  user_command
      FORM user_command USING ucomm LIKE sy-ucomm
                        selfield TYPE slis_selfield.
        CASE ucomm .
          WHEN 'REMARKS'."When u click on remarks button.
            LOOP AT i_t001 INTO w_t001 WHERE check = 'X'.
              WRITE :/ w_t001-bukrs, 'Checked'.
            ENDLOOP.
        ENDCASE.
      ENDFORM.                    "user_command
    I hope that it helps u .
    Regards,
    Venkat.O

  • Page Up and Page Down in ALV Grid

    Hello Experts,
    I have a simple ALV Grid report program. . If the report displays a lot of records then the scroll ups and downs can be used. However the new requirement is to make the page up, next, prevoius, down function. I have already included a SET PF-STATUS where I copied the standard and added the page up,down,next and previous. Those buttons/icons are now active in the toolbar but its not functioning as expected, nothing happens when it is being clicked. I've read some forums and below are the propose solutions:
    - Reduce the SAP work area --> how to reduce it?
    - Most forums are about ALV Grid report in OO and Dialog programming whereas a code will be put in PAI and PBO to make the page up, down buttons to function. --> How will this be applied since the report is just a simple report program (not OO or dialog)
    What is best solution to apply in my case?
    Thanks in advance!
    Best Regards,
    Alezandro

    hi kurtt
    Perhaps the below code, for scrolling the buttons can help u if the PF status and functionlity is already in place-
    module scroll_tab input.
    data: v_lines1 type sy-loopc.
    clear: ok_code,
    save_ok.
    ok_code = sy-ucomm.
    save_ok = ok_code.
    case save_ok.
    when 'PU'. "Page Up
    tc1-top_line = tc1-top_line - lv_looplines.
    if tc1-top_line < 1.
    tc1-top_line = 1.
    endif.
    when 'PD'. "Page Down
    tc1-top_line = tc1-top_line + lv_looplines.
    if tc1-top_line > lv_lines.
    tc1-top_line = ( lv_lines - lv_looplines ) + 1.
    endif.
    when 'PTU'. "Page total up
    tc1-top_line = 1.
    when 'PTD'. "Page total down
    TC1-TOP_LINE = ( LV_LINES - LV_LOOPLINES ) + 1.
    describe table it_vbak lines v_lines1.
    tc1-top_line = v_lines1.
    endcase.
    endmodule. " SCROLL_TAB INPUT
    regards
    praveen

  • Urgent : Insert , save and Delete in the alv grid

    Hi Experts,
    I am having a alv grid and displaying data by fetching from backend.
    i added a toolbar buttons  "Insert " "Save"  and "Delete".
    when i click on "Insert " button the first row of the table should be empty with input fields. i want to insert data and when i click on "save"  button it should update at backend.kindly let me know how to insert empty row at starting of alv grid and also how to save and delete records..
    thanks in advance.

    Hi Bharath,
    Go through this hope u can understand.
    SEL_MODE. Selection mode, determines how rows can be selected. Can have the following values:
    A Multiple columns, multiple rows with selection buttons.
    B Simple selection, listbox, Single row/column
    C Multiple rows without buttons
    D Multiple rows with buttons and select all ICON
    Setting and getting selected rows (Columns) and read line contents
    You can read which rows of the grid that has been selected, and dynamic select rows of the grid using methods get_selected_rows and set_selected_rows. There are similar methods for columns.
    Note that the grid table always has the rows in the same sequence as displayed in the grid, thus you can use the index of the selected row(s) to read the information in the rows from the table. In the examples below the grid table is named gi_sflight.
    Data declaration:
    DATA:
    Internal table for indexes of selected rows
    gi_index_rows TYPE lvc_t_row,
    Information about 1 row
    g_selected_row LIKE lvc_s_row.
    Example 1: Reading index of selected row(s) and using it to read the grid table
      CALL METHOD go_grid->get_selected_rows
        IMPORTING
          et_index_rows = gi_index_rows.
      DESCRIBE TABLE gi_index_rows LINES l_lines.
      IF l_lines = 0.
        CALL FUNCTION 'POPUP_TO_DISPLAY_TEXT'
             EXPORTING
                  textline1 = 'You must choose a valid line'.
        EXIT.
      ENDIF.
      LOOP AT gi_index_rows INTO g_selected_row.
         READ TABLE gi_sflight INDEX g_selected_row-index INTO g_wa_sflight.
        ENDIF.
      ENDLOOP.
    Example 2: Set selected row(s).
      DESCRIBE TABLE gi_index_rows LINES l_lines.
      IF l_lines > 0.
        CALL METHOD go_grid->set_selected_rows
            exporting
              it_index_rows = gi_index_rows.
      ENDIF.
    Reward points if helpful.
    Thanks
    Naveen khan

  • MULTIPLE-ROW drag and drop between 2 ALV grids

    Hi,
    Can anybody help me with acheiving MULTIPLE-ROW drag and drop functionality between 2 ALV grids.

    hi Prakash,
    Actually I'm trying to develop multiple drag and drop between 2 ALV's. To understand the events properly, I started working on this sample program where it uses 1 ALV and splits it into 2 and uses single row drag and drop between them. Now I'm making it to work for multiple drag and drop, so that I can use it on my application. This is the code which I'm working on..
    *& Report  Z_ALV_GRID_CONTROLS_DRAG_DROP                               *
    REPORT  z_alv_grid_controls_drag_drop.
    DATA   : i_ztransactions  TYPE TABLE OF ztransactions
                                   WITH HEADER LINE.
    DATA   : i_ztransactions2 TYPE TABLE OF ztransactions
                                   WITH HEADER LINE.
    DATA   : ok_code LIKE sy-ucomm .
    DATA : mcontainer TYPE REF TO cl_gui_custom_container .
    DATA : mcontleft  TYPE REF TO cl_gui_container .
    DATA : mcontright TYPE REF TO cl_gui_container .
    DATA : msplitcont TYPE REF TO
                            cl_gui_easy_splitter_container .
    DATA : malv_left  TYPE REF TO cl_gui_alv_grid .
    DATA : malv_right TYPE REF TO cl_gui_alv_grid .
    DATA : mrow TYPE lvc_s_row .
    DATA : gt_outtab_source TYPE ztransactions.
    DATA : gt_outtab_target TYPE ztransactions.
    DATA : g_repid LIKE sy-repid.
    DATA:   gs_layout TYPE lvc_s_layo ,
            g_behaviour_alv TYPE REF TO cl_dragdrop .
    DATA : mlines TYPE i .
          CLASS lcl_dragdropobj DEFINITION
    This is the Class of Drag Drop Object .
    This Object is used as a temporary storage means
    of the information extracted with drag
    CLASS lcl_dragdropobj DEFINITION.
      PUBLIC SECTION.
        DATA: i_ztransactions  TYPE ztransactions ,
              index TYPE i ,
              original_table(5) TYPE c ,
              proceed_trans(1) TYPE c .
    ENDCLASS.                    "lcl_dragdropobj DEFINITION
    DATA : mdata TYPE REF TO lcl_dragdropobj .
          CLASS DND_TOOLS DEFINITION
    This class contains the methods responding to the
    events ONDRAG , ONDROP , ONDROPCOMPLETE
    of the ALV Grid Controls
    CLASS dnd_tools DEFINITION .
      PUBLIC SECTION .
       METHODS:handle_user_command
                               FOR EVENT user_command OF
                               cl_gui_alv_grid
                               IMPORTING
                               e_ucomm.
        METHODS : handle_drag_from_left
                             FOR EVENT ondrag OF
                              cl_gui_alv_grid
                              IMPORTING
                              e_row
                              e_dragdropobj .
        METHODS : handle_dropcomplete_from_left
                              FOR EVENT ondropcomplete  OF
                              cl_gui_alv_grid
                              IMPORTING
                              e_row
                              e_dragdropobj .
        METHODS : handle_drag_from_right
                              FOR EVENT ondrag OF
                              cl_gui_alv_grid
                              IMPORTING
                              e_row
                              e_dragdropobj .
        METHODS : handle_dropcomplete_from_right
                              FOR EVENT ondropcomplete  OF
                              cl_gui_alv_grid
                              IMPORTING
                              e_row
                              e_dragdropobj .
        METHODS : handle_drop_to_left
                              FOR EVENT ondrop OF
                              cl_gui_alv_grid
                              IMPORTING
                               e_dragdropobj .
        METHODS : handle_drop_to_right
                              FOR EVENT ondrop OF
                              cl_gui_alv_grid
                              IMPORTING
                              e_dragdropobj .
    ENDCLASS .                    "DND_TOOLS DEFINITION
          CLASS DND_TOOLS IMPLEMENTATION
    CLASS dnd_tools IMPLEMENTATION .
      METHOD handle_drag_from_left .
    METHOD handle_user_command.
       DATA: lt_rows TYPE lvc_t_row.
        DATA: lt_rows TYPE lvc_t_roid.
        DATA: lt_row TYPE lvc_s_roid.
        DATA: mdata TYPE REF TO lcl_dragdropobj .
        DATA: dragdropobj TYPE REF TO lcl_dragdropobj .
    get selected row
        CALL METHOD malv_left->get_selected_rows
          IMPORTING
            et_row_no = lt_rows.
        CALL METHOD cl_gui_cfw=>flush.
        IF sy-subrc NE 0.
    add your handling, for example
          CALL FUNCTION 'POPUP_TO_INFORM'
            EXPORTING
              titel = g_repid
              txt2  = sy-subrc
              txt1  = 'Error in Flush'(500).
        ENDIF.
        CREATE OBJECT mdata.
        LOOP AT lt_rows INTO lt_row.
         mrow = lt_row .
          READ TABLE i_ztransactions INDEX lt_row-row_id INTO
                     i_ztransactions.
          MOVE i_ztransactions TO mdata->i_ztransactions .
          MOVE lt_row-row_id TO mdata->index.
          MOVE 'LEFT' TO mdata->original_table .
          e_dragdropobj->object = mdata .
        ENDLOOP.
      ENDMETHOD.                           "handle_user_command
      METHOD handle_dropcomplete_from_left .
      NB : the following data object MDATA is local to
      the method and contains the information from the
      import parameter of the method E_DRAGDROPOBJ
        DATA : mdata TYPE REF TO lcl_dragdropobj .
        DATA: lt_rows TYPE lvc_t_roid.
        DATA: lt_row TYPE lvc_s_roid.
        CALL METHOD malv_left->get_selected_rows
          IMPORTING
            et_row_no = lt_rows.
        CALL METHOD cl_gui_cfw=>flush.
        IF sy-subrc NE 0.
    add your handling, for example
          CALL FUNCTION 'POPUP_TO_INFORM'
            EXPORTING
              titel = g_repid
              txt2  = sy-subrc
              txt1  = 'Error in Flush'(500).
        ENDIF.
        LOOP AT lt_rows INTO lt_row.
          mdata  ?= e_dragdropobj->object .
          CHECK mdata->proceed_trans = 'X' .
          mrow = mdata->index.
          DELETE i_ztransactions INDEX mrow .
          APPEND mdata->i_ztransactions TO i_ztransactions2 .
          SORT i_ztransactions2 BY kunnr belnr .
          DELETE i_ztransactions2 WHERE kunnr IS INITIAL .
          DESCRIBE TABLE i_ztransactions LINES mlines .
          IF mlines EQ 0 .
            CLEAR  i_ztransactions .
            APPEND i_ztransactions TO i_ztransactions .
          ENDIF .
        ENDLOOP.
        CALL METHOD malv_left->refresh_table_display.
        CALL METHOD malv_right->refresh_table_display.
      ENDMETHOD .                    "HANDLE_DROPCOMPLETE_FROM_LEFT
      METHOD handle_drag_from_right.
        mrow = e_row-index .
        READ TABLE i_ztransactions2 INDEX mrow INTO
                   i_ztransactions2 .
        CREATE OBJECT mdata .
        MOVE i_ztransactions2 TO mdata->i_ztransactions .
        MOVE mrow TO mdata->index .
        MOVE 'RIGHT' TO mdata->original_table .
        e_dragdropobj->object = mdata .
      ENDMETHOD .                    "HANDLE_DRAG_FROM_RIGHT
      METHOD handle_dropcomplete_from_right .
        DATA : mdata TYPE REF TO lcl_dragdropobj .
        mdata  ?= e_dragdropobj->object .
        CHECK mdata->proceed_trans = 'X' .
        mrow = mdata->index .
        DELETE i_ztransactions2 INDEX mrow .
        APPEND mdata->i_ztransactions TO i_ztransactions .
        SORT i_ztransactions BY kunnr belnr .
        DELETE i_ztransactions WHERE kunnr IS INITIAL .
        DESCRIBE TABLE i_ztransactions2 LINES mlines .
        IF mlines EQ 0 .
          CLEAR  i_ztransactions2 .
          APPEND i_ztransactions2 TO i_ztransactions2 .
        ENDIF .
        CALL METHOD malv_left->refresh_table_display.
        CALL METHOD malv_right->refresh_table_display.
      ENDMETHOD .                    "HANDLE_DROPCOMPLETE_FROM_RIGHT
      METHOD handle_drop_to_left .
        DATA : mdata TYPE REF TO lcl_dragdropobj .
        mdata  ?= e_dragdropobj->object .
        IF mdata->original_table = 'RIGHT' .
          mdata->proceed_trans = 'X' .
        ELSE .
          mdata->proceed_trans = ' ' .
        ENDIF .
        e_dragdropobj->object = mdata .
      ENDMETHOD .                    "HANDLE_DROP_TO_LEFT
      METHOD handle_drop_to_right .
        DATA : mdata TYPE REF TO lcl_dragdropobj .
        DATA: lt_rows TYPE lvc_t_roid.
        DATA: lt_row TYPE lvc_s_roid.
        CALL METHOD malv_left->get_selected_rows
          IMPORTING
            et_row_no = lt_rows.
        CALL METHOD cl_gui_cfw=>flush.
        IF sy-subrc NE 0.
    add your handling, for example
          CALL FUNCTION 'POPUP_TO_INFORM'
            EXPORTING
              titel = g_repid
              txt2  = sy-subrc
              txt1  = 'Error in Flush'(500).
        ENDIF.
        LOOP AT lt_rows INTO lt_row.
          mdata  ?= e_dragdropobj->object .
          IF mdata->original_table = 'LEFT' .
            mdata->proceed_trans = 'X' .
          ELSE .
            mdata->proceed_trans = ' ' .
          ENDIF .
          e_dragdropobj->object = mdata .
        ENDLOOP.
      ENDMETHOD .                    "HANDLE_DROP_TO_RIGHT
    ENDCLASS .                    "DND_TOOLS IMPLEMENTATION
    DATA : mlistener TYPE REF TO dnd_tools .
    ======================================================
    START OF SELECTION
    ======================================================
    START-OF-SELECTION .
      PERFORM get_data .
      CALL SCREEN 100 .
    The screen 100 has the custom control MCONTAINER and
    on the flow logic has the following modules :
    PROCESS BEFORE OUTPUT.
      MODULE STATUS_0100.
      MODULE PREPARE_SCREEN .
    PROCESS AFTER INPUT.
      MODULE USER_COMMAND_0100.
    (Off course not commented out in the real flow logic)
          FORM GET_DATA                                 *
    FOR THIS EXAMPLE THE DATA SELECTION IS HARD CODED
    FORM get_data .
      CLEAR : i_ztransactions , i_ztransactions[] .
      i_ztransactions-mandt = sy-mandt .
      i_ztransactions-waers = 'EUR  ' .
      i_ztransactions-kunnr = '0000000001' .
      i_ztransactions-belnr = '0000000001' .
      i_ztransactions-bldat = '20030101' .
    i_ztransactions-dmbtr = '1000' .
      APPEND i_ztransactions .
      i_ztransactions-belnr = '0000000002' .
      i_ztransactions-bldat = '20030202' .
    i_ztransactions-dmbtr = '1010' .
      APPEND i_ztransactions .
      i_ztransactions-belnr = '0000000003' .
      i_ztransactions-bldat = '20030323' .
    i_ztransactions-dmbtr = '1020' .
      APPEND i_ztransactions .
      i_ztransactions-belnr = '0000000004' .
      i_ztransactions-bldat = '20030404' .
    i_ztransactions-dmbtr = '1030' .
      APPEND i_ztransactions .
      i_ztransactions-belnr = '0000000005' .
      i_ztransactions-bldat = '20030505' .
    i_ztransactions-dmbtr = '1040' .
      APPEND i_ztransactions .
      i_ztransactions-belnr = '0000000006' .
      i_ztransactions-bldat = '20030606' .
    i_ztransactions-dmbtr = '1050' .
      APPEND i_ztransactions .
      i_ztransactions-belnr = '0000000007' .
      i_ztransactions-bldat = '20030707' .
    i_ztransactions-dmbtr = '1060' .
      APPEND i_ztransactions .
      i_ztransactions-belnr = '0000000008' .
      i_ztransactions-bldat = '20030808' .
    i_ztransactions-dmbtr = '1070' .
      APPEND i_ztransactions .
      i_ztransactions-belnr = '0000000009' .
      i_ztransactions-bldat = '20030909' .
    i_ztransactions-dmbtr = '1080' .
      APPEND i_ztransactions .
      i_ztransactions-belnr = '0000000010' .
      i_ztransactions-bldat = '20031010' .
    i_ztransactions-dmbtr = '1090' .
      APPEND i_ztransactions .
      CLEAR : i_ztransactions2 , i_ztransactions2[] .
      APPEND i_ztransactions2 .
    ENDFORM .                    "GET_DATA
    *&      Module  STATUS_0100  OUTPUT
    The PF STATUS STATUS100 called from the module below,
    has on the Standard toolbar the buttons
    BACK , EXIT and CANCEL .
    These buttons are provided with function code = 'EXIT'
    MODULE status_0100 OUTPUT.
      SET TITLEBAR 'TITLEDRAGDROP' .
      SET PF-STATUS 'STATUS100'.
    ENDMODULE.                 " STATUS_0100  OUTPUT
         Module  USER_COMMAND_0100  INPUT
    The following module checks the User Command and ends
    the program
    MODULE user_command_0100 INPUT.
      IF ok_code = 'EXIT' .
        CLEAR : mcontainer ,
               mcontleft  ,
               mcontright ,
               msplitcont ,
               malv_left  ,
               malv_right .
        LEAVE TO SCREEN 0  .
      ENDIF .
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Module  PREPARE_SCREEN  OUTPUT
    MODULE prepare_screen OUTPUT.
      IF mcontainer IS INITIAL .
        CREATE OBJECT mcontainer
                      EXPORTING
                      container_name = 'MCONTAINER' .
        CREATE OBJECT msplitcont
                      EXPORTING
                      parent = mcontainer
                      orientation = 1 .
        mcontleft = msplitcont->top_left_container .
        mcontright = msplitcont->bottom_right_container .
        CREATE OBJECT malv_left
                      EXPORTING i_parent = mcontleft .
        gs_layout-sel_mode = 'D'.
        CREATE OBJECT malv_right
                      EXPORTING i_parent = mcontright .
        gs_layout-sel_mode = 'D'.
        PERFORM set_layout_capable_of_drag_dro
                      USING 'X' 'X' .
        CALL METHOD malv_left->set_table_for_first_display
          EXPORTING
            i_structure_name = 'ZTRANSACTIONS'
            is_layout        = gs_layout
          CHANGING
            it_outtab        = i_ztransactions[].
        CALL METHOD malv_right->set_table_for_first_display
          EXPORTING
            i_structure_name = 'ZTRANSACTIONS'
            is_layout        = gs_layout
          CHANGING
            it_outtab        = i_ztransactions2[].
        CREATE OBJECT mlistener .
        CALL METHOD malv_left->set_toolbar_interactive.
        SET HANDLER mlistener->handle_drag_from_left
                    FOR malv_left .
        SET HANDLER mlistener->handle_dropcomplete_from_left
                    FOR malv_left .
        SET HANDLER mlistener->handle_drag_from_right
                    FOR malv_right.
        SET HANDLER mlistener->handle_dropcomplete_from_right
                      FOR malv_right .
        SET HANDLER mlistener->handle_drop_to_right
                     FOR malv_right .
        SET HANDLER mlistener->handle_drop_to_left
                     FOR malv_left  .
      ENDIF .
    ENDMODULE.                 " PREPARE_SCREEN  OUTPUT
          Form  SET_LAYOUT_CAPABLE_OF_DRAG_DRO
    Definition of a Drag & Drop behaviour for the ALV
    grid
    FORM set_layout_capable_of_drag_dro  USING drag drop.
      DATA : effect TYPE i ,
             handle_alv TYPE i .
      CREATE OBJECT g_behaviour_alv.
      effect = cl_dragdrop=>move + cl_dragdrop=>copy .
      CALL METHOD g_behaviour_alv->add
        EXPORTING
          flavor     = 'Line'
          dragsrc    = drag
          droptarget = drop
          effect     = effect.
      CALL METHOD g_behaviour_alv->get_handle
        IMPORTING
          handle = handle_alv.
      gs_layout-s_dragdrop-row_ddid = handle_alv.
    ENDFORM.              " SET_LAYOUT_CAPABLE_OF_DRAG_DRO

  • Regarding subtotals and new page in ALV Grid

    Hi All,
    I have 5 employees in my internal table and each employee having five records.
    Now iam displaying total employees in ALV grid and calculating their totals at the end of the hole records.
    But i need to display the sub totals for each employee and i need new page for each employee.
    means  1) New page for each employye
                2) sub totals for each employee
                3) grand total for all employees
    How can i proceed for this requirement in ALV grid?

    For subtotals first you need to set the do_sum = 'X' in the fieldcatalog for the columns you want totals.
    fieldcat-fieldname = 'ABC'.
    fieldcat-do_sum = 'X'.
    Append fieldcat to it_fieldcat,
    for subtotals you need to populate the SORT table.
    sort-fieldname = 'EMPLOYEE'.
    sort-up = 'X'.
    sort-group = '*'.  "<----- this is for new page
    "you can view new page in preview / print /
    "if you are using the list function
    sort-subtot = 'X'.
    append sort to it_sort.
    pass this it_sort to it_sort of the alv function.

  • Validations and default Values in ALV Grid

    All,
    I am using "set_table_for_first_display" to display a grid with empty editable rows wherein which users can enter data and process certain transactions.
    My requirement is to know if we can provide drop-downs and default values in this grid. for ex. if user want to insert a row, that row should automatically have some default values like company code, sales org etc.
    Also, if there is an error while validating the data, I should be able to set the focus on that field while displaying the error message. I was able to display error message but could not set the focus on the field that need to be corrected.
    Your earlier response is much appreciated.
    Regards
    Kasi

    Hi kasi,
    check these links:
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/abap/an easy reference for alv grid control.pdf
    http://www.abap4.it/download/ALV.pdf
    hope this helps,
    keerthi.

  • Left and right justifiation in alv grid

    I m using alv grid to display a tbale.I have to justify one perticular cell depending on value.So i have to first check the value of that field in itab and then justify right or left accordingly.
    Therefore , i cnt use just field of field catalog as im not goin to justify whole column.
    I tried to save justified value in itab  and then display in alv but alv doesnt display white space charaters in start and end.
    Could you help me with this topic.
    regards

    hii,
    i think this is not possible.

  • How to include change delete and insert options in alv grid display

    Hi,
    As per my requirement I need to display my output in grid.
    When the user makes any changes to any field of the alv it should get reflected in the tatabase table.
    Similarly according to the requirement if user enters a new coloumn to the alv or deletes one or more rows of the alv,same should be reflected in the databse table.
    I know there are many methods in object oriented.
    But its little bit tough for me to implement..
    Please suggest how to code for it without oo concepts.
    Thanks ,
    Smriti

    Hi,
    use FM with Edit functionality enabled for all fields and
    Create one pf-status with some buttons
    if user presses the button the alv output table should be saved and same table can be used to insert /modify /delete the dbtable.
    and check this link
    [alv list|alv list]
    Regards,
    Nandha

  • Change the total and subtotal dynamically in ALV GRID

    Hi guys,
               I need to change the total and subtotal of field "AMOUNT" dynamically.I am using ALV GRID CONTROL(oops concept).I need to override the standard functionality.I need to show my own subtotal and total line instead of standard one .

    Hi
    I've understood it, I wanted to use OO Grid too, but I had to use the ALV list in order to write my total.
    If you need to use OO grid u can try to exclude all funcitonalities for the total, subtotal and sorting and insert in the output table the lines with your totals.
    Max

Maybe you are looking for

  • How can i add my college email account to my mail box on the dashboard?

    I already have my Yahoo and my could account attached to the mail section of my computer, but i want to attach my collage, gonzaga univerity, email to it as well. I know i type in everything correctly but it still will not connect. Does anyone know h

  • Download excel file to PC in background

    Hi All, I need to write a report to local PC as an excel file. The program is working fine in foreground using cl_gui_frontend_services=>gui_download. However since the report data is very large, when the user runs the program in foreground, it alway

  • Events from iPhoto on my Mac wont sync to my iPad2 after upgrading to iOS8

    I recently updated to iOS8 on my iPad2.  During the update I got a message that the update failed and my iPad was stuck in Recovery Mode.  After Restoring my iPad2 and loading the most recent backup, I'm having issues with syncing all of my data back

  • Making a graph in java

    Hi I want to take data from a mySQL database and show it in an applet as a graph. The problem I'm having is creating the graph. Does anyone know a fairly simple way to do this? thanks

  • Default for PDF documents

    The default to open a pdf document always goes to "preview", which frequently marks the file as un readable. i have to save the pdf to a folder, then go in and "Open with" adobe. How do i change the default for any document with a .pdf subscript to a