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

display header along with ALV

Hi,

i need to display a report using ALV in the following manner. im using reuse_alv_listdisplay and the display is fine . however, i need to add a header to the list and i need to display total for the currency fields. how can i do that. your help would be appreciated.

Thanks,

kranthi.

__________________________________________________

________some company header----


__________________________________________________

-


alv report----


-


display total for currency fields------

i appreciate all of you for your quick response.

i need to call a function module which uses couple of 'write' statements to create the header. is it possible to use that in this context.

Thanks,

Kranthi.

Message was edited by: kranthi kumar

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Nov 23, 2005 at 04:50 PM

    Hi Kranthi,

    Use the events TOP_OF_LIST and END_OF_LIST to acheive your purpose.

    If you want to display for each page use TOP_OF_PAGE and END_OF_PAGE.

    Lets assume that you want to display for each page.

    Populate the events table as follows .

    wa_events-name = slis_ev_top_of_page.

    wa_events-form = 'DISPLAY_TOP_OF_PAGE'.

    append wa_events to it_events.

    clear wa_events.

    wa_events-name = slis_ev_end_of_page.

    wa_events-form = 'DISPLAY_END_OF_PAGE'.

    append wa_events to it_events.

    clear wa_events.

    Export this to the parameter IT_EVENTS of the ALV Function Module.

    Note that, you have to create two subroutines namely

    DISPLAY_TOP_OF_PAGE and DISPLAY_END_OF_PAGE.

    We can give any form names, but here I have used these two when populating the Internal Table for events.

    Then, write the code you want to display as header, in the

    subroutine DISPLAY_TOP_OF_PAGE. This can have include also

    to display standard header. You can use normal write statements also to write anything in header part.

    So, this subroutine will be called automaticlly by the ALV

    for TOP-OF-PAGE event as we have added this event to the EVENTS table.

    Also, create subroutine DISPLAY_END_OF_PAGE and write the code inside that.

    This will be called automatically for the END-OF-PAGE event as we have included this event also in the events table.

    I hope that, this will solve your problem completely.

    Thanks and Regards,

    Arshad

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 23, 2005 at 04:08 PM

    Kranthi

    While building the Layout , use

    <b>waLayout-window_titlebar</b>= 'Ur Title or Heading'.

    Thanks

    Kam

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Check this code..it will have all the functionalities that asked for.

      To display the header u can populate a form name in the Resuse_ALv_Events_get. In that form you can write normal abap code to display header. Or alternatively u need to use REUSE_ALV_COMMENTARY_WRITE to display the header.

      For totals populate the required field in the fieldcat with do_sum = 'X'.

      REPORT ZRSD9007 NO STANDARD PAGE HEADING

      MESSAGE-ID ZZ

      LINE-SIZE 200

      LINE-COUNT 65.

      TYPE-POOLS: SLIS.

      ************************************************************************

      • TABLES DECLARATION

      ************************************************************************

      TABLES : VBAK, " Sales Document: Header Data

      LIKP, " SD Document: Delivery Header Data

      VBPA, " Sales Document: Partner

      SSCRFIELDS. " Fields on selection screens

      ************************************************************************

      • STRUCTURES AND INTERNAL TABLES

      ************************************************************************

      • Structure to hold sales order header data

      DATA : BEGIN OF X_VBAK,

      VBELN LIKE VBAK-VBELN, " Sales Order Number

      BSTNK LIKE VBAK-BSTNK, " Customer PO Number

      END OF X_VBAK.

      • Structure to hold sales order item level data

      DATA : BEGIN OF X_VBAP,

      VBELN LIKE VBAK-VBELN, " Sales Order Number

      POSNR LIKE VBAP-POSNR, " Sales Order Line item

      MATNR LIKE VBAP-MATNR, " Material Number

      KWMENG LIKE VBAP-KWMENG, " Order Quantity

      END OF X_VBAP.

      • Structure to hold order status data

      DATA : BEGIN OF X_VBUP,

      VBELN LIKE VBAK-VBELN, " Sales and Distribution Document Number

      POSNR LIKE VBAP-POSNR, " Item number of the SD document

      WBSTA LIKE VBUP-WBSTA, " Goods movement status

      FKSTA LIKE VBUP-FKSTA, " Billing status

      END OF X_VBUP.

      • Strcuture to hold delivery data

      DATA : BEGIN OF X_LIPS ,

      VBELN LIKE LIPS-VBELN, " Delivery Number

      POSNR LIKE LIPS-POSNR, " Delivery Item

      VGBEL LIKE LIPS-VGBEL, " Document no of the reference document

      VGPOS LIKE LIPS-VGPOS, " Item number of the reference item

      MATNR LIKE LIPS-MATNR, " Material Number

      LFIMG LIKE LIPS-LFIMG, " Actual quantity delivered

      END OF X_LIPS.

      • Internal table to hold the final data

      DATA : BEGIN OF IT_FINAL OCCURS 0,

      VBELN1 LIKE VBAK-VBELN, " Sales Order

      POSNR1 LIKE VBAP-POSNR, " Sales order line item

      MATNR1 LIKE VBAP-MATNR, " Material Number

      KWMENG LIKE VBAP-KWMENG, " Order Qty

      BSTNK LIKE VBAK-BSTNK, " Customer PO Number

      VBELN2 LIKE LIPS-VBELN, " Delivery Number

      POSNR2 LIKE LIPS-POSNR, " Delivery Line

      MATNR2 LIKE LIPS-MATNR, " Material Number

      LFIMG LIKE LIPS-LFIMG, " Actual quantity delivered

      STATUS(25), " Status of the order

      END OF IT_FINAL.

      ************************************************************************

      • DATA DECLARATION *

      ************************************************************************

      *DATA RELATED TO ALV'S

      DATA : IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,

      WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV,

      IT_OUTTAB LIKE IT_FINAL OCCURS 0 WITH HEADER LINE, "#EC *

      V_REPID LIKE SY-REPID,

      IT_LAYOUT TYPE SLIS_LAYOUT_ALV,

      IT_EVENTS TYPE SLIS_T_EVENT,

      WA_SORT TYPE SLIS_SORTINFO_ALV,

      IT_SORT TYPE SLIS_T_SORTINFO_ALV ,

      V_PAGE_HEADER TYPE SLIS_FORMNAME VALUE 'PAGE_HEADER'.

      *Variable to hold the total number of records

      DATA : V_LINES TYPE I.

      ************************************************************************

      • CONSTANTS *

      ************************************************************************

      CONSTANTS :

      *----VBPA Partner function 'RG' -> Payer

      C_RG LIKE VBPA-PARVW VALUE 'RG',

      *----Line item to be passed for VBPA select.

      C_POSNR LIKE VBAP-POSNR VALUE '000000'.

      ************************************************************************

      • SELECTION-SCREEN *

      ************************************************************************

      SELECTION-SCREEN BEGIN OF BLOCK S1 WITH FRAME TITLE TEXT-001.

      SELECT-OPTIONS:

      S_VKORG FOR VBAK-VKORG, " Sales Organization

      S_VTWEG FOR VBAK-VTWEG, " Distribution Channel

      S_SPART FOR VBAK-SPART, " Sales Division

      S_KUNNR FOR VBAK-KUNNR, " Sold-to party

      S_PAYER FOR VBPA-KUNNR, " Payer

      S_VBELN FOR LIKP-VBELN, " Delivery Number

      S_ERDAT FOR LIKP-ERDAT OBLIGATORY, " Delivery Date

      S_LFART FOR LIKP-LFART DEFAULT 'LF', " Delivery Type

      S_AUART FOR VBAK-AUART DEFAULT 'OR'. " Order Type- Default 'OR'

      SELECTION-SCREEN END OF BLOCK S1.

      ************************************************************************

      • Initialization

      ************************************************************************

      V_REPID = SY-REPID.

      \************************************************************************

      • START-OF-SELECTION *

      ************************************************************************

      START-OF-SELECTION.

      PERFORM FETCH_DATA.

      ************************************************************************

      • END-OF-SELECTION *

      ************************************************************************

      END-OF-SELECTION.

      IF NOT IT_FINAL[] IS INITIAL.

      DESCRIBE TABLE IT_FINAL LINES V_LINES.

      PERFORM FILL_EVENTS.

      PERFORM BUILD_LAYOUT.

      PERFORM FILL_SORTTABLE.

      PERFORM FIELD_CATALOG.

      PERFORM ALV_DISPLAY.

      ELSE.

      MESSAGE I001(ZZ) WITH 'No data found'(017). "#EC *

      ENDIF.

      &----


      *& Form fetch_data

      &----


      • Subroutine to fetch the orders with the following status

      • 1. open

      • 2. shipped but not invoiced

      ----


      FORM FETCH_DATA .

      *Variable to hold the payer

      DATA: LV_KUNNR LIKE VBPA-KUNNR, "#EC NEEDED

      LV_VBELN LIKE LIKP-VBELN.

      *--Select from LIKP table

      SELECT VBELN

      FROM LIKP

      INTO LV_VBELN

      WHERE VBELN IN S_VBELN AND

      ERDAT IN S_ERDAT AND

      VKORG IN S_VKORG AND

      LFART IN S_LFART.

      *Select delivery data from LIPS for the given selection

      *criteria

      SELECT VBELN

      POSNR

      VGBEL

      VGPOS

      MATNR

      LFIMG

      FROM LIPS

      INTO X_LIPS

      WHERE VBELN = LV_VBELN.

      IF X_LIPS IS NOT INITIAL.

      CLEAR : X_VBUP, X_VBAK, X_VBAP, LV_KUNNR.

      *For the given delivery order select the sales order

      *details from VBAK and VBAP tables

      SELECT SINGLE

      VBELN

      BSTNK

      FROM VBAK

      INTO X_VBAK

      WHERE VBELN = X_LIPS-VGBEL AND

      AUART IN S_AUART AND

      VKORG IN S_VKORG AND

      VTWEG IN S_VTWEG AND

      SPART IN S_SPART AND

      KUNNR IN S_KUNNR.

      IF SY-SUBRC = 0.

      SELECT SINGLE

      VBELN

      POSNR

      MATNR

      KWMENG

      FROM VBAP

      INTO X_VBAP

      WHERE VBELN = X_VBAK-VBELN AND

      POSNR = X_LIPS-VGPOS.

      IF SY-SUBRC = 0.

      *Payer criteria filtering --> Check whether there is a valid payer

      *for the gievn sales order from VBPA table .

      SELECT SINGLE KUNNR

      INTO LV_KUNNR

      FROM VBPA

      WHERE VBELN = X_VBAP-VBELN AND

      POSNR = C_POSNR AND

      PARVW = C_RG AND "RG->Payer

      KUNNR IN S_PAYER.

      IF SY-SUBRC <> 0.

      CONTINUE.

      ENDIF.

      ELSE.

      CONTINUE.

      ENDIF.

      ELSE.

      CONTINUE.

      ENDIF.

      *Select the order status from VBUP table

      SELECT SINGLE

      VBELN

      POSNR

      WBSTA

      FKSTA

      FROM VBUP

      INTO X_VBUP

      WHERE VBELN = X_LIPS-VBELN AND

      POSNR = X_LIPS-POSNR AND

      FKSTA NE 'C' ."Shipped & invoiced

      IF SY-SUBRC = 0.

      *Consolidate the data for display

      IT_FINAL-VBELN1 = X_VBAP-VBELN.

      IT_FINAL-POSNR1 = X_VBAP-POSNR.

      IT_FINAL-MATNR1 = X_VBAP-MATNR.

      IT_FINAL-KWMENG = X_VBAP-KWMENG.

      IT_FINAL-BSTNK = X_VBAK-BSTNK.

      IT_FINAL-VBELN2 = X_LIPS-VBELN.

      IT_FINAL-POSNR2 = X_LIPS-POSNR.

      IT_FINAL-MATNR2 = X_LIPS-MATNR.

      IT_FINAL-LFIMG = X_LIPS-LFIMG.

      *If the order is shipped but no invoicing is done then

      *status is 'Shipped but not invoiced'

      IF X_VBUP-WBSTA = 'C' AND X_VBUP-FKSTA NE 'C'.

      IT_FINAL-STATUS = 'SHIPPED BUT NOT INVOICED'(008).

      *If the order is not shipped then status is 'Open'.

      ELSEIF X_VBUP-WBSTA <> 'C'.

      IT_FINAL-STATUS = 'OPEN'(009).

      ENDIF.

      APPEND IT_FINAL.

      CLEAR IT_FINAL.

      ENDIF.

      ENDIF.

      ENDSELECT.

      ENDSELECT.

      ENDFORM. " fetch_data

      &----


      *& Form FILL_EVENTS

      &----


      • Subroutine to populate the ALV events table

      ----


      FORM FILL_EVENTS.

      DATA: V_EVENT TYPE SLIS_ALV_EVENT.

      REFRESH: IT_EVENTS[].

      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

      EXPORTING

      I_LIST_TYPE = 0

      IMPORTING

      ET_EVENTS = IT_EVENTS.

      • set top of page routine

      READ TABLE IT_EVENTS WITH KEY NAME = SLIS_EV_TOP_OF_PAGE

      INTO V_EVENT.

      IF SY-SUBRC = 0.

      V_EVENT-FORM = V_PAGE_HEADER.

      MODIFY IT_EVENTS FROM V_EVENT INDEX SY-TABIX.

      ENDIF.

      ENDFORM. " FILL_EVENTS

      &----


      *& Form BUILD_LAYOUT

      &----


      • Populate the ALV layout preferences

      ----


      FORM BUILD_LAYOUT .

      IT_LAYOUT-COLWIDTH_OPTIMIZE = ' '.

      IT_LAYOUT-ZEBRA = 'X'.

      IT_LAYOUT-DETAIL_POPUP = 'X'.

      IT_LAYOUT-DETAIL_INITIAL_LINES = 'X'.

      IT_LAYOUT-GET_SELINFOS = 'X'.

      IT_LAYOUT-NO_SUBTOTALS = ' '.

      IT_LAYOUT-TOTALS_TEXT = 'GRANDTOTAL'.

      IT_LAYOUT-SUBTOTALS_TEXT = 'SUBTOTAL'.

      ENDFORM. " BUILD_LAYOUT

      &----


      *& Form FIELD_CATALOG

      &----


      • Populate the ALV field catalog

      ----


      FORM FIELD_CATALOG .

      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

      EXPORTING

      I_PROGRAM_NAME = V_REPID

      I_INTERNAL_TABNAME = 'IT_FINAL'

      • I_STRUCTURE_NAME =

      I_CLIENT_NEVER_DISPLAY = 'X'

      I_INCLNAME = V_REPID

      • I_BYPASSING_BUFFER =

      • I_BUFFER_ACTIVE =

      CHANGING

      CT_FIELDCAT = IT_FIELDCAT

      EXCEPTIONS

      INCONSISTENT_INTERFACE = 1

      PROGRAM_ERROR = 2

      OTHERS = 3

      .

      IF SY-SUBRC = 0.

      *Modifications to field catalog

      PERFORM MODIFY_FIELDCAT.

      ENDIF.

      ENDFORM. " FIELD_CATALOG

      &----


      *& Form ALV_DISPLAY

      &----


      • Subroutine to display the report using ALV

      ----


      FORM ALV_DISPLAY.

      CALL FUNCTION 'REUSE_ALV_LIST_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_STRUCTURE_NAME =

      IS_LAYOUT = IT_LAYOUT

      IT_FIELDCAT = IT_FIELDCAT

      • IT_EXCLUDING =

      • IT_SPECIAL_GROUPS =

      IT_SORT = IT_SORT

      • IT_FILTER =

      • IS_SEL_HIDE =

      • I_DEFAULT = 'X'

      • I_SAVE = ' '

      • IS_VARIANT =

      IT_EVENTS = IT_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. " ALV_DISPLAY

      &----


      *& Form PAGE_HEADER

      &----


      • To Print page header and other details

      ----


      FORM PAGE_HEADER . "#EC CALLED

      *---Page header

      ULINE AT /1(200).

      FORMAT RESET.

      FORMAT COLOR COL_BACKGROUND INTENSIFIED ON .

      WRITE:/ 'Run Date:'(002), SY-DATUM, 65 'Stanley Works'(003),

      115 'Page No:'(004), SY-PAGNO LEFT-JUSTIFIED.

      WRITE:/ 'Run Time:'(005), SY-UZEIT, 60 SY-TITLE, 115 SY-UNAME.

      WRITE:/ 'Source :'(006), SY-SYSID, 115 SY-CPROG .

      ULINE AT /1(200).

      WRITE:/1 'No of Records Extracted :'(007), V_LINES LEFT-JUSTIFIED.

      ENDFORM. "PAGE_HEADER

      &----


      *& Form MODIFY_FIELDCAT

      &----


      • Subroutine to modify the field catalog

      ----


      FORM MODIFY_FIELDCAT .

      LOOP AT IT_FIELDCAT INTO WA_FIELDCAT.

      CASE WA_FIELDCAT-FIELDNAME.

      WHEN 'STATUS'.

      WA_FIELDCAT-SELTEXT_S = 'Staus'(T01).

      WA_FIELDCAT-SELTEXT_M = 'Delivery Status'(T02).

      WA_FIELDCAT-SELTEXT_L = 'Delivery Status'(T02).

      MODIFY IT_FIELDCAT FROM WA_FIELDCAT TRANSPORTING SELTEXT_S

      SELTEXT_M SELTEXT_L.

      WHEN 'LFIMG'.

      WA_FIELDCAT-DO_SUM = 'X'.

      MODIFY IT_FIELDCAT FROM WA_FIELDCAT TRANSPORTING DO_SUM.

      WHEN 'VBELN2'.

      WA_FIELDCAT-KEY = ' '.

      WA_FIELDCAT-COL_POS = 6.

      MODIFY IT_FIELDCAT FROM WA_FIELDCAT TRANSPORTING KEY COL_POS.

      WHEN 'POSNR2'.

      WA_FIELDCAT-KEY = ' '.

      WA_FIELDCAT-COL_POS = 7.

      MODIFY IT_FIELDCAT FROM WA_FIELDCAT TRANSPORTING KEY COL_POS.

      ENDCASE.

      CLEAR WA_FIELDCAT.

      ENDLOOP.

      ENDFORM. " MODIFY_FIELDCAT

      &----


      *& Form FILL_SORTTABLE

      &----


      • Populate the ALV sort table

      ----


      FORM FILL_SORTTABLE .

      WA_SORT-SPOS = 1.

      WA_SORT-FIELDNAME = 'VBELN1'.

      WA_SORT-TABNAME = 'IT_FINAL'.

      WA_SORT-UP = 'X'.

      WA_SORT-SUBTOT = 'X' .

      APPEND WA_SORT TO IT_SORT.

      ENDFORM. " FILL_SORTTABLE

  • author's profile photo Former Member
    Former Member
    Posted on Nov 23, 2005 at 04:20 PM

    Hi kranthi,

    check this it will solves your problem.

    http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_rephead.htm

    reward points for helpfull answers and close the thread if your question is solved.

    regards,

    venu.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 23, 2005 at 04:21 PM

    Use this code..

    In your REUSE_ALV_LIST_DISPLAY

    Use this..

    Pass IT_EVENTS = GT_EVENTS.

    **************************************************

    FORM EVENTTAB_BUILD CHANGING LT_EVENTS TYPE SLIS_T_EVENT.

    CONSTANTS:

    GC_FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE'.

    DATA: LS_EVENT TYPE SLIS_ALV_EVENT.

    CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

    EXPORTING

    I_LIST_TYPE = 0

    IMPORTING

    ET_EVENTS = LT_EVENTS.

    READ TABLE LT_EVENTS WITH KEY NAME = SLIS_EV_TOP_OF_PAGE

    INTO LS_EVENT.

    IF SY-SUBRC = 0.

    MOVE GC_FORMNAME_TOP_OF_PAGE TO LS_EVENT-FORM.

    APPEND LS_EVENT TO LT_EVENTS.

    ENDIF.

    ENDFORM. "EVENTTAB_BUILD

    &----


    *& Form COMMENT_BUILD

    &----


    • text

    ----


    FORM COMMENT_BUILD CHANGING GT_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.

    DATA: GS_LINE TYPE SLIS_LISTHEADER.

    CLEAR GS_LINE.

    GS_LINE-TYP = 'H'.

    GS_LINE-INFO = 'Your Header here'.

    APPEND GS_LINE TO GT_TOP_OF_PAGE.

    ENDFORM. " COMMENT_BUILD

    &----


    *& Form TOP_OF_PAGE

    &----


    • text

    ----


    FORM TOP_OF_PAGE.

    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

    EXPORTING

    IT_LIST_COMMENTARY = GT_LIST_TOP_OF_PAGE.

    ENDFORM. "TOP_OF_PAGE

    &----


    *& Form END_OF_PAGE

    &----


    • text

    ----


    FORM END_OF_PAGE.

    -


    write your display total...

    WRITE at (sy-linsz) sy-pagno CENTERED.

    ENDFORM. "END_OF_PAGE

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 23, 2005 at 07:33 PM

    &----


    *& Report ZVENU_ALV *

    *& *

    &----


    *& *

    *& *

    &----


    .

    *----


    • Program: ZZ_ALV_REPORT_STUB

    • Author :

    • Date :

    *

    • Purpose: Report using ALV function

    *

    • Notes:

    • 1) Logos & wallpapers can be found in table BDS_CONN05

    • with class = PICTURES

    *

    • 2) Transaction OAER can be used to create PICTURES.

    • Run transaction OAER with class name = PICTURES, Class type = OT,

    • and Object key with whatever name you want to create. In the

    • next screen, right clicking on screen and import

    *

    *----


    • Revisions

    *----


    • Name :

    • Date :

    • Comments:

    *----


    report zz_alv_report_stub

    no standard page heading

    line-size 200

    line-count 65

    message-id zz.

    *----


    • Tables

    *----


    tables:

    ekpo,

    trdir.

    *----


    • Global Types

    *----


    type-pools: slis.

    *----


    • Global Internal Tables

    *----


    data:

    i_fieldcat_alv type slis_t_fieldcat_alv,

    i_events type slis_t_event,

    i_event_exit type slis_t_event_exit,

    i_list_comments type slis_t_listheader,

    i_excluding type slis_t_extab.

    • Display data

    data: begin of i_data occurs 0,

    name like trdir-name,

    clas like trdir-clas,

    subc like trdir-subc,

    cnam like trdir-cnam,

    cdat like trdir-cdat,

    myfield(1) type c,

    end of i_data.

    *----


    • Global Variables

    *----


    data:

    w_variant like disvariant,

    wx_variant like disvariant,

    w_variant_save(1) type c,

    w_exit(1) type c,

    w_repid like sy-repid,

    w_user_specific(1) type c,

    w_callback_ucomm type slis_formname,

    w_print type slis_print_alv,

    w_layout type slis_layout_alv,

    w_html_top_of_page type slis_formname,

    w_fieldcat_alv like line of i_fieldcat_alv,

    w_excluding like line of i_excluding,

    w_events like line of i_events,

    w_event_exit like line of i_event_exit,

    w_list_comments like line of i_list_comments.

    *----


    • Global Constants

    *----


    *constants:

    *----


    • Selection Screen

    *----


    selection-screen begin of block blk_criteria with frame title text-f01.

    select-options:

    s_name for trdir-name.

    selection-screen end of block blk_criteria.

    selection-screen begin of block blk_params with frame title text-f02.

    parameters:

    p_vari like disvariant-variant.

    selection-screen skip 1.

    parameters:

    p_grid radiobutton group rb01 default 'X',

    p_html as checkbox.

    selection-screen skip 1.

    parameters:

    p_list radiobutton group rb01.

    selection-screen end of block blk_params.

    *----


    • Initialization

    *----


    initialization.

    perform init_variant.

    perform variant_default using p_vari.

    clear: s_name[].

    s_name-sign = 'I'.

    s_name-option = 'CP'.

    s_name-low = 'Z*'.

    append s_name.

    *----


    • At Selection Screen PBO

    *----


    at selection-screen output.

    *----


    • At Selection Screen Value Request

    *----


    at selection-screen on value-request for p_vari.

    perform variant_f4 using p_vari.

    *----


    • At Selection Screen

    *----


    at selection-screen.

    perform variant_fill.

    *----


    • Start of Selection

    *----


    start-of-selection.

    perform get_data.

    end-of-selection.

    perform fieldcat_build.

    perform event_build.

    perform event_exit_build.

    perform exclude_build.

    perform print_build.

    perform layout_build.

    perform display_data.

    *----


    • Top of Page

    *----


    top-of-page.

    *----


    • Top of Page During Line Sel

    *----


    top-of-page during line-selection.

    *----


    • At User Command

    *----


    at user-command.

    *----


    • At Line Selection

    *----


    at line-selection.

    *----


    • Macros

    *----


    define skip_1.

    write: /001 sy-vline,

    at sy-linsz sy-vline.

    end-of-definition.

    *----


    • Forms

    *----


    &----


    *& Form variant_f4

    &----


    form variant_f4 using p_variant.

    call function 'LVC_VARIANT_F4'

    exporting

    is_variant = w_variant

    i_save = w_variant_save

    importing

    e_exit = w_exit

    es_variant = wx_variant

    exceptions

    not_found = 1

    program_error = 2

    others = 3.

    if sy-subrc <> 0.

    message i000(zz) with text-g01.

    endif.

    if w_exit is initial.

    w_variant-variant = wx_variant-variant.

    p_variant = wx_variant-variant.

    endif.

    endform.

    &----


    *& Form init_variant

    &----


    form init_variant.

    clear: w_variant.

    w_repid = sy-repid.

    w_variant-report = w_repid.

    w_variant-username = sy-uname.

    w_variant_save = 'A'. "All types

    endform.

    &----


    *& Form variant_default

    &----


    form variant_default using p_variant.

    wx_variant = w_variant.

    if not p_variant is initial.

    wx_variant-variant = p_variant.

    endif.

    call function 'LVC_VARIANT_DEFAULT_GET'

    exporting

    i_save = w_variant_save

    changing

    cs_variant = wx_variant

    exceptions

    wrong_input = 1

    not_found = 2

    program_error = 3

    others = 4.

    case sy-subrc.

    when 0.

    p_variant = wx_variant-variant.

    when 2.

    clear: p_variant.

    endcase.

    endform.

    &----


    *& Form variant_fill

    &----


    form variant_fill.

    clear: w_variant.

    if p_vari is initial.

    w_variant-variant = 'STANDARD'.

    w_variant-report = w_repid.

    else.

    w_variant-variant = p_vari.

    w_variant-report = w_repid.

    call function 'LVC_VARIANT_EXISTENCE_CHECK'

    exporting

    i_save = w_variant_save

    changing

    cs_variant = w_variant

    exceptions

    others = 01.

    if sy-subrc ne 0.

    message i000(zz) with text-g02.

    endif.

    endif.

    endform.

    &----


    *& Form fieldcat_build

    &----


    form fieldcat_build.

    call function 'REUSE_ALV_FIELDCATALOG_MERGE'

    exporting

    i_program_name = w_repid

    • i_structure_name = 'TRDIR'

    i_internal_tabname = 'I_DATA'

    i_inclname = w_repid

    changing

    ct_fieldcat = i_fieldcat_alv.

    • Modify displayed fields

    loop at i_fieldcat_alv into w_fieldcat_alv.

    case w_fieldcat_alv-fieldname.

    when 'NAME'.

    w_fieldcat_alv-hotspot = 'X'.

    when 'MYFIELD'.

    w_fieldcat_alv-checkbox = 'X'.

    w_fieldcat_alv-seltext_s = 'MyChkBox'.

    when others.

    endcase.

    modify i_fieldcat_alv from w_fieldcat_alv.

    endloop.

    endform.

    &----


    *& Form display_data

    &----


    form display_data.

    w_callback_ucomm = 'CALLBACK_UCOMM'.

    case 'X'.

    when p_grid.

    if p_html = 'X'.

    w_html_top_of_page = 'HTML_TOP_OF_PAGE'.

    endif.

    call function 'REUSE_ALV_GRID_DISPLAY'

    exporting

    • i_background_id = 'SIWB_WALLPAPER'

    i_background_id = 'SIWB_WALLPAPER'

    i_callback_program = w_repid

    i_callback_html_top_of_page = w_html_top_of_page

    • i_structure_name = 'TRDIR'

    i_default = 'X'

    i_save = 'A'

    is_variant = w_variant

    is_layout = w_layout

    i_callback_user_command = w_callback_ucomm

    it_fieldcat = i_fieldcat_alv

    it_events = i_events

    it_event_exit = i_event_exit

    it_excluding = i_excluding

    is_print = w_print

    • i_screen_start_column = 1

    • i_screen_start_line = 1

    • i_screen_end_column = 70

    • i_screen_end_line = 30

    tables

    t_outtab = i_data.

    when p_list.

    call function 'REUSE_ALV_LIST_DISPLAY'

    exporting

    • i_background_id = 'ALV_BACKGROUND'

    i_callback_program = w_repid

    i_default = 'X'

    i_save = 'A'

    is_variant = w_variant

    is_layout = w_layout

    i_callback_user_command = w_callback_ucomm

    it_fieldcat = i_fieldcat_alv

    it_events = i_events

    it_event_exit = i_event_exit

    is_print = w_print

    tables

    t_outtab = i_data.

    endcase.

    endform.

    ----


    • FORM user_command *

    ----


    form callback_ucomm using r_ucomm like sy-ucomm

    rs_selfield type slis_selfield.

    message i000(zz) with r_ucomm.

    case r_ucomm.

    when '&IC1'.

    set parameter id 'RID' field rs_selfield-value.

    call transaction 'SE38'.

    when others.

    endcase.

    endform.

    &----


    *& Form get_data

    &----


    form get_data.

    select * up to 15 rows from trdir

    into corresponding fields of table i_data

    where name in s_name.

    endform.

    ----


    • FORM ALV_TOP_OF_PAGE *

    ----


    form alv_top_of_page.

    clear: i_list_comments[].

    w_list_comments-typ = 'H'. "H=Header, S=Selection, A=Action

    w_list_comments-key = ''.

    w_list_comments-info = 'Info 1'.

    append w_list_comments to i_list_comments.

    w_list_comments-typ = 'A'. " H = Header, S = Selection, A = Action

    w_list_comments-key = ''.

    w_list_comments-info = 'Begin of list'.

    append w_list_comments to i_list_comments.

    call function 'REUSE_ALV_COMMENTARY_WRITE'

    exporting

    i_logo = 'ENJOYSAP_LOGO'

    it_list_commentary = i_list_comments.

    endform.

    &----


    *& Form event_build

    &----


    form event_build.

    call function 'REUSE_ALV_EVENTS_GET'

    exporting

    i_list_type = 0

    importing

    et_events = i_events.

    read table i_events

    with key name = slis_ev_top_of_page

    into w_events.

    if sy-subrc = 0.

    move 'ALV_TOP_OF_PAGE' to w_events-form.

    modify i_events from w_events index sy-tabix.

    endif.

    read table i_events

    with key name = slis_ev_end_of_list

    into w_events.

    if sy-subrc = 0.

    move 'ALV_END_OF_LIST' to w_events-form.

    modify i_events from w_events index sy-tabix.

    endif.

    read table i_events

    with key name = slis_ev_end_of_page

    into w_events.

    if sy-subrc = 0.

    move 'ALV_END_OF_PAGE' to w_events-form.

    modify i_events from w_events index sy-tabix.

    endif.

    endform.

    ----


    • FORM alv_end_of_list *

    ----


    form alv_end_of_list.

    clear: i_list_comments[].

    w_list_comments-typ = 'A'. "H = Header, S = Selection, A = Action

    w_list_comments-key = ''.

    w_list_comments-info = 'End of list'.

    append w_list_comments to i_list_comments.

    call function 'REUSE_ALV_COMMENTARY_WRITE'

    exporting

    it_list_commentary = i_list_comments

    i_logo = 'ZMYOBJECTKEY'

    i_end_of_list_grid = 'X'.

    endform.

    ----


    • FORM alv_end_of_page *

    ----


    form alv_end_of_page.

    endform.

    &----


    *& Form print_build

    &----


    form print_build.

    w_print-no_print_listinfos = 'X'.

    endform.

    &----


    *& Form layout_build

    &----


    form layout_build.

    w_layout-zebra = 'X'.

    w_layout-no_vline = 'X'.

    w_layout-colwidth_optimize = 'X'.

    w_layout-detail_popup = 'X'.

    w_layout-detail_initial_lines = 'X'.

    w_layout-detail_titlebar = 'Detail Title Bar'.

    endform.

    &----


    *& Form event_exit_build

    &----


    form event_exit_build.

    clear: i_event_exit[].

    • Pick

    w_event_exit-ucomm = '&ETA'.

    w_event_exit-before = ' '.

    w_event_exit-after = 'X'.

    append w_event_exit to i_event_exit.

    endform.

    ----


    • FORM HTML_TOP_OF_PAGE *

    ----


    form html_top_of_page using r_top type ref to cl_dd_document.

    data:

    text type sdydo_text_element,

    s_table type ref to cl_dd_table_element,

    col_key type ref to cl_dd_area,

    col_info type ref to cl_dd_area,

    a_logo type ref to cl_dd_area.

    • Split TOP-Document

    call method r_top->vertical_split

    exporting split_area = r_top

    split_width = '30%'

    importing right_area = a_logo.

    • Fill TOP-Document

    call method r_top->add_text

    exporting text = 'Example of a Heading'

    sap_style = 'HEADING'.

    call method r_top->new_line.

    call method r_top->new_line.

    call method r_top->add_table

    exporting no_of_columns = 2

    with_heading = ' '

    border = '1'

    importing table = s_table.

    call method s_table->add_column importing column = col_key.

    call method s_table->add_column importing column = col_info.

    text = 'A key value marked'.

    call method col_key->add_text

    exporting text = text

    sap_emphasis = 'Strong'.

    call method col_info->add_gap exporting width = 6.

    text = '600' .

    call method col_info->add_text

    exporting text = text

    sap_style = 'Key'.

    call method col_info->add_gap exporting width = 3.

    text = 'Block brick units'.

    call method col_info->add_text exporting text = text.

    call method s_table->new_row.

    text = 'Storage Bin'.

    call method col_key->add_text

    exporting text = text

    sap_emphasis = 'Strong'.

    call method col_info->add_gap exporting width = 7.

    text = 'C-A-004'.

    call method col_info->add_text exporting text = text.

    call method s_table->new_row.

    text = 'Warehouse number' .

    call method col_key->add_text

    exporting text = text

    sap_emphasis = 'Strong'.

    call method col_info->add_gap exporting width = 6.

    text = '200' .

    call method col_info->add_text

    exporting text = text

    sap_style = 'Success'.

    call method col_info->add_gap exporting width = 3.

    text = 'marked success'.

    call method col_info->add_text exporting text = text.

    call method s_table->new_row.

    call method r_top->new_line.

    text = 'This last line is a comment in italics.'.

    call method r_top->add_text

    exporting text = text

    sap_emphasis = 'EMPHASIS'.

    call method r_top->new_line.

    call method a_logo->add_picture

    • exporting picture_id = 'ZZTESTBMP'.

    exporting picture_id = 'ENJOYSAP_LOGO'.

    endform.

    &----


    *& Form exclude_build

    &----


    form exclude_build.

    w_excluding = '&GRAPH'. "Graphic

    append w_excluding to i_excluding.

    endform. " exclude_build

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 24, 2005 at 07:43 AM

    form TOP_OF_PAGE.

    Data T_Head type SLIS_LISTHEADER.

    CLEAR T_Head.

    T_Head-Typ = 'H'.

    " H = Header, S = Selection, A = Action

    T_Head-Info = 'Top Header'.

    Append T_Head to TH_Top.

    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

    EXPORTING

    it_list_commentary = TH_Top

    I_LOGO = 'ENJOYSAP_LOGO'

    EndFORM.

    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.