Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Heading in ALV report is showing up blank

Former Member
0 Kudos
1,357

Hello Friends

First of all thanks to you all for giving so much of help. I appreciate it.

I would appreciate if some could please let me know, why my code is not printing the header in my ALV report. It shows up as blank. I have written the Form 'TOP-OF-PAGE'.

Thanks a lot in advance

Ram

1 ACCEPTED SOLUTION

Former Member
0 Kudos
237

Hello Ram,

cechk this sample:


FORM REPORT_HEADING .

* Work Area TOP-OF-PAGE commentary
  DATA: WA_COMMENTARY TYPE SLIS_LISTHEADER,
        L_F_INFO(132),
        L_F_DATUM(10),
        L_F_TIME(8),
        L_F_LOW LIKE PRPS-POSID,
        L_F_HIGH LIKE PRPS-POSID,
        L_F_DATL(10),
        L_F_DATH(10).

  CLEAR : WA_COMMENTARY,
          IT_COMMENTARY,
          IT_COMMENTARY[].

  CONCATENATE TEXT-013 SY-REPID INTO L_F_INFO
                                              SEPARATED BY '   '.
  WA_COMMENTARY-TYP  = 'H'.
  WA_COMMENTARY-INFO = L_F_INFO.
  APPEND WA_COMMENTARY TO IT_COMMENTARY.

  WRITE SY-DATUM TO L_F_DATUM.
  WRITE SY-UZEIT TO L_F_TIME.
  CONCATENATE TEXT-017 L_F_DATUM TEXT-018 L_F_TIME INTO L_F_INFO
                                    SEPARATED BY '         '.
  WA_COMMENTARY-TYP  = 'S'.
  WA_COMMENTARY-INFO = L_F_INFO.
  APPEND WA_COMMENTARY TO IT_COMMENTARY.

  L_F_INFO = TEXT-001.
  WA_COMMENTARY-TYP  = 'S'.
  WA_COMMENTARY-INFO = L_F_INFO.
  APPEND WA_COMMENTARY TO IT_COMMENTARY.

  IF NOT S_PROJ[] IS INITIAL.
    READ TABLE S_PROJ INDEX 1.
    CALL FUNCTION 'CONVERSION_EXIT_ABPSN_OUTPUT'
         EXPORTING
              INPUT  = S_PROJ-LOW
         IMPORTING
              OUTPUT = L_F_LOW.
    IF L_F_LOW IS INITIAL.
      L_F_LOW = SPACE.
    ENDIF.
    CALL FUNCTION 'CONVERSION_EXIT_ABPSN_OUTPUT'
         EXPORTING
              INPUT  = S_PROJ-HIGH
         IMPORTING
              OUTPUT = L_F_HIGH.
    IF L_F_HIGH IS INITIAL.
      L_F_HIGH = SPACE.
    ENDIF.
    IF S_PROJ-OPTION = 'EQ'.
      CONCATENATE TEXT-023 ':' L_F_LOW TEXT-020 L_F_HIGH '+' INTO
                            L_F_INFO SEPARATED BY '    '.

    ELSE.
      CONCATENATE TEXT-023 ':' L_F_LOW TEXT-020 L_F_HIGH INTO
                              L_F_INFO SEPARATED BY '    '.
    ENDIF.
  ELSE.
    CONCATENATE TEXT-023 ':' TEXT-021 INTO
                            L_F_INFO SEPARATED BY '    '.

  ENDIF.
  WA_COMMENTARY-TYP  = 'S'.
  WA_COMMENTARY-INFO = L_F_INFO.
  APPEND WA_COMMENTARY TO IT_COMMENTARY.

  IF NOT S_WBS[] IS INITIAL.
    READ TABLE S_WBS INDEX 1.
    CALL FUNCTION 'CONVERSION_EXIT_ABPSN_OUTPUT'
         EXPORTING
              INPUT  = S_WBS-LOW
         IMPORTING
              OUTPUT = L_F_LOW.
    IF L_F_LOW IS INITIAL.
      L_F_LOW = SPACE.
    ENDIF.
    CALL FUNCTION 'CONVERSION_EXIT_ABPSN_OUTPUT'
         EXPORTING
              INPUT  = S_WBS-HIGH
         IMPORTING
              OUTPUT = L_F_HIGH.
    IF S_WBS-OPTION = 'EQ'.
      CONCATENATE TEXT-005 ':' L_F_LOW L_F_HIGH '+' INTO
                            L_F_INFO SEPARATED BY '    '.
    ELSE.
      CONCATENATE TEXT-023 ':' L_F_LOW TEXT-020 L_F_HIGH INTO
                              L_F_INFO SEPARATED BY '    '.

    ENDIF.
  ELSE.
    CONCATENATE TEXT-005 ':' TEXT-021 INTO
                            L_F_INFO SEPARATED BY '    '.

  ENDIF.
  WA_COMMENTARY-TYP  = 'S'.
  WA_COMMENTARY-INFO = L_F_INFO.
  APPEND WA_COMMENTARY TO IT_COMMENTARY.
  IF NOT S_VKBUR[] IS INITIAL.
    READ TABLE S_VKBUR INDEX 1.
    IF S_VKBUR-OPTION = 'EQ'.
    CONCATENATE TEXT-004 ':' S_VKBUR-LOW TEXT-020 S_VKBUR-HIGH '+' INTO
                                           L_F_INFO SEPARATED BY '    '.
    ELSE.
      CONCATENATE TEXT-004 ':' S_VKBUR-LOW TEXT-020 S_VKBUR-HIGH INTO
                              L_F_INFO SEPARATED BY '    '.
    ENDIF.
  ELSE.
    CONCATENATE TEXT-004 ':' TEXT-021 INTO
                          L_F_INFO SEPARATED BY '    '.
  ENDIF.


  WA_COMMENTARY-TYP  = 'S'.
  WA_COMMENTARY-INFO = L_F_INFO.
  APPEND WA_COMMENTARY TO IT_COMMENTARY.
  IF NOT S_AUDAT[] IS INITIAL.
    READ TABLE S_AUDAT INDEX 1.
    WRITE: S_AUDAT-LOW TO L_F_DATL,
           S_AUDAT-HIGH TO L_F_DATH.
    IF S_AUDAT-OPTION = 'EQ'.
      CONCATENATE TEXT-014 ':' L_F_DATL TEXT-020 L_F_DATH '+' INTO
                                           L_F_INFO SEPARATED BY '    '.
    ELSE.
      CONCATENATE TEXT-014 ':' L_F_DATL TEXT-020 L_F_DATH INTO
                              L_F_INFO SEPARATED BY '    '.
    ENDIF.
  ELSE.
    CONCATENATE TEXT-014 ':' TEXT-021 INTO
                          L_F_INFO SEPARATED BY '    '.
  ENDIF.

  WA_COMMENTARY-TYP  = 'S'.
  WA_COMMENTARY-INFO = L_F_INFO.
  APPEND WA_COMMENTARY TO IT_COMMENTARY.

  CONCATENATE TEXT-015 ':'  P_FILE INTO L_F_INFO SEPARATED BY '    '.
  WA_COMMENTARY-TYP  = 'S'.
  WA_COMMENTARY-INFO = L_F_INFO.
  APPEND WA_COMMENTARY TO IT_COMMENTARY.
  IF NOT P_TAB IS INITIAL.
    CONCATENATE TEXT-016 ':' TEXT-019 INTO L_F_INFO SEPARATED BY '    '.
  ELSE.
    CONCATENATE TEXT-016 ':' P_TRZEI INTO L_F_INFO SEPARATED BY '    '.
  ENDIF.
  WA_COMMENTARY-TYP  = 'S'.
  WA_COMMENTARY-INFO = L_F_INFO.
  APPEND WA_COMMENTARY TO IT_COMMENTARY.
