Skip to Content
author's profile photo Former Member
Former Member

program for xls download

hi ,

i need a program for xls down load

thanks,

kalyan

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

7 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Oct 24, 2006 at 06:55 AM
    • COPIED FROM : N/A *

    • TITLE : N/A *

    • OTHER RELATED OBJ : N/A *

    ======================================================================

    • CHANGE HISTORY LOG *

    ----


    • MOD. NO.| DATE | NAME | CORRECTION NUMBER | CHANGE REFERENCE# *

    ----


    &----


    *& Include /AMS/FUSFCO_FADEPRICIATION_FORM *

    &----


    &----


    *& Form validation_company

    &----


    • Validate Company Code

    ----


    • USING PARAMETERS:

    • -->FP_S_BUKRS[] "Company Code

    ----


    FORM validation_company USING fp_s_bukrs TYPE STANDARD TABLE.

    • Local Data declarations

    DATA: l_v_bukrs TYPE bukrs.

    IF s_bukrs[] IS INITIAL.

    MESSAGE e317 WITH text-058.

    ELSE.

    • IF NOT fp_s_bukrs IS INITIAL.

    • Check company code

    SELECT bukrs "Company code

    INTO l_v_bukrs

    UP TO 1 ROWS

    FROM t001

    WHERE bukrs IN fp_s_bukrs.

    ENDSELECT.

    • If entered company code is not existing, raise error message

    IF sy-subrc NE 0.

    MESSAGE e003. " Selected Company Code does not exist in the system

    ENDIF.

    • ENDIF.

    ENDIF.

    ENDFORM. " validation_company

    &----


    *& Form initial_values

    &----


    • Initialize The Values For Company Code

    ----


    • CHANGING PARAMETERS:

    • <-- FP_S_BUKRS[] "Company Code

    ----


    FORM initial_values .

    • For company code

    MOVE: c_i TO s_bukrs-sign,

    c_eq TO s_bukrs-option,

    c_ca TO s_bukrs-low.

    APPEND s_bukrs.

    MOVE: c_i TO s_bukrs-sign,

    c_eq TO s_bukrs-option,

    c_us TO s_bukrs-low.

    APPEND s_bukrs.

    ENDFORM. " initial_values

    &----


    *& Form get_anla_data

    &----


    • Get Asset Master Record Segment(ANAL) Data as per the Selection-Screen

    ----


    • USING PARAMETERS:

    • -->FP_S_BUKRS[] "Company Code

    • -->FP_S_ANLKL[] "Asset class

    • CHANGING PARAMETERS:

    • <--FP_I_ANLA "Asset Master Record Segment

    ----


    FORM get_anla_data USING fp_s_bukrs TYPE STANDARD TABLE

    fp_s_anlkl TYPE STANDARD TABLE

    CHANGING fp_i_anla TYPE ty_t_anla

    fp_i_anla_temp TYPE ty_t_anla.

    **Selct the Asset Master Record Segment Data from table ANLA

    SELECT bukrs "Company Code

    anln1 "Main Asset Number

    anln2 "Asset Subnumber

    anlkl "Asset class

    ktogr "Account determination

    deakt "Deactivation date

    ord41 "CARAT Report Code

    aibn1 "Original asset that was transferred

    aibdt "Original acquisition date of AuC/ transferred asset

    menge "Quantity

    txt50 "Asset description

    FROM anla

    INTO TABLE fp_i_anla

    WHERE bukrs IN fp_s_bukrs AND

    anlkl IN fp_s_anlkl.

    IF sy-subrc <> c_zero.

    MESSAGE e392 . "WITH text-001. "No Data Availble in ANLA

    ELSE.

    SORT fp_i_anla BY bukrs anln1 anln2.

    MOVE fp_i_anla TO fp_i_anla_temp.

    DELETE ADJACENT DUPLICATES FROM fp_i_anla_temp COMPARING bukrs anln1 anln2.

    ENDIF.

    ENDFORM. " get_anla_data

    &----


    *& Form get_anlb_data

    &----


    • Get Depreciation terms(ANLB) Data as per the selection-screen

    ----


    • USING PARAMETERS:

    • -->FP_S_BUKRS[] "Company Code

    • CHANGING PARAMETERS:

    • <--FP_I_ANLB "Depreciation terms

    ----


    FORM get_anlb_data USING fp_i_anla_temp TYPE ty_t_anla

    CHANGING fp_i_anlb TYPE ty_t_anlb.

    *Select the Depreciation terms Data from ANLB table

    IF fp_i_anla_temp IS NOT INITIAL.

    SELECT bukrs

    anln1

    anln2

    afabe "Real depreciation area

    afabg "Depreciation calculation start date

    afasl "Depreciation key

    ndjar "Planned useful life in years

    ndper "Planned useful life in periods

    schrw "Asset scrap value

    xafbe

    FROM anlb INTO TABLE fp_i_anlb FOR ALL ENTRIES IN fp_i_anla_temp

    WHERE bukrs = fp_i_anla_temp-bukrs

    AND anln1 = fp_i_anla_temp-anln1

    AND anln2 = fp_i_anla_temp-anln2

    AND afabe EQ c_01

    AND xafbe NE c_space.

    IF sy-subrc EQ 0.

    • To consider the performance of the select.

    SORT fp_i_anlb BY bukrs anln1 anln2.

    ENDIF.

    ENDIF.

    ENDFORM. " get_anlb_data

    &----


    *& Form get_anlc_data

    &----


    • Get Asset Value Fields(ANLC) with the condition of ANLA Data

    ----


    • USING PARAMETERS:

    • -->FP_S_BUKRS[] "Company Code

    • -->FP_I_ANLA "Depreciation terms

    • CHANGING PARAMETERS:

    • <--FP_I_ANLC "Asset Value Fields

    ----


    FORM get_anlc_data USING fp_gjahr TYPE gjahr

    fp_i_anla_temp TYPE ty_t_anla

    CHANGING fp_i_anlc TYPE ty_t_anlc.

    IF fp_i_anla_temp IS NOT INITIAL.

    *Selcet Asset Value Fields data from table ANLC

    SELECT bukrs "Company Code

    anln1 "Main Asset Number

    anln2 "Asset Sub Number

    afabe "Real depreciation area

    zujhr "Asset acquisition year (currently not used)

    zucod "Sub-classification of asset acquisitions(currently not used)

    afblpe "Period in which last depreciation was posted

    kansw "Cumulative acquisition and production costs

    knafa "Accumulated ordinary depreciation

    kaafa "Cumulative unplanned depreciation

    nafap "Planned ordinary depreciation for the year

    nafag "Ordinary depreciation posted in the current year

    aafag "Unplanned depreciation posted for the year

    nafav "Proportional accumulated ordinary depreciation

    aafav "Proportional cumulative unplanned depreciation

    nafal "Proportional ordinary depreciation for the year

    aafal "Proportional unplanned depreciation for the year

    FROM anlc INTO TABLE fp_i_anlc

    FOR ALL ENTRIES IN fp_i_anla_temp

    WHERE bukrs = fp_i_anla_temp-bukrs AND

    anln1 = fp_i_anla_temp-anln1 AND

    anln2 = fp_i_anla_temp-anln2 AND

    gjahr = fp_gjahr AND

    afabe = c_01.

    • To consider the performance of the select.

    IF sy-subrc EQ c_zero.

    SORT fp_i_anlc BY bukrs anln1 anln2.

    ENDIF.

    ENDIF.

    ENDFORM. " get_anlc_data

    &----


    *& Form get_anlp_data

    &----


    • Get Asset Periodic Values(ANLP) with the condition of ANLC Data

    ----


    • USING PARAMETERS:

    • -->FP_S_BUKRS[] "Company Code

    • -->FP_P_GJAHR "Fiscal Year

    • -->FP_I_ANLA "Asset Master Record Segment

    • CHANGING PARAMETERS:

    • <--FP_I_ANLP "Asset Periodic Values

    ----


    FORM get_anlp_data USING fp_p_gjahr TYPE gjahr

    fp_p_peraf TYPE peraf

    fp_i_anlc TYPE ty_t_anlc

    CHANGING fp_i_anlp TYPE ty_t_anlp.

    *Local Variable

    DATA : l_i_anlc TYPE ty_t_anlc.

    IF fp_i_anlc IS NOT INITIAL.

    • To consider the performance of the select.

    MOVE fp_i_anlc TO l_i_anlc.

    SORT l_i_anlc BY bukrs anln1 anln2.

    DELETE ADJACENT DUPLICATES FROM l_i_anlc COMPARING bukrs anln1 anln2.

    *Select Asset Periodic Values from table ANLP

    SELECT bukrs "Company Code

    gjahr "Fiscal Year

    peraf "Depreciation calculation period

    anln1 "Main Asset Number

    anln2 "Asset Sub Number

    nafaz "Ordinary depreciation to be posted

    aafaz "Unplanned depreciation to be posted

    FROM anlp INTO TABLE fp_i_anlp

    FOR ALL ENTRIES IN fp_i_anlc

    WHERE bukrs = fp_i_anlc-bukrs AND

    gjahr = fp_p_gjahr AND

    peraf = fp_p_peraf AND

    anln1 = fp_i_anlc-anln1 AND

    anln2 = fp_i_anlc-anln2 AND

    afaber = c_01 AND

    zujhr = fp_i_anlc-zujhr AND

    zucod = fp_i_anlc-zucod.

    • To consider the performance of the select.

    IF sy-subrc EQ c_zero.

    SORT fp_i_anlp BY bukrs gjahr peraf anln1 anln2.

    ENDIF.

    REFRESH : l_i_anlc.

    ENDIF.

    ENDFORM. " get_anlp_data

    &----


    *& Form get_anlz_data

    &----


    • Get Time-Dependent Asset Allocations(ANLZ) with the condition of ANLA Data

    ----


    • USING PARAMETERS:

    • -->FP_I_ANLA "Asset Master Record Segment

    • CHANGING PARAMETERS:

    • <--FP_I_ANLZ "Time-Dependent Asset Allocations

    ----


    FORM get_anlz_data USING fp_i_anla_temp TYPE ty_t_anla

    fp_gjahr TYPE gjahr

    fp_peraf TYPE peraf

    CHANGING fp_i_anlz TYPE ty_t_anlz.

    *Local Data Declaration

    DATA : l_date TYPE dats.

    *Constants

    DATA : l_c_ng TYPE char2 VALUE 'NG'.

    *Function Module To Calculate Last calendar day in the fiscal period

    CALL FUNCTION 'LAST_DAY_IN_PERIOD_GET'

    EXPORTING

    i_gjahr = fp_gjahr

    i_periv = l_c_ng

    i_poper = fp_peraf

    IMPORTING

    e_date = l_date

    EXCEPTIONS

    input_false = 0

    t009_notfound = 0

    t009b_notfound = 0

    OTHERS = 0.

    IF fp_i_anla_temp IS NOT INITIAL.

    *Selcet Time-Dependent Asset Allocations data from ANLZ table

    SELECT bukrs "Company Code

    anln1 "Main Asset Number

    anln2 "Asset Subnumber

    kostl "Cost Center

    FROM anlz INTO TABLE fp_i_anlz

    FOR ALL ENTRIES IN fp_i_anla_temp

    WHERE bukrs = fp_i_anla_temp-bukrs AND

    anln1 = fp_i_anla_temp-anln1 AND

    anln2 = fp_i_anla_temp-anln2 AND

    bdatu GE l_date AND

    adatu LE l_date.

    IF sy-subrc EQ c_zero.

    SORT fp_i_anlz BY bukrs anln1 anln2.

    ENDIF.

    ENDIF.

    ENDFORM. " get_anlz_data

    &----


    *& Form get_t095b_data

    &----


    • get G/L accounts value adjustment(T095b) with the condition of ANLA Data

    ----


    • USING PARAMETERS:

    • -->FP_I_ANLA "Asset Master Record Segment

    • -->FP_I_ANLB "Depreciation terms

    • CHANGING PARAMETERS:

    • <--FP_I_T095B "G/L accounts value adjustment

    ----


    FORM get_t095b_data USING fp_i_anla_temp TYPE ty_t_anla

    CHANGING fp_i_t095b TYPE ty_t_t095b.

    *Local Constants

    DATA : l_c_n001 TYPE t095b-ktopl VALUE 'N001'.

    IF fp_i_anla_temp IS NOT INITIAL.

    *Select G/L accounts value adjustment from the table T095b

    SELECT ktogr "Account determination

    afabe "Real depreciation area

    ktnafg "Expense account for ordinary depreciation to book val. 0

    ktaafg "Expense account for unplanned depreciation

    FROM t095b INTO TABLE fp_i_t095b

    FOR ALL ENTRIES IN fp_i_anla_temp

    WHERE ktopl = l_c_n001 AND

    ktogr = fp_i_anla_temp-ktogr AND

    afabe = c_01.

    IF sy-subrc EQ c_zero.

    SORT fp_i_t095b BY ktogr afabe.

    ENDIF.

    ENDIF.

    ENDFORM. " get_t095b_data

    &----


    *& Form get_anep_data

    &----


    • get Asset Line Items(ANEP) with the condition of ANLA Data

    ----


    • USING PARAMETERS:

    • -->FP_I_ANLA "Asset Master Record Segment

    • CHANGING PARAMETERS:

    • <--FP_I_ANEP "Asset Line Items

    ----


    FORM get_anep_data USING fp_i_anla_temp TYPE ty_t_anla

    fp_gjahr TYPE gjahr

    CHANGING fp_i_anep TYPE ty_t_anep

    fp_i_anbtr TYPE ty_t_anbtr. "TUT

    • Begin of TUT

    FIELD-SYMBOLS: <l_fs_anep> TYPE ty_anep.

    DATA : l_wa_anbtr TYPE ty_anbtr,

    l_v_anbtr1 TYPE anbtr VALUE '0',

    l_v_anbtr2 TYPE anbtr VALUE '0'.

    CONSTANTS: l_c_zta TYPE bwasl VALUE 'ZTA',

    l_c_ztb TYPE bwasl VALUE 'ZTB',

    l_c_zr2 TYPE bwasl VALUE 'ZR2',

    l_c_zpc TYPE bwasl VALUE 'ZPC',

    l_c_ztr TYPE bwasl VALUE 'ZTR',

    l_c_zr1 TYPE bwasl VALUE 'ZR1'.

    • End of TUT

    IF fp_i_anla_temp IS NOT INITIAL.

    *Selcet Asset Line Items from the table ANEP

    SELECT bukrs "Company Code

    anln1 "Main Asset Number

    anln2 "Asset Subnumber

    gjahr "Fiscal Year

    lnran "Sequence number of asset line items in fiscal year

    afabe "Real depreciation area

    zujhr "Asset acquisition year (currently not used)

    zucod "Sub-classification of asset acquisitions(currently not used)

    bwasl "Asset transaction type

    anbtr "Amount posted

    FROM anep

    INTO TABLE fp_i_anep

    FOR ALL ENTRIES IN fp_i_anla_temp

    WHERE bukrs = fp_i_anla_temp-bukrs

    AND anln1 = fp_i_anla_temp-anln1

    AND anln2 = fp_i_anla_temp-anln2

    AND gjahr = fp_gjahr

    AND afabe = c_01.

    IF sy-subrc EQ c_zero.

    SORT fp_i_anep BY bukrs anln1 anln2 gjahr.

    *Begin of TUT

    LOOP AT fp_i_anep ASSIGNING <l_fs_anep>.

    IF <l_fs_anep>-bwasl(1) = c_1 OR <l_fs_anep>-bwasl(1) = c_3

    OR <l_fs_anep>-bwasl = l_c_zta OR <l_fs_anep>-bwasl = l_c_ztb

    OR <l_fs_anep>-bwasl = l_c_zr1 OR <l_fs_anep>-bwasl = l_c_zr2

    OR <l_fs_anep>-bwasl = l_c_ztr OR <l_fs_anep>-bwasl = l_c_zpc.

    l_v_anbtr1 = l_v_anbtr1 + <l_fs_anep>-anbtr.

    ENDIF.

    IF <l_fs_anep>-bwasl(1) NE c_6 OR <l_fs_anep>-bwasl(1) NE c_7.

    l_v_anbtr2 = l_v_anbtr2 + <l_fs_anep>-anbtr .

    ENDIF.

    AT END OF anln1.

    l_wa_anbtr-bukrs = <l_fs_anep>-bukrs.

    l_wa_anbtr-anln1 = <l_fs_anep>-anln1.

    l_wa_anbtr-anln2 = <l_fs_anep>-anln2.

    l_wa_anbtr-gjahr = <l_fs_anep>-gjahr.

    l_wa_anbtr-anbtr1 = l_v_anbtr1.

    l_wa_anbtr-anbtr2 = l_v_anbtr2.

    APPEND l_wa_anbtr TO fp_i_anbtr.

    CLEAR: l_v_anbtr1, l_v_anbtr2.

    ENDAT.

    ENDLOOP.

    SORT fp_i_anbtr BY bukrs anln1.

    • End of TUT

    ENDIF.

    ENDIF.

    ENDFORM. " get_anep_data

    &----


    *& Form get_anea_data

    &----


    • get Asset Line Items for Proportional Values(ANEA)

    • with the condition of ANEP Data

    ----


    • USING PARAMETERS:

    • -->FP_I_ANEP "Asset Line Items

    • CHANGING PARAMETERS:

    • <--FP_I_ANEA "Asset Line Items for Proportional Values

    ----


    FORM get_anea_data USING fp_i_anep TYPE ty_t_anep

    CHANGING fp_i_anea TYPE ty_t_anea.

    IF fp_i_anep IS NOT INITIAL.

    *Select Asset Line Items for Proportional Values from the table ANEA

    SELECT bukrs "Company Code

    anln1 "Main Asset Number

    anln2 "Asset Sub Number

    nafav "Proportional accumulated ordinary depreciation

    aafav "Proportional cumulative unplanned depreciation

    nafal "Proportional ordinary depreciation for the year

    aafal "Proportional unplanned depreciation for the year

    FROM anea

    INTO TABLE fp_i_anea

    FOR ALL ENTRIES IN fp_i_anep

    WHERE bukrs = fp_i_anep-bukrs AND

    anln1 = fp_i_anep-anln1 AND

    anln2 = fp_i_anep-anln2 AND

    gjahr = fp_i_anep-gjahr AND

    lnran = fp_i_anep-lnran AND

    afabe = fp_i_anep-afabe AND

    zujhr = fp_i_anep-zujhr AND

    zucod = fp_i_anep-zucod.

    IF sy-subrc EQ c_zero.

    SORT fp_i_anea BY bukrs anln1 anln2.

    ENDIF.

    ENDIF.

    ENDFORM. " get_anea_data

    &----


    *& Form get_data_final

    &----


    • Get the data for final table and it is trnasfer to Excel File

    ----


    • USING PARAMETERS:

    • -->FP_I_ANLA "Asset Master Record Segment

    • -->FP_I_ANLB "Depreciation terms

    • -->FP_I_ANLC "Asset Value Fields

    • -->FP_I_ANLP "Asset Periodic Values

    • -->FP_I_ANLZ "Depreciation terms

    • -->FP_I_ANEA "Asset Line Items for Proportional Values

    • -->FP_I_T095B "G/L accounts value adjustment

    • CHANGING PARAMETERS:

    • <--FP_I_FINALTAB "Final Table

    ----


    FORM get_data_final USING fp_i_anla TYPE ty_t_anla

    fp_i_anlb TYPE ty_t_anlb

    fp_i_anlc TYPE ty_t_anlc

    fp_i_anlp TYPE ty_t_anlp

    fp_i_anep TYPE ty_t_anep

    fp_i_anlz TYPE ty_t_anlz

    fp_i_anea TYPE ty_t_anea

    fp_i_t095b TYPE ty_t_t095b

    fp_i_anbtr TYPE ty_t_anbtr " TUT

    CHANGING fp_i_finaltab TYPE ty_t_finaltab.

    DATA: l_wa_anla TYPE ty_anla,

    l_wa_anlb TYPE ty_anlb,

    l_wa_anlc TYPE ty_anlc,

    l_wa_anlp TYPE ty_anlp,

    l_wa_anep TYPE ty_anep,

    l_wa_anlz TYPE ty_anlz,

    l_wa_anea TYPE ty_anea,

    l_wa_t095b TYPE ty_t095b,

    l_wa_anbtr TYPE ty_anbtr, " TUT

    l_wa_ftab TYPE ty_finaltab.

    • DATA: l_v_anbtr1 TYPE anbtr VALUE '0', " TUT

    • l_v_anbtr2 TYPE anbtr VALUE '0', " TUT

    DATA: l_v_na_anfav TYPE nafav,

    l_v_na_aafal TYPE aafal,

    l_v_kansw01 TYPE kansw_altd.

    *Local constants

    • CONSTANTS: l_c_zta TYPE bwasl VALUE 'ZTA', "TUT

    • l_c_ztb TYPE bwasl VALUE 'ZTB', "TUT

    • l_c_zr2 TYPE bwasl VALUE 'ZR2', "TUT

    • l_c_zpc TYPE bwasl VALUE 'ZPC', "TUT

    • l_c_ztr TYPE bwasl VALUE 'ZTR', "TUT

    • l_c_zr1 TYPE bwasl VALUE 'ZR1'. "TUT

    LOOP AT fp_i_anla INTO l_wa_anla.

    l_wa_ftab-bukrs = l_wa_anla-bukrs.

    l_wa_ftab-anln1 = l_wa_anla-anln1.

    l_wa_ftab-anln2 = l_wa_anla-anln2.

    l_wa_ftab-anlkl = l_wa_anla-anlkl.

    l_wa_ftab-txt50 = l_wa_anla-txt50.

    l_wa_ftab-deakt = l_wa_anla-deakt.

    l_wa_ftab-ord41 = l_wa_anla-ord41.

    l_wa_ftab-aibn1 = l_wa_anla-aibn1.

    l_wa_ftab-aibdt = l_wa_anla-aibdt.

    l_wa_ftab-ktogr = l_wa_anla-ktogr.

    l_wa_ftab-menge = l_wa_anla-menge.

    READ TABLE fp_i_anlb INTO l_wa_anlb WITH KEY bukrs = l_wa_anla-bukrs

    anln1 = l_wa_anla-anln1

    anln2 = l_wa_anla-anln2

    BINARY SEARCH.

    IF sy-subrc EQ 0.

    l_wa_ftab-afasl = l_wa_anlb-afasl.

    l_wa_ftab-afabe = l_wa_anlb-afabe.

    l_wa_ftab-ndjar = l_wa_anlb-ndjar.

    l_wa_ftab-ndper = l_wa_anlb-ndper.

    l_wa_ftab-afabg = l_wa_anlb-afabg.

    l_wa_ftab-schrw = l_wa_anlb-schrw.

    ENDIF.

    READ TABLE fp_i_anlc INTO l_wa_anlc WITH KEY bukrs = l_wa_anla-bukrs

    anln1 = l_wa_anla-anln1

    anln2 = l_wa_anla-anln2

    BINARY SEARCH.

    IF sy-subrc EQ 0.

    l_wa_ftab-nafag = l_wa_anlc-nafag.

    l_wa_ftab-aafag = l_wa_anlc-aafag.

    l_wa_ftab-knafa = l_wa_anlc-knafa.

    l_wa_ftab-kaafa = l_wa_anlc-kaafa.

    l_wa_ftab-nafap = l_wa_anlc-nafap.

    l_wa_ftab-afblpe = l_wa_anlc-afblpe.

    l_wa_ftab-nafav = l_wa_anlc-nafav.

    l_wa_ftab-aafav = l_wa_anlc-aafav.

    l_wa_ftab-nafal = l_wa_anlc-nafal.

    l_wa_ftab-aafal = l_wa_anlc-aafal.

    l_wa_ftab-kansw = l_wa_anlc-kansw.

    ENDIF.

    READ TABLE fp_i_anlp INTO l_wa_anlp WITH KEY bukrs = l_wa_anla-bukrs

    anln1 = l_wa_anla-anln1

    anln2 = l_wa_anla-anln2

    BINARY SEARCH.

    IF sy-subrc EQ 0.

    l_wa_ftab-peraf = l_wa_anlp-peraf.

    l_wa_ftab-gjahr = l_wa_anlp-gjahr.

    l_wa_ftab-nafaz = l_wa_anlp-nafaz.

    l_wa_ftab-aafaz = l_wa_anlp-aafaz.

    ENDIF.

    READ TABLE fp_i_anlz INTO l_wa_anlz WITH KEY bukrs = l_wa_anla-bukrs

    anln1 = l_wa_anla-anln1

    anln2 = l_wa_anla-anln2

    BINARY SEARCH.

    IF sy-subrc EQ 0.

    l_wa_ftab-kostl = l_wa_anlz-kostl.

    ENDIF.

    READ TABLE fp_i_t095b INTO l_wa_t095b WITH KEY ktogr = l_wa_anla-ktogr

    BINARY SEARCH.

    IF sy-subrc EQ 0.

    l_wa_ftab-ktnafg = l_wa_t095b-ktnafg.

    l_wa_ftab-ktaafg = l_wa_t095b-ktaafg.

    l_v_kansw01 = l_wa_t095b-ktnafg + l_wa_t095b-ktaafg.

    l_wa_ftab-kansw01 = l_v_kansw01.

    ENDIF.

    • Begin of TUT

    READ TABLE fp_i_anbtr INTO l_wa_anbtr WITH KEY bukrs = l_wa_anla-bukrs

    anln1 = l_wa_anla-anln1

    BINARY SEARCH.

    IF sy-subrc EQ 0.

    l_wa_ftab-anbtr1 = l_wa_anbtr-anbtr1.

    l_wa_ftab-anbtr2 = l_wa_anbtr-anbtr2.

    ENDIF.

    • READ TABLE fp_i_anep INTO l_wa_anep WITH KEY bukrs = l_wa_anla-bukrs

    • anln1 = l_wa_anla-anln1

    • anln2 = l_wa_anla-anln2

    • BINARY SEARCH.

    *

    • IF sy-subrc EQ 0.

    • IF l_wa_anep-bwasl(1) = c_1 OR l_wa_anep-bwasl(1) = c_3

    • OR l_wa_anep-bwasl = l_c_zta OR l_wa_anep-bwasl = l_c_ztb

    • OR l_wa_anep-bwasl = l_c_zr1 OR l_wa_anep-bwasl = l_c_zr2

    • OR l_wa_anep-bwasl = l_c_ztr OR l_wa_anep-bwasl = l_c_zpc.

    *

    • l_v_anbtr1 = l_v_anbtr1 + l_wa_anep-anbtr.

    • ELSE.

  • ENDIF.

    • IF l_wa_anep-bwasl(1) NE c_6 OR l_wa_anep-bwasl(1) NE c_7.

    • l_v_anbtr2 = l_v_anbtr2 + l_wa_anep-anbtr .

    *

    • ENDIF.

    • ENDIF.

    • l_wa_ftab-anbtr1 = l_v_anbtr1.

    • l_wa_ftab-anbtr2 = l_v_anbtr2.

    • ENDIF.

    • End of TUT

    READ TABLE fp_i_anea INTO l_wa_anea WITH KEY bukrs = l_wa_anla-bukrs

    anln1 = l_wa_anla-anln1

    anln2 = l_wa_anla-anln2

    BINARY SEARCH.

    IF sy-subrc EQ 0.

    l_v_na_anfav = l_v_na_anfav + l_wa_anea-nafav + l_wa_anea-aafav.

    l_v_na_aafal = l_v_na_aafal + l_wa_anea-nafal + l_wa_anea-aafal.

    l_wa_ftab-na_anfav = l_v_na_anfav .

    l_wa_ftab-na_nafal = l_v_na_aafal.

    ENDIF.

    APPEND l_wa_ftab TO fp_i_finaltab.

    CLEAR: l_wa_anla,

    l_wa_anlb,

    l_wa_anlc,

    l_wa_anlp,

    l_wa_anep,

    l_wa_anlz,

    l_wa_anea,

    l_wa_t095b,

    l_wa_anbtr, "TUT

    l_wa_ftab.

    ENDLOOP.

    ENDFORM. " get_data_final

    &----


    *& Form data_download

    &----


    • Data downloaded into the Temp Folder in the Excel Format

    ----


    • USING PARAMETERS:

    • -->FP_I_FINALTAB Final Table

    ----


    FORM data_download USING fp_i_ftab TYPE ty_t_finaltab

    fp_fname TYPE filep.

    DATA : l_v_file TYPE string.

    l_v_file = fp_fname.

    ***This path mentioned in FS only

    *Constants

    • DATA: l_c_path TYPE string VALUE 'c:\temp\temp.xls'.

    IF fp_i_ftab IS NOT INITIAL.

    *Function Module used to download to Presentation Server.

    CALL FUNCTION 'GUI_DOWNLOAD'

    EXPORTING

    filename = l_v_file

    filetype = 'ASC'

    write_field_separator = c_x

    TABLES

    data_tab = fp_i_ftab

    EXCEPTIONS

    file_write_error = 1

    no_batch = 2

    gui_refuse_filetransfer = 3

    invalid_type = 4

    no_authority = 5

    unknown_error = 6

    header_not_allowed = 7

    separator_not_allowed = 8

    filesize_not_allowed = 9

    header_too_long = 10

    dp_error_create = 11

    dp_error_send = 12

    dp_error_write = 13

    unknown_dp_error = 14

    access_denied = 15

    dp_out_of_memory = 16

    disk_full = 17

    dp_timeout = 18

    file_not_found = 19

    dataprovider_exception = 20

    control_flush_error = 21

    OTHERS = 22.

    IF sy-subrc <> c_zero.

    CASE sy-subrc.

    WHEN c_one.

    MESSAGE e123. "File Write error

    WHEN c_two.

    MESSAGE e124. "No batch

    WHEN c_three.

    MESSAGE e125. "GUI Refuses file transfer

    WHEN c_four.

    MESSAGE e126. "Invalid type

    WHEN c_five.

    MESSAGE e127. "No authority

    WHEN c_six.

    MESSAGE e128. "Unknown error

    WHEN c_seven.

    MESSAGE e129. "Header not allowed

    WHEN c_eight.

    MESSAGE e130. "Seperator not allowed

    WHEN c_nine.

    MESSAGE e131. "File size not allowed

    WHEN c_ten.

    MESSAGE e132. "Header too long

    WHEN c_eleven.

    MESSAGE e133. "Dp error create

    WHEN c_twelve.

    MESSAGE e134. "Dp error send

    WHEN c_thirteen.

    MESSAGE e135. "Dp error write

    WHEN c_fourteen.

    MESSAGE e136. "Unknown Dp error

    WHEN c_fifteen.

    MESSAGE e137. "Access denied

    WHEN c_sixteen.

    MESSAGE e138. "Dp out of memory

    WHEN c_seventeen.

    MESSAGE e139. "Disk full

    WHEN c_eighteen.

    MESSAGE e140. "Dp time out

    WHEN c_nineteen.

    MESSAGE e141. "File not found

    WHEN c_twenty.

    MESSAGE e142. "Data provider exception

    WHEN c_twentyone.

    MESSAGE e143. "Control flush error

    WHEN c_twentytwo.

    MESSAGE e144. "Unknown error

    ENDCASE.

    REFRESH fp_i_ftab.

    ENDIF.

    ELSE.

    MESSAGE s317 WITH text-050. "Data Downloaded into Temp Folder in C Drive

    ENDIF.

    ENDFORM. " data_download

    &----


    *& Form header_info

    &----


    • For Header Information For the Excel Sheet

    ----


    • USING PARAMETERS:

    • -->FP_I_FINALTAB Final Table

    • CHANGING PARAMETERS:

    • <--FP_I_HEADER For Header Of Excel

    • <--FP_I_FTAB For Final Table and Header

    ----


    FORM header_info USING fp_i_finaltab TYPE ty_t_finaltab

    CHANGING fp_i_header TYPE ty_t_finaltab

    fp_i_ftab TYPE ty_t_finaltab.

    DATA: l_wa_ftab TYPE ty_finaltab.

    DATA: l_c_asset TYPE char40,

    l_c_year TYPE char20.

    DATA: l_wa_user_defaults TYPE usdefaults.

    DATA:l_wa_ftab1 TYPE ty_head.

    l_wa_ftab-anln1 = text-004.

    l_wa_ftab-anln2 = text-005.

    l_wa_ftab-bukrs = text-006.

    l_wa_ftab-anlkl = text-007.

    l_wa_ftab-txt50 = text-008.

    l_wa_ftab-deakt = text-009.

    l_wa_ftab-ord41 = text-010.

    l_wa_ftab-aibn1 = text-011.

    l_wa_ftab-aibdt = text-012.

    l_wa_ftab-ktogr = text-013.

    l_wa_ftab-menge = text-014.

    l_wa_ftab-afasl = text-015.

    l_wa_ftab-afabe = text-016.

    l_wa_ftab-ndjar = text-017.

    l_wa_ftab-ndper = text-018.

    l_wa_ftab-afabg = text-019.

    l_wa_ftab-schrw = text-020.

    l_wa_ftab-nafag = text-021.

    l_wa_ftab-aafag = text-022.

    l_wa_ftab-knafa = text-023.

    l_wa_ftab-kaafa = text-024.

    l_wa_ftab-nafap = text-025.

    l_wa_ftab-afblpe = text-026.

    l_wa_ftab-nafav = text-027.

    l_wa_ftab-aafav = text-028.

    l_wa_ftab-nafal = text-029.

    l_wa_ftab-aafal = text-030.

    l_wa_ftab-kansw = text-031.

    l_wa_ftab-peraf = text-032.

    l_wa_ftab-gjahr = text-033.

    l_wa_ftab-nafaz = text-034.

    l_wa_ftab-aafaz = text-035.

    l_wa_ftab-kostl = text-036.

    l_wa_ftab-ktnafg = text-037.

    l_wa_ftab-ktaafg = text-038.

    l_wa_ftab-kansw01 = text-057.

    l_wa_ftab-anbtr1 = text-039.

    l_wa_ftab-anbtr2 = text-040.

    l_wa_ftab-na_anfav = text-041.

    l_wa_ftab-na_nafal = text-042.

    fp_i_ftab[] = fp_i_finaltab.

    APPEND l_wa_ftab TO fp_i_header.

    INSERT l_wa_ftab INTO fp_i_ftab INDEX 1.

    CONCATENATE text-055 ' ' p_peraf INTO l_c_asset.

    l_wa_ftab1-asset = l_c_asset.

    INSERT l_wa_ftab1 INTO fp_i_ftab INDEX 1.

    CLEAR: l_wa_ftab1,

    l_c_asset.

    l_wa_ftab1-asset+0(5) = text-054.

    l_wa_ftab1-asset+21(4) = p_gjahr.

    INSERT l_wa_ftab1 INTO fp_i_ftab INDEX 1.

    CLEAR: l_wa_ftab1,

    l_c_asset.

    l_wa_ftab1-asset+0(13) = text-053.

    l_wa_ftab1-asset+21(4) = s_anlkl.

    INSERT l_wa_ftab1 INTO fp_i_ftab INDEX 1.

    CLEAR: l_wa_ftab1,

    l_c_asset.

    l_wa_ftab1-asset+0(14) = text-052.

    l_wa_ftab1-asset+21(4) = s_bukrs-low.

    IF s_bukrs-high IS NOT INITIAL.

    l_wa_ftab1-asset+25(1) = '-'.

    l_wa_ftab1-asset+26(4) = s_bukrs-high.

    ENDIF.

    INSERT l_wa_ftab1 INTO fp_i_ftab INDEX 1.

    CLEAR: l_wa_ftab1,

    l_c_asset.

    WRITE sy-datum TO l_wa_ftab1-asset+21(10).

    l_wa_ftab1-asset+0(10) = text-051.

    INSERT l_wa_ftab1 INTO fp_i_ftab INDEX 1.

    CLEAR: l_wa_ftab1,

    l_c_asset.

    l_wa_ftab1-asset = text-049.

    INSERT l_wa_ftab1 INTO fp_i_ftab INDEX 1.

    CLEAR: l_wa_ftab1,

    l_c_asset.

    CLEAR l_wa_ftab.

    ENDFORM. " header_info

    &----


    *& Form send_mail

    &----


    • This perform used for send the data into the mail

    • specified in the Selection-Screen

    ----


    • USING PARAMETERS:

    • -->FP_I_FINALTAB " Final Internal Table

    ----


    FORM send_mail USING fp_i_finaltab TYPE ty_t_finaltab

    fp_i_reclist TYPE ty_reclist_tab.

    • Constants

    CONSTANTS: l_c_u TYPE so_escape VALUE 'U', " Escape sequence

    l_c_cret TYPE c VALUE cl_abap_char_utilities=>newline,

    "Carriage Return and Line Feed" Character Pair

    l_c_htab TYPE c VALUE

    cl_abap_char_utilities=>horizontal_tab,

    "Horizontal Tab Stop" Character

    l_c_raw TYPE so_obj_tp VALUE 'RAW', "Constant RAW

    l_c_int TYPE char3 VALUE 'INT', "Constant INT

    l_c_xls TYPE char3 VALUE 'XLS'. "File format

    • Internal table types for sopcklsti1 table

    TYPES : l_ty_sopcklsti1 TYPE STANDARD TABLE OF sopcklsti1,

    l_ty_somlreci1 TYPE STANDARD TABLE OF somlreci1.

    • Internal table and WA to hold the contents to be passed

    DATA : l_i_mail_data TYPE STANDARD TABLE OF solisti1,

    l_wa_mail_data TYPE solisti1.

    • Local work area declaration

    DATA: l_wa_message TYPE solisti1, " WA for Message body

    l_wa_objpack TYPE sopcklsti1, " WA for packing list

    l_wa_docdata TYPE sodocchgi1. " WA for Doc Data

    DATA : l_v_output(2000) TYPE c. "Output WA in string format5

    • Local Internal tables

    • Local data declarations

    DATA: l_i_reclist TYPE ty_reclist_tab,

    l_wa_reclist TYPE ty_reclist.

    DATA : l_i_objpack TYPE l_ty_sopcklsti1, " IT for contents table

    • l_i_reclist TYPE l_ty_somlreci1, " Recievers list

    l_i_message TYPE STANDARD TABLE OF solisti1. " Message Body

    FIELD-SYMBOLS : <l_wa_rep_header> TYPE ty_finaltab, " For Report Header data

    <l_wa_rep_detail> TYPE ty_finaltab. " For Report Details data

    DATA: l_r_mail TYPE ty_t_mail,

    l_wa_mail LIKE LINE OF l_r_mail.

    l_r_mail = s_email[].

    LOOP AT l_r_mail INTO l_wa_mail.

    • Prepare the list of recieving email IDs

    l_wa_reclist-receiver = l_wa_mail-low.

    l_wa_reclist-rec_type = c_rectyp .

    APPEND l_wa_reclist TO l_i_reclist.

    IF l_wa_mail-high IS NOT INITIAL.

    l_wa_reclist-receiver = l_wa_mail-high.

    l_wa_reclist-rec_type = c_rectyp .

    APPEND l_wa_reclist TO l_i_reclist.

    ENDIF.

    ENDLOOP.

    SORT l_i_reclist BY receiver.

    DELETE ADJACENT DUPLICATES FROM l_i_reclist.

    • Fill up the body of the message

    • SAP ASSET MASTER

    l_wa_message = text-049.

    APPEND l_wa_message TO l_i_message.

    CLEAR l_wa_message.

    • Rundate

    l_wa_message+0(8) = text-051.

    WRITE sy-datum TO l_wa_message+10(10).

    • l_wa_message+10(8) = sy-datum.

    APPEND l_wa_message TO l_i_message.

    CLEAR l_wa_message.

    • Company Code

    l_wa_message+0(13) = text-052.

    l_wa_message+15(4) = s_bukrs-low.

    IF s_bukrs-high IS NOT INITIAL.

    l_wa_message+20(1) = '-'.

    l_wa_message+21(4) = s_bukrs-high.

    ENDIF.

    APPEND l_wa_message TO l_i_message.

    CLEAR l_wa_message.

    *Asset Class

    l_wa_message+0(12) = text-053.

    l_wa_message+15(4) = s_anlkl.

    APPEND l_wa_message TO l_i_message.

    CLEAR l_wa_message.

    *Year

    l_wa_message+0(5) = text-054.

    l_wa_message+7(4) = p_gjahr.

    APPEND l_wa_message TO l_i_message.

    CLEAR l_wa_message.

    *Depriciation Period

    l_wa_message+0(20) = text-055.

    l_wa_message+22(3) = p_peraf.

    APPEND l_wa_message TO l_i_message.

    CLEAR l_wa_message.

    l_wa_docdata-obj_langu = sy-langu.

    l_wa_docdata-obj_descr = text-048. " Reports

    l_wa_docdata-doc_size = 2000.

    • create the entry for the compressed document.

    • Describe the body of the message

    REFRESH l_i_objpack.

    l_wa_objpack-transf_bin = c_x.

    • l_wa_objpack-transf_bin = space.

    • Start of header

    l_wa_objpack-head_start = c_1.

    • Start of the attchment

    l_wa_objpack-body_start = c_1.

    • Size of attachment

    l_wa_objpack-body_num = 2000.

    • Attachment Type

    l_wa_objpack-doc_type = l_c_raw.

    • Append the work area to internal table

    APPEND l_wa_objpack TO l_i_objpack.

    CLEAR l_wa_objpack.

    • Transfer the structural details

    CLEAR l_wa_objpack-transf_bin.

    • From where the header starts

    l_wa_objpack-head_start = 1.

    • Where the body starts

    l_wa_objpack-body_start = 1.

    • No. of lines in the body

    l_wa_objpack-body_num = 2000.

    • The document type

    l_wa_objpack-doc_type = l_c_xls.

    • Attachment Description

    l_wa_objpack-obj_descr = text-047.

    • l_wa_objpack-doc_size = 40 * 5000 * 255.

    APPEND l_wa_objpack TO l_i_objpack.

    CLEAR l_wa_objpack.

    • Prepare the data in the header and detailed table in the format

    • so that the report can be sent in excel format

    LOOP AT i_header ASSIGNING <l_wa_rep_header>.

    • Move the column info for the detailed data

    l_v_output+0(20) = text-004.

    l_v_output+20(1) = l_c_htab.

    l_v_output+21(20) = text-005.

    l_v_output+41(1) = l_c_htab.

    l_v_output+42(12) = text-006.

    l_v_output+54(1) = l_c_htab.

    l_v_output+55(12) = text-007.

    l_v_output+67(1) = l_c_htab.

    l_v_output+68(50) = text-008.

    l_v_output+118(1) = l_c_htab.

    l_v_output+119(20) = text-009.

    l_v_output+139(1) = l_c_htab.

    l_v_output+140(22) = text-010.

    l_v_output+162(1) = l_c_htab.

    l_v_output+163(35) = text-011.

    l_v_output+198(1) = l_c_htab.

    l_v_output+199(51) = text-012.

    l_v_output+250(1) = l_c_htab.

    l_wa_mail_data-line = l_v_output.

    CLEAR l_v_output.

    APPEND l_wa_mail_data TO l_i_mail_data.

    l_v_output+0(21) = text-013.

    l_v_output+21(1) = l_c_htab.

    l_v_output+22(12) = text-036.

    l_v_output+34(1) = l_c_htab.

    l_v_output+35(16) = text-015.

    l_v_output+51(1) = l_c_htab.

    l_v_output+52(22) = text-016.

    l_v_output+74(1) = l_c_htab.

    l_v_output+75(29) = text-017.

    l_v_output+104(1) = l_c_htab.

    l_v_output+105(30) = text-018.

    l_v_output+135(1) = l_c_htab.

    l_v_output+136(35) = text-019.

    l_v_output+171(1) = l_c_htab.

    l_v_output+172(58) = text-037.

    l_v_output+230(1) = l_c_htab.

    l_wa_mail_data-line = l_v_output.

    CLEAR l_v_output.

    APPEND l_wa_mail_data TO l_i_mail_data.

    l_v_output+0(58) = text-038.

    l_v_output+58(1) = l_c_htab.

    l_v_output+59(50) = text-057.

    l_v_output+109(1) = l_c_htab.

    l_v_output+110(50) = text-021.

    l_v_output+160(1) = l_c_htab.

    l_v_output+161(50) = text-022.

    l_v_output+211(1) = l_c_htab.

    l_wa_mail_data-line = l_v_output.

    CLEAR l_v_output.

    APPEND l_wa_mail_data TO l_i_mail_data.

    l_v_output+0(50) = text-023.

    l_v_output+50(1) = l_c_htab.

    l_v_output+51(50) = text-024.

    l_v_output+101(1) = l_c_htab.

    l_v_output+102(45) = text-025.

    l_v_output+147(1) = l_c_htab.

    l_v_output+148(45) = text-026.

    l_v_output+193(1) = l_c_htab.

    l_v_output+194(32) = text-032.

    l_v_output+226(1) = l_c_htab.

    l_v_output+227(12) = text-033.

    l_v_output+239(1) = l_c_htab.

    l_wa_mail_data-line = l_v_output.

    CLEAR l_v_output.

    APPEND l_wa_mail_data TO l_i_mail_data.

    l_v_output+0(35) = text-034.

    l_v_output+35(1) = l_c_htab.

    l_v_output+36(40) = text-035.

    l_v_output+76(1) = l_c_htab.

    l_v_output+77(9) = text-014.

    l_v_output+86(1) = l_c_htab.

    l_v_output+87(46) = text-027.

    l_v_output+133(1) = l_c_htab.

    l_v_output+134(46) = text-028.

    l_v_output+180(1) = l_c_htab.

    l_v_output+181(50) = text-029.

    l_v_output+231(1) = l_c_htab.

    l_wa_mail_data-line = l_v_output.

    CLEAR l_v_output.

    APPEND l_wa_mail_data TO l_i_mail_data.

    l_v_output+0(50) = text-030.

    l_v_output+50(1) = l_c_htab.

    l_v_output+51(50) = text-031.

    l_v_output+101(1) = l_c_htab.

    l_v_output+102(14) = text-039.

    l_v_output+116(1) = l_c_htab.

    l_v_output+117(14) = text-040.

    l_v_output+131(1) = l_c_htab.

    l_v_output+132(46) = text-041.

    l_v_output+178(1) = l_c_htab.

    l_v_output+179(50) = text-042.

    l_v_output+229(1) = l_c_htab.

    l_v_output+230(17) = text-020.

    l_wa_mail_data-line = l_v_output.

    l_wa_mail_data-line+254(1) = l_c_cret.

    APPEND l_wa_mail_data TO l_i_mail_data.

    • Get the records from the detailed data which are linked to the

    • customer number

    LOOP AT fp_i_finaltab ASSIGNING <l_wa_rep_detail>.

    l_v_output+0(20) = <l_wa_rep_detail>-anln1.

    l_v_output+20(1) = l_c_htab.

    l_v_output+21(20) = <l_wa_rep_detail>-anln2.

    l_v_output+41(1) = l_c_htab.

    l_v_output+42(12) = <l_wa_rep_detail>-bukrs.

    l_v_output+54(1) = l_c_htab.

    l_v_output+55(12) = <l_wa_rep_detail>-anlkl.

    l_v_output+67(1) = l_c_htab.

    l_v_output+68(50) = <l_wa_rep_detail>-txt50.

    l_v_output+118(1) = l_c_htab.

    l_v_output+119(20) = <l_wa_rep_detail>-deakt.

    l_v_output+139(1) = l_c_htab.

    l_v_output+140(22) = <l_wa_rep_detail>-ord41.

    l_v_output+162(1) = l_c_htab.

    l_v_output+163(35) = <l_wa_rep_detail>-aibn1.

    l_v_output+198(1) = l_c_htab.

    l_v_output+199(51) = <l_wa_rep_detail>-aibdt.

    l_v_output+250(1) = l_c_htab.

    l_wa_mail_data-line = l_v_output.

    CLEAR l_v_output.

    APPEND l_wa_mail_data TO l_i_mail_data.

    l_v_output+0(21) = <l_wa_rep_detail>-ktogr.

    l_v_output+21(1) = l_c_htab.

    l_v_output+22(12) = <l_wa_rep_detail>-kostl.

    l_v_output+34(1) = l_c_htab.

    l_v_output+35(16) = <l_wa_rep_detail>-afasl.

    l_v_output+51(1) = l_c_htab.

    l_v_output+52(22) = <l_wa_rep_detail>-afabe.

    l_v_output+74(1) = l_c_htab.

    l_v_output+75(29) = <l_wa_rep_detail>-ndjar.

    l_v_output+104(1) = l_c_htab.

    l_v_output+105(30) = <l_wa_rep_detail>-ndper.

    l_v_output+135(1) = l_c_htab.

    l_v_output+136(35) = <l_wa_rep_detail>-afabg.

    l_v_output+171(1) = l_c_htab.

    l_v_output+172(58) = <l_wa_rep_detail>-ktnafg.

    l_v_output+230(1) = l_c_htab.

    l_wa_mail_data-line = l_v_output.

    CLEAR l_v_output.

    APPEND l_wa_mail_data TO l_i_mail_data.

    l_v_output+0(58) = <l_wa_rep_detail>-ktaafg.

    l_v_output+58(1) = l_c_htab.

    l_v_output+59(50) = <l_wa_rep_detail>-kansw01.

    l_v_output+109(1) = l_c_htab.

    l_v_output+110(50) = <l_wa_rep_detail>-nafag.

    l_v_output+160(1) = l_c_htab.

    l_v_output+161(50) = <l_wa_rep_detail>-aafag.

    l_v_output+211(1) = l_c_htab.

    l_wa_mail_data-line = l_v_output.

    CLEAR l_v_output.

    APPEND l_wa_mail_data TO l_i_mail_data.

    l_v_output+0(50) = <l_wa_rep_detail>-knafa.

    l_v_output+50(1) = l_c_htab.

    l_v_output+51(50) = <l_wa_rep_detail>-kaafa.

    l_v_output+101(1) = l_c_htab.

    l_v_output+102(45) = <l_wa_rep_detail>-nafap.

    l_v_output+147(1) = l_c_htab.

    l_v_output+148(45) = <l_wa_rep_detail>-afblpe.

    l_v_output+193(1) = l_c_htab.

    l_v_output+194(32) = <l_wa_rep_detail>-peraf .

    l_v_output+226(1) = l_c_htab.

    l_v_output+227(12) = <l_wa_rep_detail>-gjahr.

    l_v_output+239(1) = l_c_htab.

    l_wa_mail_data-line = l_v_output.

    CLEAR l_v_output.

    APPEND l_wa_mail_data TO l_i_mail_data.

    l_v_output+0(35) = <l_wa_rep_detail>-nafaz.

    l_v_output+35(1) = l_c_htab.

    l_v_output+36(40) = <l_wa_rep_detail>-aafaz.

    l_v_output+76(1) = l_c_htab.

    l_v_output+77(9) = <l_wa_rep_detail>-menge .

    l_v_output+86(1) = l_c_htab.

    l_v_output+87(46) = <l_wa_rep_detail>-nafav.

    l_v_output+133(1) = l_c_htab.

    l_v_output+134(46) = <l_wa_rep_detail>-aafav.

    l_v_output+180(1) = l_c_htab.

    l_v_output+181(50) = <l_wa_rep_detail>-nafal.

    l_v_output+231(1) = l_c_htab.

    l_wa_mail_data-line = l_v_output.

    CLEAR l_v_output.

    APPEND l_wa_mail_data TO l_i_mail_data.

    l_v_output+0(50) = <l_wa_rep_detail>-aafal.

    l_v_output+50(1) = l_c_htab.

    l_v_output+51(50) = <l_wa_rep_detail>-kansw.

    l_v_output+101(1) = l_c_htab.

    l_v_output+102(14) = <l_wa_rep_detail>-anbtr1.

    l_v_output+116(1) = l_c_htab.

    l_v_output+117(14) = <l_wa_rep_detail>-anbtr2.

    l_v_output+131(1) = l_c_htab.

    l_v_output+132(46) = <l_wa_rep_detail>-na_anfav.

    l_v_output+178(1) = l_c_htab.

    l_v_output+179(50) = <l_wa_rep_detail>-na_nafal.

    l_v_output+229(1) = l_c_htab.

    l_v_output+230(17) = <l_wa_rep_detail>-schrw.

    l_wa_mail_data-line = l_v_output.

    l_wa_mail_data-line+254(1) = l_c_cret.

    APPEND l_wa_mail_data TO l_i_mail_data.

    ENDLOOP.

    ENDLOOP.

    • Call the FM to send the output list to the recipients

    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

    EXPORTING

    document_data = l_wa_docdata

    put_in_outbox = c_x

    commit_work = c_x

    TABLES

    packing_list = l_i_objpack

    contents_bin = l_i_message

    contents_txt = l_i_mail_data

    receivers = l_i_reclist

    EXCEPTIONS

    too_many_receivers = 1

    document_not_sent = 2

    document_type_not_exist = 3

    operation_no_authorization = 4

    parameter_error = 5

    x_error = 6

    enqueue_error = 7

    OTHERS = 8.

    IF sy-subrc NE c_zero.

    CASE sy-subrc.

    WHEN c_one.

    • Too many recipients, no authorization

    MESSAGE e964.

    WHEN c_two.

    • Document was not sent

    MESSAGE e965.

    WHEN c_three.

    • Document type or attachment type does not exist

    MESSAGE e966.

    WHEN c_four.

    • No authorization to send/create

    MESSAGE e967.

    WHEN c_five.

    • Invalid combination of parameter values

    MESSAGE e968.

    WHEN c_six.

    • Internal error or database inconsistency

    MESSAGE e969.

    WHEN c_seven.

    • Required locks could not be set

    MESSAGE e317 WITH text-106.

    ENDCASE.

    ELSE.

    WAIT UP TO 2 SECONDS.

    SUBMIT rsconn01 WITH mode = l_c_int

    AND RETURN.

    ENDIF.

    ENDFORM. " send_mail

    &----


    *& Form disable_selection_screen

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM disable_selection_screen .

    • Disable selection screen fields which are not required

    • LOOP AT SCREEN.

    • IF screen-group4 = 004.

    • " OR " Personnel number

    • screen-group4 = l_c_165 OR " Personnel Subarea

    • screen-group4 = l_c_171. " Payroll Area

    • Making selection screen fields disable

  • screen-required = c_01.

  • MODIFY SCREEN.

  • ENDIF.

  • *if p_peraf is initial.

    *message e317 with text-059.

    *else.

    • IF p_gjahr IS INITIAL.

    • MESSAGE e317 WITH text-060.

    • ELSE.

    • IF s_email[] IS INITIAL.

    • MESSAGE e317 WITH text-061.

    • ENDIF.

    • ENDIF.

    • ENDLOOP.

    ENDFORM. " disable_selection_screen

    &----


    *& Form depriciation_period

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM depriciation_period USING fp_p_peraf TYPE peraf.

    IF fp_p_peraf IS INITIAL.

    MESSAGE e317 WITH text-059.

    ENDIF.

    ENDFORM. " depriciation_period

    &----


    *& Form fiscal_year

    &----


    • text

    ----


    • -->P_P_GJAHR text

    ----


    FORM fiscal_year USING fp_p_gjahr TYPE gjahr.

    IF fp_p_gjahr IS INITIAL.

    MESSAGE e317 WITH text-060.

    ENDIF.

    ENDFORM. " fiscal_year

    &----


    *& Form mail

    &----


    • text

    ----


    • -->P_S_Email text

    ----


    FORM mail USING fp_s_email TYPE STANDARD TABLE.

    IF fp_s_email[] IS INITIAL.

    MESSAGE e317 WITH text-061.

    ENDIF.

    ENDFORM. " mail

