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

ABAP-ALV CONCEPT USING FUNCTION MODULES

HI ALL,

WHY I AM NOT ABLE TO FIND DATA IN SECONDARY LIST.

I.E;

SELECT STATEMENT COULD NOT BE ABLE TO PUT DATA IN TARGET.

HERE IS THE SOURCE CODE.

SOMEBODY HELP ME OUT.

&----


*& Report ZALVINSTANCE1 *

*& *

&----


*& *

*& *

&----


REPORT ZALVINSTANCE1 .

TABLES:KNA1,VBAK,VBAP.

TYPE-POOLS:SLIS.

SELECT-OPTIONS: CUSTOMER FOR KNA1-KUNNR.

DATA:

WA LIKE KNA1,

ITAB LIKE TABLE OF KNA1,

WA1 LIKE VBAK,

JTAB LIKE TABLE OF VBAK,

WA2 LIKE VBAP,

KTAB LIKE TABLE OF VBAP.

DATA: WA_EVENTS TYPE SLIS_ALV_EVENT,

ITAB_EVENTS TYPE SLIS_T_EVENT.

START-OF-SELECTION.

PERFORM EVENTS.

SELECT * FROM KNA1 INTO TABLE ITAB UP TO 50 ROWS WHERE KUNNR IN CUSTOMER

.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = SY-CPROG

I_STRUCTURE_NAME = 'KNA1'

IT_EVENTS = ITAB_EVENTS

TABLES

T_OUTTAB = ITAB.

FORM EVENTS.

CLEAR WA_EVENTS.

WA_EVENTS-NAME = 'USER_COMMAND'.

WA_EVENTS-FORM = 'PROCESSING'.

APPEND WA_EVENTS TO ITAB_EVENTS.

ENDFORM.

FORM PROCESSING USING UCOMM LIKE SY-UCOMM

SEL TYPE SLIS_SELFIELD.

DATA:

X_KUNNR(15) TYPE N,

X_VBELN(15) TYPE N,

X_MATNR(15) TYPE C.

IF SEL-FIELDNAME = 'KUNNR'.

X_KUNNR = SEL-VALUE.

SELECT * FROM VBAK INTO TABLE JTAB UP TO 50 ROWS WHERE

KUNNR = X_KUNNR.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = SY-CPROG

I_STRUCTURE_NAME = 'VBAK'

IT_EVENTS = ITAB_EVENTS

TABLES

T_OUTTAB = JTAB.

ENDIF.

IF SEL-FIELDNAME = 'VBELN'.

X_VBELN = SEL-VALUE.

SELECT * FROM VBAP INTO TABLE KTAB UP TO 50 ROWS WHERE VBELN =

X_VBELN.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = SY-CPROG

I_STRUCTURE_NAME = 'VBAP'

IT_EVENTS = ITAB_EVENTS

TABLES

T_OUTTAB = KTAB.

ENDIF.

