Skip to Content
0
Former Member
Dec 14, 2006 at 07:16 PM

ALV Report Header is not showing up.. Please Help

32 Views

Hi

I have debugged the program and header_alv[] got all the info it should but still my report is showing without the info in the header space. The space is there but its blank.

Please help.

&----


*& Report ZAKTEVEN *

*& *

&----


  • MODIFICATION LOG *

  • DATE AUTHOR DESCRIPTION *

  • 12/13/06 kabir New Report to get chk -in/out *

&----


REPORT ZAKTEVEN no standard page heading message-id zw line-size 255.

*----


  • Dictionary tables/structures

*----


TABLES: PA0001,

PA0002,

PA0007,

PA0000,

TEVEN.

data REC LIKE TEVEN occurs 0 with header line.

  • Global ALV Data Declarations

type-pools slis.

DATA: BEGIN OF REC_I OCCURS 0,

PERNR LIKE PERNR-PERNR,

NAME(25),

SSN LIKE PA0002-PERID,

LDATE LIKE TEVEN-LDATE,

LTIME LIKE TEVEN-LTIME,

ERDAT LIKE TEVEN-ERDAT,

ERTIM LIKE TEVEN-ERTIM,

SATZA LIKE TEVEN-SATZA,

ORIGF LIKE TEVEN-ORIGF,

UNAME LIKE TEVEN-UNAME,

AEDTM LIKE TEVEN-AEDTM,

SCHKZ LIKE PA0007-SCHKZ,

WERKS LIKE PA0001-WERKS,

BTRTL LIKE PA0001-BTRTL,

ABKRS LIKE PA0001-ABKRS,

SACHA LIKE PA0001-SACHA.

DATA: END OF REC_I.

DATA: BEGIN OF REC_ALV OCCURS 0,

PERNR LIKE PERNR-PERNR,

NAME(25),

SSN LIKE PA0002-PERID,

LDATE LIKE TEVEN-LDATE,

LTIME LIKE TEVEN-LTIME,

ERDAT LIKE TEVEN-ERDAT,

ERTIM LIKE TEVEN-ERTIM,

SATZA LIKE TEVEN-SATZA,

ORIGF LIKE TEVEN-ORIGF,

UNAME LIKE TEVEN-UNAME,

AEDTM LIKE TEVEN-AEDTM,

SCHKZ LIKE PA0007-SCHKZ,

WERKS LIKE PA0001-WERKS,

BTRTL LIKE PA0001-BTRTL,

ABKRS LIKE PA0001-ABKRS,

SACHA LIKE PA0001-SACHA.

DATA: END OF REC_ALV.

data:

begin of x_sortinfo_alv occurs 0,

spos like alvdynp-sortpos,

fieldname type slis_fieldname,

tabname type slis_fieldname,

up like alvdynp-sortup,

down like alvdynp-sortdown,

group like alvdynp-grouplevel,

subtot like alvdynp-subtotals,

comp(1) type c,

expa(1) type c,

obligatory(1) type c,

end of x_sortinfo_alv,

v_variant like disvariant,

v_repid like sy-repid,

v_save(1) type c,

lv_sortseq type i,

s_title(20), "Maximum selection field description 20 bytes.

fieldcat type slis_t_fieldcat_alv,

ls_line type slis_listheader,

gd_layout type slis_layout_alv,

gt_sort type slis_t_sortinfo_alv,

ls_sort type slis_sortinfo_alv,

events type slis_t_event,

list_top_of_page type slis_t_listheader,

top_of_page type slis_formname value 'TOP_OF_PAGE'.

constants:

alv_slis_formname type slis_formname value 'ALV_USER_COMMAND',

c_yes like space value 'X',

c_no like space value space.

*----


  • includes

*----


DATA: BEGIN OF E_NAME,

NACHN LIKE PA0002-NACHN,

VORNA LIKE PA0002-VORNA.

DATA: END OF E_NAME.