ENDFORM.                    " REPORT_HEADING
FORM ALV_DISPLAY .
  DATA: IT_VARIANT LIKE DISVARIANT.
* For storing the variant layout
  IT_VARIANT-REPORT  = SY-REPID.
  CLEAR G_T_OUTTAB.
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
            I_CALLBACK_PROGRAM     = IT_VARIANT-REPORT
            I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
            IT_FIELDCAT            = IT_FIELDCAT
            I_SAVE                 = 'A'
            IS_VARIANT             = IT_VARIANT
       TABLES
            T_OUTTAB               = G_T_OUTTAB
       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  TOP-OF-PAGE
*&---------------------------------------------------------------------*
*        For Top of page
*----------------------------------------------------------------------*

FORM TOP_OF_PAGE.                                           "#EC CALLED

  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
       EXPORTING
            IT_LIST_COMMENTARY = IT_COMMENTARY.

ENDFORM.                    "top_of_page

If usefulreward.

Vasanth

8 REPLIES 8

Former Member
0 Kudos
237

There was a typo. In ALV GRID function, I had typed the form name wrong. It has to be 'ALV_TOP_OF_PAGE'. But still the problem exists.

Hope to hear from some one.

THanks a lot

Ram

Former Member
0 Kudos
237

HI,

Can you post ur code?