Add a comment
10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 24, 2006 at 06:57 AM
    • COPIED FROM : N/A *

    • TITLE : N/A *

    • OTHER RELATED OBJ : N/A *

    ======================================================================

    • CHANGE HISTORY LOG *

    ----


    • MOD. NO.| DATE | NAME | CORRECTION NUMBER | CHANGE REFERENCE# *

    ----


    &----


    *& Include /AMS/FUSFCO_FADEPRICIATION_FORM *

    &----


    &----


    *& Form validation_company

    &----


    • Validate Company Code

    ----


    • USING PARAMETERS:

    • -->FP_S_BUKRS[] "Company Code

    ----


    FORM validation_company USING fp_s_bukrs TYPE STANDARD TABLE.

    • Local Data declarations

    DATA: l_v_bukrs TYPE bukrs.

    IF s_bukrs[] IS INITIAL.

    MESSAGE e317 WITH text-058.

    ELSE.

    • IF NOT fp_s_bukrs IS INITIAL.

    • Check company code

    SELECT bukrs "Company code

    INTO l_v_bukrs

    UP TO 1 ROWS

    FROM t001

    WHERE bukrs IN fp_s_bukrs.

    ENDSELECT.

    • If entered company code is not existing, raise error message

    IF sy-subrc NE 0.

    MESSAGE e003. " Selected Company Code does not exist in the system

    ENDIF.

    • ENDIF.

    ENDIF.

    ENDFORM. " validation_company

    &----


    *& Form initial_values

    &----


    • Initialize The Values For Company Code

    ----


    • CHANGING PARAMETERS:

    • <-- FP_S_BUKRS[] "Company Code

    ----


    FORM initial_values .

    • For company code

    MOVE: c_i TO s_bukrs-sign,

    c_eq TO s_bukrs-option,

    c_ca TO s_bukrs-low.

    APPEND s_bukrs.

    MOVE: c_i TO s_bukrs-sign,

    c_eq TO s_bukrs-option,

    c_us TO s_bukrs-low.

    APPEND s_bukrs.

    ENDFORM. " initial_values

    &----


    *& Form get_anla_data

    &----


    • Get Asset Master Record Segment(ANAL) Data as per the Selection-Screen

    ----


    • USING PARAMETERS:

    • -->FP_S_BUKRS[] "Company Code

    • -->FP_S_ANLKL[] "Asset class

    • CHANGING PARAMETERS:

    • <--FP_I_ANLA "Asset Master Record Segment

    ----


    FORM get_anla_data USING fp_s_bukrs TYPE STANDARD TABLE

    fp_s_anlkl TYPE STANDARD TABLE

    CHANGING fp_i_anla TYPE ty_t_anla

    fp_i_anla_temp TYPE ty_t_anla.

    **Selct the Asset Master Record Segment Data from table ANLA

    SELECT bukrs "Company Code

    anln1 "Main Asset Number

    anln2 "Asset Subnumber

    anlkl "Asset class

    ktogr "Account determination

    deakt "Deactivation date

    ord41 "CARAT Report Code

    aibn1 "Original asset that was transferred

    aibdt "Original acquisition date of AuC/ transferred asset

    menge "Quantity

    txt50 "Asset description

    FROM anla

    INTO TABLE fp_i_anla

    WHERE bukrs IN fp_s_bukrs AND

    anlkl IN fp_s_anlkl.

    IF sy-subrc <> c_zero.

    MESSAGE e392 . "WITH text-001. "No Data Availble in ANLA

    ELSE.

    SORT fp_i_anla BY bukrs anln1 anln2.

    MOVE fp_i_anla TO fp_i_anla_temp.

    DELETE ADJACENT DUPLICATES FROM fp_i_anla_temp COMPARING bukrs anln1 anln2.

    ENDIF.

    ENDFORM. " get_anla_data

    &----


    *& Form get_anlb_data

    &----


    • Get Depreciation terms(ANLB) Data as per the selection-screen

    ----


    • USING PARAMETERS:

    • -->FP_S_BUKRS[] "Company Code

    • CHANGING PARAMETERS:

    • <--FP_I_ANLB "Depreciation terms

    ----


    FORM get_anlb_data USING fp_i_anla_temp TYPE ty_t_anla

    CHANGING fp_i_anlb TYPE ty_t_anlb.

    *Select the Depreciation terms Data from ANLB table

    IF fp_i_anla_temp IS NOT INITIAL.

    SELECT bukrs

    anln1

    anln2

    afabe "Real depreciation area

    afabg "Depreciation calculation start date

    afasl "Depreciation key

    ndjar "Planned useful life in years

    ndper "Planned useful life in periods

    schrw "Asset scrap value

    xafbe

    FROM anlb INTO TABLE fp_i_anlb FOR ALL ENTRIES IN fp_i_anla_temp

    WHERE bukrs = fp_i_anla_temp-bukrs

    AND anln1 = fp_i_anla_temp-anln1

    AND anln2 = fp_i_anla_temp-anln2

    AND afabe EQ c_01

    AND xafbe NE c_space.

    IF sy-subrc EQ 0.

    • To consider the performance of the select.

    SORT fp_i_anlb BY bukrs anln1 anln2.

    ENDIF.

    ENDIF.

    ENDFORM. " get_anlb_data

    &----


    *& Form get_anlc_data

    &----


    • Get Asset Value Fields(ANLC) with the condition of ANLA Data

    ----


    • USING PARAMETERS:

    • -->FP_S_BUKRS[] "Company Code

    • -->FP_I_ANLA "Depreciation terms

    • CHANGING PARAMETERS:

    • <--FP_I_ANLC "Asset Value Fields

    ----


    FORM get_anlc_data USING fp_gjahr TYPE gjahr

    fp_i_anla_temp TYPE ty_t_anla

    CHANGING fp_i_anlc TYPE ty_t_anlc.

    IF fp_i_anla_temp IS NOT INITIAL.

    *Selcet Asset Value Fields data from table ANLC

    SELECT bukrs "Company Code

    anln1 "Main Asset Number

    anln2 "Asset Sub Number

    afabe "Real depreciation area

    zujhr "Asset acquisition year (currently not used)

    zucod "Sub-classification of asset acquisitions(currently not used)

    afblpe "Period in which last depreciation was posted

    kansw "Cumulative acquisition and production costs

    knafa "Accumulated ordinary depreciation

    kaafa "Cumulative unplanned depreciation

    nafap "Planned ordinary depreciation for the year

    nafag "Ordinary depreciation posted in the current year

    aafag "Unplanned depreciation posted for the year

    nafav "Proportional accumulated ordinary depreciation

    aafav "Proportional cumulative unplanned depreciation

    nafal "Proportional ordinary depreciation for the year

    aafal "Proportional unplanned depreciation for the year

    FROM anlc INTO TABLE fp_i_anlc

    FOR ALL ENTRIES IN fp_i_anla_temp

    WHERE bukrs = fp_i_anla_temp-bukrs AND

    anln1 = fp_i_anla_temp-anln1 AND

    anln2 = fp_i_anla_temp-anln2 AND

    gjahr = fp_gjahr AND

    afabe = c_01.

    • To consider the performance of the select.

    IF sy-subrc EQ c_zero.

    SORT fp_i_anlc BY bukrs anln1 anln2.

    ENDIF.

    ENDIF.

    ENDFORM. " get_anlc_data

    &----


    *& Form get_anlp_data

    &----


    • Get Asset Periodic Values(ANLP) with the condition of ANLC Data

    ----


    • USING PARAMETERS:

    • -->FP_S_BUKRS[] "Company Code

    • -->FP_P_GJAHR "Fiscal Year

    • -->FP_I_ANLA "Asset Master Record Segment

    • CHANGING PARAMETERS:

    • <--FP_I_ANLP "Asset Periodic Values

    ----


    FORM get_anlp_data USING fp_p_gjahr TYPE gjahr

    fp_p_peraf TYPE peraf

    fp_i_anlc TYPE ty_t_anlc

    CHANGING fp_i_anlp TYPE ty_t_anlp.

    *Local Variable

    DATA : l_i_anlc TYPE ty_t_anlc.

    IF fp_i_anlc IS NOT INITIAL.

    • To consider the performance of the select.

    MOVE fp_i_anlc TO l_i_anlc.

    SORT l_i_anlc BY bukrs anln1 anln2.

    DELETE ADJACENT DUPLICATES FROM l_i_anlc COMPARING bukrs anln1 anln2.

    *Select Asset Periodic Values from table ANLP

    SELECT bukrs "Company Code

    gjahr "Fiscal Year

    peraf "Depreciation calculation period

    anln1 "Main Asset Number

    anln2 "Asset Sub Number

    nafaz "Ordinary depreciation to be posted

    aafaz "Unplanned depreciation to be posted

    FROM anlp INTO TABLE fp_i_anlp

    FOR ALL ENTRIES IN fp_i_anlc

    WHERE bukrs = fp_i_anlc-bukrs AND

    gjahr = fp_p_gjahr AND

    peraf = fp_p_peraf AND

    anln1 = fp_i_anlc-anln1 AND

    anln2 = fp_i_anlc-anln2 AND

    afaber = c_01 AND

    zujhr = fp_i_anlc-zujhr AND

    zucod = fp_i_anlc-zucod.

    • To consider the performance of the select.

    IF sy-subrc EQ c_zero.

    SORT fp_i_anlp BY bukrs gjahr peraf anln1 anln2.

    ENDIF.

    REFRESH : l_i_anlc.

    ENDIF.

    ENDFORM. " get_anlp_data

    &----


    *& Form get_anlz_data

    &----


    • Get Time-Dependent Asset Allocations(ANLZ) with the condition of ANLA Data

    ----


    • USING PARAMETERS:

    • -->FP_I_ANLA "Asset Master Record Segment

    • CHANGING PARAMETERS:

    • <--FP_I_ANLZ "Time-Dependent Asset Allocations

    ----


    FORM get_anlz_data USING fp_i_anla_temp TYPE ty_t_anla

    fp_gjahr TYPE gjahr

    fp_peraf TYPE peraf

    CHANGING fp_i_anlz TYPE ty_t_anlz.

    *Local Data Declaration

    DATA : l_date TYPE dats.

    *Constants

    DATA : l_c_ng TYPE char2 VALUE 'NG'.

    *Function Module To Calculate Last calendar day in the fiscal period

    CALL FUNCTION 'LAST_DAY_IN_PERIOD_GET'

    EXPORTING

    i_gjahr = fp_gjahr

    i_periv = l_c_ng

    i_poper = fp_peraf

    IMPORTING

    e_date = l_date

    EXCEPTIONS

    input_false = 0

    t009_notfound = 0

    t009b_notfound = 0

    OTHERS = 0.

    IF fp_i_anla_temp IS NOT INITIAL.

    *Selcet Time-Dependent Asset Allocations data from ANLZ table

    SELECT bukrs "Company Code

    anln1 "Main Asset Number

    anln2 "Asset Subnumber

    kostl "Cost Center

    FROM anlz INTO TABLE fp_i_anlz

    FOR ALL ENTRIES IN fp_i_anla_temp

    WHERE bukrs = fp_i_anla_temp-bukrs AND

    anln1 = fp_i_anla_temp-anln1 AND

    anln2 = fp_i_anla_temp-anln2 AND

    bdatu GE l_date AND

    adatu LE l_date.

    IF sy-subrc EQ c_zero.

    SORT fp_i_anlz BY bukrs anln1 anln2.

    ENDIF.

    ENDIF.

    ENDFORM. " get_anlz_data

    &----


    *& Form get_t095b_data

    &----


    • get G/L accounts value adjustment(T095b) with the condition of ANLA Data

    ----


    • USING PARAMETERS:

    • -->FP_I_ANLA "Asset Master Record Segment

    • -->FP_I_ANLB "Depreciation terms

    • CHANGING PARAMETERS:

    • <--FP_I_T095B "G/L accounts value adjustment

    ----


    FORM get_t095b_data USING fp_i_anla_temp TYPE ty_t_anla

    CHANGING fp_i_t095b TYPE ty_t_t095b.

    *Local Constants

    DATA : l_c_n001 TYPE t095b-ktopl VALUE 'N001'.

    IF fp_i_anla_temp IS NOT INITIAL.

    *Select G/L accounts value adjustment from the table T095b

    SELECT ktogr "Account determination

    afabe "Real depreciation area

    ktnafg "Expense account for ordinary depreciation to book val. 0

    ktaafg "Expense account for unplanned depreciation

    FROM t095b INTO TABLE fp_i_t095b

    FOR ALL ENTRIES IN fp_i_anla_temp

    WHERE ktopl = l_c_n001 AND

    ktogr = fp_i_anla_temp-ktogr AND

    afabe = c_01.

    IF sy-subrc EQ c_zero.

    SORT fp_i_t095b BY ktogr afabe.

    ENDIF.

    ENDIF.

    ENDFORM. " get_t095b_data

    &----


    *& Form get_anep_data

    &----


    • get Asset Line Items(ANEP) with the condition of ANLA Data

    ----


    • USING PARAMETERS:

    • -->FP_I_ANLA "Asset Master Record Segment

    • CHANGING PARAMETERS:

    • <--FP_I_ANEP "Asset Line Items

    ----


    FORM get_anep_data USING fp_i_anla_temp TYPE ty_t_anla

    fp_gjahr TYPE gjahr

    CHANGING fp_i_anep TYPE ty_t_anep

    fp_i_anbtr TYPE ty_t_anbtr. "TUT

    • Begin of TUT

    FIELD-SYMBOLS: <l_fs_anep> TYPE ty_anep.

    DATA : l_wa_anbtr TYPE ty_anbtr,

    l_v_anbtr1 TYPE anbtr VALUE '0',

    l_v_anbtr2 TYPE anbtr VALUE '0'.

    CONSTANTS: l_c_zta TYPE bwasl VALUE 'ZTA',

    l_c_ztb TYPE bwasl VALUE 'ZTB',

    l_c_zr2 TYPE bwasl VALUE 'ZR2',

    l_c_zpc TYPE bwasl VALUE 'ZPC',

    l_c_ztr TYPE bwasl VALUE 'ZTR',

    l_c_zr1 TYPE bwasl VALUE 'ZR1'.

    • End of TUT

    IF fp_i_anla_temp IS NOT INITIAL.

    *Selcet Asset Line Items from the table ANEP

    SELECT bukrs "Company Code

    anln1 "Main Asset Number

    anln2 "Asset Subnumber

    gjahr "Fiscal Year

    lnran "Sequence number of asset line items in fiscal year

    afabe "Real depreciation area

    zujhr "Asset acquisition year (currently not used)

    zucod "Sub-classification of asset acquisitions(currently not used)

    bwasl "Asset transaction type

    anbtr "Amount posted

    FROM anep

    INTO TABLE fp_i_anep

    FOR ALL ENTRIES IN fp_i_anla_temp

    WHERE bukrs = fp_i_anla_temp-bukrs

    AND anln1 = fp_i_anla_temp-anln1

    AND anln2 = fp_i_anla_temp-anln2

    AND gjahr = fp_gjahr

    AND afabe = c_01.

    IF sy-subrc EQ c_zero.

    SORT fp_i_anep BY bukrs anln1 anln2 gjahr.

    *Begin of TUT

    LOOP AT fp_i_anep ASSIGNING <l_fs_anep>.

    IF <l_fs_anep>-bwasl(1) = c_1 OR <l_fs_anep>-bwasl(1) = c_3

    OR <l_fs_anep>-bwasl = l_c_zta OR <l_fs_anep>-bwasl = l_c_ztb

    OR <l_fs_anep>-bwasl = l_c_zr1 OR <l_fs_anep>-bwasl = l_c_zr2

    OR <l_fs_anep>-bwasl = l_c_ztr OR <l_fs_anep>-bwasl = l_c_zpc.

    l_v_anbtr1 = l_v_anbtr1 + <l_fs_anep>-anbtr.

    ENDIF.

    IF <l_fs_anep>-bwasl(1) NE c_6 OR <l_fs_anep>-bwasl(1) NE c_7.

    l_v_anbtr2 = l_v_anbtr2 + <l_fs_anep>-anbtr .

    ENDIF.

    AT END OF anln1.

    l_wa_anbtr-bukrs = <l_fs_anep>-bukrs.

    l_wa_anbtr-anln1 = <l_fs_anep>-anln1.

    l_wa_anbtr-anln2 = <l_fs_anep>-anln2.

    l_wa_anbtr-gjahr = <l_fs_anep>-gjahr.

    l_wa_anbtr-anbtr1 = l_v_anbtr1.

    l_wa_anbtr-anbtr2 = l_v_anbtr2.

    APPEND l_wa_anbtr TO fp_i_anbtr.

    CLEAR: l_v_anbtr1, l_v_anbtr2.

    ENDAT.

    ENDLOOP.

    SORT fp_i_anbtr BY bukrs anln1.

    • End of TUT

    ENDIF.

    ENDIF.

    ENDFORM. " get_anep_data

    &----


    *& Form get_anea_data

    &----


    • get Asset Line Items for Proportional Values(ANEA)

    • with the condition of ANEP Data

    ----


    • USING PARAMETERS:

    • -->FP_I_ANEP "Asset Line Items

    • CHANGING PARAMETERS:

    • <--FP_I_ANEA "Asset Line Items for Proportional Values

    ----


    FORM get_anea_data USING fp_i_anep TYPE ty_t_anep

    CHANGING fp_i_anea TYPE ty_t_anea.

    IF fp_i_anep IS NOT INITIAL.

    *Select Asset Line Items for Proportional Values from the table ANEA

    SELECT bukrs "Company Code

    anln1 "Main Asset Number

    anln2 "Asset Sub Number

    nafav "Proportional accumulated ordinary depreciation

    aafav "Proportional cumulative unplanned depreciation

    nafal "Proportional ordinary depreciation for the year

    aafal "Proportional unplanned depreciation for the year

    FROM anea

    INTO TABLE fp_i_anea

    FOR ALL ENTRIES IN fp_i_anep

    WHERE bukrs = fp_i_anep-bukrs AND

    anln1 = fp_i_anep-anln1 AND

    anln2 = fp_i_anep-anln2 AND

    gjahr = fp_i_anep-gjahr AND

    lnran = fp_i_anep-lnran AND

    afabe = fp_i_anep-afabe AND

    zujhr = fp_i_anep-zujhr AND

    zucod = fp_i_anep-zucod.

    IF sy-subrc EQ c_zero.

    SORT fp_i_anea BY bukrs anln1 anln2.

    ENDIF.

    ENDIF.

    ENDFORM. " get_anea_data

    &----


    *& Form get_data_final

    &----


    • Get the data for final table and it is trnasfer to Excel File

    ----


    • USING PARAMETERS:

    • -->FP_I_ANLA "Asset Master Record Segment

    • -->FP_I_ANLB "Depreciation terms

    • -->FP_I_ANLC "Asset Value Fields

    • -->FP_I_ANLP "Asset Periodic Values

    • -->FP_I_ANLZ "Depreciation terms

    • -->FP_I_ANEA "Asset Line Items for Proportional Values

    • -->FP_I_T095B "G/L accounts value adjustment

    • CHANGING PARAMETERS:

    • <--FP_I_FINALTAB "Final Table

    ----


    FORM get_data_final USING fp_i_anla TYPE ty_t_anla

    fp_i_anlb TYPE ty_t_anlb

    fp_i_anlc TYPE ty_t_anlc

    fp_i_anlp TYPE ty_t_anlp

    fp_i_anep TYPE ty_t_anep

    fp_i_anlz TYPE ty_t_anlz

    fp_i_anea TYPE ty_t_anea

    fp_i_t095b TYPE ty_t_t095b

    fp_i_anbtr TYPE ty_t_anbtr " TUT

    CHANGING fp_i_finaltab TYPE ty_t_finaltab.

    DATA: l_wa_anla TYPE ty_anla,

    l_wa_anlb TYPE ty_anlb,

    l_wa_anlc TYPE ty_anlc,

    l_wa_anlp TYPE ty_anlp,

    l_wa_anep TYPE ty_anep,

    l_wa_anlz TYPE ty_anlz,

    l_wa_anea TYPE ty_anea,

    l_wa_t095b TYPE ty_t095b,

    l_wa_anbtr TYPE ty_anbtr, " TUT

    l_wa_ftab TYPE ty_finaltab.

    • DATA: l_v_anbtr1 TYPE anbtr VALUE '0', " TUT

    • l_v_anbtr2 TYPE anbtr VALUE '0', " TUT

    DATA: l_v_na_anfav TYPE nafav,

    l_v_na_aafal TYPE aafal,

    l_v_kansw01 TYPE kansw_altd.

    *Local constants

    • CONSTANTS: l_c_zta TYPE bwasl VALUE 'ZTA', "TUT

    • l_c_ztb TYPE bwasl VALUE 'ZTB', "TUT

    • l_c_zr2 TYPE bwasl VALUE 'ZR2', "TUT

    • l_c_zpc TYPE bwasl VALUE 'ZPC', "TUT

    • l_c_ztr TYPE bwasl VALUE 'ZTR', "TUT

    • l_c_zr1 TYPE bwasl VALUE 'ZR1'. "TUT

    LOOP AT fp_i_anla INTO l_wa_anla.

    l_wa_ftab-bukrs = l_wa_anla-bukrs.

    l_wa_ftab-anln1 = l_wa_anla-anln1.

    l_wa_ftab-anln2 = l_wa_anla-anln2.

    l_wa_ftab-anlkl = l_wa_anla-anlkl.

    l_wa_ftab-txt50 = l_wa_anla-txt50.

    l_wa_ftab-deakt = l_wa_anla-deakt.

    l_wa_ftab-ord41 = l_wa_anla-ord41.

    l_wa_ftab-aibn1 = l_wa_anla-aibn1.

    l_wa_ftab-aibdt = l_wa_anla-aibdt.

    l_wa_ftab-ktogr = l_wa_anla-ktogr.

    l_wa_ftab-menge = l_wa_anla-menge.

    READ TABLE fp_i_anlb INTO l_wa_anlb WITH KEY bukrs = l_wa_anla-bukrs

    anln1 = l_wa_anla-anln1

    anln2 = l_wa_anla-anln2

    BINARY SEARCH.

    IF sy-subrc EQ 0.

    l_wa_ftab-afasl = l_wa_anlb-afasl.

    l_wa_ftab-afabe = l_wa_anlb-afabe.

    l_wa_ftab-ndjar = l_wa_anlb-ndjar.

    l_wa_ftab-ndper = l_wa_anlb-ndper.

    l_wa_ftab-afabg = l_wa_anlb-afabg.

    l_wa_ftab-schrw = l_wa_anlb-schrw.

    ENDIF.

    READ TABLE fp_i_anlc INTO l_wa_anlc WITH KEY bukrs = l_wa_anla-bukrs

    anln1 = l_wa_anla-anln1

    anln2 = l_wa_anla-anln2

    BINARY SEARCH.

    IF sy-subrc EQ 0.

    l_wa_ftab-nafag = l_wa_anlc-nafag.

    l_wa_ftab-aafag = l_wa_anlc-aafag.

    l_wa_ftab-knafa = l_wa_anlc-knafa.

    l_wa_ftab-kaafa = l_wa_anlc-kaafa.

    l_wa_ftab-nafap = l_wa_anlc-nafap.

    l_wa_ftab-afblpe = l_wa_anlc-afblpe.

    l_wa_ftab-nafav = l_wa_anlc-nafav.

    l_wa_ftab-aafav = l_wa_anlc-aafav.

    l_wa_ftab-nafal = l_wa_anlc-nafal.

    l_wa_ftab-aafal = l_wa_anlc-aafal.

    l_wa_ftab-kansw = l_wa_anlc-kansw.

    ENDIF.

    READ TABLE fp_i_anlp INTO l_wa_anlp WITH KEY bukrs = l_wa_anla-bukrs

    anln1 = l_wa_anla-anln1

    anln2 = l_wa_anla-anln2

    BINARY SEARCH.

    IF sy-subrc EQ 0.

    l_wa_ftab-peraf = l_wa_anlp-peraf.

    l_wa_ftab-gjahr = l_wa_anlp-gjahr.

    l_wa_ftab-nafaz = l_wa_anlp-nafaz.

    l_wa_ftab-aafaz = l_wa_anlp-aafaz.

    ENDIF.

    READ TABLE fp_i_anlz INTO l_wa_anlz WITH KEY bukrs = l_wa_anla-bukrs

    anln1 = l_wa_anla-anln1

    anln2 = l_wa_anla-anln2

    BINARY SEARCH.

    IF sy-subrc EQ 0.

    l_wa_ftab-kostl = l_wa_anlz-kostl.

    ENDIF.

    READ TABLE fp_i_t095b INTO l_wa_t095b WITH KEY ktogr = l_wa_anla-ktogr

    BINARY SEARCH.

    IF sy-subrc EQ 0.

    l_wa_ftab-ktnafg = l_wa_t095b-ktnafg.

    l_wa_ftab-ktaafg = l_wa_t095b-ktaafg.

    l_v_kansw01 = l_wa_t095b-ktnafg + l_wa_t095b-ktaafg.

    l_wa_ftab-kansw01 = l_v_kansw01.

    ENDIF.

    • Begin of TUT

    READ TABLE fp_i_anbtr INTO l_wa_anbtr WITH KEY bukrs = l_wa_anla-bukrs

    anln1 = l_wa_anla-anln1

    BINARY SEARCH.

    IF sy-subrc EQ 0.

    l_wa_ftab-anbtr1 = l_wa_anbtr-anbtr1.

    l_wa_ftab-anbtr2 = l_wa_anbtr-anbtr2.

    ENDIF.

    • READ TABLE fp_i_anep INTO l_wa_anep WITH KEY bukrs = l_wa_anla-bukrs

    • anln1 = l_wa_anla-anln1

    • anln2 = l_wa_anla-anln2

    • BINARY SEARCH.

    *

    • IF sy-subrc EQ 0.

    • IF l_wa_anep-bwasl(1) = c_1 OR l_wa_anep-bwasl(1) = c_3

    • OR l_wa_anep-bwasl = l_c_zta OR l_wa_anep-bwasl = l_c_ztb

    • OR l_wa_anep-bwasl = l_c_zr1 OR l_wa_anep-bwasl = l_c_zr2

    • OR l_wa_anep-bwasl = l_c_ztr OR l_wa_anep-bwasl = l_c_zpc.

    *

    • l_v_anbtr1 = l_v_anbtr1 + l_wa_anep-anbtr.

    • ELSE.

  • ENDIF.

    • IF l_wa_anep-bwasl(1) NE c_6 OR l_wa_anep-bwasl(1) NE c_7.

    • l_v_anbtr2 = l_v_anbtr2 + l_wa_anep-anbtr .

    *

    • ENDIF.

    • ENDIF.

    • l_wa_ftab-anbtr1 = l_v_anbtr1.

    • l_wa_ftab-anbtr2 = l_v_anbtr2.

    • ENDIF.

    • End of TUT

    READ TABLE fp_i_anea INTO l_wa_anea WITH KEY bukrs = l_wa_anla-bukrs

    anln1 = l_wa_anla-anln1

    anln2 = l_wa_anla-anln2

    BINARY SEARCH.

    IF sy-subrc EQ 0.

    l_v_na_anfav = l_v_na_anfav + l_wa_anea-nafav + l_wa_anea-aafav.

    l_v_na_aafal = l_v_na_aafal + l_wa_anea-nafal + l_wa_anea-aafal.

    l_wa_ftab-na_anfav = l_v_na_anfav .

    l_wa_ftab-na_nafal = l_v_na_aafal.

    ENDIF.

    APPEND l_wa_ftab TO fp_i_finaltab.

    CLEAR: l_wa_anla,

    l_wa_anlb,

    l_wa_anlc,

    l_wa_anlp,

    l_wa_anep,

    l_wa_anlz,

    l_wa_anea,

    l_wa_t095b,

    l_wa_anbtr, "TUT

    l_wa_ftab.

    ENDLOOP.

    ENDFORM. " get_data_final

    &----


    *& Form data_download

    &----


    • Data downloaded into the Temp Folder in the Excel Format

    ----


    • USING PARAMETERS:

    • -->FP_I_FINALTAB Final Table

    ----


    FORM data_download USING fp_i_ftab TYPE ty_t_finaltab

    fp_fname TYPE filep.

    DATA : l_v_file TYPE string.

    l_v_file = fp_fname.

    ***This path mentioned in FS only

    *Constants

    • DATA: l_c_path TYPE string VALUE 'c:\temp\temp.xls'.

    IF fp_i_ftab IS NOT INITIAL.

    *Function Module used to download to Presentation Server.

    CALL FUNCTION 'GUI_DOWNLOAD'

    EXPORTING

    filename = l_v_file

    filetype = 'ASC'

    write_field_separator = c_x

    TABLES

    data_tab = fp_i_ftab

    EXCEPTIONS

    file_write_error = 1

    no_batch = 2

    gui_refuse_filetransfer = 3

    invalid_type = 4

    no_authority = 5

    unknown_error = 6

    header_not_allowed = 7

    separator_not_allowed = 8

    filesize_not_allowed = 9

    header_too_long = 10

    dp_error_create = 11

    dp_error_send = 12

    dp_error_write = 13

    unknown_dp_error = 14

    access_denied = 15

    dp_out_of_memory = 16

    disk_full = 17

    dp_timeout = 18

    file_not_found = 19

    dataprovider_exception = 20

    control_flush_error = 21

    OTHERS = 22.

    IF sy-subrc <> c_zero.

    CASE sy-subrc.

    WHEN c_one.

    MESSAGE e123. "File Write error

    WHEN c_two.

    MESSAGE e124. "No batch

    WHEN c_three.

    MESSAGE e125. "GUI Refuses file transfer

    WHEN c_four.

    MESSAGE e126. "Invalid type

    WHEN c_five.

    MESSAGE e127. "No authority

    WHEN c_six.

    MESSAGE e128. "Unknown error

    WHEN c_seven.

    MESSAGE e129. "Header not allowed

    WHEN c_eight.

    MESSAGE e130. "Seperator not allowed

    WHEN c_nine.

    MESSAGE e131. "File size not allowed

    WHEN c_ten.

    MESSAGE e132. "Header too long

    WHEN c_eleven.

    MESSAGE e133. "Dp error create

    WHEN c_twelve.

    MESSAGE e134. "Dp error send

    WHEN c_thirteen.

    MESSAGE e135. "Dp error write

    WHEN c_fourteen.

    MESSAGE e136. "Unknown Dp error

    WHEN c_fifteen.

    MESSAGE e137. "Access denied

    WHEN c_sixteen.

    MESSAGE e138. "Dp out of memory

    WHEN c_seventeen.

    MESSAGE e139. "Disk full

    WHEN c_eighteen.

    MESSAGE e140. "Dp time out

    WHEN c_nineteen.

    MESSAGE e141. "File not found

    WHEN c_twenty.

    MESSAGE e142. "Data provider exception

    WHEN c_twentyone.

    MESSAGE e143. "Control flush error

    WHEN c_twentytwo.

    MESSAGE e144. "Unknown error

    ENDCASE.

    REFRESH fp_i_ftab.

    ENDIF.

    ELSE.

    MESSAGE s317 WITH text-050. "Data Downloaded into Temp Folder in C Drive

    ENDIF.

    ENDFORM. " data_download

    &----


    *& Form header_info

    &----


    • For Header Information For the Excel Sheet

    ----


    • USING PARAMETERS:

    • -->FP_I_FINALTAB Final Table

    • CHANGING PARAMETERS:

    • <--FP_I_HEADER For Header Of Excel

    • <--FP_I_FTAB For Final Table and Header

    ----


    FORM header_info USING fp_i_finaltab TYPE ty_t_finaltab

    CHANGING fp_i_header TYPE ty_t_finaltab

    fp_i_ftab TYPE ty_t_finaltab.

    DATA: l_wa_ftab TYPE ty_finaltab.

    DATA: l_c_asset TYPE char40,

    l_c_year TYPE char20.

    DATA: l_wa_user_defaults TYPE usdefaults.

    DATA:l_wa_ftab1 TYPE ty_head.

    l_wa_ftab-anln1 = text-004.

    l_wa_ftab-anln2 = text-005.

    l_wa_ftab-bukrs = text-006.

    l_wa_ftab-anlkl = text-007.

    l_wa_ftab-txt50 = text-008.

    l_wa_ftab-deakt = text-009.

    l_wa_ftab-ord41 = text-010.

    l_wa_ftab-aibn1 = text-011.

    l_wa_ftab-aibdt = text-012.

    l_wa_ftab-ktogr = text-013.

    l_wa_ftab-menge = text-014.

    l_wa_ftab-afasl = text-015.

    l_wa_ftab-afabe = text-016.

    l_wa_ftab-ndjar = text-017.

    l_wa_ftab-ndper = text-018.

    l_wa_ftab-afabg = text-019.

    l_wa_ftab-schrw = text-020.

    l_wa_ftab-nafag = text-021.

    l_wa_ftab-aafag = text-022.

    l_wa_ftab-knafa = text-023.

    l_wa_ftab-kaafa = text-024.

    l_wa_ftab-nafap = text-025.

    l_wa_ftab-afblpe = text-026.

    l_wa_ftab-nafav = text-027.

    l_wa_ftab-aafav = text-028.

    l_wa_ftab-nafal = text-029.

    l_wa_ftab-aafal = text-030.

    l_wa_ftab-kansw = text-031.

    l_wa_ftab-peraf = text-032.

    l_wa_ftab-gjahr = text-033.

    l_wa_ftab-nafaz = text-034.

    l_wa_ftab-aafaz = text-035.

    l_wa_ftab-kostl = text-036.

    l_wa_ftab-ktnafg = text-037.

    l_wa_ftab-ktaafg = text-038.

    l_wa_ftab-kansw01 = text-057.

    l_wa_ftab-anbtr1 = text-039.

    l_wa_ftab-anbtr2 = text-040.

    l_wa_ftab-na_anfav = text-041.

    l_wa_ftab-na_nafal = text-042.

    fp_i_ftab[] = fp_i_finaltab.

    APPEND l_wa_ftab TO fp_i_header.

    INSERT l_wa_ftab INTO fp_i_ftab INDEX 1.

    CONCATENATE text-055 ' ' p_peraf INTO l_c_asset.

    l_wa_ftab1-asset = l_c_asset.

    INSERT l_wa_ftab1 INTO fp_i_ftab INDEX 1.

    CLEAR: l_wa_ftab1,

    l_c_asset.

    l_wa_ftab1-asset+0(5) = text-054.

    l_wa_ftab1-asset+21(4) = p_gjahr.

    INSERT l_wa_ftab1 INTO fp_i_ftab INDEX 1.

    CLEAR: l_wa_ftab1,

    l_c_asset.

    l_wa_ftab1-asset+0(13) = text-053.

    l_wa_ftab1-asset+21(4) = s_anlkl.

    INSERT l_wa_ftab1 INTO fp_i_ftab INDEX 1.

    CLEAR: l_wa_ftab1,

    l_c_asset.

    l_wa_ftab1-asset+0(14) = text-052.

    l_wa_ftab1-asset+21(4) = s_bukrs-low.

    IF s_bukrs-high IS NOT INITIAL.

    l_wa_ftab1-asset+25(1) = '-'.

    l_wa_ftab1-asset+26(4) = s_bukrs-high.

    ENDIF.

    INSERT l_wa_ftab1 INTO fp_i_ftab INDEX 1.

    CLEAR: l_wa_ftab1,

    l_c_asset.

    WRITE sy-datum TO l_wa_ftab1-asset+21(10).

    l_wa_ftab1-asset+0(10) = text-051.

    INSERT l_wa_ftab1 INTO fp_i_ftab INDEX 1.

    CLEAR: l_wa_ftab1,

    l_c_asset.

    l_wa_ftab1-asset = text-049.

    INSERT l_wa_ftab1 INTO fp_i_ftab INDEX 1.

    CLEAR: l_wa_ftab1,

    l_c_asset.

    CLEAR l_wa_ftab.

    ENDFORM. " header_info

    &----


    *& Form send_mail

    &----


    • This perform used for send the data into the mail

    • specified in the Selection-Screen

    ----


    • USING PARAMETERS:

    • -->FP_I_FINALTAB " Final Internal Table

    ----


    FORM send_mail USING fp_i_finaltab TYPE ty_t_finaltab

    fp_i_reclist TYPE ty_reclist_tab.

    • Constants

    CONSTANTS: l_c_u TYPE so_escape VALUE 'U', " Escape sequence

    l_c_cret TYPE c VALUE cl_abap_char_utilities=>newline,

    "Carriage Return and Line Feed" Character Pair

    l_c_htab TYPE c VALUE

    cl_abap_char_utilities=>horizontal_tab,

    "Horizontal Tab Stop" Character

    l_c_raw TYPE so_obj_tp VALUE 'RAW', "Constant RAW

    l_c_int TYPE char3 VALUE 'INT', "Constant INT

    l_c_xls TYPE char3 VALUE 'XLS'. "File format

    • Internal table types for sopcklsti1 table

    TYPES : l_ty_sopcklsti1 TYPE STANDARD TABLE OF sopcklsti1,

    l_ty_somlreci1 TYPE STANDARD TABLE OF somlreci1.

    • Internal table and WA to hold the contents to be passed

    DATA : l_i_mail_data TYPE STANDARD TABLE OF solisti1,

    l_wa_mail_data TYPE solisti1.

    • Local work area declaration

    DATA: l_wa_message TYPE solisti1, " WA for Message body

    l_wa_objpack TYPE sopcklsti1, " WA for packing list

    l_wa_docdata TYPE sodocchgi1. " WA for Doc Data

    DATA : l_v_output(2000) TYPE c. "Output WA in string format5

    • Local Internal tables

    • Local data declarations

    DATA: l_i_reclist TYPE ty_reclist_tab,

    l_wa_reclist TYPE ty_reclist.

    DATA : l_i_objpack TYPE l_ty_sopcklsti1, " IT for contents table

    • l_i_reclist TYPE l_ty_somlreci1, " Recievers list

    l_i_message TYPE STANDARD TABLE OF solisti1. " Message Body

    FIELD-SYMBOLS : <l_wa_rep_header> TYPE ty_finaltab, " For Report Header data

    <l_wa_rep_detail> TYPE ty_finaltab. " For Report Details data

    DATA: l_r_mail TYPE ty_t_mail,

    l_wa_mail LIKE LINE OF l_r_mail.

    l_r_mail = s_email[].

    LOOP AT l_r_mail INTO l_wa_mail.

    • Prepare the list of recieving email IDs

    l_wa_reclist-receiver = l_wa_mail-low.

    l_wa_reclist-rec_type = c_rectyp .

    APPEND l_wa_reclist TO l_i_reclist.

    IF l_wa_mail-high IS NOT INITIAL.

    l_wa_reclist-receiver = l_wa_mail-high.

    l_wa_reclist-rec_type = c_rectyp .

    APPEND l_wa_reclist TO l_i_reclist.

    ENDIF.

    ENDLOOP.

    SORT l_i_reclist BY receiver.

    DELETE ADJACENT DUPLICATES FROM l_i_reclist.

    • Fill up the body of the message

    • SAP ASSET MASTER

    l_wa_message = text-049.

    APPEND l_wa_message TO l_i_message.

    CLEAR l_wa_message.

    • Rundate

    l_wa_message+0(8) = text-051.

    WRITE sy-datum TO l_wa_message+10(10).

    • l_wa_message+10(8) = sy-datum.

    APPEND l_wa_message TO l_i_message.

    CLEAR l_wa_message.

    • Company Code

    l_wa_message+0(13) = text-052.

    l_wa_message+15(4) = s_bukrs-low.

    IF s_bukrs-high IS NOT INITIAL.

    l_wa_message+20(1) = '-'.

    l_wa_message+21(4) = s_bukrs-high.

    ENDIF.

    APPEND l_wa_message TO l_i_message.

    CLEAR l_wa_message.

    *Asset Class

    l_wa_message+0(12) = text-053.

    l_wa_message+15(4) = s_anlkl.

    APPEND l_wa_message TO l_i_message.

    CLEAR l_wa_message.

    *Year

    l_wa_message+0(5) = text-054.

    l_wa_message+7(4) = p_gjahr.

    APPEND l_wa_message TO l_i_message.

    CLEAR l_wa_message.

    *Depriciation Period

    l_wa_message+0(20) = text-055.

    l_wa_message+22(3) = p_peraf.

    APPEND l_wa_message TO l_i_message.

    CLEAR l_wa_message.

    l_wa_docdata-obj_langu = sy-langu.

    l_wa_docdata-obj_descr = text-048. " Reports

    l_wa_docdata-doc_size = 2000.

    • create the entry for the compressed document.

    • Describe the body of the message

    REFRESH l_i_objpack.

    l_wa_objpack-transf_bin = c_x.

    • l_wa_objpack-transf_bin = space.

    • Start of header

    l_wa_objpack-head_start = c_1.

    • Start of the attchment

    l_wa_objpack-body_start = c_1.

    • Size of attachment

    l_wa_objpack-body_num = 2000.

    • Attachment Type

    l_wa_objpack-doc_type = l_c_raw.

    • Append the work area to internal table

    APPEND l_wa_objpack TO l_i_objpack.

    CLEAR l_wa_objpack.

    • Transfer the structural details

    CLEAR l_wa_objpack-transf_bin.

    • From where the header starts

    l_wa_objpack-head_start = 1.

    • Where the body starts

    l_wa_objpack-body_start = 1.

    • No. of lines in the body

    l_wa_objpack-body_num = 2000.

    • The document type

    l_wa_objpack-doc_type = l_c_xls.

    • Attachment Description

    l_wa_objpack-obj_descr = text-047.

    • l_wa_objpack-doc_size = 40 * 5000 * 255.

    APPEND l_wa_objpack TO l_i_objpack.

    CLEAR l_wa_objpack.

    • Prepare the data in the header and detailed table in the format

    • so that the report can be sent in excel format

    LOOP AT i_header ASSIGNING <l_wa_rep_header>.

    • Move the column info for the detailed data

    l_v_output+0(20) = text-004.

    l_v_output+20(1) = l_c_htab.

    l_v_output+21(20) = text-005.

    l_v_output+41(1) = l_c_htab.

    l_v_output+42(12) = text-006.

    l_v_output+54(1) = l_c_htab.

    l_v_output+55(12) = text-007.

    l_v_output+67(1) = l_c_htab.

    l_v_output+68(50) = text-008.

    l_v_output+118(1) = l_c_htab.

    l_v_output+119(20) = text-009.

    l_v_output+139(1) = l_c_htab.

    l_v_output+140(22) = text-010.

    l_v_output+162(1) = l_c_htab.

    l_v_output+163(35) = text-011.

    l_v_output+198(1) = l_c_htab.

    l_v_output+199(51) = text-012.

    l_v_output+250(1) = l_c_htab.

    l_wa_mail_data-line = l_v_output.

    CLEAR l_v_output.

    APPEND l_wa_mail_data TO l_i_mail_data.

    l_v_output+0(21) = text-013.

    l_v_output+21(1) = l_c_htab.

    l_v_output+22(12) = text-036.

    l_v_output+34(1) = l_c_htab.

    l_v_output+35(16) = text-015.

    l_v_output+51(1) = l_c_htab.

    l_v_output+52(22) = text-016.

    l_v_output+74(1) = l_c_htab.

    l_v_output+75(29) = text-017.

    l_v_output+104(1) = l_c_htab.

    l_v_output+105(30) = text-018.

    l_v_output+135(1) = l_c_htab.

    l_v_output+136(35) = text-019.

    l_v_output+171(1) = l_c_htab.

    l_v_output+172(58) = text-037.

    l_v_output+230(1) = l_c_htab.

    l_wa_mail_data-line = l_v_output.

    CLEAR l_v_output.

    APPEND l_wa_mail_data TO l_i_mail_data.

    l_v_output+0(58) = text-038.

    l_v_output+58(1) = l_c_htab.

    l_v_output+59(50) = text-057.

    l_v_output+109(1) = l_c_htab.

    l_v_output+110(50) = text-021.

    l_v_output+160(1) = l_c_htab.

    l_v_output+161(50) = text-022.

    l_v_output+211(1) = l_c_htab.

    l_wa_mail_data-line = l_v_output.

    CLEAR l_v_output.

    APPEND l_wa_mail_data TO l_i_mail_data.

    l_v_output+0(50) = text-023.

    l_v_output+50(1) = l_c_htab.

    l_v_output+51(50) = text-024.

    l_v_output+101(1) = l_c_htab.

    l_v_output+102(45) = text-025.

    l_v_output+147(1) = l_c_htab.

    l_v_output+148(45) = text-026.

    l_v_output+193(1) = l_c_htab.

    l_v_output+194(32) = text-032.

    l_v_output+226(1) = l_c_htab.

    l_v_output+227(12) = text-033.

    l_v_output+239(1) = l_c_htab.

    l_wa_mail_data-line = l_v_output.

    CLEAR l_v_output.

    APPEND l_wa_mail_data TO l_i_mail_data.

    l_v_output+0(35) = text-034.

    l_v_output+35(1) = l_c_htab.

    l_v_output+36(40) = text-035.

    l_v_output+76(1) = l_c_htab.

    l_v_output+77(9) = text-014.

    l_v_output+86(1) = l_c_htab.

    l_v_output+87(46) = text-027.

    l_v_output+133(1) = l_c_htab.

    l_v_output+134(46) = text-028.

    l_v_output+180(1) = l_c_htab.

    l_v_output+181(50) = text-029.

    l_v_output+231(1) = l_c_htab.

    l_wa_mail_data-line = l_v_output.

    CLEAR l_v_output.

    APPEND l_wa_mail_data TO l_i_mail_data.

    l_v_output+0(50) = text-030.

    l_v_output+50(1) = l_c_htab.

    l_v_output+51(50) = text-031.

    l_v_output+101(1) = l_c_htab.

    l_v_output+102(14) = text-039.

    l_v_output+116(1) = l_c_htab.

    l_v_output+117(14) = text-040.

    l_v_output+131(1) = l_c_htab.

    l_v_output+132(46) = text-041.

    l_v_output+178(1) = l_c_htab.

    l_v_output+179(50) = text-042.

    l_v_output+229(1) = l_c_htab.

    l_v_output+230(17) = text-020.

    l_wa_mail_data-line = l_v_output.

    l_wa_mail_data-line+254(1) = l_c_cret.

    APPEND l_wa_mail_data TO l_i_mail_data.

    • Get the records from the detailed data which are linked to the

    • customer number

    LOOP AT fp_i_finaltab ASSIGNING <l_wa_rep_detail>.

    l_v_output+0(20) = <l_wa_rep_detail>-anln1.

    l_v_output+20(1) = l_c_htab.

    l_v_output+21(20) = <l_wa_rep_detail>-anln2.

    l_v_output+41(1) = l_c_htab.

    l_v_output+42(12) = <l_wa_rep_detail>-bukrs.

    l_v_output+54(1) = l_c_htab.

    l_v_output+55(12) = <l_wa_rep_detail>-anlkl.

    l_v_output+67(1) = l_c_htab.

    l_v_output+68(50) = <l_wa_rep_detail>-txt50.

    l_v_output+118(1) = l_c_htab.

    l_v_output+119(20) = <l_wa_rep_detail>-deakt.

    l_v_output+139(1) = l_c_htab.

    l_v_output+140(22) = <l_wa_rep_detail>-ord41.

    l_v_output+162(1) = l_c_htab.

    l_v_output+163(35) = <l_wa_rep_detail>-aibn1.

    l_v_output+198(1) = l_c_htab.

    l_v_output+199(51) = <l_wa_rep_detail>-aibdt.

    l_v_output+250(1) = l_c_htab.

    l_wa_mail_data-line = l_v_output.

    CLEAR l_v_output.

    APPEND l_wa_mail_data TO l_i_mail_data.

    l_v_output+0(21) = <l_wa_rep_detail>-ktogr.

    l_v_output+21(1) = l_c_htab.

    l_v_output+22(12) = <l_wa_rep_detail>-kostl.

    l_v_output+34(1) = l_c_htab.

    l_v_output+35(16) = <l_wa_rep_detail>-afasl.

    l_v_output+51(1) = l_c_htab.

    l_v_output+52(22) = <l_wa_rep_detail>-afabe.

    l_v_output+74(1) = l_c_htab.

    l_v_output+75(29) = <l_wa_rep_detail>-ndjar.

    l_v_output+104(1) = l_c_htab.

    l_v_output+105(30) = <l_wa_rep_detail>-ndper.

    l_v_output+135(1) = l_c_htab.

    l_v_output+136(35) = <l_wa_rep_detail>-afabg.

    l_v_output+171(1) = l_c_htab.

    l_v_output+172(58) = <l_wa_rep_detail>-ktnafg.

    l_v_output+230(1) = l_c_htab.

    l_wa_mail_data-line = l_v_output.

    CLEAR l_v_output.

    APPEND l_wa_mail_data TO l_i_mail_data.

    l_v_output+0(58) = <l_wa_rep_detail>-ktaafg.

    l_v_output+58(1) = l_c_htab.

    l_v_output+59(50) = <l_wa_rep_detail>-kansw01.

    l_v_output+109(1) = l_c_htab.

    l_v_output+110(50) = <l_wa_rep_detail>-nafag.

    l_v_output+160(1) = l_c_htab.

    l_v_output+161(50) = <l_wa_rep_detail>-aafag.

    l_v_output+211(1) = l_c_htab.

    l_wa_mail_data-line = l_v_output.

    CLEAR l_v_output.

    APPEND l_wa_mail_data TO l_i_mail_data.

    l_v_output+0(50) = <l_wa_rep_detail>-knafa.

    l_v_output+50(1) = l_c_htab.

    l_v_output+51(50) = <l_wa_rep_detail>-kaafa.

    l_v_output+101(1) = l_c_htab.

    l_v_output+102(45) = <l_wa_rep_detail>-nafap.

    l_v_output+147(1) = l_c_htab.

    l_v_output+148(45) = <l_wa_rep_detail>-afblpe.

    l_v_output+193(1) = l_c_htab.

    l_v_output+194(32) = <l_wa_rep_detail>-peraf .

    l_v_output+226(1) = l_c_htab.

    l_v_output+227(12) = <l_wa_rep_detail>-gjahr.

    l_v_output+239(1) = l_c_htab.

    l_wa_mail_data-line = l_v_output.

    CLEAR l_v_output.

    APPEND l_wa_mail_data TO l_i_mail_data.

    l_v_output+0(35) = <l_wa_rep_detail>-nafaz.

    l_v_output+35(1) = l_c_htab.

    l_v_output+36(40) = <l_wa_rep_detail>-aafaz.

    l_v_output+76(1) = l_c_htab.

    l_v_output+77(9) = <l_wa_rep_detail>-menge .

    l_v_output+86(1) = l_c_htab.

    l_v_output+87(46) = <l_wa_rep_detail>-nafav.

    l_v_output+133(1) = l_c_htab.

    l_v_output+134(46) = <l_wa_rep_detail>-aafav.

    l_v_output+180(1) = l_c_htab.

    l_v_output+181(50) = <l_wa_rep_detail>-nafal.

    l_v_output+231(1) = l_c_htab.

    l_wa_mail_data-line = l_v_output.

    CLEAR l_v_output.

    APPEND l_wa_mail_data TO l_i_mail_data.

    l_v_output+0(50) = <l_wa_rep_detail>-aafal.

    l_v_output+50(1) = l_c_htab.

    l_v_output+51(50) = <l_wa_rep_detail>-kansw.

    l_v_output+101(1) = l_c_htab.

    l_v_output+102(14) = <l_wa_rep_detail>-anbtr1.

    l_v_output+116(1) = l_c_htab.

    l_v_output+117(14) = <l_wa_rep_detail>-anbtr2.

    l_v_output+131(1) = l_c_htab.

    l_v_output+132(46) = <l_wa_rep_detail>-na_anfav.

    l_v_output+178(1) = l_c_htab.

    l_v_output+179(50) = <l_wa_rep_detail>-na_nafal.

    l_v_output+229(1) = l_c_htab.

    l_v_output+230(17) = <l_wa_rep_detail>-schrw.

    l_wa_mail_data-line = l_v_output.

    l_wa_mail_data-line+254(1) = l_c_cret.

    APPEND l_wa_mail_data TO l_i_mail_data.

    ENDLOOP.

    ENDLOOP.

    • Call the FM to send the output list to the recipients

    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

    EXPORTING

    document_data = l_wa_docdata

    put_in_outbox = c_x

    commit_work = c_x

    TABLES

    packing_list = l_i_objpack

    contents_bin = l_i_message

    contents_txt = l_i_mail_data

    receivers = l_i_reclist

    EXCEPTIONS

    too_many_receivers = 1

    document_not_sent = 2

    document_type_not_exist = 3

    operation_no_authorization = 4

    parameter_error = 5

    x_error = 6

    enqueue_error = 7

    OTHERS = 8.

    IF sy-subrc NE c_zero.

    CASE sy-subrc.

    WHEN c_one.

    • Too many recipients, no authorization

    MESSAGE e964.

    WHEN c_two.

    • Document was not sent

    MESSAGE e965.

    WHEN c_three.

    • Document type or attachment type does not exist

    MESSAGE e966.

    WHEN c_four.

    • No authorization to send/create

    MESSAGE e967.

    WHEN c_five.

    • Invalid combination of parameter values

    MESSAGE e968.

    WHEN c_six.

    • Internal error or database inconsistency

    MESSAGE e969.

    WHEN c_seven.

    • Required locks could not be set

    MESSAGE e317 WITH text-106.

    ENDCASE.

    ELSE.

    WAIT UP TO 2 SECONDS.

    SUBMIT rsconn01 WITH mode = l_c_int

    AND RETURN.

    ENDIF.

    ENDFORM. " send_mail

    &----


    *& Form disable_selection_screen

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM disable_selection_screen .

    • Disable selection screen fields which are not required

    • LOOP AT SCREEN.

    • IF screen-group4 = 004.

    • " OR " Personnel number

    • screen-group4 = l_c_165 OR " Personnel Subarea

    • screen-group4 = l_c_171. " Payroll Area

    • Making selection screen fields disable

  • screen-required = c_01.

  • MODIFY SCREEN.

  • ENDIF.

  • *if p_peraf is initial.

    *message e317 with text-059.

    *else.

    • IF p_gjahr IS INITIAL.

    • MESSAGE e317 WITH text-060.

    • ELSE.

    • IF s_email[] IS INITIAL.

    • MESSAGE e317 WITH text-061.

    • ENDIF.

    • ENDIF.

    • ENDLOOP.

    ENDFORM. " disable_selection_screen

    &----


    *& Form depriciation_period

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM depriciation_period USING fp_p_peraf TYPE peraf.

    IF fp_p_peraf IS INITIAL.

    MESSAGE e317 WITH text-059.

    ENDIF.

    ENDFORM. " depriciation_period

    &----


    *& Form fiscal_year

    &----


    • text

    ----


    • -->P_P_GJAHR text

    ----


    FORM fiscal_year USING fp_p_gjahr TYPE gjahr.

    IF fp_p_gjahr IS INITIAL.

    MESSAGE e317 WITH text-060.

    ENDIF.

    ENDFORM. " fiscal_year

    &----


    *& Form mail

    &----


    • text

    ----


    • -->P_S_Email text

    ----


    FORM mail USING fp_s_email TYPE STANDARD TABLE.

    IF fp_s_email[] IS INITIAL.

    MESSAGE e317 WITH text-061.

    ENDIF.

    ENDFORM. " mail

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 24, 2006 at 06:59 AM

    ======================================================================

    • COPIED FROM : N/A *

    • TITLE : N/A *

    • OTHER RELATED OBJ : N/A *

    ======================================================================

    • CHANGE HISTORY LOG *

    ----


    • MOD. NO.| DATE | NAME | CORRECTION NUMBER | CHANGE REFERENCE# *

    ----


    &----


    *& Include /AMS/FUSFCO_FADEPRICIATION_TOP *

    &----


    *Constants

    CONSTANTS : c_01 TYPE char2 VALUE '01',

    c_zero TYPE char1 VALUE '0',

    c_x TYPE char1 VALUE 'X', " Constant X

    c_e TYPE char1 VALUE 'E',

    c_i TYPE char1 VALUE 'I',

    c_eq TYPE char2 VALUE 'EQ',

    c_ca TYPE bukrs VALUE 'CA19',

    c_us TYPE bukrs VALUE 'US43',

    c_1 TYPE char1 VALUE '1',

    c_3 TYPE char1 VALUE '3',

    c_6 TYPE char1 VALUE '6',

    c_7 TYPE char1 VALUE '7',

    c_one TYPE sysubrc VALUE '1', "Identifier for 1

    c_two TYPE sysubrc VALUE '2', "Identifier for 2

    c_three TYPE sysubrc VALUE '3', "Identifier for 3

    c_four TYPE sysubrc VALUE '4', "Identifier for 4

    c_five TYPE sysubrc VALUE '5', "Identifier for 5

    c_six TYPE sysubrc VALUE '6', "Identifier for 6

    c_seven TYPE sysubrc VALUE '7', "Identifier for 7

    c_eight TYPE sysubrc VALUE '8', "Identifier for 8

    c_nine TYPE sysubrc VALUE '9', "Identifier for 9

    c_ten TYPE sysubrc VALUE '10',"Identifier for 10

    c_eleven TYPE sysubrc VALUE '11',"Identifier for 11

    c_twelve TYPE sysubrc VALUE '12',"Identifier for 12

    c_thirteen TYPE sysubrc VALUE '13',"Identifier for 13

    c_fourteen TYPE sysubrc VALUE '14',"Identifier for 14

    c_fifteen TYPE sysubrc VALUE '15',"Identifier for 15

    c_sixteen TYPE sysubrc VALUE '16',"Identifier for 16

    c_seventeen TYPE sysubrc VALUE '17',"Identifier for 17

    c_eighteen TYPE sysubrc VALUE '18',"Identifier for 18

    c_nineteen TYPE sysubrc VALUE '19',"Identifier for 19

    c_twenty TYPE sysubrc VALUE '20',"Identifier for 20

    c_twentyone TYPE sysubrc VALUE '21',"Identifier for 21

    c_twentytwo TYPE sysubrc VALUE '22',"Identifier for 22

    c_space TYPE char1 VALUE ' ',

    c_rectyp TYPE so_escape VALUE 'U',

    c_fname TYPE filep VALUE 'c:\temp'.

    • Global variable Declaration for selection screen

    DATA : v_bukrs TYPE bukrs,

    v_anlkl TYPE anlkl,

    v_email TYPE comm_id_long.

    • Declaration of types

    • Structure Type for ANLA Table

    TYPES : BEGIN OF ty_anla,

    bukrs TYPE bukrs, "Company Code

    anln1 TYPE anln1, "Main Asset Number

    anln2 TYPE anln2, "Asset Subnumber

    anlkl TYPE anlkl, "Asset class

    ktogr TYPE ktogr, "Account determination

    deakt TYPE deakt, "Deactivation date

    ord41 TYPE ord41, "CARAT Report Code

    aibn1 TYPE aibn1, "Original asset that was transferred

    aibdt TYPE aibdt, "Original acquisition date of AuC/ transferred asset

    menge TYPE am_menge, "Quantity

    txt50 TYPE txa50_anlt, "Asset description

    END OF ty_anla.

    • Structure Type for ANLB Table

    TYPES : BEGIN OF ty_anlb,

    bukrs TYPE bukrs, "Company Code

    anln1 TYPE anln1, "Main Asset Number

    anln2 TYPE anln2, "Asset Subnumber

    afabe TYPE afabe_d, "Real depreciation area

    afabg TYPE afabg, "Depreciation calculation start date

    afasl TYPE afasl, "Depreciation key

    ndjar TYPE ndjar, "Planned useful life in years

    ndper TYPE ndper, "Planned useful life in periods

    schrw TYPE schrw, "Asset scrap value

    xafbe TYPE xafbe,

    END OF ty_anlb.

    • Structure Type for ANLC Table

    TYPES : BEGIN OF ty_anlc,

    bukrs TYPE bukrs, "Company Code

    anln1 TYPE anln1, "Main Asset Number

    anln2 TYPE anln2, "Asset Subnumber

    afabe TYPE afabe_d, "Real depreciation area

    zujhr TYPE dzujhr, "Asset acquisition year (currently not used)

    zucod TYPE dzucod, "Sub-classification of asset acquisitions(currently not used)

    afblpe TYPE afblpe, "Period in which last depreciation was posted

    kansw TYPE kansw, "Cumulative acquisition and production costs

    knafa TYPE knafa, "Accumulated ordinary depreciation

    kaafa TYPE kaafa, "Cumulative unplanned depreciation

    nafap TYPE nafap, "Planned ordinary depreciation for the year

    nafag TYPE nafag, "Ordinary depreciation posted in the current year

    aafag TYPE aafag, "Unplanned depreciation posted for the year

    nafav TYPE nafav, "Proportional accumulated ordinary depreciation

    aafav TYPE aafav, "Proportional cumulative unplanned depreciation

    nafal TYPE nafal, "Proportional ordinary depreciation for the year

    aafal TYPE aafal, "Proportional unplanned depreciation for the year

    END OF ty_anlc.

    • Structure Type for ANLP Table

    TYPES : BEGIN OF ty_anlp,

    bukrs TYPE bukrs, "Company Code

    gjahr TYPE gjahr, "Fiscal Year

    peraf TYPE peraf, "Depreciation calculation period

    anln1 TYPE anln1, "Main Asset Number

    anln2 TYPE anln2, "Asset Subnumber

    nafaz TYPE nafaz, "Ordinary depreciation to be posted

    aafaz TYPE aafaz, "Unplanned depreciation to be posted

    END OF ty_anlp.

    • Structure Type for ANLP Table

    TYPES : BEGIN OF ty_anlz,

    bukrs TYPE bukrs, "Company Code

    anln1 TYPE anln1, "Main Asset Number

    anln2 TYPE anln2, "Asset Subnumber

    kostl TYPE kostl, "Cost Center

    END OF ty_anlz.

    • Structure Type for T095B Table

    TYPES : BEGIN OF ty_t095b,

    ktogr TYPE ktogr,

    afabe TYPE afabe_d,

    ktnafg TYPE ktnafg,

    ktaafg TYPE ktaafg,

    END OF ty_t095b.

    • Structure Type for ANEP Table

    TYPES : BEGIN OF ty_anep,

    bukrs TYPE bukrs,

    anln1 TYPE anln1,

    anln2 TYPE anln2,

    gjahr TYPE gjahr,

    lnran TYPE lnran,

    afabe TYPE afabe_d,

    zujhr TYPE dzujhr,

    zucod TYPE dzucod,

    bwasl TYPE bwasl,

    anbtr TYPE anbtr,

    END OF ty_anep,

    • Structure Type for ANEA Table

    BEGIN OF ty_anea,

    bukrs TYPE bukrs,

    anln1 TYPE anln1,

    anln2 TYPE anln2,

    nafav TYPE nafav,

    aafav TYPE aafav,

    nafal TYPE aafav,

    aafal TYPE aafav,

    END OF ty_anea.

    • Structure Type for Header for the Excel File

    TYPES: BEGIN OF ty_head,

    asset TYPE char40,

    • rdate TYPE char8,

    • bukrs TYPE bukrs,

    • anlkl TYPE char8,

    • gjahr TYPE char4,

    • peraf TYPE char3,

    END OF ty_head.

    *Begin of TUT

    TYPES: BEGIN OF ty_anbtr,

    bukrs TYPE bukrs,

    anln1 TYPE anln1,

    anln2 TYPE anln2,

    gjahr TYPE gjahr,

    anbtr1 TYPE anbtr,

    anbtr2 TYPE anbtr,

    END OF ty_anbtr.

    • End of TUT

    • Structure Type for FInal table.

    TYPES: BEGIN OF ty_finaltab,

    anln1 TYPE char20, "Main Asset Number

    anln2 TYPE char20, "Asset Subnumber

    bukrs TYPE char12, "Company Code

    anlkl TYPE char12, "Asset class

    txt50 TYPE char50, "Asset description

    deakt TYPE char20, "Deactivation date

    ord41 TYPE char22, "CARAT Report Code

    aibn1 TYPE char35, "Original asset that was transferred

    aibdt TYPE char50, "Original acquisition date of AuC/ transferred asset

    ktogr TYPE char21, "Account determination

    kostl TYPE char12, "Cost Center

    afasl TYPE char16, "Depreciation key

    afabe TYPE char22, "Real depreciation area

    ndjar TYPE char29, "Planned useful life in years

    ndper TYPE char30, "Planned useful life in periods

    afabg TYPE char35, "Depreciation calculation start date

    ktnafg TYPE char58, "Expense account for ordinary depreciation to book val. 0

    ktaafg TYPE char58, "Expense account for unplanned depreciation

    kansw01 TYPE char50, "Cumulative APC

    nafag TYPE char50, "Ordinary depreciation posted in the current year

    aafag TYPE char50, "Unplanned depreciation posted for the year

    knafa TYPE char50, "Accumulated ordinary depreciation

    kaafa TYPE char50, "Cumulative unplanned depreciation

    nafap TYPE char45, "Planned ordinary depreciation for the year

    afblpe TYPE char45, "Period in which last depreciation was posted

    peraf TYPE char32, "Depreciation calculation period

    gjahr TYPE char12, "Fiscal Year

    nafaz TYPE char35, "Ordinary depreciation to be posted

    aafaz TYPE char40, "Unplanned depreciation to be posted

    menge TYPE char9, "Quantity

    nafav TYPE char46, "Proportional accumulated ordinary depreciation

    aafav TYPE char46, "Proportional cumulative unplanned depreciation

    nafal TYPE char50, "Proportional ordinary depreciation for the year

    aafal TYPE char50, "Proportional unplanned depreciation for the year

    kansw TYPE char50, "Cumulative acquisition and production costs

    anbtr1 TYPE char14, "Amount posted1

    anbtr2 TYPE char14, "Amount posted2

    na_anfav TYPE char46, "Proportional accumulated ordinary depreciation

    na_nafal TYPE char50, "Proportional ordinary depreciation for the year

    schrw TYPE char17, "Asset scrap value

    END OF ty_finaltab.

    • Table type for recipients list

    TYPES: BEGIN OF ty_reclist.

    INCLUDE STRUCTURE somlreci1.

    TYPES: END OF ty_reclist,

    ty_reclist_tab TYPE STANDARD TABLE OF ty_reclist INITIAL SIZE 0.

    DATA : i_reclist TYPE ty_reclist_tab. " List of recepients of mail

    ******Table Type For Purpose of mail

    TYPES : ty_t_mail TYPE RANGE OF comm_id_long."so_recname. "ty_mail.

    ******Table Types

    TYPES : ty_t_anla TYPE STANDARD TABLE OF ty_anla,

    ty_t_anlb TYPE STANDARD TABLE OF ty_anlb,

    ty_t_anlc TYPE STANDARD TABLE OF ty_anlc,

    ty_t_anlp TYPE STANDARD TABLE OF ty_anlp,

    ty_t_anlz TYPE STANDARD TABLE OF ty_anlz,

    ty_t_t095b TYPE STANDARD TABLE OF ty_t095b,

    ty_t_anep TYPE STANDARD TABLE OF ty_anep,

    ty_t_anea TYPE STANDARD TABLE OF ty_anea,

    ty_t_head TYPE STANDARD TABLE OF ty_head,

    ty_t_anbtr TYPE STANDARD TABLE OF ty_anbtr. " TUT

    ******Table Type For Final Table

    TYPES: ty_t_finaltab TYPE STANDARD TABLE OF ty_finaltab.

    ******Internal tables For Final Table

    DATA: i_finaltab TYPE STANDARD TABLE OF ty_finaltab,

    i_ftab TYPE STANDARD TABLE OF ty_finaltab,

    i_header TYPE STANDARD TABLE OF ty_finaltab.

    • Declaration of internal tables

    DATA : i_anla TYPE ty_t_anla,

    i_anla_temp TYPE ty_t_anla,

    i_anlb TYPE ty_t_anlb,

    i_anlc TYPE ty_t_anlc,

    i_anlp TYPE ty_t_anlp,

    i_anlz TYPE ty_t_anlz,

    i_t095b TYPE ty_t_t095b,

    i_anep TYPE ty_t_anep,

    i_anea TYPE ty_t_anea,

    i_anbtr TYPE ty_t_anbtr.

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

    • S E L E C T I O N - S C R E E N *

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

    SELECTION-SCREEN: BEGIN OF BLOCK block1 WITH FRAME." TITLE text-001.

    SELECT-OPTIONS: s_bukrs FOR v_bukrs. " OBLIGATORY .

    SELECTION-SCREEN: END OF BLOCK block1.

    SELECTION-SCREEN: BEGIN OF BLOCK block2 WITH FRAME TITLE text-002.

    SELECT-OPTIONS: s_anlkl FOR v_anlkl.

    SELECTION-SCREEN: END OF BLOCK block2.

    SELECTION-SCREEN: BEGIN OF BLOCK block3 WITH FRAME TITLE text-003.

    PARAMETERS : p_peraf TYPE anlp-peraf," OBLIGATORY,

    p_gjahr TYPE anlp-gjahr." OBLIGATORY.

    SELECTION-SCREEN: END OF BLOCK block3.

    SELECTION-SCREEN: BEGIN OF BLOCK block4 WITH FRAME TITLE text-043.

    PARAMETERS : p_cb_dld AS CHECKBOX DEFAULT c_x,

    p_fname TYPE filep DEFAULT c_fname.

    SELECTION-SCREEN: BEGIN OF BLOCK block5 WITH FRAME TITLE text-044.

    SELECT-OPTIONS : s_email FOR v_email NO INTERVALS. " OBLIGATORY NO INTERVALS.

    SELECTION-SCREEN: END OF BLOCK block5.

    SELECTION-SCREEN: END OF BLOCK block4.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 24, 2006 at 07:01 AM

    ======================================================================

    • COPIED FROM : N/A *

    • TITLE : N/A *

    • OTHER RELATED OBJ : N/A *

    ======================================================================

    • CHANGE HISTORY LOG *

    ----


    • MOD. NO.| DATE | NAME | CORRECTION NUMBER | CHANGE REFERENCE# *

    ----


    REPORT /ams/fusfco_fixed_assets NO STANDARD PAGE HEADING

    LINE-SIZE 150

    LINE-COUNT 20

    MESSAGE-ID /ams/ramfcmess .

    &----


    &

    & INCLUDES &

    &----


    &

    *Include for Data declarations

    INCLUDE /ams/fusfcn_fixed_assets_top.

    *Include Subroutine Forms

    INCLUDE /ams/fusfcn_fixed_assets_form.

    • Initialize the selection-screen values

    INITIALIZATION.

    PERFORM initial_values.

    &----


    *& AT SELECTION-SCREEN OUTPUT

    &----


    AT SELECTION-SCREEN .

    • Selection- screen parameters is Disabled------------------------------*

    PERFORM disable_selection_screen.

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

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

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

    AT SELECTION-SCREEN ON s_bukrs.

    • Validate Company Code

    PERFORM validation_company USING s_bukrs[].

    AT SELECTION-SCREEN ON p_peraf.

    • Validate Depriciation Period

    PERFORM depriciation_period USING p_peraf.

    AT SELECTION-SCREEN ON p_gjahr.

    • Validate Depriciation Period

    PERFORM fiscal_year USING p_gjahr.

    AT SELECTION-SCREEN ON s_email.

    • Validate mail

    PERFORM mail USING s_email[].

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

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

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

    START-OF-SELECTION.

    *GET ANLA DATA

    PERFORM get_anla_data USING s_bukrs[]

    s_anlkl[]

    CHANGING i_anla

    i_anla_temp.

    *Get anlb data

    PERFORM get_anlb_data USING i_anla_temp

    CHANGING i_anlb.

    *Get anlc data

    PERFORM get_anlc_data USING p_gjahr

    i_anla_temp

    CHANGING i_anlc.

    *Get anlp data

    PERFORM get_anlp_data USING p_gjahr

    p_peraf

    i_anlc

    CHANGING i_anlp.

    *Get anlz data

    PERFORM get_anlz_data USING i_anla_temp

    p_gjahr

    p_peraf

    CHANGING i_anlz.

    *Get t095b data

    PERFORM get_t095b_data USING i_anla_temp

    CHANGING i_t095b.

    *Get anep data

    PERFORM get_anep_data USING i_anla_temp

    p_gjahr

    CHANGING i_anep

    i_anbtr. " TUT

    *Get anea data

    PERFORM get_anea_data USING i_anep

    CHANGING i_anea.

    *Get Final Data

    PERFORM get_data_final USING i_anla

    i_anlb

    i_anlc

    i_anlp

    i_anep

    i_anlz

    i_anea

    i_t095b

    i_anbtr " TUT

    CHANGING i_finaltab.

    *For Header Information

    PERFORM header_info USING i_finaltab

    CHANGING i_header

    i_ftab.

    *If download is selected

    IF p_cb_dld = c_x.

    *For Downloading Purpose

    PERFORM data_download USING i_ftab

    p_fname.

    ENDIF.

    *Send the report to email address given on selection screen

    *Send the report output in excel format by mail

    PERFORM send_mail USING i_finaltab CHANGING i_reclist.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 24, 2006 at 08:57 AM

    Any specific issue with the code..can you define your exact problem ?

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 24, 2006 at 12:56 PM

    Hi ,

    using ws_excel Function module or in download function module using .xls extension in filetype.

    Thanks & Regards,

    Padmaja

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 25, 2006 at 08:35 AM

    HI,

    Go thru this below link and code .

    http://www.sapdevelopment.co.uk/fmodules/fmssap.htm

    REPORT ZRMM0056 NO STANDARD PAGE HEADING

    MESSAGE-ID ZZ

    LINE-SIZE 300

    LINE-COUNT 65.

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

    • Program : ZRMM0056

    • Title : Non Inventory PO's

    • Description : Non Inventory Purchase Orders details with

    • Vendor and Invoice Receipts and Goods Receipts.

    • Input :

    • Select-options : 1. G/L Account No

    *

    • Parameters : 1.File Paths for the Excel sheet

    *

    • Others (Specify):

    • Output : Extract Files in the application server

    • Report :

    *

    • Hear Ticket # : 113392

    • Created by : Srinivas Rao.M

    • Created on : 12/15/2005

    • Version : 1

    • Request : D10K944304

    • Transaction Code : Z420

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

    • Change History *

    • Date Programmer Search String Description *

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

    • 12/19/2005 Srinivas D10K944316 Removed Purchasing document

    • Company code and Plant from

    • Select-Options and Inculded

    • G/L Account No and changed

    • code accordingly.

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

    • T A B L E S *

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

    TABLES: EKBE, " History of Purchasing Document

    EKPO, " Purchasing Document Item

    EKKO, " Purchasing Document Header

    LFA1, " Vendor master (general section)

    EKKN. " Account Assignment in Purchasing Doc

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

    • INTERNAL TABLES

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

    *--Internal table to store Purchasing document header data

    DATA : BEGIN OF IT_POHEADER OCCURS 0,

    EBELN LIKE EKKO-EBELN, "Purchasing document

    AEDAT LIKE EKKO-AEDAT, "Created on

    ERNAM LIKE EKKO-ERNAM, "Created by

    LIFNR LIKE EKKO-LIFNR, "Vendor

    END OF IT_POHEADER.

    *--Internal table to store Purchasing document Item data

    DATA : BEGIN OF IT_POITEM OCCURS 0,

    EBELN LIKE EKPO-EBELN, "Purchasing document

    EBELP LIKE EKPO-EBELP, "Item Number

    MATNR LIKE EKPO-MATNR, "Material number

    BUKRS LIKE EKPO-BUKRS, "Company code

    WERKS LIKE EKPO-WERKS, "Plant

    MATKL LIKE EKPO-MATKL, "Material Group

    MENGE LIKE EKPO-MENGE, "Order Quantity

    NETPR LIKE EKPO-NETPR, "Net Price

    PEINH LIKE EKPO-PEINH, "Price unit

    NETWR LIKE EKPO-NETWR, "Net Value

    END OF IT_POITEM.

    *--Internal table to hold final display data.

    DATA : BEGIN OF IT_FINAL OCCURS 0,

    EBELN LIKE EKKO-EBELN, "Purchasing document

    EBELP LIKE EKPO-EBELP, "Item Number

    AEDAT LIKE EKKO-AEDAT, "Created on

    ERNAM LIKE EKKO-ERNAM, "Created by

    MATNR LIKE EKPO-MATNR, "Material number

    BUKRS LIKE EKPO-BUKRS, "Company code

    WERKS LIKE EKPO-WERKS, "Plant

    MATKL LIKE EKPO-MATKL, "Material Group

    MENGE LIKE EKPO-MENGE, "Order Quantity

    NETPR LIKE EKPO-NETPR, "Net Price

    PEINH LIKE EKPO-PEINH, "Price unit

    NETWR LIKE EKPO-NETWR, "Net Value

    LIFNR LIKE EKKO-LIFNR, "Vendor

    NAME1 LIKE LFA1-NAME1, "Vendor Name

    GSBER LIKE EKKN-GSBER, "Business area

    *--IR details

    IR_BELNR LIKE EKBE-BELNR, "IR-Number of Material Document

    IR_BUZEI LIKE EKBE-BUZEI, "IR-Item in material Document

    IR_BUDAT LIKE EKBE-BUDAT, "IR-Posting date

    IR_MENGE LIKE EKBE-MENGE, "IR-Quantity

    *--GR details

    GR_BELNR LIKE EKBE-BELNR, "GR-Number of Material Document

    GR_BUZEI LIKE EKBE-BUZEI, "GR-Item in material Document

    GR_BUDAT LIKE EKBE-BUDAT, "GR-Posting date

    GR_MENGE LIKE EKBE-MENGE, "GR-Quantity

    END OF IT_FINAL.

    *--Internal table to store History per Purchasing Document data

    DATA : BEGIN OF IT_HISTORY OCCURS 0,

    EBELN LIKE EKBE-EBELN, "Purchasing document

    EBELP LIKE EKBE-EBELP, "Item

    VGABE LIKE EKBE-VGABE, "Trans/Event type

    BELNR LIKE EKBE-BELNR, "Number of Material Document

    BUZEI LIKE EKBE-BUZEI, "Item in material Document

    BUDAT LIKE EKBE-BUDAT, "Posting date

    MENGE LIKE EKBE-MENGE, "Quantity

    BEWTP LIKE EKBE-BEWTP, "Posting history category

    END OF IT_HISTORY.

    *--Internal table to store vendor name.

    DATA : BEGIN OF IT_VENDOR OCCURS 0,

    LIFNR LIKE LFA1-LIFNR, "Vendor Number

    NAME1 LIKE LFA1-NAME1, "Vendor Name

    END OF IT_VENDOR.

    *--Internal table to store Business area for Purchasing document

    DATA : BEGIN OF IT_BUSINESS OCCURS 0,

    EBELN LIKE EKKN-EBELN, "Purchasing document

    EBELP LIKE EKKN-EBELP, "Purchasing Item

    SAKTO LIKE EKKN-SAKTO, "G/L Account No

    GSBER LIKE EKKN-GSBER, "Business area

    END OF IT_BUSINESS.

    DATA : BEGIN OF FIELDNAMES OCCURS 0,

    TEXT(40),

    END OF FIELDNAMES.

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

    • VARIABLES DECLARATION *

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

    DATA: V_FILE LIKE IBIPPARMS-PATH, "File path

    V_FLD LIKE DYNPREAD-FIELDNAME, "Dynpread fieldname

    V_FLAG(1) VALUE SPACE. "FLAG VARIABLE

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

    • SELECTION-SCREEN *

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

    SELECTION-SCREEN BEGIN OF BLOCK S1 WITH FRAME TITLE TEXT-001.

    *--Begin of change D10K944316

    SELECT-OPTIONS : S_SAKTO FOR EKKN-SAKTO. "G/L Accoun no.

    *--End of change D10K944316

    SELECTION-SCREEN END OF BLOCK S1.

    SELECTION-SCREEN BEGIN OF BLOCK S2 WITH FRAME TITLE TEXT-002.

    PARAMETERS : P_EXCEL AS CHECKBOX DEFAULT ' ' . " download to excel

    PARAMETERS : C_FILE(128) DEFAULT : 'C:\ZRMM0056.xls'.

    SELECTION-SCREEN END OF BLOCK S2.

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

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

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

    AT SELECTION-SCREEN ON VALUE-REQUEST FOR C_FILE.

    *-Form to get file path for download of data

    PERFORM GET_FILE_PATH.

    AT SELECTION-SCREEN.

    PERFORM SCREEN_VALIDATIONS.

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

    • START-OF-SELECTION

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

    START-OF-SELECTION.

    *--Extract Purchasing document header data.

    PERFORM GET_PO_HEADER_DATA.

    *--Extract Purchasing document Item data.

    IF NOT IT_BUSINESS[] IS INITIAL.

    PERFORM GET_PO_ITEM_DATA.

    *--Get complete required data in final internal table

    PERFORM GET_FINAL_DATA.

    ENDIF.

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

    • END-OF-SELECTION

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

    END-OF-SELECTION.

    IF V_FLAG IS INITIAL.

    *--Display Purchasing document details

    IF NOT IT_FINAL[] IS INITIAL.

    PERFORM DISPLAY_PODATA.

    IF P_EXCEL = 'X'.

    *--To down load data to excel sheet

    PERFORM DOWN_LOAD_TO_EXCEL.

    ENDIF.

    ENDIF.

    ELSE.

    MESSAGE I001(ZZ) WITH 'No data found'(003).

    ENDIF.

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

    • TOP-OF-PAGE

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

    TOP-OF-PAGE.

    *--To display page header

    PERFORM PAGE_HEADER.

    &----


    *& Form GET_PO_HEADER_DATA

    &----


    • To Get Purchasing header data

    ----


    FORM GET_PO_HEADER_DATA .

    *--To extract Business Area details

    CLEAR IT_BUSINESS.

    REFRESH IT_BUSINESS.

    SELECT EBELN "Purchasing document

    EBELP "Purchasing document item

    SAKTO "G/L Account no

    GSBER "Business area

    FROM EKKN

    INTO TABLE IT_BUSINESS

    WHERE SAKTO IN S_SAKTO.

    IF SY-SUBRC <> 0.

    V_FLAG = 'X'.

    MESSAGE I001(ZZ) WITH

    'No data selected for the given selection criteria'(004).

    STOP.

    ELSE.

    *--To extract Purchasing document details with respect

    • to G/L Account no

    CLEAR IT_POHEADER.

    REFRESH IT_POHEADER.

    SELECT EBELN "Purchasing document

    AEDAT "Created on

    ERNAM "Created by

    LIFNR "Vendor

    FROM EKKO

    INTO TABLE IT_POHEADER

    FOR ALL ENTRIES IN IT_BUSINESS

    WHERE EBELN = IT_BUSINESS-EBELN.

    IF NOT IT_POHEADER[] IS INITIAL.

    CLEAR IT_VENDOR.

    REFRESH IT_VENDOR.

    *--Extracting Vendor details

    SELECT LIFNR "Vendor #

    NAME1 "Name

    FROM LFA1

    INTO TABLE IT_VENDOR

    FOR ALL ENTRIES IN IT_POHEADER

    WHERE LIFNR = IT_POHEADER-LIFNR.

    ENDIF.

    ENDIF.

    ENDFORM. " GET_PO_HEADER_DATA

    &----


    *& Form GET_PO_ITEM_DATA

    &----


    • To extract Purchasing document item data

    ----


    FORM GET_PO_ITEM_DATA .

    CLEAR IT_POITEM.

    REFRESH IT_POITEM.

    SELECT EBELN "Purchasing document

    EBELP "Item Number

    MATNR "Material number

    BUKRS "Company code

    WERKS "Plant

    MATKL "Material Group

    MENGE "Order Quantity

    NETPR "Net Price

    PEINH "Price unit

    NETWR "Net Value

    FROM EKPO

    INTO TABLE IT_POITEM

    FOR ALL ENTRIES IN IT_BUSINESS

    WHERE EBELN = IT_BUSINESS-EBELN

    AND EBELP = IT_BUSINESS-EBELP.

    IF NOT IT_POITEM[] IS INITIAL.

    CLEAR IT_HISTORY.

    REFRESH IT_HISTORY.

    SELECT EBELN "Purchasing document

    EBELP "Item

    VGABE "Trans/Event type

    BELNR "Number of Material Document

    BUZEI "Item in material Document

    BUDAT "Posting date

    MENGE "Quantity

    BEWTP "Posting history category

    FROM EKBE

    INTO TABLE IT_HISTORY

    FOR ALL ENTRIES IN IT_POITEM

    WHERE EBELN = IT_POITEM-EBELN

    AND EBELP = IT_POITEM-EBELP

    AND ( VGABE = '1' OR VGABE = '2' ) "1 = GR , 2 = IR

    AND ( BEWTP = 'Q' OR BEWTP = 'E' ). "Q = GR , R = IR

    IF SY-SUBRC = 0.

    SORT IT_HISTORY BY EBELN EBELP.

    ENDIF.

    ENDIF.

    ENDFORM. " GET_PO_ITEM_DATA

    &----


    *& Form GET_FILE_PATH

    &----


    • Select file path

    ----


    FORM GET_FILE_PATH .

    CLEAR V_FILE.

    MOVE 'p_flname' TO V_FLD.

    MOVE C_FILE TO V_FILE.

    CALL FUNCTION 'F4_FILENAME'

    EXPORTING

    PROGRAM_NAME = SYST-CPROG

    DYNPRO_NUMBER = SYST-DYNNR

    FIELD_NAME = V_FLD

    IMPORTING

    FILE_NAME = V_FILE

    EXCEPTIONS

    OTHERS = 1.

    MOVE V_FILE TO C_FILE.

    ENDFORM. " GET_FILE_PATH

    &----


    *& Form PAGE_HEADER

    &----


    • To Print page header and other details

    ----


    FORM PAGE_HEADER .

    *--Page Header

    ULINE AT /1(300).

    FORMAT COLOR 1.

    WRITE:/ 'Run Date:'(005), SY-DATUM, 45 'Stanley Works'(006),

    100 'Page No:'(007), SY-PAGNO LEFT-JUSTIFIED, 298 ''.

    WRITE:/ 'Run Time:'(008), SY-UZEIT, 43 SY-TITLE, 100 SY-UNAME, 298 ''.

    WRITE:/ 'Source :'(009), SY-SYSID, 100 SY-CPROG, 298 ''.

    FORMAT COLOR OFF.

    ULINE AT /1(300).

    FORMAT COLOR 4.

    WRITE : / SY-VLINE , (10) 'Purchasing Doc'(010),

    SY-VLINE, (5) 'Item'(011),

    SY-VLINE, (10) 'Created On'(012),

    SY-VLINE, (7) 'Crea By'(013),

    SY-VLINE, (10) 'Material'(014),

    SY-VLINE, (6) 'Com cd'(015),

    SY-VLINE, (5) 'Plant'(016),

    SY-VLINE, (10) 'Mat Group'(017),

    SY-VLINE, (13) 'Order Qty'(018),

    SY-VLINE, (11) 'Net Price'(019),

    SY-VLINE, (10) 'Price Unit'(020),

    SY-VLINE, (13) 'Net Value'(021),

    SY-VLINE, (8) 'Bus Area'(022),

    SY-VLINE, (10) 'Vendor'(023),

    SY-VLINE, (28) 'Vendor Name'(024),

    *--IR details

    SY-VLINE, (10) 'IR-Mat Doc'(025),

    SY-VLINE, (5) 'IR-It'(026),

    SY-VLINE, (9) 'IR-Post dt'(027),

    SY-VLINE, (13) 'IR-Quantity'(028),

    *--GR details

    SY-VLINE, (10) 'GR-Mat Doc'(029),

    SY-VLINE, (5) 'GR-It'(030),

    SY-VLINE, (9) 'GR-Post dt'(031),

    SY-VLINE, (13) 'GR-Quantity'(032), SY-VLINE.

    FORMAT COLOR OFF.

    ULINE AT /1(300).

    ENDFORM. " PAGE_HEADER

    &----


    *& Form SCREEN_VALIDATIONS

    &----


    • Selection screen validations

    ----


    FORM SCREEN_VALIDATIONS .

    *--Validation for G/L Account No

    IF NOT S_SAKTO IS INITIAL.

    SELECT SAKNR UP TO 1 ROWS

    INTO EKKN-SAKTO

    FROM SKA1 WHERE

    SAKNR IN S_SAKTO.

    ENDSELECT.

    IF SY-SUBRC <> 0.

    MESSAGE E001(ZZ) with 'Please enter a valid G/L Account no'(048).

    ENDIF.

    ENDIF.

    *--Validation for Excel file path

    IF P_EXCEL = 'X'.

    IF C_FILE = ' '.

    MESSAGE E001(ZZ) with 'Please enter a valid Excle Path'(035).

    ENDIF.

    ENDIF.

    ENDFORM. " SCREEN_VALIDATIONS

    &----


    *& Form DISPLAY_PODATA

    &----


    • To Display Purchasing Document details

    ----


    FORM DISPLAY_PODATA .

    FORMAT COLOR 2.

    SORT IT_FINAL BY EBELN EBELP AEDAT BUKRS WERKS.

    LOOP AT IT_FINAL.

    WRITE : / SY-VLINE ,(10) IT_FINAL-EBELN, "Purchasing Doc

    SY-VLINE, (5) IT_FINAL-EBELP, "Item

    SY-VLINE, (10) IT_FINAL-AEDAT, "Created On

    SY-VLINE, (7) IT_FINAL-ERNAM, "Created By

    SY-VLINE, (10) IT_FINAL-MATNR, "Material

    SY-VLINE, (6) IT_FINAL-BUKRS, "Company code

    SY-VLINE, (5) IT_FINAL-WERKS, "Plant

    SY-VLINE, (10) IT_FINAL-MATKL, "Material Group

    SY-VLINE, (13) IT_FINAL-MENGE, "#EC UOM_IN_MES

    "Order Qty

    SY-VLINE, (11) IT_FINAL-NETPR, "#EC UOM_IN_MES

    "Net Price

    SY-VLINE, (10) IT_FINAL-PEINH, "#EC UOM_IN_MES

    "Price Unit

    SY-VLINE, (13) IT_FINAL-NETWR, "#EC UOM_IN_MES

    "Net Value

    SY-VLINE, (8) IT_FINAL-GSBER, "Bus Area

    SY-VLINE, (10) IT_FINAL-LIFNR, "Vendor

    SY-VLINE, (28) IT_FINAL-NAME1, "Vendor name

    *--IR details

    SY-VLINE, (10) IT_FINAL-IR_BELNR, "IR-Mat Doc

    SY-VLINE, (5) IT_FINAL-IR_BUZEI, "IR-It

    SY-VLINE, (9) IT_FINAL-IR_BUDAT, "IR-Post dt

    SY-VLINE, (13) IT_FINAL-IR_MENGE, "#EC UOM_IN_MES

    "IR-Quantity

    *--GR details

    SY-VLINE, (10) IT_FINAL-GR_BELNR, "GR-Mat Doc

    SY-VLINE, (5) IT_FINAL-GR_BUZEI, "GR-It

    SY-VLINE, (9) IT_FINAL-GR_BUDAT, "GR-Post dt

    SY-VLINE, (13) IT_FINAL-GR_MENGE, SY-VLINE.

    "#EC UOM_IN_MES

    "GR-Quantity

    ENDLOOP.

    FORMAT COLOR OFF.

    ENDFORM. " DISPLAY_PODATA

    &----


    *& Form DOWN_LOAD_TO_EXCEL

    &----


    • text

    ----


    FORM DOWN_LOAD_TO_EXCEL .

    REFRESH FIELDNAMES.

    FIELDNAMES-TEXT = TEXT-010.

    APPEND FIELDNAMES.CLEAR FIELDNAMES.

    FIELDNAMES-TEXT = TEXT-011.

    APPEND FIELDNAMES.CLEAR FIELDNAMES.

    FIELDNAMES-TEXT = TEXT-012.

    APPEND FIELDNAMES.CLEAR FIELDNAMES.

    FIELDNAMES-TEXT = 'Created By'(036).

    APPEND FIELDNAMES.CLEAR FIELDNAMES.

    FIELDNAMES-TEXT = TEXT-014.

    APPEND FIELDNAMES.CLEAR FIELDNAMES.

    FIELDNAMES-TEXT = 'Company Code'(037).

    APPEND FIELDNAMES.CLEAR FIELDNAMES.

    FIELDNAMES-TEXT = TEXT-016.

    APPEND FIELDNAMES.CLEAR FIELDNAMES.

    FIELDNAMES-TEXT = 'Material Group'(038).

    APPEND FIELDNAMES.CLEAR FIELDNAMES.

    FIELDNAMES-TEXT = 'Order Quantity'(039).

    APPEND FIELDNAMES.CLEAR FIELDNAMES.

    FIELDNAMES-TEXT = TEXT-019.

    APPEND FIELDNAMES.CLEAR FIELDNAMES.

    FIELDNAMES-TEXT = TEXT-020.

    APPEND FIELDNAMES.CLEAR FIELDNAMES.

    FIELDNAMES-TEXT = TEXT-021.

    APPEND FIELDNAMES.CLEAR FIELDNAMES.

    FIELDNAMES-TEXT = 'Business Area'(040).

    APPEND FIELDNAMES.CLEAR FIELDNAMES.

    FIELDNAMES-TEXT = TEXT-023.

    APPEND FIELDNAMES.CLEAR FIELDNAMES.

    FIELDNAMES-TEXT = TEXT-024.

    APPEND FIELDNAMES.CLEAR FIELDNAMES.

    FIELDNAMES-TEXT = 'IR Material Doc'(041).

    APPEND FIELDNAMES.CLEAR FIELDNAMES.

    FIELDNAMES-TEXT = 'IR Item'(042).

    APPEND FIELDNAMES.CLEAR FIELDNAMES.

    FIELDNAMES-TEXT = 'IR Posting Date'(043).

    APPEND FIELDNAMES.CLEAR FIELDNAMES.

    FIELDNAMES-TEXT = TEXT-028.

    APPEND FIELDNAMES.CLEAR FIELDNAMES.

    FIELDNAMES-TEXT = 'GR Material Doc'(044).

    APPEND FIELDNAMES.CLEAR FIELDNAMES.

    FIELDNAMES-TEXT = 'GR Item'(045).

    APPEND FIELDNAMES.CLEAR FIELDNAMES.

    FIELDNAMES-TEXT = 'GR Posting Date'(046).

    APPEND FIELDNAMES.CLEAR FIELDNAMES.

    FIELDNAMES-TEXT = TEXT-032.

    APPEND FIELDNAMES.CLEAR FIELDNAMES.

    *--FM to download data to Excel sheet

    CALL FUNCTION 'WS_DOWNLOAD'

    EXPORTING

    FILENAME = C_FILE

    FILETYPE = 'DAT'

    TABLES

    DATA_TAB = IT_FINAL

    FIELDNAMES = FIELDNAMES

    EXCEPTIONS

    FILE_OPEN_ERROR = 1

    FILE_WRITE_ERROR = 2

    INVALID_FILESIZE = 3

    INVALID_TABLE_WIDTH = 4

    INVALID_TYPE = 5

    NO_BATCH = 6

    UNKNOWN_ERROR = 7

    GUI_REFUSE_FILETRANSFER = 8

    OTHERS = 9.

    IF SY-SUBRC <> 0.

    MESSAGE E001(ZZ) WITH 'Data could not downloaded'(047).

    ENDIF.

    ENDFORM. " DOWN_LOAD_TO_EXCEL

    &----


    *& Form GET_FINAL_DATA

    &----


    • To Populate required data in final internal table

    ----


    FORM GET_FINAL_DATA .

    CLEAR IT_FINAL.

    REFRESH IT_FINAL.

    LOOP AT IT_POITEM.

    CLEAR IT_POHEADER.

    READ TABLE IT_POHEADER WITH KEY EBELN = IT_POITEM-EBELN.

    IF SY-SUBRC = 0.

    MOVE : IT_POHEADER-EBELN TO IT_FINAL-EBELN, "Purchasing Doc

    IT_POITEM-EBELP TO IT_FINAL-EBELP, "Item

    IT_POHEADER-AEDAT TO IT_FINAL-AEDAT, "Created On

    IT_POHEADER-ERNAM TO IT_FINAL-ERNAM, "Created By

    IT_POITEM-MATNR TO IT_FINAL-MATNR, "Material

    IT_POITEM-BUKRS TO IT_FINAL-BUKRS, "Company code

    IT_POITEM-WERKS TO IT_FINAL-WERKS, "Plant

    IT_POITEM-MATKL TO IT_FINAL-MATKL, "Material Group

    IT_POITEM-MENGE TO IT_FINAL-MENGE, "Order Qty

    IT_POITEM-NETPR TO IT_FINAL-NETPR, "Net Price

    IT_POITEM-PEINH TO IT_FINAL-PEINH, "Price Unit

    IT_POITEM-NETWR TO IT_FINAL-NETWR, "Net Value

    IT_POHEADER-LIFNR TO IT_FINAL-LIFNR. "Vendor

    *--To Insert IR details

    CLEAR IT_HISTORY.

    READ TABLE IT_HISTORY WITH KEY EBELN = IT_POITEM-EBELN

    EBELP = IT_POITEM-EBELP

    VGABE = '2'

    BEWTP = 'Q'.

    IF SY-SUBRC = 0.

    MOVE :

    IT_HISTORY-BELNR TO IT_FINAL-IR_BELNR, "IR-Number of Mat Doc

    IT_HISTORY-BUZEI TO IT_FINAL-IR_BUZEI, "IR-Item in mat Doc

    IT_HISTORY-BUDAT TO IT_FINAL-IR_BUDAT, "IR-Posting date

    IT_HISTORY-BUDAT TO IT_FINAL-IR_MENGE. "IR-Quantity

    ENDIF.

    *--To insert GR details

    CLEAR IT_HISTORY.

    READ TABLE IT_HISTORY WITH KEY EBELN = IT_POITEM-EBELN

    EBELP = IT_POITEM-EBELP

    VGABE = '1'

    BEWTP = 'E'.

    IF SY-SUBRC = 0.

    MOVE :

    IT_HISTORY-BELNR TO IT_FINAL-GR_BELNR, "IR-Number of Mat Doc

    IT_HISTORY-BUZEI TO IT_FINAL-GR_BUZEI, "IR-Item in mat Doc

    IT_HISTORY-BUDAT TO IT_FINAL-GR_BUDAT, "IR-Posting date

    IT_HISTORY-BUDAT TO IT_FINAL-GR_MENGE. "IR-Quantity

    ENDIF.

    *--To insert Vendor details

    CLEAR IT_VENDOR.

    READ TABLE IT_VENDOR WITH KEY LIFNR = IT_POHEADER-LIFNR.

    IF SY-SUBRC = 0.

    MOVE : IT_VENDOR-NAME1 TO IT_FINAL-NAME1.

    ENDIF.

    *--To insert Business area

    CLEAR IT_BUSINESS.

    READ TABLE IT_BUSINESS WITH KEY EBELN = IT_POITEM-EBELN

    EBELP = IT_POITEM-EBELP.

    IF SY-SUBRC = 0.

    MOVE : IT_BUSINESS-GSBER TO IT_FINAL-GSBER.

    ENDIF.

    APPEND IT_FINAL.

    CLEAR IT_FINAL.

    ENDIF.

    ENDLOOP.

    ENDFORM. " GET_FINAL_DATA

    Thanks

    Sunil

    Add a comment
    10|10000 characters needed characters exceeded

  • Before answering

    You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
    You must be Logged in to submit an answer.

    Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.