ALV code in function module

Hi
I have created a report and it gets displayed in ALV. My requirement was to put the whole code in a function module, including the ALV functionality...I have put the same..the problem is that I am not able to see the TOP-OF-PAGE..
I am putting a sample code of what exactly I did in the function module..let me know what needs to be done..
FUNCTION ZAZTEST.
""Local Interface:
*"  IMPORTING
*"     REFERENCE(GV_REPID) TYPE  SY-REPID
*"  TABLES
*"      S_KUNNR STRUCTURE  JITO_KUNNR_RANGE
perform sub_get_customers tables s_kunnr
                          changing gt_kna1.
perform sub_prepare_fieldcatalog using :
'KUNNR'       'Customer No'       '10'          'GT_KNA1'    space         space changing   gt_fieldcat,
    'NAME1'         'Name'       '35'           'GT_KNA1'    space         space changing   gt_fieldcat,
    'LAND1'         'Country'       '4'           'GT_KNA1'    space         space changing  gt_fieldcat,
    'ORT01'         'City'       '35'           'GT_KNA1'    space         space changing  gt_fieldcat.
perform sub_build_alv_events changing gt_events.
perform sub_comment_build tables s_kunnr changing gt_list_top_of_page.
PERFORM sub_display using gv_repid gt_fieldcat   gt_events    gt_kna1.
ENDFUNCTION.
form sub_get_customers tables p_kunnr structure JITO_KUNNR_RANGE
changing p_it_kna1 type tt_kna1.
select kunnr name1 land1 ort01
from kna1
into table p_it_kna1
where kunnr in p_kunnr.
if sy-subrc eq 0.
  sort p_it_kna1 by kunnr.
endif.
endform.
      Prepare Field Catalog
     -->lv_F  fieldname
     -->lv_D  column Description
     -->lv_L  Output length
     -->lv_T  Tablename
     --lv_A  Reference table name
     --lv_B  Reference Field Name
FORM sub_prepare_fieldcatalog using value(lv_f)
                                    value(lv_d)
                                  value(lv_t)
                                    value(lv_l)
                                    value(lv_a)
                                     value(lv_b)
                                     changing pt_fieldcat TYPE  slis_t_fieldcat_alv.
DATA:  gs_fieldcat TYPE slis_fieldcat_alv.
  gs_fieldcat-fieldname = lv_f.
  gs_fieldcat-seltext_m = lv_d.
   gs_fieldcat-tabname   = lv_t.
  gs_fieldcat-outputlen = lv_l.
  gs_fieldcat-ref_tabname    = lv_a.
  gs_fieldcat-ref_fieldname = lv_b.
  APPEND gs_fieldcat TO Pt_fieldcat.
  CLEAR gs_fieldcat.
ENDFORM.                    "sub_prepare_fieldcatalog
*&      Form  sub_build_alv_events
FORM sub_build_alv_events CHANGING PT_EVENTS TYPE slis_t_event.
  DATA: ls_index TYPE sy-tabix,
  GS_EVENTS TYPE  slis_alv_event.
  CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
    EXPORTING
      i_list_type     = 0
    IMPORTING
      et_events       = Pt_events[]
    EXCEPTIONS
      list_type_wrong = 0
      OTHERS          = 0.
  READ TABLE Pt_events
        INTO gs_events
        WITH KEY name = slis_ev_top_of_page
  IF sy-subrc = 0.
    ls_index = sy-tabix.
    gs_events-form    = c_ev_top_of_page.
    MODIFY Pt_events FROM gs_events INDEX ls_index.
  ENDIF.
  CLEAR gs_events.
ENDFORM.                    " sub_build_alv_events
*&      Form  sub_comment_build
      text: print select options in the output
FORM sub_comment_build tables p_kunnr structure JITO_KUNNR_RANGE
changing gt_top_of_page type slis_t_listheader.
  DATA: ls_line TYPE slis_listheader,
        lv_Low(10) type c,
        lv_high(10) type c.
  lv_low = p_kunnr-low.
  lv_high = p_kunnr-high.
  CLEAR: ls_line.
  ls_line-typ  = 'H'.
  ls_line-info = 'Customer Details'.
  APPEND ls_line TO gt_top_of_page.
  IF NOT lv_low IS INITIAL AND NOT lv_high IS INITIAL.
    CLEAR: ls_line.
    ls_line-typ  = 'S'.
    ls_line-key  = 'Customer No'.   "TEXT DESCRIPTION
    CONCATENATE lv_low 'to' lv_high INTO ls_line-info
    SEPARATED BY space.
    APPEND ls_line TO gt_top_of_page.
elseif  lv_low is initial and lv_high is initial.
    CLEAR: ls_line.
    ls_line-typ  = 'S'.
    ls_line-key  = 'Customer No'.
    ls_line-info = 'ALL Values'.
    APPEND ls_line TO gt_top_of_page.
  ELSEIF lv_high IS INITIAL.
    CLEAR: ls_line.
    ls_line-typ  = 'S'.
    ls_line-key  = 'Customer No'.
    ls_line-info = lv_low.
    APPEND ls_line TO gt_top_of_page.
  ENDIF.
endform.
form SUB_EVENT_TOP_OF_PAGE.
  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
      it_list_commentary = gt_list_top_of_page.
ENDFORM.                    "sub_comment_build
**&      Form  sub_display
    ALV Grid Display
Form sub_display using pv_repid type sy-repid
        pt_fieldcat TYPE slis_t_fieldcat_alv
          pt_events type slis_t_event
         pt_kna1 type TT_kna1.
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program = pv_repid
      it_fieldcat        = Pt_fieldcat
      it_events          = Pt_events[]
    TABLES
      t_outtab           = Pt_kna1
    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.                                      "sub_display

Hello shakir,
You can refer to the code below:
TYPE-POOLS : slis.
* internal table declaration
Data:i_fieldcat TYPE STANDARD TABLE OF slis_fieldcat_alv,
      top_header TYPE slis_t_listheader.  "Table to store The Values of Top-Of-Page Parameter for ALV  
* work area declaration
Data: wa_top_header TYPE slis_listheader,
        wa_fieldcat   TYPE slis_fieldcat_alv.
* CONSTANTS
CONSTANTS: c_h    TYPE slis_listheader VALUE 'H',
                     c_s    TYPE slis_listheader VALUE 'S'.
********* calling a subroutine to display the fields ********************
    PERFORM zalv_display.
********* function module to display the report in Grid format ***********
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
        i_callback_program     = sy-repid
        i_callback_top_of_page = 'TOP_OF_PAGE'
        it_fieldcat            = i_fieldcat
      TABLES
        t_outtab               = i_final
      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  zalv_display
*       Subroutine To display the fields in grid format
FORM zalv_display .
  PERFORM zalv_grid_disp USING '1'  'CHARG'      'I_FINAL'    'Shotton coil id'.
  PERFORM zalv_grid_disp USING '2'  'MATNR'      'I_FINAL'    'Material number'.
  PERFORM zalv_grid_disp USING '3'  'BESTQ'      'I_FINAL'    'Stock Status'.
  PERFORM zalv_grid_disp USING '4'  'AUFNR'      'I_FINAL'    'PROCESS ORDER NUMBER'.
  PERFORM zalv_grid_disp USING '5'  'KDAUF'      'I_FINAL'    'SALES ORDER NUM'.
  PERFORM zalv_grid_disp USING '6'  'GESME'      'I_FINAL'    'Coil Weight'.
  PERFORM zalv_grid_disp USING '7'  'WDATU'      'I_FINAL'    'Date of coil receipt'.
  PERFORM zalv_grid_disp USING '8'  'LGTYP'      'I_FINAL'    'Storage Type'.
  PERFORM zalv_grid_disp USING '9'  'LGPLA'      'I_FINAL'    'Storage Bin'.
  PERFORM zalv_grid_disp USING '10' 'COIL_STAT'  'I_FINAL'    'COIL STATUS'.
  PERFORM zalv_grid_disp USING '11' 'MAKTX'      'I_FINAL'    'MATERIAL DESP'.
ENDFORM.                    " zalv_display
*&      Form  zalv_grid_disp
*       text
*      -->P_0691   column position
*      -->P_0692   field name
*      -->P_0693   table name
*      -->P_0694   field text
FORM zalv_grid_disp  USING    value(col_pos)     TYPE n
                              value(field_name)  TYPE c
                              value(tab_name)    TYPE c
                              value(sel_text)    TYPE c.
  wa_fieldcat-col_pos = col_pos.
  wa_fieldcat-fieldname = field_name.
  wa_fieldcat-tabname = tab_name.
  wa_fieldcat-seltext_l = sel_text.
  APPEND wa_fieldcat TO i_fieldcat.
  CLEAR wa_fieldcat.
ENDFORM.                    " zalv_grid_disp
*&      Form  top_of_page
*       module to display Header Information
FORM top_of_page.
************************     HEADER     ********************************
  wa_top_header-typ = c_h.
  CONCATENATE 'CONCESSION'
              'COIL'
              'REPORT'
              INTO wa_top_header-info
              SEPARATED BY space.
  APPEND wa_top_header TO top_header.
  CLEAR wa_top_header.
  wa_top_header-typ  = c_s.
  wa_top_header-key  = 'Date:'.
  WRITE sy-datum TO wa_top_header-info.
  APPEND wa_top_header TO top_header.
  CLEAR wa_top_header.
  wa_top_header-typ  = c_s.
  wa_top_header-key  = 'User Name:'.
  WRITE sy-uname TO wa_top_header-info.
  APPEND wa_top_header TO top_header.
  CLEAR wa_top_header.
*  wa_top_header-typ  = c_s.
*  wa_top_header-key  = 'No.Of Records :'.
*  WRITE sy-dbcnt TO wa_top_header-info.
*  APPEND wa_top_header TO top_header.
*  CLEAR wa_top_header.
  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
      it_list_commentary = top_header.
ENDFORM.                    "top_of_page