0 Kudos
237

Thanks priya for the response.

Fortunately I figured out the problem. I had the following function missing 'REUSE_ALV_COMMENTARY_WRITE'

and adding that helped.

Thanks anyway. I appreciate your response.

Ram

Former Member
0 Kudos
237

This coding will give u the solution ....

this is an interactive ALV ...

*&----


*

*& Report ZMR001_MATERIAL_STOCK_VALUE

*&

*&----


*

*&

*&

*&----


*

REPORT zmr001_material_stock_value.

*----


*

  • MODULE MMxxxxxxxx. *

*----


*

  • Objective :.......................................... *

  • Program : Updates Tables ( ) Downloads data ( ) *

  • Outputs List ( ) *

  • Technical Spec No ............... *

  • Date Created 07/12/2006 *

  • Author Jayakumar.T.... *

  • Location April Business / Banglore *

  • LDB ..... *

*----


*

  • External Dependencies *

*----


*

  • *

*----


*

  • Amendment History *

*----


*

  • Who Change ID Reason *

  • ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ *

  • XXXXXXXXX AADDMMYYYY Where XXXX = Developers Name................. *

  • AA- Developers Initial ................................ *

*----


*

  • Includes *

*----


*

*INCLUDE : *

*----


*

  • Tables *

*----


*

*TABLES : *

TABLES : mchb , mara , mbew , tvkos , t001w.

*----


*

  • Types Begin with TY_ *

*----


*

*TYPES : *

TYPES : BEGIN OF ty_mchb,

matnr LIKE mchb-matnr,

charg LIKE mchb-charg,

clabs LIKE mchb-clabs,

werks LIKE mchb-werks,

spart LIKE mara-spart,

maktx LIKE makt-maktx,

value LIKE mchb-clabs,

total LIKE mchb-clabs,

END OF ty_mchb.

TYPE-POOLS: slis.

CONSTANTS:

c_formname_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE'.

DATA gt_list_top_of_page TYPE slis_t_listheader.

*----


*

  • Constants Begin with C_ *

*----


*

*CONSTANTS: *

*----


*

  • Data Begin with W_ *

*----


*

*DATA : *

*----


*

  • Infotypes ( HR Module Specific) *

*----


*

*INFOTYPES : *

*----


*

  • Internal tables Begin with IT_ *

*----


*

*DATA : *

DATA : it_mchb TYPE TABLE OF ty_mchb,

wa_mchb TYPE ty_mchb ,

it_final TYPE TABLE OF ty_mchb,

wa_final TYPE ty_mchb,

it_temp TYPE TABLE OF ty_mchb,

wa_temp TYPE ty_mchb,

it_temp1 TYPE TABLE OF ty_mchb,

wa_temp1 TYPE ty_mchb

.

DATA: it_listheader TYPE slis_t_listheader.

*----


*

  • Field Symbols Begin with FS_ *

*----


*

*FIELD-SYMBOLS: *

*----


*

  • Insert *

*----


*

*INSERT : *

*----


*

  • Select Options Begin with SO_ *

*----


*

*SELECT-OPTIONS : *

*----


*

  • Parameters Begin with PR_ *

*----


*

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001 .

PARAMETERS : pr_vkorg LIKE tvko-vkorg OBLIGATORY .

SELECT-OPTIONS : so_werks FOR mchb-werks.

SELECT-OPTIONS : so_spart FOR mara-spart.

SELECTION-SCREEN END OF BLOCK b1.

*----


*

  • Initialisation *

*----


*

*INITIALISATION :

DATA: wa_variant LIKE disvariant , "Variant

wa_fieldcat TYPE slis_fieldcat_alv ,

it_fieldcat TYPE slis_t_fieldcat_alv ,

it_fieldcat1 TYPE slis_t_fieldcat_alv ,

wa_layout TYPE slis_layout_alv ,

wa_print TYPE slis_print_alv ,

it_sort TYPE slis_t_sortinfo_alv ,

it_sp_group TYPE slis_t_sp_group_alv ,

it_events TYPE slis_t_event ,

it_list_top_of_page TYPE slis_t_listheader,

w_title1 TYPE lvc_title,

w_datum LIKE sy-datum.

DATA slis_ev_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE'.

DATA w_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE'. " for top of page

DATA it_event TYPE slis_t_event.

INITIALIZATION.

PERFORM eventtab_build USING it_event[].

*set pf-status '002'.

*----


