Skip to Content
0
Former Member
Jan 25, 2007 at 08:15 AM

i want to add new field to this list

19 Views

hi all,

i want to add new field to this list.

kostenstelle from table zfmkstel

&----


*& Report ZFM_MOBLIST *

*& *

&----


*& *

*& *

&----


REPORT ZFM_MOBLIST.

TABLES: zfm_handy , pa0002.

TYPE-POOLS : slis.

DATA: g_repid LIKE sy-repid,

gs_print TYPE slis_print_alv,

gt_list_top_of_page TYPE slis_t_listheader,

gt_list_end_of_page TYPE slis_t_listheader,

gt_events TYPE slis_t_event,

gt_sort TYPE slis_t_sortinfo_alv,

gs_layout TYPE slis_layout_alv,

gt_fieldcat TYPE slis_t_fieldcat_alv,

fieldcat_ln LIKE LINE OF gt_fieldcat,

col_pos TYPE i.

*

*DATA : BEGIN OF it_moblist OCCURS 0.

  • INCLUDE STRUCTURE zfm_handy.

*DATA : nachn TYPE pa0002-nachn,

  • vorna TYPE pa0002-vorna,

  • END OF it_moblist.

*

DATA : BEGIN OF IT_MOBLIST OCCURS 0,

TELNUM TYPE ZFM_HANDY-TELNUM,

KARTNR TYPE ZFM_HANDY-KARTNR,

ZUTART TYPE ZFM_HANDY-ZUTART,

PERNR TYPE ZFM_HANDY-PERNR,

nachn TYPE pa0002-nachn,

VORNA TYPE pa0002-vorna,

ZDATE TYPE ZFM_HANDY-ZDATE,

PINNR TYPE ZFM_HANDY-PINNR,

PUKNR TYPE ZFM_HANDY-PUKNR,

TARIF1 TYPE ZFM_HANDY-TARIF1,

TARIF2 TYPE ZFM_HANDY-TARIF2,

TARIF3 TYPE ZFM_HANDY-TARIF3,

GTYPE TYPE ZFM_HANDY-GTYPE,

IMEI TYPE ZFM_HANDY-TARIF1,

twincard type zfm_handy-twincard,

twinbill type zfm_handy-twinbill,

einbau type zfm_handy-einbau,

beschr type zfm_handy-beschr,

text1 type zfm_handy-text1,

text2 type zfm_handy-text2,

text3 type zfm_handy-text3,

end of it_moblist.

DATA : BEGIN OF IT_zfm_handy OCCURS 0,

TELNUM TYPE ZFM_HANDY-TELNUM,

KARTNR TYPE ZFM_HANDY-KARTNR,

ZUTART TYPE ZFM_HANDY-ZUTART,

PERNR TYPE ZFM_HANDY-PERNR,

ZDATE TYPE ZFM_HANDY-ZDATE,

PINNR TYPE ZFM_HANDY-PINNR,

PUKNR TYPE ZFM_HANDY-PUKNR,

TARIF1 TYPE ZFM_HANDY-TARIF1,

TARIF2 TYPE ZFM_HANDY-TARIF2,

TARIF3 TYPE ZFM_HANDY-TARIF3,

GTYPE TYPE ZFM_HANDY-GTYPE,

IMEI TYPE ZFM_HANDY-TARIF1,

twincard type zfm_handy-twincard,

twinbill type zfm_handy-twinbill,

einbau type zfm_handy-einbau,

beschr type zfm_handy-beschr,

text1 type zfm_handy-text1,

text2 type zfm_handy-text2,

text3 type zfm_handy-text3,

end of it_zfm_handy.

*

*DATA : BEGIN OF it_zfm_handy OCCURS 0.

  • INCLUDE STRUCTURE zfm_handy.

*DATA END OF it_zfm_handy.

*

DATA : BEGIN OF it_pa0002 OCCURS 0,

pernr TYPE pa0002-pernr,

nachn TYPE pa0002-nachn,

vorna TYPE pa0002-vorna,

  • pernr TYPE pa0002-pernr,

END OF it_pa0002.

INITIALIZATION.

g_repid = sy-repid.

PERFORM print_build USING gs_print. "Print PARAMETERS

START-OF-SELECTION.

PERFORM data_selection.

