Skip to Content

adjustment in top of page in alv

hi all,

i have the requirement to print the header in alv grid as below:

===================================================================

COMPANY CODE : p_bukrs ...........(blank here)..........................DATE p_zfbdt

==================================================================

col1 col2 col3 col4 col5........................................................................................col25

for the header ,i triggered the top of page event using reuse_alv_write_commentry module.

but the output is coming as

===================================================================

COMPANY CODE p_bukrs DATE p_zfbdt

==================================================================

col1 col2 col3 col4 col5........................................................................................col25

how to adjust heading as required????

Message was edited by:

kunal kakkar

Message was edited by:

kunal kakkar

Message was edited by:

kunal kakkar

Message was edited by:

kunal kakkar

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

4 Answers

  • author's profile photo
    Former Member
    Posted on Sep 28, 2007 at 10:13 AM

    I do not think that you will be able to adjust your Header as per your requirement.For that you will have to create List ALV and Header using Write Statement.

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on Sep 28, 2007 at 10:22 AM

    Hi Kunal,

    This reqirement can be done by using OOPS concept.

    In ur FM 'REUSE_ALV_GRID_DISPLAY',

    pass this:

    i_callback_html_top_of_page = 'REPORT_TOP_OF_PAGE'.

    And create a form for this event:

    FORM report_top_of_page USING r_top TYPE REF TO cl_dd_document.

    *Local variable declarations.---

    Data: l_text TYPE sdydo_text_element,

    l_table TYPE REF TO cl_dd_table_element,

    l_col_key TYPE REF TO cl_dd_area,

    l_col_info TYPE REF TO cl_dd_area,

    l_logo TYPE REF TO cl_dd_area,

    l_line1(150),

    l_uzeit(10),

    l_datum(10),

    l_budat_low(10),

    l_budat_high(10),

    l_pagno(4),

    l_dummy(30).

    Clear: l_logo.

    *Formatting the Top-of-Page.---

    CALL METHOD: r_top->vertical_split

    EXPORTING split_area = r_top

    split_width = '100%'

    IMPORTING right_area = l_logo.

    ----


    *Populating the system variables.---

    ----


    clear: l_line1.

    Concatenate: 'CLIENT:' sy-mandt sy-sysid into

    l_line1 separated by space.

    CALL METHOD: r_top->add_table EXPORTING no_of_columns = 2

    with_heading = ' '

    border = '1'

    IMPORTING table = l_table,

    l_table->add_column IMPORTING column = l_col_key,

    l_table->add_column IMPORTING column = l_col_info.

    l_text = l_line1.

    CALL METHOD l_col_key->add_text

    EXPORTING

    text = l_text

    sap_emphasis = 'Strong'.

    ----


    *Company Name.----

    ----


    l_text = Company'(027).

    *Adjusting the space between header fields.----

    CALL METHOD: l_col_info->add_gap EXPORTING width = 55,

    *Displaying the text with the letter formatting.---

    l_col_info->add_text EXPORTING text = l_text

    sap_emphasis = 'Strong'.

    ----


    *Program Name/User Id.----

    ----


    *Adjusting the space between header fields.----

    CALL METHOD l_col_info->add_gap

    EXPORTING

    width = 30.

    clear: l_line1.

    Concatenate: sy-repid '/' sy-uname into l_line1 separated by space.

    l_text = l_line1.

    *Displaying the text with the letter formatting.---

    CALL METHOD l_col_info->add_text

    EXPORTING

    text = l_text

    sap_emphasis = 'Strong'.

    ----


    *Title.----

    ----


    *Displaying the title in a new line.---

    CALL METHOD: l_table->new_row,

    *Adjusting the space between header fields.----

    l_col_info->add_gap EXPORTING width = 55.

    clear: l_line1.

    Concatenate: 'Title:' sy-title(57) into l_line1 separated by space.

    l_text = l_line1.

    *Displaying the text with the letter formatting.---

    CALL METHOD l_col_info->add_text

    EXPORTING

    text = l_text

    sap_emphasis = 'Strong'.

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

    Edit it according to ur needs.

    Assign points for the same

    Regards:

    S.Agarwal

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on Sep 28, 2007 at 10:24 AM

    hi ,

    declare a variable like

    data: s_data(100) type c.

    and assign value like this

    s_data+0(12) = 'COMPANY CODE'.

    s_data+13(5) = '99999'.

    s_data+30(4) = 'DATE'.

    and pass the variable above variable to

    w_layout-GRID_TITLE = s_data.

    I hope this will sove ur problem.

    Reward the poit if its use full

    Manikumar

    Add comment
    10|10000 characters needed characters exceeded

    • Here is my code,plzz try to adjust the header by simply running the below code as required:

      REPORT zjpfrap311 .

      &----


      *& Development ID: AP_DD_311_LJP *

      *& *

      *& Report : ZJPFRAP311 *

      *& *

      *& The pupose of this program is *

      &----


      *& Change Log: *

      *& *

      *& Init. Who Date Text *

      *& KK Kunal Kakkar 20-Sep-2007 CR No. 2F003019 *

      &----


      TABLES:bsik, "未決済明細のテーブル

      bsak, "決済明細のテーブル

      lfa1.

      *internal table for output

      DATA:BEGIN OF gt_output OCCURS 500,

      hkont LIKE bsik-hkont,

      lifnr LIKE bsik-lifnr,

      name1 LIKE lfa1-name1,

      belnr LIKE bsik-belnr,

      budat LIKE bsik-budat,

      bldat LIKE bsik-bldat,

      xblnr LIKE bsik-xblnr,

      zlspr LIKE bsik-zlspr,

      zfbdt LIKE bsik-zfbdt,

      dmbtr LIKE bsik-dmbtr,

      sign TYPE c,

      END OF gt_output.

      • other internal tables

      DATA: gt_bsik TYPE bsik OCCURS 0 WITH HEADER LINE,

      gt_bsak TYPE bsik OCCURS 0 WITH HEADER LINE,

      gt_lfa1 TYPE lfa1 OCCURS 0 WITH HEADER LINE.

      • work areas used

      DATA: wa_bsik TYPE bsik,

      wa_bsak TYPE bsak,

      wa_lfa1 TYPE lfa1.

      ----


      • TYPE POOL *

      ----


      TYPE-POOLS: slis.

      • declaration for ALV

      DATA : gt_fieldcat TYPE slis_t_fieldcat_alv,

      gf_fieldcat LIKE LINE OF gt_fieldcat,

      gt_layout TYPE slis_layout_alv,

      gt_events TYPE slis_t_event,

      gt_list_top_of_page TYPE slis_t_listheader,

      g_repid LIKE sy-repid.

      ----


      • Constants

      ----


      CONSTANTS: c_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE',

      c_save(1) TYPE c VALUE 'A'.

      ----


      • Selection screen

      ----


      SELECT-OPTIONS: s_lifnr FOR bsik-lifnr. "vendor code

      PARAMETER: p_bukrs LIKE bsik-bukrs DEFAULT 'JP05'."company code

      SELECT-OPTIONS : s_hkont FOR bsik-hkont."Account code

      PARAMETER: p_zfbdt LIKE bsik-zfbdt."baseline date

      ----


      • INITIALIZATION

      ----


      INITIALIZATION.

      g_repid = sy-repid.

      ----


      • At Selection Screen

      ----


      *AT SELECTION-SCREEN.

      *

      • Validate the material entered by the user

      *AT SELECTION-SCREEN ON s_lifnr.

      • PERFORM validate_vendor.

      *

      • Validate the company code entered by the user

      *AT SELECTION-SCREEN ON p_bukrs.

      • PERFORM validate_compcode.

      *

      **-- Authority Check

      • PERFORM authority_check.

      ----


      • Start of selection

      ----


      START-OF-SELECTION.

      • retreive data from database tables

      PERFORM select_data.

      • arrange data for output

      PERFORM arrange_data.

      • Fill event TOP_OF_PAGE

      PERFORM fill_events USING gt_events.

      • ALV event

      PERFORM built_comment USING gt_list_top_of_page[].

      • build alv field catalogue

      PERFORM build_fieldcat USING :

      '1' 'GT_OUTPUT' 'HKONT' 10 '統制勘定 ',

      '2' 'GT_OUTPUT' 'LIFNR' 15 '仕入先',

      '3' 'GT_OUTPUT' 'NAME1' 40 '仕入先名称 ',

      '4' 'GT_OUTPUT' 'BELNR' 18 '伝票番号',

      '5' 'GT_OUTPUT' 'BUDAT' 18 '転記日付 ',

      '6' 'GT_OUTPUT' 'BLDAT' 18 '伝票日付',

      '7' 'GT_OUTPUT' 'XBLNR' 18 '請求書番号',

      '8' 'GT_OUTPUT' 'ZLSPR' 18 '支払保留キー',

      '9' 'GT_OUTPUT' 'ZFBDT' 18 '支払基準日',

      '10' 'GT_OUTPUT' 'DMBTR' 18 '国内通貨額',

      '11' 'GT_OUTPUT' 'SIGN' 18 '基準日チェック'.

      • ALV grid display

      PERFORM alv_display .

      &----


      *& Form fill_events

      &----


      • text

      ----


      FORM fill_events USING lt_ev TYPE slis_t_event.

      *-- Declaration

      DATA: wa_event TYPE slis_alv_event.

      *-- Read in all possible events

      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

      EXPORTING

      i_list_type = 0

      IMPORTING

      et_events = lt_ev.

      *-- top-of-page

      READ TABLE lt_ev WITH KEY name = slis_ev_top_of_page INTO wa_event.

      IF sy-subrc EQ 0.

      wa_event-form = c_top_of_page.

      MODIFY lt_ev FROM wa_event INDEX sy-tabix.

      ENDIF.

      ENDFORM. " fill_events

      *----


      • FORM TOP_OF_PAGE *

      *----


      • ALV Header *

      *----


      FORM top_of_page. "#EC CALLED

      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

      EXPORTING

      it_list_commentary = gt_list_top_of_page.

      ENDFORM.

      &----


      *& Form built_comment

      &----


      • text

      ----


      FORM built_comment USING gt_list_top_of_page TYPE slis_t_listheader.

      DATA: c_space(30) TYPE c ,

      ls_line TYPE slis_listheader.

      DATA: lv_info(50) TYPE c,

      lv_comcode(100) TYPE c.

      lv_comcode+0(12) = 'COMPANY CODE'.

      lv_comcode+13(5) = '99999'.

      lv_comcode+30(4) = 'DATE'.

      • p_zfbdt

      • Translate lv_comcode using ', '.

      *-- Set title

      ls_line-typ = 'H'.

      ls_line-info = lv_comcode .

      APPEND ls_line TO gt_list_top_of_page.

      *-- Detailed informations

      • CLEAR ls_line.

      • ls_line-typ = 'S'.

      • ls_line-key ='Display'.

      • ls_line-info = sy-tcode.

      • APPEND ls_line TO gt_list_top_of_page.

      ENDFORM. " built_comment

      ----


      • FORM ALV_display *

      ----


      FORM alv_display .

      *function for ALV display

      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

      EXPORTING

      i_callback_program = g_repid

      i_callback_top_of_page = c_top_of_page

      i_grid_title = 'TITLE'

      is_layout = gt_layout

      it_fieldcat = gt_fieldcat[]

      i_save = 'A'

      it_events = gt_events[]

      TABLES

      t_outtab = gt_output

      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.

      &----


      *& Form build_fieldcat

      &----


      • text

      ----


      FORM build_fieldcat USING value(fp_col_pos)

      value(fp_tabname)

      value(fp_field)

      value(fp_len)

      value(fp_descr).

      DATA: wl_fieldcat TYPE slis_fieldcat_alv.

      *&---populate data for fieldcatalog

      CLEAR wl_fieldcat.

      wl_fieldcat-col_pos = fp_col_pos.

      wl_fieldcat-tabname = fp_tabname.

      wl_fieldcat-fieldname = fp_field.

      wl_fieldcat-outputlen = fp_len.

      wl_fieldcat-seltext_l = fp_descr.

      APPEND wl_fieldcat TO gt_fieldcat.

      CLEAR wl_fieldcat.

      ENDFORM. " build_fieldcat

      &----


      *& Form select_data

      &----


      • text

      ----


      FORM select_data.

      *get open items data

      SELECT * FROM bsik

      INTO TABLE gt_bsik

      WHERE bukrs = p_bukrs

      AND lifnr IN s_lifnr

      AND hkont IN s_hkont

      AND zfbdt = p_zfbdt.

      *get cleared items data

      SELECT * FROM bsak

      INTO TABLE gt_bsak

      WHERE bukrs = p_bukrs

      AND lifnr IN s_lifnr

      AND hkont IN s_hkont

      AND zfbdt = p_zfbdt.

      SELECT * FROM lfa1

      INTO TABLE gt_lfa1

      FOR ALL ENTRIES IN gt_bsik

      WHERE lifnr = gt_bsik-lifnr.

      ENDFORM. " select_data

      &----


      *& Form arrange_data

      &----


      • text

      ----


      FORM arrange_data.

      LOOP AT gt_bsik INTO wa_bsik.

      READ TABLE gt_lfa1 INTO wa_lfa1 WITH KEY lifnr = gt_bsik-lifnr.

      gt_output-hkont = wa_bsik-hkont.

      gt_output-lifnr = wa_bsik-lifnr.

      gt_output-name1 = wa_lfa1-name1.

      gt_output-belnr = wa_bsik-belnr.

      gt_output-budat = wa_bsik-budat.

      gt_output-bldat = wa_bsik-bldat.

      gt_output-xblnr = wa_bsik-xblnr.

      gt_output-zlspr = wa_bsik-zlspr.

      gt_output-zfbdt = wa_bsik-zfbdt.

      gt_output-dmbtr = wa_bsik-dmbtr.

      APPEND gt_output.

      ENDLOOP.

      LOOP AT gt_bsak INTO wa_bsak.

      READ TABLE gt_lfa1 INTO wa_lfa1 WITH KEY lifnr = gt_bsak-lifnr.

      gt_output-hkont = wa_bsak-hkont.

      gt_output-lifnr = wa_bsak-lifnr.

      gt_output-name1 = wa_lfa1-name1.

      gt_output-belnr = wa_bsak-belnr.

      gt_output-budat = wa_bsak-budat.

      gt_output-bldat = wa_bsak-bldat.

      gt_output-xblnr = wa_bsak-xblnr.

      gt_output-zlspr = wa_bsak-zlspr.

      gt_output-zfbdt = wa_bsak-zfbdt.

      gt_output-dmbtr = wa_bsak-dmbtr.

      APPEND gt_output.

      ENDLOOP.

      ENDFORM. " arrange_data

      &----


      *& Form authority_check

      &----


      • text

      ----


      FORM authority_check.

      DATA lv_reduced.

      CALL FUNCTION 'Z_0CS_AUTHORITY_CHECK_SITE'

      IMPORTING

      reduced = lv_reduced

      • TABLES

      • R_BUKRS = p_bukrs

      • R_WERKS =

      • R_KOKRS =

      • R_ERKRS =

      • R_VKORG =

      • R_VTWEG =

      • R_EKORG =

      • R_IWERK =

      • R_BWKEY =

      EXCEPTIONS

      no_authorization_at_all = 1

      no_check_control_specified = 2

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

      ENDFORM. " authority_check

      &----


      *& Form validate_vendor

      &----


      • text

      ----


      form validate_vendor.

      DATA: lv_lifnr TYPE lifnr.

      CHECK NOT s_lifnr[] IS INITIAL.

      SELECT SINGLE lifnr FROM lfa1

      INTO lv_lifnr

      WHERE lifnr IN s_lifnr.

      IF sy-subrc <> 0.

      • MESSAGE e000 WITH text-e03.

      ENDIF.

      endform. " validate_vendor

      &----


      *& Form validate_compcode

      &----


      • text

      ----


      form validate_compcode.

      DATA: lv_bukrs TYPE bukrs.

      CHECK NOT p_bukrs IS INITIAL.

      SELECT SINGLE bukrs FROM lfb1

      INTO lv_bukrs

      WHERE lifnr = p_bukrs.

      IF sy-subrc <> 0.

      • MESSAGE e000 WITH text-e03.

      ENDIF.

      endform. " validate_compcode

  • author's profile photo
    Former Member
    Posted on Sep 28, 2007 at 11:14 AM

    Hi kunal,

    Use wirte statement.

    example :

    data: lv_text type char50.

    write: 'Example' to lv_text.

    write: ':-' to lv_text+10.

    and the use the data variable

    ie slis_listheader-text = lv_Text.

    Hope this will meet ur reqirement.

    regards,

    Santosh

    Add comment
    10|10000 characters needed characters exceeded