Similar Messages

  • Example of  a Simple ALV Report using Function Modules (not OO)

    Hi,
    I am new to ABAP. Where can I get a proper Example of  a Simple ALV Report using Function Modules?  I searched the forum but did not find a proper solution. Kindly help.
    Smruthi.
    Edited by: Smruthi Acharya on Jan 29, 2009 7:13 PM

    Hi,
    Use this demo code:-
    REPORT  z_alv01 MESSAGE-ID zmsg.
    *          TABLES
    TABLES : ekpo.
    *          TYPE POOLS
    TYPE-POOLS : slis.
    *          TYPE DECLARATION
    TYPES : BEGIN OF t_ekpo,
              ebeln TYPE ekpo-ebeln,
              ebelp TYPE ekpo-ebelp,
              matnr TYPE ekpo-matnr,
              werks TYPE ekpo-werks,
              menge TYPE ekpo-menge,
            END OF t_ekpo.
    *          PARAMETERS
    PARAMETERS : s_var TYPE disvariant-variant.
    *          DATA DECLARATION
    *VARIABLES
    DATA : check(1),
           rep_id TYPE sy-repid.
    *INTERNAL TABLE TYPE OF ZEKPO
    DATA : it_ekpo TYPE STANDARD TABLE OF t_ekpo WITH HEADER LINE.
    *FIELD CATALOG
    DATA : it_field TYPE slis_t_fieldcat_alv,
           wa_field TYPE slis_fieldcat_alv.
    *SORTING
    DATA : it_sort TYPE slis_t_sortinfo_alv,
           wa_sort TYPE slis_sortinfo_alv.
    *FOR TOP OF THE PAGE
    DATA : it_top TYPE slis_t_listheader,
           wa_top TYPE slis_listheader.
    *FOR END OF THE PAGE
    DATA : it_end TYPE slis_t_listheader,
           wa_end TYPE slis_listheader.
    *TO CAPTURE EVENTS AND HANDLE
    DATA : it_event TYPE slis_t_event,
           wa_event TYPE slis_alv_event.
    *FOR GRID TITLE
    DATA : wa_title TYPE lvc_title.
    *FOR LAYOUT
    DATA : wa_layout TYPE slis_layout_alv.
    *FOR EXCLUDING STANDARD BUTTON FROM ALV TOOLBAR
    DATA : it_exclude TYPE slis_t_extab,
           wa_exclude TYPE slis_extab.
    *FOR VARIANT
    DATA : wa_variant TYPE disvariant.
    *          INITIALIZATION
    INITIALIZATION.
      check = 'X'.
      rep_id = sy-repid.
      wa_variant-report = sy-repid.
    *GET DEFUALT ON THE SELECTION SCREEN FOR DEFAULT DISPLAY
      CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
        EXPORTING
          i_save        = 'A'
        CHANGING
          cs_variant    = wa_variant
        EXCEPTIONS
          wrong_input   = 1
          not_found     = 2
          program_error = 3
          OTHERS        = 4.
      IF sy-subrc = 0.               " IF DEFAULT VARIANT FOUND
        s_var = wa_variant-variant.  " PASS THE DEFAULT VARIANT TO THE SELECTION SCREEN FIELD
      ENDIF.
    *          AT-SELECTION SCREEN ON VALUE REQUEST
    *          TO GET THE F4 HELP FOR VARIANT
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_var.
      CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
        EXPORTING
          is_variant                = wa_variant
    *   I_TABNAME_HEADER          =
    *   I_TABNAME_ITEM            =
    *   IT_DEFAULT_FIELDCAT       =
         i_save                    = 'A'
    *   I_DISPLAY_VIA_GRID        = ' '
       IMPORTING
    *   E_EXIT                    =
         es_variant                = wa_variant
       EXCEPTIONS
         not_found                 = 1
         program_error             = 2
         OTHERS                    = 3.
      IF sy-subrc = 0.
        s_var = wa_variant-variant. " PASS THE SELECTED VARIANT TO THE SELECTION SCREEN FIELD
      ENDIF.
    *          AT-SELECTION SCREEN
    *          TO CHECK THE EXISTENCE FOR VARIANT
    AT SELECTION-SCREEN.
      wa_variant-variant = s_var.
      CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
        EXPORTING
          i_save        = 'A'
        CHANGING
          cs_variant    = wa_variant
        EXCEPTIONS
          wrong_input   = 1
          not_found     = 2
          program_error = 3
          OTHERS        = 4.
      IF sy-subrc <> 0.
        MESSAGE w001.
      ENDIF.
    *          START OF SELECTION
    START-OF-SELECTION.
      SELECT ebeln
             ebelp
             matnr
             werks
             menge
             FROM ekpo
             INTO TABLE it_ekpo.
    *          FIELD CATALOG
      wa_field-fieldname = 'EBELN'.
      wa_field-tabname = 'IT_TAB'.
      wa_field-outputlen = 10.
      wa_field-seltext_l = 'PO #'.
      APPEND wa_field TO it_field.
      CLEAR wa_field.
      wa_field-fieldname = 'EBELP'.
      wa_field-tabname = 'IT_TAB'.
      wa_field-outputlen = 10.
      wa_field-seltext_l = 'Line Item'.
      APPEND wa_field TO it_field.
      CLEAR wa_field.
      wa_field-fieldname = 'MATNR'.
      wa_field-tabname = 'IT_TAB'.
      wa_field-outputlen = 15.
      wa_field-seltext_l = 'Material'.
    *  wa_field-input = check.
    *  wa_field-edit = check.
      APPEND wa_field TO it_field.
      CLEAR wa_field.
      wa_field-fieldname = 'WERKS'.
      wa_field-tabname = 'IT_TAB'.
      wa_field-outputlen = 6.
      wa_field-seltext_l = 'Plant'.
    *  wa_field-input = check.
    *  wa_field-edit = check.
      APPEND wa_field TO it_field.
      CLEAR wa_field.
      wa_field-fieldname = 'MENGE'.
      wa_field-tabname = 'IT_TAB'.
      wa_field-outputlen = 10.
      wa_field-seltext_l = 'Qty.'.
    *  wa_field-input = check.
    *  wa_field-edit = check.
      wa_field-do_sum = check.
      APPEND wa_field TO it_field.
      CLEAR wa_field.
    *          SORT W.R.T. PURCHASE ORDER NUMBER
      wa_sort-spos = 1.
      wa_sort-fieldname = 'EBELN'.
      wa_sort-tabname = 'IT_EKPO'.
      wa_sort-up = check.
      wa_sort-subtot = check.
      APPEND wa_sort TO it_sort.
      CLEAR wa_sort.
    *          FOR GRID TITLE
      wa_title = 'Hello'.
    *          FOR LAYOUT
      wa_layout-zebra = check.
    *          FOR EXCLUDING STANDARD BUTTONS FROM ALV TOOLBAR
      wa_exclude-fcode = '&OUP'.
      APPEND wa_exclude TO it_exclude.
      CLEAR wa_exclude.
      wa_exclude-fcode = '&ODN'.
      APPEND wa_exclude TO it_exclude.
      CLEAR wa_exclude.
      wa_exclude-fcode = '&OAD'.
      APPEND wa_exclude TO it_exclude.
      CLEAR wa_exclude.
    *  wa_exclude-fcode = '&AVE'.
    *  APPEND wa_exclude TO it_exclude.
    *  CLEAR wa_exclude.
      wa_exclude-fcode = '&INFO'.
      APPEND wa_exclude TO it_exclude.
      CLEAR wa_exclude.
    *          POPULATE ALL EVENTS INTO INTERNAL TABLE
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type     = 0
        IMPORTING
          et_events       = it_event
        EXCEPTIONS
          list_type_wrong = 1
          OTHERS          = 2.
      IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      READ TABLE it_event INTO wa_event WITH KEY name = 'END_OF_LIST'.
      wa_event-form = 'END'.
      MODIFY it_event FROM wa_event INDEX sy-tabix.
      CLEAR wa_event.
    *          DISPLAY RECORDS IN ALV GRID
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
    *   I_INTERFACE_CHECK                 = ' '
    *   I_BYPASSING_BUFFER                = ' '
    *   I_BUFFER_ACTIVE                   = ' '
       i_callback_program                = rep_id
    *   i_callback_pf_status_set          = 'PF'
       i_callback_user_command           = 'COMMAND'
       i_callback_top_of_page            = 'TOP'
    *   I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
    *   I_CALLBACK_HTML_END_OF_LIST       = ' '
    *   I_STRUCTURE_NAME                  =
    *   I_BACKGROUND_ID                   = ' '
       i_grid_title                      = wa_title
    *   I_GRID_SETTINGS                   =
       is_layout                         = wa_layout
       it_fieldcat                       = it_field
       it_excluding                      = it_exclude
    *   IT_SPECIAL_GROUPS                 =
       it_sort                           = it_sort
    *   IT_FILTER                         =
    *   IS_SEL_HIDE                       =
    *   I_DEFAULT                         = 'X'
       i_save                            = 'A'
       is_variant                        = wa_variant
       it_events                         = it_event
    *   IT_EVENT_EXIT                     =
    *   IS_PRINT                          =
    *   IS_REPREP_ID                      =
    *   I_SCREEN_START_COLUMN             = 0
    *   I_SCREEN_START_LINE               = 0
    *   I_SCREEN_END_COLUMN               = 0
    *   I_SCREEN_END_LINE                 = 0
    *   I_HTML_HEIGHT_TOP                 = 0
    *   I_HTML_HEIGHT_END                 = 0
    *   IT_ALV_GRAPHICS                   =
    *   IT_HYPERLINK                      =
    *   IT_ADD_FIELDCAT                   =
    *   IT_EXCEPT_QINFO                   =
    *   IR_SALV_FULLSCREEN_ADAPTER        =
    * IMPORTING
    *   E_EXIT_CAUSED_BY_CALLER           =
    *   ES_EXIT_CAUSED_BY_USER            =
        TABLES
          t_outtab                          = it_ekpo
    EXCEPTIONS
       program_error                     = 1
       OTHERS                            = 2.
      IF sy-subrc <> 0.
      ENDIF.
    *&      Form  top
    *       TO WRITE THE HEADER
    FORM top.
      REFRESH it_top.
      wa_top-typ = 'S'.
      wa_top-key = text-001.
      wa_top-info = rep_id.
      APPEND wa_top TO it_top.
      CLEAR wa_top.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary       = it_top
    *   I_LOGO                   =
    *   I_END_OF_LIST_GRID       =
    *   I_ALV_FORM               =
    ENDFORM.                    "top
    *&      Form  end
    *       TO WRITE THE FOOTER
    FORM end.
      REFRESH it_end.
      wa_end-typ = 'S'.
      wa_end-key = text-001.
      wa_end-info = rep_id.
      APPEND wa_end TO it_end.
      CLEAR wa_end.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary       = it_end
    *   I_LOGO                   =
    *   I_END_OF_LIST_GRID       =
    *   I_ALV_FORM               =
    ENDFORM.                    "end
    *&      Form  pf
    *       FOR PF-STATUS WITH USER DEFINED BUTTONS
    *      -->RT_EXTAB   text
    FORM pf USING rt_extab TYPE slis_t_extab.
      SET PF-STATUS 'ZTG_PF_ALV'.
    ENDFORM.                    "pf
    *&      Form  command
    *       TO HANDLE USER ACTIONS AGAINST PF-STATUS
    *      -->UCOMM      text
    *      -->SELFIELD   text
    FORM command USING ucomm LIKE sy-ucomm selfield TYPE slis_selfield.
      DATA : ok_code TYPE sy-ucomm.
      ok_code = ucomm.
      CASE ok_code.
        WHEN 'T_DOWN'.
          CALL FUNCTION 'POPUP_TO_INFORM'
            EXPORTING
              titel = 'HELLO'
              txt1  = 'USER COMMAND'
              txt2  = 'TOTAL DOWN'.
        WHEN 'DOWN'.
          CALL FUNCTION 'POPUP_TO_INFORM'
            EXPORTING
              titel = 'HELLO'
              txt1  = 'USER COMMAND'
              txt2  = 'DOWN'.
        WHEN 'UP'.
          CALL FUNCTION 'POPUP_TO_INFORM'
            EXPORTING
              titel = 'HELLO'
              txt1  = 'USER COMMAND'
              txt2  = 'UP'.
        WHEN 'T_UP'.
          CALL FUNCTION 'POPUP_TO_INFORM'
            EXPORTING
              titel = 'HELLO'
              txt1  = 'USER COMMAND'
              txt2  = 'TOTAL UP'.
      ENDCASE.
    ENDFORM.                    "command
    Hope this helps you.
    Thanks & Regards,
    Tarun Gambhir

  • ALV Tree using Function Modules

    Hi,
    I want a simple example of ALV Tree using Function Modules which can display multiple Columns in the Hierarchically arranged fashion along with nodes & icons.
    Also should be able to handle the events.
    Thanks in Advance..

    Hi Ramesh,
    Here is a example of alv tree
    *& Report  BCALV_TREE_DEMO                                             *
    report  bcalv_tree_demo.
    class cl_gui_column_tree definition load.
    class cl_gui_cfw definition load.
    data tree1  type ref to cl_gui_alv_tree.
    data mr_toolbar type ref to cl_gui_toolbar.
    include <icon>.
    include bcalv_toolbar_event_receiver.
    include bcalv_tree_event_receiver.
    data: toolbar_event_receiver type ref to lcl_toolbar_event_receiver.
    data: gt_sflight      type sflight occurs 0,      "Output-Table
          gt_fieldcatalog type lvc_t_fcat, "Fieldcatalog
          ok_code like sy-ucomm.           "OK-Code
    start-of-selection.
    end-of-selection.
      call screen 100.
    *&      Module  PBO  OUTPUT
    *       process before output
    module pbo output.
      set pf-status 'MAIN100'.
      if tree1 is initial.
        perform init_tree.
      endif.
      call method cl_gui_cfw=>flush.
    endmodule.                             " PBO  OUTPUT
    *&      Module  PAI  INPUT
    *       process after input
    module pai input.
      case ok_code.
        when 'EXIT' or 'BACK' or 'CANC'.
          perform exit_program.
        when others.
          call method cl_gui_cfw=>dispatch.
      endcase.
      clear ok_code.
      call method cl_gui_cfw=>flush.
    endmodule.                             " PAI  INPUT
    *&      Form  build_fieldcatalog
    *       build fieldcatalog for structure sflight
    form build_fieldcatalog.
    * get fieldcatalog
      call function 'LVC_FIELDCATALOG_MERGE'
           exporting
                i_structure_name = 'SFLIGHT'
           changing
                ct_fieldcat      = gt_fieldcatalog.
    * change fieldcatalog
      data: ls_fieldcatalog type lvc_s_fcat.
      loop at gt_fieldcatalog into ls_fieldcatalog.
        case ls_fieldcatalog-fieldname.
          when 'CARRID' or 'CONNID' or 'FLDATE'.
            ls_fieldcatalog-no_out = 'X'.
            ls_fieldcatalog-key    = ''.
          when 'PRICE' or 'SEATSOCC' or 'SEATSMAX' or 'PAYMENTSUM'.
            ls_fieldcatalog-do_sum = 'X'.
        endcase.
        modify gt_fieldcatalog from ls_fieldcatalog.
      endloop.
    endform.                               " build_fieldcatalog
    *&      Form  build_hierarchy_header
    *       build hierarchy-header-information
    *      -->P_L_HIERARCHY_HEADER  strucxture for hierarchy-header
    form build_hierarchy_header changing
                                   p_hierarchy_header type treev_hhdr.
      p_hierarchy_header-heading = 'Hierarchy Header'.         "#EC NOTEXT
      p_hierarchy_header-tooltip =
                             'This is the Hierarchy Header !'. "#EC NOTEXT
      p_hierarchy_header-width = 30.
      p_hierarchy_header-width_pix = ''.
    endform.                               " build_hierarchy_header
    *&      Form  exit_program
    *       free object and leave program
    form exit_program.
      call method tree1->free.
      leave program.
    endform.                               " exit_program
    *&      Form  build_header
    *       build table for html_header
    *  -->  p1        text
    *  <--  p2        text
    form build_comment using
          pt_list_commentary type slis_t_listheader
          p_logo             type sdydo_value.
      data: ls_line type slis_listheader.
    * LIST HEADING LINE: TYPE H
      clear ls_line.
      ls_line-typ  = 'H'.
    * LS_LINE-KEY:  NOT USED FOR THIS TYPE
      ls_line-info = 'ALV-tree-demo: flight-overview'.       "#EC NOTEXT
      append ls_line to pt_list_commentary.
    * STATUS LINE: TYPE S
      clear ls_line.
      ls_line-typ  = 'S'.
      ls_line-key  = 'valid until'.                          "#EC NOTEXT
      ls_line-info = 'January 29 1999'.                      "#EC NOTEXT
      append ls_line to pt_list_commentary.
      ls_line-key  = 'time'.
      ls_line-info = '2.00 pm'.                              "#EC NOTEXT
      append ls_line to pt_list_commentary.
    * ACTION LINE: TYPE A
      clear ls_line.
      ls_line-typ  = 'A'.
    * LS_LINE-KEY:  NOT USED FOR THIS TYPE
      ls_line-info = 'actual data'.                          "#EC NOTEXT
      append ls_line to pt_list_commentary.
      p_logo = 'ENJOYSAP_LOGO'.
    endform.
    *&      Form  create_hierarchy
    *       text
    *  -->  p1        text
    *  <--  p2        text
    form create_hierarchy.
      data: ls_sflight type sflight,
            lt_sflight type sflight occurs 0.
    * get data
      select * from sflight into table lt_sflight
                            UP TO 200 ROWS .
      sort lt_sflight by carrid connid fldate.
    * add data to tree
      data: l_carrid_key type lvc_nkey,
            l_connid_key type lvc_nkey,
            l_last_key type lvc_nkey.
      loop at lt_sflight into ls_sflight.
        on change of ls_sflight-carrid.
          perform add_carrid_line using    ls_sflight
                                  changing l_carrid_key.
        endon.
        on change of ls_sflight-connid.
          perform add_connid_line using    ls_sflight
                                           l_carrid_key
                                  changing l_connid_key.
        endon.
        perform add_complete_line using  ls_sflight
                                         l_connid_key
                                changing l_last_key.
      endloop.
    * calculate totals
      call method tree1->update_calculations.
    * this method must be called to send the data to the frontend
      call method tree1->frontend_update.
    endform.                               " create_hierarchy
    *&      Form  add_carrid_line
    *       add hierarchy-level 1 to tree
    *      -->P_LS_SFLIGHT  sflight
    *      -->P_RELEATKEY   relatkey
    *     <-->p_node_key    new node-key
    form add_carrid_line using     ps_sflight type sflight
                                   p_relat_key type lvc_nkey
                         changing  p_node_key type lvc_nkey.
      data: l_node_text type lvc_value,
            ls_sflight type sflight.
    * set item-layout
      data: lt_item_layout type lvc_t_layi,
            ls_item_layout type lvc_s_layi.
      ls_item_layout-t_image = '@3P@'.
      ls_item_layout-fieldname = tree1->c_hierarchy_column_name.
      ls_item_layout-style   =
                            cl_gui_column_tree=>style_intensifd_critical.
      append ls_item_layout to lt_item_layout.
    * add node
      l_node_text =  ps_sflight-carrid.
      call method tree1->add_node
        exporting
              i_relat_node_key = p_relat_key
              i_relationship   = cl_gui_column_tree=>relat_last_child
              i_node_text      = l_node_text
              is_outtab_line   = ls_sflight
              it_item_layout   = lt_item_layout
           importing
              e_new_node_key = p_node_key.
    endform.                               " add_carrid_line
    *&      Form  add_connid_line
    *       add hierarchy-level 2 to tree
    *      -->P_LS_SFLIGHT  sflight
    *      -->P_RELEATKEY   relatkey
    *     <-->p_node_key    new node-key
    form add_connid_line using     ps_sflight type sflight
                                   p_relat_key type lvc_nkey
                         changing  p_node_key type lvc_nkey.
      data: l_node_text type lvc_value,
            ls_sflight type sflight.
    * set item-layout
      data: lt_item_layout type lvc_t_layi,
            ls_item_layout type lvc_s_layi.
      ls_item_layout-t_image = '@3Y@'.
      ls_item_layout-style   =
                            cl_gui_column_tree=>style_intensified.
      ls_item_layout-fieldname = tree1->c_hierarchy_column_name.
      append ls_item_layout to lt_item_layout.
    * add node
      l_node_text =  ps_sflight-connid.
      call method tree1->add_node
        exporting
              i_relat_node_key = p_relat_key
              i_relationship   = cl_gui_column_tree=>relat_last_child
              i_node_text      = l_node_text
              is_outtab_line   = ls_sflight
              it_item_layout   = lt_item_layout
           importing
              e_new_node_key = p_node_key.
    endform.                               " add_connid_line
    *&      Form  add_cmplete_line
    *       add hierarchy-level 3 to tree
    *      -->P_LS_SFLIGHT  sflight
    *      -->P_RELEATKEY   relatkey
    *     <-->p_node_key    new node-key
    form add_complete_line using   ps_sflight type sflight
                                   p_relat_key type lvc_nkey
                         changing  p_node_key type lvc_nkey.
      data: l_node_text type lvc_value.
    * set item-layout
      data: lt_item_layout type lvc_t_layi,
            ls_item_layout type lvc_s_layi.
      ls_item_layout-fieldname = tree1->c_hierarchy_column_name.
      ls_item_layout-class   = cl_gui_column_tree=>item_class_checkbox.
      ls_item_layout-editable = 'X'.
      append ls_item_layout to lt_item_layout.
      l_node_text =  ps_sflight-fldate.
      call method tree1->add_node
        exporting
              i_relat_node_key = p_relat_key
              i_relationship   = cl_gui_column_tree=>relat_last_child
              is_outtab_line   = ps_sflight
              i_node_text      = l_node_text
              it_item_layout   = lt_item_layout
           importing
              e_new_node_key = p_node_key.
    endform.                               " add_complete_line
    *&      Form  register_events
    *       text
    *  -->  p1        text
    *  <--  p2        text
    form register_events.
    * define the events which will be passed to the backend
      data: lt_events type cntl_simple_events,
            l_event type cntl_simple_event.
    * define the events which will be passed to the backend
      l_event-eventid = cl_gui_column_tree=>eventid_expand_no_children.
      append l_event to lt_events.
      l_event-eventid = cl_gui_column_tree=>eventid_checkbox_change.
      append l_event to lt_events.
      l_event-eventid = cl_gui_column_tree=>eventid_header_context_men_req.
      append l_event to lt_events.
      l_event-eventid = cl_gui_column_tree=>eventid_node_context_menu_req.
      append l_event to lt_events.
      l_event-eventid = cl_gui_column_tree=>eventid_item_context_menu_req.
      append l_event to lt_events.
      l_event-eventid = cl_gui_column_tree=>eventid_header_click.
      append L_EVENT to lt_events.
      l_event-eventid = cl_gui_column_tree=>eventid_item_keypress.
      append L_EVENT to lt_events.
      call method tree1->set_registered_events
        exporting
          events = lt_events
        exceptions
          cntl_error                = 1
          cntl_system_error         = 2
          illegal_event_combination = 3.
      if sy-subrc <> 0.
        message x208(00) with 'ERROR'.                       "#EC NOTEXT
      endif.
    * set Handler
      data: l_event_receiver type ref to lcl_tree_event_receiver.
      create object l_event_receiver.
      set handler l_event_receiver->handle_node_ctmenu_request
                                                            for tree1.
      set handler l_event_receiver->handle_node_ctmenu_selected
                                                            for tree1.
      set handler l_event_receiver->handle_item_ctmenu_request
                                                            for tree1.
      set handler l_event_receiver->handle_item_ctmenu_selected
                                                            for tree1.
    endform.                               " register_events
    *&      Form  change_toolbar
    *       text
    *  -->  p1        text
    *  <--  p2        text
    form change_toolbar.
    * get toolbar control
      call method tree1->get_toolbar_object
              importing
                  er_toolbar = mr_toolbar.
      check not mr_toolbar is initial.
    * add seperator to toolbar
      call method mr_toolbar->add_button
              exporting
                  fcode     = ''
                  icon      = ''
                  butn_type = cntb_btype_sep
                  text      = ''
                  quickinfo = 'This is a Seperator'.         "#EC NOTEXT
    * add Standard Button to toolbar (for Delete Subtree)
      call method mr_toolbar->add_button
              exporting
                  fcode     = 'DELETE'
                  icon      = '@18@'
                  butn_type = cntb_btype_button
                  text      = ''
                  quickinfo = 'Delete subtree'.              "#EC NOTEXT
    * add Dropdown Button to toolbar (for Insert Line)
      call method mr_toolbar->add_button
              exporting
                  fcode     = 'INSERT_LC'
                  icon      = '@17@'
                  butn_type = cntb_btype_dropdown
                  text      = ''
                  quickinfo = 'Insert Line'.           "#EC NOTEXT
    * set event-handler for toolbar-control
      create object toolbar_event_receiver.
      set handler toolbar_event_receiver->on_function_selected
                                                          for mr_toolbar.
      set handler toolbar_event_receiver->on_toolbar_dropdown
                                                          for mr_toolbar.
    endform.                               " change_toolbar
    *&      Form  init_tree
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM init_tree.
    * create fieldcatalog for structure sflight
      perform build_fieldcatalog.
    * create container for alv-tree
      data: l_tree_container_name(30) type c,
            l_custom_container type ref to cl_gui_custom_container.
      l_tree_container_name = 'TREE1'.
      if sy-batch is initial.
        create object l_custom_container
          exporting
                container_name = l_tree_container_name
          exceptions
                cntl_error                  = 1
                cntl_system_error           = 2
                create_error                = 3
                lifetime_error              = 4
                lifetime_dynpro_dynpro_link = 5.
        if sy-subrc <> 0.
          message x208(00) with 'ERROR'.                       "#EC NOTEXT
        endif.
      endif.
    * create tree control
      create object tree1
        exporting
            parent              = l_custom_container
            node_selection_mode = cl_gui_column_tree=>node_sel_mode_single
            item_selection      = 'X'
            no_html_header      = ''
            no_toolbar          = ''
        exceptions
            cntl_error                   = 1
            cntl_system_error            = 2
            create_error                 = 3
            lifetime_error               = 4
            illegal_node_selection_mode  = 5
            failed                       = 6
            illegal_column_name          = 7.
      if sy-subrc <> 0.
        message x208(00) with 'ERROR'.                       "#EC NOTEXT
      endif.
    * create Hierarchy-header
      data l_hierarchy_header type treev_hhdr.
      perform build_hierarchy_header changing l_hierarchy_header.
    * create info-table for html-header
      data: lt_list_commentary type slis_t_listheader,
            l_logo             type sdydo_value.
      perform build_comment using
                     lt_list_commentary
                     l_logo.
    * repid for saving variants
      data: ls_variant type disvariant.
      ls_variant-report = sy-repid.
    * create emty tree-control
      call method tree1->set_table_for_first_display
         exporting
                   is_hierarchy_header  = l_hierarchy_header
                   it_list_commentary   = lt_list_commentary
                   i_logo               = l_logo
                   i_background_id      = 'ALV_BACKGROUND'
                   i_save               = 'A'
                   is_variant            = ls_variant
         changing
                   it_outtab            = gt_sflight "table must be emty !!
                   it_fieldcatalog      = gt_fieldcatalog.
    * create hierarchy
      perform create_hierarchy.
    * add own functioncodes to the toolbar
      perform change_toolbar.
    * register events
      perform register_events.
    * adjust column_width
      call method tree1->COLUMN_OPTIMIZE.
    ENDFORM.                    " init_tree
    regards,
    venu.

  • Display the  long text in alv by using function modules

    Hi all,
    How to display the  long text in alv by using function modules ?
    Send me any sample code.
    Thanks in advance
    krupali.

    Hello KR,
    Use READ_TEXT and concatenate the first lines of the text.
    CALL FUNCTION 'READ_TEXT'
         EXPORTING
              id       = 'F01'
              language = sy-langu
              name     = lv_name " purchase order with leading zeroes
              object   = 'EKKO'
         TABLES
              lines    = t_lines
         EXCEPTIONS
              OTHERS   = 8.
    You can loop at t_lines and concatenate header in to some other field.
    Best Regards,
    Sasidhar Reddy Matli.
    Edited by: Sasidhar Reddy Matli on Aug 13, 2008 12:25 PM

  • One editable cell in alv grid using function module

    Hello all,
    Any one have an idea how to make a single editable cell in alv grid using function module, i mean to say
    with out using object oriented programming.
    Regards,
    Prakash

    Hi,
    Using ALV List display it is possible.
    Try this.
    TYPE-POOLS:SLIS.
    DATA: X_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
    DATA: IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
    DATA:IT_EVENTS TYPE SLIS_T_EVENT.
    data: begin of it_chg occurs 0,
          index type sy-tabix,
          end of it_chg.
    DATA:  X_EVENTS    TYPE SLIS_ALV_EVENT.
    DATA: BEGIN OF ITAB OCCURS 0,
          NAME(10) TYPE C,
          ZTERM TYPE C,
          END OF ITAB.
    PERFORM FILL_TABLE.
    loop at itab where zterm = 'A'.
    it_chg-index = sy-tabix + 3.
    " addition 3 IS FOR FIELD LABELS
    append it_chg.
    clear it_chg.
    endloop.
    DATA:L_POS TYPE I VALUE 1.
    CLEAR: L_POS.
    L_POS = L_POS + 1.
    **fieldcatalog
    X_FIELDCAT-FIELDNAME = 'NAME'.
    X_FIELDCAT-TABNAME = 'ITAB'.
    X_FIELDCAT-COL_POS    = L_POS.
    X_FIELDCAT-OUTPUTLEN = '10'.
    APPEND X_FIELDCAT TO IT_FIELDCAT.
    CLEAR X_FIELDCAT.
    L_POS = L_POS + 1.
    X_FIELDCAT-FIELDNAME = 'ZTERM'.
    X_FIELDCAT-TABNAME = 'ITAB'.
    X_FIELDCAT-COL_POS    = L_POS.
    X_FIELDCAT-OUTPUTLEN = '10'.
    APPEND X_FIELDCAT TO IT_FIELDCAT.
    CLEAR X_FIELDCAT.
    **events
    REFRESH:IT_EVENTS.
    CLEAR:X_EVENTS,IT_EVENTS.
    X_EVENTS-NAME = SLIS_EV_END_OF_LIST.
    X_EVENTS-FORM = 'MODIFY_LIST'.
    APPEND X_EVENTS TO IT_EVENTS.
    CLEAR X_EVENTS.
    END-OF-SELECTION.
    data lv_repid type sy-repid.
    lv_repid = sy-repid.
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
        EXPORTING
          I_CALLBACK_PROGRAM = lv_REPID
          IT_FIELDCAT        = IT_FIELDCAT
          IT_EVENTS          = IT_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.
    *&      Form FILL_TABLE
          text
    FORM FILL_TABLE.
      ITAB-NAME = 'AAA'.
      ITAB-ZTERM = 'A'.
      APPEND ITAB.
      clear itab.
      ITAB-NAME = 'ABC'.
      ITAB-ZTERM = 'B'.
      APPEND ITAB.
      clear itab.
      ITAB-NAME = 'TEST'.
      ITAB-ZTERM = 'C'.
      APPEND ITAB.
      clear itab.
      ITAB-NAME = 'BBB'.
      ITAB-ZTERM = 'D'.
      APPEND ITAB.
      clear itab.
      ITAB-NAME = '123'.
      ITAB-ZTERM = 'E'.
      APPEND ITAB.
      clear itab.
      ITAB-NAME = 'GEN'.
      ITAB-ZTERM = 'A'.
      APPEND ITAB.
      clear itab.
      ITAB-NAME = 'ALV'.
      ITAB-ZTERM = 'F'.
      APPEND ITAB.
      clear itab.
      ITAB-NAME = 'ALVTEST'.
      ITAB-ZTERM = 'A'.
      APPEND ITAB.
      clear itab.
    ENDFORM.                    "FILL_TABLE
    *&      Form  MODIFY_LIST
          text
    FORM MODIFY_LIST.
    data: l_lines type i.
    describe table itab lines l_lines.
      L_LINES  = L_LINES + 3.
    "because we have 3 lines extra occupied by lables.
    "if we have header,i mean top of page add the no.of lines
    "how many ever top of page have + 3 for labels.
      DO L_LINES TIMES.
        read table it_chg with key INDEX = sy-index.
        if sy-subrc = 0.
    **This code is for reading the out put line
    **and modify accordinlg to our requiremnet.
    **don't chnage this.
          READ LINE SY-INDEX INDEX SY-LSIND.
          IF SY-SUBRC = 0.
            MODIFY LINE SY-INDEX INDEX SY-LSIND
                       FIELD FORMAT ITAB-NAME INPUT.
          ENDIF.
        ENDIF.
      ENDDO.
    ENDFORM.                    "MODIFY_LIST

  • Assigning of process code to function module

    hi all,
    please let me know where to go for assigning teh process code to function module. i am unable to get the function module from the process code(we42).  please let me know
    thank you
    chan

    In WE42 itself we can assign the process code to a FM.
    select new entries.
    Enter a process code name & description.
    Enter Ur FM in Identification Field.
    Now select Processing by Function module in Processing type.
    Save it.
    For outbound do the same thing in WE41 tcode

  • Alv grid using function module

    hi all,
    i am using editable alv grid. but i need to add a functionality by adding a button on toolbar on click on button a new blank row should be appended below where user can enter the new records. please suggest on this i am using alv grid using function module.

    Hi
    check this program
    BCALV_TEST_GRID_EDITABLE
    when u execute the program, there is an alv which displays a set of records.
    where we have a option to add new row to the alv.check it.
    Hope this helps you.

  • Adding a color to row of a alv grid using function modules

    Can anybody clearly explains me how to add a color to a row to an alv grid using function module reuse_alv_grid_display.
    thanks in advance
    regards
    anil.

    hi,
    chk this ample pgm
    report zxyz_0004
           no standard page heading.
    type-pools slis.
    data: fieldcat type slis_t_fieldcat_alv.
    data: begin of imara occurs 0,
          matnr type mara-matnr,
          mtart type mara-mtart,
          maktx type makt-maktx,
          color_line(4) type c,
          tcolor type slis_t_specialcol_alv,  "cell
          end of imara.
    data: xcolor type slis_specialcol_alv.
    start-of-selection.
      perform get_data.
      perform write_report.
    Get_Data
    form get_data.
      imara-matnr = 'ABC'.
      imara-mtart = 'ZCFG'.
      imara-maktx = 'This is description for ABC'.
      append imara.
      imara-matnr = 'DEF'.
      imara-mtart = 'ZCFG'.
      imara-maktx = 'This is description for DEF'.
      append imara.
      imara-matnr = 'GHI'.
      imara-mtart = 'ZCFG'.
      imara-maktx = 'This is description for GHI'.
      append imara.
      loop at imara.
        if sy-tabix = 1.
          imara-color_line = 'C410'.   " color line
        endif.
        if sy-tabix = 2.          "color CELL
          clear xcolor.
          xcolor-fieldname = 'MTART'.
          xcolor-color-col = '3'.
          xcolor-color-int = '1'. "Intensified on/off
          xcolor-color-inv = '0'.
          append xcolor to imara-tcolor.
        endif.
        modify imara.
      endloop.
    endform.
    WRITE_REPORT
    form write_report.
      data: layout type  slis_layout_alv.
      layout-coltab_fieldname = 'TCOLOR'.
      layout-info_fieldname = 'COLOR_LINE'.
      perform build_field_catalog.
    CALL ABAP LIST VIEWER (ALV)
      call function 'REUSE_ALV_GRID_DISPLAY'
           exporting
                is_layout   = layout
                it_fieldcat = fieldcat
           tables
                t_outtab    = imara.
    endform.
    BUILD_FIELD_CATALOG
    form build_field_catalog.
      data: fc_tmp type slis_t_fieldcat_alv with header line.
      clear: fieldcat. refresh: fieldcat.
      clear: fc_tmp.
      fc_tmp-reptext_ddic    = 'Material Number'.
      fc_tmp-fieldname  = 'MATNR'.
      fc_tmp-tabname   = 'IMARA'.
      fc_tmp-outputlen  = '18'.
      append fc_tmp to fieldcat.
      clear: fc_tmp.
      fc_tmp-reptext_ddic    = 'Material Type'.
      fc_tmp-fieldname  = 'MTART'.
      fc_tmp-tabname   = 'IMARA'.
      fc_tmp-outputlen  = '4'.
      append fc_tmp to fieldcat.
      clear: fc_tmp.
      fc_tmp-reptext_ddic    = 'Material'.
      fc_tmp-fieldname  = 'MAKTX'.
      fc_tmp-tabname   = 'IMARA'.
      fc_tmp-outputlen  = '40'.
      fc_tmp-emphasize = 'C610'.   " color column
      append fc_tmp to fieldcat.
    endform.
    <b>anil , pls chk this link also.
    http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_color.htm
    very hlpful.</b>
    rgds
    anver
    <b>pls mark points if ur issue solved</b>
    Message was edited by: Anversha s
    Message was edited by: Anversha s

  • How to EDIT a particular Row in ALV using normal function module Reuse_alv_grid_display

    Hi experts..
    i got one requirement like i need to edit some rows particularly in alv....
    Edit in alv output....is it possible to get  that .....using normal function module with out using oops concept...
    could any one pls help me...

    Hi Pendurti ,
    If you want a particular field to be editable , simply define the fieldcatalog as
    wa_fieldcatalog-edit          = 'X'.
    wa_fieldcatalog-input         = 'X'.
    for that field.
    and
    Now when you use FM ' Reuse alv grid display '
    define USER_COMMAND
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program       = v_repid
          i_callback_pf_status_set = 'SET_PF_STATUS'
          i_callback_user_command  = 'USER_COMMAND'
          it_fieldcat              = int_fieldcatalog
          is_layout                = wa_layout
        TABLES
          t_outtab                 = t_disp.
    and now in form USER_COMMAND ; code as per following
    FORM user_command  USING r_ucomm LIKE sy-ucomm
                                rs_selfield TYPE slis_selfield.
         DATA ref1 TYPE REF TO cl_gui_alv_grid.
         CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
           IMPORTING
             e_grid = ref1.
         CALL METHOD ref1->check_changed_data.
    endform.
    Regards,
    Yogendra Bhaskar

  • ALV object in function module shows old data

    Hello,
    I create a function module with import parameter matnr.
    This function module calls a screen that displays an ALV with the whole info of matnr out of table mara.
    I include this in a program where a material can be selected. This is then input for the function module. Everything looks good for the first material. However when the function module is called for a second material I still see the ALV with the data of the previous material.
    When I debug the code I see that new data is selected and put on the alv (with method set_table_for_first_display)  but still I see the old ALV (which I free by the way in the exit of my function module...). It drives me crazy, what's the problem?
    <b>My function module:
    </b>
    FUNCTION ZJVB_TEST.
    *"*"Lokale interface:
    *"  IMPORTING
    *"     REFERENCE(I_MATNR) TYPE  MATNR
    g_matnr = i_matnr.
    call SCREEN 1979.
    ENDFUNCTION.
    <b>TOP include:</b>
    FUNCTION-POOL ZJVB_TEST.                    "MESSAGE-ID ..
    data: ok_code type sy-ucomm,
          container type ref to cl_gui_custom_container,
          alv type ref to cl_gui_alv_grid,
          g_matnr type matnr.
    *&      Module  STATUS_1979  OUTPUT
    *       text
    MODULE STATUS_1979 OUTPUT.
      SET PF-STATUS 'FMAIN'.
    *  SET TITLEBAR 'xxx'.
      if container is INITIAL.
        CREATE OBJECT CONTAINER
          EXPORTING
            CONTAINER_NAME              = 'CONTAINER'    .
        CREATE OBJECT ALV
          EXPORTING
            I_PARENT          = container.
        data: itab type TABLE OF mara.
        select *
          from mara
          into TABLE itab
          where matnr = g_matnr.
        CALL METHOD ALV->SET_TABLE_FOR_FIRST_DISPLAY
          EXPORTING
             I_STRUCTURE_NAME              = 'MARA'
          CHANGING
            IT_OUTTAB                     = itab.
      endif.
    ENDMODULE.                 " STATUS_1979  OUTPUT
    *&      Module  USER_COMMAND_1979  INPUT
    *       text
    MODULE USER_COMMAND_1979 INPUT.
      case ok_code.
        when 'BACK'.
          free container.
          free alv.
          LEAVE to SCREEN 0.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_1979  INPUT
    <b>My program:</b>
    *& Report  ZJEROEN_ALV_FM
    REPORT  ZJEROEN_ALV_FM.
    data: ok_code type sy-ucomm,
          l_matnr type matnr.
    call SCREEN 1979.
    *&      Module  STATUS_1979  OUTPUT
    *       text
    MODULE STATUS_1979 OUTPUT.
      SET PF-STATUS 'MAIN'.
    *  SET TITLEBAR 'xxx'.
    ENDMODULE.                 " STATUS_1979  OUTPUT
    *&      Module  USER_COMMAND_1979  INPUT
    *       text
    MODULE USER_COMMAND_1979 INPUT.
    case ok_code.
      when 'BACK'.
        leave to screen 0.
      when 'CALL'.
          CALL FUNCTION 'ZJVB_TEST'
          EXPORTING
                    i_matnr = l_matnr.
    endcase.
    ENDMODULE.                 " USER_COMMAND_1979  INPUT
    Thx for helping,
    jeroen

    Hello,
    I found out that the container lifetime was the problem... When you create a container to put the ALV in the lifetime is set to default. Normally you never change this, I didn't mention it before I had the problem. But you have to change the lifetime to <your_instance_name>->lifetime_dynpro for instance my_container->lifetime_dynpro.
    Also check this helplink: http://help.sap.com/saphelp_nw04/helpdata/en/9b/d080b79fc111d2bd68080009b4534c/frameset.htm

  • ALV ERROR in Function Module Fieldcatlog Merge .

    Hi
    I have added 2 more fileds in internral table . this is alv report there is no syntax error .
    i have user function module
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
    i_program_name = w_repid
    i_internal_tabname = 'T_BSIK'
    I_STRUCTURE_NAME =
    I_CLIENT_NEVER_DISPLAY = 'X'
    i_inclname = w_repid
    i_bypassing_buffer = 'X'
    I_BUFFER_ACTIVE =
    CHANGING
    ct_fieldcat = T_FIELDCAT
    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.
    LOOP AT t_fieldcat INTO wa_fieldcat.
    CASE wa_fieldcat-fieldname.
    WHEN 'ZFBDT'.
    wa_fieldcat-key = ''.
    wa_fieldcat-reptext_ddic = 'Net Due Dt.'.
    wa_fieldcat-seltext_l = 'Net Due Dt.'.
    wa_fieldcat-seltext_m = 'Net Due Dt.'.
    wa_fieldcat-seltext_s = 'Net Due Dt.'.
    WHEN 'KUNNR'.
    IF p_kunnr IS INITIAL.
    wa_fieldcat-no_out = 'X'.
    ENDIF.
    WHEN 'LIFNR'.
    IF NOT p_kunnr IS INITIAL.
    wa_fieldcat-no_out = 'X'.
    ENDIF.
    WHEN 'SHKZG'.
    wa_fieldcat-no_out = 'X'.
    WHEN 'ZBD1T'.
    wa_fieldcat-no_out = 'X'.
    WHEN 'BELNR'.
    wa_fieldcat-key = 'X'.
    WHEN OTHERS.
    wa_fieldcat-key = ''.
    ENDCASE.
    MODIFY t_fieldcat FROM wa_fieldcat.
    ENDLOOP.
    I am getting error on that.
    ERROR is :
    The Internal table "\UNCTION= K_KKB_FIELDCAT_MERGE\DATA=L_ABAP_SOURCE[]" IS 72 CHARACTERS Wide
    .the program line is 79 characters wide.
    Thanks
    Chandra

    Hi Chandra,
    For ALV reports the length should not be greater than 72. (please change the same)
    You can also achive the same
    Goto SE38
    Open your program in edit
    Utilities --> Settings --> Set "Downwards-Comp Line Length" falg to X and save. (This wil auotmatically set ur code to 72 chars)
    Hope this helps,
    Nag

  • Alv's using function modules

    hi,
    in alv's using fuction modules how to add pushbuttons in application tool bar?

    Hi Ganapathi,
    Check out the list of Function Modules
    ABAP_DOCU_DOWNLOAD     Download ABAP documentation in HTML format.
    APPL_LOG_DELETE     With this function module you delete logs in the database according to specified selection conditions
    APPL_LOG_DISPLAY     With this function module you can analyze logs in the database.
    APPL_LOG_DISPLAY_INTERN     With this function module you can analyze logs in local memory, e.g. when you have only collected log records at runtime and do not want to write to the database.
    APPL_LOG_INIT     This function module checks whether the specified object or sub-object exists and deletes all existing associated data in local memory.
    APPL_LOG_READ_DB     With this function module you read the log data in the database for an object or sub-object according to specified selection conditions.
    APPL_LOG_READ_INTERN     With this function module you read all log data whose log class has at least the specified value, from local memory, for the specified object or sub-object.
    APPL_LOG_SET_OBJECT     With this function module, you create a new object or sub-object for writing in local memory. With a flag you can control whether the APPL_LOG_WRITE_... messages are written in local memory or are output on the screen.
    APPL_LOG_WRITE_DB     With this function module you write all data for the specified object or sub-object in local memory to the database. If the log for the object or sub-object in question is new, the log number is returned to the calling program.
    APPL_LOG_WRITE_HEADER     With this function module, you write the log header data in local memory.
    APPL_LOG_WRITE_LOG_PARAMETERS     With this function module, you write the name of the log parameters and the associated values for the specified object or sub-object in local memory. If this function module is called repeatedly for the same object or sub-object, the existing parameters are updated accordingly. If you do not specify an object or sub-object with the call, the most recently used is assumed.
    APPL_LOG_WRITE_MESSAGE_PARAMS     With this function module you write a single message, with parameters, in local memory. Otherwise the function module works like APPL_LOG_WRITE_SINGLE_MESSAGE.
    APPL_LOG_WRITE_MESSAGES     With this function module you write one or more messages, without parameters, in local memory.
    APPL_LOG_WRITE_SINGLE_MESSAGE     With this function module you write a single message, without parameters, in local memory. If no header entry has yet been written for the object or sub-object, it is created. If you do not specify an object or sub-object with the call, the most recently used is assumed.
    ARFC_GET_TID     will return the IP address of the terminal in hex.
    BAL_CNTL_CREATE     Create Control for log display
    BAL_CNTL_FREE     Release Control
    BAL_CNTL_REFRESH     Put new data in log display
    BAL_DB_DELETE     Delete logs from the database
    BAL_DB_DEQUEUE     Unlock log
    BAL_DB_ENQUEUE     Lock log
    BAL_DB_LOAD     Load logs from the database
    BAL_DB_LOAD     Load log(s)
    BAL_DB_SAVE     Save logs in the database
    BAL_DB_SAVE     Save log(s)
    BAL_DB_SAVE_PREPARE     Prepare save
    BAL_DB_SEARCH     Find logs in the database
    BAL_DSP_LOG_DISPLAY     Display messages in memory
    BAL_DSP_LOG_DISPLAY     Display Log
    BAL_DSP_LOG_PARAMETERS     Either output extended long text or call a callback routine (based on the data in BAL_S_LOG-PARAMS)
    BAL_DSP_LOG_TECHNICAL_DATA     Output all log header data
    BAL_DSP_MSG_LONGTEXT     Display message long text
    BAL_DSP_MSG_PARAMETERS     Either output extended long text or call a callback routine (based on the data in BAL_S_MSG-PARAMS)
    BAL_DSP_MSG_TECHNICAL_DATA     Output technical data of a message such as work area, error number, etc.
    BAL_DSP_OUTPUT_FREE     End output
    BAL_DSP_OUTPUT_INIT     Initialize output
    BAL_DSP_OUTPUT_SET_DATA     Set dataset to be displayed
    BAL_DSP_PROFILE_DETLEVEL_GET     Message hierarchy in DETLEVEL
    BAL_DSP_PROFILE_NO_TREE_GET     Display without tree (fullscreen)
    BAL_DSP_PROFILE_POPUP_GET     Display without tree (popup)
    BAL_DSP_PROFILE_SINGLE_LOG_GET     Standard profile (SLG1) for one log
    BAL_DSP_PROFILE_STANDARD_GET     Standard profile (SLG1) for a lot of logs
    BAL_GLB_AUTHORIZATION_GET     Assign authorization
    BAL_GLB_AUTHORIZATION_RESET     Reset authorization
    BAL_GLB_CONFIG_GET     Read configuration
    BAL_GLB_CONFIG_SET     Set configuration
    BAL_GLB_MEMORY_EXPORT     Put function group memory in ABAP-MEMORY
    BAL_GLB_MEMORY_IMPORT     Get function group memory from ABAP-MEMORY
    BAL_GLB_MEMORY_REFRESH     (Partially) reset global memory
    BAL_GLB_MEMORY_REFRESH     (Partially) initialize memory
    BAL_GLB_MSG_CURRENT_HANDLE_GET     Get current message handle
    BAL_GLB_MSG_DEFAULTS_GET     Get message defaults
    BAL_GLB_SEARCH_LOG     Find logs in memory
    BAL_GLB_SEARCH_MSG     Find messages in memory
    BAL_LOG_CREATE     Create log with header data
    BAL_LOG_CREATE     Create log with header data
    BAL_LOG_DELETE     Delete log (from database also at Save)
    BAL_LOG_EXIST     Check existence of a log in memory
    BAL_LOG_HDR_CHANGE     Change log header
    BAL_LOG_HDR_CHECK     Check log header data for consistency
    BAL_LOG_HDR_READ     Read log header and other data
    BAL_LOG_MSG_ADD     Put message in log
    BAL_LOG_MSG_ADD     Put message in log
    BAL_LOG_MSG_CHANGE     Change message
    BAL_LOG_MSG_CHANGE     Change message
    BAL_LOG_MSG_CHECK     Check message data for consistency
    BAL_LOG_MSG_CUMULATE     Add message cumulated
    BAL_LOG_MSG_DELETE     Delete message
    BAL_LOG_MSG_DELETE     Delete message
    BAL_LOG_MSG_EXIST     Check existence of a message in memory
    BAL_LOG_MSG_READ     Read message and other data
    BAL_LOG_MSG_REPLACE     Replace last message
    BAL_LOG_REFRESH     Delete log from memory
    BAL_LOG_REFRESH     Delete log from memory
    BAL_MSG_DISPLAY_ABAP     Output message as ABAP-MESSAGE
    BAL_OBJECT_SELECT     Read Application Log objects table record
    BAL_OBJECT_SUBOBJECT     Check whether object and subobject exist and the combination is allowed
    BAL_SUBOBJECT_SELECT     Read subobject table record
    BP_EVENT_RAISE     Trigger an event from ABAP/4 program
    BP_JOBLOG_READ     Fetch job log executions
    CHANGEDOCUMENT_READ_HEADERS     Get the change document header for a sales document, and put the results in an internal table.
    Example:
          CALL FUNCTION 'CHANGEDOCUMENT_READ_HEADERS'
               EXPORTING
                    objectclass = 'EINKBELEG'
                    objectid    = l_objectid
                    username    = space
               TABLES
                    i_cdhdr     = lt_cdhdr.
          LOOP AT lt_cdhdr WHERE udate IN s_aedat.
            CALL FUNCTION 'CHANGEDOCUMENT_READ_POSITIONS'
                 EXPORTING
                      changenumber = lt_cdhdr-changenr
                 TABLES
                      editpos      = lt_editpos.
            LOOP AT lt_editpos WHERE fname = 'LOEKZ'
                               AND   f_new = 'L'.
              p_desc = text-r01. " Cancel Contract
            ENDLOOP.
          ENDLOOP.
    CHANGEDOCUMENT_READ_POSITIONS     Get the details of a change document, and store them in an internal table. This will tell you whether a field was changed, deleted, or updated.
    Example:
          CALL FUNCTION 'CHANGEDOCUMENT_READ_HEADERS'
               EXPORTING
                    objectclass = 'EINKBELEG'
                    objectid    = l_objectid
                    username    = space
               TABLES
                    i_cdhdr     = lt_cdhdr.
          LOOP AT lt_cdhdr WHERE udate IN s_aedat.
            CALL FUNCTION 'CHANGEDOCUMENT_READ_POSITIONS'
                 EXPORTING
                      changenumber = lt_cdhdr-changenr
                 TABLES
                      editpos      = lt_editpos.
            LOOP AT lt_editpos WHERE fname = 'LOEKZ'
                               AND   f_new = 'L'.
              p_desc = text-r01. " Cancel Contract
            ENDLOOP.
          ENDLOOP.
    CLAF_CLASSIFICATION_OF_OBJECTS     Return all of the characteristics for a material
    CLOI_PUT_SIGN_IN_FRONT     Move the negative sign from the left hand side of a number, to the right hand side of the number. Note that The result will be left justified (like all character fields), not right justified as numbers normally are.
    CLPB_EXPORT     Export a text table to the clipboard (on presentation server)
    CLPB_IMPORT     Import a Text Table from the Clipboard (on presentation server)
    COMMIT_TEXT     To load long text into SAP
    CONVERSION_EXIT_ALPHA_INPUT     converts any number into a string fill with zeroes, with the number at the extreme right
    Example:
    input  = 123
    output = 0000000000000...000000000000123
    CONVERSION_EXIT_ALPHA_OUTPUT     converts any number with zeroes right into a simple integer
    Example:
    input   = 00000000000123
    output  = 123
    CONVERT_ABAPSPOOLJOB_2_PDF     convert abap spool output to PDF
    CONVERT_OTF     Convert SAP documents (SAPScript) to other types.
    Example:
    CALL FUNCTION "CONVERT_OTF"
           EXPORTING    FORMAT                = "PDF"
           IMPORTING    BIN_FILESIZE          = FILE_LEN
           TABLES       OTF                   = OTFDATA
                        LINES                 = PDFDATA
           EXCEPTIONS   ERR_MAX_LINEWIDTH     = 1                  
                        ERR_FORMAT            = 2
                        ERR_CONV_NOT_POSSIBLE = 3
                        OTHERS                = 4.
    CONVERT_OTFSPOOLJOB_2_PDF     converts a OTF spool to PDF (i.e. Sapscript document)
    CONVERT_TO_FOREIGN_CURRENCY     Convert local currency to foreign currency.
    CONVERT_TO_LOCAL_CURRENCY     Convert from foreign currency to local currency
    DATE_CHECK_PLAUSIBILITY     Check to see if a date is in a valid format for SAP. Works well when validating dates being passed in from other systems.
    DATE_COMPUTE_DAY     Returns a number indicating what day of the week the date falls on. Monday is returned as a 1, Tuesday as 2, etc.
    DATE_GET_WEEK     will return the week that a date is in.
    DATE_IN_FUTURE     Calculate a date N days in the future.
    DAY_ATTRIBUTES_GET     Return useful information about a day. Will tell you the day of the week as a word (Tuesday), the day of the week (2 would be Tuesday), whether the day is a holiday, and more.(provided by Francois Henrotte)
    DOWNLOAD     download a file to the presentation server (PC)
    DYNP_VALUES_READ     Read the values from a dynpro. This function can be used to read the values from a report's selection screen too (Another example).
    DYNP_VALUES_UPDATE     Similar to DYNP_VALUES_READ, this function will allow the updating of fields on a dynpro. Very useful when you want to change a field based on the value entered for another field.
    ENQUE_SLEEP     Wait a specified period of time before continuing processing.
    ENQUEUE_ESFUNCTION     Lock an abap program so that it cannot be executed.
    Example:
    Set the parameters as follows:
      RELID = 'ZZ'
      SRTF2 = 0
      SRTF = (your report name)
    Please note that you should not use SY-REPID to pass your report name to the function. The value of SY-REPID will change as it is being passed to the function module, and will no longer hold the value of the calling report.
    EPS_GET_DIRECTORY_LISTING     return a list of filenames from a local or network drive
    EPS_GET_FILE_ATTRIBUTES     Pass in a filename and a path, and will return attributes for the file
    F4_DATE     displays a calendar in a popup window and allows user to choose a date, or it can be displayed read only.
    F4_IF_FIELD_VALUE_REQUEST     Use values from a DDIC table to provide a list of possible values. TABNAME and FIELDNAME are required fields, and when MULTIPLE_CHOICE is selected, more than one value can be returned.
    F4IF_INT_TABLE_VALUE_REQUEST     F4 help that returns the values selected in an internal table. Very handy when programming your very own F4 help for a field.
    Example:
    data:
        begin of t_values occurs 2,
          value like kna1-begru,
        end of t_values,
        t_return like ddshretval occurs 0 with header line.
      t_values = 'PAR*'.
      append t_values.
      t_values = 'UGG'.
      append t_values.
      call function 'F4IF_INT_TABLE_VALUE_REQUEST'
           exporting
                retfield        = 'BEGRU'
                value_org       = 'S'
           tables
                value_tab       = t_values
                return_tab      = t_return
           exceptions
                parameter_error = 1
                no_values_found = 2
                others          = 3.
      if sy-subrc = 0.
        read table t_return index 1.
        o_begru-low = t_return-fieldval.
        if o_begru-low = 'PAR*'.
          o_begru-option = 'CP'.
        else.
          o_begru-option = 'EQ'.
        endif.
        o_begru-sign = 'I'.
        append o_begru to s_begru.
      else.
        o_begru = i_begru.
      endif.
    F4IF_SHLP_EXIT_EXAMPLE     documents the different reasons to use a search help exit, and shows how it is done.
    F4IP_INT_TABLE_VALUE_REQUEST     This function does not exist in 4.6 and above. Use F4IF_INT_TABLE_VALUE_REQUEST instead.
    FILENAME_GET     popup to get a filename from a user, returns blank filename if user selects cancel
    FORMAT_MESSAGE     Takes a message id and number, and puts it into a variable. Works better than WRITE_MESSAGE, since some messages use $ as a place holder, and WRITE_MESSAGE does not accommodate that, it only replaces the ampersands (&) in the message.
    FTP_COMMAND     Execute a command on the FTP server
    FTP_CONNECT     Open a connection (and log in) to an FTP server
    FTP_DISCONNECT     Close the connection (and log off) the FTP server
    FU CSAP_MAT_BOM_READ     You can use this function module to display simple material BOMs. You cannot display BOM groups (for example, all variants of a variant BOM). as in transaction CS03. Current restrictions: You cannot display long texts. You cannot display sub-items. You cannot display classification data of BOM items for batches. You can only display one alternative or variant. You cannot enter an alternative for module CSAP_MAT_BOM_READ, so you always see alternative 01. The following example came from a posting on the SAP-R3-L mailing list.
    Example:
    data: begin of tstk2 occurs 0.
              include structure stko_api02.
    data: end of tstk2.
    data: begin of tstp2 occurs 0.
              include structure stpo_api02.
    data: end of tstp2.
    data: begin of tdep_data occurs 0.
             include structure csdep_data.
    data: end of tdep_data.
    data: begin of tdep_descr occurs 0.
             include structure csdep_descr.
    data: end of tdep_descr.
    data: begin of tdep_source occurs 0.
             include structure csdep_source.
    data: end of tdep_source.
    data: begin of tdep_order occurs 0.
             include structure csdep_order.
    data: end of tdep_order.
    data: begin of tdep_doc occurs 0.
             include structure csdep_doc.
    data: end of tdep_doc.
    data: flg_warning like capiflag-flwarning.
       call function 'CSAP_MAT_BOM_READ'
            exporting
                 material   = 'MAT100'
                 plant      = '0001'
                 bom_usage  = '1'
                 valid_from = '20.12.1996'
               valid_to
            importing
                 fl_warning = flg_warning
            tables
                 t_stko       = tstk2
                 t_stpo       = tstp2
                 t_dep_data   = tdep_data
                 t_dep_descr  = tdep_descr
                 t_dep_source = tdep_source
                 t_dep_order  = tdep_order
                 t_dep_doc    = tdep_doc
            exceptions
                 error      = 1.
    Function Group GRAP is now obsolete.     SAP recommends using functions in function group SFES instead. Below is an overview of the changes.
    G_SET_GET_ALL_VALUES     Fetch values from a set.
    GET_CURRENT_YEAR     Get the current fiscal year.
    Example:
    CALL FUNCTION 'GET_CURRENT_YEAR'
      EXPORTING
        BUKRS         = '1000'     " Company Code
        DATE          = SY-DATUM   " Date to find fiscal year for
      IMPORTING
        CURRM         = w_currm    " Current Fiscal Month
        CURRY         = w_curry    " Current Fiscal Year
        PREVM         = w_prevm    " Previous Fiscal Month
        PREVY         = w_prevy.   " Previous Fiscal Year
    GET_GLOBAL_SYMBOLS     Returns a list of all tables, select options, texts, etc for a program. Even includes the text definitions for the selection screen
    GET_INCLUDETAB     Returns a list of all INCLUDES in a program
    GET_JOB_RUNTIME_INFO     Get the current job number from a program. Also returns other useful info about the current job.
    GUI_CREATE_DIRECTORY     Create a directory on the presentation server
    GUI_DELETE_FILE     Replaces WS_FILE_DELETE. Delete a file on the presentation server
    GUI_DOWNLOAD     Replaces WS_DOWNLOAD. Download table from the app server to presentation server
    GUI_EXEC     Replaces WS_EXECUTE. Start a File or Program Asynchronously with WinExec
    GUI_GET_DESKTOP_INFO     Replaces WS_QUERY. Delivers Information About the Desktop (client)
    GUI_REMOVE_DIRECTORY     Delete a directory on the presentation server
    GUI_RUN     Start a File or Program Asynchronously with Shell Execute
    GUI_UPLOAD     Replaces WS_UPLOAD. Upload file from presentation server to the app server
    HELP_START     Display help for a field. Useful for doing AT SELECTION SCREEN ON VALUE REQUEST for those fields that do not provide F4 help at the DDIC level.
    HELP_VALUES_GET_WITH_TABLE     Show a list of possible values for F4 popup help on selection screens. This function module pops up a screen that is just like all the other F4 helps, so it looks like the rest of the SAP system. Very useful for providing dropdowns on fields that do not have them predefined.
    Example:
    tables: t001w.
    DATA: lc_werks      LIKE t001w-werks,
          ltab_fields LIKE help_value OCCURS 0 with header line,
          BEGIN OF ltab_values OCCURS 0,
            feld(40) TYPE c,
          END OF ltab_values.
    *-- Set up fields to retrieve data
      ltab_fields-tabname    = 'T001W'.
      ltab_fields-fieldname  = 'WERKS'.
      ltab_fields-selectflag = 'X'.
      APPEND ltab_fields.
      ltab_fields-tabname    = 'T001W'.
      ltab_fields-fieldname  = 'NAME1'.
      ltab_fields-selectflag = space.
      APPEND ltab_fields.
    *-- Fill values
      select * from t001w.
        ltab_values-feld = t001w-werks.
        append ltab_values.
        ltab_values-feld = t001w-name1.
        append ltab_values.
      endselect.
    CALL FUNCTION 'HELP_VALUES_GET_WITH_TABLE'
         EXPORTING
              fieldname                 = 'WERKS'
              tabname                   = 'T001W'
              title_in_values_list      = 'Select a value'
         IMPORTING
              select_value              = lc_werks
         TABLES
              fields                    = ltab_fields
              valuetab                  = ltab_values
         EXCEPTIONS
              field_not_in_ddic         = 01
              more_then_one_selectfield = 02
              no_selectfield            = 03.
    HOLIDAY_CHECK_AND_GET_INFO     Useful for determining whether or not a date is a holiday. Give the function a date, and a holiday calendar, and you can determine if the date is a holiday by checking the parameter HOLIDAY_FOUND.
    Example:
    data: ld_date                 like scal-datum  default sy-datum,
          lc_holiday_cal_id       like scal-hcalid default 'CA',
          ltab_holiday_attributes like thol occurs 0 with header line,
          lc_holiday_found        like scal-indicator.
    CALL FUNCTION 'HOLIDAY_CHECK_AND_GET_INFO'
      EXPORTING
        date                               = ld_date
        holiday_calendar_id                = lc_holiday_cal_id
        WITH_HOLIDAY_ATTRIBUTES            = 'X'
      IMPORTING
        HOLIDAY_FOUND                      = lc_holiday_found
      tables
        holiday_attributes                 = ltab_holiday_attributes
      EXCEPTIONS
        CALENDAR_BUFFER_NOT_LOADABLE       = 1
        DATE_AFTER_RANGE                   = 2
        DATE_BEFORE_RANGE                  = 3
        DATE_INVALID                       = 4
        HOLIDAY_CALENDAR_ID_MISSING        = 5
        HOLIDAY_CALENDAR_NOT_FOUND         = 6
        OTHERS                             = 7.
    if sy-subrc = 0 and
       lc_holiday_found = 'X'.
      write: / ld_date, 'is a holiday'.
    else.
      write: / ld_date, 'is not a holiday, or there was an error calling the function'.
    endif.
    HOLIDAY_GET     Provides a table of all the holidays based upon a Factory Calendar &/ Holiday Calendar.
    HR_DISPLAY_BASIC_LIST     is an HR function, but can be used for any data. You pass it data, and column headers, and it provides a table control with the ability to manipulate the data, and send it to Word or Excel. Also see the additional documentation here.
    HR_GET_LEAVE_DATA     Get all leave information (includes leave entitlement, used holidays/paid out holidays)
    HR_IE_NUM_PRSI_WEEKS     Return the number of weeks between two dates.
    HR_PAYROLL_PERIODS_GET     Get the payroll period for a particular date. (provided by Francois Henrotte)
    Example:
      DATA: IT_T549Q TYPE T549Q OCCURS 0 WITH HEADER LINE,
            IT_ZL TYPE PC2BF OCCURS 0 WITH HEADER LINE.
      W_BEGDA = '20010101'.
      W_PERNR = '00000001'.
      CALL FUNCTION 'HR_PAYROLL_PERIODS_GET'
           EXPORTING
                get_begda       = w_begda
           TABLES
                get_periods     = it_t549q
           EXCEPTIONS
                no_period_found = 1
                no_valid_permo  = 2.
      CHECK sy-subrc = 0.
      CALL FUNCTION 'HR_TIME_RESULTS_GET'
           EXPORTING
                get_pernr             = w_pernr
                get_pabrj             = it_t549q-pabrj
                get_pabrp             = it_t549q-pabrp
           TABLES
                get_zl                = it_zl
           EXCEPTIONS
                no_period_specified   = 1
                wrong_cluster_version = 2
                no_read_authority     = 3
                cluster_archived      = 4
                technical_error       = 5.
    NOTE: it_zl-iftyp = 'A'   absence
          it_zl-iftyp = 'S'   at work
    HR_TIME_RESULTS_GET     Get the time results for a payroll period. (provided by Francois Henrotte)
    Example:
      DATA: IT_T549Q TYPE T549Q OCCURS 0 WITH HEADER LINE,
            IT_ZL TYPE PC2BF OCCURS 0 WITH HEADER LINE.
      W_BEGDA = '20010101'.
      W_PERNR = '00000001'.
      CALL FUNCTION 'HR_PAYROLL_PERIODS_GET'
           EXPORTING
                get_begda       = w_begda
           TABLES
                get_periods     = it_t549q
           EXCEPTIONS
                no_period_found = 1
                no_valid_permo  = 2.
      CHECK sy-subrc = 0.
      CALL FUNCTION 'HR_TIME_RESULTS_GET'
           EXPORTING
                get_pernr             = w_pernr
                get_pabrj             = it_t549q-pabrj
                get_pabrp             = it_t549q-pabrp
           TABLES
                get_zl                = it_zl
           EXCEPTIONS
                no_period_specified   = 1
                wrong_cluster_version = 2
                no_read_authority     = 3
                cluster_archived      = 4
                technical_error       = 5.
    NOTE: it_zl-iftyp = 'A'   absence
          it_zl-iftyp = 'S'   at work
    INIT_TEXT     To load long text into SAP
    K_WERKS_OF_BUKRS_FIND     Return a list of all plants for a given company code.
    LIST_FROM_MEMORY     Retrieves the output of a report from memory when the report was executed using SUBMIT... EXPORTING LIST TO MEMORY. See also WRITE_LIST.
    LIST_TO_ASCII     convert an ABAP report (displayed on screen) from OTF to ASCII format
    MBEW_EXTEND     Get the stock position for the previous month. This displays the same info that you see in MM03.
    MONTH_NAMES_GET     It returns all the month and names in respective language.
    MONTH_PLUS_DETERMINE     Add or subtract months from a date. To subtract a month, enter a negative value for the 'months' parameter.
    Example:
    data: new_date type d.
    CALL FUNCTION 'MONTH_PLUS_DETERMINE'
      EXPORTING
        months        = -5       " Negative to subtract from old date, positive to add
        olddate       = sy-datum
    IMPORTING
       NEWDATE       = new_date.
    write: / new_date.
    MS_EXCEL_OLE_STANDARD_OLE     will build a file, and automatically start Excel
    OTF_CONVERT     wraps several other function modules. Will convert OTF to ASCII or PDF
    POPUP_TO_CONFIRM_LOSS_OF_DATA     Create a dialog box in which you make a question whether the user wishes to perform a processing step with loss of data.
    POPUP_TO_CONFIRM_STEP     Create a dialog box in which you make a question whether the user wishes to perform the step.
    POPUP_TO_CONFIRM_WITH_MESSAGE     Create a dialog box in which you inform the user about a specific decision point during an action.
    POPUP_TO_CONFIRM_WITH_VALUE     Create a dialog box in which you make a question whether the user wishes to perform a processing step with a particular object.
    POPUP_TO_DECIDE     Provide user with several choices as radio buttons
    POPUP_TO_DECIDE_WITH_MESSAGE     Create a dialog box in which you inform the user about a specific decision point via a diagnosis text.
    POPUP_TO_DISPLAY_TEXT     Create a dialog box in which you display a two line message
    POPUP_TO_SELECT_MONTH     Popup to choose a month
    POPUP_WITH_TABLE_DISPLAY     Provide a display of a table for user to select one, with the value of the table line returned when selected.
    PRICING     Return pricing conditions in an internal table. Use structure TCOMK for parameter COMM_HEAD_1, and structure TCOMP for parameter COMM_ITEM_1, and set CALCULATION_TYPE to B. The pricing conditions will be returned in XOMV. You must fill TCOMP, and TCOMK with the appropriate values before callling the function in order for it to work.
    PROFILE_GET     Read an Entry in an INI File on the frontend
    PROFILE_SET     Write an Entry in an INI File on the frontend
    READ_TEXT     To load long text into SAP
    REGISTRY_GET     Read an Entry from the Registry
    REGISTRY_SET     Set an entry in the Registry
    RFC_ABAP_INSTALL_AND_RUN     Runs an ABAP program that is stored in the table PROGRAM when the MODE = 'F'. Table WRITES contains the ouput of the program. Allows you to run a program without having the source code in the target system.
    RH_GET_ACTIVE_WF_PLVAR     Return the active HR Plan
    RH_GET_DATE_DAYNAME     return the day based on the date provied
    RH_START_EXCEL_WITH_DATA     starts Excel with the contents of an internal table. This function finds Excel in the desktop registry. It also uses a local PC working directory to save the file (that's what the 'W' value for data path flag does). Very transparent to user!
    RH_STRUC_GET     Returns all related org info
    RHP0_POPUP_F4_SEARK     is a matchcode for any type of HR Planning object, including the possibility to fill the field that you want
    Example:
    Examples: search for any organizational structure
               F4 = 'X'
               PLVAR = '01'
               OTYPE = 'O '
              search for any persons
               F4 = 'X'
               PLVAR = '01'
               OTYPE = 'P '
               MULTI_SELECT = 'X' to allow multiple selection
               EASY = 'X' for user-dependent matchcode
    Unfortunately, the use of table BASE_OBJIDS is disabled, so you can't specify
    a root for the hierarchy you display
    RKD_WORD_WRAP     Convert a long string or phrase into several lines.
    RP_CALC_DATE_IN_INTERVAL     Add/subtract years/months/days from a date
    RP_LAST_DAY_OF_MONTHS     Determine last day of month
    RPY_DYNPRO_READ     Read dynpro, including screen flow
    RPY_TRANSACTION_READ     Given a transaction, return the program and screen or given a program and screen, return the transactions that use the program and screen.
    RS_COVERPAGE_SELECTIONS     Returns an internal table that contains a formatted list of all the selection parameters entered for a report. Table is ready to print out.
    RS_REFRESH_FROM_SELECTOPTIONS     Get the current contents of selection screen
    RS_SEND_MAIL_FOR_SPOOLLIST     Send message from ABAP/4 program to SAPoffice.
    RS_VARIANT_CONTENTS     Returns the contents of the specified variant in a table.
    RSPO_DOWNLOAD_SPOOLJOB     Download the spool from a program to a file. Requires spool number.
    RSPO_RETURN_ABAP_SPOOLJOB     Fetch printer spool according to the spool number informed.
    RZL_READ_DIR     If the server name is left blank, it reads a directory from local presentation server, otherwise it reads the directory of the remote server
    RZL_READ_DIR_LOCAL     Read a directory on the Application Server
    RZL_READ_FILE     Read a file from the presentation server if no server name is given, or read file from remote server. Very useful to avoid authority checks that occur doing an OPEN DATASET. This function using a SAP C program to read the data.
    RZL_SLEEP     Hang the current application from 1 to 5 seconds.
    RZL_SUBMIT     Submit a remote report.
    RZL_WRITE_FILE_LOCAL     Saves table to the presentation server (not PC). Does not use OPEN DATASET, so it does not suffer from authority checks!
    SAP_CONVERT_TO_XLS_FORMAT     Convert data to Microsoft Excel format.
    SAPGUI_PROGRESS_INDICATOR     Display a progress bar on the SAP GUI, and give the user some idea of what is happening
    SAVE_TEXT     To load long text into SAP
    SCROLLING_IN_TABLE     If you are coding a module pool and using a table control, you can use this function SCROLLING_IN_TABLE to handle any scrolling. (provided by Paul Kjaer)
    SD_DATETIME_DIFFERENCE     Give the difference in Days and Time for 2 dates
    SO_NEW_DOCUMENT_ATT_SEND_API1     Send a document as part of an email. The documentation is better than normal for this function, so please read it.
    SO_SPLIT_FILE_AND_PATH     Split a fully pathed filename into a filename and a path.
    SO_SPOOL_READ     Fetch printer spool according to the spool number informed. See also RSPO_RETURN_ABAP_SPOOLJOB
    SO_WIND_SPOOL_LIST     Browse printer spool numbers according to user informed.
    SWD_HELP_F4_ORG_OBJECTS     HR Matchcode tailored for organizational units. Includes a button so that you can browse the hierarchy too.
    SX_OBJECT_CONVERT_OTF_PDF     Conversion From OTF to PDF (SAPScript conversion)
    SX_OBJECT_CONVERT_OTF_PRT     Conversion From OTF to Printer Format (SAPScript conversion)
    SX_OBJECT_CONVERT_OTF_RAW     Conversion From OTF to ASCII (SAPScript conversion)
    SXPG_CALL_SYSTEM     you can check the user's authorization for the specified command and run the command. The command runs on the host system on which the function module is executed. The function module is RFC capable. It can therefore be run on the host system at which a user happens to be active or on another designated host system at which an R/3 server is active.
    SXPG_COMMAND_CHECK     Check whether the user is authorized to execute the specified command on the target host system with the specified arguments.
    SXPG_COMMAND_DEFINITION_GET     Read the definition of a single external OS command from the R/3 System's database.
    SXPG_COMMAND_EXECUTE     Check a user's authorization to use a command, as in SXPG_COMMAND_CHECK. If the authorization check is successful, then execute the command on the target host system.
    SXPG_COMMAND_LIST_GET     Select a list of external OS command definitions.
    TERMINAL_ID_GET     Return the terminal id
    TH_DELETE_USER     Logoff a user. Similar results to using SM04.
    TH_ENVIRONMENT     Get the UNIX environment
    TH_POPUP     Display a popup system message on a specific users screen.
    TH_REMOTE_TRANSACTION     Run a transaction on a remote server. Optionally provide BDC data to be used in the transaction
    TH_USER_INFO     Give information about the current user (sessions, workstation logged in from, etc)
    TH_USER_LIST     Show which users are logged into an app server
    TMP_GUI_DIRECTORY_LIST_FILES     Retrieve all of the files and subdirectories on the Presentation Server (PC) for a given directory.
    When a value other than * or . is used for the filter, you will not get any directories, unless they match your wildcard filter. For example, if you entered *.png, then only files and directories that end in png will be returned by the function.
    Example:
    data:  lc_directory         like bdschko16-target_dir value 'C:\TEMP\',
           lc_filter(20)        type c default '.'.
           li_file_count        type i,
           li_dir_count         type i,
           ltab_dir_table       like sdokpath occurs 0 with header line,
           ltab_file_file_table like sdokpath occurs 0 with header line.
    call function 'TMP_GUI_DIRECTORY_LIST_FILES'
      exporting
        directory        = lc_directory
        filter           = lc_filter  importing
        file_count       = li_file_count
        dir_count        = li_dir_count
      tables
        file_table       = ltab_file_table
        dir_table        = ltab_dir_table
      exceptions
        cntl_error       = 1
        others           = 2.
    UNIT_CONVERSION_SIMPLE     convert weights from one UOM to another.
    UPLOAD     upload a file to the presentation server (PC)
    UPLOAD_FILES     Will load one or more files from app or presentation server
    WEEK_GET_FIRST_DAY     For a given week (YYYYMM format), this function returns the date of the Monday of that week.
    WRITE_LIST     Useful for writing out the list contents that result from the function LIST_FROM_MEMORY.
    WS_DOWNLOAD     Save Internal Table as File on the Presentation Server
    WS_EXCEL     Start EXCEL on the PC
    WS_EXECUTE     execute a program on a windows PC
    WS_FILE_DELETE     Delete File at the Frontend
    WS_FILENAME_GET     Call File Selector
    WS_MSG     Create a dialog box in which you display an one line message
    WS_UPLOAD     Load Files from the Presentation Server to Internal ABAP Tables
    WS_VOLUME_GET     Get the label from a frontend device.
    WWW_LIST_TO_HTML     After running a report, call this function to convert the list output to HTML.
    I don't think there is any function module for ALV.
    Even for more info Checkout the links
    http://www.erpgenie.com/abap/functions.htm
    http://www.sapdevelopment.co.uk/fmodules/fmssap.htm
    http://www.erpgenie.com/abap/index.htm
    http://www.geocities.com/victorav15/sapr3/abapfun.html
    Regards,
    Chandru

  • XI-- IDOC scenario, how to link process code with function module

    Hi Forum,
    I have a XI--->IDOC (R/3) scenario,
    where i m creating a IDOC in XI and sending it to R/3,
    i have done all settings to send the IDOC from XI to the R/3,
    i also have the function module to process that IDOC in R/3,
    the problem is:
    I want to know in details (step by step) how to make a Idoc Inbound process code, link it with the function module and use the process code in the Partner Profile in R/3,
    pls help

    HI,
    FOr this u need to go to transaction WE41 for inbound and WE40 for outbound there u assign the function module.
    Now u go to WE20 transaction for partner profile and u can assign the proces code to the inbound message.
    Go to the below help for more information:
    http://help.sap.com/saphelp_nw04/helpdata/en/72/c18ee5546a11d182cc0000e829fbfe/frameset.htm
    Inbound process code:
    http://help.sap.com/saphelp_nw04/helpdata/en/72/c18ee5546a11d182cc0000e829fbfe/frameset.htm
    Thnx
    Chirag

  • Help code for function module

    Hi Gurus,
    I have to connect two table through function module in ECC side.
    Both table contains some field.
    I am not much familiar with ABAP.
    So PLease  give some demo coding for this.
    Coding  to connect two tables by function module.
    Thanks.
    Saurabh Jain

    Hi,
    Please find the sample code.Here I am extracting data from three tables.
    SELECT         
                   a~vbeln
                 a~MATNR
                 a~CHARG                 
                 a~POSNR              
                 a~SPART                
                 a~ERDAT              
                 a~AEDAT              
                 a~KWMENG
                 a~PSTYV
                 c~KUNNR
                 c~VKGRP
                 c~VKBUR
                 c~VTWEG
                 c~VKORG
                 c~BUKRS
                 c~VKGRP  
                 FROM((VBAP AS a INNER JOIN VBPA AS b
                            ON avbeln  = bvbeln
                           AND aposnr  = bposnr)INNER JOIN VBAK AS c ON cvbeln = bvbeln
                                                                       AND cposnr = bposnr).
    Modify in the way you want and Just include these codes into the Funtion module you create.
    I Hope it my help you.
    Regards,
    Prem

  • How to edit ALV report using function modules

    I have a ALV report , i want to edit the report
    using function modules.
    how can i do that...
    Edited by: ms kumar on Mar 6, 2008 3:24 PM

    hi i had used this report with the check box,
    using the fm of alvs.....
    *& Report  ZZZ00
    REPORT  ZPR_02.
    TYPE-POOLS: SLIS.
    TABLES:pa0002,pa0008.
    data:begin of it_pa0002 occurs 0,
         checkbox,
         pernr like pa0002-pernr,
         begda like pa0002-begda,
         endda like pa0002-endda,
         vorna like pa0002-vorna,
         nachn like pa0002-nachn,
         end of it_pa0002.
    data:begin of it_pa00021 occurs 0,
         pernr like pa0002-pernr,
         begda like pa0002-begda,
         endda like pa0002-endda,
         vorna like pa0002-vorna,
         nachn like pa0002-nachn,
         expand TYPE xfeld value 'X',
         end of it_pa00021.
    data:begin of it_pa0008 occurs 0,
         pernr like pa0008-pernr,
         begda like pa0008-begda,
         endda like pa0008-endda,
         ANSAL like pa0008-ANSAL,
         LGA01 like pa0008-LGA01,
         BET01 LIKE PA0008-BET01,
         end of it_pa0008.
    DATA: IT_FIELD_CAT TYPE SLIS_T_FIELDCAT_ALV,
          IT_FIELD_CAT1 TYPE SLIS_T_FIELDCAT_ALV,
          IT_LAYOUT1 TYPE SLIS_LAYOUT_ALV,
          WA_FIELD_CAT TYPE SLIS_FIELDCAT_ALV,
          WA_FIELD_CAT1 TYPE SLIS_FIELDCAT_ALV,
          IT_LAYOUT TYPE SLIS_LAYOUT_ALV,
          IT_EVENTS TYPE SLIS_T_EVENT,
          WA_EVENTS TYPE SLIS_ALV_EVENT,
          IT_HEADER TYPE SLIS_T_LISTHEADER,
          WA_HEADER TYPE SLIS_LISTHEADER,
          wa_keyinfo TYPE slis_keyinfo_alv.
    CONSTANTS:c VALUE 'X'.
    SELECT-OPTIONS: S_pernr FOR pa0002-pernr.
    START-OF-SELECTION.
      SET PF-STATUS 'DATA' .
      PERFORM GET_DATA.
      PERFORM BUILD_FIELD_CAT.
      PERFORM GET_EVENTS.
      PERFORM DISPLAY_DATA.
    *&      Form  get_data
          text
    FORM GET_DATA .
      SELECT pernr
             begda
             endda
             vorna
             nachn
             FROM pa0002
             INTO CORRESPONDING FIELDS OF TABLE IT_pa0002
             WHERE pernr IN S_pernr.
    ENDFORM.                    " get_data
    *&      Form  build_field_cat
          text
    FORM BUILD_FIELD_CAT .
        wa_field_cat-tabname = 'PA0002'.
      WA_FIELD_CAT-FIELDNAME = 'CHECKBOX'.
      wa_field_cat-ref_tabname = 'IT_PA0002'.
      WA_FIELD_CAT-REPTEXT_DDIC = 'Check Box'.
      APPEND WA_FIELD_CAT TO IT_FIELD_CAT.
      CLEAR WA_FIELD_CAT.
        wa_field_cat-tabname = 'PA0002'.
      WA_FIELD_CAT-FIELDNAME = 'PERNR'.
        wa_field_cat-ref_tabname = 'IT_PA0002'.
      WA_FIELD_CAT-REPTEXT_DDIC = 'Personnel no'.
      APPEND WA_FIELD_CAT TO IT_FIELD_CAT.
      CLEAR WA_FIELD_CAT.
        wa_field_cat-tabname = 'PA0002'.
      WA_FIELD_CAT-FIELDNAME = 'BEGDA'.
      wa_field_cat-ref_tabname = 'IT_PA0002'.
      WA_FIELD_CAT-REPTEXT_DDIC = 'Start date'.
      APPEND WA_FIELD_CAT TO IT_FIELD_CAT.
      CLEAR WA_FIELD_CAT.
        wa_field_cat-tabname = 'PA0002'.
      WA_FIELD_CAT-FIELDNAME = 'ENDDA'.
      wa_field_cat-ref_tabname = 'IT_PA0002'.
      WA_FIELD_CAT-REPTEXT_DDIC = 'End date'.
      APPEND WA_FIELD_CAT TO IT_FIELD_CAT.
      CLEAR WA_FIELD_CAT.
        wa_field_cat-tabname = 'PA0002'.
      WA_FIELD_CAT-FIELDNAME = 'VORNA'.
      wa_field_cat-ref_tabname = 'IT_PA0002'.
      WA_FIELD_CAT-REPTEXT_DDIC = 'First name'.
      APPEND WA_FIELD_CAT TO IT_FIELD_CAT.
      CLEAR WA_FIELD_CAT.
        wa_field_cat-tabname = 'PA0002'.
      WA_FIELD_CAT-FIELDNAME = 'NACHN'.
        wa_field_cat-ref_tabname = 'IT_PA0002'.
      WA_FIELD_CAT-REPTEXT_DDIC = 'Last name'.
      APPEND WA_FIELD_CAT TO IT_FIELD_CAT.
      CLEAR WA_FIELD_CAT.
        wa_field_cat1-tabname = 'PA0002'.
      WA_FIELD_CAT1-FIELDNAME = 'PERNR'.
        wa_field_cat1-ref_tabname = 'IT_PA00021'.
      WA_FIELD_CAT1-REPTEXT_DDIC = 'Personnel no'.
      APPEND WA_FIELD_CAT1 TO IT_FIELD_CAT1.
      CLEAR WA_FIELD_CAT1.
        wa_field_cat1-tabname = 'PA0002'.
      WA_FIELD_CAT1-FIELDNAME = 'BEGDA'.
        wa_field_cat1-ref_tabname = 'IT_PA00021'.
      WA_FIELD_CAT1-REPTEXT_DDIC = 'Start date'.
      APPEND WA_FIELD_CAT1 TO IT_FIELD_CAT1.
      CLEAR WA_FIELD_CAT1.
        wa_field_cat1-tabname = 'PA0002'.
      WA_FIELD_CAT1-FIELDNAME = 'ENDDA'.
        wa_field_cat1-ref_tabname = 'IT_PA00021'.
      WA_FIELD_CAT1-REPTEXT_DDIC = 'End date'.
      APPEND WA_FIELD_CAT1 TO IT_FIELD_CAT1.
      CLEAR WA_FIELD_CAT1.
        wa_field_cat1-tabname = 'PA0002'.
      WA_FIELD_CAT1-FIELDNAME = 'VORNA'.
        wa_field_cat1-ref_tabname = 'IT_PA00021'.
      WA_FIELD_CAT1-REPTEXT_DDIC = 'First name'.
      APPEND WA_FIELD_CAT1 TO IT_FIELD_CAT1.
      CLEAR WA_FIELD_CAT.
        wa_field_cat1-tabname = 'PA0002'.
      WA_FIELD_CAT1-FIELDNAME = 'NACHN'.
        wa_field_cat1-ref_tabname = 'IT_PA00021'.
      WA_FIELD_CAT1-REPTEXT_DDIC = 'Last name'.
      APPEND WA_FIELD_CAT1 TO IT_FIELD_CAT1.
      CLEAR WA_FIELD_CAT1.
        wa_field_cat1-tabname = 'PA0008'.
        wa_field_cat1-fieldname = 'PERNR'.
          wa_field_cat-ref_tabname = 'IT_PA0008'.
        wa_field_cat1-REPTEXT_DDIC = 'personnelno'.
        APPEND wa_field_cat1 TO it_field_cat1.
       CLEAR WA_FIELD_CAT1.
        wa_field_cat1-tabname = 'PA0008'.
        wa_field_cat1-fieldname = 'BEGDA'.
          wa_field_cat-ref_tabname = 'IT_PA0008'.
        wa_field_cat1-REPTEXT_DDIC = 'begindate'.
        APPEND wa_field_cat1 TO it_field_cat1.
        CLEAR WA_FIELD_CAT1.
        wa_field_cat1-tabname = 'PA0008'.
        wa_field_cat1-fieldname = 'ENDDA'.
          wa_field_cat-ref_tabname = 'IT_PA0008'.
        wa_field_cat1-REPTEXT_DDIC = 'enddate'.
        APPEND wa_field_cat1 TO it_field_cat1.
        CLEAR WA_FIELD_CAT1.
        wa_field_cat1-tabname = 'PA0008'.
        wa_field_cat1-fieldname = 'ANSAL'.
          wa_field_cat-ref_tabname = 'IT_PA0008'.
        wa_field_cat1-REPTEXT_DDIC = 'annualsalary'.
        APPEND wa_field_cat1 TO it_field_cat1.
        CLEAR WA_FIELD_CAT1.
        wa_field_cat1-tabname = 'PA0008'.
        wa_field_cat1-fieldname = 'LGA01'.
          wa_field_cat-ref_tabname = 'IT_PA0008'.
        wa_field_cat1-REPTEXT_DDIC = 'wagetype'.
        APPEND wa_field_cat1 TO it_field_cat1.
        CLEAR WA_FIELD_CAT1.
        wa_field_cat1-tabname = 'PA0008'.
        wa_field_cat1-fieldname = 'BET01'.
          wa_field_cat-ref_tabname = 'IT_PA0008'.
        wa_field_cat1-REPTEXT_DDIC = 'Amount'.
        APPEND wa_field_cat1 TO it_field_cat1.
        CLEAR WA_FIELD_CAT1.
    ENDFORM.                    " build_field_cat
    *&      Form  display_data
          text
    FORM DISPLAY_DATA .
    it_layout-box_fieldname = 'CHECKBOX'.
    it_layout-EDIT = 'X'.
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
        EXPORTING
          I_CALLBACK_PROGRAM             = SY-REPID
          I_CALLBACK_PF_STATUS_SET       = 'PF_STATUS'
          I_CALLBACK_USER_COMMAND        = 'USER_COMMAND'
          IT_FIELDCAT                    = IT_FIELD_CAT
          IS_LAYOUT                      = IT_LAYOUT
          IT_EVENTS                      = IT_EVENTS
        TABLES
          T_OUTTAB           = IT_pa0002.
    ENDFORM.                    " display_data
    *&      Form  get_events
          text
    FORM GET_EVENTS .
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
       IMPORTING
         ET_EVENTS             = IT_EVENTS .
      READ TABLE IT_EVENTS INTO WA_EVENTS
                           WITH KEY NAME = SLIS_EV_TOP_OF_PAGE.
      IF SY-SUBRC = 0.
        WA_EVENTS-FORM = 'TOP_OF_PAGE'.
        MODIFY IT_EVENTS FROM WA_EVENTS INDEX SY-TABIX.
      ENDIF.
    ENDFORM.                    " get_events
    *&      Form  top_of_page
          text
    FORM TOP_OF_PAGE.
      WA_HEADER-TYP = 'H'.
      WA_HEADER-INFO = 'EMPLOYEE DATA'.
      APPEND WA_HEADER TO IT_HEADER.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          IT_LIST_COMMENTARY       = IT_HEADER
    ENDFORM. "top_of_page
    *&      Form  GUI_SET
    FORM GUI_SET USING RT_EXTAB TYPE SLIS_T_EXTAB .
      SET PF-STATUS 'DATA' .
    ENDFORM.                    "GUI_SET
    *&      Form  USER_COMMAND
    FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
                            R_SELFIELD TYPE SLIS_SELFIELD.
    DATA:V_PERNR LIKE PA0002-PERNR.
      CASE R_UCOMM.
        WHEN 'DET'.
    DATA: V_FLAG.
      clear : v_flag.
    LOOP AT IT_PA0002.
         if it_PA0002-checkbox =  'X'.
                   v_flag = 'X'.
              v_pernr = IT_PA0002-PERNR.
    SELECT  PERNR
            BEGDA
            ENDDA
            VORNA
            NACHN
            FROM PA0002
            INTO CORRESPONDING FIELDS OF TABLE IT_PA00021
            WHERE PERNR = V_PERNR.
    SORT IT_PA00021 BY PERNR.
    DELETE ADJACENT DUPLICATES FROM IT_PA00021 COMPARING PERNR.
    READ TABLE IT_PA00021 INDEX 1.
    SELECT PERNR
           BEGDA
           ENDDA
           ANSAL
           LGA01
           BET01
           FROM PA0008
           INTO TABLE IT_PA0008
           FOR ALL ENTRIES IN IT_PA00021
           WHERE PERNR = IT_PA00021-PERNR.
              if not it_PA0008[] Is initial.
              SORT IT_PA0008 BY PERNR.
             delete adjacent duplicates from  it_PA0008 comparing pernr.
              READ TABLE IT_PA0008 INDEX 1.
              endif.
            endif.
         enddo.
      it_layout1-group_change_edit = c.
      it_layout1-colwidth_optimize = c.
      it_layout1-zebra             = c.
      it_layout1-detail_popup      = c.
      it_layout1-get_selinfos      = c.
      it_layout-expand_fieldname  = 'EXPAND'.
      wa_keyinfo-header01 = 'PERNR'.
      wa_keyinfo-item01 = 'PERNR'.
    IF NOT V_FLAG IS INITIAL.
    CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
      EXPORTING
       I_CALLBACK_PROGRAM             = SY-REPID
        IS_LAYOUT                      = IT_LAYOUT1
       IT_FIELDCAT                    =  IT_FIELD_CAT1
        I_TABNAME_HEADER               = 'PA0002'
        I_TABNAME_ITEM                 = 'PA0008'
        IS_KEYINFO                     = wa_keyinfo
        TABLES
        T_OUTTAB_HEADER                = IT_PA00021
        T_OUTTAB_ITEM                  = IT_PA0008.
    ENDIF.
    CLEAR: IT_PA00021,IT_PA0002,IT_PA0008.
    ENDLOOP.
    WHEN 'BACK'.
    EXIT.
    ENDCASE.
    ENDFORM.                    "USER_COMMAND
    reward points if useful,
    venkat.

Maybe you are looking for

  • I'm having a problem with the registry and iTunes.

    Vista stopped seeing my DVD/CD drive the other day, so I went to the registry and deleted the high and low pass filters for the drive. This fixed that problem. Only problem now was that none of my programs would see the drive, so I had to reinstall a

  • How does a record type and table type works

    Hi, How a record type and table type work for the ref cursor, below i m giving an example but its giving me errors can any one help me for this? declare type empcurtyp is ref cursor; type rectype is record (veid t.emp_id%type, vename t.ename%type); T

  • Possible to move multiple layers from one Illustrator file to another?

    I have 2 large illustrator files (lets say version 1 and version 2). If I have 40 layers on version 2 that I want to send/add to version 1, is this possible (without copy/pasting in place each individual layer?) thanks

  • Adobe Illustrator CS5 Jpeg to Vector

    I would like to change a jpeg to a vector and take out the background using CS5 Adobe Ilustrater on Windows 7 OS. Could someone help with instructions?

  • Artwork does not display on iPod

    I have attached artwork to several songs on my iPod library. The artwork is visible in iTunes when I play those songs, but they do not show when I play the songs on my iPod. I have looked over the Support chapters and did everything they told me to: