Skip to Content
author's profile photo Former Member
Former Member

alv

hi

can i have a ALV report making use of

1) sort in ascending/descending order

2) filter data

3)total summation

4) subtotal

5)select more fields to display in the report

6) choose display variant

7) export data to text file,excel, rich format etc

8) save data to ms-excel

9) save data to ms-word

10) email

regards,

kb

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Apr 03, 2008 at 11:00 AM

    HI,

    *&---------------------------------------------------------------------*
    *& Report  ZZ_22038_22098_002                                          *
    *&                                                                     *
    *&---------------------------------------------------------------------*
    *& This is an Interactive ALV report, where on line slection we can see
    *&  the secondry list
    *&
    *&                                                                     *
    *&---------------------------------------------------------------------*
    
    REPORT  ZZ_22038_22098_002 NO STANDARD PAGE HEADING LINE-SIZE 650
    MESSAGE-ID ZZ_9838                      .
    
    TYPE-POOLS: SLIS.
    *type declaration for values from ekko
    TYPES: BEGIN OF I_EKKO,
           EBELN LIKE EKKO-EBELN,
           AEDAT LIKE EKKO-AEDAT,
           BUKRS LIKE EKKO-BUKRS,
           BSART LIKE EKKO-BSART,
           LIFNR LIKE EKKO-LIFNR,
           END OF I_EKKO.
    
    DATA: IT_EKKO TYPE STANDARD TABLE OF I_EKKO INITIAL SIZE 0,
          WA_EKKO TYPE I_EKKO.
    
    *type declaration for values from ekpo
    TYPES: BEGIN OF I_EKPO,
           EBELN LIKE EKPO-EBELN,
           EBELP LIKE EKPO-EBELP,
           MATNR LIKE EKPO-MATNR,
           MENGE LIKE EKPO-MENGE,
           MEINS LIKE EKPO-MEINS,
           NETPR LIKE EKPO-NETPR,
           END OF I_EKPO.
    
    DATA: IT_EKPO TYPE STANDARD TABLE OF I_EKPO INITIAL SIZE 0,
          WA_EKPO TYPE I_EKPO .
    
    *variable for Report ID
    DATA: V_REPID LIKE SY-REPID .
    
    *declaration for fieldcatalog
    DATA: I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
          WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
    
    
    DATA: IT_LISTHEADER TYPE SLIS_T_LISTHEADER.
    
    * declaration for events table where user comand or set PF status will
    * be defined
    DATA: V_EVENTS TYPE SLIS_T_EVENT,
          WA_EVENT TYPE SLIS_ALV_EVENT.
    
    * declartion for layout
    DATA: ALV_LAYOUT TYPE SLIS_LAYOUT_ALV.
    
    * declaration for variant(type of display we want)
    DATA: I_VARIANT TYPE DISVARIANT,
          I_VARIANT1 TYPE DISVARIANT,
          I_SAVE(1) TYPE C.
    
    *PARAMETERS : p_var TYPE disvariant-variant.
    
    *Title displayed when the alv list is displayed
    DATA:  I_TITLE_EKKO TYPE LVC_TITLE VALUE 'FIRST LIST DISPLAYED'.
    DATA:  I_TITLE_EKPO TYPE LVC_TITLE VALUE 'SECONDRY LIST DISPLAYED'.
    
    INITIALIZATION.
      V_REPID = SY-REPID.
      PERFORM BUILD_FIELDCATLOG.
      PERFORM EVENT_CALL.
      PERFORM POPULATE_EVENT.
    
    START-OF-SELECTION.
      PERFORM DATA_RETRIEVAL.
      PERFORM BUILD_LISTHEADER USING IT_LISTHEADER.
      PERFORM DISPLAY_ALV_REPORT.
    
    *&--------------------------------------------------------------------*
    *&      Form  BUILD_FIELDCATLOG
    *&--------------------------------------------------------------------*
    *       Fieldcatalog has all the field details from ekko
    *---------------------------------------------------------------------*
    FORM BUILD_FIELDCATLOG.
      WA_FIELDCAT-TABNAME = 'IT_EKKO'.
      WA_FIELDCAT-FIELDNAME = 'EBELN'.
      WA_FIELDCAT-SELTEXT_M = 'PO NO.'.
      APPEND WA_FIELDCAT TO I_FIELDCAT.
      CLEAR WA_FIELDCAT.
    
      WA_FIELDCAT-TABNAME = 'IT_EKKO'.
      WA_FIELDCAT-FIELDNAME = 'AEDAT'.
      WA_FIELDCAT-SELTEXT_M = 'DATE.'.
      APPEND WA_FIELDCAT TO I_FIELDCAT.
      CLEAR WA_FIELDCAT.
    
      WA_FIELDCAT-TABNAME = 'IT_EKKO'.
      WA_FIELDCAT-FIELDNAME = 'BUKRS'.
      WA_FIELDCAT-SELTEXT_M = 'COMPANY CODE'.
      APPEND WA_FIELDCAT TO I_FIELDCAT.
      CLEAR WA_FIELDCAT.
    
    WA_FIELDCAT-TABNAME = 'IT_EKKO'.
      WA_FIELDCAT-FIELDNAME = 'BUKRS'.
      WA_FIELDCAT-SELTEXT_M = 'DOCMENT TYPE'.
      APPEND WA_FIELDCAT TO I_FIELDCAT.
      CLEAR WA_FIELDCAT.
    
    WA_FIELDCAT-TABNAME = 'IT_EKKO'.
      WA_FIELDCAT-FIELDNAME = 'LIFNR'.
      WA_FIELDCAT-NO_OUT    = 'X'.
      WA_FIELDCAT-SELTEXT_M = 'VENDOR CODE'.
      APPEND WA_FIELDCAT TO I_FIELDCAT.
      CLEAR WA_FIELDCAT.
    
    
    ENDFORM.                    "BUILD_FIELDCATLOG
    
    *&--------------------------------------------------------------------*
    *&      Form  EVENT_CALL
    *&--------------------------------------------------------------------*
    *   we get all events - TOP OF PAGE or USER COMMAND in table v_events
    *---------------------------------------------------------------------*
    FORM EVENT_CALL.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
       EXPORTING
         I_LIST_TYPE           = 0
       IMPORTING
         ET_EVENTS             = V_EVENTS
    *  EXCEPTIONS
    *    LIST_TYPE_WRONG       = 1
    *    OTHERS                = 2
                .
      IF SY-SUBRC <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    "EVENT_CALL
    
    *&--------------------------------------------------------------------*
    *&      Form  POPULATE_EVENT
    *&--------------------------------------------------------------------*
    *      Events populated for TOP OF PAGE & USER COMAND
    *---------------------------------------------------------------------*
    FORM POPULATE_EVENT.
      READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.
      IF SY-SUBRC EQ 0.
        WA_EVENT-FORM = 'TOP_OF_PAGE'.
        MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
    WA_EVENT-FORM.
      ENDIF.
    
      READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'USER_COMMAND'.
      IF SY-SUBRC EQ 0.
        WA_EVENT-FORM = 'USER_COMMAND'.
        MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
    WA_EVENT-NAME.
      ENDIF.
    ENDFORM.                    "POPULATE_EVENT
    
    
    *&--------------------------------------------------------------------*
    *&      Form  data_retrieval
    *&--------------------------------------------------------------------*
    *   retreiving values from the database table ekko
    *---------------------------------------------------------------------*
    FORM DATA_RETRIEVAL.
      SELECT EBELN AEDAT BUKRS BSART LIFNR FROM EKKO INTO TABLE IT_EKKO.
    
    ENDFORM.                    "data_retrieval
    *&--------------------------------------------------------------------*
    *&      Form  bUild_listheader
    *&--------------------------------------------------------------------*
    *       text
    *---------------------------------------------------------------------*
    *      -->I_LISTHEADEtext
    *---------------------------------------------------------------------*
    FORM BUILD_LISTHEADER USING I_LISTHEADER TYPE SLIS_T_LISTHEADER.
      DATA HLINE TYPE SLIS_LISTHEADER.
      HLINE-INFO = 'this is my first alv pgm'.
      HLINE-TYP = 'H'.
    ENDFORM.                    "build_listheader
    
    *&--------------------------------------------------------------------*
    *&      Form  display_alv_report
    *&--------------------------------------------------------------------*
    *       text
    *---------------------------------------------------------------------*
    FORM DISPLAY_ALV_REPORT.
      V_REPID = SY-REPID.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
         I_CALLBACK_PROGRAM                = V_REPID
    *   I_CALLBACK_PF_STATUS_SET          = ' '
         I_CALLBACK_USER_COMMAND           = 'USER_COMMAND'
         I_CALLBACK_TOP_OF_PAGE            = 'TOP_OF_PAGE'
         I_GRID_TITLE                      = I_TITLE_EKKO
    *   I_GRID_SETTINGS                   =
    *   IS_LAYOUT                         = ALV_LAYOUT
         IT_FIELDCAT                       = I_FIELDCAT[]
    *   IT_EXCLUDING                      =
    *   IT_SPECIAL_GROUPS                 =
    *   IT_SORT                           =
    *   IT_FILTER                         =
    *   IS_SEL_HIDE                       =
    *     i_default                         = 'ZLAY1'
         I_SAVE                            = 'A'
    *     is_variant                        = i_variant
         IT_EVENTS                         = V_EVENTS
        TABLES
          T_OUTTAB                          = IT_EKKO
    * EXCEPTIONS
    *   PROGRAM_ERROR                     = 1
    *   OTHERS                            = 2
                .
      IF SY-SUBRC <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    "display_alv_report
    
    
    
    
    *&--------------------------------------------------------------------*
    *&      Form  TOP_OF_PAGE
    *&--------------------------------------------------------------------*
    *       text
    *---------------------------------------------------------------------*
    FORM TOP_OF_PAGE.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          IT_LIST_COMMENTARY       = IT_LISTHEADER
    *    i_logo                   =
    *    I_END_OF_LIST_GRID       =
                .
    
    ENDFORM.                    "TOP_OF_PAGE
    
    *&--------------------------------------------------------------------*
    *&      Form  USER_COMMAND
    *&--------------------------------------------------------------------*
    *       text
    *---------------------------------------------------------------------*
    *      -->R_UCOMM    text
    *      -->,          text
    *      -->RS_SLEFIELDtext
    *---------------------------------------------------------------------*
    FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
    RS_SELFIELD TYPE SLIS_SELFIELD.
      CASE R_UCOMM.
        WHEN '&IC1'.
          READ TABLE IT_EKKO INTO WA_EKKO INDEX RS_SELFIELD-TABINDEX.
          PERFORM BUILD_FIELDCATLOG_EKPO.
          PERFORM EVENT_CALL_EKPO.
          PERFORM POPULATE_EVENT_EKPO.
          PERFORM DATA_RETRIEVAL_EKPO.
          PERFORM BUILD_LISTHEADER_EKPO USING IT_LISTHEADER.
          PERFORM DISPLAY_ALV_EKPO.
      ENDCASE.
    ENDFORM.                    "user_command
    *&--------------------------------------------------------------------*
    *&      Form  BUILD_FIELDCATLOG_EKPO
    *&--------------------------------------------------------------------*
    *       text
    *---------------------------------------------------------------------*
    FORM BUILD_FIELDCATLOG_EKPO.
    
      WA_FIELDCAT-TABNAME = 'IT_EKPO'.
      WA_FIELDCAT-FIELDNAME = 'EBELN'.
      WA_FIELDCAT-SELTEXT_M = 'PO NO.'.
      APPEND WA_FIELDCAT TO I_FIELDCAT.
      CLEAR WA_FIELDCAT.
      WA_FIELDCAT-TABNAME = 'IT_EKPO'.
      WA_FIELDCAT-FIELDNAME = 'EBELP'.
      WA_FIELDCAT-SELTEXT_M = 'LINE NO'.
      APPEND WA_FIELDCAT TO I_FIELDCAT.
      CLEAR WA_FIELDCAT.
      WA_FIELDCAT-TABNAME = 'I_EKPO'.
      WA_FIELDCAT-FIELDNAME = 'MATNR'.
      WA_FIELDCAT-SELTEXT_M = 'MATERIAL NO.'.
      APPEND WA_FIELDCAT TO I_FIELDCAT.
      CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'I_EKPO'.
      WA_FIELDCAT-FIELDNAME = 'MENGE'.
      WA_FIELDCAT-SELTEXT_M = 'QUANTITY'.
      APPEND WA_FIELDCAT TO I_FIELDCAT.
      CLEAR WA_FIELDCAT.
    
    WA_FIELDCAT-TABNAME = 'I_EKPO'.
      WA_FIELDCAT-FIELDNAME = 'MEINS'.
      WA_FIELDCAT-SELTEXT_M = 'UOM'.
      APPEND WA_FIELDCAT TO I_FIELDCAT.
      CLEAR WA_FIELDCAT.
    
    WA_FIELDCAT-TABNAME = 'I_EKPO'.
      WA_FIELDCAT-FIELDNAME = 'NETPR'.
      WA_FIELDCAT-SELTEXT_M = 'PRICE'.
      APPEND WA_FIELDCAT TO I_FIELDCAT.
      CLEAR WA_FIELDCAT.
    
    
    ENDFORM.                    "BUILD_FIELDCATLOG_EKPO
    
    *&--------------------------------------------------------------------*
    *&      Form  event_call_ekpo
    *&--------------------------------------------------------------------*
    *   we get all events - TOP OF PAGE or USER COMMAND in table v_events
    *---------------------------------------------------------------------*
    FORM EVENT_CALL_EKPO.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
       EXPORTING
         I_LIST_TYPE           = 0
       IMPORTING
         ET_EVENTS             = V_EVENTS
    * EXCEPTIONS
    *   LIST_TYPE_WRONG       = 1
    *   OTHERS                = 2
                .
      IF SY-SUBRC <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    "event_call_ekpo
    
    
    *&--------------------------------------------------------------------*
    *&      Form  POPULATE_EVENT
    *&--------------------------------------------------------------------*
    *        Events populated for TOP OF PAGE & USER COMAND
    *---------------------------------------------------------------------*
    FORM POPULATE_EVENT_EKPO.
      READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.
      IF SY-SUBRC EQ 0.
        WA_EVENT-FORM = 'TOP_OF_PAGE'.
        MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
    WA_EVENT-FORM.
      ENDIF.
    
      ENDFORM.                    "POPULATE_EVENT
    
    *&--------------------------------------------------------------------*
    *&      Form  TOP_OF_PAGE
    *&--------------------------------------------------------------------*
    *       text
    *---------------------------------------------------------------------*
    FORM F_TOP_OF_PAGE.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          IT_LIST_COMMENTARY       = IT_LISTHEADER
    *    i_logo                   =
    *    I_END_OF_LIST_GRID       =
                .
    
    ENDFORM.                    "TOP_OF_PAGE
    
    *&--------------------------------------------------------------------*
    *&      Form  USER_COMMAND
    *&--------------------------------------------------------------------*
    *       text
    *---------------------------------------------------------------------*
    *      -->R_UCOMM    text
    *      -->,          text
    *      -->RS_SLEFIELDtext
    *---------------------------------------------------------------------*
    
    *retreiving values from the database table ekko
    FORM DATA_RETRIEVAL_EKPO.
    SELECT EBELN EBELP MATNR MENGE MEINS NETPR FROM EKPO INTO TABLE IT_EKPO.
    ENDFORM.
    
    FORM BUILD_LISTHEADER_EKPO USING I_LISTHEADER TYPE SLIS_T_LISTHEADER.
    DATA: HLINE1 TYPE SLIS_LISTHEADER.
    HLINE1-TYP = 'H'.
    HLINE1-INFO = 'CHECKING PGM'.
    ENDFORM.
    
    
    FORM DISPLAY_ALV_EKPO.
    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           = 'F_USER_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                   = ' '
       I_GRID_TITLE                      = I_TITLE_EKPO
    *   I_GRID_SETTINGS                   =
    *   IS_LAYOUT                         =
       IT_FIELDCAT                       = I_FIELDCAT[]
    *   IT_EXCLUDING                      =
    *   IT_SPECIAL_GROUPS                 =
    *   IT_SORT                           =
    *   IT_FILTER                         =
    *   IS_SEL_HIDE                       =
    *   I_DEFAULT                         =
       I_SAVE                            = 'A'
    *   IS_VARIANT                        =
       IT_EVENTS                         = V_EVENTS
      TABLES
        T_OUTTAB                          = IT_EKPO
     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.

    Regards,

    Brown.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 03, 2008 at 11:00 AM

    Hi,

    search for BCALV_TEST_LIST* in se38 and u will find examples for your ALV list report

    Just see this sample code it contains almost all you required:

    &----


    *& Include ZALVS3

    &----


    tables : zsflight.

    data : container type ref to cl_gui_custom_container, " controls

    grid type ref to cl_gui_alv_grid.

    types : begin of ty_itab,

    carrid type sflight-carrid,

    connid type sflight-connid,

    fldate type sflight-fldate,

    price type zsflight-price,

    seatsocc type sflight-seatsocc,

    seatsmax type sflight-seatsmax,

    end of ty_itab.

    data : itab type table of zsflight,

    wa type zsflight.

    "{internal table for transfering the data in control

    data : fieldcatlog type lvc_t_fcat, " field catalog

    wa_fieldcatlog like line of fieldcatlog.

    data : ok_code type sy-ucomm. "okcode handling

    data gs_layout type lvc_s_layo.

    data :input1 type c, " INPUT FIELDS IN SCREEN 1001 '

    input2 type n,

    input9 type d,

    input3 type c,

    input4 type c,

    input5 type c,

    input6 type c,

    input7 type c,

    input8 type n.

    data: fname type rs38l_fnam. "FUNCTION FOR zALVS2

    data : itab2 type table of zsflight.

    data : container2 type ref to cl_gui_custom_container,

    grid2 type ref to cl_gui_alv_grid.

    data : fieldcatlog2 type lvc_t_fcat,

    wa_fieldcatlog2 like line of fieldcatlog2,

    gs_layout2 type lvc_s_layo.

    &----


    & Report ZALVS----


    &----


    &----


    &----


    &----


    &----


    report zalvs.

    include zalvs3.

    start-of-selection.

    select *

    from zsflight

    into corresponding fields of table itab.

    if sy-subrc eq 0.

    call screen 1000.

    endif.

    -


    MODULE status_1000 OUTPUT

    -


    -


    -


    module status_1000 output.

    set pf-status 'SAP'.

    endmodule. " STATUS_1000 OUTPUT

    &----


    *& Module USER_COMMAND_1000 INPUT

    &----


    text

    -


    module user_command_1000 input.

    ok_code = sy-ucomm.

    case ok_code.

    when 'BACK'.

    leave to screen 0.

    when 'Exit'.

    leave program.

    when 'CANCEL'.

    leave program.

    when 'PUSH1'.

    perform call_form1.

    when 'PUSH2'.

    call screen 1001.

    when 'PUSH3'.

    perform call_form3 tables itab.

    endcase.

    endmodule. " USER_COMMAND_1000 INPUT

    &----


    *& Module Create_Object OUTPUT

    &----


    text

    -


    module create_object output.

    perform prepare_layout changing gs_layout.

    if container is initial.

    create object container

    exporting

    parent = parent

    container_name = 'CONT'

    style = style

    lifetime = lifetime_default

    repid = repid

    dynnr = dynnr

    no_autodef_progid_dynnr = no_autodef_progid_dynnr

    EXCEPTIONS

    cntl_error = 1

    cntl_system_error = 2

    create_error = 3

    lifetime_error = 4

    lifetime_dynpro_dynpro_link = 5

    others = 6

    .

    if sy-subrc 0.

    message id sy-msgid type sy-msgty number sy-msgno

    with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    endif.

    create object grid

    exporting

    i_shellstyle = 0

    i_lifetime = i_lifetime

    i_parent = container

    i_appl_events = space

    i_parentdbg = i_parentdbg

    i_applogparent = i_applogparent

    i_graphicsparent = i_graphicsparent

    i_name = i_name

    i_fcat_complete = space

    EXCEPTIONS

    error_cntl_create = 1

    error_cntl_init = 2

    error_cntl_link = 3

    error_dp_create = 4

    others = 5

    .

    if sy-subrc 0.

    message id sy-msgid type sy-msgty number sy-msgno

    with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    endif.

    endif.

    endmodule. " Create_Object OUTPUT

    &----


    *& Module Transfer_data OUTPUT

    &----


    -


    text----


    *

    -


    module transfer_data output.

    call method grid->set_table_for_first_display

    exporting

    i_buffer_active = i_buffer_active

    i_bypassing_buffer = i_bypassing_buffer

    i_consistency_check = i_consistency_check

    i_structure_name = 'SFLIGHT'

    is_variant = is_variant

    i_save = i_save

    i_default = 'x'

    is_layout = gs_layout

    is_print = is_print

    it_special_groups = it_special_groups

    it_toolbar_excluding = it_toolbar_excluding

    it_hyperlink = it_hyperlink

    it_alv_graphics = it_alv_graphics

    it_except_qinfo = it_except_qinfo

    ir_salv_adapter = ir_salv_adapter

    changing

    it_outtab = itab[]

    it_fieldcatalog = fieldcatlog[]

    it_sort = it_sort

    it_filter = it_filter

    exceptions

    invalid_parameter_combination = 1

    program_error = 2

    too_many_lines = 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.

    endmodule. " Transfer_data OUTPUT

    &----


    *& Module Fill_fieldcatlog OUTPUT

    &----


    text

    -


    module fill_fieldcatlog output.

    clear wa_fieldcatlog.

    data i type i value 0.

    i = i + 1.

    wa_fieldcatlog-fieldname = 'FLDATE'.

    wa_fieldcatlog-ref_table = 'ZSFLIGHT'.

    wa_fieldcatlog-coltext = text(001).

    wa_fieldcatlog-col_pos = i .

    append wa_fieldcatlog to fieldcatlog.

    clear wa_fieldcatlog.

    i = i + 1.

    wa_fieldcatlog-fieldname = 'CARRID'.

    wa_fieldcatlog-coltext = 'CARRID' .

    wa_fieldcatlog-col_pos = i.

    append wa_fieldcatlog to fieldcatlog.

    clear wa_fieldcatlog.

    i = i + 1.

    wa_fieldcatlog-fieldname = 'CONNID'.

    wa_fieldcatlog-coltext = 'CONNID' .

    wa_fieldcatlog-col_pos = i.

    append wa_fieldcatlog to fieldcatlog.

    i = i + 1.

    clear wa_fieldcatlog.

    wa_fieldcatlog-fieldname = 'PRICE'.

    wa_fieldcatlog-ref_table = 'ZSFLIGHT'.

    "wa_fieldcatlog-coltext = text(001).

    wa_fieldcatlog-col_pos = i.

    append wa_fieldcatlog to fieldcatlog.

    i = i + 1.

    clear wa_fieldcatlog.

    wa_fieldcatlog-fieldname = 'SEATSMAX'.

    wa_fieldcatlog-coltext = 'TOTAL CAPACITY' .

    wa_fieldcatlog-col_pos = i.

    append wa_fieldcatlog to fieldcatlog.

    clear wa_fieldcatlog.

    i = i + 1.

    wa_fieldcatlog-fieldname = 'SEATSOCC'.

    wa_fieldcatlog-coltext = 'SEATS OCCUPIED' .

    wa_fieldcatlog-col_pos = i.

    append wa_fieldcatlog to fieldcatlog.

    endmodule. " Fill_fieldcatlog OUTPUT

    &----


    *& Form prepare_layout

    &----


    text

    -


    -->GS_LAYOUT text

    -


    form prepare_layout changing gs_layout type lvc_s_layo.

    gs_layout-stylefname = 'FIELD_STYLE'.

    gs_layout-zebra = 'X'.

    gs_layout-grid_title = 'FLIGHT'.

    gs_layout-sel_mode = 'A'.

    gs_layout-ctab_fname = 'COLORS'.

    endform. "prepare_layout

    &----


    *& Form call_form1

    &----


    text

    -


    form call_form1.

    call function '/1BCDWB/SF00000173'

    EXPORTING

    ARCHIVE_INDEX = ARCHIVE_INDEX

    ARCHIVE_INDEX_TAB = ARCHIVE_INDEX_TAB

    ARCHIVE_PARAMETERS = ARCHIVE_PARAMETERS

    CONTROL_PARAMETERS = CONTROL_PARAMETERS

    MAIL_APPL_OBJ = MAIL_APPL_OBJ

    MAIL_RECIPIENT = MAIL_RECIPIENT

    MAIL_SENDER = MAIL_SENDER

    OUTPUT_OPTIONS = OUTPUT_OPTIONS

    USER_SETTINGS = 'X'

    IMPORTING

    DOCUMENT_OUTPUT_INFO = DOCUMENT_OUTPUT_INFO

    JOB_OUTPUT_INFO = JOB_OUTPUT_INFO

    JOB_OUTPUT_OPTIONS = JOB_OUTPUT_OPTIONS

    tables

    itab = itab

    EXCEPTIONS

    FORMATTING_ERROR = 1

    INTERNAL_ERROR = 2

    SEND_ERROR = 3

    USER_CANCELED = 4

    .

    endform. "call_form1

    &----


    *& Module STATUS_1001 OUTPUT

    &----


    text

    -


    module status_1001 output.

    set pf-status 'SAP2'.

    SET TITLEBAR 'xxx'.

    endmodule. " STATUS_1001 OUTPUT

    &----


    *& Module USER_COMMAND_1001 INPUT

    &----


    text

    -


    module user_command_1001 input.

    ok_code = sy-ucomm.

    case ok_code.

    when 'BACK'.

    leave to screen 1000.

    when 'EXIT'.

    leave program.

    when 'CANCEL'.

    leave program.

    when 'CONTINUE'.

    perform call_form2.

    endcase.

    endmodule. " USER_COMMAND_1001 INPUT

    &----


    *& Form call_form2

    &----


    text

    -


    --> p1 text

    <-- p2 text

    -


    form call_form2 .

    call function 'SSF_FUNCTION_MODULE_NAME'

    exporting

    formname = 'ZALVS2'

    VARIANT = ' '

    DIRECT_CALL = ' '

    importing

    fm_name = fname

    *EXCEPTIONS

    NO_FORM = 1

    NO_FUNCTION_MODULE = 2

    .

    call function fname

    EXPORTING

    ARCHIVE_INDEX = ARCHIVE_INDEX

    ARCHIVE_INDEX_TAB = ARCHIVE_INDEX_TAB

    ARCHIVE_PARAMETERS = ARCHIVE_PARAMETERS

    CONTROL_PARAMETERS = CONTROL_PARAMETERS

    MAIL_APPL_OBJ = MAIL_APPL_OBJ

    MAIL_RECIPIENT = MAIL_RECIPIENT

    MAIL_SENDER = MAIL_SENDER

    OUTPUT_OPTIONS = OUTPUT_OPTIONS

    USER_SETTINGS = 'X'

    IMPORTING

    DOCUMENT_OUTPUT_INFO = DOCUMENT_OUTPUT_INFO

    JOB_OUTPUT_INFO = JOB_OUTPUT_INFO

    JOB_OUTPUT_OPTIONS = JOB_OUTPUT_OPTIONS

    EXCEPTIONS

    FORMATTING_ERROR = 1

    INTERNAL_ERROR = 2

    SEND_ERROR = 3

    USER_CANCELED = 4

    .

    endform. " call_form2

    &----


    *& Module STATUS_1002 OUTPUT

    &----


    text

    -


    module status_1002 output.

    set pf-status 'SAP3'.

    SET TITLEBAR 'xxx'.

    endmodule. " STATUS_1002 OUTPUT

    &----


    *& Module USER_COMMAND_1002 INPUT

    &----


    text

    -


    module user_command_1002 input.

    ok_code = sy-ucomm.

    case ok_code.

    when 'BACK'.

    leave to screen 1000.

    when 'EXIT'.

    leave program.

    when 'CANCEL'.

    leave to screen 1000.

    endcase.

    endmodule. " USER_COMMAND_1002 INPUT

    &----


    *& Form call_form3

    &----


    text

    -


    --> p1 text

    <-- p2 text

    -


    form call_form3 tables itab.

    "APPEND wa TO itab2.

    " CALL SCREEN 1002.

    perform prepare_layout changing gs_layout.

    clear wa_fieldcatlog2.

    data j type i value 0.

    j = j + 1.

    wa_fieldcatlog2-fieldname = 'FLDATE'.

    wa_fieldcatlog2-ref_table = 'ZSFLIGHT'.

    wa_fieldcatlog-coltext = text(001).

    wa_fieldcatlog2-col_pos = j .

    append wa_fieldcatlog2 to fieldcatlog2.

    clear wa_fieldcatlog2.

    j = j + 1.

    wa_fieldcatlog2-fieldname = 'CARRID'.

    wa_fieldcatlog2-coltext = 'CARRID' .

    wa_fieldcatlog2-col_pos = j.

    append wa_fieldcatlog2 to fieldcatlog2.

    clear wa_fieldcatlog2.

    j = j + 1.

    wa_fieldcatlog2-fieldname = 'CONNID'.

    wa_fieldcatlog2-coltext = 'CONNID' .

    wa_fieldcatlog2-col_pos = j.

    append wa_fieldcatlog2 to fieldcatlog2.

    j = j + 1.

    clear wa_fieldcatlog2.

    wa_fieldcatlog2-fieldname = 'PRICE'.

    wa_fieldcatlog2-ref_table = 'ZSFLIGHT'.

    "wa_fieldcatlog-coltext = text(001).

    wa_fieldcatlog2-col_pos = j.

    append wa_fieldcatlog2 to fieldcatlog2.

    j = j + 1.

    clear wa_fieldcatlog2.

    wa_fieldcatlog2-fieldname = 'SEATSMAX'.

    wa_fieldcatlog2-coltext = 'TOTAL CAPACITY' .

    wa_fieldcatlog2-col_pos = j.

    append wa_fieldcatlog2 to fieldcatlog2.

    clear wa_fieldcatlog2.

    j = j + 1.

    wa_fieldcatlog2-fieldname = 'SEATSOCC'.

    wa_fieldcatlog2-coltext = 'SEATS OCCUPIED' .

    wa_fieldcatlog2-col_pos = j.

    append wa_fieldcatlog2 to fieldcatlog2.

    call function 'REUSE_ALV_GRID_DISPLAY'

    exporting

    I_INTERFACE_CHECK = ' '

    I_BYPASSING_BUFFER = ' '

    I_BUFFER_ACTIVE = ' '

    I_CALLBACK_PROGRAM = ' '

    I_CALLBACK_PF_STATUS_SET = ' '

    I_CALLBACK_USER_COMMAND = ' '

    I_CALLBACK_TOP_OF_PAGE = ' '

    I_CALLBACK_HTML_TOP_OF_PAGE = ' '

    I_CALLBACK_HTML_END_OF_LIST = ' '

    i_structure_name = 'ZSFLIGHT'

    I_BACKGROUND_ID = ' '

    i_grid_title = grid2

    I_GRID_SETTINGS = I_GRID_SETTINGS

    is_layout = gs_layout

    it_fieldcat = fieldcatlog2[]

    IT_EXCLUDING = IT_EXCLUDING

    IT_SPECIAL_GROUPS = IT_SPECIAL_GROUPS

    IT_SORT = IT_SORT

    IT_FILTER = IT_FILTER

    IS_SEL_HIDE = IS_SEL_HIDE

    I_DEFAULT = 'X'

    I_SAVE = ' '

    IS_VARIANT = IS_VARIANT

    IT_EVENTS = IT_EVENTS

    IT_EVENT_EXIT = IT_EVENT_EXIT

    IS_PRINT = IS_PRINT

    IS_REPREP_ID = IS_REPREP_ID

    I_SCREEN_START_COLUMN = 0

    I_SCREEN_START_LINE = 0

    I_SCREEN_END_COLUMN = 0

    I_SCREEN_END_LINE = 0

    I_HTML_HEIGHT_TOP = 0

    I_HTML_HEIGHT_END = 0

    IT_ALV_GRAPHICS = IT_ALV_GRAPHICS

    IT_HYPERLINK = IT_HYPERLINK

    IT_ADD_FIELDCAT = IT_ADD_FIELDCAT

    IT_EXCEPT_QINFO = IT_EXCEPT_QINFO

    IR_SALV_FULLSCREEN_ADAPTER = IR_SALV_FULLSCREEN_ADAPTER

    IMPORTING

    E_EXIT_CAUSED_BY_CALLER = E_EXIT_CAUSED_BY_CALLER

    ES_EXIT_CAUSED_BY_USER = ES_EXIT_CAUSED_BY_USER

    tables

    t_outtab = itab[]

    exceptions

    program_error = 1

    .

    refresh itab2[].

    endform. " call_form3

    &----


    *& Module FILLCATLOG OUTPUT

    &----


    text

    -


    module fillcatlog output.

    clear wa_fieldcatlog2.

    data j type i value 0.

    j = j + 1.

    wa_fieldcatlog2-fieldname = 'FLDATE'.

    wa_fieldcatlog2-ref_table = 'ZSFLIGHT'.

    wa_fieldcatlog-coltext = text(001).

    wa_fieldcatlog2-col_pos = j .

    append wa_fieldcatlog2 to fieldcatlog2.

    clear wa_fieldcatlog2.

    j = j + 1.

    wa_fieldcatlog2-fieldname = 'CARRID'.

    wa_fieldcatlog2-coltext = 'CARRID' .

    wa_fieldcatlog2-col_pos = j.

    append wa_fieldcatlog2 to fieldcatlog2.

    clear wa_fieldcatlog2.

    j = j + 1.

    wa_fieldcatlog2-fieldname = 'CONNID'.

    wa_fieldcatlog2-coltext = 'CONNID' .

    wa_fieldcatlog2-col_pos = j.

    append wa_fieldcatlog2 to fieldcatlog2.

    j = j + 1.

    clear wa_fieldcatlog2.

    wa_fieldcatlog2-fieldname = 'PRICE'.

    wa_fieldcatlog2-ref_table = 'ZSFLIGHT'.

    "wa_fieldcatlog-coltext = text(001).

    wa_fieldcatlog2-col_pos = j.

    append wa_fieldcatlog2 to fieldcatlog2.

    j = j + 1.

    clear wa_fieldcatlog2.

    wa_fieldcatlog2-fieldname = 'SEATSMAX'.

    wa_fieldcatlog2-coltext = 'TOTAL CAPACITY' .

    wa_fieldcatlog2-col_pos = j.

    append wa_fieldcatlog2 to fieldcatlog2.

    clear wa_fieldcatlog2.

    j = j + 1.

    wa_fieldcatlog2-fieldname = 'SEATSOCC'.

    wa_fieldcatlog2-coltext = 'SEATS OCCUPIED' .

    wa_fieldcatlog2-col_pos = j.

    append wa_fieldcatlog2 to fieldcatlog2.

    endmodule. " FILLCATLOG OUTPUT

    Reward Points if found helpfull..

    Cheers,

    Chandra Sekhar.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Apr 03, 2008 at 11:09 AM

    Yes these things are very much possible.

    1) sorting.

    let us assume atht itab for the alv output is "itab".

    use

    sort i_tab by respective field ascending/descending.

    2)Total summation.

    let i_fcat be ur field catalog table.

    to the column which has to be summed append the option

    " wa_fcat-do_sum = 'X'. "

    eaxample.

    wa_fcat-col_POS = 12.

    wa_fcat-FIELDNAME = 'NETPR'.

    wa_fcat-do_sum = 'X'. " for summation of amounts.

    wa_fcat-selTEXT_M = 'Amount'.

    wa_fcat-selTEXT_L = 'Amount in credit memo'.

    wa_fcat-outputlen = 15.

    append wa_fcat to i_fcat.

    3) Getting the subtotal.

    example : to get the sum based on each vendor.

    --Sorting by Vendor code.

    wa_sort-spos = 1.

    wa_sort-fieldname = 'LIFNR'.

    wa_sort-up = c_x.

    wa_sort-subtot = c_x.

    append wa_sort to i_sort.

    clear wa_sort.

    append these options to the sort table of ur alv.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 14, 2009 at 10:06 PM

    thanks

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.