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

alv header??

hi experts,

i want to print a header text under which there will be certain coloumns with sub colom heading.the sub colom can be printed with fieldcatalog reptext_ddic

but how shall i print the main header ???

eg.

sales document data

-


sales org

division

i want ot know how to print 'sales documnet data' in alv grid

plz help me as it is urgent.

thank you

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Posted on Sep 09, 2007 at 06:01 AM

    Hi,

    For adding top of page

        call function 'REUSE_ALV_GRID_DISPLAY'
          exporting
            it_fieldcat                 = pt_grpfcat[]
            it_excluding                = p_grpexcltab2[]
            is_layout                   = pt_grplayout2
            i_callback_program          = sy-repid
            i_callback_html_top_of_page = 'HTML_TOP_OF_PAGE2'
            i_callback_pf_status_set    = v_status_set1
            i_callback_user_command     = v_user_command1
            i_screen_start_column       = 25
            i_screen_start_line         = 5
            i_screen_end_column         = 80
            i_screen_end_line           = 20
            it_events                   = i_events[]
          tables
            t_outtab                    = i_grpoutput.
    
    
    *&---------------------------------------------------------------------*
    * Form html_top_of_page2                                               *
    *&---------------------------------------------------------------------*
    * For top commentary for grid                                          *
    *&---------------------------------------------------------------------*
    form html_top_of_page2 using document type ref to cl_dd_document.
    
      data: text type sdydo_text_element.
        text = 'sales document data'.
    
      call method document->add_text
        exporting
          text         = text
          sap_style    = space
          sap_color    = space
          sap_fontsize = cl_dd_document=>medium
          sap_emphasis = cl_dd_document=>strong
          style_class  = space.
      call method document->new_line.
      call method document->add_gap
        exporting
          width = 3.
    
        text = '--------------------------'.
    
      call method document->add_text
        exporting
          text         = text
          sap_style    = space
          sap_color    = space
          sap_fontsize = cl_dd_document=>medium
          sap_emphasis = cl_dd_document=>strong
          style_class  = space.
      call method document->add_gap
        exporting
          width = 1.
    
    
    endform.                                 " Html_top_of_page2
    *
    

    Add a comment
    10|10000 characters needed characters exceeded

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

    hii

    sir,

    i tries this one. but it is comming at hrader portion.

    but i want it in the main header of few couloms under which the actual colom heading will come.the sub heading can be printed using fieldcatalog reptext_ddic.

    <b>but HOW MAIN HEADER CAN PRINTED.</b>

    PLZ HELP.

    THANK YOU.<b></b>

    Add a comment
    10|10000 characters needed characters exceeded

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

    &----


    *& Form sub_table_display

    &----


    • Set table for First Display

    ----


    FORM sub_table_display .

    DATA: lv_date TYPE c LENGTH 10 ,

    lv_time TYPE c LENGTH 8 ,

    lv_text TYPE string.

    CLEAR : lv_date,

    lv_time,

    lv_text.

    • Set Table for first display

    <b>WRITE sy-datum TO lv_date DD/MM/YYYY.

    WRITE sy-uzeit TO lv_time USING EDIT MASK '__:__:__'.

    CONCATENATE text-003 text-004 lv_date text-005 lv_time INTO lv_text RESPECTING BLANKS.

    gs_layo-grid_title = lv_text.

    gs_layo-smalltitle = gc_flag .</b>

    <b>Note: gc_flag = X and TEXT

    003 Report Name

    004 Date:

    005 Time:

    and gs_layo TYPE lvc_s_layo, " ALV control: Layout structure

    </b>

    CALL METHOD go_grid->set_table_for_first_display

    EXPORTING

    is_variant = gs_variant

    i_save = gc_save

    i_default = abap_true

    is_layout = gs_layo

    CHANGING

    it_outtab = gt_final[]

    it_fieldcatalog = gt_fcat.

    ENDFORM. " sub_table_display

    Rewards points if useful..................

    Minal

    Add a comment
    10|10000 characters needed characters exceeded

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

    hi,

    try this code.

    &----


    *& Report ZPROGRAM

    *&

    &----


    *&

    *&

    &----


    REPORT ZPROGRAM.

    • table declaration.

    tables : zemployee, zdepartment,zproject.

    *type-pools declaration

    type-pools : slis , icon.

    • type specification

    types : begin of ty_emp,

    empid type zempid,

    empname type zempname,

    empaddress type zempaddress,

    city type zcity,

    ponumber type zponumber,

    detid type zdeptid,

    salary type zsalary,

    end of ty_emp.

    types : begin of ty_dept,

    detid type zdeptid,

    deptname type zdeptname,

    designation type zdesignation,

    projectid type zprojectid,

    end of ty_dept.

    types : begin of ty_project,

    projectid type zprojectid,

    technology type ztechnology,

    clientname type zclientname,

    end of ty_project.

    types : begin of ty_final,

    empid type zempid,

    empname type zempname,

    empaddress type zempaddress,

    city type zcity,

    ponumber type zponumber,

    detid type zdeptid,

    deptname type zdeptname,

    designation type zdesignation,

    projectid type zprojectid,

    technology type ztechnology,

    clientname type zclientname,

    salary type zsalary,

    • average type p decimals 2,

    end of ty_final.

    • table type specification.

    types : tt_emp type standard table of ty_emp,

    tt_dept type standard table of ty_dept,

    tt_project type standard table of ty_project,

    tt_final type standard table of ty_final.

    • work area creation.

    data : wa_emp type ty_emp,

    wa_dept type ty_dept,

    wa_project type ty_project,

    wa_final type ty_final.

    • internal table declaration

    data : itab_emp type tt_emp,

    itab_dept type tt_dept,

    itab_project type tt_project,

    itab_final type tt_final.

    • layout declaration

    data : gd_layout type slis_layout_alv.

    • assigning current program name.

    data : gd_repid like sy-repid.

    gd_repid = sy-repid.

    • fieldcatalog declaration.

    data : d_fieldcat type slis_t_fieldcat_alv,

    d_fieldcat_wa type slis_fieldcat_alv.

    • header declaration.

    data : t_header type slis_t_listheader,

    wa_header type slis_listheader,

    linecount(10) type c,

    line(10) type c.

    • selection-screen.

    selection-screen : begin of block blk1 with frame title text-001.

    select-options : s_empid for zemployee-empid.

    parameters : p_dname like zdepartment-deptname.

    parameters : p_name like zemployee-empname matchcode object ZSEARCH_EMP.

    selection-screen : begin of line.

    parameters : p_rad1 radiobutton group r1.

    selection-screen comment 3(10) text-002.

    parameters : p_rad2 radiobutton group r1.

    selection-screen comment 16(10) text-003.

    selection-screen : end of line.

    parameters : chk1 as checkbox.

    selection-screen : end of block blk1.

    • end of selection screen.

    • start of selection.

    select empid empname empaddress city salary ponumber detid from zemployee into corresponding fields of table itab_emp where empid in s_empid.

    if not itab_emp is initial.

    select detid deptname designation projectid from zdepartment into corresponding fields of table itab_dept for all entries in itab_emp where detid = itab_emp-detid .

    if not itab_dept is initial.

    select projectid technology clientname from zproject into corresponding fields of table itab_project for all entries in itab_dept where projectid = itab_dept-projectid.

    endif.

    endif.

    *end of selection.

    • populating data into itab_final from itab_emp.

    loop at itab_emp into wa_emp.

    wa_final-empid = wa_emp-empid.

    wa_final-empname = wa_emp-empname.

    wa_final-empaddress = wa_emp-empaddress.

    wa_final-ponumber = wa_emp-ponumber.

    wa_final-city = wa_emp-city.

    wa_final-salary = wa_emp-salary.

    wa_final-detid = wa_emp-detid.

    append wa_final to itab_final.

    clear wa_final.

    endloop.

    *populating data into itab_final from itab_dept and itab_project

    loop at itab_final into wa_final.

    read table itab_dept into wa_dept with key detid = wa_final-detid.

    if sy-subrc = 0.

    wa_final-deptname = wa_dept-deptname.

    wa_final-designation = wa_dept-designation.

    wa_final-projectid = wa_dept-projectid.

    modify itab_final from wa_final transporting deptname designation projectid .

    endif.

    read table itab_project into wa_project with key projectid = wa_final-projectid.

    if sy-subrc = 0.

    wa_final-technology = wa_project-technology.

    wa_final-clientname = wa_project-clientname.

    modify itab_final from wa_final transporting technology clientname.

    endif.

    endloop.

    if p_rad1 = 'X' or chk1 = 'X'.

    d_fieldcat_wa-fieldname = 'EMPID'.

    d_fieldcat_wa-seltext_l = 'Employee Id'.

    d_fieldcat_wa-emphasize = 'X'.

    d_fieldcat_wa-col_pos = 1.

    append d_fieldcat_wa to d_fieldcat.

    clear d_fieldcat_wa.

    d_fieldcat_wa-fieldname = 'EMPNAME'.

    d_fieldcat_wa-seltext_l = 'Employee Name'.

    d_fieldcat_wa-emphasize = 'C710'.

    d_fieldcat_wa-col_pos = 2.

    append d_fieldcat_wa to d_fieldcat.

    clear d_fieldcat_wa.

    d_fieldcat_wa-fieldname = 'EMPADDRESS'.

    d_fieldcat_wa-seltext_l = 'Employee Address'.

    d_fieldcat_wa-emphasize = 'C710'.

    d_fieldcat_wa-col_pos = 3.

    append d_fieldcat_wa to d_fieldcat.

    clear d_fieldcat_wa.

    d_fieldcat_wa-fieldname = 'CITY'.

    d_fieldcat_wa-seltext_l = 'City'.

    d_fieldcat_wa-emphasize = 'C710'.

    d_fieldcat_wa-col_pos = 4.

    append d_fieldcat_wa to d_fieldcat.

    clear d_fieldcat_wa.

    d_fieldcat_wa-fieldname = 'PONUMBER'.

    d_fieldcat_wa-seltext_l = 'Postal Number'.

    d_fieldcat_wa-emphasize = 'C710'.

    d_fieldcat_wa-col_pos = 5.

    append d_fieldcat_wa to d_fieldcat.

    clear d_fieldcat_wa.

    d_fieldcat_wa-fieldname = 'DETID'.

    d_fieldcat_wa-seltext_l = 'Department Id'.

    d_fieldcat_wa-emphasize = 'X'.

    d_fieldcat_wa-col_pos = 6.

    append d_fieldcat_wa to d_fieldcat.

    clear d_fieldcat_wa.

    d_fieldcat_wa-fieldname = 'DEPTNAME'.

    d_fieldcat_wa-seltext_l = 'Department Name'.

    d_fieldcat_wa-emphasize = 'C710'.

    d_fieldcat_wa-col_pos = 7.

    append d_fieldcat_wa to d_fieldcat.

    clear d_fieldcat_wa.

    d_fieldcat_wa-fieldname = 'DESIGNATION'.

    d_fieldcat_wa-seltext_l = 'Designation'.

    d_fieldcat_wa-emphasize = 'C710'.

    d_fieldcat_wa-col_pos = 8.

    append d_fieldcat_wa to d_fieldcat.

    clear d_fieldcat_wa.

    d_fieldcat_wa-fieldname = 'PROJECTID'.

    d_fieldcat_wa-seltext_l = 'Project Id'.

    d_fieldcat_wa-emphasize = 'X'.

    d_fieldcat_wa-col_pos = 9.

    append d_fieldcat_wa to d_fieldcat.

    clear d_fieldcat_wa.

    d_fieldcat_wa-fieldname = 'TECHNOLOGY'.

    d_fieldcat_wa-seltext_l = 'technology'.

    d_fieldcat_wa-emphasize = 'C710'.

    d_fieldcat_wa-col_pos = 10.

    append d_fieldcat_wa to d_fieldcat.

    clear d_fieldcat_wa.

    d_fieldcat_wa-fieldname = 'CLIENTNAME'.

    d_fieldcat_wa-seltext_l = 'Client Name'.

    d_fieldcat_wa-emphasize = 'C710'.

    d_fieldcat_wa-col_pos = 11.

    append d_fieldcat_wa to d_fieldcat.

    clear d_fieldcat_wa.

    d_fieldcat_wa-fieldname = 'SALARY'.

    d_fieldcat_wa-seltext_l = 'Employee Salary'.

    d_fieldcat_wa-do_sum = 'X'.

    d_fieldcat_wa-emphasize = 'C710'.

    d_fieldcat_wa-col_pos = 12.

    append d_fieldcat_wa to d_fieldcat.

    clear d_fieldcat_wa.

    endif.

    if p_rad2 = 'X' or chk1 = 'X'.

    refresh itab_emp.

    d_fieldcat_wa-fieldname = 'DETID'.

    d_fieldcat_wa-seltext_l = 'Department Id'.

    d_fieldcat_wa-emphasize = 'C710'.

    d_fieldcat_wa-col_pos = 6.

    append d_fieldcat_wa to d_fieldcat.

    clear d_fieldcat_wa.

    d_fieldcat_wa-fieldname = 'DEPTNAME'.

    d_fieldcat_wa-seltext_l = 'Department Name'.

    d_fieldcat_wa-emphasize = 'C710'.

    d_fieldcat_wa-col_pos = 7.

    append d_fieldcat_wa to d_fieldcat.

    clear d_fieldcat_wa.

    d_fieldcat_wa-fieldname = 'DESIGNATION'.

    d_fieldcat_wa-seltext_l = 'Designation'.

    d_fieldcat_wa-emphasize = 'C710'.

    d_fieldcat_wa-col_pos = 8.

    append d_fieldcat_wa to d_fieldcat.

    clear d_fieldcat_wa.

    d_fieldcat_wa-fieldname = 'PROJECTID'.

    d_fieldcat_wa-seltext_l = 'Project Id'.

    d_fieldcat_wa-emphasize = 'C710'.

    d_fieldcat_wa-col_pos = 9.

    append d_fieldcat_wa to d_fieldcat.

    clear d_fieldcat_wa.

    d_fieldcat_wa-fieldname = 'TECHNOLOGY'.

    d_fieldcat_wa-seltext_l = 'technology'.

    d_fieldcat_wa-emphasize = 'C710'.

    d_fieldcat_wa-col_pos = 10.

    append d_fieldcat_wa to d_fieldcat.

    clear d_fieldcat_wa.

    d_fieldcat_wa-fieldname = 'CLIENTNAME'.

    d_fieldcat_wa-seltext_l = 'Client Name'.

    d_fieldcat_wa-emphasize = 'C710'.

    d_fieldcat_wa-col_pos = 11.

    append d_fieldcat_wa to d_fieldcat.

    clear d_fieldcat_wa.

    endif.

    • Grid display function module

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    • I_INTERFACE_CHECK = ' '

    • I_BYPASSING_BUFFER = ' '

    • I_BUFFER_ACTIVE = ' '

    I_CALLBACK_PROGRAM = gd_repid

    I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'

    • I_CALLBACK_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 = 'EMPLOYEE DETAILS'

    • I_GRID_SETTINGS =

    IS_LAYOUT = gd_layout

    IT_FIELDCAT = d_fieldcat

    • IT_EXCLUDING =

    • IT_SPECIAL_GROUPS =

    • IT_SORT =

    • IT_FILTER =

    • IS_SEL_HIDE =

    • I_DEFAULT = 'X'

    • I_SAVE = ' '

    • IS_VARIANT =

    • 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

    • I_HTML_HEIGHT_TOP = 0

    • I_HTML_HEIGHT_END = 0

    • IT_ALV_GRAPHICS =

    • IT_HYPERLINK =

    • IT_ADD_FIELDCAT =

    • IT_EXCEPT_QINFO =

    • IR_SALV_FULLSCREEN_ADAPTER =

    • IMPORTING

    • E_EXIT_CAUSED_BY_CALLER =

    • ES_EXIT_CAUSED_BY_USER =

    TABLES

    T_OUTTAB = itab_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.

    • set pf_status for creating client specified icons.

    form set_pf_status using rt_extab type slis_t_extab.

    set pf-status 'NEWSTATUS'.

    endform.

    • populating data into header using top_of_page

    form top_of_page.

    wa_header-typ = 'H'.

    wa_header-info = 'ALV REPORT'.

    append wa_header to t_header.

    clear wa_header.

    wa_header-typ = 'S'.

    wa_header-key = 'Date :'.

    Concatenate sy-datum+6(2) '.'

    sy-datum+4(2) '.'

    sy-datum(4) into wa_header-info.

    append wa_header to t_header.

    clear wa_header.

    wa_header-typ = 'S'.

    wa_header-key = 'Time :'.

    Concatenate sy-Uzeit(2) '.'

    sy-datum+2(2) '.'

    sy-datum+4(2) into wa_header-info.

    append wa_header to t_header.

    clear wa_header.

    describe table itab_final lines line.

    wa_header-typ = 'A'.

    linecount = line.

    Concatenate 'Total number of records :' linecount into wa_header-info separated by space.

    append wa_header to t_header.

    clear wa_header.

    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

    EXPORTING

    IT_LIST_COMMENTARY = t_header

    I_LOGO = 'VMCADMIN'

    • I_END_OF_LIST_GRID =

    • I_ALV_FORM =

    .

    endform.

    *designing layout.

    form gd_layout.

    gd_layout-zebra = 'X'.

    gd_layout-edit = 'X'.

    gd_layout-no_hotspot = ''.

    gd_layout-no_colhead = ''.

    gd_layout-colwidth_optimize = 'X'.

    endform.

    Reward with points if helpful.

    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.