Skip to Content
0
Former Member
Jul 20, 2007 at 05:01 AM

Regarding alv output

74 Views

Hi all,

My user command is not working in my program.

When i am clicking in any value on any filed its not working out. I have debuuged also i m not getting.

<code>

&----


*& Report ZVEN_PRA

*&

&----


*&

*&

&----


REPORT zven_pra

NO STANDARD PAGE HEADING

MESSAGE-ID zven.

&----


*&

*&Internal table declarations

&----


DATA:BEGIN OF it_ekko OCCURS 0,

ebeln TYPE ekko-ebeln, "po number

bukrs TYPE ekko-bukrs, "company code

bstyp TYPE ekko-bstyp, "po category

lifnr TYPE ekko-lifnr, "vendor no

ekorg TYPE ekko-ekorg, "pur org

ekgrp TYPE ekko-ekgrp, "pur group

END OF it_ekko.

DATA:BEGIN OF it_ekpo OCCURS 0,

ebelp TYPE ekpo-ebelp,"item of po number

matnr TYPE ekpo-matnr,"material no

werks TYPE ekpo-werks,"plant

menge TYPE ekpo-menge,"po qty

meins TYPE ekpo-meins,"order unit

netwr TYPE ekpo-netwr,"net order value

END OF it_ekpo.

DATA:v_field(50) TYPE c,

v_value TYPE ekko-ebeln.

DATA:v_bukrs TYPE ekko-bukrs.

TYPE-POOLS:slis.

DATA:it_fcat TYPE slis_t_fieldcat_alv,

wa_fcat TYPE slis_fieldcat_alv,

layout TYPE slis_layout_alv,

it_header TYPE slis_t_listheader,

wa_header TYPE slis_listheader.

DATA : it_event TYPE slis_t_event.

DATA:it_fcat2 TYPE slis_t_fieldcat_alv,

wa_fcat2 TYPE slis_fieldcat_alv,

gs_selfield TYPE slis_selfield,

g_exit(1) TYPE c,

gs_private TYPE slis_data_caller_exit.

*to store the variants.

data:ws_x_variant like disvariant,

ws_variant like disvariant,

ws_save type c,

ws_exit type c.

CONSTANTS :

c_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE',

c_usercommand TYPE slis_formname VALUE 'USER_COMMAND',

c_pf_status TYPE slis_formname VALUE 'PF_STATUS_SET'.

  • DATA:IT_HEADER TYPE SLIS_T_LISTHEADER.

&----


*&

*&Selection-Screen declarations

&----


TABLES:ekko.

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

SELECT-OPTIONS:s_bukrs FOR ekko-bukrs,

s_lifnr FOR ekko-lifnr.

SELECTION-SCREEN END OF BLOCK e.

*validate the company code

AT SELECTION-SCREEN.

PERFORM validate_code.

START-OF-SELECTION.

PERFORM get_data_ekko.

PERFORM build_field_catalog.

END-OF-SELECTION.

PERFORM get_layout.

PERFORM fill_event.

perform fill_variant.

PERFORM print_data_ekko.

&----


*& Form get_data_ekko

&----


  • text

FORM get_data_ekko .

SELECT ebeln

bukrs

bstyp

lifnr

ekorg

ekgrp

FROM ekko

INTO TABLE it_ekko

WHERE bukrs IN s_bukrs

AND lifnr IN s_lifnr.

IF sy-subrc = 0.

SORT it_ekko BY ebeln.

ENDIF.

ENDFORM. " get_data_ekko

&----


*& Form print_data_ekko

&----


  • text

FORM print_data_ekko .

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 = ' '

  • I_CALLBACK_TOP_OF_PAGE = TOP_1

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME = I_STRUCTURE_NAME

  • I_BACKGROUND_ID = ' '

i_grid_title = 'ALVREPORT'

  • I_GRID_SETTINGS = I_GRID_SETTINGS

  • is_layout = layout

it_fieldcat = it_fcat[]

  • IT_EXCLUDING = IT_EXCLUDING

  • IT_SPECIAL_GROUPS = IT_SPECIAL_GROUPS

  • IT_SORT = IT_SORT

  • IT_FILTER = IT_FILTER

  • IS_SEL_HIDE = IS_SEL_HIDE

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT = IS_VARIANT