*

  • At selection-screen *

*----


*

AT SELECTION-SCREEN.

SELECT SINGLE * FROM tvkos WHERE vkorg = pr_vkorg AND spart IN so_spart.

IF sy-subrc NE 0 .

MESSAGE text-008 TYPE 'E'.

ENDIF.

SELECT SINGLE * FROM t001w WHERE vkorg = pr_vkorg AND werks IN so_werks.

IF sy-subrc NE 0 .

MESSAGE text-009 TYPE 'E'.

ENDIF.

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

  • S T A R T O F S E L E C T I O N *

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

START-OF-SELECTION.

SELECT mc~matnr charg clabs werks spart maktx

INTO CORRESPONDING

FIELDS OF TABLE it_mchb FROM mchb AS mc

INNER JOIN mara AS ma

ON mamatnr = mcmatnr

INNER JOIN makt AS mt

ON mamatnr = mtmatnr

WHERE werks IN so_werks AND

spart IN so_spart

AND spras = 'EN'

.

      • it_temp[] = it_mchb[].

***

      • SORT it_temp BY matnr.

***

      • DELETE ADJACENT DUPLICATES FROM it_temp COMPARING matnr.

***

***

      • LOOP AT it_temp INTO wa_temp.

***

      • it_temp1[] = it_mchb[].

***

      • DELETE it_temp1 WHERE matnr NE wa_temp-matnr.

***

      • LOOP AT it_temp1 INTO wa_temp1.

      • SUM.

      • EXIT.

      • ENDLOOP.

***

      • wa_final-matnr = wa_temp1-matnr.

      • wa_final-charg = wa_temp1-charg.

      • wa_final-maktx = wa_temp1-maktx.

      • wa_final-clabs = wa_temp1-clabs.

      • wa_final-werks = wa_temp1-werks.

      • wa_final-spart = wa_temp1-spart.

***

      • APPEND wa_final TO it_final.

***

***

      • ENDLOOP.

SORT it_mchb BY matnr.

LOOP AT it_mchb INTO wa_mchb.

ON CHANGE OF wa_mchb-matnr.

IF wa_final-matnr IS NOT INITIAL.

SELECT SINGLE * FROM mbew WHERE matnr = wa_final-matnr

AND bwkey = wa_final-werks.

IF mbew-vprsv = 'V'.

wa_final-value = mbew-verpr.

ELSEIF mbew-vprsv = 'S'.

wa_final-value = mbew-stprs.

ENDIF.

wa_final-total = wa_final-value * wa_final-clabs.

APPEND wa_final TO it_final.

CLEAR wa_final.

ENDIF.

ENDON.

wa_final-clabs = wa_mchb-clabs + wa_final-clabs .

wa_final-matnr = wa_mchb-matnr.

wa_final-werks = wa_mchb-werks.

wa_final-charg = wa_mchb-charg.

wa_final-maktx = wa_mchb-maktx.

ENDLOOP.

IF it_final IS INITIAL.

MESSAGE text-010 TYPE 'I'.

ELSE.

PERFORM fieldcat.

PERFORM display_data.

ENDIF.

        • LOOP AT it_mchb INTO wa_mchb.

****

        • WRITE : / , wa_mchb-matnr , wa_mchb-charg , wa_mchb-maktx , wa_mchb-clabs , wa_mchb-werks , wa_mchb-spart .

****

        • ENDLOOP.

****

        • WRITE : / , 'Jaya'.

****

        • LOOP AT it_final INTO wa_final.

****

        • WRITE : / , wa_final-matnr , wa_final-charg , wa_final-maktx , wa_final-clabs , wa_final-werks , wa_final-spart .

****

        • ENDLOOP.

*GET XX.

*END-OF-SELECTION.

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

  • E N D O F S E L E C T I O N *

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

  • At line selection *

*----


*

*AT LINE-SELECTION.

*----


*

  • User Command Processing *

*----


*

*AT USER-COMMAND.

*----


*

  • Top Of Page *

*----


*

*TOP-OF-PAGE.

*----


*

  • End Of Page *

*----


*

*END-OF-PAGE.

FORM eventtab_build USING rt_events TYPE slis_t_event.

*"Registration of events to happen during list display

DATA: ls_event TYPE slis_alv_event.

  • to get the events

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

i_list_type = 0

IMPORTING

et_events = rt_events.

READ TABLE rt_events INTO ls_event WITH KEY name = slis_ev_top_of_page

.

IF sy-subrc = 0.

ls_event-form = slis_ev_top_of_page.

