Skip to Content
0
Former Member
Sep 19, 2007 at 07:06 AM

getting only one coloum in alv grid

46 Views

hi ,

i m facing a very strange problem. in my report i m getting exect data in my final table but when i m going to show it, it is showing only first coloum. well problem is coming in field catalog merge, it is not appending the whole coloum heading except first one. i did right coding but failed to get the result.

plz if anybody faced the same problem suggest me the solution.

it's really urgent.

REPORT zfir_fix_ar NO STANDARD PAGE HEADING LINE-SIZE 255 LINE-COUNT 72.

----


  • Tables *

----


TABLES : t001,anla,anlb,anlc,bsis,t095t.

&----


  • TYPE-POOL *

&----


TYPE-POOLS: slis.

&----


  • Internal Table Declaratin *

&----


DATA: BEGIN OF i_anla OCCURS 0,

bukrs TYPE anla-bukrs,

anln1 TYPE anla-anln1,

aktiv TYPE anla-aktiv,

txt50 TYPE anla-txt50,

txa50 TYPE anla-txa50,

zugdt TYPE anla-zugdt,

abgdt TYPE anla-abgdt,

ktogr TYPE anla-ktogr,

sernr TYPE anla-sernr,

invnr TYPE anla-invnr,

menge TYPE anla-menge,

meins TYPE anla-meins,

lifnr TYPE anla-lifnr,

liefe TYPE anla-liefe,

afabg TYPE anlb-afabg,

END OF i_anla.

DATA:BEGIN OF i_anlc OCCURS 0,

bukrs TYPE anlc-bukrs,

anln1 TYPE anlc-anln1,

kansw TYPE anlc-kansw,

knafa TYPE anlc-knafa,

nafap TYPE anlc-nafap,

answl TYPE anlc-answl,

END OF i_anlc.

DATA:BEGIN OF i_anlz OCCURS 0,

bukrs TYPE anlz-bukrs,

anln1 TYPE anlz-anln1,

raumn TYPE anlz-raumn,

END OF i_anlz.

DATA: BEGIN OF i_bsis OCCURS 0.

INCLUDE STRUCTURE bsis.

DATA: END OF i_bsis.

DATA: BEGIN OF i_final OCCURS 0,

srno TYPE i, " Serial no

anln1 TYPE anla-anln1, " asset code no

txt50 TYPE anla-txt50, " Brief Description of Assets

txa50 TYPE anla-txa50, " Further Description

ktogr TYPE anla-ktogr, " Asset Class No.

ktgrtx TYPE t095t-ktgrtx, " Asset Class Name

sernr TYPE anla-sernr, " Serial Number

invnr TYPE anla-invnr, " Assets Identification No

menge TYPE anla-menge, " Qty

meins TYPE anla-meins, " UOM

raumn TYPE anlz-raumn, " Location

lifnr TYPE anla-lifnr, " Vendor

liefe TYPE anla-liefe, " Capitalisation Date

aktiv TYPE anla-aktiv, " Date put to use

g_kansw TYPE anlc-kansw, " Opening Gross Block

b_kansw TYPE anlc-kansw, " Additions during the period

b_answl TYPE anlc-answl," Deductions/ Adjustmentsduring d period

g_total TYPE bsis-dmbtr, " Closing Gross Block

d_open TYPE anlb-afabg, " Dep on opening block

d_sold TYPE anlb-afabg, " Dep on assets sold/written off

d_add TYPE anlb-afabg, " dep on additions during the period

afabg TYPE anlb-afabg, " Total dep for the period

cd_sold TYPE bsis-dmbtr, " Cum Dep on assets sold

cd_asst TYPE bsis-dmbtr, " Cum Dep on assets written off

cd_dep TYPE bsis-dmbtr, " Total cum dep on deductions

ccd_dep TYPE bsis-dmbtr, " Closing Acc Dep

a TYPE bsis-dmbtr, " WDV of assets sold

b TYPE bsis-dmbtr, " Selling Price

c TYPE bsis-dmbtr, " Profit / (Loss) on sale

d TYPE bsis-dmbtr, " Loss on write off

e TYPE bsis-dmbtr, " Opening WDV

f TYPE bsis-dmbtr, " Closing WDV

END OF i_final.

DATA : text(30).

DATA : b_date TYPE sy-datum.

  • Global variables

*----


DATA: g_repid LIKE sy-repid,

g_events TYPE slis_t_event,

g_list_top_of_page TYPE slis_t_listheader,

g_exit_caused_by_caller,

g_exit_caused_by_user TYPE slis_exit_by_user,

g_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE',

g_save TYPE c.