INCLUDE RPTBAL01.

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

  • no intervals.

SELECTIOn-SCREEN Begin of Line.

SELECTIOn-SCREEN COMMENT 1(22) TEXT-002.

SELECT-OPTIONS OPT1 FOR TEVEN-AEDTM.

SELECTIOn-SCREEN End of Line.

SELECTIOn-SCREEN Begin of Line.

SELECTIOn-SCREEN COMMENT 1(25) TEXT-003.

Parameters OPT2(4) DEFAULT 'M'.

SELECTIOn-SCREEN End of Line.

SELECTIOn-SCREEN Begin of Line.

SELECTIOn-SCREEN COMMENT 1(22) TEXT-004.

SELECT-OPTIONS OPT3 FOR TEVEN-PERNR.

SELECTIOn-SCREEN End of Line.

SELECTIOn-SCREEN Begin of Line.

SELECTIOn-SCREEN COMMENT 1(22) TEXT-006.

SELECT-OPTIONS OPT4 FOR TEVEN-UNAME.

SELECTIOn-SCREEN End of Line.

selection-screen end of block wt.

selection-screen begin of block tt with frame title text-012.

SELECTIOn-SCREEN Begin of Line.

SELECTIOn-SCREEN COMMENT 1(22) TEXT-005.

SELECT-OPTIONS OPT5 FOR PA0007-SCHKZ.

SELECTIOn-SCREEN End of Line.

selection-screen end of block tt.

selection-screen begin of block tv with frame title text-011.

SELECTIOn-SCREEN Begin of Line.

SELECTIOn-SCREEN COMMENT 1(22) TEXT-007.

SELECT-OPTIONS OPT6 FOR PA0001-WERKS.

SELECTIOn-SCREEN End of Line.

SELECTIOn-SCREEN Begin of Line.

SELECTIOn-SCREEN COMMENT 1(22) TEXT-008.

SELECT-OPTIONS OPT7 FOR PA0001-BTRTL.

SELECTIOn-SCREEN End of Line.

SELECTIOn-SCREEN Begin of Line.

SELECTIOn-SCREEN COMMENT 1(22) TEXT-009.

SELECT-OPTIONS OPT8 FOR PA0001-ABKRS.

SELECTIOn-SCREEN End of Line.

SELECTIOn-SCREEN Begin of Line.

SELECTIOn-SCREEN COMMENT 1(22) TEXT-010.

SELECT-OPTIONS OPT9 FOR PA0001-SACHA.

SELECTIOn-SCREEN End of Line.

selection-screen end of block tv.

*----


  • main logic

*----


*TOP-OF-PAGE.

clear: REC, REC_I, REC_ALV.

refresh: REC, REC_I, REC_ALV.

select * from TEVEN into table REC

where ORIGF EQ OPT2

and AEDTM IN OPT1

and PERNR IN OPT3

and UNAME IN OPT4.

IF SY-SUBRC EQ 0.

loop at rec.

PERFORM LOAD_REC_I.

APPEND REC_I.

endloop.

PERFORM LOAD_REC_ALV.

PERFORM CALL_ALV.

ELSE.

WRITE: / 'no match'.

ENDIF.

&----


*& Form LOAD REC_I

&----


  • text

----


FORM LOAD_REC_I.

MOVE: REC-PERNR TO REC_I-PERNR.

PERFORM GET_SSN.

MOVE:

REC-LDATE TO REC_I-LDATE,

REC-LTIME TO REC_I-LTIME,

REC-ERDAT TO REC_I-ERDAT,

REC-ERTIM TO REC_I-ERTIM,

REC-SATZA TO REC_I-SATZA,

REC-ORIGF TO REC_I-ORIGF,

REC-UNAME TO REC_I-UNAME,

REC-AEDTM TO REC_I-AEDTM.

PERFORM LOAD_SHIFT.

PERFORM LOAD_GROUP.