MODIFY rt_events FROM ls_event TRANSPORTING form WHERE

name = ls_event-form.

ENDIF.

****

READ TABLE rt_events INTO ls_event WITH KEY name = 'USER_COMMAND'.

IF sy-subrc EQ 0.

ls_event-form = 'USER_COMMAND'.

MODIFY rt_events FROM ls_event TRANSPORTING form WHERE name = ls_event-name.

ENDIF.

ENDFORM. "eventtab_build

*&----


*

*& Form fieldcat

*&----


*

FORM fieldcat .

CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'MATNR'.

wa_fieldcat-seltext_m = text-002 .

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'MAKTX'.

wa_fieldcat-seltext_m = text-003 .

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'CLABS'.

wa_fieldcat-seltext_m = text-004 .

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'VALUE'.

wa_fieldcat-seltext_m = text-006 .

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'TOTAL'.

wa_fieldcat-seltext_m = text-007 .

APPEND wa_fieldcat TO it_fieldcat.

ENDFORM. "fieldcat

*&----


*

*& Form display_data

*&----


*

FORM display_data .

PERFORM comment_build USING gt_list_top_of_page[].

wa_layout-info_fieldname = 'LINE_COLOR'. " Line Color

wa_print-no_coverpage = 'X'.

wa_print-no_print_listinfos = 'X'. " Remove the default first page.

  • to get thr grid display

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = sy-repid

  • i_background_id = 'ALV_BACKGROUND'

  • i_callback_top_of_page = 'TOP_OF_PAGE'

i_callback_user_command = 'USER_COMMAND'

  • is_layout = wa_layout

it_fieldcat = it_fieldcat

  • i_default = 'X'

i_save = 'A'

it_events = it_event[]

  • is_print = wa_print

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. " eventtab_build

*&----


*

*& Form comment_build

*&----


*

FORM comment_build USING lt_top_of_page TYPE slis_t_listheader.

DATA: ls_line TYPE slis_listheader.

CLEAR ls_line.

ls_line-typ = 'H'.

  • to get the company text

DATA w_name(50) TYPE c.

ls_line-info = text-005 .

APPEND ls_line TO lt_top_of_page.

CLEAR ls_line.

ls_line-typ = 'S'.

ls_line-info = ''.

APPEND ls_line TO lt_top_of_page.

ENDFORM. "comment_build

*&----


*

*& Form top_of_page

*&----


*

  • to print at top of page

*----


*

FORM top_of_page.

  • to pass the comment bulid for the top of page into the alv

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = gt_list_top_of_page.

ENDFORM. "top_of_page

*&----


*

*& Form USER_COMMAND

*&----


*

  • text

*----


*

  • -->R_UCOMM text

  • -->RS_SELFIELDtext

*----


*

FORM user_command USING r_ucomm LIKE sy-ucomm

rs_selfield TYPE slis_selfield.

CASE r_ucomm.

WHEN '&IC1'.

  • MESSAGE 'jj' TYPE 'I'.

READ TABLE it_final INTO wa_final INDEX rs_selfield-tabindex.

PERFORM build_fieldcatlog.

PERFORM event_call USING it_event[].

  • PERFORM POPULATE_EVENT_EKPO.

PERFORM data_retrieval.

PERFORM build_listheader USING it_listheader.

PERFORM DISPLAY_ALV.

ENDCASE.

ENDFORM. "user_command

*&----


*

*& Form BUILD_FIELDCATLOG

*&----


*

  • text

*----


*

FORM build_fieldcatlog.

clear it_fieldcat1[].

CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'MATNR'.

wa_fieldcat-seltext_m = text-002 .

APPEND wa_fieldcat TO it_fieldcat1.

CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'MAKTX'.

wa_fieldcat-seltext_m = text-003 .

APPEND wa_fieldcat TO it_fieldcat1.

CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'CHARG'.

wa_fieldcat-seltext_m = text-003 .

APPEND wa_fieldcat TO it_fieldcat1.

CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'CLABS'.

wa_fieldcat-seltext_m = text-004 .

APPEND wa_fieldcat TO it_fieldcat1.

ENDFORM. "BUILD_FIELDCATLOG

*&----


*

*& Form EVENT_CALL

*&----


*

  • text

*----


*

  • -->RT_EVENTS text

*----


*

FORM event_call USING rt_events TYPE slis_t_event.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

i_list_type = 0

IMPORTING

et_events = rt_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 DATA_RETRIEVAL

*&----


*

  • text

*----


*

FORM data_retrieval.

it_temp[] = it_mchb[].