it_events = it_event[]

  • IT_EVENT_EXIT = IT_EVENT_EXIT

  • IS_PRINT = IS_PRINT

  • IS_REPREP_ID = IS_REPREP_ID

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • I_HTML_HEIGHT_TOP = 0

  • I_HTML_HEIGHT_END = 0

  • IT_ALV_GRAPHICS = IT_ALV_GRAPHICS

  • IT_HYPERLINK = IT_HYPERLINK

  • IT_ADD_FIELDCAT = IT_ADD_FIELDCAT

  • IT_EXCEPT_QINFO = IT_EXCEPT_QINFO

  • IR_SALV_FULLSCREEN_ADAPTER = IR_SALV_FULLSCREEN_ADAPTER

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER = E_EXIT_CAUSED_BY_CALLER

  • ES_EXIT_CAUSED_BY_USER = ES_EXIT_CAUSED_BY_USER

TABLES

t_outtab = it_ekko

  • EXCEPTIONS

  • PROGRAM_ERROR = 1

  • OTHERS = 2

.

*loop at it_ekko.

*write:/ it_ekko-ebeln hotspot on,15 it_ekko-bukrs,25 it_ekko-bstyp,

  • 35 it_ekko-lifnr,45 it_ekko-ekorg,55 it_ekko-ekgrp.

  • hide it_ekko-ebeln.

*endloop.

ENDFORM. " print_data_ekko

&----


*& Form get_data_ekpo

&----


  • text

FORM get_data_ekpo .

IF NOT it_ekko[] IS INITIAL.

SELECT ebelp

matnr

werks

menge

meins

netwr

FROM ekpo

INTO TABLE it_ekpo

WHERE ebeln = it_ekko-ebeln.

ENDIF.

ENDFORM. " get_data_ekpo

&----


*& Form validate_code

&----


  • text

FORM validate_code .

IF NOT s_bukrs[] IS INITIAL.

SELECT SINGLE bukrs

INTO v_bukrs

FROM ekko

WHERE bukrs IN s_bukrs.

IF sy-subrc <> 0.

MESSAGE e001. "invalid company code

ENDIF.

ENDIF.

ENDFORM. " validate_code

&----


*& Form build_field_catalog

&----


  • text

FORM build_field_catalog .

CLEAR wa_fcat.

*CLEAR IT_FCAT.

  • wa_fcat-emphasize = 'C112'.

wa_fcat-tabname = 'IT_EKKO'.

wa_fcat-fieldname = 'EBELN'.

wa_fcat-col_pos = '1'.

wa_fcat-seltext_l = 'PO NUMBER'.

APPEND wa_fcat TO it_fcat.

CLEAR wa_fcat.

*CLEAR IT_FCAT.

wa_fcat-emphasize = 'C212'.

wa_fcat-tabname = 'IT_EKKO'.

wa_fcat-fieldname = 'BUKRS'.

wa_fcat-col_pos = '2'.

wa_fcat-seltext_l = 'COM CODE'.

APPEND wa_fcat TO it_fcat.

CLEAR wa_fcat.

*CLEAR IT_FCAT.

wa_fcat-emphasize = 'C312'.

wa_fcat-tabname = 'IT_EKKO'.

wa_fcat-fieldname = 'BSTYP'.

wa_fcat-col_pos = '3'.

wa_fcat-seltext_l = 'PO CATEGORY'.

APPEND wa_fcat TO it_fcat.

CLEAR wa_fcat.

*CLEAR IT_FCAT.

  • wa_fcat-emphasize = 'C412'.

wa_fcat-tabname = 'IT_EKKO'.

wa_fcat-fieldname = 'LIFNR'.

wa_fcat-col_pos = '4'.

wa_fcat-seltext_l = 'VENDOR NUMBER'.

APPEND wa_fcat TO it_fcat.

CLEAR wa_fcat.

*CLEAR IT_FCAT.

  • wa_fcat-emphasize = 'C512'.

wa_fcat-tabname = 'IT_EKKO'.

wa_fcat-fieldname = 'EKORG'.

wa_fcat-col_pos = '5'.

wa_fcat-seltext_l = 'PO ORGAN'.

APPEND wa_fcat TO it_fcat.

CLEAR wa_fcat.

*CLEAR IT_FCAT.

  • wa_fcat-emphasize = 'C612'.

wa_fcat-tabname = 'IT_EKKO'.

wa_fcat-fieldname = 'EBGRP'.

wa_fcat-col_pos = '6'.

