Skip to Content
avatar image
Former Member

How to get f4 help in editable ALV

Hi experts,

Please tell me how to add f4 help for an editable ALV

points for sure

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

6 Answers

  • Best Answer
    avatar image
    Former Member
    Aug 17, 2007 at 09:24 AM

    Hi kumar,

    Write a class to handle the f4 help for alv

    ex:

    CLASS lcl_event_receiver DEFINITION.

    • on_f4 help.

    handle_onf4

    FOR EVENT onf4

    OF cl_gui_alv_grid

    IMPORTING e_fieldname e_fieldvalue es_row_no

    er_event_data et_bad_cells e_display.

    endclass.

    in the implementation of the class call the function module : F4IF_INT_TABLE_VALUE_REQUEST

    method handle_onf4.

    CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

    EXPORTING

    retfield = 'PARENT'

    dynpprog = sy-cprog

    dynpnr = sy-dynnr

    dynprofield = 'PARENT'

    stepl = 0

    window_title = text-016

    value_org = 'S'

    TABLES

    value_tab = gt_parent

    return_tab = gt_ret_tab

    EXCEPTIONS

    parameter_error = 1

    no_values_found = 2

    OTHERS = 3.

    endmethod.

    create a object of this class type.

    Register the class to the alv grid for the functon module.

    CREATE OBJECT gref_event_receiver3.

    SET HANDLER gref_event_receiver3->handle_onf4 FOR gv_relation_alv.

    hope this helps,

    Regards,

    Prasant

    • Reward points if useful

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 17, 2007 at 09:40 AM
    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 17, 2007 at 09:23 AM

    Hi Kumar,

    Refer this thread,

    F4 help -- on editable alv field.

    Hope this helps.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 17, 2007 at 09:24 AM

    Hi

    Have a look at this sample code.

    REPORT ztest440.

    TABLES : mara.

    TYPES: BEGIN OF t_mara,

    matnr TYPE mara-matnr,

    lvorm TYPE mara-lvorm,

    mtart TYPE mara-mtart,

    mbrsh TYPE mara-mbrsh,

    matkl TYPE mara-matkl,

    meins TYPE mara-meins,

    brgew TYPE mara-brgew,

    ntgew TYPE mara-ntgew,

    gewei TYPE mara-gewei,

    END OF t_mara.

    TYPES: BEGIN OF t_equk,

    matnr TYPE equk-matnr,

    werks TYPE equk-werks,

    bdatu TYPE equk-bdatu,

    vdatu TYPE equk-vdatu,

    qunum TYPE equk-qunum,

    END OF t_equk.

    CLASS : lcl_alv_grid DEFINITION DEFERRED.

    DATA : gi_mara TYPE STANDARD TABLE OF t_mara,

    gi_equk TYPE STANDARD TABLE OF t_equk,

    gs_mara TYPE t_mara,

    gs_equk TYPE t_equk.

    *-- Global data definitions for ALV

    *--- ALV Grid instance reference

    DATA : gw_alvgrid TYPE REF TO cl_gui_alv_grid,

    gw_alvgrid1 TYPE REF TO cl_gui_alv_grid .

    *--- Custom container instance reference

    DATA gw_container TYPE REF TO cl_gui_custom_container.

    DATA gw_event_handler TYPE REF TO lcl_alv_grid.

    DATA gw_event_handler1 TYPE REF TO lcl_alv_grid.

    DATA gw_container1 TYPE REF TO cl_gui_custom_container.

    *--- Field catalog table

    DATA : gi_fieldcat TYPE lvc_t_fcat,

    gi_fieldcat1 TYPE lvc_t_fcat,

    gs_fieldcat TYPE lvc_s_fcat,

    gs_fieldcat1 TYPE lvc_s_fcat.

    *--- Layout structure

    DATA : gs_layout TYPE lvc_s_layo,

    gs_layout1 TYPE lvc_s_layo.

    ----


    • CLASS lcl_alv_grid DEFINITION

    ----


    *

    ----


    CLASS lcl_alv_grid DEFINITION.

    PUBLIC SECTION.

    METHODS :

    • Handle_double_click

    handle_double_click

    FOR EVENT double_click OF cl_gui_alv_grid

    IMPORTING e_row e_column,

    • Handle_double_click

    handle_onf4

    FOR EVENT onf4 OF cl_gui_alv_grid

    IMPORTING e_fieldname.

    PRIVATE SECTION.

    ENDCLASS. " lcl_alv_grid DEFINITION

    ----


    • CLASS LCL_ALV_GRID IMPLEMENTATION *

    ----


    CLASS lcl_alv_grid IMPLEMENTATION.

    ----


    • METHOD handle_double_click *

    ----


    METHOD handle_double_click.

    READ TABLE gi_mara INTO gs_mara INDEX e_row.

    IF sy-subrc = 0.

    SELECT matnr

    werks

    bdatu

    vdatu

    qunum

    FROM equk

    INTO TABLE gi_equk

    WHERE matnr = gs_mara-matnr.

    IF sy-dbcnt NE 0.

    SORT gi_equk BY matnr werks bdatu.

    ENDIF.

    CALL SCREEN 0002.

    ENDIF.

    ENDMETHOD. "handle_double_click

    ----


    • METHOD handle_onf4 *

    ----


    METHOD handle_onf4.

    PERFORM f4_help USING e_fieldname.

    ENDMETHOD. "handle_double_click

    ENDCLASS. " lcl_alv_grid IMPLEMENTATION

    ----


    • SELECTION SCREEN DEFINITION *

    ----


    SELECTION-SCREEN BEGIN OF BLOCK b1.

    SELECT-OPTIONS : s_matnr FOR mara-matnr NO INTERVALS,

    s_mtart FOR mara-mtart NO INTERVALS.

    SELECTION-SCREEN END OF BLOCK b1.

    ----


    • START-OF-SELECTION *

    ----


    START-OF-SELECTION.

    SELECT matnr

    lvorm

    mtart

    mbrsh

    matkl

    meins

    brgew

    ntgew

    gewei

    FROM mara

    INTO TABLE gi_mara

    WHERE matnr IN s_matnr

    AND mtart IN s_mtart.

    IF sy-dbcnt NE 0.

    SORT gi_mara BY matnr.

    ENDIF.

    CALL SCREEN 0001.

    &----


    *& Module STATUS_0001 OUTPUT

    &----


    • text

    ----


    MODULE status_0001 OUTPUT.

    SET PF-STATUS '0001'.

    SET TITLEBAR '001'.

    PERFORM build_alv_display.

    ENDMODULE. " STATUS_0001 OUTPUT

    &----


    *& Module USER_COMMAND_0001 INPUT

    &----


    • text

    ----


    MODULE user_command_0001 INPUT.

    CASE sy-ucomm.

    WHEN 'EXIT'.

    LEAVE TO SCREEN 0.

    WHEN 'SAVE'.

    LEAVE TO SCREEN 0.

    ENDCASE.

    ENDMODULE. " USER_COMMAND_0001 INPUT

    &----


    *& Form build_alv_display

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM build_alv_display .

    PERFORM build_fieldcat.

    PERFORM build_layout.

    PERFORM create_alv_grid.

    PERFORM display_alv_grid.

    ENDFORM. " build_alv_display

    &----


    *& Form build_fieldcat

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM build_fieldcat .

    CLEAR gs_fieldcat.

    gs_fieldcat-fieldname = 'MATNR'.

    gs_fieldcat-tabname = 'MARA'.

    gs_fieldcat-coltext = 'Material Number'.

    gs_fieldcat-outputlen = '18'.

    gs_fieldcat-edit = ' '.

    gs_fieldcat-just = 'C'.

    gs_fieldcat-col_pos = '1'.

    APPEND gs_fieldcat TO gi_fieldcat.

    CLEAR gs_fieldcat.

    gs_fieldcat-fieldname = 'LVORM'.

    gs_fieldcat-tabname = 'MARA'.

    gs_fieldcat-coltext = 'Deletion'.

    gs_fieldcat-outputlen = '8'.

    gs_fieldcat-edit = ' '.

    gs_fieldcat-just = 'C'.

    gs_fieldcat-col_pos = '2'.

    gs_fieldcat-checkbox = 'X'.

    APPEND gs_fieldcat TO gi_fieldcat.

    CLEAR gs_fieldcat.

    gs_fieldcat-fieldname = 'MTART'.

    gs_fieldcat-tabname = 'MARA'.

    gs_fieldcat-coltext = 'Material Type'.

    gs_fieldcat-outputlen = '13'.

    gs_fieldcat-edit = ' '.

    gs_fieldcat-just = 'C'.

    gs_fieldcat-col_pos = '3'.

    APPEND gs_fieldcat TO gi_fieldcat.

    CLEAR gs_fieldcat.

    gs_fieldcat-fieldname = 'MBRSH'.

    gs_fieldcat-tabname = 'MARA'.

    gs_fieldcat-coltext = 'Industry sector'.

    gs_fieldcat-outputlen = '15'.

    gs_fieldcat-edit = ' '.

    gs_fieldcat-just = 'C'.

    gs_fieldcat-col_pos = '4'.

    APPEND gs_fieldcat TO gi_fieldcat.

    CLEAR gs_fieldcat.

    gs_fieldcat-fieldname = 'MATKL'.

    gs_fieldcat-tabname = 'MARA'.

    gs_fieldcat-coltext = 'Material group'.

    gs_fieldcat-outputlen = '14'.

    gs_fieldcat-edit = ' '.

    gs_fieldcat-just = 'C'.

    gs_fieldcat-col_pos = '5'.

    APPEND gs_fieldcat TO gi_fieldcat.

    CLEAR gs_fieldcat.

    gs_fieldcat-fieldname = 'MEINS'.

    gs_fieldcat-tabname = 'MARA'.

    gs_fieldcat-coltext = 'Base Unit of Measure'.

    gs_fieldcat-outputlen = '20'.

    gs_fieldcat-edit = ' '.

    gs_fieldcat-just = 'C'.

    gs_fieldcat-col_pos = '6'.

    APPEND gs_fieldcat TO gi_fieldcat.

    CLEAR gs_fieldcat.

    gs_fieldcat-fieldname = 'BRGEW'.

    gs_fieldcat-tabname = 'MARA'.

    gs_fieldcat-coltext = 'Gross weight'.

    gs_fieldcat-outputlen = '13'.

    gs_fieldcat-edit = ' '.

    gs_fieldcat-just = 'C'.

    gs_fieldcat-col_pos = '7'.

    APPEND gs_fieldcat TO gi_fieldcat.

    CLEAR gs_fieldcat.

    gs_fieldcat-fieldname = 'NTGEW'.

    gs_fieldcat-tabname = 'MARA'.

    gs_fieldcat-coltext = 'Net weight'.

    gs_fieldcat-outputlen = '13'.

    gs_fieldcat-edit = ' '.

    gs_fieldcat-just = 'C'.

    gs_fieldcat-col_pos = '8'.

    APPEND gs_fieldcat TO gi_fieldcat.

    CLEAR gs_fieldcat.

    gs_fieldcat-fieldname = 'GEWEI'.

    gs_fieldcat-tabname = 'MARA'.

    gs_fieldcat-coltext = 'Weight Unit'.

    gs_fieldcat-outputlen = '11'.

    gs_fieldcat-edit = ' '.

    gs_fieldcat-just = 'C'.

    gs_fieldcat-col_pos = '9'.

    APPEND gs_fieldcat TO gi_fieldcat.

    ENDFORM. " build_fieldcat

    &----


    *& Form build_layout

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM build_layout .

    gs_layout-sel_mode = 'A'.

    gs_layout-edit = ' '.

    gs_layout-no_toolbar = ' '.

    gs_layout-grid_title = 'Material Data'.

    gs_layout-no_headers = ' '.

    gs_layout-weblook = 'X'.

    ENDFORM. " build_layout

    &----


    *& Form create_alv_grid

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM create_alv_grid .

    IF gw_container IS INITIAL.

    CREATE OBJECT gw_container

    EXPORTING

    container_name = 'CC_ALV'.

    • Display ALV grid

    IF gw_alvgrid IS INITIAL.

    CREATE OBJECT gw_alvgrid

    EXPORTING

    i_parent = gw_container.

    ENDIF.

    ENDIF.

    IF gw_event_handler IS INITIAL.

    CREATE OBJECT gw_event_handler.

    SET HANDLER gw_event_handler->handle_double_click

    FOR gw_alvgrid.

    SET HANDLER gw_event_handler->handle_onf4

    FOR gw_alvgrid.

    ENDIF.

    ENDFORM. " create_alv_grid

    &----


    *& Form display_alv_grid

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM display_alv_grid .

    CALL METHOD gw_alvgrid->set_table_for_first_display

    EXPORTING

    i_buffer_active = ' '

    i_bypassing_buffer = ' '

    i_structure_name = 'T_MARA'

    is_layout = gs_layout

    CHANGING

    it_outtab = gi_mara[]

    it_fieldcatalog = gi_fieldcat[]

    EXCEPTIONS

    OTHERS = 0.

    ENDFORM. " display_alv_grid

    *&----


    *

    *& Module STATUS_0002 OUTPUT

    *&----


    *

    • text

    *----


    *

    MODULE status_0002 OUTPUT.

    SET PF-STATUS '0002'.

    SET TITLEBAR '002'.

    PERFORM build_alv_display1.

    ENDMODULE. " STATUS_0002 OUTPUT

    *&----


    *

    *& Module USER_COMMAND_0002 INPUT

    *&----


    *

    • text

    *----


    *

    MODULE user_command_0002 INPUT.

    CASE sy-ucomm.

    WHEN 'EXIT'.

    LEAVE TO SCREEN 0.

    ENDCASE.

    ENDMODULE. " USER_COMMAND_0002 INPUT

    *&----


    *

    *& Form build_alv_display1

    *&----


    *

    • text

    *----


    *

    • --> p1 text

    • <-- p2 text

    *----


    *

    FORM build_alv_display1 .

    PERFORM build_fieldcat1.

    PERFORM build_layout1.

    PERFORM create_alv_grid1.

    PERFORM display_alv_grid1.

    ENDFORM. " build_alv_display1

    *&----


    *

    *& Form build_fieldcat2

    *&----


    *

    • text

    *----


    *

    • --> p1 text

    • <-- p2 text

    *----


    *

    FORM build_fieldcat1.

    CLEAR gs_fieldcat.

    gs_fieldcat-fieldname = 'MATNR'.

    gs_fieldcat-tabname = 'EQUK'.

    gs_fieldcat-coltext = 'Material Number'.

    gs_fieldcat-outputlen = '18'.

    gs_fieldcat-edit = ' '.

    gs_fieldcat-just = 'C'.

    gs_fieldcat-col_pos = '1'.

    gs_fieldcat-f4availabl = 'X'.

    APPEND gs_fieldcat TO gi_fieldcat1.

    CLEAR gs_fieldcat.

    gs_fieldcat-fieldname = 'WERKS'.

    gs_fieldcat-tabname = 'EQUK'.

    gs_fieldcat-coltext = 'Plant'.

    gs_fieldcat-outputlen = '4'.

    gs_fieldcat-edit = ' '.

    gs_fieldcat-just = 'C'.

    gs_fieldcat-col_pos = '2'.

    APPEND gs_fieldcat TO gi_fieldcat1.

    CLEAR gs_fieldcat.

    gs_fieldcat-fieldname = 'BDATU'.

    gs_fieldcat-tabname = 'EQUK'.

    gs_fieldcat-coltext = 'Valid Untill'.

    gs_fieldcat-outputlen = '12'.

    gs_fieldcat-edit = ' '.

    gs_fieldcat-just = 'C'.

    gs_fieldcat-col_pos = '3'.

    APPEND gs_fieldcat TO gi_fieldcat1.

    CLEAR gs_fieldcat.

    gs_fieldcat-fieldname = 'VDATU'.

    gs_fieldcat-tabname = 'EQUK'.

    gs_fieldcat-coltext = 'Valid From'.

    gs_fieldcat-outputlen = '10'.

    gs_fieldcat-edit = ' '.

    gs_fieldcat-just = 'C'.

    gs_fieldcat-col_pos = '4'.

    APPEND gs_fieldcat TO gi_fieldcat1.

    CLEAR gs_fieldcat.

    gs_fieldcat-fieldname = 'QUNUM'.

    gs_fieldcat-tabname = 'EQUK'.

    gs_fieldcat-coltext = 'Quota'.

    gs_fieldcat-outputlen = '10'.

    gs_fieldcat-edit = ' '.

    gs_fieldcat-just = 'C'.

    gs_fieldcat-col_pos = '5'.

    APPEND gs_fieldcat TO gi_fieldcat1.

    ENDFORM. " build_fieldcat2

    *&----


    *

    *& Form build_layout2

    *&----


    *

    • text

    *----


    *

    • --> p1 text

    • <-- p2 text

    *----


    *

    FORM build_layout1.

    gs_layout1-sel_mode = 'A'.

    gs_layout1-edit = ' '.

    gs_layout1-no_toolbar = ' '.

    gs_layout1-grid_title = 'Quota Header Data'.

    gs_layout1-no_headers = ' '.

    ENDFORM. " build_layout1

    *&----


    *

    *& Form create_alv_grid2

    *&----


    *

    • text

    *----


    *

    • --> p1 text

    • <-- p2 text

    *----


    *

    FORM create_alv_grid1.

    IF gw_container1 IS INITIAL.

    CREATE OBJECT gw_container1

    EXPORTING

    container_name = 'CC_ALV1'.

    • Display ALV grid

    IF gw_alvgrid1 IS INITIAL.

    CREATE OBJECT gw_alvgrid1

    EXPORTING

    i_parent = gw_container1.

    ENDIF.

    ENDIF.

    IF gw_event_handler1 IS INITIAL.

    CREATE OBJECT gw_event_handler1.

    SET HANDLER gw_event_handler1->handle_onf4

    FOR gw_alvgrid1.

    ENDIF.

    ENDFORM. " create_alv_grid1

    *&----


    *

    *& Form display_alv_grid2

    *&----


    *

    • text

    *----


    *

    • --> p1 text

    • <-- p2 text

    *----


    *

    FORM display_alv_grid1 .

    DATA : li_f4 TYPE lvc_t_f4,

    ls_f4 TYPE lvc_s_f4.

    CALL METHOD gw_alvgrid1->set_table_for_first_display

    EXPORTING

    i_buffer_active = ' '

    i_bypassing_buffer = ' '

    i_structure_name = 'T_EQUK'

    is_layout = gs_layout1

    CHANGING

    it_outtab = gi_equk[]

    it_fieldcatalog = gi_fieldcat1[]

    EXCEPTIONS

    OTHERS = 0.

    IF li_f4[] IS INITIAL.

    MOVE 'MATNR' TO ls_f4-fieldname.

    MOVE 'X' TO ls_f4-register.

    MOVE 'X' TO ls_f4-getbefore.

    APPEND ls_f4 TO li_f4.

    CLEAR ls_f4.

    CALL METHOD gw_alvgrid1->register_f4_for_fields

    EXPORTING

    it_f4 = li_f4.

    ENDIF.

    ENDFORM. " display_alv_grid1

    &----


    *& Form f4_help

    &----


    • text

    ----


    • -->P_FIELDNAME text

    ----


    FORM f4_help USING p_fieldname.

    TYPES : BEGIN OF t_values,

    matnr TYPE mara-matnr,

    END OF t_values.

    DATA : li_fields TYPE TABLE OF dfies,

    li_select_values TYPE TABLE OF ddshretval,

    li_values TYPE TABLE OF t_values,

    ls_fields TYPE dfies,

    ls_values TYPE t_values.

    REFRESH : li_fields,

    li_select_values.

    SELECT matnr

    FROM equk

    INTO TABLE li_values.

    CASE p_fieldname.

    WHEN 'MATNR'.

    ls_fields-tabname = 'EQUK'.

    ls_fields-fieldname = 'MATNR'.

    APPEND ls_fields TO li_fields.

    CLEAR ls_fields.

    SORT li_values BY matnr.

    DELETE ADJACENT DUPLICATES FROM li_values COMPARING matnr.

    CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

    EXPORTING

    retfield = 'MATNR'

    TABLES

    value_tab = li_values

    field_tab = li_fields

    return_tab = li_select_values.

    IF sy-subrc = 0.

    • LOOP AT li_select_values WHERE fieldname = 'MATNR'.

    • clear gs_mara.

    • gs_mara in

    ENDIF.

    ENDCASE.

    ENDFORM. " f4_help

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 17, 2007 at 09:28 AM

    Hi,

    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_step.

    PERFORM value_request_step.

    IF NOT gi_return_tab[] IS INITIAL.

    LOOP AT gi_return_tab INTO gs_return_tab WHERE fieldname = 'ZSTEP'.

    p_step = gs_return_tab-fieldval.

    ENDLOOP.

    ENDIF.

    &----


    *

    *& Form value_request_step

    &----


    • For providing the F4 functionality.

    ----


    • -->P_GI_RETURN_TAB Internal Table for getting the values

    ----


    FORM value_request_step.

    "TABLES pi_gi_return_tab structure gs_return_tab.

    • structure for getting the possible values from step.

    TYPES : BEGIN OF lt_step,

    step TYPE z8istep,

    END OF lt_step.

    • Internal table definition.

    DATA : li_fields_tab TYPE STANDARD TABLE OF dfies,

    li_step TYPE STANDARD TABLE OF lt_step.

    • Work Area definition.

    DATA : ls_fields_tab TYPE dfies,

    ls_step TYPE lt_step.

    *data:gs_return_tab type ddshretval.

    • Working variable definition.

    REFRESH : gi_return_tab.

    • Call function for screen fields values read

    MOVE : 'ZSTEP' TO ls_fields_tab-fieldname,

    'ZDC8IT53' TO ls_fields_tab-tabname.

    APPEND ls_fields_tab TO li_fields_tab.

    ls_step-step = '01'.

    APPEND ls_step TO li_step.

    CLEAR ls_step.

    ls_step-step = '02'.

    APPEND ls_step TO li_step.

    CLEAR ls_step.

    ls_step-step = '03'.

    APPEND ls_step TO li_step.

    CLEAR ls_step.

    ls_step-step = '04'.

    APPEND ls_step TO li_step.

    CLEAR ls_step.

    • Preparation of the matchcode

    CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

    EXPORTING

    retfield = 'ZSTEP'

    dynpprog = sy-repid

    dynpnr = sy-dynnr

    value_org = 'C'

    TABLES

    value_tab = li_step

    field_tab = li_fields_tab

    return_tab = gi_return_tab

    EXCEPTIONS

    parameter_error = 1

    no_values_found = 2

    OTHERS = 3.

    IF sy-subrc NE 0.

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

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

    ENDIF.

    ENDFORM. " value_request_arbpl

    Reward if useful,

    Thanks,

    Mahendar

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 17, 2007 at 09:30 AM

    REPORT z_alv12.

    TABLES : vbak,vbap.

    TYPES: BEGIN OF itab ,

    vbeln TYPE vbak-vbeln,

    erdat TYPE vbak-erdat,

    ernam TYPE vbak-ernam,

    audat TYPE vbak-audat,

    END OF itab.

    TYPES: BEGIN OF itab11,

    vbeln TYPE vbap-vbeln,

    erdat TYPE vbap-posnr,

    matnr TYPE vbap-matnr,

    audat TYPE vbap-matkl,

    END OF itab11.

    DATA: itab1 TYPE STANDARD TABLE OF itab,

    gi_tab TYPE lvc_t_f4,

    ls_itab TYPE itab.

    DATA: itab12 TYPE STANDARD TABLE OF itab11,

    ls_itab1 TYPE itab11.

    *--- ALV Grid instance reference

    DATA :gr_alvgrid TYPE REF TO cl_gui_alv_grid ,

    gr_alvgrid1 TYPE REF TO cl_gui_alv_grid .

    *--- Name of the custom control added on the screen

    DATA: gc_custom_control_name TYPE scrfname.

    CLASS lcl_event_handler DEFINITION DEFERRED.

    *--- Custom container instance reference

    DATA gr_ccontainer TYPE REF TO cl_gui_custom_container .

    DATA gr_ccontainer1 TYPE REF TO cl_gui_custom_container .

    *--- Field catalog table

    DATA gt_fieldcat TYPE lvc_t_fcat .

    DATA gt_fieldcat1 TYPE lvc_t_fcat .

    *--- Layout structure

    DATA gs_layout TYPE lvc_s_layo.

    DATA gs_layout1 TYPE lvc_s_layo.

    DATA gw_event_handler TYPE REF TO lcl_event_handler.

    DATA gw_event_handler1 TYPE REF TO lcl_event_handler.

    SELECT-OPTIONS: vbeln FOR vbak-vbeln.

    ----


    • CLASS lcl_event_handler DEFINITION .

    ----


    *

    ----


    CLASS lcl_event_handler DEFINITION .

    PUBLIC SECTION.

    METHODS :

    • Handle_double_click

    handle_double_click

    FOR EVENT double_click OF cl_gui_alv_grid

    IMPORTING e_row e_column,

    • Handle_double_click

    handle_onf4

    FOR EVENT onf4 OF cl_gui_alv_grid

    IMPORTING e_fieldname.

    PRIVATE SECTION.

    ENDCLASS. " lcl_alv_grid DEFINITION

    ----


    • CLASS lcl_event_handler IMPLEMENTATION . *

    ----


    CLASS lcl_event_handler IMPLEMENTATION .

    *Handle Double Click

    METHOD handle_double_click .

    PERFORM handle_double_click USING e_row e_column .

    ENDMETHOD . "handle_double_click

    ----


    • METHOD handle_onf4 *

    ----


    METHOD handle_onf4.

    PERFORM f4_help USING e_fieldname.

    ENDMETHOD. "handle_double_click

    ENDCLASS. "lcl_event_handler IMPLEMENTATION

    &----


    *& Form handle_double_click

    &----


    • text

    ----


    FORM handle_double_click USING p_e_row

    p_e_column.

    IF sy-dynnr = '0412'.

    READ TABLE itab1 INTO ls_itab INDEX p_e_row.

    IF sy-subrc = 0.

    SELECT vbeln

    posnr

    matnr

    matkl

    FROM vbap

    INTO TABLE itab12

    WHERE vbeln = ls_itab-vbeln.

    CALL SCREEN 200 .

    ENDIF .

    • ELSEIF sy-dynnr = '0200'.

    • READ TABLE itab12 INTO ls_itab1 INDEX p_e_row.

    • IF sy-subrc = 0.

    • SET PARAMETER ID 'MAT' FIELD ls_itab1-matnr.

    • CALL TRANSACTION 'MM02' AND SKIP FIRST SCREEN.

    • ENDIF.

    ENDIF.

    ENDFORM. " handle_double_click

    START-OF-SELECTION.

    CALL SCREEN 0412.

    &----


    *& Module alv_display OUTPUT

    &----


    • text

    ----


    MODULE alv_display OUTPUT.

    SET PF-STATUS 'ABC'.

    SELECT vbeln

    erdat

    ernam

    audat

    FROM vbak

    INTO TABLE itab1

    WHERE vbeln IN vbeln.

    PERFORM display_alv.

    ENDMODULE. " alv_display OUTPUT

    &----


    *& Form display_alv

    &----


    • text

    ----


    FORM display_alv .

    IF gr_alvgrid IS INITIAL.

    CREATE OBJECT gr_ccontainer

    EXPORTING

    container_name = 'CC_ALV'.

    CREATE OBJECT gr_alvgrid

    EXPORTING

    i_parent = gr_ccontainer.

    IF gw_event_handler IS INITIAL.

    CREATE OBJECT gw_event_handler.

    SET HANDLER gw_event_handler->handle_double_click

    FOR gr_alvgrid.

    ENDIF.

    **----Preparing field catalog.

    PERFORM prepare_field_catalog CHANGING gt_fieldcat .

    **----Preparing layout structure

    PERFORM prepare_layout CHANGING gs_layout .

    CALL METHOD gr_alvgrid->set_table_for_first_display

    EXPORTING

    is_layout = gs_layout

    CHANGING

    it_outtab = itab1[]

    it_fieldcatalog = gt_fieldcat

    EXCEPTIONS

    invalid_parameter_combination = 1

    program_error = 2

    too_many_lines = 3

    OTHERS = 4.

    IF sy-subrc <> 0.

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

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

    ENDIF.

    ELSE .

    CALL METHOD gr_alvgrid->refresh_table_display

    EXCEPTIONS

    finished = 1

    OTHERS = 2 .

    IF sy-subrc <> 0.

    *--Exception handling

    ENDIF.

    ENDIF.

    ENDFORM. " display_alv

    &----


    *& Form prepare_field_catalog

    &----


    • text

    ----


    FORM prepare_field_catalog CHANGING p_gt_fieldcat.

    DATA ls_fcat TYPE lvc_s_fcat .

    ls_fcat-fieldname = 'VBELN' .

    ls_fcat-coltext = 'SALES DOCUMENT' .

    ls_fcat-seltext = 'SALES DOCUMENT' .

    • ls_fcat-f4availabl = 'X'.

    APPEND ls_fcat TO gt_fieldcat.

    CLEAR ls_fcat .

    ls_fcat-fieldname = 'ERDAT' .

    ls_fcat-coltext = 'ERDAT' .

    ls_fcat-seltext = 'ERDAT' .

    • ls_fcat-f4availabl = 'X'.

    APPEND ls_fcat TO gt_fieldcat .

    CLEAR ls_fcat .

    ls_fcat-fieldname = 'ERNAM' .

    ls_fcat-coltext = 'ERNAM' .

    ls_fcat-seltext = 'ERNAM' .

    • ls_fcat-f4availabl = ''.

    APPEND ls_fcat TO gt_fieldcat .

    CLEAR ls_fcat .

    ls_fcat-fieldname = 'AUDAT' .

    ls_fcat-coltext = 'AUDAT' .

    ls_fcat-seltext = 'AUDAT' .

    • ls_fcat-f4availabl = ''.

    APPEND ls_fcat TO gt_fieldcat.

    CLEAR ls_fcat .

    ENDFORM. " prepare_field_catalog

    &----


    *& Form prepare_layout

    &----


    • text

    ----


    FORM prepare_layout CHANGING p_gs_layout.

    gs_layout-zebra = 'X' .

    gs_layout-grid_title = 'FirstList' .

    gs_layout-smalltitle = 'X' .

    ENDFORM. " prepare_layout

    &----


    *& Module pai_0412 INPUT

    &----


    • text

    ----


    MODULE pai_0412 INPUT.

    CASE sy-ucomm.

    WHEN 'BACK'.

    LEAVE TO SCREEN 0.

    ENDCASE.

    ENDMODULE. " pai_0412 INPUT

    &----


    *& Module alv_display1 OUTPUT

    &----


    • text

    ----


    MODULE alv_display1 OUTPUT.

    SET PF-STATUS 'WER'.

    DATA : li_f4 TYPE lvc_t_f4,

    ls_f4 TYPE lvc_s_f4.

    IF gr_alvgrid1 IS INITIAL.

    CREATE OBJECT gr_ccontainer1

    EXPORTING

    container_name = 'CC_ALV1'.

    CREATE OBJECT gr_alvgrid1

    EXPORTING

    i_parent = gr_ccontainer1.

    • secondary list interactive report....

    IF gw_event_handler1 IS INITIAL.

    CREATE OBJECT gw_event_handler1.

    SET HANDLER gw_event_handler1->handle_double_click

    FOR gr_alvgrid1.

    SET HANDLER gw_event_handler1->handle_onf4

    FOR gr_alvgrid1.

    ENDIF.

    **----Preparing field catalog.

    PERFORM prepare_field_catalog1 CHANGING gt_fieldcat1 .

    **----Preparing layout structure

    PERFORM prepare_layout1 CHANGING gs_layout1 .

    CALL METHOD gr_alvgrid1->set_table_for_first_display

    EXPORTING

    is_layout = gs_layout1

    CHANGING

    it_outtab = itab12[]

    it_fieldcatalog = gt_fieldcat1

    EXCEPTIONS

    invalid_parameter_combination = 1

    program_error = 2

    too_many_lines = 3

    OTHERS = 4.

    IF sy-subrc <> 0.

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

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

    ENDIF.

    ELSE .

    CALL METHOD gr_alvgrid1->refresh_table_display

    EXCEPTIONS

    finished = 1

    OTHERS = 2.

    ENDIF.

    IF li_f4[] IS INITIAL.

    MOVE 'MATNR' TO ls_f4-fieldname.

    MOVE 'X' TO ls_f4-register.

    MOVE 'X' TO ls_f4-getbefore.

    APPEND ls_f4 TO li_f4.

    CLEAR ls_f4.

    CALL METHOD gr_alvgrid1->register_f4_for_fields

    EXPORTING

    it_f4 = li_f4.

    ENDIF.

    ENDMODULE. " alv_display1 OUTPUT

    &----


    *& Form prepare_field_catalog1

    &----


    • text

    ----


    FORM prepare_field_catalog1 CHANGING p_gt_fieldcat1.

    DATA ls_fcat1 TYPE lvc_s_fcat .

    ls_fcat1-fieldname = 'VBELN' .

    ls_fcat1-coltext = 'SALES DOCUMENT' .

    ls_fcat1-seltext = 'SALES DOCUMENT' .

    • ls_fcat1-f4availabl = 'X'.

    APPEND ls_fcat1 TO gt_fieldcat1.

    CLEAR ls_fcat1 .

    ls_fcat1-fieldname = 'POSNR' .

    ls_fcat1-coltext = 'POSNR' .

    ls_fcat1-seltext = 'POSNR' .

    • ls_fcat1-f4availabl = 'X'.

    APPEND ls_fcat1 TO gt_fieldcat1 .

    CLEAR ls_fcat1 .

    ls_fcat1-fieldname = 'MATNR' .

    ls_fcat1-coltext = 'MATNR' .

    ls_fcat1-seltext = 'MATNR' .

    ls_fcat1-f4availabl = 'X'.

    APPEND ls_fcat1 TO gt_fieldcat1 .

    CLEAR ls_fcat1 .

    ls_fcat1-fieldname = 'MATKL' .

    ls_fcat1-coltext = 'MATKL' .

    ls_fcat1-seltext = 'MATKL' .

    • ls_fcat1-f4availabl = ''.

    APPEND ls_fcat1 TO gt_fieldcat1.

    CLEAR ls_fcat1 .

    ENDFORM. " prepare_field_catalog1

    &----


    *& Form prepare_layout1

    &----


    • text

    ----


    FORM prepare_layout1 CHANGING p_gs_layout1.

    gs_layout1-zebra = 'X' .

    gs_layout1-grid_title = 'Interactive' .

    gs_layout1-smalltitle = 'X' .

    ENDFORM. " prepare_layout

    &----


    *& Form f4_help

    &----


    • text

    ----


    FORM f4_help USING p_e_fieldname.

    TYPES : BEGIN OF t_values,

    matnr TYPE vbap-matnr,

    END OF t_values.

    DATA : li_fields TYPE TABLE OF dfies,

    li_select_values TYPE TABLE OF ddshretval,

    li_values TYPE TABLE OF t_values,

    ls_fields TYPE dfies,

    ls_values TYPE t_values.

    REFRESH : li_fields,

    li_select_values.

    SELECT matnr

    FROM vbap

    INTO TABLE li_values.

    CASE p_e_fieldname.

    WHEN 'MATNR'.

    ls_fields-tabname = 'VBAP'.

    ls_fields-fieldname = 'MATNR'.

    APPEND ls_fields TO li_fields.

    CLEAR ls_fields.

    SORT li_values BY matnr.

    DELETE ADJACENT DUPLICATES FROM li_values COMPARING matnr.

    CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

    EXPORTING

    retfield = 'MATNR'

    TABLES

    value_tab = li_values

    field_tab = li_fields

    return_tab = li_select_values.

    IF sy-subrc = 0.

    ENDIF.

    ENDCASE.

    ENDFORM. " f4_help

    &----


    *& Module USER_COMMAND_0200 INPUT

    &----


    • text

    ----


    MODULE user_command_0200 INPUT.

    CASE sy-ucomm.

    WHEN 'BACK'.

    LEAVE TO SCREEN 0.

    ENDCASE.

    ENDMODULE. " USER_COMMAND_0200 INPUT

    Add comment
    10|10000 characters needed characters exceeded