DELETE it_temp WHERE matnr NE wa_final-matnr.

ENDFORM. "DATA_RETRIEVAL

*&----


*

*& Form BUILD_LISTHEADER

*&----


*

  • text

*----


*

  • -->I_LISTHEADEtext

*----


*

FORM build_listheader USING i_listheader TYPE slis_t_listheader.

DATA: hline1 TYPE slis_listheader.

hline1-typ = 'H'.

hline1-info = 'CHECKING PGM'.

ENDFORM. "BUILD_LISTHEADER

FORM DISPLAY_ALV.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

  • I_CALLBACK_PROGRAM = sy-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 = TITLE_EKPO

  • I_GRID_SETTINGS =

  • IS_LAYOUT =

IT_FIELDCAT = It_FIELDCAT1[]

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT =

  • I_SAVE = 'A'

  • IS_VARIANT =

IT_EVENTS = it_EVENTS[]

TABLES

T_OUTTAB = IT_temp[]

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.

Former Member
0 Kudos
237

Hi..Just copy and paste the following and go through the following code..

you will get easily an idea......

REPORT YH642_ALV_TOPOFPAGE.

TYPE-POOLS:

SLIS.

tables:

SPFLI.

DATA:

T_SPFLI LIKE STANDARD TABLE

OF SPFLI WITH HEADER LINE.

DATA:

T_EVENTCAT TYPE SLIS_T_EVENT,

FS_EVENTCAT LIKE LINE OF T_EVENTCAT,

T_SORT TYPE SLIS_T_SORTINFO_ALV,

FS_SORT LIKE LINE OF T_SORT.

SELECT *

FROM SPFLI

INTO TABLE T_SPFLI.

PERFORM FILL_EVENT.

*PERFORM FILL_SORT.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = SY-REPID

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

I_STRUCTURE_NAME = 'SPFLI'

  • IS_LAYOUT =

  • IT_FIELDCAT =

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT = T_SORT

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

IT_EVENTS = T_EVENTCAT

  • 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

  • IR_SALV_LIST_ADAPTER =

  • IT_EXCEPT_QINFO =

  • I_SUPPRESS_EMPTY_DATA = ABAP_FALSE

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB = T_SPFLI[]

  • 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.

*********************_____________________________________________

*DATA:

  • T_EVENTS TYPE SLIS_T_EVENT,

  • FS_EVENTS LIKE LINE OF T_EVENTS.

*

*CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

    • EXPORTING

    • I_LIST_TYPE = 0

  • IMPORTING

  • ET_EVENTS = T_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.

*

*LOOP AT T_EVENTS INTO FS_EVENTS.

  • WRITE:/

  • FS_EVENTS-NAME.

*ENDLOOP.

&----


*& Form FILL_EVENT

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM FILL_EVENT .

FS_EVENTCAT-NAME = 'TOP_OF_PAGE'.

FS_EVENTCAT-FORM = 'PAGE_HEADER'.

APPEND FS_EVENTCAT TO T_EVENTCAT.

FS_EVENTCAT-NAME = 'END_OF_PAGE'.

FS_EVENTCAT-FORM = 'PAGE_FOOTER'.

APPEND FS_EVENTCAT TO T_EVENTCAT.

ENDFORM. " FILL_EVENT

FORM PAGE_HEADER.

DATA:

W_INDEX TYPE I.

W_INDEX = SY-TABIX.

READ TABLE T_SPFLI INDEX W_INDEX INTO SPFLI.

WRITE: / 'T_O_P'.

WRITE: 20 SPFLI-CARRID.

ENDFORM.

FORM PAGE_FOOTER.

WRITE: / 'RAM'.

Former Member
0 Kudos
238

Hello Ram,

cechk this sample:


FORM REPORT_HEADING .