wa_fcat-seltext_l = 'PO GROUP'.

APPEND wa_fcat TO it_fcat.

CLEAR wa_fcat.

ENDFORM. " build_field_catalog

&----


*& Form get_layout

&----


  • text

FORM get_layout .

layout-zebra = 'X'.

ENDFORM. " get_layout

&----


*& Form get_headerin_alv

&----


  • text

----


  • -->P_IT_HEADER text

----


FORM top_of_page .

DATA:it_header TYPE slis_t_listheader,

wa_header TYPE slis_listheader.

CLEAR wa_header.

wa_header-typ = 'H'.

wa_header-info = 'venkatakrishna'.

APPEND wa_header TO it_header.

CLEAR wa_header.

wa_header-typ = 'S'.

wa_header-info = 'SOFTWARE ENGINEER'.

APPEND wa_header TO it_header.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = it_header

  • I_LOGO = I_LOGO

  • I_END_OF_LIST_GRID = I_END_OF_LIST_GRID

  • I_ALV_FORM = I_ALV_FORM

.

ENDFORM. "TOP_OF_PAGE

&----


*& Form user_command

&----


  • text

----


  • -->RF_UCOMM text

  • -->RS_SELFIELD text

----


FORM user_command USING rf_ucomm TYPE sy-ucomm

rs_selfield TYPE slis_selfield.

CASE rf_ucomm.

WHEN '&IC1'.

READ TABLE it_ekko INDEX rs_selfield-tabindex.

IF sy-subrc = 0.

PERFORM get_data_ekpo.

  • PERFORM PRINT_DATA_EKPO.

PERFORM build_field_catalog2.

PERFORM print_field_data.

ENDIF.

ENDCASE.

ENDFORM. "user_command

&----


*& Form BUILD_FIELD_CATALOG2

&----


  • text

FORM build_field_catalog2 .

CLEAR: it_fcat,wa_fcat.

CLEAR: wa_fcat2,it_fcat2.

wa_fcat2-tabname = 'IT_EKPO'.

wa_fcat2-fieldname = 'EBELP'.

wa_fcat2-col_pos = '1'.

wa_fcat2-seltext_l = 'item of po number'.

APPEND wa_fcat2 TO it_fcat2.

CLEAR wa_fcat2.

wa_fcat2-tabname = 'IT_EKPO'.

wa_fcat2-fieldname = 'MATNR'.

wa_fcat2-col_pos = '2'.

wa_fcat2-seltext_l = 'material no'.

APPEND wa_fcat2 TO it_fcat2.

CLEAR wa_fcat2.

wa_fcat2-tabname = 'IT_EKPO'.

wa_fcat2-fieldname = 'WERKS'.

wa_fcat2-col_pos = '3'.

wa_fcat2-seltext_l = 'PLANT'.

APPEND wa_fcat2 TO it_fcat2.

CLEAR wa_fcat2.

wa_fcat2-tabname = 'IT_EKPO'.

wa_fcat2-fieldname = 'MENGE'.

wa_fcat2-col_pos = '4'.

wa_fcat2-seltext_l = 'PO QTY'.

APPEND wa_fcat2 TO it_fcat2.

CLEAR wa_fcat2.

wa_fcat2-tabname = 'IT_EKPO'.

wa_fcat2-fieldname = 'MEINS'.

wa_fcat2-col_pos = '5'.

wa_fcat2-seltext_l = 'ORDER UNIT'.

APPEND wa_fcat2 TO it_fcat2.

CLEAR wa_fcat2.

wa_fcat2-tabname = 'IT_EKPO'.

wa_fcat2-fieldname = 'NETWR'.

wa_fcat2-col_pos = '6'.

wa_fcat2-seltext_l = 'net order value'.

APPEND wa_fcat2 TO it_fcat2.

ENDFORM. " BUILD_FIELD_CATALOG2

&----


*& Form PRINT_FIELD_DATA

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM print_field_data .

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 = ' '

  • I_CALLBACK_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME = 'EKPO'

  • I_BACKGROUND_ID = ' '

i_grid_title = 'INTERACTIVE REPORT'

  • I_GRID_SETTINGS = I_GRID_SETTINGS

  • IS_LAYOUT = IS_LAYOUT