ENDFORM.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jun 13, 2008 at 03:44 PM

    hi,

    check the data type declaration for Kunnr because it is Numeric 15 chars which is a mismatch.Make it Char10 it will work.

    Regards

    RajD

    Add a comment
    10|10000 characters needed characters exceeded

    • ... you can't use where vbeln = sel-value for more than one reason:

      1. the technical properties (field length) of VBELN and sel-value are different.

      2. sel-value hast the displayed (external representation) value of VBELN. In the WHERE clause you need the exact (internal) value which is preceded by zeros. You mus either read directly from the table displayed (read itab index sel-index) or convert back to internal using FM CONVERSION_EXIT_ALPHA_INPUT.

      Regards,

      Clemens

  • author's profile photo Former Member
    Former Member
    Posted on Jun 13, 2008 at 03:46 PM

    Raj D is almost right.

    declare x_kunnr type KUNAG

    then call FM conversion_exit_alpha_input to properly format your x_kunnr field

    for selection.

    the FM is the key to your issue

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 13, 2008 at 04:04 PM

    Hi,

    Modified little bit of code (Made in Bold)

    &----


    *& Report ZALVINSTANCE1 *

    *& *

    &----


    *& *

    *& *

    &----


    REPORT ZALVINSTANCE1 .

    TABLES:KNA1,VBAK,VBAP.

    TYPE-POOLS:SLIS.

    SELECT-OPTIONS: CUSTOMER FOR KNA1-KUNNR.

    DATA:

    WA LIKE KNA1,

    ITAB LIKE TABLE OF KNA1,

    WA1 LIKE VBAK,

    JTAB LIKE TABLE OF VBAK,

    WA2 LIKE VBAP,

    KTAB LIKE TABLE OF VBAP.

    DATA: WA_EVENTS TYPE SLIS_ALV_EVENT,

    ITAB_EVENTS TYPE SLIS_T_EVENT.

    START-OF-SELECTION.

    PERFORM EVENTS.

    SELECT * FROM KNA1 INTO TABLE ITAB UP TO 50 ROWS WHERE KUNNR IN CUSTOMER

    .

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    I_CALLBACK_PROGRAM = SY-CPROG

    I_STRUCTURE_NAME = 'KNA1'

    IT_EVENTS = ITAB_EVENTS

    TABLES

    T_OUTTAB = ITAB.

    FORM EVENTS.

    CLEAR WA_EVENTS.

    WA_EVENTS-NAME = 'USER_COMMAND'.

    WA_EVENTS-FORM = 'PROCESSING'.

    APPEND WA_EVENTS TO ITAB_EVENTS.

    ENDFORM.

    FORM PROCESSING USING UCOMM LIKE SY-UCOMM

    SEL TYPE SLIS_SELFIELD.

    DATA:

    X_KUNNR(15) TYPE N,

    X_VBELN(15) TYPE N,

    X_MATNR(15) TYPE C.

    CASE UCOMM.

    WHEN '&IC1'

    IF SEL-FIELDNAME = 'KUNNR'.

    X_KUNNR = SEL-VALUE.

    SELECT * FROM VBAK INTO TABLE JTAB UP TO 50 ROWS WHERE

    KUNNR = X_KUNNR.

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    I_CALLBACK_PROGRAM = SY-CPROG

    I_STRUCTURE_NAME = 'VBAK'

    IT_EVENTS = ITAB_EVENTS

    TABLES

    T_OUTTAB = JTAB.

    ENDIF.

    IF SEL-FIELDNAME = 'VBELN'.

    X_VBELN = SEL-VALUE.

    SELECT * FROM VBAP INTO TABLE KTAB UP TO 50 ROWS WHERE VBELN =

    X_VBELN.

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    I_CALLBACK_PROGRAM = SY-CPROG

    I_STRUCTURE_NAME = 'VBAP'

    IT_EVENTS = ITAB_EVENTS

    TABLES

    T_OUTTAB = KTAB.

    ENDIF.

    ENDCASE.

    ENDFORM.

    here i am giving sample code for Interactive ALV.Which includes all events.

    USe this as reference.

    REPORT z50871_alv_griddisplay message-id z50871msg.

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

    • Report : z50871_alv_griddisplay *

    • Title : Interactive ALV *

    • Author : SANDEEP REDDY *

    • Date of Creation : January 07, 2008 *

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

    • Modification Log *

    • Author : *

    • Date of Change : *

    • Functional Specs # : *

    • Correction Request # : *

    • Description of Change : *

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

    ----


    • STRUCTURE DECLARATIONS

    • INTERNAL TABLE DECLARATIONS

    • WORKAREA DECLARATIONS

    • TYPE-POOLS DECLARATION

    ----


    TYPE-POOLS : slis.

    TYPES : BEGIN OF st_ekko,

    ebeln TYPE ekko-ebeln, "Purchasing Document Number

    bstyp TYPE ekko-bstyp, "Purchasing Document Category

    bsart TYPE ekko-bsart, "Purchasing Document Type

    aedat TYPE ekko-aedat, "record created on

    ernam TYPE ekko-ernam, "Person who Created the Object

    check(1),

    END OF st_ekko.

    TYPES : BEGIN OF st_ekpo,

    ebeln TYPE ekko-ebeln,

    ebelp TYPE ekpo-ebelp, "Item Number of Purchasing Document

    ematn TYPE ekpo-ematn, "Material number

    matkl TYPE ekpo-matkl, "Material group

    netpr TYPE ekpo-netpr, "Net price in purchasing document

    END OF st_ekpo.

    TYPES : BEGIN OF st_ebeln,

    ebeln TYPE ekpo-ebeln,

    END OF st_ebeln.

    TYPES : BEGIN OF st_eine,

    ebeln TYPE ekko-ebeln,

    ekorg TYPE eine-ekorg,

    ekgrp TYPE eine-ekgrp,

    END OF st_eine.

    TYPES : BEGIN OF st_check,

    check(1),

    END OF st_check.

    DATA : it_ekpo TYPE STANDARD TABLE OF st_ekpo,

    it_ekko TYPE STANDARD TABLE OF st_ekko,

    wa_ekko LIKE LINE OF it_ekko,

    it_fieldcat TYPE slis_t_fieldcat_alv,

    wa_fieldcat LIKE LINE OF it_fieldcat,

    wa_layout TYPE slis_layout_alv,

    it_events TYPE slis_t_event,

    st_event LIKE LINE OF it_events,

    it_listheadr TYPE slis_t_listheader ,

    wa_listheadr LIKE LINE OF it_listheadr,

    st_printparams TYPE slis_print_alv,

    it_sortinfo TYPE slis_t_sortinfo_alv,

    wa_sortinfo LIKE LINE OF it_sortinfo,

    it_ekposortinfo TYPE slis_t_sortinfo_alv,

    wa_ekposortinfo LIKE LINE OF it_ekposortinfo,

    it_filter TYPE slis_t_filter_alv,

    it_ebeln TYPE STANDARD TABLE OF st_ebeln,

    it_eine TYPE STANDARD TABLE OF st_eine,

    wa_eine TYPE st_eine,

    it_popup TYPE STANDARD TABLE OF st_eine,

    wa_popup TYPE st_eine,

    it_check TYPE STANDARD TABLE OF st_check,

    wa_check TYPE st_check.

    DATA : v_ebeln TYPE ekko-ebeln.

    ----


    • SELECTION-SCREEN

    ----


    SELECTION-SCREEN BEGIN OF BLOCK b WITH FRAME TITLE tit.

    SELECT-OPTIONS: so_ebeln FOR v_ebeln OBLIGATORY.

    SELECTION-SCREEN END OF BLOCK b.

    ----


    • INITIALIZATION

    ----


    INITIALIZATION.

    tit = text-000.

    ----


    • AT SELECTION-SCREEN ON

    ----


    AT SELECTION-SCREEN ON so_ebeln.

    PERFORM validate_ebeln.

    ----


    • START-OF-SELECTION

    ----


    START-OF-SELECTION.

    PERFORM get_ekko_data.

    PERFORM get_eine_data.

    ----


    • END-OF-SELECTION

    ----


    END-OF-SELECTION.

    PERFORM populate_fieldcat1.

    PERFORM populate_layout.

    PERFORM get_eventlist.

    PERFORM get_ekkosortinfo.

    PERFORM ekkodisplay_onalv.

    &----


    *& Form POPULATE_FIELDCAT1

    &----


    FORM populate_fieldcat1.

    wa_fieldcat-fieldname = 'EBELN'.

    wa_fieldcat-seltext_l = text-004.

    wa_fieldcat-no_zero = 'X'.

    APPEND wa_fieldcat TO it_fieldcat.

    wa_fieldcat-fieldname = 'BSTYP'.

    wa_fieldcat-seltext_l = text-005.

    APPEND wa_fieldcat TO it_fieldcat.

    wa_fieldcat-fieldname = 'BSART'.

    wa_fieldcat-seltext_l = text-006.

    APPEND wa_fieldcat TO it_fieldcat.

    wa_fieldcat-fieldname = 'AEDAT'.

    wa_fieldcat-seltext_l = text-007.

    APPEND wa_fieldcat TO it_fieldcat.

    wa_fieldcat-fieldname = 'ERNAM'.

    wa_fieldcat-seltext_l = text-008.

    APPEND wa_fieldcat TO it_fieldcat.

    ENDFORM. "POPULATE_FIELDCAT1

    &----


    *& Form populate_fieldcat2

    &----


    FORM populate_fieldcat2 .

    CLEAR wa_fieldcat.

    CLEAR it_fieldcat.

    REFRESH it_fieldcat.

    wa_fieldcat-fieldname = 'EBELN'.

    wa_fieldcat-seltext_l = text-004.

    wa_fieldcat-hotspot = 'X'.

    • wa_fieldcat-no_zero = 'X'.

    APPEND wa_fieldcat TO it_fieldcat.

    wa_fieldcat-fieldname = 'EBELP'.

    wa_fieldcat-seltext_l = text-009.

    APPEND wa_fieldcat TO it_fieldcat.

    wa_fieldcat-fieldname = 'EMATN'.

    wa_fieldcat-seltext_l = text-010.

    APPEND wa_fieldcat TO it_fieldcat.

    wa_fieldcat-fieldname = 'MATKL'.

    wa_fieldcat-seltext_l = text-011.

    APPEND wa_fieldcat TO it_fieldcat.

    wa_fieldcat-fieldname = 'NETPR'.

    wa_fieldcat-seltext_l = text-012.

    wa_fieldcat-datatype = 'CURR'. "Obligatory to perform SUM

    wa_fieldcat-do_sum = 'X'.

    APPEND wa_fieldcat TO it_fieldcat.

    ENDFORM. "populate_fieldcat2

    &----


    *& Form GET_EVENTLIST

    &----


    FORM get_eventlist.

    CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

    EXPORTING

    i_list_type = 0

    IMPORTING

    et_events = it_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.

    READ TABLE it_events WITH KEY name = slis_ev_pf_status_set INTO st_event.

    IF sy-subrc EQ 0.

    st_event-form = 'SET_PF_STATUS1'.

    APPEND st_event TO it_events.

    CLEAR st_event.

    ENDIF.

    READ TABLE it_events WITH KEY name = slis_ev_end_of_page INTO st_event.

    IF sy-subrc EQ 0.

    st_event-form = 'END_OF_PAGE'.

    APPEND st_event TO it_events.

    CLEAR st_event.

    ENDIF.

    ENDFORM. "GET_EVENTLIST

    &----


    *& Form ekpodisplay_onalv

    &----


    FORM ekpodisplay_onalv .

    IF it_ekpo[] IS INITIAL.

    MESSAGE 'NO DATA FOUND' TYPE 'I'.

    ELSE.

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    i_callback_program = sy-repid

    i_callback_pf_status_set = 'SET_PF_STATUS'

    i_callback_user_command = 'AT_USER_COMMAND1'

    i_callback_top_of_page = 'TOP_OF_PAGE'

    • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

    • I_CALLBACK_HTML_END_OF_LIST = ' '

    • I_STRUCTURE_NAME = I_STRUCTURE_NAME

    • I_BACKGROUND_ID = ' '

    • I_GRID_TITLE = I_GRID_TITLE

    • I_GRID_SETTINGS = I_GRID_SETTINGS

    is_layout = wa_layout

    it_fieldcat = it_fieldcat

    • IT_EXCLUDING = IT_EXCLUDING

    • IT_SPECIAL_GROUPS = IT_SPECIAL_GROUPS

    it_sort = it_ekposortinfo[]

    • IT_FILTER = IT_FILTER

    • IS_SEL_HIDE = IS_SEL_HIDE

    • I_DEFAULT = 'X'

    • I_SAVE = ' '

    • IS_VARIANT = IS_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 .

    IF sy-subrc <> 0.

    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    ENDIF.

    ENDIF.

    ENDFORM. "ekpodisplay_onalv

    &----


    *& Form SET_PF_STATUS1

    &----


    FORM set_pf_status1 USING rt_extab TYPE slis_t_extab.

    SET PF-STATUS 'MENU' excluding rt_extab. "Copy from SALV .

    ENDFORM. "SET_PF_STATUS1

    &----


    *& Form SET_PF_STATUS

    &----


    FORM set_pf_status USING rt_extab TYPE slis_t_extab.

    SET PF-STATUS 'STANDARD' excluding rt_extab. "Copy from SALV .

    ENDFORM. "SET_PF_STATUS

    &----


    *& Form AT_user_command

    &----


    FORM at_user_command USING r_ucomm LIKE sy-ucomm

    rs_selfield TYPE slis_selfield.

    CASE r_ucomm.

    WHEN '&IC1'.

    IF rs_selfield-fieldname EQ 'EBELN'.

    READ TABLE it_ekko INTO wa_ekko INDEX rs_selfield-tabindex.

    SELECT ebeln ebelp ematn matkl netpr

    FROM ekpo

    INTO TABLE it_ekpo

    WHERE ebeln EQ wa_ekko-ebeln.

    PERFORM populate_fieldcat2.

    PERFORM populate_layout2.

    PERFORM get_ekposortinfo.

    PERFORM ekpodisplay_onalv.

    ELSE.

    MESSAGE i020(z50871msg) WITH text-013.

    ENDIF.

    WHEN 'SE16'.

    CALL TRANSACTION 'SE16'.

    WHEN 'SE37'.

    CALL TRANSACTION 'SE37'.

    WHEN 'DISP'.

    PERFORM get_popupdata.

    PERFORM get_popupfcat.

    PERFORM display_popup.

    ENDCASE.

    ENDFORM. "AT_user_command

    &----


    *& Form TOP_OF_PAGE

    &----


    FORM top_of_page.

    REFRESH it_listheadr.

    wa_listheadr-typ = 'H'.

    wa_listheadr-info = text-001.

    APPEND wa_listheadr TO it_listheadr.

    CLEAR wa_listheadr.

    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

    EXPORTING

    it_list_commentary = it_listheadr[]

    i_logo = 'ENJOYSAP_LOGO'. "From OAER transaction

    ENDFORM. "TOP_OF_PAGE

    &----


    *& Form build_print_params

    &----


    FORM build_print_params.

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

    st_printparams-no_coverpage = 'X'.

    ENDFORM. "build_print_params

    &----


    *& Form end_of_page

    &----


    FORM end_of_page.

    REFRESH it_listheadr.

    wa_listheadr-typ = 'H'.

    wa_listheadr-info = sy-pagno.

    APPEND wa_listheadr TO it_listheadr.

    CLEAR wa_listheadr.

    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

    EXPORTING

    it_list_commentary = it_listheadr[].

    ENDFORM. "end_of_page

    &----


    *& Form GET_EKPOSORTINFO

    &----


    FORM get_ekposortinfo.

    wa_ekposortinfo-up = 'X'.

    wa_ekposortinfo-spos = 1.

    wa_ekposortinfo-fieldname = 'EBELP'.

    wa_ekposortinfo-tabname = 'EKPO'.

    APPEND wa_ekposortinfo TO it_ekposortinfo.

    CLEAR wa_ekposortinfo.

    wa_ekposortinfo-up = 'X'.

    wa_ekposortinfo-spos = 2.

    wa_ekposortinfo-fieldname = 'EMATN'.

    wa_ekposortinfo-tabname = 'EKPO'.

    APPEND wa_ekposortinfo TO it_ekposortinfo.

    CLEAR wa_ekposortinfo.

    ENDFORM. "GET_EKPOSORTINFO

    *

    &----


    *& Form POPULATE_LAYOUT

    &----


    FORM populate_layout.

    wa_layout-colwidth_optimize = 'X'. "column width

    wa_layout-zebra = 'X'.

    • wa_layout-no_hline = 'X'.

    • wa_layout-no_vline = 'X'.

    • wa_layout-cell_merge = 'X'.

    wa_layout-box_fieldname = 'CHECK'.

    wa_layout-box_tabname = 'IT_EKKO'.

    wa_layout-window_titlebar = 'PURCHASE ORDER HEADER DETAILS'.

    ENDFORM. "POPULATE_LAYOUT

    &----


    *& Form get_EKKOsortinfo

    &----


    FORM get_ekkosortinfo.

    wa_sortinfo-up = 'X'.

    wa_sortinfo-spos = 1.

    wa_sortinfo-fieldname = 'EBELN'.

    wa_sortinfo-tabname = 'EKKO'.

    APPEND wa_sortinfo TO it_sortinfo.

    CLEAR wa_sortinfo.

    wa_sortinfo-up = 'X'.

    wa_sortinfo-spos = 2.

    wa_sortinfo-fieldname = 'BSTYP'.

    wa_sortinfo-tabname = 'EKKO'.

    APPEND wa_sortinfo TO it_sortinfo.

    CLEAR wa_sortinfo.

    wa_sortinfo-up = 'X'.

    wa_sortinfo-spos = 3.

    wa_sortinfo-fieldname = 'AEDAT'.

    wa_sortinfo-tabname = 'EKKO'.

    APPEND wa_sortinfo TO it_sortinfo.

    CLEAR wa_sortinfo.

    ENDFORM. "get_EKKOsortinfo

    &----


    *& Form EKKODISPLAY_ONALV

    &----


    FORM ekkodisplay_onalv.

    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

    EXPORTING

    i_callback_program = sy-repid

    i_callback_pf_status_set = 'SET_PF_STATUS1'

    i_callback_user_command = 'AT_USER_COMMAND'

    is_layout = wa_layout

    it_fieldcat = it_fieldcat

    it_sort = it_sortinfo[]

    it_filter = it_filter

    it_events = it_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. "EKKODISPLAY_ONALV

    &----


    *& Form validate_ebeln

    &----


    FORM validate_ebeln.

    SELECT ebeln

    FROM ekpo

    INTO TABLE it_ebeln

    WHERE ebeln IN so_ebeln.

    IF sy-subrc NE 0.

    MESSAGE e020(z50871msg) WITH text-014.

    ENDIF.

    ENDFORM. "validate_ebeln

    &----


    *& Form populate_layout2

    &----


    FORM populate_layout2 .

    CLEAR wa_layout.

    wa_layout-colwidth_optimize = 'X'. "column width

    • wa_layout-zebra = 'X'.

    • wa_layout-no_hline = 'X'.

    • wa_layout-no_vline = 'X'.

    • wa_layout-cell_merge = 'X'.

    wa_layout-window_titlebar = 'PURCHASE ORDER DETAILS SECOND SCREEN'.

    ENDFORM. " populate_layout2

    &----


    *& Form GET_POPUPDATA

    &----


    FORM get_popupdata .

    LOOP AT it_ekko INTO wa_ekko WHERE check = 'X'.

    READ TABLE it_eine INTO wa_eine WITH KEY ebeln = wa_ekko-ebeln.

    IF sy-subrc NE 0.

    MESSAGE i020(z50871msg) WITH text-015 wa_ekko-ebeln .

    ELSE.

    wa_popup-ebeln = wa_eine-ebeln.

    wa_popup-ekorg = wa_eine-ekorg.

    wa_popup-ekgrp = wa_eine-ekgrp.

    APPEND wa_popup TO it_popup.

    ENDIF.

    ENDLOOP.

    ENDFORM. " GET_POPUPDATA

    &----


    *& Form GET_POPUPFCAT

    &----


    FORM get_popupfcat .

    CLEAR wa_fieldcat.

    REFRESH it_fieldcat.

    wa_fieldcat-fieldname = 'EBELN'.

    wa_fieldcat-seltext_l = text-004.

    wa_fieldcat-hotspot = 'X'.

    APPEND wa_fieldcat TO it_fieldcat.

    wa_fieldcat-fieldname = 'EKORG'.

    wa_fieldcat-seltext_l = text-016.

    APPEND wa_fieldcat TO it_fieldcat.

    wa_fieldcat-fieldname = 'EKGRP'.

    wa_fieldcat-seltext_l = text-017.

    APPEND wa_fieldcat TO it_fieldcat.

    ENDFORM. " GET_POPUPFCAT

    &----


    *& Form DISPLAY_POPUP

    &----


    FORM display_popup .

    LOOP AT it_ekko INTO wa_ekko WHERE check EQ 'X'.

    wa_check-check = wa_ekko-check.

    APPEND wa_check TO it_check.

    ENDLOOP.

    IF it_check[] IS INITIAL.

    MESSAGE i020(z50871msg) WITH text-018.

    ENDIF.

    IF NOT it_popup[] IS INITIAL.

    CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'

    EXPORTING

    i_title = text-003

    i_allow_no_selection = 'X'

    i_scroll_to_sel_line = 'X'

    i_tabname = 'IT_POPUP'

    it_fieldcat = it_fieldcat

    i_callback_program = sy-repid

    TABLES

    t_outtab = it_popup

    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.

    ENDIF.

    REFRESH it_check.

    REFRESH it_popup.

    ENDFORM. " DISPLAY_POPUP

    &----


    *& Form get_ekko_data

    &----


    FORM get_ekko_data .

    SELECT ebeln bstyp bsart aedat ernam

    FROM ekko

    INTO CORRESPONDING FIELDS OF TABLE it_ekko

    WHERE ebeln IN so_ebeln.

    IF sy-subrc NE 0.

    MESSAGE e020(z50871msg) WITH text-019.

    ENDIF.

    ENDFORM. " get_ekko_data

    &----


    *& Form get_eine_data

    &----


    FORM get_eine_data .

    SELECT ebeln ekorg ekgrp

    FROM eine

    INTO TABLE it_eine

    WHERE ebeln IN so_ebeln.

    ENDFORM. " get_eine_data

    &----


    *& Form at_user_command1

    &----


    FORM at_user_command1 USING r_ucomm LIKE sy-ucomm

    rs_selfield TYPE slis_selfield.

    CASE r_ucomm.

    WHEN 'SE16'.

    CALL TRANSACTION 'SE16'.

    WHEN 'SE37'.

    CALL TRANSACTION 'SE37'.

    ENDCASE.

    ENDFORM. "at_user_command1

    Regards

    Sandeep REddy

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      sandep,

      if you take his code and debug through it, you will see that it does indeed get to the VBAK select statement through his IF statement. it's a good idea to add the CASE so that the Select only happens on double-click but it isn't going to solve his issue.

      the real issue is with the format of that field - that is why I recommended using the conversion exit FM.

  • author's profile photo Former Member
    Former Member
    Posted on Jun 14, 2008 at 04:19 AM

    Hi,

    In ALV Grid Interactive display, you sholud not use events for secondary list.

    Have a look on the following code

    TYPE-POOLS SLIS.

    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.

    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.

    DATA: V_REPID TYPE SY-REPID,

    I_FLDCAT TYPE SLIS_T_FIELDCAT_ALV,

    WA_FLDCAT TYPE SLIS_FIELDCAT_ALV,

    I_FLDCAT1 TYPE SLIS_T_FIELDCAT_ALV,

    WA_FLDCAT1 TYPE SLIS_FIELDCAT_ALV.

    DATA: I_TITLE_EKKO TYPE LVC_TITLE VALUE 'FIRST ALV REPORT',

    I_TITLE_EKPO TYPE LVC_TITLE VALUE 'SECONDARY ALV REPORT'.

    INITIALIZATION.

    V_REPID = SY-REPID.

    PERFORM FLDCATALOG.

    START-OF-SELECTION.

    PERFORM DATA_RETRIEVAL.

    PERFORM DISPLAY_ALV_REPORT.

    FORM FLDCATALOG.

    WA_FLDCAT-TABNAME = 'IT_EKKO'.

    WA_FLDCAT-FIELDNAME = 'EBELN'.

    WA_FLDCAT-SELTEXT_M = 'PO NUMBER'.

    APPEND WA_FLDCAT TO I_FLDCAT.

    CLEAR WA_FLDCAT.

    WA_FLDCAT-TABNAME = 'IT_EKKO'.

    WA_FLDCAT-FIELDNAME = 'AEDAT'.

    WA_FLDCAT-SELTEXT_M = 'DATE'.

    APPEND WA_FLDCAT TO I_FLDCAT.

    CLEAR WA_FLDCAT.

    WA_FLDCAT-TABNAME = 'IT_EKKO'.

    WA_FLDCAT-FIELDNAME = 'BUKRS'.

    WA_FLDCAT-SELTEXT_M = 'DOCUMENT TYPE'.

    APPEND WA_FLDCAT TO I_FLDCAT.

    CLEAR WA_FLDCAT.

    WA_FLDCAT-TABNAME = 'IT_EKKO'.

    WA_FLDCAT-FIELDNAME = 'LIFNR'.

    WA_FLDCAT-SELTEXT_M = 'VENDOR CODE'.

    APPEND WA_FLDCAT TO I_FLDCAT.

    CLEAR WA_FLDCAT.

    ENDFORM.

    FORM DATA_RETRIEVAL.

    SELECT EBELN AEDAT BUKRS BSART LIFNR

    FROM EKKO INTO TABLE IT_EKKO.

    ENDFORM.

    FORM DISPLAY_ALV_REPORT.

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    I_CALLBACK_PROGRAM = V_REPID

    I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

    I_GRID_TITLE = I_TITLE_EKKO

    IT_FIELDCAT = I_FLDCAT[]

    I_SAVE = 'A'

    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.

    FORM USER_COMMAND USING R_COMM TYPE SY-UCOMM

    RS_SELFIELD TYPE SLIS_SELFIELD.

    CASE R_COMM.

    WHEN '&IC1'.

    IF RS_SELFIELD-FIELDNAME = 'EBELN'.

    SET PARAMETER ID 'BES' FIELD WA_EKKO-EBELN. " BES is data element of EBELN

    READ TABLE IT_EKKO INTO WA_EKKO INDEX RS_SELFIELD-TABINDEX.

    PERFORM FLDCAT_EKPO.

    PERFORM DATA_RETRIEVAL_EKPO.

    PERFORM DISPLAY_ALV_REPORT_EKPO.

    ENDIF.

    ENDCASE.

    ENDFORM.

    FORM FLDCAT_EKPO.

    WA_FLDCAT1-TABNAME = 'IT_EKPO'.

    WA_FLDCAT1-FIELDNAME = 'EBELN'.

    WA_FLDCAT1-SELTEXT_M = 'PO NUMBER'.

    APPEND WA_FLDCAT1 TO I_FLDCAT1.

    CLEAR WA_FLDCAT1.

    WA_FLDCAT1-TABNAME = 'IT_EKPO'.

    WA_FLDCAT1-FIELDNAME = 'EBELP'.

    WA_FLDCAT1-SELTEXT_M = 'LINE NO'.

    APPEND WA_FLDCAT1 TO I_FLDCAT1.

    CLEAR WA_FLDCAT1.

    WA_FLDCAT1-TABNAME = 'IT_EKPO'.

    WA_FLDCAT1-FIELDNAME = 'MATNR'.

    WA_FLDCAT1-SELTEXT_M = 'MATERIAL NUMBER'.

    APPEND WA_FLDCAT1 TO I_FLDCAT1.

    CLEAR WA_FLDCAT1.

    WA_FLDCAT1-TABNAME = 'IT_EKPO'.

    WA_FLDCAT1-FIELDNAME = 'MENGE'.

    WA_FLDCAT1-SELTEXT_M = 'QUANTITY'.

    APPEND WA_FLDCAT1 TO I_FLDCAT1.

    CLEAR WA_FLDCAT1.

    WA_FLDCAT1-TABNAME = 'IT_EKPO'.

    WA_FLDCAT1-FIELDNAME = 'MEINS'.

    WA_FLDCAT1-SELTEXT_M = 'BASE UNIT OF MEASURE'.

    APPEND WA_FLDCAT1 TO I_FLDCAT1.

    CLEAR WA_FLDCAT1.

    WA_FLDCAT1-TABNAME = 'IT_EKPO'.

    WA_FLDCAT1-FIELDNAME = 'NETPR'.

    WA_FLDCAT1-SELTEXT_M = 'PRICE'.

    APPEND WA_FLDCAT1 TO I_FLDCAT1.

    CLEAR WA_FLDCAT1.

    ENDFORM.

    FORM DATA_RETRIEVAL_EKPO.

    SELECT EBELN EBELP MATNR MENGE MEINS NETPR

    INTO TABLE IT_EKPO

    FROM EKPO.

    ENDFORM.

    FORM DISPLAY_ALV_REPORT_EKPO.

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    I_CALLBACK_PROGRAM = V_REPID

    I_GRID_TITLE = I_TITLE_EKPO

    IT_FIELDCAT = I_FLDCAT1[]

    I_SAVE = 'A'

    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.

    REFRESH: IT_EKPO,I_FLDCAT1.

    ENDFORM.

    Reward, if useful.

    Thanks,

    Chandu

    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.