* Work Area TOP-OF-PAGE commentary
  DATA: WA_COMMENTARY TYPE SLIS_LISTHEADER,
        L_F_INFO(132),
        L_F_DATUM(10),
        L_F_TIME(8),
        L_F_LOW LIKE PRPS-POSID,
        L_F_HIGH LIKE PRPS-POSID,
        L_F_DATL(10),
        L_F_DATH(10).

  CLEAR : WA_COMMENTARY,
          IT_COMMENTARY,
          IT_COMMENTARY[].

  CONCATENATE TEXT-013 SY-REPID INTO L_F_INFO
                                              SEPARATED BY '   '.
  WA_COMMENTARY-TYP  = 'H'.
  WA_COMMENTARY-INFO = L_F_INFO.
  APPEND WA_COMMENTARY TO IT_COMMENTARY.

  WRITE SY-DATUM TO L_F_DATUM.
  WRITE SY-UZEIT TO L_F_TIME.
  CONCATENATE TEXT-017 L_F_DATUM TEXT-018 L_F_TIME INTO L_F_INFO
                                    SEPARATED BY '         '.
  WA_COMMENTARY-TYP  = 'S'.
  WA_COMMENTARY-INFO = L_F_INFO.
  APPEND WA_COMMENTARY TO IT_COMMENTARY.

  L_F_INFO = TEXT-001.
  WA_COMMENTARY-TYP  = 'S'.
  WA_COMMENTARY-INFO = L_F_INFO.
  APPEND WA_COMMENTARY TO IT_COMMENTARY.

  IF NOT S_PROJ[] IS INITIAL.
    READ TABLE S_PROJ INDEX 1.
    CALL FUNCTION 'CONVERSION_EXIT_ABPSN_OUTPUT'
         EXPORTING
              INPUT  = S_PROJ-LOW
         IMPORTING
              OUTPUT = L_F_LOW.
    IF L_F_LOW IS INITIAL.
      L_F_LOW = SPACE.
    ENDIF.
    CALL FUNCTION 'CONVERSION_EXIT_ABPSN_OUTPUT'
         EXPORTING
              INPUT  = S_PROJ-HIGH
         IMPORTING
              OUTPUT = L_F_HIGH.
    IF L_F_HIGH IS INITIAL.
      L_F_HIGH = SPACE.
    ENDIF.
    IF S_PROJ-OPTION = 'EQ'.
      CONCATENATE TEXT-023 ':' L_F_LOW TEXT-020 L_F_HIGH '+' INTO
                            L_F_INFO SEPARATED BY '    '.

    ELSE.
      CONCATENATE TEXT-023 ':' L_F_LOW TEXT-020 L_F_HIGH INTO
                              L_F_INFO SEPARATED BY '    '.
    ENDIF.
  ELSE.
    CONCATENATE TEXT-023 ':' TEXT-021 INTO
                            L_F_INFO SEPARATED BY '    '.

  ENDIF.
  WA_COMMENTARY-TYP  = 'S'.
  WA_COMMENTARY-INFO = L_F_INFO.
  APPEND WA_COMMENTARY TO IT_COMMENTARY.

  IF NOT S_WBS[] IS INITIAL.
    READ TABLE S_WBS INDEX 1.
    CALL FUNCTION 'CONVERSION_EXIT_ABPSN_OUTPUT'
         EXPORTING
              INPUT  = S_WBS-LOW
         IMPORTING
              OUTPUT = L_F_LOW.
    IF L_F_LOW IS INITIAL.
      L_F_LOW = SPACE.
    ENDIF.
    CALL FUNCTION 'CONVERSION_EXIT_ABPSN_OUTPUT'
         EXPORTING
              INPUT  = S_WBS-HIGH
         IMPORTING
              OUTPUT = L_F_HIGH.
    IF S_WBS-OPTION = 'EQ'.
      CONCATENATE TEXT-005 ':' L_F_LOW L_F_HIGH '+' INTO
                            L_F_INFO SEPARATED BY '    '.
    ELSE.
      CONCATENATE TEXT-023 ':' L_F_LOW TEXT-020 L_F_HIGH INTO
                              L_F_INFO SEPARATED BY '    '.

    ENDIF.
  ELSE.
    CONCATENATE TEXT-005 ':' TEXT-021 INTO
                            L_F_INFO SEPARATED BY '    '.

  ENDIF.
  WA_COMMENTARY-TYP  = 'S'.
  WA_COMMENTARY-INFO = L_F_INFO.
  APPEND WA_COMMENTARY TO IT_COMMENTARY.
  IF NOT S_VKBUR[] IS INITIAL.
    READ TABLE S_VKBUR INDEX 1.
    IF S_VKBUR-OPTION = 'EQ'.
    CONCATENATE TEXT-004 ':' S_VKBUR-LOW TEXT-020 S_VKBUR-HIGH '+' INTO
                                           L_F_INFO SEPARATED BY '    '.
    ELSE.
      CONCATENATE TEXT-004 ':' S_VKBUR-LOW TEXT-020 S_VKBUR-HIGH INTO
                              L_F_INFO SEPARATED BY '    '.
    ENDIF.
  ELSE.
    CONCATENATE TEXT-004 ':' TEXT-021 INTO
                          L_F_INFO SEPARATED BY '    '.
  ENDIF.


  WA_COMMENTARY-TYP  = 'S'.
  WA_COMMENTARY-INFO = L_F_INFO.
  APPEND WA_COMMENTARY TO IT_COMMENTARY.
  IF NOT S_AUDAT[] IS INITIAL.
    READ TABLE S_AUDAT INDEX 1.
    WRITE: S_AUDAT-LOW TO L_F_DATL,
           S_AUDAT-HIGH TO L_F_DATH.
    IF S_AUDAT-OPTION = 'EQ'.
      CONCATENATE TEXT-014 ':' L_F_DATL TEXT-020 L_F_DATH '+' INTO
                                           L_F_INFO SEPARATED BY '    '.
    ELSE.
      CONCATENATE TEXT-014 ':' L_F_DATL TEXT-020 L_F_DATH INTO
                              L_F_INFO SEPARATED BY '    '.
    ENDIF.
  ELSE.
    CONCATENATE TEXT-014 ':' TEXT-021 INTO
                          L_F_INFO SEPARATED BY '    '.
  ENDIF.

  WA_COMMENTARY-TYP  = 'S'.
  WA_COMMENTARY-INFO = L_F_INFO.
  APPEND WA_COMMENTARY TO IT_COMMENTARY.

  CONCATENATE TEXT-015 ':'  P_FILE INTO L_F_INFO SEPARATED BY '    '.
  WA_COMMENTARY-TYP  = 'S'.
  WA_COMMENTARY-INFO = L_F_INFO.
  APPEND WA_COMMENTARY TO IT_COMMENTARY.
  IF NOT P_TAB IS INITIAL.
    CONCATENATE TEXT-016 ':' TEXT-019 INTO L_F_INFO SEPARATED BY '    '.
  ELSE.
    CONCATENATE TEXT-016 ':' P_TRZEI INTO L_F_INFO SEPARATED BY '    '.
  ENDIF.
  WA_COMMENTARY-TYP  = 'S'.
  WA_COMMENTARY-INFO = L_F_INFO.
  APPEND WA_COMMENTARY TO IT_COMMENTARY.