it_fieldcat = it_fcat2

  • IT_EXCLUDING = IT_EXCLUDING

  • IT_SPECIAL_GROUPS = IT_SPECIAL_GROUPS

  • IT_SORT = IT_SORT

  • IT_FILTER = IT_FILTER

  • IS_SEL_HIDE = IS_SEL_HIDE

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

IS_VARIANT = ws_x_variant

  • IT_EVENTS = IT_EVENTS

  • IT_EVENT_EXIT = IT_EVENT_EXIT

  • IS_PRINT = IS_PRINT

  • IS_REPREP_ID = IS_REPREP_ID

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • I_HTML_HEIGHT_TOP = 0

  • I_HTML_HEIGHT_END = 0

  • IT_ALV_GRAPHICS = IT_ALV_GRAPHICS

  • IT_HYPERLINK = IT_HYPERLINK

  • IT_ADD_FIELDCAT = IT_ADD_FIELDCAT

  • IT_EXCEPT_QINFO = IT_EXCEPT_QINFO

  • IR_SALV_FULLSCREEN_ADAPTER = IR_SALV_FULLSCREEN_ADAPTER

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER = E_EXIT_CAUSED_BY_CALLER

  • ES_EXIT_CAUSED_BY_USER = ES_EXIT_CAUSED_BY_USER

TABLES

t_outtab = it_ekpo

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2

.

*USE THE POPUP_TO_CONFIRM FUNCTION MODULE FOR SELECT

  • CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'

  • EXPORTING

  • I_TITLE = 'venkat'

  • I_SELECTION = 'X'

  • I_ALLOW_NO_SELECTION = I_ALLOW_NO_SELECTION

  • I_ZEBRA = 'X'

    • I_SCREEN_START_COLUMN = 0

    • I_SCREEN_START_LINE = 0

    • I_SCREEN_END_COLUMN = 0

    • I_SCREEN_END_LINE = 0

    • I_CHECKBOX_FIELDNAME = I_CHECKBOX_FIELDNAME

    • I_LINEMARK_FIELDNAME = I_LINEMARK_FIELDNAME

    • I_SCROLL_TO_SEL_LINE = 'X'

  • i_tabname = 'EKPO'

    • i_structure_name = 'EKPO'

  • it_fieldcat = it_fcat2

    • IT_EXCLUDING = IT_EXCLUDING

    • I_CALLBACK_PROGRAM = I_CALLBACK_PROGRAM

    • I_CALLBACK_USER_COMMAND = I_CALLBACK_USER_COMMAND

  • is_private = gs_private

  • IMPORTING

  • es_selfield = gs_selfield

  • e_exit = g_exit

  • TABLES

  • t_outtab = IT_EKPO

  • EXCEPTIONS

  • PROGRAM_ERROR = 1

  • OTHERS = 2

  • .

  • ENDFORM. " PRINT_FIELD_DATA

    &----


    *& Form fill_event

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM fill_event .

    DATA : st_event TYPE slis_alv_event.

    *- Clear.

    CLEAR : st_event, it_event[].

    *- Local variable

    DATA : l_tabix TYPE sy-tabix.

    *

    CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

    EXPORTING

    i_list_type = 0

    IMPORTING

    et_events = it_event

    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.

    *

    *- Read event table

    READ TABLE it_event WITH KEY name = slis_ev_top_of_page

    INTO st_event.

    *- Top of page event

    *- Clear

    CLEAR l_tabix.

    l_tabix = sy-tabix.

    *- Check subrc

    IF sy-subrc = 0.

    st_event-form = c_top_of_page.

    *- Modify

    MODIFY it_event FROM st_event INDEX l_tabix.

    *- Clear

    CLEAR st_event.

    ENDIF.

    *

    *- User command event

    *- Read event table

    READ TABLE it_event WITH KEY name = slis_ev_user_command

    INTO st_event.

    *- Clear

    CLEAR l_tabix.

    l_tabix = sy-tabix.

    *- Check subrc

    IF sy-subrc = 0.

    st_event-form = c_usercommand.

    *- Modify

    MODIFY it_event FROM st_event INDEX l_tabix.

    *- Clear

    CLEAR st_event.

    ENDIF.

    ENDFORM. " fill_event

    &----


    *& Form GET_HEADER

    &----


    • text

    &----


    *& Form fill_variant

    &----


    • text

    form fill_variant .

    ws_x_variant-report = 'ZVEN_PRA'.

    endform. " fill_variant

    </code>

    Thanks,

    suraj