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

alv

still i am not able create an interactive alv report .Please send me an very simple report to understand interactive alv and event catalog and layout in alv..?!

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jan 17, 2007 at 12:45 PM
    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 17, 2007 at 12:47 PM

    Hi please see the below ALV report in which Interacting with the output is handled in 'USER_COMMAND' subroutine

    report zrpmm_sa_liability_report

    no standard page heading

    line-size 180

    line-count 65

    message-id zcus.

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

    • T a b l e s D e c l a r a t i o n *

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

    Tables:

    t024, " Purchasing Groups

    mara, " Material Master

    tcurr, " Exchange rates

    t001w, " Plants

    ekko, " Purchasing Document Header

    ekpo, " Purchasing Document Item

    mdkp, " Header Data for MRP Document

    plsc,

    t161.

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

    • S t r u c t u r e s D e c l a r a t i o n

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

    • Structure for selecting data from EKKO

    types: Begin of ty_ekko,

    ebeln type ekko-ebeln, " Scheduling Agreement no.

    ekgrp type ekko-ekgrp, " Purchasing Group

    lifnr type ekko-lifnr, " Vendor no.

    bsart type ekko-bsart, " Sheduling Agreement type

    waers type ekko-waers, " Currency

    bukrs type ekko-bukrs, " Company code

    ekorg type ekko-ekorg, " Purchase Organization

    kdatb type ekko-kdatb, " SA validity start date

    kdate type ekko-kdate, " SA validity end date

    end of ty_ekko.

    • Structure for selecting data from EKPO

    types: Begin of ty_ekpo,

    ebeln type ekpo-ebeln, " Scheduling Agreement no.

    ebelp type ekpo-ebelp, " SA item no.

    matnr type ekpo-matnr, " Material Number

    txz01 type ekpo-txz01, " Short text of item

    netpr type ekpo-netpr, " SA line price

    ktmng type ekpo-ktmng, " Target quantity of SA item

    meins type ekpo-meins, " Base Unit of Measure

    plifz type ekpo-plifz, " Planned Delivery time

    etfz1 type ekpo-etfz1, " Firm Zone from SA item

    etfz2 type ekpo-etfz2, " Trade off zone from SA item

    kzstu type ekpo-kzstu, " FRM/TRZ binding MRP

    werks type ekpo-werks, " Plant

    end of ty_ekpo.

    • Structure for selecting data from T024

    types: Begin of ty_t024,

    ekgrp type t024-ekgrp, " Purchasing Group

    eknam type t024-eknam, " Purchasing Group Name

    end of ty_t024.

    • Structure for selecting data from LFA1

    types: Begin of ty_lfa1,

    lifnr type lfa1-lifnr, " Vendor no.

    name1 type lfa1-name1, " Vendor Name

    end of ty_lfa1.

    • Structure for selecting data from EKET

    types: Begin of ty_eket,

    ebeln type eket-ebeln, " Scheduling Agreement no.

    ebelp type eket-ebelp, " SA item no.

    etenr type eket-etenr,

    menge type eket-menge, " Quantity delivered

    end of ty_eket.

    • Structure for selecting data from MDKP

    types: Begin of ty_mdkp,

    matnr type mdkp-matnr, " Material Number

    plwrk type mdkp-plwrk, " Plant

    plscn type mdkp-plscn, " Planning Scenario

    dtnum type mdkp-dtnum, " Material planning table no.

    cflag type mdkp-cflag, " Agregated MRP list

    end of ty_mdkp.

    • Structure for selecting data from EORD

    types: Begin of ty_eord,

    matnr type eord-matnr, " Material Number

    werks type eord-werks, " Plant

    lifnr type eord-lifnr, " Vendor no.

    ebeln type eord-ebeln, " Scheduling Agreement no.

    ebelp type eord-ebelp, " SA item no.

    vdatu type eord-vdatu, " Source list validity dt.from

    bdatu type eord-bdatu, " Source list validity dt.to

    ekorg type eord-ekorg, " Purchase organization

    end of ty_eord.

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

    • I n t e r n a l T a b l e s *

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

    • Internal Table for Output Data

    data: it_alv_data type table of

    ZRPMM_SA_LIABILITY_REPORT_ALV with header line.

    • Internal Table for selecting data from EKKO

    data: it_ekko type table of ty_ekko with header line.

    • Temparary internal Table for selecting data from EKKO

    data: it_ekko_temp type table of ty_ekko with header line.

    • Internal Table for selecting data from EKPO

    data: it_ekpo type table of ty_ekpo with header line.

    • Temporary Internal Table for selecting data from EKPO

    data: it_ekpo_temp type table of ty_ekpo with header line.

    • Internal Table for selecting data from T024

    data: it_t024 type table of ty_t024 with header line.

    • Internal Table for selecting data from LFA1

    data: it_lfa1 type table of ty_lfa1 with header line.

    • Internal Table for selecting data from EKET

    data: it_eket type table of ty_eket with header line.

    • Internal Table for selecting data from MDKP

    data: it_mdkp type table of ty_mdkp with header line.

    • Internal Table for selecting data from EORD

    data: it_eord type table of ty_eord with header line.

    • Internal Table for selecting mrp data.

    data: it_mdtb type table of mdtb with header line.

    • Internal table for BDC

    data: it_bdc LIKE bdcdata OCCURS 0 WITH HEADER LINE.

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

    • C o n s t a n t s D e c l a r a t i o n *

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

    constants: c_lp type mdkp-dtart value 'LP',

    c_neg type c value '-'.

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

    • V a r i a b l e s D e c l a r a t i o n *

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

    data: w_alv_table_name type dd02d-strname value 'it_alv_data',

    w_sdate type d,

    w_edate type d.

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

    • S e l e c t i o n S c r e e n *

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

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

    parameters: p_plscn like mdkp-plscn obligatory. " LTP Scenerio No

    select-options: s_bsart for ekko-bsart, " Document Type

    s_kdatb for ekko-kdatb, " SA Validity from

    s_kdate for ekko-kdate, " SA Validity to

    s_werks for ekpo-werks, " Plant

    s_ekgrp for ekko-ekgrp, " Purchasing Group

    s_matnr for ekpo-matnr, " Material Number

    s_ddate for sy-datum.

    parameters p_waers like ekko-waers DEFAULT 'USD'

    obligatory. " Currency

    selection-screen end of block b1.

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

    • S t a n d a r d I n c l u d e *

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

    • Include that Contains ALV Related Forms

    include zalv_reuse_forms_2.

    ----


    • I n i t i a l i z a t i o n *

    ----


    initialization.

    • Initializing Variant

    perform initialize_variant.

    perform extract_initialize.

    • initialize demand date

    perform get_end_dates_of_next_quarter.

    perform initialize_doc_type.

    ----


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

    ----


    at selection-screen.

    PERFORM pai_of_selection_screen.

    perform user_action.

    perform check_extracts_count.

    perform validate_screen.

    at selection-screen on value-request for p_vari.

    • Adding F4 help to Variant.

    perform f4_for_variant.

    at selection-screen on value-request for p_zex1.

    perform f4_for_save_extract.

    at selection-screen on value-request for p_zex2.

    perform f4_for_existing_extract.

    at selection-screen output.

    perform set_screen.

    ----


    • S t a r t O f S e l e c t i o n *

    ----


    start-of-selection.

    if p_noexz = 'X'. " Without Extract

    • Select Report Data From Database Tables

    perform get_data.

    • Append the data into final internal table

    perform append_data.

    endif.

    if p_load2 = 'X'. " Read Extract

    perform load_extract.

    endif.

    if p_save2 = 'X'. " Save Extract

    • Select Report Data From Database Tables

    perform get_data.

    • Append the data into final internal table

    perform append_data.

    • Save the extract

    perform save_extract.

    endif.

    ----


    • E n d O f S e l e c t i o n *

    ----


    end-of-selection.

    • Display the report.

    perform alv_common_stuff.

    &----


    *& Form get_data

    &----


    • Selecting the data from the Database Tables

    ----


    FORM get_data .

    • Select Scheduling agreement header data

    perform get_sa_header_data.

    • Select Purchase Group Names.

    perform get_purchase_group.

    • Select Scheduling agreement item data

    perform get_sa_item_data.

    • Select Vendor Names

    perform get_vendor_data.

    • Select Sheduling agreement schedule line data

    perform get_sa_schedule_lines.

    • Select purchasing source list data

    perform get_source_list_data.

    • Select MRP header data

    perform get_mrp_header_data.

    ENDFORM. " get_data

    &----


    *& Form get_sa_header_data

    &----


    • Select Scheduling Agreement header level data

    ----


    FORM get_sa_header_data .

    select ebeln

    ekgrp

    lifnr

    bsart

    waers

    bukrs

    ekorg

    kdatb

    kdate

    into table it_ekko

    from ekko

    where bsart in s_bsart and

    ekgrp in s_ekgrp and

    kdatb in s_kdatb and

    kdate in s_kdate. "#EC CI_SUBRC

    sort it_ekko by ebeln.

    ENDFORM. " get_sa_header_data

    &----


    *& Form get_sa_item_data

    &----


    • Select Scheduling Agreement Item data

    ----


    FORM get_sa_item_data .

    if not it_ekko[] is initial.

    select ebeln

    ebelp

    matnr

    txz01

    netpr

    ktmng

    meins

    plifz

    etfz1

    etfz2

    kzstu

    werks

    into table it_ekpo

    from ekpo

    for all entries in it_ekko

    where ebeln = it_ekko-ebeln and

    matnr in s_matnr and

    werks in s_werks and "#EC CI_SUBRC

    elikz = ' ' and "Remedy#154048

    LOEKZ <> 'L'."KRDK960077

    sort it_ekpo by ebeln ebelp.

    endif.

    ENDFORM. " get_sa_item_data

    &----


    *& Form get_purchase_group

    &----


    • Select Purchase Group Names.

    ----


    FORM get_purchase_group .

    clear it_ekko_temp.

    refresh it_ekko_temp.

    it_ekko_temp[] = it_ekko[].

    sort it_ekko_temp by ekgrp.

    delete adjacent duplicates from it_ekko_temp comparing ekgrp.

    if not it_ekko_temp[] is initial.

    select ekgrp

    eknam

    into table it_t024

    from t024

    for all entries in it_ekko_temp

    where ekgrp = it_ekko_temp-ekgrp. "#EC CI_SUBRC

    sort it_t024 by ekgrp.

    endif.

    ENDFORM. " get_purchase_group

    &----


    *& Form get_vendor_data

    &----


    • Select Vendor Names

    ----


    FORM get_vendor_data .

    clear it_ekko_temp.

    refresh it_ekko_temp.

    it_ekko_temp[] = it_ekko[].

    sort it_ekko_temp by lifnr.

    delete adjacent duplicates from it_ekko_temp comparing lifnr.

    if not it_ekko[] is initial.

    select lifnr

    name1

    into table it_lfa1

    from lfa1

    for all entries in it_ekko_temp

    where lifnr = it_ekko_temp-lifnr. "#EC CI_SUBRC

    sort it_lfa1 by lifnr.

    endif.

    ENDFORM. " get_vendor_data

    &----


    *& Form get_sa_schedule_lines

    &----


    • Select Sheduling agreement schedule line data

    ----


    FORM get_sa_schedule_lines .

    if not it_ekpo[] is initial.

    select ebeln

    ebelp

    etenr

    menge

    into table it_eket

    from eket

    for all entries in it_ekpo

    where ebeln = it_ekpo-ebeln and

    ebelp = it_ekpo-ebelp. "#EC CI_SUBRC

    sort it_eket by ebeln ebelp.

    endif.

    ENDFORM. " get_sa_schedule_lines

    &----


    *& Form get_source_list_data

    &----


    • Select purchasing source list data

    ----


    FORM get_source_list_data .

    clear it_ekpo_temp.

    refresh it_ekpo_temp.

    it_ekpo_temp[] = it_ekpo[].

    sort it_ekpo_temp by matnr werks.

    delete adjacent duplicates from it_ekpo_temp

    comparing matnr werks.

    if not it_ekpo_temp[] is initial.

    select matnr

    werks

    lifnr

    ebeln

    ebelp

    vdatu

    bdatu

    ekorg

    into table it_eord

    from eord

    for all entries in it_ekpo_temp

    where matnr = it_ekpo_temp-matnr and

    werks = it_ekpo_temp-werks. "#EC CI_SUBRC

    sort it_eord by matnr werks.

    endif.

    ENDFORM. " get_source_list_data

    &----


    *& Form append_data

    &----


    • Append the data into final internal table

    ----


    FORM append_data .

    data lw_menge like eket-menge.

    clear it_alv_data.

    loop at it_ekpo.

    • get SA item level data

    it_alv_data-ebeln = it_ekpo-ebeln.

    it_alv_data-ebelp = it_ekpo-ebelp.

    it_alv_data-matnr = it_ekpo-matnr.

    it_alv_data-txz01 = it_ekpo-txz01.

    it_alv_data-ktmng = it_ekpo-ktmng.

    it_alv_data-plifz = it_ekpo-plifz.

    it_alv_data-etfz1 = it_ekpo-etfz1.

    it_alv_data-etfz2 = it_ekpo-etfz2.

    it_alv_data-kzstu = it_ekpo-kzstu.

    it_alv_data-werks = it_ekpo-werks.

    it_alv_data-meins = it_ekpo-meins.

    it_alv_data-meins_qo = it_ekpo-meins.

    it_alv_data-meins_qr = it_ekpo-meins.

    it_alv_data-meins_md = it_ekpo-meins.

    • get SA header level data

    clear it_ekko.

    read table it_ekko with key ebeln = it_ekpo-ebeln

    binary search.

    if sy-subrc = 0.

    it_alv_data-bsart = it_ekko-bsart.

    if p_waers is initial.

    it_alv_data-waers = it_ekko-waers.

    it_alv_data-waers_pr = it_ekko-waers.

    it_alv_data-waers_ov = it_ekko-waers.

    it_alv_data-waers_re = it_ekko-waers.

    it_alv_data-waers_md = it_ekko-waers.

    else.

    it_alv_data-waers = p_waers.

    it_alv_data-waers_pr = p_waers.

    it_alv_data-waers_ov = p_waers.

    it_alv_data-waers_re = p_waers.

    it_alv_data-waers_md = p_waers.

    endif.

    it_alv_data-bukrs = it_ekko-bukrs.

    it_alv_data-ekorg = it_ekko-ekorg.

    it_alv_data-kdatb = it_ekko-kdatb.

    it_alv_data-kdate = it_ekko-kdate.

    • converting the amount into specified currency

    if it_ekko-waers = p_waers.

    it_alv_data-netpr = it_ekpo-netpr.

    else.

    perform currency_conversion.

    endif.

    • get purchse group name

    clear it_t024.

    read table it_t024 with key ekgrp = it_ekko-ekgrp

    binary search.

    if sy-subrc = 0.

    it_alv_data-ekgrp = it_t024-ekgrp.

    it_alv_data-eknam = it_t024-eknam.

    endif.

    • get Vendor name

    clear it_lfa1.

    read table it_lfa1 with key lifnr = it_ekko-lifnr

    binary search.

    if sy-subrc = 0.

    it_alv_data-name1 = it_lfa1-name1.

    endif.

    • get purchasing source list data.

    clear it_eord.

    read table it_eord with key matnr = it_ekpo-matnr

    werks = it_ekpo-werks

    lifnr = it_ekko-lifnr

    ebeln = it_ekko-ebeln

    ebelp = it_ekpo-ebelp.

    if sy-subrc = 0.

    it_alv_data-vdatu = it_eord-vdatu.

    it_alv_data-bdatu = it_eord-bdatu.

    endif.

    endif.

    • get SA schedule line data

    clear: it_eket,

    lw_menge.

    loop at it_eket where ebeln = it_ekpo-ebeln and "EC CI_NESTED

    ebelp = it_ekpo-ebelp.

    lw_menge = lw_menge + it_eket-menge.

    endloop.

    it_alv_data-menge = lw_menge.

    • determine projected value

    it_alv_data-pvalu = it_ekpo-ktmng * it_alv_data-netpr.

    • determine ordered value

    it_alv_data-ovalu = it_alv_data-menge * it_alv_data-netpr.

    • determine quantity remaining

    it_alv_data-qremn = it_ekpo-ktmng - it_alv_data-menge.

    if it_alv_data-qremn < 0.

    it_alv_data-qremn = it_alv_data-qremn * -1.

    endif.

    • determine remaining value

    it_alv_data-rvalu = it_alv_data-qremn * it_alv_data-netpr.

    • determin month demand

    clear it_mdkp.

    read table it_mdkp with key matnr = it_ekpo-matnr

    plwrk = it_ekpo-werks

    binary search.

    if sy-subrc = 0.

    • read mrp data

    clear it_mdtb.

    refresh it_mdtb.

    call function 'READ_MRP_LIST'

    EXPORTING

    idtnum = it_mdkp-dtnum

    icflag = it_mdkp-cflag

    TABLES

    mdtbx = it_mdtb.

    if not it_mdtb[] is initial.

    perform get_months_demand.

    endif.

    • planning scenario.

    it_alv_data-plscn = it_mdkp-plscn.

    endif.

    append it_alv_data.

    clear it_alv_data.

    endloop.

    delete it_alv_data where plscn ne p_plscn.

    ENDFORM. " append_data

    &----


    *& Form currency_conversion

    &----


    • Convert the price into specified currency

    ----


    FORM currency_conversion .

    CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'

    EXPORTING

    CLIENT = SY-MANDT

    DATE = sy-datum

    FOREIGN_AMOUNT = it_ekpo-netpr

    FOREIGN_CURRENCY = it_ekko-waers

    LOCAL_CURRENCY = p_waers

    RATE = 0

    TYPE_OF_RATE = 'M'

    READ_TCURR = 'X'

    IMPORTING

    LOCAL_AMOUNT = it_alv_data-netpr

    EXCEPTIONS

    NO_RATE_FOUND = 1

    OVERFLOW = 2

    NO_FACTORS_FOUND = 3

    NO_SPREAD_FOUND = 4

    DERIVED_2_TIMES = 5

    OTHERS = 6.

    IF SY-SUBRC <> 0.

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

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

    ENDIF.

    ENDFORM. " currency_conversion

    &----


    *& Form alv_common_stuff

    &----


    • Get The Report Data From Database Tables

    ----


    form alv_common_stuff .

    perform initialize_alv_variables using w_alv_table_name space

    space space space

    c_xflag_alv_flg.

    perform build_events using c_xflag_alv_flg c_xflag_alv_flg.

    describe table it_alv_data lines w_total_records.

    w_structure = 'ZRPMM_SA_LIABILITY_REPORT_ALV'.

    perform build_comments_top.

    clear it_end_of_list[].

    perform build_comments_top_endlist using 'S' 'L E G E N D :' space.

    perform build_comments_top_endlist using 'S' 'GREEN' 'Success'(002).

    perform field_cat_build.

    perform modify_field_cat_build.

    perform call_alv_fm_user_status.

    endform. " alv_common_stuff

    &----


    *& Form modify_field_cat_build

    &----


    • Modify Field catelog

    ----


    FORM modify_field_cat_build .

    DATA: lwa_fieldcat TYPE slis_fieldcat_alv.

    LOOP AT it_fieldcat INTO lwa_fieldcat.

    CASE lwa_fieldcat-fieldname.

    WHEN 'EKNAM'.

    lwa_fieldcat-col_pos = 1.

    lwa_fieldcat-seltext_m = lwa_fieldcat-seltext_s =

    lwa_fieldcat-reptext_ddic = lwa_fieldcat-seltext_l =

    'Purchasing Group'(004).

    WHEN 'NAME1'.

    lwa_fieldcat-col_pos = 2.

    lwa_fieldcat-seltext_m = lwa_fieldcat-seltext_s =

    lwa_fieldcat-reptext_ddic = lwa_fieldcat-seltext_l =

    'Vendor Name'(005).

    WHEN 'EBELN'.

    lwa_fieldcat-col_pos = 3.

    lwa_fieldcat-outputlen = 20.

    lwa_fieldcat-seltext_m = lwa_fieldcat-seltext_s =

    lwa_fieldcat-reptext_ddic = lwa_fieldcat-seltext_l =

    'Scheduling Agreement'(006).

    WHEN 'EBELP'.

    lwa_fieldcat-col_pos = 4.

    lwa_fieldcat-seltext_m = lwa_fieldcat-seltext_s =

    lwa_fieldcat-reptext_ddic = lwa_fieldcat-seltext_l =

    'SA item number'(007).

    WHEN 'BSART'.

    lwa_fieldcat-col_pos = 5.

    lwa_fieldcat-seltext_m = lwa_fieldcat-seltext_s =

    lwa_fieldcat-reptext_ddic = lwa_fieldcat-seltext_l =

    'Scheduling Agreement type'(008).

    WHEN 'MATNR'.

    lwa_fieldcat-col_pos = 6.

    lwa_fieldcat-seltext_m = lwa_fieldcat-seltext_s =

    lwa_fieldcat-reptext_ddic = lwa_fieldcat-seltext_l =

    'Material Number'(009).

    WHEN 'TXZ01'.

    lwa_fieldcat-col_pos = 7.

    lwa_fieldcat-seltext_m = lwa_fieldcat-seltext_s =

    lwa_fieldcat-reptext_ddic = lwa_fieldcat-seltext_l =

    'Short text'(010).

    WHEN 'NETPR'.

    lwa_fieldcat-col_pos = 8.

    lwa_fieldcat-seltext_m = lwa_fieldcat-seltext_s =

    lwa_fieldcat-reptext_ddic = lwa_fieldcat-seltext_l =

    'Unit Cost'(011).

    WHEN 'WAERS'.

    lwa_fieldcat-col_pos = 9.

    lwa_fieldcat-seltext_m = lwa_fieldcat-seltext_s =

    lwa_fieldcat-reptext_ddic = lwa_fieldcat-seltext_l =

    'Currency'(012).

    WHEN 'KDATB'.

    lwa_fieldcat-col_pos = 10.

    lwa_fieldcat-seltext_m = lwa_fieldcat-seltext_s =

    lwa_fieldcat-reptext_ddic = lwa_fieldcat-seltext_l =

    'Validity start'(013).

    WHEN 'KDATE'.

    lwa_fieldcat-col_pos = 11.

    lwa_fieldcat-seltext_m = lwa_fieldcat-seltext_s =

    lwa_fieldcat-reptext_ddic = lwa_fieldcat-seltext_l =

    'Validity end'(014).

    WHEN 'KTMNG'.

    lwa_fieldcat-col_pos = 12.

    lwa_fieldcat-seltext_m = lwa_fieldcat-seltext_s =

    lwa_fieldcat-reptext_ddic = lwa_fieldcat-seltext_l =

    'Target Qty'(015).

    WHEN 'MEINS'.

    lwa_fieldcat-col_pos = 13.

    lwa_fieldcat-seltext_m = lwa_fieldcat-seltext_s =

    lwa_fieldcat-reptext_ddic = lwa_fieldcat-seltext_l =

    'OUn'(052).

    WHEN 'PVALU'.

    lwa_fieldcat-col_pos = 14.

    lwa_fieldcat-reptext_ddic = lwa_fieldcat-seltext_m =

    lwa_fieldcat-seltext_s = lwa_fieldcat-seltext_l =

    'Projected Value'(036).

    WHEN 'WAERS_PR'.

    lwa_fieldcat-col_pos = 15.

    lwa_fieldcat-seltext_m = lwa_fieldcat-seltext_s =

    lwa_fieldcat-reptext_ddic = lwa_fieldcat-seltext_l =

    'Currency'(012).

    WHEN 'MENGE'.

    lwa_fieldcat-col_pos = 16.

    lwa_fieldcat-outputlen = 20.

    lwa_fieldcat-seltext_m = lwa_fieldcat-seltext_s =

    lwa_fieldcat-reptext_ddic = lwa_fieldcat-seltext_l =

    'Ord Qty'(037).

    WHEN 'MEINS_QO'.

    lwa_fieldcat-col_pos = 17.

    lwa_fieldcat-seltext_m = lwa_fieldcat-seltext_s =

    lwa_fieldcat-reptext_ddic = lwa_fieldcat-seltext_l =

    'OUn'(052).

    WHEN 'OVALU'.

    lwa_fieldcat-col_pos = 18.

    lwa_fieldcat-outputlen = 20.

    lwa_fieldcat-seltext_m = lwa_fieldcat-seltext_s =

    lwa_fieldcat-reptext_ddic = lwa_fieldcat-seltext_l =

    'Ord Value'(038).

    lwa_fieldcat-no_sign = c_xflag_alv_flg.

    WHEN 'WAERS_OV'.

    lwa_fieldcat-col_pos = 19.

    lwa_fieldcat-seltext_m = lwa_fieldcat-seltext_s =

    lwa_fieldcat-reptext_ddic = lwa_fieldcat-seltext_l =

    'Currency'(012).

    WHEN 'QREMN'.

    lwa_fieldcat-col_pos = 20.

    lwa_fieldcat-outputlen = 20.

    lwa_fieldcat-seltext_m = lwa_fieldcat-seltext_s =

    lwa_fieldcat-reptext_ddic = lwa_fieldcat-seltext_l =

    'Qty Rem'(039).

    lwa_fieldcat-no_sign = c_xflag_alv_flg.

    WHEN 'MEINS_QR'.

    lwa_fieldcat-col_pos = 21.

    lwa_fieldcat-seltext_m = lwa_fieldcat-seltext_s =

    lwa_fieldcat-reptext_ddic = lwa_fieldcat-seltext_l =

    'OUn'(052).

    WHEN 'RVALU'.

    lwa_fieldcat-col_pos = 22.

    lwa_fieldcat-outputlen = 20.

    lwa_fieldcat-seltext_m = lwa_fieldcat-seltext_s =

    lwa_fieldcat-reptext_ddic = lwa_fieldcat-seltext_l =

    'Rem.Value'(040).

    lwa_fieldcat-no_sign = c_xflag_alv_flg.

    WHEN 'WAERS_RE'.

    lwa_fieldcat-col_pos = 23.

    lwa_fieldcat-seltext_m = lwa_fieldcat-seltext_s =

    lwa_fieldcat-reptext_ddic = lwa_fieldcat-seltext_l =

    'Currency'(012).

    WHEN 'MDEMA'.

    lwa_fieldcat-col_pos = 24.

    lwa_fieldcat-outputlen = 20.

    lwa_fieldcat-seltext_m = lwa_fieldcat-seltext_s =

    lwa_fieldcat-reptext_ddic = lwa_fieldcat-seltext_l =

    'Month Demand'(041).

    lwa_fieldcat-no_sign = c_xflag_alv_flg.

    WHEN 'MEINS_MD'.

    lwa_fieldcat-col_pos = 25.

    lwa_fieldcat-seltext_m = lwa_fieldcat-seltext_s =

    lwa_fieldcat-reptext_ddic = lwa_fieldcat-seltext_l =

    'OUn'(052).

    WHEN 'MDEMD'.

    lwa_fieldcat-col_pos = 26.

    lwa_fieldcat-outputlen = 20.

    lwa_fieldcat-seltext_m = lwa_fieldcat-seltext_s =

    lwa_fieldcat-reptext_ddic = lwa_fieldcat-seltext_l =

    'Month Demand'(042).

    lwa_fieldcat-no_sign = c_xflag_alv_flg.

    WHEN 'WAERS_MD'.

    lwa_fieldcat-col_pos = 27.

    lwa_fieldcat-seltext_m = lwa_fieldcat-seltext_s =

    lwa_fieldcat-reptext_ddic = lwa_fieldcat-seltext_l =

    'Currency'(012).

    WHEN 'MDEMR'.

    lwa_fieldcat-col_pos = 28.

    lwa_fieldcat-outputlen = 20.

    lwa_fieldcat-seltext_m = lwa_fieldcat-seltext_s =

    lwa_fieldcat-reptext_ddic = lwa_fieldcat-seltext_l =

    'Mon. Rem'(043).

    lwa_fieldcat-no_sign = c_xflag_alv_flg.

    WHEN 'VDATU'.

    lwa_fieldcat-col_pos = 29.

    lwa_fieldcat-outputlen = 20.

    lwa_fieldcat-seltext_m = lwa_fieldcat-seltext_s =

    lwa_fieldcat-reptext_ddic = lwa_fieldcat-seltext_l =

    'SL from'(044).

    WHEN 'BDATU'.

    lwa_fieldcat-col_pos = 30.

    lwa_fieldcat-outputlen = 20.

    lwa_fieldcat-seltext_m = lwa_fieldcat-seltext_s =

    lwa_fieldcat-reptext_ddic = lwa_fieldcat-seltext_l =

    'SL to'(045).

    WHEN 'PLIFZ'.

    lwa_fieldcat-col_pos = 31.

    lwa_fieldcat-outputlen = 20.

    lwa_fieldcat-seltext_m = lwa_fieldcat-seltext_s =

    lwa_fieldcat-reptext_ddic = lwa_fieldcat-seltext_l =

    'PDT'(046).

    WHEN 'ETFZ1'.

    lwa_fieldcat-col_pos = 32.

    lwa_fieldcat-outputlen = 20.

    lwa_fieldcat-seltext_m = lwa_fieldcat-seltext_s =

    lwa_fieldcat-reptext_ddic = lwa_fieldcat-seltext_l =

    'Firm Zone'(047).

    WHEN 'ETFZ2'.

    lwa_fieldcat-col_pos = 33.

    lwa_fieldcat-outputlen = 20.

    lwa_fieldcat-seltext_m = lwa_fieldcat-seltext_s =

    lwa_fieldcat-reptext_ddic = lwa_fieldcat-seltext_l =

    'Trade off Zone'(048).

    WHEN 'KZSTU'.

    lwa_fieldcat-col_pos = 34.

    lwa_fieldcat-outputlen = 20.

    lwa_fieldcat-seltext_m = lwa_fieldcat-seltext_s =

    lwa_fieldcat-reptext_ddic = lwa_fieldcat-seltext_l =

    'FRM/TRZ Binding MRP'(049).

    WHEN 'PLSCN'.

    lwa_fieldcat-col_pos = 35.

    lwa_fieldcat-outputlen = 20.

    lwa_fieldcat-seltext_m = lwa_fieldcat-seltext_s =

    lwa_fieldcat-reptext_ddic = lwa_fieldcat-seltext_l =

    'Scenario'(050).

    WHEN 'WERKS'.

    lwa_fieldcat-no_out = c_xflag_alv_flg.

    WHEN 'EKORG'.

    lwa_fieldcat-no_out = c_xflag_alv_flg.

    WHEN 'EKGRP'.

    lwa_fieldcat-no_out = c_xflag_alv_flg.

    WHEN 'BUKRS'.

    lwa_fieldcat-no_out = c_xflag_alv_flg.

    ENDCASE.

    MODIFY it_fieldcat FROM lwa_fieldcat.

    ENDLOOP.

    ENDFORM. " modify_field_cat_build

    &----


    *& Form get_mrp_header_data

    &----


    • Select mrp header data

    ----


    FORM get_mrp_header_data .

    clear it_ekpo_temp.

    refresh it_ekpo_temp.

    it_ekpo_temp[] = it_ekpo[].

    sort it_ekpo_temp by matnr werks.

    delete adjacent duplicates from it_ekpo_temp

    comparing matnr werks.

    if not it_ekpo[] is initial.

    select matnr

    plwrk

    plscn

    dtnum

    cflag

    into table it_mdkp

    from mdkp

    for all entries in it_ekpo_temp

    where dtart = c_lp and

    matnr = it_ekpo_temp-matnr and

    plwrk = it_ekpo_temp-werks and

    plscn = p_plscn. "#EC CI_SUBRC

    sort it_mdkp by matnr plwrk.

    endif.

    ENDFORM. " get_mrp_header_data

    &----


    *& Form get_end_dates_of_next_quarter

    &----


    • Get the ending dates of next quarter

    ----


    FORM get_end_dates_of_next_quarter .

    type-pools p99sg.

    data: lit_quarter type P99SG_QUARTER,

    lw_ret type sy-subrc,

    lw_next_qrt type i.

    • get the current quarter & year

    CALL FUNCTION 'HR_99S_GET_QUARTER'

    EXPORTING

    IM_DATE = sy-datum

    IMPORTING

    EX_QUARTER = lit_quarter " Table with current quarter

    EX_RETURNCODE = lw_ret. " and year

    lw_next_qrt = lit_quarter-q + 1. " To get next quarter

    if lw_next_qrt = 5.

    lw_next_qrt = 1.

    lit_quarter-year = lit_quarter-year + 1.

    endif.

    .

    CALL FUNCTION 'HR_99S_GET_DATES_QUARTER'

    EXPORTING

    IM_QUARTER = lw_next_qrt

    IM_YEAR = lit_quarter-year

    IMPORTING

    EX_BEGDA = w_sdate

    EX_ENDDA = w_edate.

    s_ddate-low = w_sdate.

    s_ddate-high = w_edate.

    append s_ddate.

    lw_ret = 0.

    ENDFORM. " get_end_dates_of_next_quarter

    &----


    *& Form get_months_demand

    &----


    • Get month's demand

    ----


    FORM get_months_demand .

    data: lw_m3_demand type mdtb-mng01.

    delete it_mdtb where plumi ne c_neg.

    delete it_mdtb where dat00 < s_ddate-low.

    delete it_mdtb where dat00 > s_ddate-high.

    loop at it_mdtb.

    lw_m3_demand = lw_m3_demand + it_mdtb-mng01. " Three month's

    "demand

    endloop.

    • Month demand

    it_alv_data-mdema = lw_m3_demand / 3.

    • Month demand in $

    it_alv_data-mdemd = it_alv_data-mdema * it_alv_data-netpr.

    • Month demand remaining

    if it_alv_data-mdemd ne 0.

    it_alv_data-mdemr = it_alv_data-rvalu / it_alv_data-mdemd.

    endif.

    ENDFORM. " get_months_demand

    &----


    *& Form user_command

    &----


    • Hadle the user interaction from ALV list.

    ----


    • -->P_UCOMM - User selected option

    • -->P_SELFIELD - Cusor feild information

    ----


    form user_command using p_ucomm type sy-ucomm

    p_selfield type slis_selfield. "#EC CALLED

    case p_ucomm.

    when '&INFO2'.

    perform do_show_print_selections.

    when '&IC1'. " At Line Selection

    read table it_alv_data index p_selfield-tabindex.

    case p_selfield-fieldname.

    when 'EBELN'.

    check it_alv_data-ebeln is not initial.

    perform display_scheduling_agreements.

    when 'MATNR'.

    perform display_material_mm03.

    when 'NAME1'.

    perform display_vendor_xk03.

    when 'TXZ01'.

    check it_alv_data-werks is not initial.

    check it_alv_data-matnr is not initial.

    check it_alv_data-plscn is not initial.

    perform display_mrp_list_ms05.

    • Start of addition: Rem# 127218

    when 'VDATU'.

    check it_alv_data-matnr is not initial.

    check it_alv_data-werks is not initial.

    perform display_source_list_me03.

    • End of addition: Rem# 127218

    when others.

    message i006(zenh).

    endcase.

    when others.

    endcase.

    endform. "user_command

    &----


    *& Form display_material_mm03

    &----


    • Display the Material ( MRP2 Screen)

    ----


    FORM display_material_mm03 .

    clear it_bdc.

    refresh it_bdc.

    PERFORM populate_bdc_data USING 'X' 'SAPLMGMM' '0060'.

    PERFORM populate_bdc_data USING space 'BDC_OKCODE'

    '/00'.

    PERFORM populate_bdc_data USING space 'RMMG1-MATNR'

    it_alv_data-matnr.

    PERFORM populate_bdc_data USING 'X' 'SAPLMGMM' '0070'.

    PERFORM populate_bdc_data USING space 'BDC_OKCODE'

    '=ENTR'.

    PERFORM populate_bdc_data USING space 'MSICHTAUSW-KZSEL(14)'

    'X'.

    PERFORM populate_bdc_data USING 'X' 'SAPLMGMM' '0080'.

    PERFORM populate_bdc_data USING space 'BDC_OKCODE'

    '=ENTR'.

    PERFORM populate_bdc_data USING space 'RMMG1-WERKS'

    it_alv_data-werks.

    CALL TRANSACTION 'MM03' USING it_bdc MODE 'E'.

    CLEAR it_bdc.

    REFRESH it_bdc.

    ENDFORM. " display_material_mm03

    &----


    *& Form populate_bdc_data

    &----


    • Populating Data into BDC table

    ----


    FORM populate_bdc_data USING value(p_0860) TYPE c

    value(p_0861) TYPE c

    value(p_0862) TYPE c.

    IF p_0860 = c_xflag_alv_flg.

    it_bdc-dynbegin = p_0860.

    it_bdc-program = p_0861.

    it_bdc-dynpro = p_0862.

    ELSE.

    it_bdc-fnam = p_0861.

    it_bdc-fval = p_0862.

    ENDIF.

    APPEND it_bdc.

    CLEAR it_bdc.

    ENDFORM. " populate_bdc_data

    &----


    *& Form set_screen

    &----


    • Change the Selection screen : Demand date to Display only

    ----


    FORM set_screen .

    loop at SCREEN.

    if SCREEN-NAME = 'S_DDATE-LOW' or SCREEN-NAME = 'S_DDATE-HIGH'.

    SCREEN-INPUT = 0.

    endif.

    modify SCREEN.

    endloop.

    ENDFORM. " set_screen

    &----


    *& Form validate_screen

    &----


    • Validate selection screen

    ----


    FORM validate_screen .

    • Validate material number

    clear mara.

    if not s_matnr[] is initial.

    select matnr from mara up to 1 rows

    into mara-matnr where matnr in s_matnr. "#EC CI_SUBRC

    endselect.

    if sy-subrc ne 0.

    message e998 with 'Invalid Material no...'(053).

    endif.

    endif.

    • Validate plant

    clear t001w.

    if not s_werks[] is initial.

    select werks from t001w up to 1 rows

    into t001w-werks where werks in s_werks. "#EC CI_SUBRC

    endselect.

    if sy-subrc ne 0.

    message e998 with 'Invalid Plant...'(055).

    endif.

    endif.

    • Validate Purchasing group

    clear t024.

    if not s_ekgrp[] is initial.

    select ekgrp from t024 up to 1 rows

    into t024-ekgrp where ekgrp in s_ekgrp. "#EC CI_SUBRC

    endselect.

    if sy-subrc ne 0.

    message e998 with 'Invalid Purchasing Group...'(056).

    endif.

    endif.

    • Validate Currency

    clear tcurr.

    if not p_waers is initial.

    select tcurr from tcurr up to 1 rows

    into tcurr-tcurr where tcurr = p_waers. "#EC CI_SUBRC

    endselect.

    if sy-subrc ne 0.

    message e998 with 'Currency not maintained in Table...'(054).

    endif.

    endif.

    • Start of addition: Rem# 127218

    • Validate Planning Scenario.

    clear plsc.

    if not p_plscn is initial.

    select plscn from plsc up to 1 rows

    into plsc-plscn where plscn = p_plscn. "#EC CI_SGLSELECT

    "#EC CI_SUBRC

    endselect.

    if sy-subrc ne 0.

    message e998 with 'Invalid Planning Scenario...'(057).

    endif.

    endif.

    • Validate PO doc. type

    clear t161.

    if not s_bsart[] is initial.

    select bsart from t161 up to 1 rows

    into t161-bsart where bsart in s_bsart. "#EC CI_SGLSELECT

    "#EC CI_SUBRC

    endselect.

    if sy-subrc ne 0.

    message e998 with 'Invalid Document type...'(058).

    endif.

    endif.

    • End of addition: Rem# 127218

    ENDFORM. " validate_screen

    &----


    *& Form display_vendor_xk03

    &----


    • Display Vendor Details through XK03

    ----


    FORM display_vendor_xk03 .

    clear: it_bdc,

    it_lfa1.

    refresh it_bdc.

    read table it_lfa1 with key name1 = it_alv_data-name1.

    check it_lfa1-lifnr is not initial.

    check it_alv_data-ekorg is not initial.

    check it_alv_data-bukrs is not initial.

    PERFORM populate_bdc_data USING 'X' 'SAPMF02K' '0101'.

    PERFORM populate_bdc_data USING space 'BDC_OKCODE'

    '/00'.

    PERFORM populate_bdc_data USING space 'RF02K-LIFNR'

    it_lfa1-lifnr.

    PERFORM populate_bdc_data USING space 'RF02K-BUKRS'

    it_alv_data-bukrs.

    PERFORM populate_bdc_data USING space 'RF02K-EKORG'

    it_alv_data-ekorg.

    PERFORM populate_bdc_data USING space 'RF02K-D0110' 'X'.

    PERFORM populate_bdc_data USING space 'RF02K-D0120' 'X'.

    PERFORM populate_bdc_data USING space 'RF02K-D0130' 'X'.

    PERFORM populate_bdc_data USING space 'RF02K-D0210' 'X'.

    PERFORM populate_bdc_data USING space 'RF02K-D0215' 'X'.

    PERFORM populate_bdc_data USING space 'RF02K-D0220' 'X'.

    PERFORM populate_bdc_data USING space 'RF02K-D0310' 'X'.

    PERFORM populate_bdc_data USING space 'WRF02K-D0320' 'X'.

    CALL TRANSACTION 'XK03' USING it_bdc MODE 'E'.

    ENDFORM. " display_vendor_xk03

    &----


    *& Form display_scheduling_agreements

    &----


    • Display the scheduling agreements

    ----


    FORM display_scheduling_agreements .

    clear: it_bdc.

    refresh it_bdc.

    PERFORM populate_bdc_data USING 'X' 'SAPMM06E' '0205'.

    PERFORM populate_bdc_data USING space 'BDC_OKCODE'

    '/00'.

    PERFORM populate_bdc_data USING space 'RM06E-EVRTN'

    it_alv_data-ebeln.

    CALL TRANSACTION 'ME33L' USING it_bdc MODE 'E'.

    ENDFORM. " display_scheduling_agreements

    &----


    *& Form display_mrp_list_ms05

    &----


    • Display MRP list : Long term planning with MS05

    ----


    FORM display_mrp_list_ms05 .

    clear: it_bdc.

    refresh it_bdc.

    PERFORM populate_bdc_data USING 'X' 'SAPMM61R' '0600'.

    PERFORM populate_bdc_data USING space 'BDC_OKCODE'

    '=ENTR'.

    PERFORM populate_bdc_data USING space 'RM61R-PLSCN'

    it_alv_data-plscn.

    PERFORM populate_bdc_data USING space 'RM61R-MATNR'

    it_alv_data-matnr.

    PERFORM populate_bdc_data USING space 'RM61R-WERKS'

    it_alv_data-werks.

    CALL TRANSACTION 'MS05' USING it_bdc MODE 'E'.

    ENDFORM. " display_mrp_list_ms05

    &----


    *& Form initialize_doc_type

    &----


    • Initialize Document type to ZK & LP

    ----


    FORM initialize_doc_type .

    constants: lc_i type c value 'I',

    lc_eq(2) type c value 'EQ',

    lc_zk(2) type c value 'ZK',

    lc_lp(2) type c value 'LP'.

    s_bsart-sign = lc_i.

    s_bsart-option = lc_eq.

    s_bsart-low = lc_zk.

    append s_bsart.

    clear s_bsart.

    s_bsart-sign = lc_i.

    s_bsart-option = lc_eq.

    s_bsart-low = lc_lp.

    append s_bsart.

    clear s_bsart.

    ENDFORM. " initialize_doc_type

    • Start of addition: Rem# 127218

    &----


    *& Form display_source_list_me03

    &----


    • Display Source List Data

    ----


    FORM display_source_list_me03 .

    set parameter id 'MAT' field it_alv_data-matnr.

    set parameter id 'WRK' field it_alv_data-werks.

    call transaction 'ME03' and skip first screen.

    ENDFORM. " display_source_list_me03

    • End of addition: Rem# 127218

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 17, 2007 at 12:50 PM

    Hi Kannan,

    The report in SAP BALVSD03 is a very simple sample how to that includes the field catalog.

    You can also go and look under development class/package SLIS with many many sample programs of how to use ALV from very simple to seriously complex.

    Hope this will help you as it did help me allot.

    Regards,

    Marius

    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.