PERFORM build_fieldcat.

PERFORM eventtab_build CHANGING gt_events.

PERFORM comment_build CHANGING gt_list_top_of_page.

PERFORM call_alv.

&----


*& Form TOP_OF_PAGE

&----


FORM top_of_page.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = gt_list_top_of_page.

WRITE: sy-datum, 'Page No', sy-pagno RIGHT-JUSTIFIED.

ENDFORM. "TOP_OF_PAGE

&----


*& Form END_OF_PAGE

&----


FORM end_of_page.

WRITE: /.

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

ENDFORM. "END_OF_PAGE

  • ### PRINT SETTINGS

FORM print_build USING ls_print TYPE slis_print_alv.

ls_print-print = ' '. "PRINT IMMEDIATE

ls_print-no_print_selinfos = 'X'. "NO SELECTION INFO

ls_print-no_coverpage = ' '. "NO COVER PAGE

ls_print-no_new_page = ' '. "NO NEW PAGE

ls_print-no_print_listinfos = 'X'. "NO PRINT LIST INFO

ls_print-reserve_lines = 2. " FOOTERLINE

ENDFORM. "PRINT_BUILD

&----


*& Form data_selection

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM data_selection .

data : n(8) type n.

SELECT * FROM

zfm_handy

INTO CORRESPONDING FIELDS OF TABLE it_zfm_handy where pernr ne space.

IF NOT it_zfm_handy[] IS INITIAL.

loop at it_zfm_handy.

n = it_zfm_handy-pernr.

it_zfm_handy-pernr = n.

modify it_zfm_handy.

endloop.

SELECT pernr nachn

vorna

FROM pa0002

INTO TABLE it_pa0002

FOR ALL ENTRIES IN it_zfm_handy

WHERE pernr = it_zfm_handy-pernr and endda = '99991231'.

  • SELECT pernr nachn

  • vorna

  • FROM pa0002

  • INTO TABLE it_pa0002

  • FOR ALL ENTRIES IN it_zfm_handy

  • WHERE pernr = it_zfm_handy-pernr and begda le sy-datum and endda ge sy-datum.

*

ENDIF. " not it_zfm_handy

LOOP AT it_zfm_handy.

MOVE-CORRESPONDING it_zfm_handy TO it_moblist.

clear it_pa0002.

READ TABLE it_pa0002 WITH KEY pernr = it_zfm_handy-pernr.

if sy-subrc = 0.

move it_pa0002-nachn to it_moblist-nachn.

move it_pa0002-vorna to it_moblist-vorna.

move it_pa0002-pernr to it_moblist-pernr.

ENDIF.

APPEND it_moblist.

CLEAR it_moblist.

*endif.

ENDLOOP.

ENDFORM. " data_selection

&----


*& Form BUILD

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM build_fieldcat .

  • Explain Field Description to ALV

DATA: fieldcat_in TYPE slis_fieldcat_alv.

CLEAR fieldcat_in.

fieldcat_ln-fieldname = 'TELNUM'.

fieldcat_ln-tabname = 'IT_MOBLIST'.

fieldcat_ln-no_out = ' '.

fieldcat_ln-seltext_l = 'TELNUM'.

APPEND fieldcat_ln TO gt_fieldcat.

CLEAR fieldcat_in.

fieldcat_ln-fieldname = 'KARTNR'.

fieldcat_ln-tabname = 'IT_MOBLIST'.

fieldcat_ln-no_out = ' '.

fieldcat_ln-seltext_l = 'KARTNR'.

APPEND fieldcat_ln TO gt_fieldcat.

CLEAR fieldcat_in.

fieldcat_ln-fieldname = 'ZUTART'.

fieldcat_ln-tabname = 'IT_MOBLIST'.

fieldcat_ln-no_out = ' '.

fieldcat_ln-seltext_l = 'ZUTART'.

APPEND fieldcat_ln TO gt_fieldcat.

CLEAR fieldcat_in.

fieldcat_ln-fieldname = 'PERNR'.

fieldcat_ln-tabname = 'IT_MOBLIST'.

fieldcat_ln-no_out = ' '.

fieldcat_ln-seltext_l = 'PERNR'.

APPEND fieldcat_ln TO gt_fieldcat.

CLEAR fieldcat_in.