*----


  • Declaration for Constants

*----


CONSTANTS : c_x TYPE c VALUE 'X', " Flag

c_c TYPE c VALUE 'C', " Flag

c_l TYPE c VALUE 'L', " Flag

c_a TYPE c VALUE 'A', " Line Type

c_h TYPE c VALUE 'H', " Dr/Cr

c_s TYPE c VALUE 'S'. " Line Type

  • * Internal table to hold field catgory data

DATA: i_fldcat TYPE slis_t_fieldcat_alv. " Table - field catgory

  • Internal table to hold Sort/Subtotals criteria data

DATA: i_sort TYPE slis_t_sortinfo_alv. " Table - sort/Subtotals

*----


  • Structure

*----


DATA: x_layout TYPE slis_layout_alv, " Structure-layout

x_fldcat LIKE LINE OF i_fldcat, " Structure-field catagory

x_sort LIKE LINE OF i_sort. " Structure-Sort/Subtotals

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

----


  • s e l e c t i o n s c r e e n

----


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

SELECT-OPTIONS : s_bukrs FOR t001-bukrs OBLIGATORY NO INTERVALS

NO-EXTENSION.

SELECT-OPTIONS : s_anlkl FOR anla-anlkl.

SELECT-OPTIONS : s_anln FOR anla-anln1.

SELECT-OPTIONS : s_date FOR sy-datum OBLIGATORY.

SELECTION-SCREEN : END OF BLOCK b1.

*----


  • Initialization

*----


INITIALIZATION.

g_repid = sy-repid.

PERFORM layout_init USING x_layout.

PERFORM eventtab_build USING g_events[].

&----


  • START OF SELECTION *

&----


START-OF-SELECTION.

PERFORM calc_date.

PERFORM get_data.

PERFORM move_data.

*PERFORM display_data.

*----


  • End of selection

*----


END-OF-SELECTION.

  • Build layout report layout.

PERFORM populate_layout_stucture.

  • Perform build_field_catalog and Sort Table

PERFORM build_field_catalog.

  • PERFORM BUILD_SORT_TOTALS.

  • List Header for Top-Of-Page

PERFORM comment_build USING g_list_top_of_page[].

  • Call list viewer function module

PERFORM call_list_viewer .

****************Form - Routines************************************

*----


  • Form : layout_init

  • Description : Form to Build layout for list display

*----


FORM layout_init USING rs_layout TYPE slis_layout_alv.

rs_layout-detail_popup = c_x.

ENDFORM. "layout_init

*----


  • Form : Eventtab_build

  • Description : Registration of events to happen during list display

*----


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.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

i_list_type = 0

IMPORTING

et_events = rt_events.

READ TABLE rt_events WITH KEY name = slis_ev_top_of_page

INTO ls_event.

IF sy-subrc = 0.

MOVE g_top_of_page TO ls_event-form.

APPEND ls_event TO rt_events.

ENDIF.

ENDFORM. "eventtab_build

*----


  • Form : top_of_page

*----


FORM top_of_page.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = g_list_top_of_page.

ENDFORM. "top_of_page

*

&----


*& Form GET_Data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM get_data .

SELECT abukrs aanln1 aaktiv atxt50 atxa50 azugdt aabgdt aktogr

asernr ainvnr amenge ameins alifnr aliefe b~afabg

INTO TABLE i_anla

FROM anla AS a INNER JOIN anlb AS b

ON aanln1 EQ banln1 AND

abukrs EQ bbukrs

WHERE a~anln1 IN s_anln

AND a~anlkl IN s_anlkl

AND a~bukrs IN s_bukrs

AND b~afabe = '01'.

SELECT bukrs anln1 kansw knafa nafap answl INTO TABLE i_anlc

FROM anlc

FOR ALL ENTRIES IN i_anla

WHERE anln1 = i_anla-anln1

AND bukrs = i_anla-bukrs.

SELECT bukrs anln1 raumn FROM anlz INTO TABLE i_anlz

FOR ALL ENTRIES IN i_anla

WHERE anln1 = i_anla-anln1

AND bukrs = i_anla-bukrs.

ENDFORM. " GET_Data

&----


*& Form Move_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM move_data .

LOOP AT i_anla.

MOVE i_anla-anln1 TO i_final-anln1.

MOVE i_anla-txt50 TO i_final-txt50.

MOVE i_anla-txa50 TO i_final-txa50.

MOVE i_anla-ktogr TO i_final-ktogr.

MOVE i_anla-sernr TO i_final-sernr.

MOVE i_anla-invnr TO i_final-invnr.