ENDFORM. " GET_SSN

&----


*& Form GET_SSN

&----


  • text

----


FORM GET_SSN.

SELECT SINGLE * FROM PA0002 WHERE PERNR = REC-PERNR.

IF SY-SUBRC EQ 0.

MOVE: PA0002-PERNR TO REC_I-SSN,

PA0002-VORNA TO E_NAME-VORNA,

PA0002-NACHN TO E_NAME-NACHN.

CONDENSE E_NAME.

MOVE: E_NAME TO REC_I-NAME.

ENDIF.

ENDFORM. " GET_SSN

&----


*& Form LOAD_SHIFT

&----


  • text

----


FORM LOAD_SHIFT.

SELECT SINGLE * FROM PA0007 WHERE PERNR = REC-PERNR.

IF SY-SUBRC EQ 0.

MOVE: PA0007-SCHKZ TO REC_I-SCHKZ.

ENDIF.

ENDFORM.

&----


*& Form LOAD_GROUP

&----


  • text

----


FORM LOAD_GROUP.

SELECT SINGLE * FROM PA0001 WHERE PERNR = REC-PERNR.

IF SY-SUBRC EQ 0.

MOVE:

PA0001-WERKS TO REC_I-WERKS,

PA0001-BTRTL TO REC_I-BTRTL,

PA0001-ABKRS TO REC_I-ABKRS,

PA0001-SACHA TO REC_I-SACHA.

ENDIF.

ENDFORM.

&----


*& Form LOAD REC_ALV

&----


  • text

----


FORM LOAD_REC_ALV.

LOOP AT REC_I.

IF REC_I-SCHKZ IN OPT5 AND REC_I-WERKS IN OPT6

AND REC_I-BTRTL IN OPT7

AND REC_I-ABKRS IN OPT8

AND REC_I-SACHA IN OPT9.

MOVE:

REC_I-PERNR TO REC_ALV-PERNR,

REC_I-NAME TO REC_ALV-NAME,

REC_I-SSN TO REC_ALV-SSN,

REC_I-LDATE TO REC_ALV-LDATE,

REC_I-LTIME TO REC_ALV-LTIME,

REC_I-ERDAT TO REC_ALV-ERDAT,

REC_I-ERTIM TO REC_ALV-ERTIM,

REC_I-SATZA TO REC_ALV-SATZA,

REC_I-ORIGF TO REC_ALV-ORIGF,

REC_I-UNAME TO REC_ALV-UNAME,

REC_I-AEDTM TO REC_ALV-AEDTM,

REC_I-SCHKZ TO REC_ALV-SCHKZ,

REC_I-WERKS TO REC_ALV-WERKS,

REC_I-BTRTL TO REC_ALV-BTRTL,

REC_I-ABKRS TO REC_ALV-ABKRS,

REC_I-SACHA TO REC_ALV-SACHA.

APPEND REC_ALV.

ENDIF.

ENDLOOP.

ENDFORM.

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

  • CALL_ALV

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

form call_alv.

v_repid = sy-repid.

perform build_field_catalog using field_tab[].

perform build_eventtab using events[].

perform comment_build using header_alv[].

perform build_sorttab using gt_sort[].

perform build_layout.

v_variant-variant = '/DETAIL'.

  • Call ABAP List Viewer

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

it_fieldcat = field_tab[]

  • i_callback_user_command = 'USER_COMMAND'

  • i_grid_title = 'xyz'

i_structure_name = 'REC_ALV'

i_callback_program = v_repid

is_variant = v_variant

it_events = events[]

it_sort = gt_sort[]

i_save = v_save

is_layout = gd_layout

tables

t_outtab = REC_ALV

exceptions

program_error = 1

others = 2.

endform.

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

  • BUILD_FIELD_CATALOG

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

form build_field_catalog USING pt_fieldcat type

slis_t_fieldcat_alv.

clear: fieldcat, pt_fieldcat[]. refresh: fieldcat.