fieldcat_ln-fieldname = 'NACHN'.

fieldcat_ln-tabname = 'IT_MOBLIST'.

fieldcat_ln-no_out = ' '.

fieldcat_ln-seltext_l = 'NACHN'.

APPEND fieldcat_ln TO gt_fieldcat.

CLEAR fieldcat_in.

fieldcat_ln-fieldname = 'VORNA'.

fieldcat_ln-tabname = 'IT_MOBLIST'.

fieldcat_ln-no_out = ' '.

fieldcat_ln-seltext_l = 'VORNA'.

APPEND fieldcat_ln TO gt_fieldcat.

CLEAR fieldcat_in.

fieldcat_ln-fieldname = 'ZDATE'.

fieldcat_ln-tabname = 'IT_MOBLIST'.

fieldcat_ln-no_out = ' '.

fieldcat_ln-seltext_l = 'ZDATE'.

APPEND fieldcat_ln TO gt_fieldcat.

CLEAR fieldcat_in.

fieldcat_ln-fieldname = 'PINNR'.

fieldcat_ln-tabname = 'IT_MOBLIST'.

fieldcat_ln-no_out = ' '.

fieldcat_ln-seltext_l = 'PINNR'.

APPEND fieldcat_ln TO gt_fieldcat.

CLEAR fieldcat_in.

fieldcat_ln-fieldname = 'PUKNR'.

fieldcat_ln-tabname = 'IT_MOBLIST'.

fieldcat_ln-no_out = ' '.

fieldcat_ln-seltext_l = 'PUKNR'.

APPEND fieldcat_ln TO gt_fieldcat.

CLEAR fieldcat_in.

fieldcat_ln-fieldname = 'TARIF1'.

fieldcat_ln-tabname = 'IT_MOBLIST'.

fieldcat_ln-no_out = ' '.

fieldcat_ln-seltext_l = 'TARIF1'.

APPEND fieldcat_ln TO gt_fieldcat.

CLEAR fieldcat_in.

fieldcat_ln-fieldname = 'TARIF2'.

fieldcat_ln-tabname = 'IT_MOBLIST'.

fieldcat_ln-no_out = ' '.

fieldcat_ln-seltext_l = 'TARIF2'.

APPEND fieldcat_ln TO gt_fieldcat.

CLEAR fieldcat_in.

fieldcat_ln-fieldname = 'TARIF3'.

fieldcat_ln-tabname = 'IT_MOBLIST'.

fieldcat_ln-no_out = ' '.

fieldcat_ln-seltext_l = 'TARIF3'.

APPEND fieldcat_ln TO gt_fieldcat.

CLEAR fieldcat_in.

fieldcat_ln-fieldname = 'GTYPE'.

fieldcat_ln-tabname = 'IT_MOBLIST'.

fieldcat_ln-no_out = ' '.

fieldcat_ln-seltext_l = 'GTYPE'.

APPEND fieldcat_ln TO gt_fieldcat.

CLEAR fieldcat_in.

fieldcat_ln-fieldname = 'IMEI'.

fieldcat_ln-tabname = 'IT_MOBLIST'.

fieldcat_ln-no_out = ' '.

fieldcat_ln-seltext_l = 'IMEI'.

APPEND fieldcat_ln TO gt_fieldcat.

CLEAR fieldcat_in.

fieldcat_ln-fieldname = 'TWINCARD'.

fieldcat_ln-tabname = 'IT_MOBLIST'.

fieldcat_ln-no_out = ' '.

fieldcat_ln-seltext_l = 'TWINCARD'.

APPEND fieldcat_ln TO gt_fieldcat.

CLEAR fieldcat_in.

fieldcat_ln-fieldname = 'TWINBILL'.

fieldcat_ln-tabname = 'IT_MOBLIST'.

fieldcat_ln-no_out = ' '.

fieldcat_ln-seltext_l = 'TWINBILL'.

APPEND fieldcat_ln TO gt_fieldcat.

CLEAR fieldcat_in.

fieldcat_ln-fieldname = 'EINBAU'.

fieldcat_ln-tabname = 'IT_MOBLIST'.

fieldcat_ln-no_out = ' '.

fieldcat_ln-seltext_l = 'EINBAU'.