MOVE i_anla-menge TO i_final-menge.

MOVE i_anla-meins TO i_final-meins.

MOVE i_anla-afabg TO i_final-afabg.

MOVE i_anla-lifnr TO i_final-lifnr.

MOVE i_anla-liefe TO i_final-liefe.

MOVE i_anla-aktiv TO i_final-aktiv.

SELECT SINGLE * FROM t095t WHERE spras = 'E'

AND ktogr = i_anla-ktogr.

MOVE t095t-ktgrtx TO i_final-ktgrtx.

READ TABLE i_anlc WITH KEY anln1 = i_anla-anln1

bukrs = i_anla-bukrs.

IF sy-subrc EQ 0.

IF i_anla-zugdt LT s_date-low.

MOVE i_anlc-kansw TO i_final-g_kansw.

ELSEIF i_anla-abgdt BETWEEN s_date-low AND s_date-high.

MOVE i_anlc-kansw TO i_final-b_answl.

MOVE i_anlc-nafap TO i_final-d_add.

ELSEIF i_anla-aktiv BETWEEN s_date-low AND s_date-high.

MOVE i_anlc-kansw TO i_final-b_kansw.

MOVE i_anlc-nafap TO i_final-d_sold.

ELSE.

MOVE i_anlc-nafap TO i_final-d_open.

ENDIF.

i_final-cd_sold = i_final-d_open + i_final-d_sold.

i_final-cd_asst = i_final-d_open + i_final-d_sold.

i_final-cd_dep = i_final-cd_sold + i_final-cd_asst.

i_final-ccd_dep = i_final-afabg + i_final-d_open - i_final-cd_dep.

i_final-a = i_final-b_answl - i_final-cd_sold.

i_final-d = i_final-b_answl - i_final-cd_asst.

i_final-e = i_final-g_kansw - i_final-d_open.

i_final-f = i_final-g_kansw - i_final-ccd_dep.

i_final-afabg = i_final-d_sold + i_final-d_open +

i_final-d_add.

i_final-g_total = i_final-g_kansw + i_final-b_answl +

i_final-b_kansw.

ENDIF.

READ TABLE i_anlz WITH KEY anln1 = i_anla-anln1

bukrs = i_anla-bukrs.

IF sy-subrc EQ 0.

MOVE i_anlz-raumn TO i_final-raumn.

ENDIF.

APPEND i_final.

CLEAR i_final.

ENDLOOP.

ENDFORM. " Move_data

----


  • Form : populate_layout_stucture

  • Description : Populating the layout structure

----


FORM populate_layout_stucture.

CLEAR x_layout .

  • Layout properties

x_layout-zebra = c_x.

x_layout-detail_popup = c_x.

x_layout-detail_initial_lines = c_x.

x_layout-colwidth_optimize = c_x.

ENDFORM. " populate_layout_stucture

----


  • Form : build_field_catalog

  • Description : Building the field catalog data

----


FORM build_field_catalog.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

i_program_name = g_repid

i_internal_tabname = 'I_FINAL'

i_inclname = g_repid

CHANGING

ct_fieldcat = i_fldcat.

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: SY-

  • Getting the Header text for the coloums

LOOP AT i_fldcat INTO x_fldcat WHERE fieldname = 'SRNO' OR

fieldname = 'ANLN1' OR

fieldname = 'TXT50' OR

fieldname = 'TXA50' OR

fieldname = 'KTOGR' OR

fieldname = 'KTGRTX' OR

fieldname = 'SERNR' OR

fieldname = 'INVNR' OR

fieldname = 'MENGE' OR

fieldname = 'MEINS' OR

fieldname = 'RAUMN' OR

fieldname = 'LIFNR' OR

fieldname = 'LIEFE' OR

fieldname = 'AKTIV' OR

fieldname = 'AFABG' OR

fieldname = 'G_KANSW' OR

fieldname = 'B_KANSW' OR

fieldname = 'B_ANSWL' OR

fieldname = 'G_TOTAL' OR

fieldname = 'D_OPEN' OR

fieldname = 'D_SOLD' OR

fieldname = 'D_ADD' OR

fieldname = 'AFABG' OR

fieldname = 'CD_SOLD' OR

fieldname = 'CD_ASST' OR

fieldname = 'CD_DEP' OR

fieldname = 'CCD_DEP' OR

fieldname = 'A' OR

fieldname = 'B' OR

fieldname = 'C' OR

fieldname = 'D' OR

fieldname = 'E' OR

fieldname = 'F'.

IF x_fldcat-fieldname = 'SRNO'.

x_fldcat-seltext_l = 'Sr. No'.