data: ls_fieldcat type slis_fieldcat_alv.

ls_fieldcat-tabname = 'REC_ALV'.

ls_fieldcat-edit = ' '.

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

ls_fieldcat-fieldname = 'SACHA'.

ls_fieldcat-ref_tabname = 'REC_ALV'.

ls_fieldcat-ref_fieldname = 'SACHA'.

ls_fieldcat-seltext_s = 'PADMIN'.

ls_fieldcat-seltext_m = 'Pyrll Admin'.

ls_fieldcat-seltext_l = 'Payroll Administrator'.

ls_fieldcat-outputlen = 15.

ls_fieldcat-no_sum = 'X'. "Don't use field for totals

append ls_fieldcat to pt_fieldcat.

clear ls_fieldcat.

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

ls_fieldcat-fieldname = 'SSN'.

ls_fieldcat-ref_tabname = 'REC_ALV'.

ls_fieldcat-ref_fieldname = 'SSN'.

ls_fieldcat-seltext_s = 'EMP #'.

ls_fieldcat-seltext_m = 'EMP No'.

ls_fieldcat-seltext_l = 'Employee Number'.

ls_fieldcat-outputlen = 15.

ls_fieldcat-no_sum = 'X'. "Don't use field for totals

ls_fieldcat-datatype = 'NUMC'.

append ls_fieldcat to pt_fieldcat.

clear ls_fieldcat.

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

ls_fieldcat-fieldname = 'NAME'.

ls_fieldcat-ref_tabname = 'REC_ALV'.

ls_fieldcat-ref_fieldname = 'NAME'.

ls_fieldcat-seltext_s = 'Name'.

ls_fieldcat-seltext_m = 'EMP N'.

ls_fieldcat-seltext_l = 'Employee Name '.

append ls_fieldcat to pt_fieldcat.

clear ls_fieldcat.

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

ls_fieldcat-fieldname = 'LDATE'.

ls_fieldcat-ref_tabname = 'REC_ALV'.

ls_fieldcat-ref_fieldname = 'LDATE'.

ls_fieldcat-seltext_s = 'DATE'.

ls_fieldcat-seltext_m = 'DATE '.

ls_fieldcat-seltext_l = 'DATE '.

append ls_fieldcat to pt_fieldcat.

clear ls_fieldcat.

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

ls_fieldcat-fieldname = 'LTIME'.

ls_fieldcat-ref_tabname = 'REC_ALV'.

ls_fieldcat-ref_fieldname = 'LTIME'.

ls_fieldcat-seltext_s = 'TIME'.

ls_fieldcat-seltext_m = 'TIME '.

ls_fieldcat-seltext_l = 'TIME '.

append ls_fieldcat to pt_fieldcat.

clear ls_fieldcat.

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

ls_fieldcat-fieldname = 'ERDAT'.

ls_fieldcat-ref_tabname = 'REC_ALV'.

ls_fieldcat-ref_fieldname = 'ERDAT'.

ls_fieldcat-seltext_s = 'CDate'.

ls_fieldcat-seltext_m = 'Cr. Date '.

ls_fieldcat-seltext_l = 'Created Date '.

append ls_fieldcat to pt_fieldcat.

clear ls_fieldcat.

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

ls_fieldcat-fieldname = 'ERTIM'.

ls_fieldcat-ref_tabname = 'REC_ALV'.

ls_fieldcat-ref_fieldname = 'ERTIM'.

ls_fieldcat-seltext_s = 'CTIME'.

ls_fieldcat-seltext_m = 'Cr. Time'.

ls_fieldcat-seltext_l = 'Created Time '.

append ls_fieldcat to pt_fieldcat.

clear ls_fieldcat.

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

ls_fieldcat-fieldname = 'SATZA'.

ls_fieldcat-ref_tabname = 'REC_ALV'.

ls_fieldcat-ref_fieldname = 'SATZA'.