APPEND fieldcat_ln TO gt_fieldcat.

CLEAR fieldcat_in.

fieldcat_ln-fieldname = 'BESCHR'.

fieldcat_ln-tabname = 'IT_MOBLIST'.

fieldcat_ln-no_out = ' '.

fieldcat_ln-seltext_l = 'BESCHR'.

APPEND fieldcat_ln TO gt_fieldcat.

CLEAR fieldcat_in.

fieldcat_ln-fieldname = 'TEXT1'.

fieldcat_ln-tabname = 'IT_MOBLIST'.

fieldcat_ln-no_out = ' '.

fieldcat_ln-seltext_l = 'TEXT1'.

APPEND fieldcat_ln TO gt_fieldcat.

CLEAR fieldcat_in.

fieldcat_ln-fieldname = 'TEXT2'.

fieldcat_ln-tabname = 'IT_MOBLIST'.

fieldcat_ln-no_out = ' '.

fieldcat_ln-seltext_l = 'TEXT2'.

APPEND fieldcat_ln TO gt_fieldcat.

CLEAR fieldcat_in.

fieldcat_ln-fieldname = 'TEXT3'.

fieldcat_ln-tabname = 'IT_MOBLIST'.

fieldcat_ln-no_out = ' '.

fieldcat_ln-seltext_l = 'TEXT3'.

APPEND fieldcat_ln TO gt_fieldcat.

  • DATA SORTING

DATA: gs_sort TYPE slis_sortinfo_alv.

CLEAR gs_sort.

gs_sort-fieldname = 'TELNUM'.

gs_sort-spos = 1.

gs_sort-up = 'X'.

  • GS_SORT-SUBTOT = 'X'.

APPEND gs_sort TO gt_sort.

  • CLEAR GS_SORT.

  • GS_SORT-FIELDNAME = 'KARTNR'.

  • GS_SORT-SPOS = 2.

  • GS_SORT-UP = 'X'.

*GS_SORT-SUBTOT = 'X'.

APPEND gs_sort TO gt_sort.

ENDFORM. " BUILD

&----


*& Form EVENTTAB_BUILD

&----


  • text

----


  • <--P_GT_EVENTS text

----


FORM eventtab_build CHANGING lt_events TYPE slis_t_event.

CONSTANTS:

gc_formname_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE',

gc_formname_end_of_page TYPE slis_formname VALUE 'END_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.

  • define END_OF_PAGE event

READ TABLE lt_events WITH KEY name = slis_ev_end_of_page

INTO ls_event.

IF sy-subrc = 0.

MOVE gc_formname_end_of_page TO ls_event-form.

APPEND ls_event TO lt_events.

ENDIF.

ENDFORM. " EVENTTAB_BUILD

&----


*& Form COMMENT_BUILD

&----


  • text

----


  • <--P_GT_LIST_TOP_OF_PAGE text

----


FORM comment_build CHANGING gt_top_of_page TYPE slis_t_listheader.

DATA: gs_line TYPE slis_listheader.

DATA: today_date(10) TYPE c.

CONCATENATE

sy-datum+6(2) '.'

sy-datum+4(2) '.'

sy-datum(4) INTO today_date.

CLEAR gs_line.

gs_line-typ = 'H'.

gs_line-info = 'MOBLIST DETAILS'.

APPEND gs_line TO gt_top_of_page.

CLEAR gs_line.

gs_line-typ = 'S'.

gs_line-key = 'Date:'.

gs_line-info = today_date.

APPEND gs_line TO gt_top_of_page.

  • GS_LINE-KEY = 'User:'.

  • GS_LINE-INFO = sy-uname.

APPEND gs_line TO gt_top_of_page.

*

**

CLEAR gs_line.

gs_line-typ = 'A'.

gs_line-info = 'ACTION'.

APPEND gs_line TO gt_top_of_page.

ENDFORM. " COMMENT_BUILD

&----


*& Form CALL_ALV

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM call_alv .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = g_repid

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

is_layout = gs_layout

it_fieldcat = gt_fieldcat

it_sort = gt_sort

it_events = gt_events

is_print = gs_print

TABLES

t_outtab = IT_MOBLIST

EXCEPTIONS

program_error = 1

OTHERS = 2.

ENDFORM. "CALL_ALV.