Custom ALV

Hi all,
I'm new to WDA and I'm trying to use ALV (SALV_WD_TABLE).
I have a few questions regarding customizing the display:
1. How do I show only part of the node attributes?
     (The node has 5 attributes and I only want to show 3)
2. How do I change the default column headers?
3. How do I set the order of column appearance?
Tnx,
Aviad

Hi,
Using the column settings you can hide the columns, set the column headers, and their positions also.
* Instantiate the used component
  DATA lo_cmp_usage TYPE REF TO if_wd_component_usage.
  lo_cmp_usage =   wd_this->wd_cpuse_usg_alv1( ).
  IF lo_cmp_usage->has_active_component( ) IS INITIAL.
    lo_cmp_usage->create_component( ).
  ENDIF.
* Get Model
  DATA lo_interfacecontroller TYPE REF TO iwci_salv_wd_table .
  lo_interfacecontroller =   wd_this->wd_cpifc_usg_alv1( ).
  DATA lo_value TYPE REF TO cl_salv_wd_config_table.
  lo_value = lo_interfacecontroller->get_model(
DATA  lt_column_settings TYPE REF TO if_salv_wd_column_settings.
  lt_column_settings ?= lo_value.
DATA: lr_col_header  TYPE REF TO cl_salv_wd_column_header .
  DATA: lt_columns TYPE salv_wd_t_column_ref ,
              ls_columns TYPE salv_wd_s_column_ref ,
             lr_column type ref to cl_salv_wd_column.
   lt_columns = lt_column_settings->get_columns( )              .
  LOOP AT lt_columns INTO ls_columns .
  lr_column = = ls_columns-r_column.
    CASE ls_columns-id                                        .
      WHEN 'PERNR'                                            .
        lr_column_header = ls_columns-r_column->get_header( )  .
        lr_column_header->set_ddic_binding_field(
           if_salv_wd_c_column_settings=>ddic_bind_none )     .
         lr_column_header->set_text('Emp Id' )            .
      lr_column->set_position( 1).
      WHEN' NAME1'.
      lr_column->set_position( 2).    "Set position
when 'NAME2'.
          CALL METHOD lr_column->set_visible
            EXPORTING
              value = cl_wd_uielement=>e_visible-none.    "Hide column
       WHEN OTHERS.
ENDLOOP.
Regards,
Lekha.

Similar Messages

  • Custom ALV HTML Header

    I am trying to create a standard header for our company as we are trying increase the development of custom ALV reports.  I have the header working, but I am wondering how to convert an internal table to html and display in the header.  This is mostly for formatting purposes.
    I have included the code i use currently below... i am open to any suggestion.. thanks.
      DATA:        V_EVENT_RECEIVER      TYPE REF TO V_LCL_EVENT_RECEIVER.
      DATA: V_SPLIT            TYPE REF TO CL_GUI_EASY_SPLITTER_CONTAINER,
            O_DOCKINGCONTAINER TYPE REF TO CL_GUI_DOCKING_CONTAINER,
            V_CONTNR_TOP       TYPE REF TO CL_GUI_CONTAINER,
            V_CONTNR_BOT       TYPE REF TO CL_GUI_CONTAINER,
            V_GRID_02          TYPE REF TO CL_GUI_ALV_GRID,
            V_HTML             TYPE REF TO CL_DD_DOCUMENT,
            V_HTML_VIEW        TYPE REF TO CL_GUI_HTML_VIEWER,
            V_TEXT20(255)      TYPE C,
            V_TEXT16(255)      TYPE C.
      IF CL_GUI_ALV_GRID=>OFFLINE( ) IS INITIAL.
    *Create a container
        CREATE OBJECT O_DOCKINGCONTAINER
          EXPORTING
            RATIO                       = '95'
          EXCEPTIONS
            CNTL_ERROR                  = 1
            CNTL_SYSTEM_ERROR           = 2
            CREATE_ERROR                = 3
            LIFETIME_ERROR              = 4
            LIFETIME_DYNPRO_DYNPRO_LINK = 5
            OTHERS                      = 6.
    *    IF sy-subrc NE 0.
    *      MESSAGE i000 WITH text-e01."Error in creating Docking container
    *      LEAVE LIST-PROCESSING.
    *    ENDIF.
      ENDIF.
      CREATE OBJECT V_SPLIT
           EXPORTING
             PARENT            = O_DOCKINGCONTAINER
              ORIENTATION       = 0
             SASH_POSITION     = 25
             WITH_BORDER       = 1
           EXCEPTIONS
             CNTL_ERROR        = 1
             CNTL_SYSTEM_ERROR = 2
             OTHERS            = 3.
      IF SY-SUBRC NE 0.
    *      MESSAGE i000 WITH text-e01."Error in creating Docking container
        LEAVE LIST-PROCESSING.
      ENDIF.
    *   Get the containers of the splitter control
      V_CONTNR_TOP = V_SPLIT->TOP_LEFT_CONTAINER.
      V_CONTNR_BOT = V_SPLIT->BOTTOM_RIGHT_CONTAINER.
    *   CREATE OBJECT o_alvgrid
      CREATE OBJECT CUSTOM_ALVGRID_1
      EXPORTING
        I_PARENT = O_DOCKINGCONTAINER.
    *   Create an instance of alv control
      CREATE OBJECT CUSTOM_ALVGRID_1
      EXPORTING I_PARENT = V_CONTNR_BOT.
    *  CREATE OBJECT V_HTML_VIEW
    *    EXPORTING
    *      PARENT = V_CONTNR_TOP.
    *   Object for display of selection parameters in HTML top container
      CREATE OBJECT V_HTML
           EXPORTING
             STYLE = 'ALV_GRID'
             BACKGROUND_COLOR = cl_dd_document=>COL_TEXTAREA.
    *   Must be after the SET HANDLER for TOP_OF_PAGE and foreground only
      CALL METHOD CUSTOM_ALVGRID_1->LIST_PROCESSING_EVENTS
        EXPORTING
          I_EVENT_NAME = 'TOP_OF_PAGE'
          I_DYNDOC_ID  = V_HTML.
      CALL METHOD V_HTML->ADD_GAP
        EXPORTING
          WIDTH = 25.
      CALL METHOD V_HTML->ADD_PICTURE
        EXPORTING
          PICTURE_ID       = 'BD_LOGO_TEST'
          WIDTH            = '800'
    *        ALTERNATIVE_TEXT =
    *        TABINDEX         =
    *CALL METHOD V_HTML_VIEW->LOAD_DATA
    **  EXPORTING
    **    URL                  =
    **    TYPE                 = 'text'
    **    SUBTYPE              = 'html'
    **    SIZE                 = 0
    **    ENCODING             =
    **    CHARSET              =
    **    LANGUAGE             =
    **  IMPORTING
    **    ASSIGNED_URL         =
    *  CHANGING
    *    DATA_TABLE           = <ITAB>
    *  EXCEPTIONS
    *    DP_INVALID_PARAMETER = 1
    *    DP_ERROR_GENERAL     = 2
    *    CNTL_ERROR           = 3
    *    others               = 4
    *IF SY-SUBRC <> 0.
    ** MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    **            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    *ENDIF.
      CALL METHOD V_HTML->NEW_LINE.
    ** Display Text-016
    *    CALL METHOD v_html->add_gap
    *                EXPORTING
    *                  width         = 10.
      DATA:
        REPID    LIKE V_TEXT16,
        UNAME    LIKE V_TEXT16,
        SYSINFO  LIKE V_TEXT16,
        TITLE    LIKE V_TEXT16,
        MONTH    LIKE V_TEXT16,
        DAY      LIKE V_TEXT16,
        YEAR     LIKE V_TEXT16,
        DATUM    LIKE V_TEXT16,
        UZEIT    LIKE V_TEXT16.
      REPID = SY-REPID.
      TITLE = SY-TITLE.
      YEAR  = SY-DATUM(4).
      MONTH = SY-DATUM+4(2).
      DAY   = SY-DATUM+6(2).
      DATUM = SY-DATUM.
      uname = sy-uname.
      uzeit = sy-uzeit.
      CONCATENATE MONTH DAY YEAR INTO DATUM SEPARATED BY SLASH.
      CONCATENATE '  Run Date:   ' ' ' datum into datum.
      Concatenate '  Run Time:   ' uzeit(2) ':' uzeit+2(2) into uzeit.
      CALL METHOD V_HTML->ADD_GAP EXPORTING WIDTH = 10.
      CALL METHOD V_HTML->ADD_TEXT
        EXPORTING
          TEXT = 'Report Title:'.
      CALL METHOD V_HTML->NEW_LINE.
      CALL METHOD V_HTML->ADD_GAP EXPORTING WIDTH = 10.
      CALL METHOD V_HTML->ADD_TEXT
        EXPORTING
          TEXT = REPID.
      CALL METHOD V_HTML->NEW_LINE.
      CALL METHOD V_HTML->ADD_GAP EXPORTING WIDTH = 10.
      CALL METHOD V_HTML->ADD_TEXT
        EXPORTING
          TEXT = uname.
      CALL METHOD V_HTML->NEW_LINE.
      CALL METHOD V_HTML->ADD_GAP EXPORTING WIDTH = 10.
      CALL METHOD V_HTML->ADD_TEXT
        EXPORTING
          TEXT = uzeit.
      CALL METHOD V_HTML->NEW_LINE.
      CALL METHOD V_HTML->ADD_GAP EXPORTING WIDTH = 10.
      CALL METHOD V_HTML->ADD_TEXT
        EXPORTING
          TEXT = DATUM.
      CALL METHOD V_HTML->NEW_LINE.
    *  CALL METHOD V_HTML->ADD_LINK
    *    EXPORTING
    *     NAME                   = 'TEST'
    *       URL                    =
    *'http://adweek.blogs.com/photos/uncategorized/bk_birds.jpg'
    **      TOOLTIP                =
    *      TEXT                   = 'Test'
    **      DESTINATION_IN_DOC_SET =
    **      DESTINATION_IN_DOC_POS =
    **      TABINDEX               =
    **      HOTKEY                 =
    **   IMPORTING
    **      LINK                   =
      call method v_html->SET_DOCUMENT_BACKGROUND
        EXPORTING
          PICTURE_ID = space.
    * Display the data
      CALL METHOD V_HTML->DISPLAY_DOCUMENT
        EXPORTING
          PARENT = V_CONTNR_TOP
    *data visible(1) type c.
    *visible = v_html_view->visible_true.
    *  CALL METHOD V_HTML_VIEW->SET_VISIBLE
    *    EXPORTING
    *      VISIBLE = 'Y'.
    *   Handle the event
      CALL METHOD CUSTOM_ALVGRID_1->LIST_PROCESSING_EVENTS
        EXPORTING
          I_EVENT_NAME = 'PRINT_TOP_OF_PAGE'.
      CALL METHOD CUSTOM_ALVGRID_1->SET_TABLE_FOR_FIRST_DISPLAY
    *    IMPORTING
    *       is_variant                    = w_variant
    *       i_save                        = c_a
    *       is_layout                     = w_layout
        CHANGING
           IT_OUTTAB                     = <ITAB>
           IT_FIELDCATALOG               = GT_FIELDCAT_LVC[]
        EXCEPTIONS
           INVALID_PARAMETER_COMBINATION = 1
           PROGRAM_ERROR                 = 2
           TOO_MANY_LINES                = 3
           OTHERS                        = 4.
      IF SY-SUBRC <> 0.
    *    MESSAGE i000 WITH text-e06."Error in ALV report display
        LEAVE LIST-PROCESSING.
      ENDIF.
    * Create object
      IF V_EVENT_RECEIVER IS INITIAL.
        CREATE OBJECT V_EVENT_RECEIVER.
      ENDIF.
      SET HANDLER V_EVENT_RECEIVER->HANDLE_PRINT_TOP_OF_PAGE FOR
          CUSTOM_ALVGRID_1.
      SET HANDLER V_EVENT_RECEIVER->HANDLE_TOP_OF_PAGE FOR
          CUSTOM_ALVGRID_1.

    Hi
    An internal table can be converted into an HTML Template using the function Module WWW_HTML_FROM_LISTOBJECT. This will create an HTML template which will be stored in SMW0->(Zero)
    Now you can call this template in your header.
    Regards,
    Vara

  • Functionality of queries to be added to custom ALV GRID program

    I have got a requirement in which we have created a custom program. Earlier it used to be a query for that. Now the customer wants the same options such as ABC analysis , Graphics , Import to excel, word processing etc., options to be added to the custom program. What I have observed is that these are present in the  PF status of the ALV grid display which I am using . Is there any way to trigger the functionality of them directly after displaying the ALV. i.e. If the user wants to see the ABC analysis checks the option and we need to get the ABC analysis which is there in the ALV display

    Varun,
    I have never tried this but try callig the function LVC_ABC_ANALYSIS and pass the field catalog and the field on which you want to do the analysis, after the SET_TABLE_FOR_FIRST_DISPLAY method or the REUSE* function.
    Regards,
    Ravi
    Note : Please mark the helpful answers

  • Printing from ITS a custom ALV report

    Dear All,
    If anybody has any ideas on the following topic it would be appreciated.
    We have written a custom report that outputs in ALV, this is then rendered as service on our ITS server.
    The problem is that when you try to print the frame using standard browser printing it only prints what is on the screen.
    Are there any techniques to use to allow printing of all data that is returned to the browser?
    Thanks
    Matt

    Hi Matt,
    Printing from within the browser is always problematic. Therefore such print jobs are normally done by the SAP system and not by the browser. I would recommend to use the print button of the ALV grid for such printouts. You may either do a print out using a printer connected to the SAP system or may select a PDF printer. Using the PDF printer you can print out using your local printer connected to the PC. You may want to check note 351230 for systems with a basis up to release 6.20 and note 771683 for systems 6.40 and higher.
    Best regards,
    Klaus

  • How to design Customized ALV report like normal report !

    Hello Friends,
                  I like to design a ALV report, with sub headers, sub totals, summary total and other summary details like percentage sale, which is not relavent to the fields displayed in the ALV.
    I know it is possible to get total of the displayed field, but is it possible to design flexible ALV report like normal report.
    Could U please provide example code, if available.
    Thank you,
    Senthil

    HI,
    Just check this example.
    REPORT  ZLAXMI_ALVEXER2  MESSAGE-ID ZZ                       .
    *& TABLES DECLARATION                                                  *
    TABLES: VBAK.
    *& TYPE POOLS DECLARATION                                              *
    TYPE-POOLS: SLIS.
    *& INTERNAL TABLE DECLARATION                                          *
    DATA: BEGIN OF ITAB OCCURS 0,
           ICON TYPE ICON-ID,
           VBELN LIKE VBAK-VBELN,
           AUDAT LIKE VBAK-AUDAT,
           VBTYP LIKE VBAK-VBTYP,
           AUART LIKE VBAK-AUART,
           AUGRU LIKE VBAK-AUGRU,
           NETWR LIKE VBAK-NETWR,
           WAERK LIKE VBAK-WAERK,
        END OF ITAB.
    *INTERNAL TABLE FOR FIELD CATALOG
    DATA: WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
        IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
    IT_FIELDCAT TYPE STANDARD TABLE OF SLIS_FIELDCAT_ALV
               WITH HEADER LINE,
    *INTERNAL TABLE FOR EVENTS
    DATA:    IT_EVENT TYPE SLIS_T_EVENT,
          WA_EVENT TYPE SLIS_ALV_EVENT,
    *INTERNAL TABLE FOR SORTING
          IT_SORT TYPE SLIS_T_SORTINFO_ALV,
          WA_SORT TYPE SLIS_SORTINFO_ALV,
    *INTERNAL TABLE FOR LAYOUT
          WA_LAYOUT TYPE SLIS_LAYOUT_ALV.
    *& VARIABLE DECLARATION                                                *
    DATA : V_REPID TYPE SY-REPID,
           V_PAGNO(4) TYPE N,
           V_DATE(8)  TYPE C.
    *& CONSTANTS                                                           *
    CONSTANTS: C_X TYPE C VALUE 'X'.
    *& SELECTION SCREEN                                                    *
    SELECTION-SCREEN: BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    SELECT-OPTIONS: S_VBELN FOR VBAK-VBELN,
                    S_VBTYP FOR VBAK-VBTYP DEFAULT 'C'.
    SELECTION-SCREEN: END OF BLOCK B1.
    SELECTION-SCREEN: BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-002.
    SELECTION-SCREEN : BEGIN OF LINE.
    SELECTION-SCREEN  COMMENT 1(20) TEXT-003.
    PARAMETERS: P_LIST RADIOBUTTON GROUP RAD1 DEFAULT 'X'.
    SELECTION-SCREEN : END OF LINE.
    SELECTION-SCREEN : BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 1(20) TEXT-004.
    PARAMETERS: P_GRID RADIOBUTTON GROUP RAD1.
    SELECTION-SCREEN : END OF LINE.
    SELECTION-SCREEN: END OF BLOCK B2.
    AT SELECTION-SCREEN.
      PERFORM VALIDATE_SCREEN.
    *& START OF SELECTION                                               *
    START-OF-SELECTION.
      CLEAR: ITAB, ITAB[].
    V_REPID = SY-REPID.
      PERFORM GET_DATA.
      PERFORM DISPLAY_DATA.
    *& END OF SELECTION                                                    *
    END-OF-SELECTION.
    *--DO ALV Process
      V_REPID = SY-REPID.
    *--Sort the Output Fields
      PERFORM SORT_FIELDS.
    *--Build Field catalog for the Output fields
    PERFORM BUILD_FIELDCAT.
    *--Set the Layout for ALV
      PERFORM SET_LAYOUT.
    *&      Form  GET_DATA
          text
    TO GET THE DATA FROM TABLES INTO ITAB
    FORM GET_DATA .
      SELECT VBELN
             AUDAT
             VBTYP
             AUART
             AUGRU
             NETWR
             WAERK
             INTO CORRESPONDING FIELDS OF TABLE ITAB
             FROM VBAK
             WHERE VBELN IN S_VBELN AND
             AUDAT > '04.04.2005'
             AND NETWR > 0.
      LOOP AT ITAB.
        IF ITAB-NETWR < 10000.
          ITAB-ICON = '@08@'.
        ELSEIF ITAB-NETWR > 10000 AND ITAB-NETWR < 100000.
          ITAB-ICON = '@09@'.
        ELSEIF ITAB-NETWR > 100000.
          ITAB-ICON = '@0A@'.
        ENDIF.
        MODIFY ITAB INDEX SY-TABIX.
      ENDLOOP.
    ENDFORM.                    " GET_DATA
    *&      Form  sort_fields
    FORM SORT_FIELDS .
      CLEAR WA_SORT.
      WA_SORT-FIELDNAME = 'VBTYP'.
      WA_SORT-SPOS = '1'.
      WA_SORT-UP = 'X'.
      APPEND WA_SORT TO IT_SORT.
      CLEAR WA_SORT.
      WA_SORT-FIELDNAME = 'NETWR'.
      WA_SORT-SPOS = '2'.
      WA_SORT-UP = 'X'.
      WA_SORT-SUBTOT = 'X'.
      APPEND WA_SORT TO IT_SORT.
    ENDFORM.                    " sort_fields
    *&      Form  build_fieldcat
    *FORM BUILD_FIELDCAT .
    IT_FIELDCAT-COL_POS    = '1'.
    IT_FIELDCAT-FIELDNAME  = 'ICON'.
    IT_FIELDCAT-KEY        = 'X'.
    IT_FIELDCAT-OUTPUTLEN  = '10'.
    IT_FIELDCAT-SELTEXT_L  = 'LIGHT'.
    APPEND IT_FIELDCAT.
    CLEAR  IT_FIELDCAT.
    IT_FIELDCAT-COL_POS    = '2'.
    IT_FIELDCAT-FIELDNAME  = 'VBELN'.
    IT_FIELDCAT-KEY        = 'X'.
    IT_FIELDCAT-OUTPUTLEN  = '10'.
    IT_FIELDCAT-SELTEXT_L  = 'SALES DOC NUMBER'(009).
    APPEND IT_FIELDCAT.
    CLEAR  IT_FIELDCAT.
    IT_FIELDCAT-COL_POS    = '3'.
    IT_FIELDCAT-FIELDNAME  = 'AUDAT'.
    IT_FIELDCAT-KEY        = 'X'.
    IT_FIELDCAT-OUTPUTLEN  = '4'.
    IT_FIELDCAT-SELTEXT_L  = 'DOCUMENT DATE'(010).
    APPEND IT_FIELDCAT.
    CLEAR  IT_FIELDCAT.
    IT_FIELDCAT-COL_POS    = '4'.
    IT_FIELDCAT-FIELDNAME  = 'VBTYP'.
    IT_FIELDCAT-KEY        = 'X'.
    IT_FIELDCAT-OUTPUTLEN  = '4'.
    IT_FIELDCAT-SELTEXT_L  = 'CATEGORY'(011).
    APPEND IT_FIELDCAT.
    CLEAR  IT_FIELDCAT.
    IT_FIELDCAT-COL_POS    = '5'.
    IT_FIELDCAT-FIELDNAME  = 'AUART'.
    IT_FIELDCAT-OUTPUTLEN  = '4'.
    IT_FIELDCAT-SELTEXT_L  = 'DOCUMENT TYPE'(012).
    APPEND IT_FIELDCAT.
    CLEAR  IT_FIELDCAT.
    IT_FIELDCAT-COL_POS    = '6'.
    IT_FIELDCAT-FIELDNAME  = 'AUGRU'.
    IT_FIELDCAT-OUTPUTLEN  = '12'.
    IT_FIELDCAT-SELTEXT_L  = 'Order reason'(013).
    APPEND IT_FIELDCAT.
    CLEAR  IT_FIELDCAT.
    IT_FIELDCAT-COL_POS    = '7'.
    IT_FIELDCAT-FIELDNAME  = 'NETWR'.
    IT_FIELDCAT-OUTPUTLEN  = '12'.
    IT_FIELDCAT-SELTEXT_L  = 'NET VALUE'(014).
    APPEND IT_FIELDCAT.
    CLEAR  IT_FIELDCAT.
    IT_FIELDCAT-COL_POS    = '8'.
    IT_FIELDCAT-FIELDNAME  = 'WAERK'.
    IT_FIELDCAT-OUTPUTLEN  = '12'.
    IT_FIELDCAT-SELTEXT_L  = 'SD DOC CURR'(015).
    APPEND IT_FIELDCAT.
    CLEAR  IT_FIELDCAT.
    *ENDFORM.                    " build_fieldcat
    *&      Form  set_layout
    FORM SET_LAYOUT .
      IF P_LIST = C_X .
        WA_LAYOUT-WINDOW_TITLEBAR = 'LIST DISPLAY'(016).
        WA_LAYOUT-ZEBRA = 'X'.
    *-- ALV LIST DISPLAY
        PERFORM LIST_DISPLAY TABLES ITAB.
    *-- ALV GRID DISPLAY
      ELSEIF P_GRID = C_X.
        WA_LAYOUT-WINDOW_TITLEBAR = 'GRID DISPLAY'(017).
        WA_LAYOUT-ZEBRA = 'X'.
        PERFORM GRID_DISPLAY TABLES ITAB.
      ENDIF.
    ENDFORM.                    " set_layout
    *&      Form  list_display
    FORM LIST_DISPLAY  TABLES   P_ITAB .
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
        EXPORTING
          I_CALLBACK_PROGRAM = V_REPID
          IS_LAYOUT          = WA_LAYOUT
          IT_FIELDCAT        = IT_FIELDCAT[]
          IT_SORT            = IT_SORT[]
          I_SAVE             = 'U'
        TABLES
          T_OUTTAB           = ITAB
        EXCEPTIONS
          PROGRAM_ERROR      = 1
          OTHERS             = 2.
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " list_display
    *&      Form  GRID_DISPLAY
    FORM GRID_DISPLAY  TABLES   P_ITAB .
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          I_CALLBACK_PROGRAM = V_REPID
          IS_LAYOUT          = WA_LAYOUT
          IT_FIELDCAT        = IT_FIELDCAT[]
          IT_SORT            = IT_SORT[]
          IT_EVENTS          = IT_EVENT
        TABLES
          T_OUTTAB           = ITAB
        EXCEPTIONS
          PROGRAM_ERROR      = 1
          OTHERS             = 2.
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " GRID_DISPLAY
    *&      Form  VALIDATE_SCREEN
          text
    -->  p1        text
    <--  p2        text
    FORM VALIDATE_SCREEN .
      DATA: LV_VBELN LIKE VBAK-VBELN.
      IF NOT S_VBELN IS INITIAL.
        SELECT VBELN
        INTO LV_VBELN
        UP TO 1 ROWS
        FROM VBAK
        WHERE VBELN IN S_VBELN.
        ENDSELECT.
        IF SY-SUBRC <> 0.
          MESSAGE E000 WITH 'INVALID SALES DOC'.
        ENDIF.
      ENDIF.
    ENDFORM.                    " VALIDATE_SCREEN
    *&      Form  display_data
          text
    -->  p1        text
    <--  p2        text
    FORM DISPLAY_DATA .
      DEFINE M_FIELDCAT.
        ADD 1 TO WA_FIELDCAT-COL_POS.
        WA_FIELDCAT-FIELDNAME   = &1.
        WA_FIELDCAT-REF_TABNAME = 'VBAK'.
        WA_FIELDCAT-DO_SUM      = &2.
        WA_FIELDCAT-CFIELDNAME  = &3.
        APPEND WA_FIELDCAT TO IT_FIELDCAT.
      END-OF-DEFINITION.
    DATA:
        LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
        LT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
      M_FIELDCAT 'ICON' ''  ''.
      M_FIELDCAT 'VBELN' ''  ''.
      M_FIELDCAT 'AUDAT' ''  ''.
      M_FIELDCAT 'VBTYP' ''  ''.
      M_FIELDCAT 'AUART' ''  ''.
      M_FIELDCAT 'AUGRU' ''  ''.
      M_FIELDCAT 'NETWR' 'C' 'WAERK'.
      M_FIELDCAT 'WAERK' ''  ''.
    ENDFORM.                    " display_data
    Regards
    Laxmi

  • Short dump when exporting the ALV grid report in to spread sheet

    HI,
    I am facing a problem when downloading ALV grid report in to spread sheet LIST>EXPORT>LOCAL FILE -->SPREADSHEET.
    in shotdump the cursor shows : "assign cline+cbegin(clength) to <field_cont>."
    In SAP internal table LIST,in the first record the value of the filed LENG is 0. when i have changed this value ex:10 etc it is coming properly.
    Kindly help me
    Nagendra

    Is this a standard SAP report, or your own? Can you tell what your report does, if it is a custom ALV report?

  • Reserved lines in ALV report

    Hi Experts,
    I have written few lines of code in "HTML_TOP_OF_PAGE" sub routine. This subroutine I am using in ALV. like below...
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          I_CALLBACK_PROGRAM                  = G_REPID
          I_CALLBACK_HTML_TOP_OF_PAGE = 'HTML_TOP_OF_PAGE'
          IS_LAYOUT                                       = GS_LAYOUT
          IT_FIELDCAT                                    = IT_FIELDS
          IT_SORT                                           = IT_SORT
          I_SAVE                                             = 'A'
          IS_VARIANT                                      = G_VARIANT
        TABLES
          T_OUTTAB                                        = ITAB
        EXCEPTIONS
          PROGRAM_ERROR                           = 1
          OTHERS                                           = 2.
    I would like to reserve some lines for the top of page. i mean After displaying the data in top of page, ITAB data should be displayed.Now we can only visible three lines data only. still there are six lines are there. After displaying another six lines the Itab data should be displayed in ALV table.
    Of course, we can drag down my data table. But user doesn't want to see without any efforts.
    Pls help me.
    Thanks in advance
    Raghu

    CALL METHOD document->add_gap
        EXPORTING
          width = 50. should help you..
    FORM html_top_of_page USING document TYPE REF TO cl_dd_document.
      DATA: text TYPE sdydo_text_element.
      CALL METHOD document->add_gap
        EXPORTING
          width = 100.
      text =  'Jay custom ALV'.
      CALL METHOD document->add_text
        EXPORTING
          text      = text
          sap_style = 'HEADING'.
      CALL METHOD document->new_line.
      CALL METHOD document->new_line.
      CALL METHOD document->new_line.
      text = 'User Name : '.
      CALL METHOD document->add_text
        EXPORTING
          text         = text
          sap_emphasis = 'Strong'.
      CALL METHOD document->add_gap
        EXPORTING
          width = 6.
      text = sy-uname.
      CALL METHOD document->add_text
        EXPORTING
          text      = text
          sap_style = 'Key'.
      CALL METHOD document->add_gap
        EXPORTING
          width = 50.
      text = 'Date : '.
      CALL METHOD document->add_text
        EXPORTING
          text         = text
          sap_emphasis = 'Strong'.
      CALL METHOD document->add_gap
        EXPORTING
          width = 6.
      DATA: zword TYPE string, zdd TYPE string, zmmm TYPE string,
            zyyyy TYPE string, zfin TYPE string.
      CALL FUNCTION 'CONVERSION_EXIT_IDATE_OUTPUT'
        EXPORTING
          input  = sy-datum
        IMPORTING
          output = zword.
      zdd = zword+3(2).
      zmmm = zword+0(3).
      zyyyy = zword+7(2).
      CONCATENATE zdd '-' zmmm '-' zyyyy INTO zfin.
      text = zfin.
      CALL METHOD document->add_text
        EXPORTING
          text      = text
          sap_style = 'Key'.
      CALL METHOD document->add_gap
        EXPORTING
          width = 50.
      text = 'Time : '.
      CALL METHOD document->add_text
        EXPORTING
          text         = text
          sap_emphasis = 'Strong'.
      CALL METHOD document->add_gap
        EXPORTING
          width = 6.
      text = sy-uzeit.
      CALL METHOD document->add_text
        EXPORTING
          text      = text
          sap_style = 'Key'.
      CALL METHOD document->new_line.
      text = lv_count.
      CALL METHOD document->add_text
        EXPORTING
          text      = text
          sap_style = 'Key'.
      CALL METHOD document->new_line.
    ENDFORM.                    "HTML_TOP_OF_PAGE

  • Field value is not coming in my customize ALV report

    Hi All,
    Good day.
    I have added two fields in a customized ALV report. But the customized report was not developed by me. Therefore I am unable to understand the whole report. As per my requirement I have added 2 fields more like* quantity* & unit field in that ALV. But not understanding why values are not coming in my report though values are there in DB. Plz help me regarding this. The portion of the code is given below.
    SORT t_ekbe by belnr.
      loop at t_ekbe INTO w_ekbe where vgabe = '1'.
        on CHANGE OF w_ekbe-belnr.
          SELECT  MBLNR
            BWART
            SMBLN
            ERFMG   " This is the new added field
            erfme     " This is the new added field
          INTO CORRESPONDING FIELDS OF TABLE t_mseg
          from mseg
          where mblnr = t_ekbe-belnr
          AND   bwart = '101'.
        endon.
      ENDLOOP.
    Thanks,
    Tripod.

    hi ,
    Do according to this
    SORT t_ekbe by belnr.
      if  t_ekbe[] is not initial  .
          SELECT  MBLNR
            BWART
            SMBLN
            ERFMG   " This is the new added field
            erfme     " This is the new added field
          INTO CORRESPONDING FIELDS OF TABLE t_mseg
        for all entries in t_ekbe
          from mseg
          where mblnr = t_ekbe-belnr
          AND   bwart = '101'.
      endif.
    after this
    loop at t_ekbe .
    loop at t_mseg  where mblnr  = t_ekbe-belnr .
      t_ekbe-ERFMG = t_mseg-ERFMG .
    t_ekbe-erfme =   t_mseg-erfme  .
    modify t_ekbe transporting ERFMG  erfme .
    clear t_mseg .
    endloop.
    clear t_ekbe .
    endloop.
    Regards
    Deepak .

  • Error when OO ALV report run in background

    Hello all,
    We recently applied stack 12 for a 7.0 system.  My custom ALV report using CL_GUI_CUSTOM_CONTAINER coding now returns an error when run in Background.  It works fine in dialog.
    The error occurred in program CL_GUI_CUSTOM_CONTAINER=======CP.  The log message was "Control Framework: Fatal error - GUI cannot be reached".
    Is there a solution for OO ALV reports run in the background?  I would not like to re-write my ALV reports using the function call.  Any advice is appreciated.  Thanks!!

    Yes, you need to code it a little differently, but you can still use CL_GUI_ALV_GRID.  Here is an example. 
    REPORT ZRICH_0006 .
    DATA: ITAB TYPE TABLE OF MARA.
    DATA: R_GRID TYPE REF TO CL_GUI_ALV_GRID.
    DATA: R_CONTROL TYPE REF TO CL_GUI_CUSTOM_CONTAINER.
    DATA: G_DOCK TYPE REF TO CL_GUI_DOCKING_CONTAINER.
    DATA: OKCODE type sy-ucomm.
    START-OF-SELECTION.
      SELECT * FROM MARA INTO TABLE ITAB  up to 100 rows.
      CALL SCREEN 100.
    *& Module STATUS_0100 OUTPUT
    * text
    MODULE STATUS_0100 OUTPUT.
      SET PF-STATUS '0100'.
      SET TITLEBAR '0100'.
      IF R_CONTROL IS INITIAL.
    * Check whether the program is run in batch or foreground
        IF CL_GUI_ALV_GRID=>OFFLINE( ) IS INITIAL.
    * Run in foreground
          CREATE OBJECT R_CONTROL EXPORTING CONTAINER_NAME = 'CONTAINER_1'.
          CREATE OBJECT R_GRID EXPORTING I_PARENT = R_CONTROL.
        ELSE.
    * Run in background
          CREATE OBJECT R_GRID EXPORTING I_PARENT = G_DOCK.
        ENDIF.
        CALL METHOD R_GRID->SET_TABLE_FOR_FIRST_DISPLAY
        EXPORTING
        I_STRUCTURE_NAME = 'MARA'
        CHANGING
        IT_OUTTAB = ITAB.
      ENDIF.
    ENDMODULE. " STATUS_0100 OUTPUT
    *& Module USER_COMMAND_0100 INPUT
    * text
    MODULE USER_COMMAND_0100 INPUT.
      CASE OKCODE.
        WHEN 'BACK'.
          leave program.
      ENDCASE.
    ENDMODULE. " USER_COMMAND_0100 INPUT
    Regards,
    Rich Heilman

  • ALV List export to Excel when program is run in background

    Hello,
    I am running into an issue with a custom ALV report which contains an export to Excel option on the input screen. However, when I attempt to run the report in background due to high volume of records/expected performance constraints, the job fails to produce a spool when the "export to Excel" option is selected. When I deselect that option, the background job successfully generates a spool, which I can then export to Excel (albeit the formatting will not look the same).
    Is the above an accurate statement or does anyone know of a way where either;
    1) The background job can create and store the Excel output into a cached directory?
    2) The spool generated, when exported to Excel, can match the format of the foreground Excel output?
    Thanks in advancce.

    Check out the sample program of the provided link ..
    http://www.sap-img.com/abap/download-in-background-in-excel-format.htm

  • Problem with Custom container - cl_gui_custom_container/cl_gui_alv_grid

    Hi,
    I want to reuse the same custom container screen for a different data.
    First screen there will be button 1 and button 2
    if I click button 1 then calculate and display data  in custom container, if button 2 is clicked then calculate and display data with  in the same custom container.
    For this
    1. Created Custom container - CONTAINER
    2. In program defined and created custom container and custom alv grid
    g_custom_container TYPE REF TO cl_gui_custom_container,
            alv_grid                     TYPE REF TO cl_gui_alv_grid.
           IF g_custom_container IS INITIAL.
                CREATE OBJECT g_custom_container
                    EXPORTING
                  container_name = 'CONTAINER'.
                CREATE OBJECT alv_grid
                   EXPORTING
                    i_parent = g_custom_container.
          ENDIF.
    3. Display data using CALL METHOD alv_grid->set_table_for_first_display
       every thing works great for button 1
    4. when button 2 is clicked then calculate and display different set of data in same custom container which is used earlier.
    5. here I used
    call method alv_grid->free.
        call method g_custom_container->free.
    6. create above objects once again and tried to use
    call method alv_grid->set_table_for_first_display
    , to reuse the same custom container 'CONTAINER' again for a different set of data and getting ABAP dump.
    In debug mode, when I used the above method FREE for both ALV_GRID and G_CUSTOM_CONTAINER objects are not clearing.
    Please let me know how can I reuse the same container for a different set of data when button2 is pressed.
    Thanks in advance,
    Krishna
    Please use code tags to format your code and post in the correct forum
    Edited by: Rob Burbank on Oct 1, 2010 2:37 PM

    Hello Krishna
    I would recommend to use a different approach instead of trying to initialize your container instances:
    DATA:
      go_container_1 TYPE REF TO cl_gui_custom_container,
      go_container_2 TYPE REF TO cl_gui_custom_container,
      go_grid_1          TYPE REF TO cl_gui_alv_grid,
      go_grid_2          TYPE REF TO cl_gui_alv_grid.
    " NOTE: Do this coding BEFORE calling the screen
    * (1) Create 2 containers
    CREATE OBJECT g_container_1
                    EXPORTING
                  container_name = 'CONTAINER'.
    CREATE OBJECT g_container_2
                    EXPORTING
                  container_name = 'CONTAINER'.
    " NOTE: If it is not possible to use the same container name then either create an additional
    "            dummy screen having a second CUSTOM_CONTROL element or replace
    " the customer containers with docking containers -> here you do not need to give a container name
    * (2) Create 2 grid instances using a different container
    * (3) Link the first container to the screen using its LINK method:
      CALL METHOD go_container_1
        EXPORTING
           repid = <...>
          dynnr = <...>.
    * (4) Perhaps you need to define a second dummy screen to which you link the second container
    * (5) Display first grid instance (as default)
    Now when the user pushes button 2 (to display the second grid) link container_1 to the dummy screen
    and link container_2 to your main screen.
    Regards
      Uwe

  • ALV - Excel download Date field sits in the last Column

    Hi,
    I have custom ALV grid report using OOp . From the report i am exporting the results to an EXCEL, but the date columns in the report sits as last column the exported excel.
    Any idea ?
    Thanks
    aRs

    That is the default functionality of the ALV grid, it collects all the similar data types together and then donwloads the data.
    If you don't want that, you will have write code yourself and download the data
    Regards,
    Ravi
    Note - Please mark all the helpful answers

  • What event will be triggered by check button on ALV?

    Hi,
    What event will be triggered by the standard check button on ALV? ON_DATA_CHECK is only triggered by a change in an editable field on ALV, so if no change were made, ON_DATA_CHECK wouldn't be triggered. I also tried events for before and after standard function but neither were triggered. How can I use the standard check function?
    Regards,
    ts

    Hi ts,
    The event ON_DATA_CHECK would trigger only if the content on alv is dirtly i.e. user modified something.
    If there are no changes done for the contents, whats your requirement to use check button?
    You can create a custom alv toolbar button and use event ON_FUNCTION on click of tool bar button.
    Regards,
    Rama

  • Grand total (of all columns) in ALV grid

    Hi Experts,
    I have developed one custom ALV report in GRID format. Now Report output is displaying like below.
    COL1 |   COL2  |    COL3  |  COL4 |
    TYPE1  |   10   |           44  |          05 |
    TYPE2  |    01  |           20  |          35 |
    TYPE3  |   05   |          10   |         20  |
    =============================
       sum  |     16  |          74   |  50  |
    But I need Grand Total for COL2 and COL3 and COL4 (i.e 16 + 74 + 50 )
    This grand total line should be at the end of the internal table -- 140 .
    The report output should be like below.....
    COL1 |   COL2  |    COL3  |  COL4 |
    TYPE1  |   10   |           44  |          05 |
    TYPE2  |    01  |           20  |          35 |
    TYPE3  |   05   |          10   |         20  |
    =============================
       sum  |     16  |          74   |  50  |           ====> this sum will displayed when user select sum button on the Grid toolbar.
    =============================
    Grand Total   140 |
    Suppose when I press sum button on the COL2. it should not change grand total. I mean Grand total should be like footer always.
    Please advise
    Thanks in advance.
    Raghu

    Hi
    For your requirment ,you have to fill the field catalog for each field for which
    you have to create the the grand total and check the option DO_SUM.
    If you neeed the sub total ,in the sort table you can check the option- fs_sort-subtot = 'X'.
    Just try the belo code .
    It will solve your problem.
    REPORT ztest.
    * INTERNAL TABLE DECLARATION.
    DATA:
    t_sflight TYPE TABLE OF sflight,
    fs_sflight TYPE sflight.
    *OBJECTS FOR CONTAINER AND GRID.
    DATA:
    r_container1 TYPE REF TO cl_gui_custom_container,
    r_grid1 TYPE REF TO cl_gui_alv_grid.
    *FIELD CATALOG
    DATA:
    t_fcat TYPE lvc_t_fcat,
    fs_fcat TYPE lvc_s_fcat.
    fs_fcat-fieldname = 'SEATSMAX'.
    fs_fcat-do_sum = 'X'.
    APPEND fs_fcat TO t_fcat.
    CLEAR fs_fcat.
    fs_fcat-fieldname = 'PRICE'.
    fs_fcat-do_sum = 'X'.
    APPEND fs_fcat TO t_fcat.
    CLEAR fs_fcat.
    * SORT TABLE
    DATA:
    t_sort TYPE lvc_t_sort,
    fs_sort TYPE lvc_s_sort.
    * LAYOUT TABLE
    DATA:
    fs_layo TYPE lvc_s_layo.
    *FS_LAYO-SGL_CLK_HD = 'X'.
    fs_layo-zebra = 'X'.
    fs_sort-spos ='1'.
    fs_sort-fieldname = 'CARRID'.
    fs_sort-down = 'X'.
    fs_sort-group = '*'.
    *fs_sort-subtot = 'X'.
    APPEND fs_sort TO t_sort.
    SELECT * FROM sflight INTO TABLE t_sflight.
    CALL SCREEN 100.
    *&      Module  STATUS_0100  OUTPUT
    *       text
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'SCREEN1'.
      SET TITLEBAR 'TITLE1'.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
    *       text
    MODULE user_command_0100 INPUT.
      CASE sy-ucomm.
        WHEN 'BACK'.
          LEAVE TO SCREEN 0.
      ENDCASE.
    ENDMODULE.                    "user_command_0100 INPUT
    **&      Module  HANDLER  OUTPUT
    **       text
    MODULE  header  OUTPUT.
      CREATE OBJECT r_container1
        EXPORTING
          container_name = 'CONTAINER'.
      CREATE OBJECT r_grid1
        EXPORTING
          i_parent = r_container1.
      CALL METHOD r_grid1->set_table_for_first_display
        EXPORTING
          is_layout        = fs_layo
          i_structure_name = 'SFLIGHT'
        CHANGING
          it_fieldcatalog  = t_fcat
          it_outtab        = t_sflight
          it_sort          = t_sort.
    ENDMODULE.                    "Header OUTPUT
    Regards
    Hareesh.

  • FPL9 Account Display - Basic List in custom screen

    Hi,
    I have requirement in which I need to create a screen which displays latest entries of FPL9 in with all cosmetics like color, traffic lights etc.
    Is there any FM / Program which can create this type of list directly or is custom ALV list to be created.
    If I want to create it manually then what will be the logic to arrange entries fetched from DFKKOP, DFKKKO, DFKKOPK?
    Thanks in advance.
    Regards,
    Murtuza

    Hi Murtuza,
    U can use the FM   FKK_ACCOUNT_BALANCE_COMPUTE  and use the field AMPEL for traffic light.
    Regards,
    AnUrAg

Maybe you are looking for

  • Issue about 10.1 Sync with google contacts

    here's the situation: i bought my Q10 came with OS238, when i set google account up with IMAP, all the email, calendar, and contacts would sync ONCE, which means i got all my contacts from google on my Q10. however, when i add or modify any contact o

  • Finally A Fast Browser with Flash Support

    Recently I ran across a very nice browser that load all pages without no hesitation... Even Verizon's for web browsing page.. This browsers very simple in design but can exceed all other browsers....  all pages load fast and all contents is accessibl

  • Adobe Reader fails to load Core DLL

    I'm at my wits end here. For some unknown reason my Win 7 Home Premium 64-bit Dell laptop has started popping up  the following message about Protected Mode. If I choose Do Not open, then Reader just closes. If I choose Open with PM disabled, I get:

  • Transfer Printer Settings to Another Mac

    Hello - I have a few printers to configure among twelve different Macs. All Macs run Tiger. How could I configure the printers once, and copy the settings to the other macs? Thanks

  • CSS Background frustrations

    Hi Guys, I've come across an issue I regularly have and am determined to find out why and to solve it. Basically, the problem is applying background images to divs. Works fine in IE but never in FF. FireFox takes it's positioning from the top left ha