ls_fieldcat-seltext_s = 'SATZA'.

ls_fieldcat-seltext_m = 'SATZA'.

ls_fieldcat-seltext_l = 'SATZA '.

append ls_fieldcat to pt_fieldcat.

clear ls_fieldcat.

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

ls_fieldcat-fieldname = 'ORIGF'.

ls_fieldcat-ref_tabname = 'REC_ALV'.

ls_fieldcat-ref_fieldname = 'ORIGF'.

ls_fieldcat-seltext_s = 'ORIGF'.

ls_fieldcat-seltext_m = 'ORIGF'.

ls_fieldcat-seltext_l = 'ORIGF '.

append ls_fieldcat to pt_fieldcat.

clear ls_fieldcat.

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

ls_fieldcat-fieldname = 'UNAME'.

ls_fieldcat-ref_tabname = 'REC_ALV'.

ls_fieldcat-ref_fieldname = 'UNAME'.

ls_fieldcat-seltext_s = 'UName'.

ls_fieldcat-seltext_m = 'User N'.

ls_fieldcat-seltext_l = 'User Name '.

append ls_fieldcat to pt_fieldcat.

clear ls_fieldcat.

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

ls_fieldcat-fieldname = 'AEDTM'.

ls_fieldcat-ref_tabname = 'REC_ALV'.

ls_fieldcat-ref_fieldname = 'AEDTM'.

ls_fieldcat-seltext_s = 'CRDTON'.

ls_fieldcat-seltext_m = 'Cr. Dt On'.

ls_fieldcat-seltext_l = 'Created Date On '.

append ls_fieldcat to pt_fieldcat.

clear ls_fieldcat.

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

ls_fieldcat-fieldname = 'SCHKZ'.

ls_fieldcat-ref_tabname = 'REC_ALV'.

ls_fieldcat-ref_fieldname = 'SCHKZ'.

ls_fieldcat-seltext_s = 'Name'.

ls_fieldcat-seltext_m = 'EMP N'.

ls_fieldcat-seltext_l = 'Employee Name '.

append ls_fieldcat to pt_fieldcat.

clear ls_fieldcat.

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

ls_fieldcat-fieldname = 'WERKS'.

ls_fieldcat-ref_tabname = 'REC_ALV'.

ls_fieldcat-ref_fieldname = 'WERKS'.

ls_fieldcat-seltext_s = 'Name'.

ls_fieldcat-seltext_m = 'EMP N'.

ls_fieldcat-seltext_l = 'Employee Name '.

append ls_fieldcat to pt_fieldcat.

clear ls_fieldcat.

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

ls_fieldcat-fieldname = 'BTRTL'.

ls_fieldcat-ref_tabname = 'REC_ALV'.

ls_fieldcat-ref_fieldname = 'BTRTL'.

ls_fieldcat-seltext_s = 'Name'.

ls_fieldcat-seltext_m = 'EMP N'.

ls_fieldcat-seltext_l = 'Employee Name '.

append ls_fieldcat to pt_fieldcat.

clear ls_fieldcat.

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

ls_fieldcat-fieldname = 'ABKRS'.

ls_fieldcat-ref_tabname = 'REC_ALV'.

ls_fieldcat-ref_fieldname = 'ABKRS'.

ls_fieldcat-seltext_s = 'Name'.

ls_fieldcat-seltext_m = 'EMP N'.

ls_fieldcat-seltext_l = 'Employee Name '.

append ls_fieldcat to pt_fieldcat.

clear ls_fieldcat.

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

ls_fieldcat-fieldname = 'SACHA'.

ls_fieldcat-ref_tabname = 'REC_ALV'.

ls_fieldcat-ref_fieldname = 'SACHA'.

ls_fieldcat-seltext_s = 'Name'.

ls_fieldcat-seltext_m = 'EMP N'.

ls_fieldcat-seltext_l = 'Employee Name '.