x_fldcat-outputlen = 6.

x_fldcat-just = 'C'.

x_fldcat-key = 'X'.

x_fldcat-inttype = c_c.

ENDIF.

IF x_fldcat-fieldname = 'ANLN1'.

x_fldcat-outputlen = 17.

x_fldcat-seltext_l = 'SAP Asset Code'.

x_fldcat-just = 'L'.

x_fldcat-key = 'X'.

x_fldcat-inttype = c_c.

x_fldcat-seltext_m = 'SAP Asset Code'.

x_fldcat-seltext_s = 'SAP Asset Code'.

x_fldcat-reptext_ddic = 'SAP Asset Code'.

ENDIF.

IF x_fldcat-fieldname = 'TXT50'.

x_fldcat-outputlen = 50.

x_fldcat-seltext_l = 'Brief Description of Assets'.

x_fldcat-just = 'L'.

x_fldcat-key = 'X'.

ENDIF.

IF x_fldcat-fieldname = 'TXA50'.

x_fldcat-outputlen = 60.

x_fldcat-seltext_l = 'Further Description'.

x_fldcat-just = 'L'.

ENDIF.

IF x_fldcat-fieldname = 'KTOGR'.

x_fldcat-outputlen = 15.

x_fldcat-seltext_l = 'Acct determinat'.

x_fldcat-just = 'L'.

ENDIF.

IF x_fldcat-fieldname = 'KTGRTX'.

x_fldcat-outputlen = 30.

x_fldcat-seltext_l = 'Acct determinat Text'.

x_fldcat-just = 'L'.

ENDIF.

IF x_fldcat-fieldname = 'SERNR'.

x_fldcat-outputlen = 20.

x_fldcat-seltext_l = 'Serial number'.

x_fldcat-just = 'L'.

ENDIF.

IF x_fldcat-fieldname = 'INVNR'.

x_fldcat-outputlen = 25.

x_fldcat-seltext_l = 'Assets identification No'.

x_fldcat-just = 'L'.

ENDIF.

IF x_fldcat-fieldname = 'MENGE'.

x_fldcat-outputlen = 15.

x_fldcat-seltext_l = 'Qty'.

x_fldcat-just = 'L'.

ENDIF.

IF x_fldcat-fieldname = 'MEINS'.

x_fldcat-outputlen = 10.

x_fldcat-seltext_l = 'UOM'.

x_fldcat-just = 'L'.

ENDIF.

IF x_fldcat-fieldname = 'RAUMN'.

x_fldcat-outputlen = 15.

x_fldcat-seltext_l = 'Location'.

x_fldcat-just = 'L'.

ENDIF.

IF x_fldcat-fieldname = 'LIFNR'.

x_fldcat-outputlen = 20.

x_fldcat-seltext_l = 'Vendor'.

x_fldcat-just = 'L'.

ENDIF.

IF x_fldcat-fieldname = 'LIEFE'.

x_fldcat-outputlen = 30.

x_fldcat-seltext_l = 'Supplier Name'.

x_fldcat-just = 'L'.

ENDIF.

IF x_fldcat-fieldname = 'AKTIV'.

x_fldcat-outputlen = 20.

x_fldcat-seltext_l = 'Capitalisation Date'.

x_fldcat-just = 'L'.

ENDIF.

IF x_fldcat-fieldname = 'AFABG'.

x_fldcat-outputlen = 18.

x_fldcat-seltext_l = 'Date put to use'.

x_fldcat-just = 'L'.

ENDIF.

IF x_fldcat-fieldname = 'G_KANSW'.

x_fldcat-outputlen = 18.

x_fldcat-seltext_l = 'Opening Gross Block'.

x_fldcat-just = 'L'.

ENDIF.

IF x_fldcat-fieldname = 'B_KANSW'.

x_fldcat-outputlen = 15.

x_fldcat-seltext_l = 'Addition'.

x_fldcat-just = 'L'.

ENDIF.

IF x_fldcat-fieldname = 'B_ANSWL'.

x_fldcat-outputlen = 15.

x_fldcat-seltext_l = 'Deduction / Adj'.

x_fldcat-just = 'L'.

ENDIF.

IF x_fldcat-fieldname = 'G_TOTAL'.

x_fldcat-outputlen = 20.

x_fldcat-seltext_l = 'Closing Gross Block'.

x_fldcat-just = 'L'.

ENDIF.

IF x_fldcat-fieldname = 'D_OPEN'.

x_fldcat-outputlen = 20.

x_fldcat-seltext_l = 'Dep on opening block'.

x_fldcat-just = 'L'.

ENDIF.

