Alv sort error ?

hi friends ı write this code .
data : BEGIN OF g_itable OCCURS 0,
       COLOR LIKE icon-id, "emrah color degisken
       bukrs LIKE bkpf-bukrs,
       belnr LIKE bkpf-belnr,
       gjahr LIKE bkpf-gjahr,
       koart LIKE bseg-koart,
       koart_text(60) TYPE c,
       dmbtr LIKE bseg-dmbtr,
       dmbtr1 LIKE bseg-dmbtr,
       name1 LIKE kna1-name1,
       buzei LIKE bseg-buzei,
       shkzg LIKE bseg-shkzg,
       kunnr LIKE bseg-kunnr,
       budat LIKE bkpf-budat,
       header_th(100) TYPE n,
       hkont LIKE bseg-hkont,
       lifnr LIKE bseg-lifnr,
END OF g_itable.
  PERFORM FILL_T_SORT
       USING  : 'G_ITABLE' 'HEADER_TH' 'X' '' ''.
FORM FILL_T_SORT USING   TABNAME FIELDNAME UP DOWN SUBTOT .
  CLEAR U_SORT .
  MOVE : TABNAME   TO U_SORT-TABNAME   ,
         FIELDNAME TO U_SORT-FIELDNAME ,
         UP        TO U_SORT-UP        ,
         DOWN      TO U_SORT-DOWN      ,
         SUBTOT    TO U_SORT-SUBTOT    .
  APPEND U_SORT .
ENDFORM.  
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
   EXPORTING
  I_INTERFACE_CHECK                 = ' '
  I_BYPASSING_BUFFER                =
  I_BUFFER_ACTIVE                   =
     I_CALLBACK_PROGRAM                = gd_repid
   I_CALLBACK_PF_STATUS_SET          = 'GUI'
     I_CALLBACK_USER_COMMAND           = 'COMMAND'
     I_CALLBACK_TOP_OF_PAGE            = 'TOP_OF_PAGE'
  I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
  I_CALLBACK_HTML_END_OF_LIST       = ' '
  I_STRUCTURE_NAME                  =
  I_BACKGROUND_ID                   = 'DTY_BACKGROUND'
  I_GRID_TITLE                      =
  I_GRID_SETTINGS                   =
     IS_LAYOUT                     = gd_layout
     IT_FIELDCAT                  = fieldcatalog[]
  IT_EXCLUDING                      =
  IT_SPECIAL_GROUPS_LVC             =
  IT_SORT_LVC                       =
  IT_FILTER_LVC                     =
  IT_HYPERLINK                      =
  IS_SEL_HIDE                       =
  I_DEFAULT                         = 'X'
   I_SAVE                            = 'A'
      IS_VARIANT               = VARIANTE
  IT_EVENTS                         =
  IT_EVENT_EXIT                     =
  IS_PRINT_LVC                      =
  IS_REPREP_ID_LVC                  =
  I_SCREEN_START_COLUMN             = 0
  I_SCREEN_START_LINE               = 0
  I_SCREEN_END_COLUMN               = 0
  I_SCREEN_END_LINE                 = 0
  I_HTML_HEIGHT_TOP                 =
  I_HTML_HEIGHT_END                 =
  IT_ALV_GRAPHICS                   =
  IT_EXCEPT_QINFO_LVC               =
    IT_SORT                  = U_SORT[]
  IR_SALV_FULLSCREEN_ADAPTER        =
IMPORTING
  E_EXIT_CAUSED_BY_CALLER           =
  ES_EXIT_CAUSED_BY_USER            =
    TABLES
      t_outtab                          = g_itable2
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.
where do ı do error?help me please

probably you have to specify field SPOS in your UT_SORT.

