Skip to Content
avatar image
Former Member

How to download output data into Excel with all Column Headings

Hi Experts,

Please tell me How to download output data of ALV Grid into Excel file with all Column Headings and I want to do this using coding,

please send me if any solution is available.

Thanks & Regards,

Yogesh

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • avatar image
    Former Member
    Aug 17, 2007 at 11:56 AM

    Hi Yogesh,

    Try with this code.

    &----


    *& Report Z_EX_OLE_EXCEL *

    *& *

    &----


    *& *

    *& *

    &----


    REPORT Z_EX_OLE_EXCEL .

    data: it_t001 type t001 occurs 0,

    it_fields type dfies occurs 0 with header line,

    begin of it_fnames occurs 0,

    reptext like dfies-reptext,

    end of it_fnames.

    • The structure definition required for this internal table.

    • The following definition is not working:

    • it_fnames like dfies-reptext occurs 0 with header line.

    • because Function Module will use the following:

    • ASSIGN COMPONENT 1 OF STRUCTURE FIELDNAMES TO <F>.

    select * from t001 into table it_t001 where land1 = 'DE'.

    CALL FUNCTION 'GET_FIELDTAB'

    EXPORTING

    • LANGU = SY-LANGU

    • ONLY = ' '

    TABNAME = 'T001'

    • WITHTEXT = 'X'

    • IMPORTING

    • HEADER =

    • RC =

    TABLES

    FIELDTAB = it_fields

    EXCEPTIONS

    INTERNAL_ERROR = 1

    NO_TEXTS_FOUND = 2

    TABLE_HAS_NO_FIELDS = 3

    TABLE_NOT_ACTIV = 4

    OTHERS = 5

    .

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

    it_fnames-reptext = it_fields-reptext.

    append it_fnames.

    endloop.

    CALL FUNCTION 'EXCEL_OLE_STANDARD_DAT'

    EXPORTING

    FILE_NAME = 'C:\test1'

    • CREATE_PIVOT = 0

    DATA_SHEET_NAME = 'Companies'

    • PIVOT_SHEET_NAME = ' '

    • PASSWORD = ' '

    • PASSWORD_OPTION = 0

    TABLES

    • PIVOT_FIELD_TAB =

    DATA_TAB = it_t001

    FIELDNAMES = it_fnames

    EXCEPTIONS

    FILE_NOT_EXIST = 1

    FILENAME_EXPECTED = 2

    COMMUNICATION_ERROR = 3

    OLE_OBJECT_METHOD_ERROR = 4

    OLE_OBJECT_PROPERTY_ERROR = 5

    INVALID_FILENAME = 6

    INVALID_PIVOT_FIELDS = 7

    DOWNLOAD_PROBLEM = 8

    OTHERS = 9

    .

    IF SY-SUBRC <> 0.

    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    Reward points. if useful

    regards

    Murugan Arumugam.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 17, 2007 at 11:57 AM

    there is a sample code in the below link

    ALV Header and Footer Exporting in MS-Excel

    Regards,

    Aparna

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 17, 2007 at 12:23 PM

    hi,

    use GUI_DOWNLOAD function module.

    if helpful reward some points.

    with regards,

    Suresh Aluri.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 18, 2007 at 08:39 AM
    • VERSION CONTROL (Most recent on top): *

    • DATE(mm.dd.yyyy) AUTHOR *

    • 06.25.2007 Pattan Naveen *

    Hi yogesh,,

    Go through this in this u find ur solution.

    report ZTEst_programe no standard page heading

    line-size 100

    line-count 50(5)

    message-id zz.

    *--alv type declaration

    type-pools: slis.

    *--Tables:

    tables: anla,

    anlz,

    anlh,

    anlb,

    anlc.

    data: v_pos type i.

    data: v_ndjar type i.

    data: v_ndper type i,

    v_ndperndabp type i,

    v_ndjarndabp1 type i,

    v_ndjarndabp type i,

    value type i,

    date(10) type c value '2006.12.04'.

    data: c_0000(4) type c value '0000'.

    data: begin of it_final occurs 0,

    anlkl(8),

    bukrs(4),

    anln1 like anla-anln1,

    anln2 like anla-anln2,

    txt50 like anla-txt50,

    txa50 like anla-txa50,

    anlhtxt like anlh-anlhtxt,

    sernr like anla-sernr,

    invnr like anla-invnr,

    menge like anla-menge,

    meins like anla-meins,

    inken like anla-inken,

    ivdat like anla-ivdat,

    aktiv like anla-aktiv,

    gsber like anlz-gsber,

    kostl like anlz-kostl,

    kostlv like anlz-kostlv,

    werks like anlz-werks,

    stort like anlz-stort,

    raumn like anlz-raumn,

    txjcd like anlz-txjcd,

    ord41 like anla-ord41,

    ord44 like anla-ord44,

    gdlgrp like anla-gdlgrp,

    anlue like anla-anlue,

    lifnr like anla-lifnr,

    typbz like anla-typbz,

    aibn1 like anla-aibn1,

    aibn2 like anla-aibn2,

    aibdt like anla-aibdt,

    posnr like anla-posnr,

    vmgli like anla-vmgli,

    invzu like anla-invzu,

    ernam like anla-ernam,

    erdat like anla-erdat,

    afabe like anlb-afabe,

    afasl like anlb-afasl,

    ndjar like anlb-ndjar,

    ndper like anlb-ndper,

    afabg like anlb-afabg,

    ndabj like anlc-ndabj,

    ndabp like anlc-ndabp,

    andsj like anlc-andsj,

    andsp like anlc-andsp,

    safbg like anlb-safbg,

    umjar like anlb-umjar,

    inbda like anlb-inbda,

    kansw like anlc-kansw,

    knafa like anlc-knafa,

    kaafa like anlc-kaafa,

    deakt like anla-deakt,

    kanza like anlc-kanza,

    kaufw like anlc-kaufw,

    kinvz like anlc-kinvz,

    ksafa like anlc-ksafa,

    kmafa like anlc-kmafa,

    end of it_final.

    data: begin of it_final_as91 occurs 0,

    anlkl(8),

    bukrs(4),

    anln1 like anla-anln1,

    anln2 like anla-anln2,

    txt50 like anla-txt50,

    txa50 like anla-txa50,

    anlhtxt like anlh-anlhtxt,

    sernr like anla-sernr,

    invnr like anla-invnr,

    menge like anla-menge,

    meins like anla-meins,

    inken like anla-inken,

    ivdat like anla-ivdat,

    aktiv like anla-aktiv,

    gsber like anlz-gsber,

    kostl like anlz-kostl,

    kostlv like anlz-kostlv,

    werks like anlz-werks,

    stort like anlz-stort,

    raumn like anlz-raumn,

    txjcd like anlz-txjcd,

    ord41 like anla-ord41,

    ord44 like anla-ord44,

    gdlgrp like anla-gdlgrp,

    anlue like anla-anlue,

    lifnr(10),

    typbz(15),

    aibn1 like anla-aibn1,

    aibn2 like anla-aibn2,

    aibdt like anla-aibdt,

    posnr like anla-posnr,

    vmgli like anla-vmgli,

    invzu like anla-invzu,

    ernam like anla-ernam,

    erdat like anla-erdat,

    end of it_final_as91.

    data: it_download_as91 like it_final_as91 occurs 0

    with header line."#EC NEEDED

    data: begin of it_final_as92 occurs 0,

    anlkl(8),

    bukrs(4),

    anln1 like anla-anln1,

    anln2 like anla-anln2,

    deakt like anla-deakt,

    ernam like anla-ernam,

    erdat like anla-erdat,

    afabe like anlb-afabe,

    afasl like anlb-afasl,

    ndjar like anlb-ndjar,

    ndper like anlb-ndper,

    afabg like date,

    ndabj(3) type c,

    ndabp(3) type c,

    kansw like anlc-kansw,

    knafa like anlc-knafa,

    kaafa like anlc-kaafa,

    kanza like anlc-kanza,

    kaufw like anlc-kaufw,

    kinvz like anlc-kinvz,

    ksafa like anlc-ksafa,

    kmafa like anlc-kmafa,

    end of it_final_as92.

    data: it_download_as92 like it_final_as92 occurs 0

    with header line."#EC NEEDED

    data: begin of it_values occurs 0,

    anlkl(8),

    bukrs(4),

    anln1 like anla-anln1,

    anln2 like anla-anln2,

    deakt like anla-deakt,

    afabe like anlb-afabe,

    afasl like anlb-afasl,

    ndjar like anlb-ndjar,

    ndper like anlb-ndper,

    afabg like date,

    ndabj(3) type c,

    ndabp(3) type c,

    afabe_02 like anlb-afabe,

    afasl_02 like anlb-afasl,

    ndjar_02 like anlb-ndjar,

    ndper_02 like anlb-ndper,

    afabg_02 like date,

    ndabj_02 like anlc-ndabj,

    ndabp_02 like anlc-ndabp,

    kansw01 like anlc-kansw,

    knafa01 like anlc-knafa,

    kaafa01 like anlc-kaafa,

    kansw02 like anlc-kansw,

    knafa02 like anlc-knafa,

    kaafa02 like anlc-kaafa,

    kansw03 like anlc-kansw,

    knafa03 like anlc-knafa,

    kaafa03 like anlc-kaafa,

    kansw04 like anlc-kansw,

    knafa04 like anlc-knafa,

    kaafa04 like anlc-kaafa,

    kansw05 like anlc-kansw,

    knafa05 like anlc-knafa,

    kaafa05 like anlc-kaafa,

    kansw06 like anlc-kansw,

    knafa06 like anlc-knafa,

    kaafa06 like anlc-kaafa,

    kansw07 like anlc-kansw,

    knafa07 like anlc-knafa,

    kaafa07 like anlc-kaafa,

    kansw08 like anlc-kansw,

    knafa08 like anlc-knafa,

    kaafa08 like anlc-kaafa,

    kansw09 like anlc-kansw,

    knafa09 like anlc-knafa,

    kaafa09 like anlc-kaafa,

    kanza01 like anlc-kanza,

    kaufw01 like anlc-kaufw,

    kinvz01 like anlc-kinvz,

    ksafa01 like anlc-ksafa,

    kmafa01 like anlc-kmafa,

    end of it_values.

    data: it_values_xls like it_values occurs 0

    with header line."#EC NEEDED

    data: begin of it_itab1 occurs 0,

    bukrs like anla-bukrs,

    anlkl like anla-anlkl,

    anln1 like anla-anln1,

    anln2 like anla-anln2,

    txt50 like anla-txt50,

    txa50 like anla-txa50,

    invnr like anla-invnr,

    ktogr like anla-ktogr,

    sernr like anla-sernr,

    menge like anla-menge,

    meins like anla-meins,

    ivdat like anla-ivdat,

    inken like anla-inken,

    aktiv like anla-aktiv,

    deakt like anla-deakt,

    zugdt like anla-zugdt,

    zujhr like anla-zujhr,

    zuper like anla-zuper,

    gdlgrp like anla-gdlgrp,

    anlue like anla-anlue,

    xafabch like anla-xafabch,

    aibn1 like anla-aibn1,

    aibn2 like anla-aibn2,

    aibdt like anla-aibdt,

    posnr like anla-posnr,

    ord41 like anla-ord41,

    ord44 like anla-ord44,

    vmgli like anla-vmgli,

    invzu like anla-invzu,

    typbz like anla-typbz,

    lifnr like anla-lifnr,

    ernam like anla-ernam,

    erdat like anla-erdat,

    end of it_itab1.

    data: begin of it_itab2 occurs 0,

    bukrs like anlz-bukrs,

    anln1 like anlz-anln1,

    anln2 like anla-anln2,

    bdatu like anlz-bdatu,

    werks like anlz-werks,

    gsber like anlz-gsber,

    kostl like anlz-kostl,

    kostlv like anlz-kostlv,

    stort like anlz-stort,

    raumn like anlz-raumn,

    txjcd like anlz-txjcd,

    ipsnr like anlz-ipsnr,

    end of it_itab2.

    data: begin of it_itab3 occurs 0,

    bukrs like anlh-bukrs,

    anln1 like anlh-anln1,

    anlhtxt like anlh-anlhtxt,

    end of it_itab3.

    data: begin of it_itab4 occurs 0,

    bukrs like anlb-bukrs,

    anln1 like anlb-anln1,

    anln2 like anla-anln2,

    afabe like anlb-afabe,

    bdatu like anlb-bdatu,

    afasl like anlb-afasl,

    ndjar like anlb-ndjar,

    ndper like anlb-ndper,

    afabg like anlb-afabg,

    ndurj like anlb-ndurj,

    ndurp like anlb-ndurp,

    umjar like anlb-umjar,

    safbg like anlb-safbg,

    zinbg like anlb-zinbg,

    inbda like anlb-inbda,

    end of it_itab4.

    data: begin of it_itab5 occurs 0,

    bukrs like anlc-bukrs,

    anln1 like anlc-anln1,

    anln2 like anla-anln2,

    gjahr like anlc-gjahr,

    afabe like anlc-afabe,

    zujhr like anlc-zujhr,

    zucod like anlc-zucod,

    ndabj like anlc-ndabj,

    ndabp like anlc-ndabp,

    kansw like anlc-kansw,

    knafa like anlc-knafa,

    kaafa like anlc-kaafa,

    ksafa like anlc-ksafa,

    andsj like anlc-andsj,

    andsp like anlc-andsp,

    kanza like anlc-kanza,

    kaufw like anlc-kaufw,

    kinvz like anlc-kinvz,

    kmafa like anlc-kmafa,

    end of it_itab5.

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

    • ALV DECLARATIONS

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

    *--declarations for Xls sheet header field names

    data: begin of it_head occurs 0,

    column(70).

    data: end of it_head.

    data: begin of it_head1 occurs 0,

    column(70).

    data: end of it_head1.

    *--type declarations for field catalog for basic report

    data: it_fldcat_head type slis_t_fieldcat_alv,

    wa_fldcat_head type slis_fieldcat_alv."#EC NEEDED

    data : w_field type slis_fieldcat_alv."#EC NEEDED

    data: it_fldcat_head1 type slis_t_fieldcat_alv,

    wa_fldcat_head1 type slis_fieldcat_alv."#EC NEEDED

    *--type declarations for layout design

    data: wa_layout type slis_layout_alv.

    *--type declarations for list header on grid

    *data: top_of_page type slis_t_listheader.

    *--declaration of variables

    data : w_repid like sy-repid.

    **selection-screen

    select-options: s_bukrs for anla-bukrs,

    s_anln1 for anla-anln1.

    select-options: s_deakt for anla-deakt,

    s_gjahr for anlc-gjahr obligatory,

    s_anlkl for anla-anlkl,

    s_date for anla-aktiv.

    *selection-screen

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

    selection-screen begin of line.

    parameters : r1 radiobutton group g1 default 'X'.

    selection-screen comment 20(50) text-020.

    selection-screen end of line.

    selection-screen begin of line.

    parameters : r2 radiobutton group g1.

    selection-screen comment 20(50) text-021.

    selection-screen end of line.

    selection-screen end of block blk1.

    selection-screen begin of block blk2 with frame title text-023.

    select-options: s_ernam for anla-ernam,

    s_erdat for anla-erdat .

    selection-screen end of block blk2.

    *--INITIALIZATION

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

    initialization.

    w_repid = sy-repid.

    at selection-screen.

    if r1 = 'X'.

    perform selection_screen_validation.

    endif.

    if r2 = 'X'.

    perform selection_screen_validation.

    endif.

    *--START-OF-SELCTION

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

    start-of-selection.

    if r1 = 'X'.

    perform populate-data.

    perform fill_finaldata.

    • perform comment_build using top_of_page.

    perform xls_output.

    perform download.

    endif.

    if r2 = 'X'.

    perform populate-data.

    perform fill_finaldata.

    perform fill_as92data.

    perform putdata_horizontal.

    perform xls_output_as92.

    perform download_as92.

    endif.

    *--END-OF-SELCTION

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

    end-of-selection.

    if r1 = 'X'.

    perform build_layout.

    perform build_fieldcatalog.

    • perform top_of_page.

    perform list-display.

    endif.

    if r2 = 'X'.

    perform build_layout.

    perform build_fieldcatalog1.

    perform list-display1.

    endif.

    &----


    *& Form SELECTION_SCREEN_VALIDATION

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    form selection_screen_validation.

    *--validating originating company code

    data: l_bukrs like anla-bukrs."#EC NEEDED

    if not s_bukrs[] is initial.

    select single bukrs from anla

    into l_bukrs

    where bukrs in s_bukrs.

    if sy-subrc <> 0.

    message e000 with text-001 .

    endif.

    endif.

    *--validating originating main asset no.

    data: l_anln1 like anla-anln1."#EC NEEDED

    if not s_anln1[] is initial.

    select single anln1 from anla

    into l_anln1

    where anln1 in s_anln1.

    if sy-subrc <> 0.

    message e000 with text-002 .

    endif.

    endif.

    *--validating originating Deactivation date

    data: l_deakt like anla-deakt."#EC NEEDED

    if not s_deakt[] is initial.

    select single deakt from anla

    into l_deakt

    where deakt in s_deakt.

    if sy-subrc <> 0.

    message e000 with text-004 .

    endif.

    endif.

    *--validating originating asset class.

    data: l_anlkl like anla-anlkl."#EC NEEDED

    if not s_anlkl[] is initial.

    select single anlkl from anla

    into l_anlkl

    where anlkl in s_anlkl.

    if sy-subrc <> 0.

    message e000 with text-006 .

    endif.

    endif.

    *--validating originating Date

    data: l_date like anla-aktiv."#EC NEEDED

    if not s_date[] is initial.

    select single aktiv from anla

    into l_date

    where aktiv in s_date.

    if sy-subrc <> 0.

    message e000 with text-007 .

    endif.

    endif.

    *--validating originating Fiscal year which first acquisition was posted

    data: l_gjahr like anlc-gjahr."#EC NEEDED

    if not s_gjahr[] is initial.

    select single gjahr from anlc

    into l_gjahr

    where gjahr in s_gjahr.

    if sy-subrc <> 0.

    message e000 with text-008.

    endif.

    endif.

    data: l_ernam like anla-ernam."#EC NEEDED

    if not s_ernam[] is initial.

    select single ernam from anla

    into l_ernam

    where ernam in s_ernam.

    if sy-subrc <> 0.

    message e000 with text-009.

    endif.

    endif.

    data: l_erdat like anla-erdat."#EC NEEDED

    if not s_erdat[] is initial.

    select single erdat from anla

    into l_erdat

    where erdat in s_erdat.

    if sy-subrc <> 0.

    message e000 with text-010.

    endif.

    endif.

    endform. " SELECTION_SCREEN_VALIDATION

    &----


    *& Form POPULATE-DATA

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    form populate-data.

    select bukrs

    anlkl

    anln1

    anln2

    txt50

    txa50

    invnr

    ktogr

    sernr

    menge

    meins

    ivdat

    inken

    aktiv

    deakt

    zugdt

    zujhr

    zuper

    gdlgrp

    anlue

    xafabch

    aibn1

    aibn2

    aibdt

    posnr

    ord41

    ord44

    vmgli

    invzu

    typbz

    lifnr

    ernam

    erdat

    from anla

    into table it_itab1

    where anlkl in s_anlkl and

    anln1 in s_anln1 and

    deakt in s_deakt and

    bukrs in s_bukrs and

    aktiv in s_date.

    if sy-subrc ne 0.

    message e000 with 'Data does not exist'(094).

    endif.

    if not it_itab1[] is initial.

    select bukrs

    anln1

    anln2

    bdatu

    werks

    gsber

    kostl

    kostlv

    stort

    raumn

    txjcd

    ipsnr

    from anlz

    into table it_itab2

    for all entries in it_itab1

    where bukrs = it_itab1-bukrs and

    anln1 = it_itab1-anln1 and

    • anln2 = it_itab1-anln2.

    anln2 = '0000'.

    if sy-subrc ne 0.

    message e000 with 'Data does not exist'(094).

    endif.

    endif.

    if not it_itab2[] is initial.

    select bukrs

    anln1

    anlhtxt

    from anlh

    into table it_itab3

    for all entries in it_itab2

    where bukrs = it_itab2-bukrs and

    anln1 = it_itab2-anln1.

    if sy-subrc ne 0.

    message e000 with 'Data does not exist'(094).

    endif.

    endif.

    if not it_itab1[] is initial.

    select bukrs

    anln1

    anln2

    afabe

    bdatu

    afasl

    ndjar

    ndper

    afabg

    ndurj

    ndurp

    umjar

    safbg

    zinbg

    inbda

    from anlb

    into table it_itab4

    for all entries in it_itab1

    where bukrs = it_itab1-bukrs and

    anln1 = it_itab1-anln1 and

    • anln2 = it_itab1-anln2.

    anln2 = '0000'.

    if sy-subrc ne 0.

    message e000 with 'Data does not exist'(094).

    endif.

    endif.

    sort it_itab4 by bukrs anln1 anln2 afabe.

    if not it_itab4[] is initial.

    select bukrs

    anln1

    anln2

    gjahr

    afabe

    zujhr

    zucod

    ndabj

    ndabp

    kansw

    knafa

    kaafa

    ksafa

    andsj

    andsp

    kanza

    kaufw

    kinvz

    kmafa

    from anlc

    into table it_itab5

    for all entries in it_itab4

    where bukrs = it_itab4-bukrs and

    anln1 = it_itab4-anln1 and

    • anln2 = it_itab4-anln2 and

    anln2 = '0000' and

    gjahr in s_gjahr.

    if sy-subrc ne 0.

    message e000 with 'Data does not exist'(094).

    endif.

    endif.

    sort it_itab5 by bukrs anln1 anln2 ndabj ndabp.

    endform. " POPULATE-DATA

    &----


    *& Form FILL_FINALDATA

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    form fill_finaldata.

    loop at it_itab5.

    loop at it_itab4 where bukrs = it_itab5-bukrs and

    anln1 = it_itab5-anln1 and

    anln2 = it_itab5-anln2 and

    afabe = it_itab5-afabe.

    it_final-afabe = it_itab4-afabe.

    it_final-afasl = it_itab4-afasl.

    it_final-ndjar = it_itab4-ndjar.

    it_final-ndper = it_itab4-ndper.

    it_final-afabg = it_itab4-afabg.

    it_final-umjar = it_itab4-umjar.

    it_final-safbg = it_itab4-safbg.

    it_final-inbda = it_itab4-inbda.

    it_final-ndabj = it_itab5-ndabj.

    it_final-ndabp = it_itab5-ndabp.

    it_final-kansw = it_itab5-kansw.

    it_final-knafa = it_itab5-knafa.

    it_final-kaafa = it_itab5-kaafa.

    it_final-andsj = it_itab5-andsj.

    it_final-andsp = it_itab5-andsp.

    it_final-kanza = it_itab5-kanza.

    it_final-kaufw = it_itab5-kaufw.

    it_final-kinvz = it_itab5-kinvz.

    it_final-ksafa = it_itab5-ksafa.

    it_final-kmafa = it_itab5-kmafa.

    read table it_itab1 with key bukrs = it_itab5-bukrs

    anln1 = it_itab5-anln1

    anln2 = it_itab5-anln2.

    if sy-subrc = 0.

    it_final-anlkl = it_itab1-anlkl.

    it_final-anln1 = it_itab1-anln1.

    it_final-anln2 = it_itab1-anln2.

    it_final-bukrs = it_itab1-bukrs.

    it_final-txt50 = it_itab1-txt50.

    it_final-txa50 = it_itab1-txa50.

    it_final-invnr = it_itab1-invnr.

    it_final-sernr = it_itab1-sernr.

    it_final-menge = it_itab1-menge.

    it_final-meins = it_itab1-meins.

    it_final-ivdat = it_itab1-ivdat.

    it_final-inken = it_itab1-inken.

    it_final-aktiv = it_itab1-aktiv.

    it_final-deakt = it_itab1-deakt.

    it_final-gdlgrp = it_itab1-gdlgrp.

    it_final-anlue = it_itab1-anlue.

    it_final-aibn1 = it_itab1-aibn1.

    it_final-aibn2 = it_itab1-aibn2.

    it_final-aibdt = it_itab1-aibdt.

    it_final-ord41 = it_itab1-ord41.

    it_final-ord44 = it_itab1-ord44.

    it_final-vmgli = it_itab1-vmgli.

    it_final-typbz = it_itab1-typbz.

    it_final-lifnr = it_itab1-lifnr.

    it_final-posnr = it_itab1-posnr.

    it_final-invzu = it_itab1-invzu.

    endif.

    read table it_itab2 with key bukrs = it_itab5-bukrs

    anln1 = it_itab5-anln1

    anln2 = it_itab5-anln2.

    if sy-subrc = 0.

    it_final-werks = it_itab2-werks.

    it_final-gsber = it_itab2-gsber.

    it_final-kostl = it_itab2-kostl.

    it_final-kostlv = it_itab2-kostlv.

    it_final-stort = it_itab2-stort.

    it_final-raumn = it_itab2-raumn.

    it_final-txjcd = it_itab2-txjcd.

    endif.

    read table it_itab3 with key bukrs = it_itab5-bukrs

    anln1 = it_itab5-anln1.

    if sy-subrc = 0.

    it_final-anlhtxt = it_itab3-anlhtxt.

    endif.

    append it_final.

    clear it_final.

    endloop.

    endloop.

    loop at it_final.

    move-corresponding it_final to it_final_as91.

    append it_final_as91.

    clear it_final_as91.

    endloop.

    delete adjacent duplicates from it_final_as91 comparing anlkl bukrs

    anln1 anln2.

    it_download_as91[] = it_final_as91[].

    endform. " FILL_FINALDATA

    &----


    *& Form BUILD_LAYOUT

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    form build_layout.

    wa_layout-zebra = 'X'.

    endform. " BUILD_LAYOUT

    &----


    *& Form BUILD_FIELDCATALOG

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    form build_fieldcatalog.

    if it_fldcat_head is initial.

    v_pos = 0.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head-tabname = 'it_FINAL_AS91'.

    wa_fldcat_head-fieldname = 'ANLKL'.

    wa_fldcat_head-seltext_l = 'Asset Class'(093).

    append wa_fldcat_head to it_fldcat_head.

    • V_POS = 0.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head-tabname = 'it_FINAL_AS91'.

    wa_fldcat_head-fieldname = 'BUKRS'.

    wa_fldcat_head-seltext_l = 'Company'(092).

    append wa_fldcat_head to it_fldcat_head.

    • V_POS = 0.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head-tabname = 'it_FINAL_AS91'.

    wa_fldcat_head-fieldname = 'ANLN1'.

    wa_fldcat_head-seltext_l = 'Asset No'(091).

    append wa_fldcat_head to it_fldcat_head.

    • V_POS = 0.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head-tabname = 'it_FINAL_AS91'.

    wa_fldcat_head-fieldname = 'ANLN2'.

    wa_fldcat_head-seltext_l = 'Asset Sub No'(090).

    append wa_fldcat_head to it_fldcat_head.

    • V_POS = 0.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head-tabname = 'it_FINAL_AS91'.

    wa_fldcat_head-fieldname = 'TXT50'.

    wa_fldcat_head-seltext_l = 'Asset Des.'(089).

    append wa_fldcat_head to it_fldcat_head.

    • V_POS = 0.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head-tabname = 'it_FINAL_AS91'.

    wa_fldcat_head-fieldname = 'TXA50'.

    wa_fldcat_head-seltext_l = 'Asset Des.'(088).

    append wa_fldcat_head to it_fldcat_head.

    • V_POS = 0.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head-tabname = 'it_FINAL_AS91'.

    wa_fldcat_head-fieldname = 'ANLHTXT'.

    wa_fldcat_head-seltext_l = 'Asset main no txt'(087).

    append wa_fldcat_head to it_fldcat_head.

    • V_POS = 0.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head-tabname = 'it_FINAL_AS91'.

    wa_fldcat_head-fieldname = 'SERNR'.

    wa_fldcat_head-seltext_l = 's.no/Expl no.'(086).

    append wa_fldcat_head to it_fldcat_head.

    • V_POS = 0.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head-tabname = 'it_FINAL_AS91'.

    wa_fldcat_head-fieldname = 'INVNR'.

    wa_fldcat_head-seltext_l = 'Inv No'(085).

    append wa_fldcat_head to it_fldcat_head.

    • V_POS = 0.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head-tabname = 'it_FINAL_AS91'.

    wa_fldcat_head-fieldname = 'MENGE'.

    wa_fldcat_head-seltext_l = 'Qtty'(084).

    append wa_fldcat_head to it_fldcat_head.

    • V_POS = 0.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head-tabname = 'it_FINAL_AS91'.

    wa_fldcat_head-fieldname = 'MEINS'.

    wa_fldcat_head-seltext_l = 'Units'(083).

    append wa_fldcat_head to it_fldcat_head.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head-tabname = 'it_FINAL_AS91'.

    wa_fldcat_head-fieldname = 'INKEN'.

    wa_fldcat_head-seltext_l = 'Inv indi.'(082).

    append wa_fldcat_head to it_fldcat_head.

    • V_POS = 0.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head-tabname = 'it_FINAL_AS91'.

    wa_fldcat_head-fieldname = 'IVDAT'.

    wa_fldcat_head-seltext_l = 'Last inv date'(081).

    append wa_fldcat_head to it_fldcat_head.

    • V_POS = 0.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head-tabname = 'it_FINAL_AS91'.

    wa_fldcat_head-fieldname = 'AKTIV'.

    wa_fldcat_head-seltext_l = 'Asset Capital date'(080).

    append wa_fldcat_head to it_fldcat_head.

    • V_POS = 0.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head-tabname = 'it_FINAL_AS91'.

    wa_fldcat_head-fieldname = 'GSBER'.

    wa_fldcat_head-seltext_l = 'Busin. Area'(079).

    append wa_fldcat_head to it_fldcat_head.

    • V_POS = 0.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head-tabname = 'it_FINAL_AS91'.

    wa_fldcat_head-fieldname = 'KOSTL'.

    wa_fldcat_head-seltext_l = 'cost centre'(078).

    append wa_fldcat_head to it_fldcat_head.

    • V_POS = 0.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head-tabname = 'it_FINAL_AS91'.

    wa_fldcat_head-fieldname = 'KOSTLV'.

    wa_fldcat_head-seltext_l = 'CC respon.for asset'(077).

    append wa_fldcat_head to it_fldcat_head.

    • V_POS = 0.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head-tabname = 'it_FINAL_AS91'.

    wa_fldcat_head-fieldname = 'WERKS'.

    wa_fldcat_head-seltext_l = 'Plant'(076).

    append wa_fldcat_head to it_fldcat_head.

    • V_POS = 0.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head-tabname = 'it_FINAL_AS91'.

    wa_fldcat_head-fieldname = 'STORT'.

    wa_fldcat_head-seltext_l = 'Asset location'(075).

    append wa_fldcat_head to it_fldcat_head.

    • V_POS = 0.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head-tabname = 'it_FINAL_AS91'.

    wa_fldcat_head-fieldname = 'RAUMN'.

    wa_fldcat_head-seltext_l = 'Room'(074).

    append wa_fldcat_head to it_fldcat_head.

    • V_POS = 0.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head-tabname = 'it_FINAL_AS91'.

    wa_fldcat_head-fieldname = 'TXJCD'.

    wa_fldcat_head-seltext_l = 'Tax. Jur.'(073).

    append wa_fldcat_head to it_fldcat_head.

    • V_POS = 0.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head-tabname = 'it_FINAL_AS91'.

    wa_fldcat_head-fieldname = 'ORD41'.

    wa_fldcat_head-seltext_l = 'Evaluation Grp 1'(072).

    append wa_fldcat_head to it_fldcat_head.

    • V_POS = 0.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head-tabname = 'it_FINAL_AS91'.

    wa_fldcat_head-fieldname = 'ORD44'.

    wa_fldcat_head-seltext_l = 'Evaluation Grp 4'(071).

    append wa_fldcat_head to it_fldcat_head.

    • V_POS = 0.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head-tabname = 'it_FINAL_AS91'.

    wa_fldcat_head-fieldname = 'GDLGRP'.

    wa_fldcat_head-seltext_l = 'Evalu. group 5'(070).

    append wa_fldcat_head to it_fldcat_head.

    • V_POS = 0.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head-tabname = 'it_FINAL_AS91'.

    wa_fldcat_head-fieldname = 'ANLUE'.

    wa_fldcat_head-seltext_l = 'Asset Super No'(069).

    append wa_fldcat_head to it_fldcat_head.

    • V_POS = 0.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head-tabname = 'it_FINAL_AS91'.

    wa_fldcat_head-fieldname = 'LIFNR'.

    wa_fldcat_head-seltext_l = 'Vendor Acct. No.'(068).

    append wa_fldcat_head to it_fldcat_head.

    • V_POS = 0.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head-tabname = 'it_FINAL_AS91'.

    wa_fldcat_head-fieldname = 'TYPBZ'.

    wa_fldcat_head-seltext_l = 'Reference no'(067).

    append wa_fldcat_head to it_fldcat_head.

    • V_POS = 0.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head-tabname = 'it_FINAL_AS91'.

    wa_fldcat_head-fieldname = 'AIBN1'.

    wa_fldcat_head-seltext_l = 'Original Asset Trans.'(066).

    append wa_fldcat_head to it_fldcat_head.

    • V_POS = 0.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head-tabname = 'it_FINAL_AS91'.

    wa_fldcat_head-fieldname = 'AIBN2'.

    wa_fldcat_head-seltext_l = 'Original Asset Trans.'(065).

    append wa_fldcat_head to it_fldcat_head.

    • V_POS = 0.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head-tabname = 'it_FINAL_AS91'.

    wa_fldcat_head-fieldname = 'AIBDT'.

    wa_fldcat_head-seltext_l = 'Trans. Asset'(064).

    append wa_fldcat_head to it_fldcat_head.

    • V_POS = 0.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head-tabname = 'it_FINAL_AS91'.

    wa_fldcat_head-fieldname = 'POSNR'.

    wa_fldcat_head-seltext_l = 'WBS Elt. Invt. Proj.'(063).

    append wa_fldcat_head to it_fldcat_head.

    • V_POS = 0.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head-tabname = 'it_FINAL_AS91'.

    wa_fldcat_head-fieldname = 'VMGLI'.

    wa_fldcat_head-seltext_l = 'Property clas.key'(062).

    append wa_fldcat_head to it_fldcat_head.

    • V_POS = 0.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head-tabname = 'it_FINAL_AS91'.

    wa_fldcat_head-fieldname = 'INVZU'.

    wa_fldcat_head-seltext_l = 'suppl.inv spec.'(061).

    append wa_fldcat_head to it_fldcat_head.

    endif.

    endform. " BUILD_FIELDCATALOG

    &----


    *& Form COMMENT_BUILD

    &----


    • text

    ----


    • -->P_TOP_OF_PAGE text

    ----


    *

    *

    *form comment_build using top_of_page type slis_t_listheader.

    *

    • data: ls_line type slis_listheader.

    *

    ****Header

    • clear : ls_line.

    • ls_line-typ = 'H'.

    • LS_LINE-KEY: not used for this type

  • ls_line-info = 'ASSET MASTER DATA LIST'.

  • append ls_line to top_of_page.

  • *

    ****Selection

    • clear ls_line.

    • ls_line-typ = 'S'.

    • ls_line-key = 'Key 1'.

    • ls_line-info = 'Asset Records'.

    • append ls_line to top_of_page.

    *

    ****Action

    • clear ls_line.

    • ls_line-typ = 'A'.

    • LS_LINE-KEY: not used for this type

  • ls_line-info = 'for AS91'.

  • append ls_line to top_of_page.

  • *

    *endform. "comment_build

    ----


    • FORM top_of_page *

    ----


    • *

    ----


    *form top_of_page.

    **

    • call function 'REUSE_ALV_COMMENTARY_WRITE'

    • exporting

    • i_logo = 'ENJOYSAP_LOGO'

    • it_list_commentary = top_of_page.

    *

    *endform. "top_of_page

    &----


    *& Form LIST-DISPLAY

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    form list-display.

    • wa_layout-colwidth_optimize = 'X'.

    call function 'REUSE_ALV_GRID_DISPLAY'

    exporting

    i_callback_program = w_repid

    • i_callback_top_of_page = 'TOP_OF_PAGE'

    is_layout = wa_layout

    it_fieldcat = it_fldcat_head

    • i_background_id = 'ALV_BACKGROUND'

    tables

    t_outtab = it_final_as91

    exceptions

    program_error = 1

    others = 2.

    if sy-subrc <> 0.

    write:/'No Top of Page'(098).

    endif.

    endform. " LIST-DISPLAY

    &----


    *& Form DOWNLOAD

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    form download.

    perform setup_header.

    call function 'DOWNLOAD'

    exporting

    filetype = 'DAT'

    tables

    data_tab = it_download_as91

    fieldnames = it_head

    exceptions

    invalid_filesize = 1

    invalid_table_width = 2

    invalid_type = 3

    no_batch = 4

    unknown_error = 5

    gui_refuse_filetransfer = 6

    customer_error = 7

    others = 8.

    if sy-subrc <> 0.

    write:/'Error in file Type'(097).

    endif.

    endform. " DOWNLOAD

    &----


    *& Form setup_header

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    form setup_header.

    it_head-column = 'Asset Class'(093).

    append it_head.

    it_head-column = 'Company'(092).

    append it_head.

    it_head-column = 'Asset No'(091).

    append it_head.

    it_head-column = 'Asset Sub No'(090).

    append it_head.

    it_head-column = 'Asset Des.'(089).

    append it_head.

    it_head-column = 'Asset Des.'(088).

    append it_head.

    it_head-column = 'Asset main no txt'(087).

    append it_head.

    it_head-column = 's.no/Expl no.'(086).

    append it_head.

    it_head-column = 'Inv No'(085).

    append it_head.

    it_head-column = 'Qtty'(084).

    append it_head.

    it_head-column = 'Units'(083).

    append it_head.

    it_head-column = 'Inv indi.'(082).

    append it_head.

    it_head-column = 'Last inv date'(081).

    append it_head.

    it_head-column = 'Asset Capital date'(080).

    append it_head.

    it_head-column = 'Busin. Area'(079).

    append it_head.

    it_head-column = 'cost centre'(078).

    append it_head.

    it_head-column = 'CC respon.for asset'(077).

    append it_head.

    it_head-column = 'Plant'(076).

    append it_head.

    it_head-column = 'Asset location'(075).

    append it_head.

    it_head-column = 'Room'(074).

    append it_head.

    it_head-column = 'Tax. Jur.'(073).

    append it_head.

    it_head-column = 'Evaluation Grp 1'(072).

    append it_head.

    it_head-column = 'Evaluation Grp 4'(071).

    append it_head.

    it_head-column = 'Evalu. group 5'(070).

    append it_head.

    it_head-column = 'Asset Super No'(069).

    append it_head.

    it_head-column = 'Vendor Acct. No.'(068).

    append it_head.

    it_head-column = 'Reference no'(067).

    append it_head.

    it_head-column = 'Original Asset Trans.'(066).

    append it_head.

    it_head-column = 'Original Asset Trans.'(065).

    append it_head.

    it_head-column = 'Trans. Asset'(064).

    append it_head.

    it_head-column = 'WBS Elt. Invt. Proj.'(063).

    append it_head.

    it_head-column = 'Property clas.key'(062).

    append it_head.

    it_head-column = 'suppl.inv spec.'(061).

    append it_head.

    endform. "setup_header

    &----


    *& Form XLS_OUTPUT

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    form xls_output.

    move it_final_as91-anlkl to it_download_as91-anlkl .

    move it_final_as91-bukrs to it_download_as91-bukrs .

    move it_final_as91-anln1 to it_download_as91-anln1 .

    move it_final_as91-anln2 to it_download_as91-anln2 .

    move it_final_as91-txt50 to it_download_as91-txt50 .

    move it_final_as91-txa50 to it_download_as91-txa50 .

    move it_final_as91-anlhtxt to it_download_as91-anlhtxt.

    move it_final_as91-sernr to it_download_as91-sernr .

    move it_final_as91-invnr to it_download_as91-invnr .

    move it_final_as91-menge to it_download_as91-menge .

    move it_final_as91-meins to it_download_as91-meins .

    move it_final_as91-inken to it_download_as91-inken .

    move it_final_as91-ivdat to it_download_as91-ivdat .

    move it_final_as91-aktiv to it_download_as91-aktiv .

    move it_final_as91-gsber to it_download_as91-gsber .

    move it_final_as91-kostl to it_download_as91-kostl .

    move it_final_as91-kostlv to it_download_as91-kostlv .

    move it_final_as91-werks to it_download_as91-werks .

    move it_final_as91-stort to it_download_as91-stort .

    move it_final_as91-raumn to it_download_as91-raumn .

    move it_final_as91-txjcd to it_download_as91-txjcd .

    move it_final_as91-ord41 to it_download_as91-ord41 .

    move it_final_as91-ord44 to it_download_as91-ord44 .

    move it_final_as91-gdlgrp to it_download_as91-gdlgrp.

    move it_final_as91-anlue to it_download_as91-anlue .

    move it_final_as91-lifnr to it_download_as91-lifnr .

    move it_final_as91-typbz to it_download_as91-typbz .

    move it_final_as91-aibn1 to it_download_as91-aibn1 .

    move it_final_as91-aibn2 to it_download_as91-aibn2 .

    move it_final_as91-aibdt to it_download_as91-aibdt .

    move it_final_as91-posnr to it_download_as91-posnr .

    move it_final_as91-vmgli to it_download_as91-vmgli .

    move it_final_as91-invzu to it_download_as91-invzu .

    endform. " XLS_OUTPUT

    &----


    *& Form FILL_AS92DATA

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    form fill_as92data.

    sort it_final by bukrs anln1 anln2 afabe.

    loop at it_final .

    move-corresponding it_final to it_final_as92.

    append it_final_as92.

    clear it_final_as92.

    endloop.

    it_download_as91[] = it_final_as92[].

    endform. " FILL_AS92DATA

    &----


    *& Form XLS_OUTPUT_AS92

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    form xls_output_as92.

    it_values_xls-anlkl = it_values-anlkl.

    it_values_xls-bukrs = it_values-bukrs.

    it_values_xls-anln1 = it_values-anln1.

    it_values_xls-anln2 = it_values-anln2.

    it_values_xls-deakt = it_values-deakt.

    it_values_xls-afabe = it_values-afabe.

    it_values_xls-afasl = it_values-afasl.

    it_values_xls-ndjar = it_values-ndjar.

    it_values_xls-ndper = it_values-ndper.

    it_values_xls-afabg = it_values-afabg.

    it_values_xls-ndabj = it_values-ndabj.

    it_values_xls-ndabp = it_values-ndabp.

    it_values_xls-afabe_02 = it_values-afabe_02.

    it_values_xls-afasl_02 = it_values-afasl_02.

    it_values_xls-ndjar_02 = it_values-ndjar_02.

    it_values_xls-ndper_02 = it_values-ndper_02.

    it_values_xls-afabg_02 = it_values-afabg_02.

    it_values_xls-ndabj_02 = it_values-ndabj_02.

    it_values_xls-ndabp_02 = it_values-ndabp_02.

    it_values_xls-kansw01 = it_values-kansw01.

    it_values_xls-knafa01 = it_values-knafa01.

    it_values_xls-kaafa01 = it_values-kaafa01.

    it_values_xls-kansw02 = it_values-kansw02.

    it_values_xls-knafa02 = it_values-knafa02.

    it_values_xls-kaafa02 = it_values-kaafa02.

    it_values_xls-kansw03 = it_values-kansw03.

    it_values_xls-knafa03 = it_values-knafa03.

    it_values_xls-kaafa03 = it_values-kaafa03.

    it_values_xls-kansw04 = it_values-kansw04.

    it_values_xls-knafa04 = it_values-knafa04.

    it_values_xls-kaafa04 = it_values-kaafa04.

    it_values_xls-kansw05 = it_values-kansw05.

    it_values_xls-knafa05 = it_values-knafa05.

    it_values_xls-kaafa05 = it_values-kaafa05.

    it_values_xls-kansw06 = it_values-kansw06.

    it_values_xls-knafa06 = it_values-knafa06.

    it_values_xls-kaafa06 = it_values-kaafa06.

    it_values_xls-kansw07 = it_values-kansw07.

    it_values_xls-knafa07 = it_values-knafa07.

    it_values_xls-kaafa07 = it_values-kaafa07.

    it_values_xls-kansw08 = it_values-kansw08.

    it_values_xls-knafa08 = it_values-knafa08.

    it_values_xls-kaafa08 = it_values-kaafa08.

    it_values_xls-kansw09 = it_values-kansw09.

    it_values_xls-knafa09 = it_values-knafa09.

    it_values_xls-kaafa09 = it_values-kaafa09.

    endform. " XLS_OUTPUT_AS92

    &----


    *& Form DOWNLOAD_AS92

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    form download_as92.

    perform setup_header1.

    call function 'DOWNLOAD'

    exporting

    filetype = 'DAT'

    tables

    data_tab = it_values

    fieldnames = it_head1

    exceptions

    invalid_filesize = 1

    invalid_table_width = 2

    invalid_type = 3

    no_batch = 4

    unknown_error = 5

    gui_refuse_filetransfer = 6

    customer_error = 7

    others = 8.

    if sy-subrc <> 0.

    write:/'Error in File size'(096).

    endif.

    endform. " DOWNLOAD_AS92

    &----


    *& Form SETUP_HEADER1

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    form setup_header1.

    it_head1-column = 'Asset Class'(060).

    append it_head1.

    it_head1-column = 'Company'(059).

    append it_head1.

    it_head1-column = 'Asset No'(058).

    append it_head1.

    it_head1-column = 'Asset Sub No'(057).

    append it_head1.

    it_head1-column = 'Deact.Date'(056).

    append it_head1.

    it_head1-column = 'Depre. Area'(055).

    append it_head1.

    it_head1-column = 'Depre. Key'(054).

    append it_head1.

    it_head1-column = 'Planned useful years'(053).

    append it_head1.

    it_head1-column = 'Planned useful Prds'(052).

    append it_head1.

    it_head1-column = 'Depr Calc.Stt Date'(051).

    append it_head1.

    it_head1-column = 'Expi usful life yrs'(050).

    append it_head1.

    it_head1-column = 'Expi usful life Prds'(049).

    append it_head1.

    it_head1-column = 'Depre. Area(02)'(048).

    append it_head1.

    it_head1-column = 'Depre. Key(02)'(047).

    append it_head1.

    it_head1-column = 'Planned useful years(02)'(046).

    append it_head1.

    it_head1-column = 'Planned useful Prds(02)'(045).

    append it_head1.

    it_head1-column = 'Depr Calc.Stt Date(02)'(044).

    append it_head1.

    it_head1-column = 'Expi usful life yrs(02)'(043).

    append it_head1.

    it_head1-column = 'Expi usful life Prds(02)'(042).

    append it_head1.

    it_head1-column = 'Cumul.acqu.prod.cost(01)'(041).

    append it_head1.

    it_head1-column = 'Accum.ordi.depre(01)'(040).

    append it_head1.

    it_head1-column = 'Cumul.unpla.depre(01)'(039).

    append it_head1.

    it_head1-column = 'Cumul.acq.prod.cost(02)'(038).

    append it_head1.

    it_head1-column = 'Accu.ordi.depre(02)'(037).

    append it_head1.

    it_head1-column = 'Cumul.unpla.depre(02)'(036).

    append it_head1.

    it_head1-column = 'Cumul.acqu.prod.cost(03)'(035).

    append it_head1.

    it_head1-column = 'Accum.ordi.depre(03)'(034).

    append it_head1.

    it_head1-column = 'Cumul.unpla.depre(03)'(033).

    append it_head1.

    it_head1-column = 'Cumul.acqu.prod.cost(04)'(032).

    append it_head1.

    it_head1-column = 'Accum.ordi.depre(04)'(031).

    append it_head1.

    it_head1-column = 'Cumul.unpla depre(04)'(030).

    append it_head1.

    it_head1-column = 'Cumul.acqu.prod.cost(05)'(029).

    append it_head1.

    it_head1-column = 'Accum.ordi.depre(05)'(028).

    append it_head1.

    it_head1-column = 'Cumul.unpla depre(05)'(027).

    append it_head1.

    it_head1-column = 'Cumul.acqu.prod.cost(06)'(026).

    append it_head1.

    it_head1-column = 'Accum.ordi.depre(06)'(025).

    append it_head1.

    it_head1-column = 'Cumul.unpla.depre(06)'(024).

    append it_head1.

    it_head1-column = 'Cumul.acqu.produc.cost(07)'(019).

    append it_head1.

    it_head1-column = 'Accum.ordi.depre(07)'(018).

    append it_head1.

    it_head1-column = 'Cumul.unpla.depre(07)'(017).

    append it_head1.

    it_head1-column = 'Cumul.acqu.prod.cost(08)'(016).

    append it_head1.

    it_head1-column = 'Accum.ordi.depre(08)'(015).

    append it_head1.

    it_head1-column = 'Cumul.unpla.depre(08)'(014).

    append it_head1.

    it_head1-column = 'Cumul.acq.prod.cost(09)'(013).

    append it_head1.

    it_head1-column = 'Accum.ordi.depre(09)'(012).

    append it_head1.

    it_head1-column = 'Cumul.unpla depre(09)'(011).

    append it_head1.

    endform. " SETUP_HEADER1

    &----


    *& Form BUILD_FIELDCATALOG1

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    form build_fieldcatalog1.

    if it_fldcat_head1 is initial.

    v_pos = 0.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head1-tabname = 'it_VALUES'.

    wa_fldcat_head1-fieldname = 'ANLKL'.

    wa_fldcat_head1-seltext_l = 'Asset Class'(060).

    append wa_fldcat_head1 to it_fldcat_head1.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head1-tabname = 'it_VALUES'.

    wa_fldcat_head1-fieldname = 'BUKRS'.

    wa_fldcat_head1-seltext_l = 'Company'(059).

    append wa_fldcat_head1 to it_fldcat_head1.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head1-tabname = 'it_VALUES'.

    wa_fldcat_head1-fieldname = 'ANLN1'.

    wa_fldcat_head1-seltext_l = 'Asset No'(058).

    append wa_fldcat_head1 to it_fldcat_head1.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head1-tabname = 'it_VALUES'.

    wa_fldcat_head1-fieldname = 'ANLN2'.

    wa_fldcat_head1-seltext_l = 'Asset Sub No'(057).

    append wa_fldcat_head1 to it_fldcat_head1.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head1-tabname = 'it_VALUES'.

    wa_fldcat_head1-fieldname = 'DEAKT'.

    wa_fldcat_head1-seltext_l = 'Deact.Date'(056).

    append wa_fldcat_head1 to it_fldcat_head1.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head1-tabname = 'it_VALUES'.

    wa_fldcat_head1-fieldname = 'AFABE'.

    wa_fldcat_head1-seltext_l = 'Depre. Area'(055).

    append wa_fldcat_head1 to it_fldcat_head1.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head1-tabname = 'it_VALUES'.

    wa_fldcat_head1-fieldname = 'AFASL'.

    wa_fldcat_head1-seltext_l = 'Depre. Key'(054).

    append wa_fldcat_head1 to it_fldcat_head1.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head1-tabname = 'it_VALUES'.

    wa_fldcat_head1-fieldname = 'NDJAR'.

    wa_fldcat_head1-seltext_l = 'Planned useful years'(053).

    append wa_fldcat_head1 to it_fldcat_head1.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head1-tabname = 'it_VALUES'.

    wa_fldcat_head1-fieldname = 'NDPER'.

    wa_fldcat_head1-seltext_l = 'Planned useful Prds'(052).

    append wa_fldcat_head1 to it_fldcat_head1.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head1-tabname = 'it_VALUES'.

    wa_fldcat_head1-fieldname = 'AFABG'.

    wa_fldcat_head1-seltext_l = 'Depr Calc.Stt Date'(051).

    append wa_fldcat_head1 to it_fldcat_head1.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head1-tabname = 'it_VALUES'.

    wa_fldcat_head1-fieldname = 'NDABJ'.

    wa_fldcat_head1-seltext_l = 'Expi usful life yrs'(050).

    append wa_fldcat_head1 to it_fldcat_head1.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head1-tabname = 'it_VALUES'.

    wa_fldcat_head1-fieldname = 'NDABP'.

    wa_fldcat_head1-seltext_l = 'Expi usful life Prds'(049).

    append wa_fldcat_head1 to it_fldcat_head1.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head1-tabname = 'it_VALUES'.

    wa_fldcat_head1-fieldname = 'AFABE_02'.

    wa_fldcat_head1-seltext_l = 'Depre. Area(02)'(048).

    append wa_fldcat_head1 to it_fldcat_head1.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head1-tabname = 'it_VALUES'.

    wa_fldcat_head1-fieldname = 'AFASL_02'.

    wa_fldcat_head1-seltext_l = 'Depre. Key(02)'(047).

    append wa_fldcat_head1 to it_fldcat_head1.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head1-tabname = 'it_VALUES'.

    wa_fldcat_head1-fieldname = 'NDJAR_02'.

    wa_fldcat_head1-seltext_l = 'Planned useful years(02)'(046).

    append wa_fldcat_head1 to it_fldcat_head1.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head1-tabname = 'it_VALUES'.

    wa_fldcat_head1-fieldname = 'NDPER_02'.

    wa_fldcat_head1-seltext_l = 'Planned useful Prds(02)'(045).

    append wa_fldcat_head1 to it_fldcat_head1.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head1-tabname = 'it_VALUES'.

    wa_fldcat_head1-fieldname = 'AFABG_02'.

    wa_fldcat_head1-seltext_l = 'Depr Calc.Stt Date(02)'(044).

    append wa_fldcat_head1 to it_fldcat_head1.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head1-tabname = 'it_VALUES'.

    wa_fldcat_head1-fieldname = 'NDABJ_02'.

    wa_fldcat_head1-seltext_l = 'Expi usful life yrs(02)'(043).

    append wa_fldcat_head1 to it_fldcat_head1.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head1-tabname = 'it_VALUES'.

    wa_fldcat_head1-fieldname = 'NDABP_02'.

    wa_fldcat_head1-seltext_l = 'Expi usful life Prds(02)'(042).

    append wa_fldcat_head1 to it_fldcat_head1.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head1-tabname = 'it_VALUES'.

    wa_fldcat_head1-fieldname = 'KANSW01'.

    wa_fldcat_head1-seltext_l = 'Cumul.acqu.prod.cost(01)'(041).

    append wa_fldcat_head1 to it_fldcat_head1.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head1-tabname = 'it_VALUES'.

    wa_fldcat_head1-fieldname = 'KNAFA01'.

    wa_fldcat_head1-seltext_l = 'Accum.ordi.depre(01)'(040).

    append wa_fldcat_head1 to it_fldcat_head1.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head1-tabname = 'it_VALUES'.

    wa_fldcat_head1-fieldname = 'KAAFA01'.

    wa_fldcat_head1-seltext_l = 'Cumul.unpla.depre(01)'(039).

    append wa_fldcat_head1 to it_fldcat_head1.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head1-tabname = 'it_VALUES'.

    wa_fldcat_head1-fieldname = 'KANSW02'.

    wa_fldcat_head1-seltext_l = 'Cumul.acq.prod.cost(02)'(038).

    append wa_fldcat_head1 to it_fldcat_head1.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head1-tabname = 'it_VALUES'.

    wa_fldcat_head1-fieldname = 'KNAFA02'.

    wa_fldcat_head1-seltext_l = 'Accu.ordi.depre(02)'(037).

    append wa_fldcat_head1 to it_fldcat_head1.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head1-tabname = 'it_VALUES'.

    wa_fldcat_head1-fieldname = 'KAAFA02'.

    wa_fldcat_head1-seltext_l = 'Cumul.unpla.depre(02)'(036).

    append wa_fldcat_head1 to it_fldcat_head1.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head1-tabname = 'it_VALUES'.

    wa_fldcat_head1-fieldname = 'KANSW03'.

    wa_fldcat_head1-seltext_l = 'Cumul.acqu.prod.cost(03)'(035).

    append wa_fldcat_head1 to it_fldcat_head1.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head1-tabname = 'it_VALUES'.

    wa_fldcat_head1-fieldname = 'KNAFA03'.

    wa_fldcat_head1-seltext_l = 'Accum.ordi.depre(03)'(034).

    append wa_fldcat_head1 to it_fldcat_head1.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head1-tabname = 'it_VALUES'.

    wa_fldcat_head1-fieldname = 'KAAFA03'.

    wa_fldcat_head1-seltext_l = 'Cumul.unpla.depre(03)'(033).

    append wa_fldcat_head1 to it_fldcat_head1.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head1-tabname = 'it_VALUES'.

    wa_fldcat_head1-fieldname = 'KANSW04'.

    wa_fldcat_head1-seltext_l = 'Cumul.acqu.prod.cost(04)'(032).

    append wa_fldcat_head1 to it_fldcat_head1.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head1-tabname = 'it_VALUES'.

    wa_fldcat_head1-fieldname = 'KNAFA04'.

    wa_fldcat_head1-seltext_l = 'Accum.ordi.depre(04)'(031).

    append wa_fldcat_head1 to it_fldcat_head1.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head1-tabname = 'it_VALUES'.

    wa_fldcat_head1-fieldname = 'KAAFA04'.

    wa_fldcat_head1-seltext_l = 'Cumul.unpla depre(04)'(030).

    append wa_fldcat_head1 to it_fldcat_head1.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head1-tabname = 'it_VALUES'.

    wa_fldcat_head1-fieldname = 'KANSW05'.

    wa_fldcat_head1-seltext_l = 'Cumul.acqu.prod.cost(05)'(029).

    append wa_fldcat_head1 to it_fldcat_head1.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head1-tabname = 'it_VALUES'.

    wa_fldcat_head1-fieldname = 'KNAFA05'.

    wa_fldcat_head1-seltext_l = 'Accum.ordi.depre(05)'(028).

    append wa_fldcat_head1 to it_fldcat_head1.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head1-tabname = 'it_VALUES'.

    wa_fldcat_head1-fieldname = 'KAAFA05'.

    wa_fldcat_head1-seltext_l = 'Cumul.unpla depre(05)'(027).

    append wa_fldcat_head1 to it_fldcat_head1.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head1-tabname = 'it_VALUES'.

    wa_fldcat_head1-fieldname = 'KANSW06'.

    wa_fldcat_head1-seltext_l = 'Cumul.acqu.prod.cost(06)'(026).

    append wa_fldcat_head1 to it_fldcat_head1.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head1-tabname = 'it_VALUES'.

    wa_fldcat_head1-fieldname = 'KNAFA06'.

    wa_fldcat_head1-seltext_l = 'Accum.ordi.depre(06)'(025).

    append wa_fldcat_head1 to it_fldcat_head1.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head1-tabname = 'it_VALUES'.

    wa_fldcat_head1-fieldname = 'KAAFA06'.

    wa_fldcat_head1-seltext_l = 'Cumul.unpla.depre(06)'(024).

    append wa_fldcat_head1 to it_fldcat_head1.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head1-tabname = 'it_VALUES'.

    wa_fldcat_head1-fieldname = 'KANSW07'.

    wa_fldcat_head1-seltext_l = 'Cumul.acqu.produc.cost(07)'(019).

    append wa_fldcat_head1 to it_fldcat_head1.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head1-tabname = 'it_VALUES'.

    wa_fldcat_head1-fieldname = 'KNAFA07'.

    wa_fldcat_head1-seltext_l = 'Accum.ordi.depre(07)'(018).

    append wa_fldcat_head1 to it_fldcat_head1.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head1-tabname = 'it_VALUES'.

    wa_fldcat_head1-fieldname = 'KAAFA07'.

    wa_fldcat_head1-seltext_l = 'Cumul.unpla.depre(07)'(017).

    append wa_fldcat_head1 to it_fldcat_head1.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head1-tabname = 'it_VALUES'.

    wa_fldcat_head1-fieldname = 'KANSW08'.

    wa_fldcat_head1-seltext_l = 'Cumul.acqu.prod.cost(08)'(016).

    append wa_fldcat_head1 to it_fldcat_head1.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head1-tabname = 'it_VALUES'.

    wa_fldcat_head1-fieldname = 'KNAFA08'.

    wa_fldcat_head1-seltext_l = 'Accum.ordi.depre(08)'(015).

    append wa_fldcat_head1 to it_fldcat_head1.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head1-tabname = 'it_VALUES'.

    wa_fldcat_head1-fieldname = 'KAAFA08'.

    wa_fldcat_head1-seltext_l = 'Cumul.unpla.depre(08)'(014).

    append wa_fldcat_head1 to it_fldcat_head1.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head1-tabname = 'it_VALUES'.

    wa_fldcat_head1-fieldname = 'KANSW09'.

    wa_fldcat_head1-seltext_l = 'Cumul.acq.prod.cost(09)'(013).

    append wa_fldcat_head1 to it_fldcat_head1.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head1-tabname = 'it_VALUES'.

    wa_fldcat_head1-fieldname = 'KNAFA09'.

    wa_fldcat_head1-seltext_l = 'Accum.ordi.depre(09)'(012).

    append wa_fldcat_head1 to it_fldcat_head1.

    v_pos = v_pos + 1.

    w_field-col_pos = v_pos.

    wa_fldcat_head1-tabname = 'it_VALUES'.

    wa_fldcat_head1-fieldname = 'KAAFA09'.

    wa_fldcat_head1-seltext_l = 'Cumul.unpla depre(09)'(011).

    append wa_fldcat_head1 to it_fldcat_head1.

    endif.

    endform. " BUILD_FIELDCATALOG1

    &----


    *& Form LIST-DISPLAY1

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    form list-display1.

    wa_layout-colwidth_optimize = 'X'.

    call function 'REUSE_ALV_GRID_DISPLAY'

    exporting

    i_callback_program = w_repid

    is_layout = wa_layout

    it_fieldcat = it_fldcat_head1

    tables

    t_outtab = it_values

    exceptions

    program_error = 1

    others = 2.

    if sy-subrc <> 0.

    write:/'Error in column width'(095).

    endif.

    endform. " LIST-DISPLAY1

    &----


    *& Form PUTDATA_HORIZONTAL

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    form putdata_horizontal.

    data: v_cnt type i.

    data: v_curr_asset(20) type c.

    read table it_final_as92 index 1.

    v_curr_asset = it_final_as92-anln1.

    v_cnt = 1.

    loop at it_final_as92.

    if v_curr_asset ne it_final_as92-anln1.

    v_curr_asset = it_final_as92-anln1.

    v_cnt = 1.

    append it_values.

    clear it_values.

    endif.

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

    if v_cnt = 1. "Start of the 01Dep. area calculations and other values

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

    it_values-anlkl = it_final_as92-anlkl.

    it_values-bukrs = it_final_as92-bukrs.

    it_values-anln1 = it_final_as92-anln1.

    it_values-anln2 = it_final_as92-anln2.

    it_values-deakt = it_final_as92-deakt.

    it_values-afabe = it_final_as92-afabe.

    it_values-afasl = it_final_as92-afasl.

    it_values-ndjar = it_final_as92-ndjar.

    it_values-ndper = it_final_as92-ndper.

    it_values-afabg = it_final_as92-afabg.

    it_values-ndabj = it_final_as92-ndabj.

    it_values-ndabp = it_final_as92-ndabp.

    it_values-kansw01 = it_final_as92-kansw.

    it_values-knafa01 = it_final_as92-knafa.

    it_values-kaafa01 = it_final_as92-kaafa.

    v_cnt = v_cnt + 1.

    elseif v_cnt = 2.

    it_values-kansw02 = it_final_as92-kansw.

    it_values-knafa02 = it_final_as92-knafa.

    it_values-kaafa02 = it_final_as92-kaafa.

    • for depreciation area 02.

    if ( it_final_as92-ndjar eq '0' and it_final_as92-ndper eq '0' )

    or

    it_final_as92-ndjar eq '99'.

    it_final_as92-afasl = c_0000.

    it_final_as92-ndjar = '99'.

    it_final_as92-ndper = ''.

    it_final_as92-ndabj = '0'.

    it_final_as92-ndabp = '0'.

    else.

    it_final_as92-afasl = 'SLM'.

    it_final_as92-afabg = date. "'2006.12.04'.

    endif.

    if it_final_as92-ndjar = ''.

    it_final_as92-ndjar = 0.

    modify it_final_as92.

    endif.

    if it_final_as92-ndabj = ''.

    it_final_as92-ndabj = 0.

    modify it_final_as92.

    endif.

    if it_final_as92-ndper = ''.

    it_final_as92-ndper = 0.

    modify it_final_as92.

    endif.

    if it_final_as92-ndabp = ''.

    it_final_as92-ndabp = 0.

    modify it_final_as92.

    endif.

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

    *Usefullife caluculation Start

    v_ndjarndabp = it_final_as92-ndjar - it_final_as92-ndabj.

    v_ndperndabp = it_final_as92-ndper - it_final_as92-ndabp.

    v_ndjarndabp1 = v_ndjarndabp - 1.

    if v_ndperndabp ge 0."First if condition

    if v_ndjarndabp lt 0.

    it_final_as92-ndjar = 0.

    v_ndjar = 0.

    it_final_as92-ndper = 0.

    v_ndper = 0.

    modify it_final_as92.

    else.

    it_final_as92-ndjar = v_ndjarndabp.

    v_ndjar = v_ndjarndabp.

    it_final_as92-ndper = v_ndperndabp.

    v_ndper = v_ndperndabp.

    modify it_final_as92.

    endif.

    else. "First if condition Else

    if v_ndjarndabp1 lt 0.

    it_final_as92-ndjar = 0.

    v_ndjar = 0.

    it_final_as92-ndper = 0.

    v_ndper = 0.

    else.

    it_final_as92-ndjar = v_ndjarndabp - 1.

    v_ndjar = v_ndjarndabp - 1.

    it_final_as92-ndper = 12 + v_ndperndabp.

    v_ndper = 12 + v_ndperndabp.

    endif.

    modify it_final_as92.

    endif."First if condition

    *For dep.area 02 the values for expired useful life should be 0

    it_final_as92-ndabj = '0'.

    it_final_as92-ndabp = '0'.

    *If useful life after calculation = 0 then make it 99 years and

    *depreciation key as 0000.

    data: v_tot(13) type c,

    v_sum(13) type c.

    if ( it_final_as92-ndjar = '0' and

    it_final_as92-ndper = '0' ).

    it_values-afasl_02 = c_0000.

    it_values-ndjar_02 = '99'.

    it_values-ndper_02 = ''.

    else.

    it_values-afasl_02 = it_final_as92-afasl.

    it_values-ndjar_02 = it_final_as92-ndjar.

    it_values-ndper_02 = it_final_as92-ndper.

    endif.

    it_values-afabe_02 = it_final_as92-afabe.

    it_values-afabg_02 = it_final_as92-afabg.

    it_values-ndabj_02 = it_final_as92-ndabj.

    it_values-ndabp_02 = it_final_as92-ndabp.

    *Calculation for Takeover value of Accumulated ordinery Dep. for 01 area

    value = ( v_ndjar * 12 + v_ndper ) .

    v_tot = ( it_final_as92-kansw + it_final_as92-kanza +

    it_final_as92-kaufw + it_final_as92-kinvz ) .

    v_sum = ( it_final_as92-knafa + it_final_as92-ksafa +

    it_final_as92-kaafa + it_final_as92-kmafa ) .

    it_values-kansw02 = v_tot + v_sum .

    if it_values-kansw02 lt 0.

    it_values-kansw02 = '0'.

    endif.

    if value ne 0.

    it_values-knafa02 = it_values-kansw02 / value.

    else.

    it_values-knafa02 = '0'.

    endif.

    *commented below as Cumulative unplanned dep is 0 for deparea 01

    *IT_VALUES-KAAFA01 = IT_FINAL_AS92-KAAFA.

    v_cnt = v_cnt + 1.

    elseif v_cnt = 3.

    it_values-kansw03 = it_final_as92-kansw.

    it_values-knafa03 = it_final_as92-knafa.

    it_values-kaafa03 = it_final_as92-kaafa.

    v_cnt = v_cnt + 1.

    elseif v_cnt = 4.

    it_values-kansw04 = it_final_as92-kansw.

    it_values-knafa04 = it_final_as92-knafa.

    it_values-kaafa04 = it_final_as92-kaafa.

    v_cnt = v_cnt + 1.

    elseif v_cnt = 5.

    it_values-kansw05 = it_final_as92-kansw.

    it_values-knafa05 = it_final_as92-knafa.

    it_values-kaafa05 = it_final_as92-kaafa.

    v_cnt = v_cnt + 1.

    elseif v_cnt = 6.

    it_values-kansw06 = it_final_as92-kansw.

    it_values-knafa06 = it_final_as92-knafa.

    it_values-kaafa06 = it_final_as92-kaafa.

    v_cnt = v_cnt + 1.

    elseif v_cnt = 7.

    it_values-kansw07 = it_final_as92-kansw.

    it_values-knafa07 = it_final_as92-knafa.

    it_values-kaafa07 = it_final_as92-kaafa.

    v_cnt = v_cnt + 1.

    elseif v_cnt = 8.

    it_values-kansw08 = it_final_as92-kansw.

    it_values-knafa08 = it_final_as92-knafa.

    it_values-kaafa08 = it_final_as92-kaafa.

    v_cnt = v_cnt + 1.

    elseif v_cnt = 9.

    it_values-kansw09 = it_final_as92-kansw.

    it_values-knafa09 = it_final_as92-knafa.

    it_values-kaafa09 = it_final_as92-kaafa.

    v_cnt = v_cnt + 1.

    endif.

    at last.

    append it_values.

    clear it_values.

    endat.

    endloop.

    sort it_values by anln1.

    endform. " PUTDATA_HORIZONTAL

    Reward points if helpful.

    Thanks

    Naveen khan

Add comment
10|10000 characters needed characters exceeded