ENDFORM.                    " REPORT_HEADING
FORM ALV_DISPLAY .
  DATA: IT_VARIANT LIKE DISVARIANT.
* For storing the variant layout
  IT_VARIANT-REPORT  = SY-REPID.
  CLEAR G_T_OUTTAB.
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
            I_CALLBACK_PROGRAM     = IT_VARIANT-REPORT
            I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
            IT_FIELDCAT            = IT_FIELDCAT
            I_SAVE                 = 'A'
            IS_VARIANT             = IT_VARIANT
       TABLES
            T_OUTTAB               = G_T_OUTTAB
       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  TOP-OF-PAGE
*&---------------------------------------------------------------------*
*        For Top of page
*----------------------------------------------------------------------*

FORM TOP_OF_PAGE.                                           "#EC CALLED

  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
       EXPORTING
            IT_LIST_COMMENTARY = IT_COMMENTARY.

ENDFORM.                    "top_of_page

If usefulreward.

Vasanth

Former Member
0 Kudos
237

Thanks a lot guys for your quick response. I am learning a lot from all of you..

Ram

Former Member
0 Kudos
237

Hi,

so you put in your

data: G_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE',

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = G_REPID

  • I_BACKGROUND_ID = 'ALV_BACKGROUND'

  • I_BACKGROUND_ID = 'ALV_WALLPAPER'

I_GRID_TITLE = G_TITLE

I_CALLBACK_PF_STATUS_SET = G_STATUS

I_CALLBACK_USER_COMMAND = G_USER_COMMAND

IT_EVENTS = GT_EVENTS[]

I_CALLBACK_TOP_OF_PAGE = G_TOP_OF_PAGE

IT_FIELDCAT = FIELDCAT[]

IT_SORT = SORT[]

IS_LAYOUT = LAYOUT

TABLES

T_OUTTAB = TAB_F.

in the I_CALLBACK_TOP_OF_PAGE = G_TOP_OF_PAGE.

Then you created a form, named TOP_OF_PAGE, in wich you have:

FORM TOP_OF_PAGE.

DATA: GT_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER,

CLEAR LS_LINE.

LS_LINE-TYP = 'S'.

LS_LINE-KEY = 'Data:'.

WRITE: '10.10.2006' TO LS_LINE-INFO.

APPEND LS_LINE TO GT_LIST_TOP_OF_PAGE .

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

IT_LIST_COMMENTARY = GT_LIST_TOP_OF_PAGE.

this should work,

Regards,