Skip to Content
avatar image
Former Member

ALv

Hi,

How to use interactive ALV.Kindly send me some sample code.

Regards,

Sankar.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

6 Answers

  • avatar image
    Former Member
    Aug 16, 2007 at 03:41 PM

    Hi find the below code,

    report ZALV_INTERACTIVE .

    tables : lfa1,ekko,ekpo.

    select-options : vendor for lfa1-lifnr.

    data : begin of itab occurs 0,

    lifnr like lfa1-lifnr,

    name1 like lfa1-name1,

    end of itab.

    data : begin of jtab occurs 0,

    ebeln like ekko-ebeln,

    aedat like ekko-aedat,

    end of jtab.

    data : begin of ktab occurs 0,

    ebelp like ekpo-ebelp,

    matnr like ekpo-matnr,

    end of ktab.

    type-pools : slis.

    data : repid like sy-repid.

    data :lfa1_b type slis_t_fieldcat_alv,

    lfa1_w type slis_fieldcat_alv,

    ekko_b type slis_t_fieldcat_alv,

    ekko_w type slis_fieldcat_alv,

    ekpo_b type slis_t_fieldcat_alv,

    ekpo_w type slis_fieldcat_alv,

    events_b type slis_t_event,

    events_w type slis_alv_event.

    perform get_val.

    repid = sy-repid.

    select lifnr name1 from lfa1 into table itab where lifnr in vendor.

    *perform val USING USER_COMMAND sel.

    call function 'REUSE_ALV_LIST_DISPLAY'

    exporting

    i_callback_program = repid

    it_fieldcat = lfa1_b

    it_events = events_b

    tables

    t_outtab = itab.

    &----


    *& Form GET_VAL

    &----


    • text this is to put column headings

    ----


    form get_val.

    lfa1_w-fieldname = 'LIFNR'.

    lfa1_w-ref_tabname = 'LFA1'.

    lfa1_w-ref_fieldname = 'LIFNR'.

    append lfa1_w to lfa1_b.

    lfa1_w-fieldname = 'NAME1'.

    lfa1_w-ref_tabname = 'LFA1'.

    lfa1_w-ref_fieldname = 'NAME1'.

    append lfa1_w to lfa1_b.

    ekko_w-fieldname = 'EBELN'.

    ekko_w-ref_tabname = 'EKKO'.

    ekko_w-ref_fieldname = 'EBELN'.

    append ekko_w to ekko_b.

    ekko_w-fieldname = 'AEDAT'.

    ekko_w-ref_tabname = 'EKKO'.

    ekko_w-ref_fieldname = 'AEDAT'.

    append ekko_w to ekko_b.

    ekpo_w-fieldname = 'EBELP'.

    ekpo_w-ref_tabname = 'EKPO'.

    ekpo_w-ref_fieldname = 'EBELP'.

    append ekpo_w to ekpo_b.

    ekpo_w-fieldname = 'MATNR'.

    ekpo_w-ref_tabname = 'EKPO'.

    ekpo_w-ref_fieldname = 'MATNR'.

    append ekpo_w to ekpo_b.

    events_w-name = 'USER_COMMAND'.

    events_w-form = 'VAL'.

    append events_w to events_b.

    endform. "GET_VAL

    &----


    *& Form VAL

    &----


    • text

    ----


    • -->USER_COMMANtext

    • -->SEL text for retrieving data

    ----


    form val using user_command like sy-ucomm sel type slis_selfield.

    data : ven(10) type n,

    po(10) type n.

    data : mat(10) type c.

    if sel-fieldname = 'LIFNR'.

    ven = sel-value.

    select ebeln aedat from ekko into table jtab where lifnr = ven.

    call function 'REUSE_ALV_LIST_DISPLAY'

    exporting

    i_callback_program = repid

    • I_STRUCTURE_NAME = EKKO_B

    it_fieldcat = ekko_b

    it_events = events_b

    tables

    t_outtab = jtab.

    endif.

    if sel-fieldname = 'EBELN'.

    po = sel-value.

    select ebelp matnr from ekpo into table ktab where ebeln = po.

    call function 'REUSE_ALV_POPUP_TO_SELECT'

    exporting

    i_title = 'ITEM DETAILS'

    i_tabname = 'EKPO'

    it_fieldcat = ekpo_b

    i_callback_program = repid

    importing

    es_selfield = sel

    tables

    t_outtab = ktab.

    endif.

    • logic to select a record

    if sel-fieldname = 'MATNR'.

    mat = sel-value.

    set parameter id 'MAT' field mat.

    call transaction 'MM02' and skip first screen.

    endif.

    endform. "VAL

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 16, 2007 at 10:49 AM

    Hi

    chk this one and reward points

    &----


    *& Report ZALV_FIELD_GRID1

    *&

    &----


    *&

    *&

    &----


    REPORT ZALV_FIELD_GRID1

    NO STANDARD PAGE HEADING.

    TABLES MARA.

    type-pools :slis.

    TYPES : BEGIN OF TMARA ,

    MATNR LIKE MARA-MATNR,

    MEINS LIKE MARA-MEINS,

    ERSDA LIKE MARA-ERSDA,

    color(4) type c,

    SEL type c,

    LIGHT TYPE C,

    END OF TMARA.

    TYPES: BEGIN OF TMAKT,

    MATNR LIKE MAKT-MATNR,

    MAKTX LIKE MAKT-MAKTX,

    MAKTG LIKE MAKT-MAKTG,

    SEL TYPE C,

    COLOR(4),

    END OF TMAKT.

    DATA: ITAB TYPE TMARA OCCURS 0 WITH HEADER LINE,

    ITAB1 TYPE TMAKT OCCURS 0 WITH HEADER LINE,

    wa_fieldcat type slis_fieldcat_alv,

    fieldcat type slis_fieldcat_alv occurs 0,

    i_layout type slis_layout_alv,

    WA_LISTHEADER TYPE SLIS_LISTHEADER,

    i_LISTHEADER TYPE SLIS_LISTHEADER OCCURS 0,

    V_EVENTS TYPE SLIS_T_EVENT ,

    WA_EVENT TYPE SLIS_ALV_EVENT,

    I_TITLE_MARA TYPE LVC_TITLE VALUE 'FIRST LIST DISPLAYED',

    I_TITLE_MAKT TYPE LVC_TITLE VALUE 'SECONDRY LIST DISPLAYED',

    SORT TYPE slis_t_sortinfo_alv WITH HEADER LINE,

    PRINT_CONT type slis_print_alv.

    *----


    • SELECTION SCREE

    *----


    selection-screen begin of block screen1 with frame title TEXT-001.

    SELECTION-SCREEN SKIP.

    SELECTION-SCREEN COMMENT /32(35) COMM1.

    SELECTION-SCREEN ULINE /27(35).

    SELECTION-SCREEN SKIP.

    SELECT-OPTIONS MATNR FOR MARA-MATNR.

    SELECTION-SCREEN SKIP.

    SELECTION-SCREEN ULINE.

    SELECTION-SCREEN COMMENT /30(50) COMM2.

    SELECTION-SCREEN ULINE /27(40).

    SELECTION-SCREEN SKIP.

    SELECT-OPTIONS ERSDA FOR MARA-ERSDA.

    SELECTION-SCREEN SKIP.

    selection-screen end of block screen1.

    *----


    • INITIALIZATION

    *----


    INITIALIZATION.

    MATNR-low = '23'.

    MATNR-high = '1000'.

    MATNR-option = 'BT'.

    MATNR-sign = 'I'.

    APPEND MATNR.

    ERSDA-low = '20030124'.

    ERSDA-high = '20050302' .

    APPEND ERSDA.

    PERFORM FILLFIELD.

    PERFORM FILLLAYOUT.

    PERFORM build_print_params.

    PERFORM FILL_SORT.

    PERFORM EVENT_CALL.

    PERFORM POPULATE_EVENT.

    *----


    • SELECTION-SCREEN OUTPUT

    *----


    AT SELECTION-SCREEN OUTPUT.

    comm1 ='SELECT MATERIAL NUMBER RANGE'.

    comm2 ='SELECT MATERIAL CREATION DATE'.

    *----


    • START-OF-SELECTION

    *----


    START-OF-SELECTION.

    PERFORM READDATA.

    PERFORM POPDATA.

    &----


    *& Form READDATA

    &----


    • text

    ----


    FORM READDATA .

    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

    EXPORTING

    INPUT = MATNR-LOW

    IMPORTING

    OUTPUT = MATNR-LOW.

    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

    EXPORTING

    INPUT = MATNR-HIGH

    IMPORTING

    OUTPUT = MATNR-HIGH.

    SELECT MATNR

    ERSDA

    MEINS

    FROM MARA

    INTO CORRESPONDING FIELDS OF

    TABLE ITAB

    WHERE MATNR IN MATNR AND ERSDA IN ERSDA.

    LOOP AT ITAB.

    data id_color type i VALUE 1.

    data id_colors(2) type c.

    IF ITAB-MATNR < '000000000000000100'.

    ITAB-LIGHT = '1'.

    ELSEIF ITAB-MATNR < '000000000000000150' AND ITAB-MATNR >

    '000000000000000100' .

    ITAB-LIGHT = '2'.

    ELSE.

    ITAB-LIGHT = '3'.

    ENDIF.

    id_color = id_color + 1.

    if id_color > 7.

    id_color = 1.

    endif.

    id_colors = id_color.

    concatenate 'C' id_colors '10' into itab-color.

    modify itab.

    CLEAR ITAB.

    endloop.

    ENDFORM. " READDATA

    ----


    • Form FILLFIELD

    ----


    FORM FILLFIELD .

    WA_FIELDCAT-FIELDNAME = 'MATNR'.

    WA_FIELDCAT-KEY = 'X'.

    WA_FIELDCAT-COL_POS = '1'.

    WA_FIELDCAT-outputlen = 20.

    WA_FIELDCAT-HOTSPOT = 'X'.

    wa_fieldcat-seltext_m = 'MATERIAL NUMBER'.

    *WA_FIELDCAT-EMPHASIZE = 'C210'.

    APPEND WA_FIELDCAT TO FIELDCAT.

    clear wa_fieldcat.

    WA_FIELDCAT-FIELDNAME = 'MEINS'.

    WA_FIELDCAT-COL_POS = '2'.

    *WA_FIELDCAT-EMPHASIZE = 'C510'.

    WA_FIELDCAT-outputlen = 10.

    wa_fieldcat-seltext_m = 'UNIT'.

    APPEND WA_FIELDCAT TO FIELDCAT.

    clear wa_fieldcat.

    WA_FIELDCAT-FIELDNAME = 'ERSDA'.

    WA_FIELDCAT-COL_POS = '3'.

    WA_FIELDCAT-outputlen = 15.

    *WA_FIELDCAT-EDIT_MASK = 'DD.MM.YYYY'.

    *WA_FIELDCAT-EMPHASIZE = 'C710'.

    wa_fieldcat-seltext_m = 'CREAT DATE'.

    APPEND WA_FIELDCAT TO FIELDCAT.

    clear wa_fieldcat.

    ENDFORM. "FILLFIELD

    &----


    • Setup print parameters

    ----


    form build_print_params.

    PRINT_CONT-reserve_lines = '3'. "Lines reserved for footer

    PRINT_CONT-no_coverpage = 'X'.

    endform. " BUILD_PRINT_PARAMS

    ----


    • Form POPDATA

    ----


    FORM POPDATA .

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    • I_INTERFACE_CHECK = ' '

    • I_BYPASSING_BUFFER = ' '

    • I_BUFFER_ACTIVE = ' '

    I_CALLBACK_PROGRAM = sy-repid

    • I_CALLBACK_PF_STATUS_SET = ' '

    I_CALLBACK_USER_COMMAND = 'USER-COMMAND'

    I_CALLBACK_TOP_OF_PAGE = 'TOPPAGE'

    • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

    • I_CALLBACK_HTML_END_OF_LIST = ' '

    • I_STRUCTURE_NAME =

    • I_BACKGROUND_ID = ' '

    I_GRID_TITLE = I_TITLE_MARA

    • I_GRID_SETTINGS =

    IS_LAYOUT = I_LAYOUT

    IT_FIELDCAT = fieldcat

    • IT_EXCLUDING =

    • IT_SPECIAL_GROUPS =

    IT_SORT = SORT[]

    • IT_FILTER =

    • IS_SEL_HIDE =

    • I_DEFAULT = 'X'

    • I_SAVE = ' '

    • IS_VARIANT =

    IT_EVENTS = V_EVENTS

    • IT_EVENT_EXIT =

    IS_PRINT = PRINT_CONT

    TABLES

    T_OUTTAB = ITAB

    EXCEPTIONS

    PROGRAM_ERROR = 1

    OTHERS = 2

    .

    ENDFORM. " POPDATA

    ----


    • Form TOPPAGE

    ----


    FORM TOPPAGE.

    REFRESH I_LISTHEADER.

    DATA: ld_lines type i,

    ld_linesc(10) type c,

    I_DATE(10) TYPE C,

    I_INFO LIKE WA_LISTHEADER-INFO.

    WA_LISTHEADER-TYP = 'H'.

    WA_LISTHEADER-INFO = 'MATERIAL DETAIL'.

    APPEND WA_LISTHEADER TO I_LISTHEADER.

    CLEAR WA_LISTHEADER.

    WA_LISTHEADER-TYP = 'S'.

    WA_LISTHEADER-KEY = 'DATE :'.

    CONCATENATE SY-DATUM+6(2) '.'

    SY-DATUM+4(2) '.'

    SY-DATUM(4) INTO I_DATE.

    WA_LISTHEADER-INFO = I_datE.

    APPEND WA_LISTHEADER TO I_LISTHEADER.

    CLEAR WA_LISTHEADER.

    describe table ITAB lines ld_lines.

    ld_linesc = ld_lines.

    concatenate 'TOTAL NUMBER OF RECORD SELECTED: ' ld_linesc

    into I_INFO separated by space.

    WA_LISTHEADER-TYP = 'A'.

    WA_LISTHEADER-INFO = I_INFO.

    append WA_LISTHEADER to I_LISTHEADER.

    clear: WA_LISTHEADER , I_INFO.

    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

    EXPORTING

    IT_LIST_COMMENTARY = I_LISTHEADER

    I_LOGO = 'ENJOYSAP_LOGO'.

    ENDFORM. "TOPPAGE

    ----


    • Form FILLLAYOUT

    ----


    FORM FILLLAYOUT .

    i_layout-zebra = 'X'.

    i_layout-info_fieldname = 'COLOR'.

    i_layout-box_fieldname = 'SEL'.

    I_LAYOUT-lights_fieldname = 'LIGHT'.

    I_LAYOUT-EDIT ='X'.

    I_LAYOUT-colwidth_optimize = 'X'.

    I_LAYOUT-window_titlebar = 'EXAMPLE FOR ALV GRID'.

    I_LAYOUT-no_totalline = 'X'.

    ENDFORM. "FILLLAYOUT

    ----


    • Form FILL_SORT

    ----


    FORM FILL_SORT .

    SORT-DOWN = 'X'.

    SORT-SPOS = 1.

    SORT-FIELDNAME = 'MATNR'.

    SORT-tabname = 'MARA'.

    APPEND SORT.

    ENDFORM. " FILL_SORT

    ----


    • Form EVENT_CALL

    ----


    FORM EVENT_CALL .

    DATA: I_EVENT LIKE V_EVENTS.

    CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

    EXPORTING

    I_LIST_TYPE = 0

    IMPORTING

    ET_EVENTS = V_EVENTS.

    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. " EVENT_CALL

    ----


    • Form POPULATE_EVENT

    ----


    FORM POPULATE_EVENT .

    READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'USER_COMMAND'.

    IF SY-SUBRC EQ 0.

    WA_EVENT-FORM = 'USER_COMMAND'.

    MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =

    WA_EVENT-NAME.

    READ TABLE V_EVENTS WITH KEY NAME = SLIS_EV_END_OF_PAGE

    INTO WA_EVENT.

    IF SY-SUBRC = 0.

    move 'END_OF_PAGE' to WA_EVENT-FORM.

    MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =

    WA_EVENT-NAME.

    endif.

    ENDIF.

    ENDFORM. "POPULATE_EVENT

    *----


    FORM END_OF_PAGE.

    write: sy-uline(50).

    skip.

    write:/40 'Page:', sy-pagno .

    ENDFORM.

    &----


    *& Form USER_COMMAND

    ----


    FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM

    RS_SELFIELD TYPE SLIS_SELFIELD.

    CASE R_UCOMM.

    WHEN '&IC1'.

    CASE RS_SELFIELD-FIELDNAME.

    when 'MATNR'.

    read table itab with key matnr = RS_SELFIELD-VALUE.

    if sy-subrc = 0.

    PERFORM DATA_RETRIEVAL_MAKT USING RS_SELFIELD-VALUE.

    PERFORM BUILD_FIELDCATLOG_MAKT.

    PERFORM FILLLAYOUT_MAKT.

    PERFORM DISPLAY_ALV_MAKT.

    CLEAR RS_SELFIELD.

    ENDIF.

    ENDCASE.

    ENDCASE.

    ENDFORM. "user_command

    ----


    • Form DATA_RETRIEVAL_MAKT

    ----


    FORM DATA_RETRIEVAL_MAKT USING TMATNR .

    SELECT MATNR

    MAKTX

    MAKTG

    UP TO 100 ROWS

    FROM MAKT

    INTO TABLE ITAB1

    WHERE SPRAS = 'EN' AND MATNR = TMATNR.

    LOOP AT ITAB1.

    data id_color type i VALUE 1.

    data id_colors(2) type c.

    id_color = id_color + 1.

    if id_color > 7.

    id_color = 1.

    endif.

    id_colors = id_color.

    concatenate 'C' id_colors '10' into itab1-color.

    modify itab1.

    CLEAR ITAB1.

    ENDLOOP.

    ENDFORM. "DATA_RETRIEVAL_MAKT

    ----


    • Form FILLLAYOUT_MAKT

    ----


    FORM FILLLAYOUT_MAKT .

    CLEAR I_LAYOUT.

    i_layout-zebra = 'X'.

    i_layout-info_fieldname = 'COLOR'.

    i_layout-box_fieldname = 'SEL'.

    I_LAYOUT-EDIT ='X'.

    I_LAYOUT-colwidth_optimize = 'X'.

    I_LAYOUT-window_titlebar = 'EXAMPLE FOR ALV GRID'.

    ENDFORM. " LAYOUT_MAKT

    ----


    • Form BUILD_FIELDCATLOG_MAKT

    ----


    FORM BUILD_FIELDCATLOG_MAKT .

    REFRESH FIELDCAT.

    WA_FIELDCAT-FIELDNAME = 'MATNR'.

    WA_FIELDCAT-KEY = 'X'.

    WA_FIELDCAT-COL_POS = '1'.

    *WA_FIELDCAT-EDIT_MASK = 'DD.MM.YYYY'.

    WA_FIELDCAT-EMPHASIZE = 'C510'.

    wa_fieldcat-seltext_m = 'MATERIAL NUMBER'.

    APPEND WA_FIELDCAT TO FIELDCAT.

    clear wa_fieldcat.

    WA_FIELDCAT-FIELDNAME = 'MAKTX'.

    WA_FIELDCAT-COL_POS = '2'.

    WA_FIELDCAT-EMPHASIZE = 'C710'.

    wa_fieldcat-seltext_m = 'MATERIAL DESCRIPTION'.

    APPEND WA_FIELDCAT TO FIELDCAT.

    clear wa_fieldcat.

    WA_FIELDCAT-FIELDNAME = 'MAKTG'.

    WA_FIELDCAT-COL_POS = '3'.

    WA_FIELDCAT-EMPHASIZE = 'C210'.

    wa_fieldcat-seltext_m = 'MATERIAL DESCRIPTION'.

    APPEND WA_FIELDCAT TO FIELDCAT.

    clear wa_fieldcat.

    ENDFORM. " BUILD_FIELDCATLOG_MAKT

    ----


    • Form DISPLAY_ALV_MAKT

    ----


    FORM TOP-OF-PAGE.

    REFRESH I_LISTHEADER.

    DATA: ld_lines type i,

    ld_linesc(10) type c,

    I_DATE(10) TYPE C,

    I_INFO LIKE WA_LISTHEADER-INFO.

    WA_LISTHEADER-TYP = 'H'.

    WA_LISTHEADER-INFO = 'MATERIAL DESCRIPTION FOR SELECTED NUMBER'.

    APPEND WA_LISTHEADER TO I_LISTHEADER.

    CLEAR WA_LISTHEADER.

    WA_LISTHEADER-TYP = 'S'.

    WA_LISTHEADER-KEY = 'DATE :'.

    CONCATENATE SY-DATUM+6(2) '.'

    SY-DATUM+4(2) '.'

    SY-DATUM(4) INTO I_DATE.

    WA_LISTHEADER-INFO = I_datE.

    APPEND WA_LISTHEADER TO I_LISTHEADER.

    CLEAR WA_LISTHEADER.

    describe table ITAB1 lines ld_lines.

    ld_linesc = ld_lines.

    concatenate 'TOTAL NUMBER OF RECORD SELECTED: ' ld_linesc

    into I_INFO separated by space.

    WA_LISTHEADER-TYP = 'A'.

    WA_LISTHEADER-INFO = I_INFO.

    append WA_LISTHEADER to I_LISTHEADER.

    clear: WA_LISTHEADER , I_INFO.

    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

    EXPORTING

    IT_LIST_COMMENTARY = I_LISTHEADER

    I_LOGO = 'ENJOYSAP_LOGO'.

    • I_END_OF_LIST_GRID =

    • I_ALV_FORM =

    ENDFORM. "TOP-OF-PAGE

    &----


    *& Form DISPLAY_ALV_MAKT

    &----


    • text

    ----


    FORM DISPLAY_ALV_MAKT .

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    I_CALLBACK_PROGRAM = SY-REPID

    I_CALLBACK_TOP_OF_PAGE = 'TOP-OF-PAGE'

    I_GRID_TITLE = I_TITLE_MAKT

    IS_LAYOUT = I_LAYOUT

    IT_FIELDCAT = fieldcat

    TABLES

    T_OUTTAB = ITAB1

    EXCEPTIONS

    PROGRAM_ERROR = 1

    OTHERS = 2.

    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. " DISPLAY_ALV_MAKT

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 16, 2007 at 10:50 AM

    Hi!

    Use the comand USER_COMMAND

    see the sample example

    report yh645_secndry_alv.

    type-pools: slis.

    data: fieldcat type slis_t_fieldcat_alv,

    fieldcat_ln like line of fieldcat,

    fs_layout type slis_layout_alv,

    t_layoout like standard table

    of fs_layout.

    data: begin of fs_spfli,

    carrid type spfli-carrid,

    connid type spfli-connid,

    countryfr type spfli-countryfr,

    cityfrom type spfli-cityfrom,

    airpfrom type spfli-airpfrom,

    countryto type spfli-countryto,

    cityto type spfli-cityto,

    airpto type spfli-airpto,

    fltime type spfli-fltime,

    deptime type spfli-deptime,

    arrtime type spfli-arrtime,

    distance type spfli-distance,

    distid type spfli-distid,

    fltype type spfli-fltype,

    period type spfli-period,

    checkbox,

    color(3),

    end of fs_spfli.

    data:

    begin of fs_table,

    carrid type spfli-carrid,

    connid type spfli-connid,

    end of fs_table.

    data: begin of fs_sflight,

    check,

    color(3).

    include type sflight.

    data:end of fs_sflight.

    data:

    begin of fs_table1,

    carrid type sflight-carrid,

    connid type sflight-connid,

    fldate type sflight-fldate,

    end of fs_table1.

    data:

    t_spfli like standard table

    of fs_spfli.

    data:

    t_table like standard table

    of fs_table.

    data:

    t_table1 like standard table

    of fs_table1.

    data:

    t_sflight like standard table

    of fs_sflight.

    data:

    t_sbook like standard table

    of sbook.

    data t_layout type slis_layout_alv.

    select *

    into corresponding fields of table t_spfli

    from spfli.

    perform start_list_viewer.

    perform get_spfli_details.

    *&----


    *

    *& Form SUB1

    *&----


    *

    • text

    *----


    *

    • -->RT_EXTAB text

    *----


    *

    form sub1 using rt_extab type slis_t_extab.

    data: flight type slis_extab.

    flight-fcode = 'SFLIGHT'.

    append flight to rt_extab.

    set pf-status 'SFLIGHT'. " EXCLUDING RT_EXTAB.

    endform. "SUB1

    *&----


    *

    *& Form START_LIST_VIEWER

    *&----


    *

    • text

    *----


    *

    • --> p1 text

    • <-- p2 text

    *----


    *

    form start_list_viewer .

    data: pgm like sy-repid.

    pgm = sy-repid.

    fs_layout-box_fieldname = 'CHECKBOX'.

    fs_layout-info_fieldname = 'COLOR'.

    call function 'REUSE_ALV_LIST_DISPLAY'

    exporting

    i_callback_program = pgm

    i_callback_pf_status_set = 'SUB1'

    i_callback_user_command = 'USER_COMMAND'

    i_structure_name = 'SPFLI'

    is_layout = fs_layout

    tables

    t_outtab = t_spfli

    exceptions

    program_error = 1

    others = 2.

    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. " START_LIST_VIEWER

    *******Process Call Back Events (Begin)**************************

    form user_command using ucomm like sy-ucomm

    selfield type slis_selfield.

    case ucomm.

    when 'SFLIGHT'.

    selfield-refresh = 'X'.

    perform get_spfli_details.

    select *

    from sflight

    into corresponding fields of table t_sflight

    for all entries in t_table

    where carrid eq t_table-carrid

    and connid eq t_table-connid.

    perform display_sflight.

    when 'SBOOK'.

    selfield-refresh = 'X'.

    perform get_sflight_details.

    select *

    from sbook

    into corresponding fields of table t_sbook

    for all entries in t_table1

    where carrid eq t_table1-carrid

    and connid eq t_table1-connid

    and fldate eq t_table1-fldate.

    perform display_sbook.

    endcase.

    endform. "USER_COMMAND

    *&----


    *

    *& Form SUB2

    *&----


    *

    • text

    *----


    *

    • -->RT_EXTAB text

    *----


    *

    form sub2 using rt_extab type slis_t_extab.

    data: flight type slis_extab.

    flight-fcode = 'SBOOK'.

    append flight to rt_extab.

    set pf-status 'SBOOK'. " EXCLUDING RT_EXTAB.

    endform. "SUB2

    *&----


    *

    *& Form DISPLAY_SFLIGHT

    *&----


    *

    • text

    *----


    *

    • --> p1 text

    • <-- p2 text

    *----


    *

    form display_sflight .

    data: pgm like sy-repid.

    pgm = sy-repid.

    clear t_layout.

    fs_layout-box_fieldname = 'CHECK'.

    fs_layout-info_fieldname = 'COLOR'.

    call function 'REUSE_ALV_LIST_DISPLAY'

    exporting

    i_callback_program = pgm

    i_callback_pf_status_set = 'SUB2'

    i_callback_user_command = 'USER_COMMAND'

    i_structure_name = 'SFLIGHT'

    is_layout = fs_layout

    tables

    t_outtab = t_sflight

    exceptions

    program_error = 1

    others = 2.

    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. " DISPLAY_SFLIGHT

    *&----


    *

    *& Form GET_SPFLI_DETAILS

    *&----


    *

    • text

    *----


    *

    • --> p1 text

    • <-- p2 text

    *----


    *

    form get_spfli_details .

    loop at t_spfli into fs_spfli.

    if fs_spfli-checkbox = 'X'.

    fs_spfli-color = 'C51'.

    fs_spfli-checkbox = '1'.

    fs_table-carrid = fs_spfli-carrid.

    fs_table-connid = fs_spfli-connid.

    append fs_table to t_table.

    modify t_spfli from fs_spfli.

    endif.

    endloop.

    endform. " GET_SFLIGHT_DETAILS

    *&----


    *

    *& Form GET_SFLIGHT_DETAILS

    *&----


    *

    • text

    *----


    *

    • --> p1 text

    • <-- p2 text

    *----


    *

    form get_sflight_details .

    loop at t_sflight into fs_sflight.

    if fs_sflight-check = 'X'.

    fs_sflight-color = 'C71'.

    fs_sflight-check = '1'.

    fs_table1-carrid = fs_sflight-carrid.

    fs_table1-connid = fs_sflight-connid.

    fs_table1-fldate = fs_sflight-fldate.

    append fs_table1 to t_table1.

    modify t_sflight from fs_sflight.

    endif.

    endloop.

    endform. " GET_SFLIGHT_DETAILS

    *&----


    *

    *& Form DISPLAY_SBOOK

    *&----


    *

    • text

    *----


    *

    • --> p1 text

    • <-- p2 text

    *----


    *

    form display_sbook .

    data: pgm like sy-repid.

    pgm = sy-repid.

    call function 'REUSE_ALV_LIST_DISPLAY'

    exporting

    i_callback_program = pgm

    i_structure_name = 'SBOOK'

    tables

    t_outtab = t_sbook

    exceptions

    program_error = 1

    others = 2.

    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. " DISPLAY_SBOOK

    Regards

    Tamá

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 16, 2007 at 11:12 AM

    Hi sankar,

    Hope this will helps u

    An Interactive ALV Report

    &----


    *& Report ZZ_22038_22098_002 *

    *& *

    &----


    *& This is an Interactive ALV report, where on line slection we can see

    *& the secondry list

    *&

    *& *

    &----


    REPORT ZZ_22038_22098_002 NO STANDARD PAGE HEADING LINE-SIZE 650

    MESSAGE-ID ZZ_9838 .

    TYPE-POOLS: SLIS.

    *type declaration for values from ekko

    TYPES: BEGIN OF I_EKKO,

    EBELN LIKE EKKO-EBELN,

    AEDAT LIKE EKKO-AEDAT,

    BUKRS LIKE EKKO-BUKRS,

    BSART LIKE EKKO-BSART,

    LIFNR LIKE EKKO-LIFNR,

    END OF I_EKKO.

    DATA: IT_EKKO TYPE STANDARD TABLE OF I_EKKO INITIAL SIZE 0,

    WA_EKKO TYPE I_EKKO.

    *type declaration for values from ekpo

    TYPES: BEGIN OF I_EKPO,

    EBELN LIKE EKPO-EBELN,

    EBELP LIKE EKPO-EBELP,

    MATNR LIKE EKPO-MATNR,

    MENGE LIKE EKPO-MENGE,

    MEINS LIKE EKPO-MEINS,

    NETPR LIKE EKPO-NETPR,

    END OF I_EKPO.

    DATA: IT_EKPO TYPE STANDARD TABLE OF I_EKPO INITIAL SIZE 0,

    WA_EKPO TYPE I_EKPO .

    *variable for Report ID

    DATA: V_REPID LIKE SY-REPID .

    *declaration for fieldcatalog

    DATA: I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,

    WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.

    DATA: IT_LISTHEADER TYPE SLIS_T_LISTHEADER.

    • declaration for events table where user comand or set PF status will

    • be defined

    DATA: V_EVENTS TYPE SLIS_T_EVENT,

    WA_EVENT TYPE SLIS_ALV_EVENT.

    • declartion for layout

    DATA: ALV_LAYOUT TYPE SLIS_LAYOUT_ALV.

    • declaration for variant(type of display we want)

    DATA: I_VARIANT TYPE DISVARIANT,

    I_VARIANT1 TYPE DISVARIANT,

    I_SAVE(1) TYPE C.

    *PARAMETERS : p_var TYPE disvariant-variant.

    *Title displayed when the alv list is displayed

    DATA: I_TITLE_EKKO TYPE LVC_TITLE VALUE 'FIRST LIST DISPLAYED'.

    DATA: I_TITLE_EKPO TYPE LVC_TITLE VALUE 'SECONDRY LIST DISPLAYED'.

    INITIALIZATION.

    V_REPID = SY-REPID.

    PERFORM BUILD_FIELDCATLOG.

    PERFORM EVENT_CALL.

    PERFORM POPULATE_EVENT.

    START-OF-SELECTION.

    PERFORM DATA_RETRIEVAL.

    PERFORM BUILD_LISTHEADER USING IT_LISTHEADER.

    PERFORM DISPLAY_ALV_REPORT.

    &----


    *& Form BUILD_FIELDCATLOG

    &----


    • Fieldcatalog has all the field details from ekko

    ----


    FORM BUILD_FIELDCATLOG.

    WA_FIELDCAT-TABNAME = 'IT_EKKO'.

    WA_FIELDCAT-FIELDNAME = 'EBELN'.

    WA_FIELDCAT-SELTEXT_M = 'PO NO.'.

    APPEND WA_FIELDCAT TO I_FIELDCAT.

    CLEAR WA_FIELDCAT.

    WA_FIELDCAT-TABNAME = 'IT_EKKO'.

    WA_FIELDCAT-FIELDNAME = 'AEDAT'.

    WA_FIELDCAT-SELTEXT_M = 'DATE.'.

    APPEND WA_FIELDCAT TO I_FIELDCAT.

    CLEAR WA_FIELDCAT.

    WA_FIELDCAT-TABNAME = 'IT_EKKO'.

    WA_FIELDCAT-FIELDNAME = 'BUKRS'.

    WA_FIELDCAT-SELTEXT_M = 'COMPANY CODE'.

    APPEND WA_FIELDCAT TO I_FIELDCAT.

    CLEAR WA_FIELDCAT.

    WA_FIELDCAT-TABNAME = 'IT_EKKO'.

    WA_FIELDCAT-FIELDNAME = 'BUKRS'.

    WA_FIELDCAT-SELTEXT_M = 'DOCMENT TYPE'.

    APPEND WA_FIELDCAT TO I_FIELDCAT.

    CLEAR WA_FIELDCAT.

    WA_FIELDCAT-TABNAME = 'IT_EKKO'.

    WA_FIELDCAT-FIELDNAME = 'LIFNR'.

    WA_FIELDCAT-NO_OUT = 'X'.

    WA_FIELDCAT-SELTEXT_M = 'VENDOR CODE'.

    APPEND WA_FIELDCAT TO I_FIELDCAT.

    CLEAR WA_FIELDCAT.

    ENDFORM. "BUILD_FIELDCATLOG

    &----


    *& Form EVENT_CALL

    &----


    • we get all events - TOP OF PAGE or USER COMMAND in table v_events

    ----


    FORM EVENT_CALL.

    CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

    EXPORTING

    I_LIST_TYPE = 0

    IMPORTING

    ET_EVENTS = V_EVENTS

    • EXCEPTIONS

    • LIST_TYPE_WRONG = 1

    • OTHERS = 2

    .

    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. "EVENT_CALL

    &----


    *& Form POPULATE_EVENT

    &----


    • Events populated for TOP OF PAGE & USER COMAND

    ----


    FORM POPULATE_EVENT.

    READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.

    IF SY-SUBRC EQ 0.

    WA_EVENT-FORM = 'TOP_OF_PAGE'.

    MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =

    WA_EVENT-FORM.

    ENDIF.

    READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'USER_COMMAND'.

    IF SY-SUBRC EQ 0.

    WA_EVENT-FORM = 'USER_COMMAND'.

    MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =

    WA_EVENT-NAME.

    ENDIF.

    ENDFORM. "POPULATE_EVENT

    &----


    *& Form data_retrieval

    &----


    • retreiving values from the database table ekko

    ----


    FORM DATA_RETRIEVAL.

    SELECT EBELN AEDAT BUKRS BSART LIFNR FROM EKKO INTO TABLE IT_EKKO.

    ENDFORM. "data_retrieval

    &----


    *& Form bUild_listheader

    &----


    • text

    ----


    • -->I_LISTHEADEtext

    ----


    FORM BUILD_LISTHEADER USING I_LISTHEADER TYPE SLIS_T_LISTHEADER.

    DATA HLINE TYPE SLIS_LISTHEADER.

    HLINE-INFO = 'this is my first alv pgm'.

    HLINE-TYP = 'H'.

    ENDFORM. "build_listheader

    &----


    *& Form display_alv_report

    &----


    • text

    ----


    FORM DISPLAY_ALV_REPORT.

    V_REPID = SY-REPID.

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    I_CALLBACK_PROGRAM = V_REPID

    • I_CALLBACK_PF_STATUS_SET = ' '

    I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

    I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'

    I_GRID_TITLE = I_TITLE_EKKO

    • I_GRID_SETTINGS =

    • IS_LAYOUT = ALV_LAYOUT

    IT_FIELDCAT = I_FIELDCAT[]

    • IT_EXCLUDING =

    • IT_SPECIAL_GROUPS =

    • IT_SORT =

    • IT_FILTER =

    • IS_SEL_HIDE =

    • i_default = 'ZLAY1'

    I_SAVE = 'A'

    • is_variant = i_variant

    IT_EVENTS = V_EVENTS

    TABLES

    T_OUTTAB = IT_EKKO

    • EXCEPTIONS

    • PROGRAM_ERROR = 1

    • OTHERS = 2

    .

    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. "display_alv_report

    &----


    *& Form TOP_OF_PAGE

    &----


    • text

    ----


    FORM TOP_OF_PAGE.

    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

    EXPORTING

    IT_LIST_COMMENTARY = IT_LISTHEADER

    • i_logo =

    • I_END_OF_LIST_GRID =

    .

    ENDFORM. "TOP_OF_PAGE

    &----


    *& Form USER_COMMAND

    &----


    • text

    ----


    • -->R_UCOMM text

    • -->, text

    • -->RS_SLEFIELDtext

    ----


    FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM

    RS_SELFIELD TYPE SLIS_SELFIELD.

    CASE R_UCOMM.

    WHEN '&IC1'.

    READ TABLE IT_EKKO INTO WA_EKKO INDEX RS_SELFIELD-TABINDEX.

    PERFORM BUILD_FIELDCATLOG_EKPO.

    PERFORM EVENT_CALL_EKPO.

    PERFORM POPULATE_EVENT_EKPO.

    PERFORM DATA_RETRIEVAL_EKPO.

    PERFORM BUILD_LISTHEADER_EKPO USING IT_LISTHEADER.

    PERFORM DISPLAY_ALV_EKPO.

    ENDCASE.

    ENDFORM. "user_command

    &----


    *& Form BUILD_FIELDCATLOG_EKPO

    &----


    • text

    ----


    FORM BUILD_FIELDCATLOG_EKPO.

    WA_FIELDCAT-TABNAME = 'IT_EKPO'.

    WA_FIELDCAT-FIELDNAME = 'EBELN'.

    WA_FIELDCAT-SELTEXT_M = 'PO NO.'.

    APPEND WA_FIELDCAT TO I_FIELDCAT.

    CLEAR WA_FIELDCAT.

    WA_FIELDCAT-TABNAME = 'IT_EKPO'.

    WA_FIELDCAT-FIELDNAME = 'EBELP'.

    WA_FIELDCAT-SELTEXT_M = 'LINE NO'.

    APPEND WA_FIELDCAT TO I_FIELDCAT.

    CLEAR WA_FIELDCAT.

    WA_FIELDCAT-TABNAME = 'I_EKPO'.

    WA_FIELDCAT-FIELDNAME = 'MATNR'.

    WA_FIELDCAT-SELTEXT_M = 'MATERIAL NO.'.

    APPEND WA_FIELDCAT TO I_FIELDCAT.

    CLEAR WA_FIELDCAT.

    WA_FIELDCAT-TABNAME = 'I_EKPO'.

    WA_FIELDCAT-FIELDNAME = 'MENGE'.

    WA_FIELDCAT-SELTEXT_M = 'QUANTITY'.

    APPEND WA_FIELDCAT TO I_FIELDCAT.

    CLEAR WA_FIELDCAT.

    WA_FIELDCAT-TABNAME = 'I_EKPO'.

    WA_FIELDCAT-FIELDNAME = 'MEINS'.

    WA_FIELDCAT-SELTEXT_M = 'UOM'.

    APPEND WA_FIELDCAT TO I_FIELDCAT.

    CLEAR WA_FIELDCAT.

    WA_FIELDCAT-TABNAME = 'I_EKPO'.

    WA_FIELDCAT-FIELDNAME = 'NETPR'.

    WA_FIELDCAT-SELTEXT_M = 'PRICE'.

    APPEND WA_FIELDCAT TO I_FIELDCAT.

    CLEAR WA_FIELDCAT.

    ENDFORM. "BUILD_FIELDCATLOG_EKPO

    &----


    *& Form event_call_ekpo

    &----


    • we get all events - TOP OF PAGE or USER COMMAND in table v_events

    ----


    FORM EVENT_CALL_EKPO.

    CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

    EXPORTING

    I_LIST_TYPE = 0

    IMPORTING

    ET_EVENTS = V_EVENTS

    • EXCEPTIONS

    • LIST_TYPE_WRONG = 1

    • OTHERS = 2

    .

    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. "event_call_ekpo

    &----


    *& Form POPULATE_EVENT

    &----


    • Events populated for TOP OF PAGE & USER COMAND

    ----


    FORM POPULATE_EVENT_EKPO.

    READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.

    IF SY-SUBRC EQ 0.

    WA_EVENT-FORM = 'TOP_OF_PAGE'.

    MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =

    WA_EVENT-FORM.

    ENDIF.

    ENDFORM. "POPULATE_EVENT

    &----


    *& Form TOP_OF_PAGE

    &----


    • text

    ----


    FORM F_TOP_OF_PAGE.

    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

    EXPORTING

    IT_LIST_COMMENTARY = IT_LISTHEADER

    • i_logo =

    • I_END_OF_LIST_GRID =

    .

    ENDFORM. "TOP_OF_PAGE

    &----


    *& Form USER_COMMAND

    &----


    • text

    ----


    • -->R_UCOMM text

    • -->, text

    • -->RS_SLEFIELDtext

    ----


    *retreiving values from the database table ekko

    FORM DATA_RETRIEVAL_EKPO.

    SELECT EBELN EBELP MATNR MENGE MEINS NETPR FROM EKPO INTO TABLE IT_EKPO.

    ENDFORM.

    FORM BUILD_LISTHEADER_EKPO USING I_LISTHEADER TYPE SLIS_T_LISTHEADER.

    DATA: HLINE1 TYPE SLIS_LISTHEADER.

    HLINE1-TYP = 'H'.

    HLINE1-INFO = 'CHECKING PGM'.

    ENDFORM.

    FORM DISPLAY_ALV_EKPO.

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    • I_INTERFACE_CHECK = ' '

    • I_BYPASSING_BUFFER = ' '

    • I_BUFFER_ACTIVE = ' '

    I_CALLBACK_PROGRAM = V_REPID

    • I_CALLBACK_PF_STATUS_SET = ' '

    • I_CALLBACK_USER_COMMAND = 'F_USER_COMMAND'

    I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'

    • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

    • I_CALLBACK_HTML_END_OF_LIST = ' '

    • I_STRUCTURE_NAME =

    • I_BACKGROUND_ID = ' '

    I_GRID_TITLE = I_TITLE_EKPO

    • I_GRID_SETTINGS =

    • IS_LAYOUT =

    IT_FIELDCAT = I_FIELDCAT[]

    • IT_EXCLUDING =

    • IT_SPECIAL_GROUPS =

    • IT_SORT =

    • IT_FILTER =

    • IS_SEL_HIDE =

    • I_DEFAULT =

    I_SAVE = 'A'

    • IS_VARIANT =

    IT_EVENTS = V_EVENTS

    TABLES

    T_OUTTAB = IT_EKPO

    EXCEPTIONS

    PROGRAM_ERROR = 1

    OTHERS = 2

    .

    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.

    Reward points if helpful.

    Thanks

    Naveen khan

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 16, 2007 at 03:46 PM

    hi

    good

    &----


    *& Report ZZ_22038_22098_002 *

    *& *

    &----


    *& This is an Interactive ALV report, where on line slection we can see

    *& the secondry list

    *&

    *& *

    &----


    REPORT ZZ_22038_22098_002 NO STANDARD PAGE HEADING LINE-SIZE 650

    MESSAGE-ID ZZ_9838 .

    TYPE-POOLS: SLIS.

    *type declaration for values from ekko

    TYPES: BEGIN OF I_EKKO,

    EBELN LIKE EKKO-EBELN,

    AEDAT LIKE EKKO-AEDAT,

    BUKRS LIKE EKKO-BUKRS,

    BSART LIKE EKKO-BSART,

    LIFNR LIKE EKKO-LIFNR,

    END OF I_EKKO.

    DATA: IT_EKKO TYPE STANDARD TABLE OF I_EKKO INITIAL SIZE 0,

    WA_EKKO TYPE I_EKKO.

    *type declaration for values from ekpo

    TYPES: BEGIN OF I_EKPO,

    EBELN LIKE EKPO-EBELN,

    EBELP LIKE EKPO-EBELP,

    MATNR LIKE EKPO-MATNR,

    MENGE LIKE EKPO-MENGE,

    MEINS LIKE EKPO-MEINS,

    NETPR LIKE EKPO-NETPR,

    END OF I_EKPO.

    DATA: IT_EKPO TYPE STANDARD TABLE OF I_EKPO INITIAL SIZE 0,

    WA_EKPO TYPE I_EKPO .

    *variable for Report ID

    DATA: V_REPID LIKE SY-REPID .

    *declaration for fieldcatalog

    DATA: I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,

    WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.

    DATA: IT_LISTHEADER TYPE SLIS_T_LISTHEADER.

    • declaration for events table where user comand or set PF status will

    • be defined

    DATA: V_EVENTS TYPE SLIS_T_EVENT,

    WA_EVENT TYPE SLIS_ALV_EVENT.

    • declartion for layout

    DATA: ALV_LAYOUT TYPE SLIS_LAYOUT_ALV.

    • declaration for variant(type of display we want)

    DATA: I_VARIANT TYPE DISVARIANT,

    I_VARIANT1 TYPE DISVARIANT,

    I_SAVE(1) TYPE C.

    *PARAMETERS : p_var TYPE disvariant-variant.

    *Title displayed when the alv list is displayed

    DATA: I_TITLE_EKKO TYPE LVC_TITLE VALUE 'FIRST LIST DISPLAYED'.

    DATA: I_TITLE_EKPO TYPE LVC_TITLE VALUE 'SECONDRY LIST DISPLAYED'.

    INITIALIZATION.

    V_REPID = SY-REPID.

    PERFORM BUILD_FIELDCATLOG.

    PERFORM EVENT_CALL.

    PERFORM POPULATE_EVENT.

    START-OF-SELECTION.

    PERFORM DATA_RETRIEVAL.

    PERFORM BUILD_LISTHEADER USING IT_LISTHEADER.

    PERFORM DISPLAY_ALV_REPORT.

    &----


    *& Form BUILD_FIELDCATLOG

    &----


    • Fieldcatalog has all the field details from ekko

    ----


    FORM BUILD_FIELDCATLOG.

    WA_FIELDCAT-TABNAME = 'IT_EKKO'.

    WA_FIELDCAT-FIELDNAME = 'EBELN'.

    WA_FIELDCAT-SELTEXT_M = 'PO NO.'.

    APPEND WA_FIELDCAT TO I_FIELDCAT.

    CLEAR WA_FIELDCAT.

    WA_FIELDCAT-TABNAME = 'IT_EKKO'.

    WA_FIELDCAT-FIELDNAME = 'AEDAT'.

    WA_FIELDCAT-SELTEXT_M = 'DATE.'.

    APPEND WA_FIELDCAT TO I_FIELDCAT.

    CLEAR WA_FIELDCAT.

    WA_FIELDCAT-TABNAME = 'IT_EKKO'.

    WA_FIELDCAT-FIELDNAME = 'BUKRS'.

    WA_FIELDCAT-SELTEXT_M = 'COMPANY CODE'.

    APPEND WA_FIELDCAT TO I_FIELDCAT.

    CLEAR WA_FIELDCAT.

    WA_FIELDCAT-TABNAME = 'IT_EKKO'.

    WA_FIELDCAT-FIELDNAME = 'BUKRS'.

    WA_FIELDCAT-SELTEXT_M = 'DOCMENT TYPE'.

    APPEND WA_FIELDCAT TO I_FIELDCAT.

    CLEAR WA_FIELDCAT.

    WA_FIELDCAT-TABNAME = 'IT_EKKO'.

    WA_FIELDCAT-FIELDNAME = 'LIFNR'.

    WA_FIELDCAT-NO_OUT = 'X'.

    WA_FIELDCAT-SELTEXT_M = 'VENDOR CODE'.

    APPEND WA_FIELDCAT TO I_FIELDCAT.

    CLEAR WA_FIELDCAT.

    ENDFORM. "BUILD_FIELDCATLOG

    &----


    *& Form EVENT_CALL

    &----


    • we get all events - TOP OF PAGE or USER COMMAND in table v_events

    ----


    FORM EVENT_CALL.

    CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

    EXPORTING

    I_LIST_TYPE = 0

    IMPORTING

    ET_EVENTS = V_EVENTS

    • EXCEPTIONS

    • LIST_TYPE_WRONG = 1

    • OTHERS = 2

    .

    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. "EVENT_CALL

    &----


    *& Form POPULATE_EVENT

    &----


    • Events populated for TOP OF PAGE & USER COMAND

    ----


    FORM POPULATE_EVENT.

    READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.

    IF SY-SUBRC EQ 0.

    WA_EVENT-FORM = 'TOP_OF_PAGE'.

    MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =

    WA_EVENT-FORM.

    ENDIF.

    READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'USER_COMMAND'.

    IF SY-SUBRC EQ 0.

    WA_EVENT-FORM = 'USER_COMMAND'.

    MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =

    WA_EVENT-NAME.

    ENDIF.

    ENDFORM. "POPULATE_EVENT

    &----


    *& Form data_retrieval

    &----


    • retreiving values from the database table ekko

    ----


    FORM DATA_RETRIEVAL.

    SELECT EBELN AEDAT BUKRS BSART LIFNR FROM EKKO INTO TABLE IT_EKKO.

    ENDFORM. "data_retrieval

    &----


    *& Form bUild_listheader

    &----


    • text

    ----


    • -->I_LISTHEADEtext

    ----


    FORM BUILD_LISTHEADER USING I_LISTHEADER TYPE SLIS_T_LISTHEADER.

    DATA HLINE TYPE SLIS_LISTHEADER.

    HLINE-INFO = 'this is my first alv pgm'.

    HLINE-TYP = 'H'.

    ENDFORM. "build_listheader

    &----


    *& Form display_alv_report

    &----


    • text

    ----


    FORM DISPLAY_ALV_REPORT.

    V_REPID = SY-REPID.

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    I_CALLBACK_PROGRAM = V_REPID

    • I_CALLBACK_PF_STATUS_SET = ' '

    I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

    I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'

    I_GRID_TITLE = I_TITLE_EKKO

    • I_GRID_SETTINGS =

    • IS_LAYOUT = ALV_LAYOUT

    IT_FIELDCAT = I_FIELDCAT[]

    • IT_EXCLUDING =

    • IT_SPECIAL_GROUPS =

    • IT_SORT =

    • IT_FILTER =

    • IS_SEL_HIDE =

    • i_default = 'ZLAY1'

    I_SAVE = 'A'

    • is_variant = i_variant

    IT_EVENTS = V_EVENTS

    TABLES

    T_OUTTAB = IT_EKKO

    • EXCEPTIONS

    • PROGRAM_ERROR = 1

    • OTHERS = 2

    .

    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. "display_alv_report

    &----


    *& Form TOP_OF_PAGE

    &----


    • text

    ----


    FORM TOP_OF_PAGE.

    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

    EXPORTING

    IT_LIST_COMMENTARY = IT_LISTHEADER

    • i_logo =

    • I_END_OF_LIST_GRID =

    .

    ENDFORM. "TOP_OF_PAGE

    &----


    *& Form USER_COMMAND

    &----


    • text

    ----


    • -->R_UCOMM text

    • -->, text

    • -->RS_SLEFIELDtext

    ----


    FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM

    RS_SELFIELD TYPE SLIS_SELFIELD.

    CASE R_UCOMM.

    WHEN '&IC1'.

    READ TABLE IT_EKKO INTO WA_EKKO INDEX RS_SELFIELD-TABINDEX.

    PERFORM BUILD_FIELDCATLOG_EKPO.

    PERFORM EVENT_CALL_EKPO.

    PERFORM POPULATE_EVENT_EKPO.

    PERFORM DATA_RETRIEVAL_EKPO.

    PERFORM BUILD_LISTHEADER_EKPO USING IT_LISTHEADER.

    PERFORM DISPLAY_ALV_EKPO.

    ENDCASE.

    ENDFORM. "user_command

    &----


    *& Form BUILD_FIELDCATLOG_EKPO

    &----


    • text

    ----


    FORM BUILD_FIELDCATLOG_EKPO.

    WA_FIELDCAT-TABNAME = 'IT_EKPO'.

    WA_FIELDCAT-FIELDNAME = 'EBELN'.

    WA_FIELDCAT-SELTEXT_M = 'PO NO.'.

    APPEND WA_FIELDCAT TO I_FIELDCAT.

    CLEAR WA_FIELDCAT.

    WA_FIELDCAT-TABNAME = 'IT_EKPO'.

    WA_FIELDCAT-FIELDNAME = 'EBELP'.

    WA_FIELDCAT-SELTEXT_M = 'LINE NO'.

    APPEND WA_FIELDCAT TO I_FIELDCAT.

    CLEAR WA_FIELDCAT.

    WA_FIELDCAT-TABNAME = 'I_EKPO'.

    WA_FIELDCAT-FIELDNAME = 'MATNR'.

    WA_FIELDCAT-SELTEXT_M = 'MATERIAL NO.'.

    APPEND WA_FIELDCAT TO I_FIELDCAT.

    CLEAR WA_FIELDCAT.

    WA_FIELDCAT-TABNAME = 'I_EKPO'.

    WA_FIELDCAT-FIELDNAME = 'MENGE'.

    WA_FIELDCAT-SELTEXT_M = 'QUANTITY'.

    APPEND WA_FIELDCAT TO I_FIELDCAT.

    CLEAR WA_FIELDCAT.

    WA_FIELDCAT-TABNAME = 'I_EKPO'.

    WA_FIELDCAT-FIELDNAME = 'MEINS'.

    WA_FIELDCAT-SELTEXT_M = 'UOM'.

    APPEND WA_FIELDCAT TO I_FIELDCAT.

    CLEAR WA_FIELDCAT.

    WA_FIELDCAT-TABNAME = 'I_EKPO'.

    WA_FIELDCAT-FIELDNAME = 'NETPR'.

    WA_FIELDCAT-SELTEXT_M = 'PRICE'.

    APPEND WA_FIELDCAT TO I_FIELDCAT.

    CLEAR WA_FIELDCAT.

    ENDFORM. "BUILD_FIELDCATLOG_EKPO

    &----


    *& Form event_call_ekpo

    &----


    • we get all events - TOP OF PAGE or USER COMMAND in table v_events

    ----


    FORM EVENT_CALL_EKPO.

    CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

    EXPORTING

    I_LIST_TYPE = 0

    IMPORTING

    ET_EVENTS = V_EVENTS

    • EXCEPTIONS

    • LIST_TYPE_WRONG = 1

    • OTHERS = 2

    .

    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. "event_call_ekpo

    &----


    *& Form POPULATE_EVENT

    &----


    • Events populated for TOP OF PAGE & USER COMAND

    ----


    FORM POPULATE_EVENT_EKPO.

    READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.

    IF SY-SUBRC EQ 0.

    WA_EVENT-FORM = 'TOP_OF_PAGE'.

    MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =

    WA_EVENT-FORM.

    ENDIF.

    ENDFORM. "POPULATE_EVENT

    &----


    *& Form TOP_OF_PAGE

    &----


    • text

    ----


    FORM F_TOP_OF_PAGE.

    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

    EXPORTING

    IT_LIST_COMMENTARY = IT_LISTHEADER

    • i_logo =

    • I_END_OF_LIST_GRID =

    .

    ENDFORM. "TOP_OF_PAGE

    &----


    *& Form USER_COMMAND

    &----


    • text

    ----


    • -->R_UCOMM text

    • -->, text

    • -->RS_SLEFIELDtext

    ----


    *retreiving values from the database table ekko

    FORM DATA_RETRIEVAL_EKPO.

    SELECT EBELN EBELP MATNR MENGE MEINS NETPR FROM EKPO INTO TABLE IT_EKPO.

    ENDFORM.

    FORM BUILD_LISTHEADER_EKPO USING I_LISTHEADER TYPE SLIS_T_LISTHEADER.

    DATA: HLINE1 TYPE SLIS_LISTHEADER.

    HLINE1-TYP = 'H'.

    HLINE1-INFO = 'CHECKING PGM'.

    ENDFORM.

    FORM DISPLAY_ALV_EKPO.

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    • I_INTERFACE_CHECK = ' '

    • I_BYPASSING_BUFFER = ' '

    • I_BUFFER_ACTIVE = ' '

    I_CALLBACK_PROGRAM = V_REPID

    • I_CALLBACK_PF_STATUS_SET = ' '

    • I_CALLBACK_USER_COMMAND = 'F_USER_COMMAND'

    I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'

    • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

    • I_CALLBACK_HTML_END_OF_LIST = ' '

    • I_STRUCTURE_NAME =

    • I_BACKGROUND_ID = ' '

    I_GRID_TITLE = I_TITLE_EKPO

    • I_GRID_SETTINGS =

    • IS_LAYOUT =

    IT_FIELDCAT = I_FIELDCAT[]

    • IT_EXCLUDING =

    • IT_SPECIAL_GROUPS =

    • IT_SORT =

    • IT_FILTER =

    • IS_SEL_HIDE =

    • I_DEFAULT =

    I_SAVE = 'A'

    • IS_VARIANT =

    IT_EVENTS = V_EVENTS

    TABLES

    T_OUTTAB = IT_EKPO

    EXCEPTIONS

    PROGRAM_ERROR = 1

    OTHERS = 2

    .

    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.

    thanks

    mrutyun^

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 17, 2007 at 05:03 AM

    Best way is go to SLIS package.......... and there u will find out lots of example programs...

    Add comment
    10|10000 characters needed characters exceeded