append ls_fieldcat to pt_fieldcat.

clear ls_fieldcat.

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

ls_fieldcat-edit = ' '.

endform.

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

  • BUILD_EVENTTAB

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

form build_eventtab using events type slis_t_event.

  • Registration of events to happen during list display

data: tmp_event type slis_alv_event.

call function 'REUSE_ALV_EVENTS_GET'

exporting

i_list_type = 0

importing

et_events = events.

read table events with key name = slis_ev_top_of_page into tmp_event.

if sy-subrc = 0.

move top_of_page to tmp_event-form.

append tmp_event to events.

endif.

endform.

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

  • COMMENT_BUILD

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

form comment_build using pt_top_of_page type slis_t_listheader.

data: v_head_string(255) value space, d1(2), m1(2), y1(2), d2(2), m2(2), y2(2).

clear: ls_line, pt_top_of_page.

ls_line-typ = 'H'.

data pnpfrom(10).

data pnpto(10).

data: print_date(10).

data: print_time(10).

d1 = OPT1-LOW6(2). d2 = OPT1-HIGH6(2).

m1 = OPT1-LOW4(2). m2 = OPT1-HIGH4(2).

y1 = OPT1-LOW2(2). y2 = OPT1-HIGH2(2).

concatenate m1 '/' d1 '/' y1 into pnpfrom.

concatenate m2 '/' d2 '/' y2 into pnpto.

d1 = sy-datum6(2). d2 = sy-uzeit2(2).

m1 = sy-datum4(2). m2 = sy-uzeit0(2).

y1 = sy-datum2(2). y2 = sy-uzeit4(2).

concatenate m1 '/' d1 '/' y1 into print_date.

concatenate m2 ':' d2 ':' y2 into print_time.

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

ls_line-info = sy-repid.

append ls_line to pt_top_of_page.

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

concatenate 'Printed by:' sy-uname 'on' print_date 'at' print_time

into ls_line-info separated by space.

append ls_line to pt_top_of_page.

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

ls_line-info = 'BGM INDUSTRIES, INC.'.

append ls_line to pt_top_of_page.

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

concatenate 'Supply Period:' pnpfrom 'to' pnpto

into ls_line-info separated by space.

append ls_line to pt_top_of_page.

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

endform.

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

  • Build layout for ALV grid report

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

form build_layout.

gd_layout-no_input = 'X'.

gd_layout-colwidth_optimize = 'X'.

gd_layout-totals_text = 'Totals'(201).

gd_layout-info_fieldname = 'LINE_COLOR'.

endform. " BUILD_LAYOUT

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

  • TOP_OF_PAGE

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

form top_of_page.

call function 'REUSE_ALV_COMMENTARY_WRITE'

exporting

i_logo = 'Z_BGLOGO'

it_list_commentary = header_alv.

endform.

*&----


*& Form build_sorttab

*&----


  • Set up the sorting for the report.

*----


form build_sorttab using pt_sort type slis_t_sortinfo_alv.

clear lv_sortseq.

  • **********************************************************************

perform build_sort tables pt_sort changing ls_sort.

ls_sort-fieldname = 'SACHA'.

append ls_sort to pt_sort.

ls_sort-subtot = ' '.

  • **********************************************************************

perform build_sort tables pt_sort changing ls_sort.

ls_sort-fieldname = 'SSN'.

  • ls_sort-subtot = 'X'.

append ls_sort to pt_sort.

ls_sort-subtot = ' '.

endform. " build_sorttab

*& Form build_sort

&----


  • Use to add another sort field.

*----


form build_sort

tables pt_sort

changing ls_sort structure x_sortinfo_alv.

clear ls_sort.

add 1 to lv_sortseq.

ls_sort-spos = lv_sortseq.

ls_sort-up = 'X'.

ls_sort-tabname = 'REC_ALV'.

endform. "build_sort

Message was edited by:

Anwarul Kabir