IF x_fldcat-fieldname = 'D_SOLD'.

x_fldcat-outputlen = 20.

x_fldcat-seltext_l = 'Dep on assets sold/ written off'.

x_fldcat-just = 'L'.

ENDIF.

IF x_fldcat-fieldname = 'D_ADD'.

x_fldcat-outputlen = 15.

x_fldcat-seltext_l = 'Addition During Year'.

x_fldcat-just = 'L'.

ENDIF.

IF x_fldcat-fieldname = 'AFABG'.

x_fldcat-outputlen = 20.

x_fldcat-seltext_l = 'Total dep for the period'.

x_fldcat-just = 'L'.

ENDIF.

IF x_fldcat-fieldname = 'CD_SOLD'.

x_fldcat-outputlen = 20.

x_fldcat-seltext_l = 'Cum Dep on assets sold'.

x_fldcat-just = 'L'.

ENDIF.

IF x_fldcat-fieldname = 'CD_ASST'.

x_fldcat-outputlen = 15.

x_fldcat-seltext_l = 'Cum Dep on assets written off'.

x_fldcat-just = 'L'.

ENDIF.

IF x_fldcat-fieldname = 'CD_DEP'.

x_fldcat-outputlen = 20.

x_fldcat-seltext_l = 'Total cum dep on deductions'.

x_fldcat-just = 'L'.

ENDIF.

IF x_fldcat-fieldname = 'CCD_DEP'.

x_fldcat-outputlen = 20.

x_fldcat-seltext_l = 'Closing Acc Dep'.

x_fldcat-just = 'L'.

ENDIF.

IF x_fldcat-fieldname = 'A'.

x_fldcat-outputlen = 15.

x_fldcat-seltext_l = 'WDV of assets sold'.

x_fldcat-just = 'L'.

ENDIF.

IF x_fldcat-fieldname = 'B'.

x_fldcat-outputlen = 15.

x_fldcat-seltext_l = 'Selling Price'.

x_fldcat-just = 'L'.

ENDIF.

IF x_fldcat-fieldname = 'C'.

x_fldcat-outputlen = 15.

x_fldcat-seltext_l = 'Profit / (Loss) on sale'.

x_fldcat-just = 'L'.

ENDIF.

IF x_fldcat-fieldname = 'D'.

x_fldcat-outputlen = 15.

x_fldcat-seltext_l = 'Loss on Write off'.

x_fldcat-just = 'L'.

ENDIF.

IF x_fldcat-fieldname = 'E'.

x_fldcat-outputlen = 15.

x_fldcat-seltext_l = 'Closing WDV'.

x_fldcat-just = 'L'.

ENDIF.

IF x_fldcat-fieldname = 'F'.

x_fldcat-outputlen = 15.

x_fldcat-seltext_l = 'Opening WDV'.

x_fldcat-just = 'L'.

ENDIF.

MODIFY i_fldcat FROM x_fldcat INDEX sy-tabix.

ENDLOOP.

ENDFORM. " build_field_catalog

----


  • Form : comment_build

  • Description : This form is used to display the Report Header(ALV)

----


*

FORM comment_build USING lt_top_of_page TYPE

slis_t_listheader.

DATA: l_line TYPE slis_listheader,

l_heading1 LIKE rs38m-repti.

CLEAR l_line.

l_heading1 =

'Asset Register Report'.

g_repid = sy-repid.

l_line-typ = c_h.

MOVE l_heading1 TO l_line-info.

APPEND l_line TO lt_top_of_page.

ENDFORM. "comment_build

&----


*& Form calc_date

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM calc_date .

b_date = s_date-low - 1.

ENDFORM. " calc_date

----


  • Form : call_list_viewer

  • Description : This form is used to display the grid through ALV

----


FORM call_list_viewer.

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

*PERFORM header_prn.

LOOP AT i_final.

MOVE sy-tabix TO i_final-srno.

MODIFY i_final TRANSPORTING srno.

ENDLOOP.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = g_repid

is_layout = x_layout

it_fieldcat = i_fldcat[]

it_sort = i_sort[]

i_default = c_x

i_save = g_save

it_events = g_events[]

IMPORTING

e_exit_caused_by_caller = g_exit_caused_by_caller

es_exit_caused_by_user = g_exit_caused_by_user

TABLES

t_outtab = i_final

EXCEPTIONS

program_error = 1

OTHERS = 2.

IF sy-subrc <> 0.

WRITE: / 'Problem in calling the ALV report'(042).

ENDIF.

ENDFORM. " call_list_viewer

thanks in advance,

marks will b sure*

regards

vijay dwivedi