Similar Messages

  • Hotspot-clicking (Insert function) plus ALV Sorting

    Hi,
    I have a requirement where the ALV display has to be SORTED based on values entered/changed on a certain column. The sort works ok when used with a custom APPEND button for new records (always inserted at the bottom of the list).
    However, it does not work correctly when used with the Hotspot-click (INSERT functionality). It looks like if you CLICK on a particular record onscreen, you are actually addressing the original record in that position before the SORT was effected. 
    Is the Hotspot-clicking (Insert functionality) possible with ALV sorting? The ideal solution would be to have the ALV sorted at PBO and also at PAI so that the user can change existing records and add new ones with the sorting being updated everytime ON_DATA_CHANGED is triggered.
    Will appreciate any help on this.
    Thanks!
    Michael

    Hello Michael
    Thanks for further specifying your requirements. I have created the sample variant ZUS_SDN_ALVGRID_HOTSPOT_SORT_1 which contains two differences as compared to its template:
    Replace table VBAK with VBAP (so we have two levels of sorting: VBELN, POSNR)
    Move SET_TABLE_FOR_FIRST_DISPLAY method call into PBO
    When I click on the hotspot (VBELN) a new row entry for the order number is created. The sorting (VBELN, POSNR) is kept even though the new row has been appended to the itab.
    *& Report  ZUS_SDN_ALVGRID_HOTSPOT_SORT
    *& Thread: Hotspot-clicking (Insert function) plus ALV Sorting
    *& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1159431"></a>
    REPORT  zus_sdn_alvgrid_hotspot_sort.
    TYPES: BEGIN OF ty_s_outtab.
    INCLUDE TYPE vbap.
    TYPES: END OF ty_s_outtab.
    TYPES: ty_t_outtab    TYPE STANDARD TABLE OF ty_s_outtab
                          WITH DEFAULT KEY.
    DATA: gt_outtab    TYPE ty_t_outtab.
    DATA:
      gd_okcode        TYPE ui_func,
      gd_repid         TYPE syrepid,
      gt_sort          TYPE lvc_t_sort,
      gt_fcat          TYPE lvc_t_fcat,
      gs_layout        TYPE lvc_s_layo,
      gs_variant       TYPE disvariant,
      go_docking       TYPE REF TO cl_gui_docking_container,
      go_grid          TYPE REF TO cl_gui_alv_grid.
    *       CLASS lcl_eventhandler DEFINITION
    CLASS lcl_eventhandler DEFINITION.
      PUBLIC SECTION.
        CLASS-DATA:
          ms_sel_row    TYPE lvc_s_row. " selected row
        CLASS-METHODS:
          handle_data_changed FOR EVENT data_changed OF cl_gui_alv_grid
            IMPORTING
              er_data_changed
              e_onf4
              e_onf4_before
              e_onf4_after
              sender,
          handle_hotspot_click FOR EVENT hotspot_click OF cl_gui_alv_grid
            IMPORTING
              e_row_id
              e_column_id
              es_row_no
              sender.
    ENDCLASS.                    "lcl_eventhandler DEFINITION
    *       CLASS lcl_eventhandler IMPLEMENTATION
    CLASS lcl_eventhandler IMPLEMENTATION.
      METHOD handle_data_changed.
        FIELD-SYMBOLS: <lt_outtab>  TYPE ty_t_outtab.
        BREAK-POINT.
      ENDMETHOD.                    "handle_data_changed
      METHOD handle_hotspot_click.
        " define local data
        DATA: ls_outtab    TYPE ty_s_outtab,
              ld_msg        TYPE bapi_msg.
        BREAK-POINT.
        CLEAR: lcl_eventhandler=>ms_sel_row.
        ms_sel_row = e_row_id.
        READ TABLE gt_outtab INTO ls_outtab INDEX e_row_id-index.
        CONCATENATE 'Selected Sales Order = ' ls_outtab-vbeln ' / '
                                              ls_outtab-posnr
          INTO ld_msg.
          message i398(00) with ld_msg.
        " Trigger PAI
        CALL METHOD cl_gui_cfw=>set_new_ok_code
          EXPORTING
            new_code = 'INSERT'
    *      IMPORTING
    *        rc       =
      ENDMETHOD.                    "handle_hotspot_click
    ENDCLASS.                    "lcl_eventhandler IMPLEMENTATION
    PARAMETERS:
      p_vkorg      TYPE vkorg  DEFAULT '0001'  OBLIGATORY.
    START-OF-SELECTION.
    **  SELECT  * FROM  vbak INTO CORRESPONDING FIELDS OF TABLE gt_outtab
    **    UP TO 200 ROWS
    **         WHERE  vkorg = p_vkorg.
      SELECT * FROM vbap INTO CORRESPONDING FIELDS OF TABLE gt_outtab
        UP TO 100 ROWS.
      PERFORM init_controls.
    * Build fieldcatalog and set hotspot for field KUNNR
      PERFORM build_fieldcatalog.
      PERFORM set_layout_and_variant.
      PERFORM set_sorting.
      " Register EDIT event
      CALL METHOD go_grid->register_edit_event
        EXPORTING
          i_event_id = cl_gui_alv_grid=>mc_evt_enter
        EXCEPTIONS
          error      = 1
          OTHERS     = 2.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      SET HANDLER:
        lcl_eventhandler=>handle_data_changed  FOR go_grid,
        lcl_eventhandler=>handle_hotspot_click FOR go_grid.
    * Link the docking container to the target dynpro
      gd_repid = syst-repid.
      CALL METHOD go_docking->link
        EXPORTING
          repid                       = gd_repid
          dynnr                       = '0100'
    *      CONTAINER                   =
        EXCEPTIONS
          OTHERS                      = 4.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * ok-code field = GD_OKCODE
      CALL SCREEN '0100'.
    END-OF-SELECTION.
    *&      Module  STATUS_0100  OUTPUT
    *       text
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'STATUS_0100'.
    *  SET TITLEBAR 'xxx'.
    * Display data
      CALL METHOD go_grid->set_table_for_first_display
        EXPORTING
          i_bypassing_buffer            = abap_true
          is_variant                    = gs_variant
          i_save                        = 'A'
    *      i_default                     = 'X'
          is_layout                     = gs_layout
    *      is_print                      =
    *      it_special_groups             =
    *      it_toolbar_excluding          =
    *      it_hyperlink                  =
    *      it_alv_graphics               =
    *      it_except_qinfo               =
    *      ir_salv_adapter               =
        CHANGING
          it_outtab                     = gt_outtab
          it_fieldcatalog               = gt_fcat
          it_sort                       = gt_sort
    *      it_filter                     =
        EXCEPTIONS
          invalid_parameter_combination = 1
          program_error                 = 2
          too_many_lines                = 3
          OTHERS                        = 4.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    **  CALL METHOD go_grid->refresh_table_display
    ***        EXPORTING
    ***          IS_STABLE      =
    ***          I_SOFT_REFRESH =
    **    EXCEPTIONS
    **      finished       = 1
    **      OTHERS         = 2.
    **  IF sy-subrc ne 0.
    ***       MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    ***                  WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    **  ENDIF.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
    *       text
    MODULE user_command_0100 INPUT.
      CASE gd_okcode.
        WHEN 'BACK' OR
             'EXIT'  OR
             'CANC'.
          SET SCREEN 0. LEAVE SCREEN.
        WHEN 'INSERT'.
          PERFORM insert_row.
        WHEN OTHERS.
          " Check for changed data at the frontend (= grid control)
          CALL METHOD go_grid->check_changed_data( ).
      ENDCASE.
      CALL METHOD go_grid->refresh_table_display
    *    EXPORTING
    *      IS_STABLE      =
    *      I_SOFT_REFRESH =
        EXCEPTIONS
          finished       = 1
          OTHERS         = 2.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      CLEAR: gd_okcode.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Form  INIT_CONTROLS
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM init_controls .
    * Create docking container
      CREATE OBJECT go_docking
        EXPORTING
          parent = cl_gui_container=>screen0
          ratio  = 90
        EXCEPTIONS
          others = 6.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      CALL METHOD go_docking->set_extension
        EXPORTING
          extension  = 99999
        EXCEPTIONS
          cntl_error = 1
          OTHERS     = 2.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * Create ALV grid
      CREATE OBJECT go_grid
        EXPORTING
          i_parent = go_docking
        EXCEPTIONS
          others   = 5.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " INIT_CONTROLS
    *&      Form  BUILD_FIELDCATALOG
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM build_fieldcatalog.
    * define local data
      DATA:
        ls_fcat        TYPE lvc_s_fcat.
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
    *     I_BUFFER_ACTIVE              =
          i_structure_name             = 'VBAP'  " 'VBAK'
    *     I_CLIENT_NEVER_DISPLAY       = 'X'
    *     I_BYPASSING_BUFFER           =
    *     I_INTERNAL_TABNAME           =
        CHANGING
          ct_fieldcat                  = gt_fcat
        EXCEPTIONS
          inconsistent_interface       = 1
          program_error                = 2
          OTHERS                       = 3.
      IF sy-subrc NE 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    **  LOOP AT gt_fcat INTO ls_fcat.
    **    CASE ls_fcat-fieldname.
    **      WHEN 'VBELN'  OR
    **           'ERDAT'  OR
    **           'ERZET'  OR
    **           'ERNAM'  OR
    **           'AUART'  OR
    **           'NETWR'  OR
    **           'WAERK'.
    **        CONTINUE.
    **      WHEN OTHERS.
    **        ls_fcat-no_out = abap_true.
    **    ENDCASE.
    **    MODIFY gt_fcat FROM ls_fcat INDEX syst-tabix.
    **  ENDLOOP.
    * Only non-key fields are editable
    **  ls_fcat-edit = 'X'.
    **  MODIFY gt_fcat FROM ls_fcat
    **    TRANSPORTING edit
    **    WHERE ( fieldname NE space ).
      ls_fcat-hotspot = abap_true.
      MODIFY gt_fcat FROM ls_fcat
        TRANSPORTING hotspot
        WHERE ( fieldname = 'AUART'   OR
                fieldname = 'VBELN' ).
    **  DELETE gt_fcat FROM 15 TO 99.
    ENDFORM.                    " BUILD_FIELDCATALOG_KNB1
    *&      Form  SET_LAYOUT_AND_VARIANT
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM set_layout_and_variant .
      CLEAR: gs_layout,
             gs_variant.
      gs_layout-cwidth_opt = abap_true.
      gs_variant-report = syst-repid.
      gs_variant-handle = 'GRID'.
    ENDFORM.                    " SET_LAYOUT_AND_VARIANT
    *&      Form  SET_SORTING
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM set_sorting .
    * define local data
      DATA: ls_sort   TYPE lvc_s_sort.
      REFRESH: gt_sort.
      CLEAR: ls_sort.
      ls_sort-spos = 1.
      ls_sort-fieldname = 'VBELN'.
      ls_sort-up = abap_true.
      APPEND ls_sort TO gt_sort.
      CLEAR: ls_sort.
      ls_sort-spos = 1.
      ls_sort-fieldname = 'POSNR'.
      ls_sort-up = abap_true.
      APPEND ls_sort TO gt_sort.
    ENDFORM.                    " SET_SORTING
    *&      Form  INSERT_ROW
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM insert_row .
    * define local data
      DATA: ls_outtab   TYPE ty_s_outtab,
            ld_order    TYPE vbeln.
      READ TABLE gt_outtab INTO ls_outtab
                           INDEX lcl_eventhandler=>ms_sel_row-index.
      ld_order = ls_outtab-vbeln.
      " Find last item of sales order
      LOOP AT gt_outtab INTO ls_outtab
                        WHERE ( vbeln = ld_order ).
      ENDLOOP.
      " Create next item:
      add 10 to ls_outtab-posnr.
      " NOTE: added at the end of the list
      APPEND ls_outtab TO gt_outtab.
      " NOTE: insert new row AFTER selected row => works, too
    **  INSERT ls_outtab INTO gt_outtab
    **                   INDEX lcl_eventhandler=>ms_sel_row-index.
    ENDFORM.                    " INSERT_ROW

  • ALV Sort

    Hi Guru's
    i am use alv sort in my report .
    i use following code.
    but it gives me DUMP ERROR.
    my code like this.
    DATA : it_sort TYPE slis_t_sortinfo_alv WITH HEADER LINE.
    FORM do_sort .
      it_sort-spos = 1.
      it_sort-fieldname = 'vbeln'.
      it_sort-tabname = 'it_vbak'.
      it_sort-up = 'X'.
      it_sort-subtot = 'X'.
    it_sort-group = '*'.
    it_sort-expa = 'X'.
      APPEND it_sort.
      it_sort-spos = 2.
      it_sort-fieldname = 'posnr'.
      it_sort-tabname = 'it_vbap'.
      it_sort-up = 'X'.
      it_sort-subtot = 'X'.
    it_sort-group = '*'.
    it_sort-expa = 'X'.
      APPEND it_sort.
    ENDFORM.  
    please tell me where is the error.
    Thanks in advance.
    Regards.
    Sam.

    Hi,
    Try the following code
    DATA : it_sort TYPE slis_t_sortinfo_alv WITH HEADER LINE.
    FORM do_sort .
    it_sort-spos = 1.
    it_sort-fieldname = 'VBELN'.
    it_sort-tabname = 'IT_VBAK'.
    it_sort-up = 'X'.
    it_sort-subtot = 'X'.
    it_sort-group = '*'.
    it_sort-expa = 'X'.
    APPEND it_sort.
    it_sort-spos = 2.
    it_sort-fieldname = 'POSNR'.
    it_sort-tabname = 'IT_VBAP'.
    it_sort-up = 'X'.
    it_sort-subtot = 'X'.
    it_sort-group = '*'.
    it_sort-expa = 'X'.
    APPEND it_sort.
    ENDFORM.
    Hope this will have u.
    If it is helpful provide point.
    Thanks.

  • DTW Sort Error - after mapping during import

    I got the "Sort Error - after mapping during import" message in DTW. (version 8.8)
    I would like to import warehouse info for items.
    My itemcodes are fix 15 character numbers, like this: 10204150020011
    The note nr. [1331130|http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/oss_notes/sdn_oss_sbo_dtw/~form/handler%7b5f4150503d3030323030363832353030303030303031393732265f4556454e543d444953504c4159265f4e4e554d3d31333331313330%7d] said that I can't use recordkey like this.
    Do you have any idea how can I import thees information with DTW?
    Thank you,
    Attila Sarkady

    Dear All
    Please give correct and complete information
    i have tested every kind of combination;
    - recreate the template with the dtw for Items = i have UDF's
    - ADD the column RecordKey   !!! unbelievable that we have to do this
    - i have entered a nr 1 in it (even when we had already 850 items in the database)
    (and of course the hints of Gordon - columns as text, start with basic... - and use CSV format)
    now at last i can import the record line
    greetings
    philippe

  • Print ALV List error

    Hello,
    We have a custom ALV report which is very wide (more than 1000 chars).
    Now, when I try to print the list the field with the number of columns is grey (for some users it is grey and for some users it is editable). The format is set to X_65_255.
    When I don't change the number of columns to 255 and trigger the printout I receive the gui error "The memory could not be read blablabla" and the GUI closes. When I change the number of columns to 255 the printout is ok.
    Do you know why for some users the field is grey (user profiles are the same)? What I can do not to receive the gui error while printing.
    Regards,
    Piotr

    Hi,
    See this thread ALV Program errors
    Regards,
    Flavya

  • DTW - Sort Error

    For test purposes I'm trying to import some items (ca. 60) into SAP 2550A, SP01, PL12.
    I use the original template Items.xlt where I filled out only the colums RecordKey, ItemCode, InventoryItem (always set to tYES), ItemName, ItemType (always set to itItems), PurchaseItem and SalesItem (both set always to tYES). RecordKey is always set to the value of corresponding ItemCode (as we are used to do it always). All other colums are left unchanged and empty.
    I saved the template as a semicolon-separated csv-file. This file looks OK when checked using a text editor.
    In DTW I selected oItems as object with the saved csv-file. Other sub-objects to oItems were not specfied. In step 3 of the wizzard under register Source Data all item-entries as defined in the csv-file appear correctly.
    The import process ends up with the error-message "Sort Error - after map, please check ...". In the protocol the import process is stated as "successful", but no items are imported to SAP.
    Before posting this question I checked other threads in the forum and the self-help but couldn't find any hints!
    Thanks for your help!
    Frank

    Frank,
    The version of SAP Business One 2005A SP01 PL 12 is very many patch levels behind.  I would first suggest that you download the latest SAP Business One 2005A SP01 patches and apply to Business One as well as the DTW.  The latest patch level is 23 I believe.
    HTH,
    Eddy

  • ALV Display - Error in field catalog

    Hi ,
    I am facing a problem in ALV... Field catalot is not getting populated... I am getting a message field catalog not found...
    Can anyone please help me....... <URGENT DOES NOT EXIST HERE>...
    I am enclosing my code also.. please go thourh it and help it....
    REPORT ZINVENTORY
          LINE-SIZE  120
           LINE-COUNT 64.
          MESSAGE-ID Z2
          NO STANDARD PAGE HEADING..
    type-pools : slis.
    Tables                                                               *
    tables: zasset,
            anla,
            itob,
            equi.
    data: v_repid LIKE sy-repid.
    Selection Screen                                                     *
    SELECTION-SCREEN : BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001 .
    SELECT-OPTIONS : S_bukrs FOR anla-bukrs OBLIGATORY ,
                     S_kostl FOR itob-kostl .
    SELECTION-SCREEN : END OF BLOCK B1 .
    SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-t02.
    PARAMETERS: p_screen RADIOBUTTON GROUP gr1,
                p_list RADIOBUTTON GROUP gr1 DEFAULT 'X'.
    SELECTION-SCREEN END OF BLOCK b2.
    Internal Tables                                                      *
    types: BEGIN OF ty_zasset, " occurs 0,
             equnr  like zasset-equnr,
             ANLN1 LIKE zasset-ANLN1, " Asset number
             ANLN2 LIKE zasset-ANLN2, " Sub Asset number
             BUKRS LIKE zasset-BUKRS, " Company Code
             KOSTL  like zasset-kostl,
             SCANNEDBY type zasset-scannedby,
             SCANNINGDATE type zasset-SCANNINGDATE,
             SCANNINGTIME type zasset-scanningtime,
             UPDATEDATE   type zasset-updatedate,
             UPDATETIME type zasset-updatetime,
           END OF ty_zasset.
    DATA: wa_zasset   TYPE ty_zasset.
    DATA: it_zasset TYPE TABLE OF ty_zasset with header line..
    types: BEGIN OF ty_zasset1, " occurs 0,
            equnr  TYPE equi-equnr,
             ANLN1 LIKE anla-ANLN1, " Asset number
             ANLN2 LIKE anla-ANLN2, " Sub Asset number
             BUKRS LIKE anla-BUKRS, " Company Code
             ernam like anla-ernam,
             erdat like anla-erdat,
            KOSTL  like anlz-kostl,
            SCANNEDBY type zasset-scannedby,
            SCANNINGDATE type zasset-SCANNINGDATE,
            SCANNINGTIME type zasset-scanningtime,
            UPDATEDATE   type zasset-updatedate,
            UPDATETIME type zasset-updatetime,
           END OF ty_zasset1.
    DATA: wa_zasset1   TYPE ty_zasset1.
    DATA: it_zasset1 TYPE TABLE OF ty_zasset1 with header line..
    types: BEGIN OF ty_zasset2, " occurs 0,
             equnr  like itob-equnr,
             ANLNr LIKE itob-ANLNr, " Asset number
             ANLuN LIKE itob-ANLuN, " Sub Asset number
             BUKRS LIKE itob-BUKRS, " Company Code
             timbi like itob-timbi,
             kostl like itob-kostl,
            KOSTL  like anlz-kostl,
            SCANNEDBY type zasset-scannedby,
            SCANNINGDATE type zasset-SCANNINGDATE,
            SCANNINGTIME type zasset-scanningtime,
            UPDATEDATE   type zasset-updatedate,
            UPDATETIME type zasset-updatetime,
           END OF ty_zasset2.
    DATA: wa_zasset2   TYPE ty_zasset2.
    DATA: it_zasset2 TYPE TABLE OF ty_zasset2 with header line..
    types: begin of ty_final , "occurs 0,
            equnr like itob-equnr,
            anln1 like anla-anln1,
            anln2 like anla-anln2,
            bukrs like anla-bukrs,
           ernam
           erdat
            kostl like itob-kostl,
            end of ty_final.
    DATA: wa_final   TYPE ty_final.
    DATA: it_final TYPE TABLE OF ty_final with header line..
    *DATA: it_zasset TYPE TABLE OF ty_zasset.
    *data: it_zasset1 type table of ty_zasset1.
    *data:wa_zasset type ty_zasset.
    *data:wa_zasset1 type ty_zasset1.
    Flags and Variables                                                 *
    DATA : F_ERROR.                   " Flag for No Data
    *pop field cat for f7
    data: V_SYREPID LIKE SY-REPID,
          IT_FLDCAT type slis_t_fieldcat_alv , "with header line,
          wa_fldcat   type slis_fieldcat_alv.
    *DATA : IT_FLDCATS TYPE SLIS_T_FIELDCAT_ALV.
    data: itab_events type slis_t_event,
          wa_events   type slis_alv_event.
    *data: wa_layout type slis_layout_alv.
    DATA : IT_COMMENTS TYPE SLIS_T_LISTHEADER,
           WA_COMMENTS TYPE SLIS_LISTHEADER.
    DATA : IT_SORTINFO TYPE SLIS_T_SORTINFO_ALV,
           WA_SORTINFO TYPE SLIS_SORTINFO_ALV.
    Initialization                                                       *
    initialization.
      SY-REPID = V_REPID.
    At Selection Screen                                                  *
    AT SELECTION-SCREEN.
      PERFORM validation.
    Start Of Selection                                                   *
    start-of-selection.
    perform select_data.
    IF P_LIST = 'X'.
    perform get_field_catalog.
    PERFORM MODIFYFIELDCAT.
    perform get_events.
    perform write_comments.
    perform grid_display.
    *perform list_display.
    ENDIF.
    IF sy-subrc = 0.
       IF p_list = 'X'.
       loop at it_final.
       perform get_events.
       endloop.
       endif.
       endloop.
       else.
    *endif.
    End Of Selection                                                     *
    END-OF-SELECTION.
    *perform display_Recorsds.
    *loop at zasset.
    *&      Form  validation
          text
    -->  p1        text
    <--  p2        text
    FORM validation.
    *Local variables.
      DATA:
            lv_bukrs type anla-bukrs,
            lv_kostl type itob-kostl,
            lv_anln1 TYPE anla-anln1,        "MAterial Number
            lv_anln2 TYPE anla-anln2.
    *Validation for company code
      if not s_bukrs is initial.
        select single bukrs from anla
               into lv_bukrs
               where bukrs in s_bukrs.
        if sy-subrc <> 0.
    *Message used : Invalid company code.
        endif.
      endif    .
    Validation for cost center
      if not s_kostl is initial.
        select single kostl from itob
               into lv_kostl
               where kostl in s_kostl.
        if sy-subrc <> 0.
    *Message used : Invalid company code.
        endif.
      endif  .
    ENDFORM.                    " validation
    *&      Form  display
          text
    -->  p1        text
    <--  p2        text
    FORM display.
      write :/15 it_final-anln1,
      it_final-anln2,
                sy-vline.
    *-bukrs,
           it_zasset-anln1.
    ENDFORM.                    " display
    *&      Form  get_field_catalog
          text
    -->  p1        text
    <--  p2        text
    FORM get_field_catalog.
    *REFRESH IT_FLDCAT.
    *CLEAR IT_FLDCAT.
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
       I_PROGRAM_NAME               = V_REPID
       I_INTERNAL_TABNAME           = 'IT_FINAL'
       I_INCLNAME                   = V_REPID
      I_BYPASSING_BUFFER           =
      I_BUFFER_ACTIVE              =
      CHANGING
        CT_FIELDCAT                  = IT_FLDCAT
    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.
    ENDFORM.                    " get_field_catalog
    *&      Form  get_events
          text
    -->  p1        text
    <--  p2        text
    FORM get_events.
      WA_COMMENTS-TYP = 'H'.
      WA_COMMENTS-KEY = 'THIS IS THE HEADING.'.
      WA_COMMENTS-INFO = 'LIST OF SALES ORDERS'.
      APPEND WA_COMMENTS TO IT_COMMENTS.
    ENDFORM.                    " get_events
    *&      Form  grid_display
          text
    -->  p1        text
    <--  p2        text
    FORM grid_display.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      I_INTERFACE_CHECK                 = ' '
      I_BYPASSING_BUFFER                =
      I_BUFFER_ACTIVE                   = ' '
       I_CALLBACK_PROGRAM                = v_repid
      I_CALLBACK_PF_STATUS_SET          = ' '
      I_CALLBACK_USER_COMMAND           = ' '
       I_CALLBACK_TOP_OF_PAGE            = 'FIRST PAGE'
      I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
      I_CALLBACK_HTML_END_OF_LIST       = ' '
      I_STRUCTURE_NAME                  =
      I_BACKGROUND_ID                   = ' '
       I_GRID_TITLE                      =  'LIST OF FLIGHT DETAILS'
      I_GRID_SETTINGS                   =
      IS_LAYOUT                         =
       IT_FIELDCAT                       =  it_fldcat
      IT_EXCLUDING                      =
      IT_SPECIAL_GROUPS                 =
      IT_SORT                           =
      IT_FILTER                         =
      IS_SEL_HIDE                       =
      I_DEFAULT                         = 'X'
      I_SAVE                            = ' '
      IS_VARIANT                        =
      IT_EVENTS                         =  itab_events
      IT_EVENT_EXIT                     =
      IS_PRINT                          =
      IS_REPREP_ID                      =
      I_SCREEN_START_COLUMN             = 0
      I_SCREEN_START_LINE               = 0
      I_SCREEN_END_COLUMN               = 0
      I_SCREEN_END_LINE                 = 0
      IT_ALV_GRAPHICS                   =
      IT_ADD_FIELDCAT                   =
      IT_HYPERLINK                      =
      I_HTML_HEIGHT_TOP                 =
      I_HTML_HEIGHT_END                 =
      IT_EXCEPT_QINFO                   =
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER           =
      ES_EXIT_CAUSED_BY_USER            =
      TABLES
        T_OUTTAB                          = it_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.
    ENDFORM.                    " grid_display
    *&      Form  write_comments
          text
    -->  p1        text
    <--  p2        text
    FORM write_comments.
      WA_COMMENTS-TYP = 'H'.
      WA_COMMENTS-KEY = 'THIS IS THE HEADING.'.
      WA_COMMENTS-INFO = 'LIST OF SALES ORDERS'.
      APPEND WA_COMMENTS TO IT_COMMENTS.
    ENDFORM.                    " write_comments
    *&      Form  select_data
          text
    -->  p1        text
    <--  p2        text
    FORM select_data.
      clear: it_zasset, it_zasset[].
      select  equnr "bukrs
              anln1
              anln2
              bukrs
              KOSTL
              SCANNEDBY
              SCANNINGDATE
              SCANNINGTIME
              UPDATEDATE
              UPDATETIME
              into table it_zasset "(g_anln1,g_anln2)
              from zasset
              where bukrs = zasset-bukrs..
          and   kostl = zasset-kostl.
      if sy-subrc = 0.
        sort it_zasset by anln1 anln2.
      endif.
    append it_zasset.
      clear it_zasset1.
      select
             equnr
              anln1
              anln2
              bukrs
              ernam
              erdat
             bukrs
             KOSTL
             SCANNEDBY
             SCANNINGDATE
             SCANNINGTIME
             UPDATEDATE
             UPDATETIME
              into table it_zasset1 "(g_anln1,g_anln2)
              from  anla
             where bukrs = it_zasset-bukrs.
      WHERE BUKRS IN S_BUKRS.
    and   kostl = anla-kostl.
      if sy-subrc = 0.
        select equnr
               anlnr
               anlun
               bukrs
               timbi
               kostl
               into table it_zasset2
               from itob
               for all entries in it_zasset1
              where bukrs = it_zasset1-bukrs
               WHERE   anlnr = it_zasset1-anln1.
      endif.
      APPEND IT_ZASSET1.
      IF SY-SUBRC = 0.
    *loop at it_zasset1 into wa_zasset1.
    loop at it_ZASSET1 into wa_zasset1.
    move wa_zasset1-bukrs to wa_final-bukrs.
        move wa_zasset1-anln1 to wa_final-anln1.
        move wa_zasset1-anln2 to wa_final-anln2.
    append wa_final to it_final.
    endloop.
    ENDIF.
    sort it_final.
    *LOOP AT IT_FINAL.
    *ENDLOOP.
    *ENDIF.
    *if sy-subrc = 0.
    *loop at it_zasset into wa_asset.
    *read table it_zasset into wa_asset with key anln2 = wa_asset-anln2
    *binary search.
    *read table it_final into wa_final with key anln2 = wa_final-anln2
    *binary search.
    *if wa_asset-anln2 = wa_final-anln2.
    *write : / 'error'.
    *endif.
    If sy-subrc <> 0.
       f_error = 'X'.
       write :  'No data Exists for the given selection in FA table'.
    else.
       loop at it_final.
         perform display.
       endloop.
    records exits in anla table also.
    endif.
    ENDFORM.                    " select_data
    *&      Form  MODIFYFIELDCAT
          text
    -->  p1        text
    <--  p2        text
    FORM MODIFYFIELDCAT.
      LOOP AT IT_FLDCAT INTO WA_FLDCAT.
         CASE WA_FLDCAT-FIELDNAME.
            WHEN 'EQUNR'.
    WA_FLDCAT-COL_POS = 1.
              WA_FLDCAT-SELTEXT_L = 'aSSET'.
            WHEN 'ANLN1'.
            wa_FLDCAT-KEY = 'X'.
              WA_FLDCAT-COL_POS = 5.
              WA_FLDCAT-SELTEXT_L = 'aSSET'.
            WHEN 'ANLN2'.
              WA_FLDCAT-KEY = 'X'.
              WA_FLDCAT-COL_POS = 6.
            wa_FLDCAT-HOTSPOT = 'X'.
            WHEN 'BUKRS'.
              WA_FLDCAT-CURRENCY = 'INR'.
             WA_FLDCAT-SYMBOL = 'X'.
          ENDCASE.
        MODIFY IT_FLDCAT FROM WA_FLDCAT.
    *IT_FLDCAT-fieldname   = 'EQUNR'.
    IT_FLDCAT-seltext_m   = 'DOCUM_TYPE'.
    IT_FLDCAT-col_pos     = 1.
    IT_FLDCAT-outputlen   = 10.
    IT_FLDCAT-emphasize   = 'X'.
    IT_FLDCAT-key         = 'X'.
    fieldcatalog-do_sum      = 'X'.
    fieldcatalog-no_zero     = 'X'.
    append IT_FLDCAT TO IT_FLDCAT.
    IT_FLDCAT-fieldname   = 'ANLN1'.
    IT_FLDCAT-seltext_m   = 'DOCUM_TYPE'.
    IT_FLDCAT-col_pos     = 1.
    IT_FLDCAT-outputlen   = 10.
    IT_FLDCAT-emphasize   = 'X'.
    IT_FLDCAT-key         = 'X'.
    fieldcatalog-do_sum      = 'X'.
    fieldcatalog-no_zero     = 'X'.
    append IT_FLDCAT TO IT_FLDCAT.
      ENDLOOP.
    ENDFORM.                    " MODIFYFIELDCAT
    *&      Form  list_display
          text
    -->  p1        text
    <--  p2        text
    *FORM list_display.
    *CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
      I_INTERFACE_CHECK              = ' '
      I_BUFFER_ACTIVE                = ' '
      I_CALLBACK_PROGRAM             = V_SYREPID
      I_CALLBACK_PF_STATUS_SET       = ' '
      I_CALLBACK_USER_COMMAND        = 'FRM_USER_COMMAND'
      I_STRUCTURE_NAME               =
      IS_LAYOUT                      = wa_layout
      IT_FIELDCAT                    = IT_FLDCAT
      IT_EXCLUDING                   =
      IT_SPECIAL_GROUPS              =
      IT_SORT                        =
      IT_FILTER                      =
      IS_SEL_HIDE                    =
      I_DEFAULT                      = 'X'
      I_SAVE                         = 'A'
      IS_VARIANT                     =
      IT_EVENTS                      = ITAB_EVENTS
      IT_EVENT_EXIT                  =
      IS_PRINT                       =
      IS_REPREP_ID                   =
      I_SCREEN_START_COLUMN          = 0
      I_SCREEN_START_LINE            = 0
      I_SCREEN_END_COLUMN            = 0
      I_SCREEN_END_LINE              = 0
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER        =
      ES_EXIT_CAUSED_BY_USER         =
    TABLES
       T_OUTTAB                       = IT_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.
    *ENDFORM.                    " list_display
    Edited by: Craig Cmehil on Jul 18, 2008 10:01 AM

    The problem is with this...
    types: begin of ty_final , "occurs 0,
    equnr like itob-equnr,
    anln1 like anla-anln1,
    anln2 like anla-anln2,
    bukrs like anla-bukrs,
    ernam
    erdat
    kostl like itob-kostl,
    end of ty_final.
    DATA: wa_final TYPE ty_final.
    DATA: it_final TYPE TABLE OF ty_final with header line.
    when you are using Fieldcatalog merge you have to avoid using the TYPES Declaration of the internal table.
    Instead of that you can do this
    data: begin of it_final occurs 0,
    equnr like itob-equnr,
    anln1 like anla-anln1,
    anln2 like anla-anln2,
    bukrs like anla-bukrs,
    ernam
    erdat
    kostl like itob-kostl,
            end of it_final.

  • ALV SUM error

    Hi all !!
    I'm dipalying CURR field on alv. When trying to do sum on i get short dump.
    that is my fieldcat definition:
      ls_fieldcat-fieldname    = 'NETWR'.
      ls_fieldcat-ref_fieldname  = 'NETWR'.
      ls_fieldcat-ref_tabname  = 'VBRP'.
      ls_fieldcat-datatype = 'CURR'.
      ls_fieldcat-cfieldname = 'WAERK'.
      ls_fieldcat-ctabname = 'VBRK'.
    What is my error ??
    BR, JAcek

    Nothing of that doesnt work fine on my system (4.7).
    (ST22 Error):  MESSAGE_TYPE_X
    assign component
              <ls_fieldcat>-fieldname of structure rt_data to <g_field>.
       if sy-subrc ne 0.
         message x000(0k).
       endif.
    or when using in fieldac:
    ls_fieldcat-cfieldname = 'WAERS'.
    what was suggested in similiar problem in that formum sone times ago:
    (st22)
    Invalid dynamic line component.
    When the ABAP program "SAPLSKBH" attempted to process the internal
    table "RT_COLLECT00[]" with "SORT", a component "WAERS " was specified
    dynamically
    as the contents of the field "L_UFIELDNAME".
    One of the following errors then occurred:
    - The line type "u" of the internal table "RT_COLLECT00[]" contains no
      component "WAERS ".
    - "WAERS " contained an invalid offset or length specification (for
      example, you may have tried to access part of a field with type I or
      STRING).
    - The program "SAPLSKBH" is a Unicode program. In Unicode programs, you
      can only apply offset/length access to a structure within its
      character-type initial section. The system went beyond the
      boundaries of "WAERS " 's initial section in this case.
    - "WAERS " contains a declaration of the form "A->B" for dynamically
      accessing an object attribute. At present, attributes can only be
      addressed in this way statically.
    - "WAERS " contained significant trailing spaces (only possible with type
      STRING).
    Message was edited by: Jacek Slowikowski

  • ALV Sorting Not Working after Adding Checkbox to ALV

    Hi All.
    I am currently doing an ALV report using REUSE_ALV_GRID_DISPLAY function. I am sorting the list by Employee Name and Personnel Area. It works fine where the personnel are field and employee name field are merger together for same personnel are and employee name. But afterwards I added a checkbox field to the internal table and the list outputs a checkbox for each line. Afer  putting the checkbox the list no long merges the same personnel are and employee name fields according to original sorting.
    Can anyone explain if there is a way to solve this?
    Thanks a lot.
    Lily

    yes there is a way. Just see this..
    There is no Straight forward solution. There is a work around.
    REPORT  ztest_check_box                         .
    TYPE-POOLS: slis,icon.
    DATA: BEGIN OF it_vbap OCCURS 0,
           vbeln LIKE vbap-vbeln,
           matnr LIKE vbap-matnr,
           posnr LIKE vbap-posnr,
           kunnr LIKE vbak-kunnr,
           kwmeng LIKE vbap-kwmeng,
           check TYPE c,
           id TYPE icon-id,
          END OF it_vbap.
    DATA: it_fieldcat  TYPE slis_t_fieldcat_alv.
    DATA:  x_fieldcat  TYPE slis_fieldcat_alv.
    DATA: it_sort TYPE slis_t_sortinfo_alv,
          x_sort TYPE slis_sortinfo_alv.
    SELECT vbak~vbeln
           vbak~kunnr
           vbap~posnr
           vbap~matnr
           vbap~kwmeng
           INTO CORRESPONDING FIELDS OF TABLE it_vbap
           FROM vbak JOIN vbap
           ON vbak~vbeln = vbap~vbeln.
    SORT it_vbap BY matnr.
    DELETE it_vbap WHERE matnr IS INITIAL.
    LOOP AT it_vbap.
      it_vbap-id = '@T9@'.
      MODIFY it_vbap.
    ENDLOOP.
    x_fieldcat-fieldname = 'ID'.
    x_fieldcat-seltext_l = 'CHECK'.
    x_fieldcat-outputlen = 4.
    x_fieldcat-icon  = 'X'.
    x_fieldcat-col_pos   = 1.
    x_fieldcat-hotspot  = 'X'.
    x_fieldcat-tabname   = 'IT_VBAP'.
    APPEND x_fieldcat TO it_fieldcat.
    CLEAR x_fieldcat.
    x_fieldcat-fieldname = 'MATNR'.
    x_fieldcat-seltext_l = 'MATNR'.
    x_fieldcat-col_pos   = 2.
    x_fieldcat-tabname   = 'IT_VBAP'.
    APPEND x_fieldcat TO it_fieldcat.
    CLEAR x_fieldcat.
    x_fieldcat-fieldname = 'KUNNR'.
    x_fieldcat-seltext_l = 'KUNNR'.
    x_fieldcat-col_pos   = 3.
    x_fieldcat-tabname   = 'IT_VBAP'.
    APPEND x_fieldcat TO it_fieldcat.
    CLEAR x_fieldcat.
    x_fieldcat-fieldname = 'VBELN'.
    x_fieldcat-seltext_l = 'VBELN'.
    x_fieldcat-col_pos   = 4.
    x_fieldcat-tabname   = 'IT_VBAP'.
    APPEND x_fieldcat TO it_fieldcat.
    CLEAR x_fieldcat.
    x_fieldcat-fieldname = 'POSNR'.
    x_fieldcat-seltext_l = 'POSNR'.
    x_fieldcat-col_pos   = 5.
    x_fieldcat-tabname   = 'IT_VBAP'.
    APPEND x_fieldcat TO it_fieldcat.
    CLEAR x_fieldcat.
    x_fieldcat-fieldname = 'KWMENG'.
    x_fieldcat-seltext_l = 'KWMENG'.
    x_fieldcat-col_pos   = 6.
    x_fieldcat-do_sum   = 'X'.
    x_fieldcat-tabname   = 'IT_VBAP'.
    APPEND x_fieldcat TO it_fieldcat.
    CLEAR x_fieldcat.
    x_sort-fieldname = 'MATNR'.
    x_sort-spos       = 1.
    x_sort-up = 'X'.
    x_sort-group = 'X'.
    x_sort-subtot = 'X'.
    APPEND x_sort TO it_sort.
    CLEAR x_sort.
    x_sort-fieldname = 'KUNNR'.
    x_sort-spos       = 2.
    x_sort-up = 'X'.
    APPEND x_sort TO it_sort.
    CLEAR x_sort.
    x_sort-fieldname = 'VBELN'.
    x_sort-spos       = 3.
    x_sort-up = 'X'.
    APPEND x_sort TO it_sort.
    CLEAR x_sort.
    *DATA:x_layout TYPE lvc_s_layo.
    *x_layout-box_fname = 'CHECK'.
    *x_layout-no_rowmark = 'X'.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
        i_callback_program = sy-repid
    *   is_layout          = x_layout
        i_callback_user_command = 'USER_COMMAND'
        it_fieldcat        = it_fieldcat
        it_sort            = it_sort
      TABLES
        t_outtab           = it_vbap[]
      EXCEPTIONS
        program_error      = 1
        OTHERS             = 2.
    IF sy-subrc ne 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    *&      Form  itab_user_command
    *       text
    *      -->WHATCOMM   text
    *      -->WHATROW    text
    FORM user_command USING whatcomm TYPE sy-ucomm selfield TYPE
    slis_selfield.
      IF selfield-fieldname = 'ID'.
        READ TABLE it_vbap INDEX selfield-tabindex.
        IF sy-subrc = 0.
          IF it_vbap-check = ''.
            it_vbap-id = '@R7@'.
            it_vbap-check = 'X'.
          ELSE.
            it_vbap-id = '@T9@'.
            it_vbap-check = ''.
          ENDIF.
          MODIFY it_vbap INDEX selfield-tabindex.
        ENDIF.
      ENDIF.
      selfield-refresh = 'X'.
    ENDFORM.                    "itab_user_command
    if you want to make the above code to work in lower versions then you have to do this..
    then maintain the ICON using the view V_ICON from SM30 add the New Entry.
    get the properties from the below screen shot.
    http://img404.imageshack.us/img404/3338/testig9.png

  • Alv edit error

    i'm using fieldcatalog to rename the column header(name) like this..
    CLEAR g_wa_fieldcat.
      g_wa_fieldcat-coltext    = 'Module'.
      g_wa_fieldcat-fieldname  = 'MODULETYPE'.  
      g_wa_fieldcat-style      = cl_gui_alv_grid=>mc_style_enabled.
      g_wa_fieldcat-ref_table  = 'G_IT_DEV_LIST'.
      g_wa_fieldcat-just = 'C'.           
      g_wa_fieldcat-col_opt  = 'X'.     
      APPEND g_wa_fieldcat TO g_fieldcat.
    and after edit the alv
    CALL METHOD g_grid->set_table_for_first_display
        EXPORTING
          i_structure_name = 'ZDEVELOP_LIST'
          is_layout        = g_layout
        CHANGING
          it_outtab        = g_it_dev_list
          it_fieldcatalog  = g_fieldcat.
    after i renamed the column name..
    after edit or add the new column and  when i use
    CALL METHOD g_grid->check_changed_data.
    the errors are occur!!
    Selected Logs(Local Time) : 2007.10.09 03:07:
    NameOfTheColumn  | Message Text
    &#51648;&#50672;                   Field G_IT_DEV_LIST-LIGHT is not in the ABAP Dictionary
    Module                     Field G_IT_DEV_LIST-MODULETYPE is not in the ABAP Dictionary
    ID                     Field G_IT_DEV_LIST-ID is not in the ABAP Dictionary
    T-CODE                     Field G_IT_DEV_LIST-T_CODE is not in the ABAP Dictionary
    g_it_dev_list has above fieldname. if i don't rename the column name, it doesn's occur!!
    plz help me!!!!
    Message was edited by:
            Seung Chul Yang

    Hi,
    Instead of passing value to <b>ref_table</b> pass the value to <b>tabname.</b>
    <b>correct one.</b>
    g_wa_fieldcat-coltext = 'Module'.
    g_wa_fieldcat-fieldname = 'MODULETYPE'.
    g_wa_fieldcat-style = cl_gui_alv_grid=>mc_style_enabled.
    *comment below line
    *g_wa_fieldcat-ref_table = 'G_IT_DEV_LIST'.
    *Add below line
    <b>g_wa_fieldcat-tabnam = 'G_IT_DEV_LIST'.</b>
    g_wa_fieldcat-just = 'C'.
    g_wa_fieldcat-col_opt = 'X'.
    APPEND g_wa_fieldcat TO g_fieldcat.
    <b></b>

  • ALV: Runtime error when calling only few columns of tables in ALV rpt

    Dear ABAP Gurus N Experts,
    I am new for ABAP.
    I am creating an ALV for fetching the data from ztable. It works fine, If I select all column than .
    SELECT * FROM zshipment01 INTO TABLE gi_zshipment01.
    But when I try to select only few column it gives an error. Runtime errors: DBIF_RSQL_INVALID_RSQL, Exception:  CX_SY_OPEN_SQL_DB
    SELECT container shipment_no bill_of_lad bl_date DATE_OF_PORT ARRIVAL_NO1 ED_TRUCKING
    FROM zshipment01 INTO TABLE gi_zshipment01.
    I am using following function:, which is called in program as PERFORM load_data_into_grid.
    FORM load_data_into_grid.
    SELECT * FROM zshipment01 INTO TABLE gi_zshipment01.
    Load data into the grid and display them
    CALL METHOD go_grid->set_table_for_first_display
           EXPORTING i_structure_name = 'zshipment01'
           CHANGING  it_outtab        = gi_zshipment01.
       ENDFORM.                    " load_data_into_grid
    Early response will be highly appreciated.
    With thanks,
    DSC
    Moderator Messge: Basic questions are not allowed. Search before you post.
    Edited by: kishan P on Feb 29, 2012 2:22 PM

    Hi Devendra,
    Try to use "corresponding" statement.
    SELECT field1 field1 etc FROM zshipment01 *INTO CORRESPONDING FIELD OF TABLE* gi_zshipment01.
    Regards,
    Dondi.
    Points unassigned
    Edited by: kishan P on Feb 29, 2012 2:22 PM

  • ALV Sort problem

    Hi Experts,
    I have encountered a peculiar situation with respect to ALV, using sort. The problem is as follows:
    1. I have an internal table with 3 fields, upon which I am supposed to implement a sort criteria on the first two fields.
    2. My data is something like this, for ex:
    abc  1  a
    abc  1  b
    cde  1  a
    cde  1  b
    3. I have applied sort criteria, on the first two fields and passed to the fm "REUSE_ALV_GRID_DISPLAY'.
    4. Now the output is as follows:
    abc  1  a
      --  b
    cde --  a
    ---   --  b
    Here ( -- ) dotted lines mean the identical entry from the previous row...
    5. My requirement is I want the output as:
    abc  1  a
    ---  --   b
    cde  1  a
    ---   --  b 
    I mean the sort critetia of the second column should follow the first(adjacent column) sort criteria
    I hope it is clearly explained, and kindly let me know how this can be solved..
    Thank you,
    Shashi

    Hi Bala,
    The suggested solution is not giving the desired results..
    This happens because, when i sort the entries i mentioned earlier, remains the same, even after the two explicit sort statements on the internal table.
    Kindly check the same and let me know.
    Regards,
    Shashi

  • Alv sorting

    hi
    need to sort alv data, but the entries are like header and item
    means first line is of header data and if has items then
          the items will be displayed starting from second line but some columns for all items
          will be empty (means header data at the top line refers)
    now second header data comes and then its items.
    in such case how to sort the ALV basing on the header number.
    while sorting all the items are going at the bottom since it has no header number in its line
      and header items are coming at the top
    how to sort these entries correctly

    Hi,
    Try this
    DATA : gt_sort TYPE slis_t_sortinfo_alv,
               wa_sort TYPE slis_sortinfo_alv.
    PERFORM fill_sort.               " Filling sort of REUSE_ALV_GRID_DISPALY
    FORM fill_sort .
      wa_sort-fieldname = 'MATNR'.
      wa_sort-up = c_x.
      APPEND wa_sort TO gt_sort.
      CLEAR wa_sort.
    ENDFORM.                    " FILL_SORT
          CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
            EXPORTING
              i_callback_program = g_repid
              i_grid_title       = text-012
              is_layout          = wa_slis_layout
              it_sort            = gt_sort[]
              it_fieldcat        = gt_fieldcat[]
              i_save             = 'A'              
            TABLES
              t_outtab           = <fs_table>
            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.

  • ALV - Sort on Subtotals

    Hi,
    Does anyone know how to sort on the subtotals of a numeric column in an ALV.
    Murali.

    Hi Santosh,
    Wouldnt this just sort a column and then show the subtotals ?
    a     X     1
    b     X     2
    c     X     3
    X subtotal     6     
    d     Y     4
    e     Y     5
    f     Y     6
    g     Y     7
    Y subtotal     22     
    Grand total     28
    I am looking to sort 22 and 6 in descending order with subtotal 22 at the top.
    Thanks
    Edited by: Muralidaran Shanmugam on Feb 10, 2010 7:11 AM

  • ALV Sort with cell merge

    Please help!
    When i run an ALV report in foreground, there is cell-merge when a column is sorted.
    However, when the ALV run @ background, why the cell-merge cannot work ? All data is listed, rather than is summarized into a block for all rows with the same field content.
    Please Advice
    Regards
    Annie

    Hi,
    see this example.
    TABLES : vbak.
    TYPE-POOLS: slis.                      " ALV Global types
    SELECT-OPTIONS :
      s_vkorg FOR vbak-vkorg,              " Sales organization
      s_kunnr FOR vbak-kunnr,              " Sold-to party
      s_vbeln FOR vbak-vbeln.              " Sales document
    SELECTION-SCREEN :
      SKIP, BEGIN OF LINE,COMMENT 5(27) v_1 FOR FIELD p_max.
    PARAMETERS p_max(2) TYPE n DEFAULT '20' OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    DATA:
      BEGIN OF gt_vbak OCCURS 0,
        vkorg LIKE vbak-vkorg,             " Sales organization
        kunnr LIKE vbak-kunnr,             " Sold-to party
        vbeln LIKE vbak-vbeln,             " Sales document
        netwr LIKE vbak-netwr,             " Net Value of the Sales Order
        waerk LIKE vbak-waerk,             " Document currency
      END OF gt_vbak.
    INITIALIZATION.
      v_1 = 'Maximum of records to read'.
    START-OF-SELECTION.
      PERFORM f_read_data.
      PERFORM f_display_data.
    *      Form  f_read_data
    FORM f_read_data.
      SELECT * INTO CORRESPONDING FIELDS OF TABLE gt_vbak
               FROM vbak
                 UP TO p_max ROWS
              WHERE kunnr IN s_kunnr
                AND vbeln IN s_vbeln
                AND vkorg IN s_vkorg.
    ENDFORM.                               " F_READ_DATA
    *      Form  f_display_data
    FORM f_display_data.
      DEFINE m_fieldcat.
        add 1 to ls_fieldcat-col_pos.
        ls_fieldcat-fieldname   = &1.
        ls_fieldcat-ref_tabname = 'VBAK'.
        ls_fieldcat-do_sum      = &2.
        ls_fieldcat-cfieldname  = &3.
        append ls_fieldcat to lt_fieldcat.
      END-OF-DEFINITION.
      DEFINE m_sort.
        add 1 to ls_sort-spos.
        ls_sort-fieldname = &1.
        ls_sort-up        = 'X'.
        ls_sort-subtot    = &2.
        append ls_sort to lt_sort.
      END-OF-DEFINITION.
      DATA:
        ls_fieldcat TYPE slis_fieldcat_alv,
        lt_fieldcat TYPE slis_t_fieldcat_alv,
        lt_sort     TYPE slis_t_sortinfo_alv,
        ls_sort     TYPE slis_sortinfo_alv,
        ls_layout   TYPE slis_layout_alv.
      m_fieldcat 'VKORG' ''  ''.
      m_fieldcat 'KUNNR' ''  ''.
      m_fieldcat 'VBELN' ''  ''.
      m_fieldcat 'NETWR' 'X' 'WAERK'.
      m_fieldcat 'WAERK' ''  ''.
      m_sort 'VKORG' 'X'.                  " Sort by vkorg and subtotal
      m_sort 'KUNNR' 'X'.                  " Sort by kunnr and subtotal
      m_sort 'VBELN' ''.                   " Sort by vbeln
      ls_layout-cell_merge = 'X'.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
           EXPORTING
                is_layout   = ls_layout
                it_fieldcat = lt_fieldcat
                it_sort     = lt_sort
           TABLES
                t_outtab    = gt_vbak.
    ENDFORM.
    rgds,
    bharat.

Maybe you are looking for