F4 help -- on editable alv field.

<b><i>Hi ABAPers,</i></b>
<i><b>I want to incorporate F4 help with the editable field of my ALV report.</b></i>
The editable field is type of IHPA-PARNR.
At present user is able to enter value at this field. but the requirement is to give F4 help there.
I am not using the OOPs alv.
<i><b>Please suggest me
Thanks in advance
Regards
Debjani</b></i>

For F4 help, you must register the fields whose F4 request will trigger the “onf4” event. For this you must prepare a table of type “LVC_T_F4” and register this table using the method “register_f4_for_fields”. While preparing table you must include a line for each field which will trigger F4 event. For each field in the structure;
- Pass the fieldname to ‘FIELDNAME’
- Set ‘REGISTER’ to make the field registered,
- Set ‘GETBEFORE’ to provide field content transport before F4 in editable mode
- Set ‘CHNGEAFTER’ to make the data changed after F4 in editable mode.
DATA: lt_f4 TYPE lvc_t_f4 WITH HEADER LINE .
lt_f4-fieldname = 'Your field name'.
lt_f4-register = 'X' .
lt_f4-getbefore = 'X' .
APPEND lt_f4 .
CALL METHOD gr_alvgrid->register_f4_for_fields
EXPORTING
it_f4 = lt_f4[] .
A sample “onf4” method implementation
METHOD handle_on_f4 .
PERFORM f4_help USING e_fieldname es_row_no .
er_event_data->m_event_handled = 'X' .
ENDMETHOD .
The attribute “er_event_data->m_event_handled” is to prevent further processing of standard F4 help.

Similar Messages

  • Exception while creating f4 help for editable alv field

         hi experts
    i have created search help for editable alv field by following link
    http://scn.sap.com/docs/DOC-39832
    But i m getting an exception :  Field symbol has not yet been assigned.
    exception area code
       read table <tab1> into <ls_wa> index i_row_id.
        assign component m_cl_variant->ms_layout-stylefname
               of structure <ls_wa> to <l_field>.
        read table <l_field> into ls_style
                with table key fieldname = is_col_id-fieldname.
        if sy-subrc eq 0.
          if ls_style-style o mc_style_enabled.
            ready_for_input = 1.
            exit.
          elseif ls_style-style o mc_style_disabled.
            ready_for_input = 0.
            exit.
          endif.
    first read statement is giving sy-subrc =4.
    PS: exception from method..:IS_READY_FOR_INPUT
    kindly help

    Hello Ankush,
    read table <tab1>  ASSIGNING <ls_wa> index i_row_id.
    IF  <ls_wa> IS ASSIGNED.
        assign component m_cl_variant->ms_layout-stylefname
               of structure <ls_wa> to <l_field>.
        read table <l_field> into ls_style
                with table key fieldname = is_col_id-fieldname.
        if sy-subrc eq 0.
          if ls_style-style o mc_style_enabled.
            ready_for_input = 1.
            exit.
          elseif ls_style-style o mc_style_disabled.
            ready_for_input = 0.
            exit.
          endif.
    ENDIF.
    Regards,
    TP

  • F4 help in Editable ALV

    Hello Experts,
    We have a requirement of showing F4 help for a editable field of ALV Grid. I'm able to register the on_f4 event, but I do have a problem while implementing the method, as the pop up values are not appearing. I have used following logic for implementing the class(PFB the code I have used for implementing the method). Can you please suggest the corrections in the following code or suggest a new method, if the following will not work.
      METHOD on_f4.
      TYPE-POOLS: slis.
            DATA: gs_selfield TYPE slis_selfield,
                  gs_private TYPE slis_data_caller_exit,
                  g_exit(1) TYPE c,
                  gs_fieldcat_popup TYPE slis_fieldcat_alv.
            DATA: gt_fieldcat_popup TYPE TABLE OF slis_fieldcat_alv,
                  pt_value type standard table of ztable.
        SELECT * FROM ztable
        INTO TABLE pt_value.
            gs_fieldcat_popup-fieldname   = 'Z_SALES'.
            gs_fieldcat_popup-seltext_l   =  'Sales'.
            gs_fieldcat_popup-col_pos     = 1.
            gs_fieldcat_popup-outputlen   = 34.
            gs_fieldcat_popup-datatype    = 'CHAR'.
            APPEND gs_fieldcat_popup TO gt_fieldcat_popup .
       CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'
          EXPORTING
          I_TITLE                       =
          I_SELECTION                   = 'X'
          I_ZEBRA                       = ' '
          I_SCREEN_START_COLUMN         = 0
          I_SCREEN_START_LINE           = 0
          I_SCREEN_END_COLUMN           = 0
          I_SCREEN_END_LINE             = 0
          I_CHECKBOX_FIELDNAME          =
          I_LINEMARK_FIELDNAME          =
          I_SCROLL_TO_SEL_LINE          = 'X'
            i_tabname                     = '1'
          I_STRUCTURE_NAME              =
           IT_FIELDCAT                   = gt_fieldcat_popup[]
          IT_EXCLUDING                  =
          I_CALLBACK_PROGRAM            =
          I_CALLBACK_USER_COMMAND       =
          IS_PRIVATE                    =
        IMPORTING
          ES_SELFIELD                   =
          E_EXIT                        =
          tables
            t_outtab                      = pt_value
        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.
      ENDMETHOD.
    Best Regards,
    Bharath.

    Hello ,
    while implementing F4 for Editable ALV , you need to make sure follwing steps.
    1. Field Catalog.
         gs_fieldcat-f4availabl = 'X '.
    2.Register f4 event.
          gs_f4-fieldname  = 'CONNID'.
          gs_f4-getbefore  = check.
          gs_f4-chngeafter = change.
          append gs_f4 to gt_f4.
          call method grid->register_f4_for_fields
            exporting
              it_f4 = gt_f4.
    3.Implementing F4 Method.

  • Match code for an editable ALV field

    Hi everyone,
    I have an ALV with an editable field. I want to add matchcode with predefined 2 values to it.
    I used EDIT option for field catalog to make this field editable.
    I defined this field as a custom field in one of the DB table.
    The possible values of the field are in the declaration of the DOMAIN. But I still can't see the matchcode with those values when I want to enter a value into this field in ALV.
    What should I do?
    Thank you in advance,
    Diana

    Hi Diana,
    Welcome to SDN
    When you set the field catalog you have to set option F4AVAILABL to 'X'.
    If w_fcat is the field catalog structure then set as
    w_fact-F4AVAILABL = 'X'
    w_fact-CHECKTABLE = 'SCARR'
    w_fact-REF_TABLE = 'SPFLI'
    w_fact-REF_FIELD = 'CARRID'.
    Refer the standard program BCALV_TEST_GRID_F4_HELP and BCALV_GRID_EDIT_DELTA
    Please go through this thread for sample code
    Re: F4 for fields in ALV Grid
    Hope this would help you.
    Good luck
    Narin

  • A question about editing ALV fields

    Hello Expert,
    In my project, we need to read data from DB and display in the ALV. In the ALV output, we should be able to edit the records, and after user clicks the "Save" button in the applicaiton toolbar, the program should be able to save the changed data into DB.
    Currently, I can display the data in ALV and all fields are editable. After I change some data and click "Save", the program will go into subroutine 'F_ALV_USER_COMMAND',  but the data in the internal table GT_OUTTAB is not changed.
    I generate the ALV output by the following calling:
    call function 'REUSE_ALV_GRID_DISPLAY'
          exporting
            i_callback_program = wf_pgm
            is_layout          = gs_layout
            it_fieldcat        = gt_fieldcat[]
            i_callback_pf_status_set     = 'F_PF_STATUS_SET'
            i_callback_user_command = 'F_ALV_USER_COMMAND'
            is_variant         = g_variant
          tables
            t_outtab           = gt_outtab
          exceptions
            program_error      = 1
            others             = 2.
    In the subroutine 'F_PF_STATUS_SET', I call a GUI Status defined by myself.
    But if I call as below
    call function 'REUSE_ALV_GRID_DISPLAY'
          exporting
            i_callback_program = wf_pgm
            is_layout          = gs_layout
            it_fieldcat        = gt_fieldcat[]
           i_callback_pf_status_set     = 'F_PF_STATUS_SET'
            i_callback_user_command = 'F_ALV_USER_COMMAND'
            is_variant         = g_variant
          tables
            t_outtab           = gt_outtab
          exceptions
            program_error      = 1
            others             = 2.
    GT_OUTTAB is changed accordingly after clicking the "Save".
    Can any expert tell me why Internal table is not changed in the case I use user-defined GUI Status?
    Thanks & Regards, Johnny
    Edited by: Yongbo Wu on Jun 10, 2011 10:51 AM

    Hi Yongbo;
    Unfortunately REUSE_ALV_GRID_DISPLAY has update problem.
    REUSE_ALV_LIST_DISPLAY FM is making automatic update/change itab.
    You can change REUSE_ALV_GRID_DISPLAY FM with REUSE_ALV_LIST_DISPLAY FM.
    Best Regards.
    call function 'REUSE_ALV_LIST_DISPLAY' "'REUSE_ALV_GRID_DISPLAY'

  • Step to step document for F4 Help in Editable ALV

    Hi Gurus,
        I am new to Web Dynpros,
    It would be great if any one of you can send me a document for creating a F4 help for individual cells of an Editable Table....
    Its Very Urgent.....
    Pleas mail me @ [email protected]
    Points will be awarded to the useful answers / documents....

    Hello Kiran,
    In your context structure, where you have defined your context nodes and attributes, select the attribute for which you would like to have an F4 help and select the type of input help in the properties table underneath.
    Regards,
    Neha

  • Search Help For An Editable ALV List

    Hi,
    All ABAP Gurus !!
    I have made an Editable ALV with the fields of ZTable. In ALV I want the search help in one of the columns.The entry in that should come from the standard table name-TVM5 and the field which should come is MVGR5. MVGR5  does not contain the search help .Following are the description for my ZTable-------
    Field Name    - MC_NO,
    Data Element - ZZMC_NO1,
    Domain          -ZZMC_NO1.
    While creating this ZTable, in the Entry help/check tab I have also mention Input help with fixed values in the column- Origin of the input help and entered the entries also.
    About ALV (Only one alv column is shown here for reference in which search help or input help is needed of all the possible entries)---
    DATA: INT_FIELDCATALOG2 TYPE LVC_T_FCAT WITH HEADER LINE.
    DATA: WA_FIELDCATALOG2  TYPE LVC_S_FCAT ,
               WA_LAYOUT2        TYPE SLIS_LAYOUT_ALV ,
              GD_LAYOUT2        TYPE LVC_S_LAYO.     "slis_layout_alv.
      WA_FIELDCATALOG2-FIELDNAME      = 'MC_NO'.
      WA_FIELDCATALOG2-TABNAME        = 'T_ITAB2'.            " T_ITAB2 contains all the other fields
      WA_FIELDCATALOG2-SCRTEXT_M     = 'Machine No.'.
      WA_FIELDCATALOG2-EDIT                  = 'X'.
      WA_FIELDCATALOG2-F4AVAILABL   = 'X'.
      WA_FIELDCATALOG2-REF_FIELD       = 'MVGR5'.
      WA_FIELDCATALOG2-REF_TABLE     = 'TVM5'.
    APPEND WA_FIELDCATALOG2 TO INT_FIELDCATALOG2.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
        EXPORTING
          I_CALLBACK_PROGRAM              = V_REPID
          I_CALLBACK_PF_STATUS_SET   = 'SET_PF_STATUS1'
          I_CALLBACK_USER_COMMAND  = 'USER_COMMAND'
          IT_FIELDCAT_LVC                        = INT_FIELDCATALOG2[]
          IS_LAYOUT_LVC                         = GD_LAYOUT2
        TABLES
          T_OUTTAB                 = T_ITAB2.
    Please explain in detail
    Thanks to all in advance.

    Please check the following links :
    F4 help -- on editable alv field.
    F4 help in editable ALV
    ALV Editable Grid Control F4 help problem
    And search the forum for  f4 help on editable alv
    KR
    Veeranji Reddy P.

  • F4 help for REUSE ALV grid

    Hi,
    I am doing an ALV report using REUSE_ALV_GRID_DISPLAY . This is my requirement
    If user press F4 in field in WERKS then i need to get values from table T001W and also from my custom table YT001W and display, so user can select from the f4 list.
    How to do this.
    Your help is appreciated
    Sa_R

    DATA : alvgrid TYPE REF TO cl_gui_alv_grid,
    custom_container TYPE REF TO cl_gui_custom_container,
    fieldcatalog TYPE lvc_t_fcat.
    table to contain fields that require f4...............................
    DATA : lt_f4 TYPE lvc_t_f4 WITH HEADER LINE.
    ok_code declaration...................................................
    DATA : ok_code TYPE sy-ucomm.
    Tables declaration....................................................
    TABLES : zaemp.
    Types declaration.....................................................
    TYPES : BEGIN OF ty_emp,
    code LIKE zaemp-code,
    designation LIKE zaemp-designation,
    END OF ty_emp.
    Internal table declaration............................................
    DATA : i_emp TYPE TABLE OF ty_emp.
    Workarea declaration..................................................
    DATA : wa_emp TYPE ty_emp.
    Selection screen parameters...........................................
    SELECT-OPTIONS : s_code FOR zaemp-code.
    CLASS lcl_event_handler DEFINITION
    CLASS lcl_event_handler DEFINITION.
    PUBLIC SECTION.
    METHODS :
    handle_on_f1 FOR EVENT onf1 OF cl_gui_alv_grid
    IMPORTING e_fieldname es_row_no er_event_data,
    handle_on_f4 for event onf4 of cl_gui_alv_grid
    importing e_fieldname es_row_no er_event_data
    ENDCLASS.
    CLASS lcl_event_handler IMPLEMENTATION
    CLASS lcl_event_handler IMPLEMENTATION.
    METHOD handle_on_f1.
    custom f1 help for code field.......................................
    IF e_fieldname = 'code'.
    CALL SCREEN 3001.
    ENDIF.
    to prevent processing of standard f1 help............................
    er_event_data->m_event_handled = 'X'.
    ENDMETHOD.
    Method handle_on_f4.
    standard f4 help will be invoked......................................
    endmethod.
    ENDCLASS.
    start of selection....................................................
    START-OF-SELECTION.
    SELECT code designation FROM zaemp
    INTO CORRESPONDING FIELDS OF TABLE i_emp
    WHERE code IN s_code.
    CALL SCREEN 3000.
    *& Module STATUS_3000 OUTPUT
    text
    MODULE status_3000 OUTPUT.
    SET PF-STATUS 'ZTOOL'.
    SET TITLEBAR 'ZTITLE'.
    IF alvgrid IS INITIAL.
    CREATE OBJECT custom_container
    EXPORTING
    container_name = 'ZCONTAINER'.
    CREATE OBJECT alvgrid
    EXPORTING
    i_parent = custom_container.
    PERFORM prepare_f4.
    CALL METHOD alvgrid->register_f4_for_fields
    EXPORTING
    it_f4 = lt_f4[]
    creating instance for event handler..................................
    DATA : event_handler TYPE REF TO lcl_event_handler.
    CREATE OBJECT event_handler.
    SET HANDLER event_handler->handle_on_f1 FOR alvgrid.
    SET HANDLER event_handler->handle_on_f4 FOR alvgrid.
    preparing field catalog..............................................
    PERFORM prepare_fieldcatalog CHANGING fieldcatalog.
    CALL METHOD alvgrid->set_table_for_first_display
    EXPORTING
    I_BYPASSING_BUFFER =
    I_BUFFER_ACTIVE =
    I_CONSISTENCY_CHECK =
    I_STRUCTURE_NAME =
    IS_VARIANT =
    I_SAVE =
    I_DEFAULT = 'X'
    IS_LAYOUT =
    IS_PRINT =
    IT_SPECIAL_GROUPS =
    IT_TOOLBAR_EXCLUDING =
    IT_HYPERLINK =
    IT_ALV_GRAPHICS =
    IT_EXCEPT_QINFO =
    CHANGING
    it_outtab = i_emp
    it_fieldcatalog = fieldcatalog
    IT_SORT =
    IT_FILTER =
    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.
    ENDIF.
    ENDMODULE. " STATUS_3000 OUTPUT
    preparing field catalog...............................................
    FORM prepare_fieldcatalog CHANGING i_fieldcatalog TYPE lvc_t_fcat.
    DATA : ls_fcat TYPE lvc_s_fcat.
    ls_fcat-fieldname = 'code'.
    ls_fcat-ref_table = 'zaemp'.
    ls_fcat-coltext = 'EMPLOYEE ID'.
    APPEND ls_fcat TO i_fieldcatalog.
    CLEAR ls_fcat.
    ls_fcat-fieldname = 'designation'.
    ls_fcat-ref_table = 'zaemp'.
    ls_fcat-coltext = 'EMPLOYEE NAME'.
    APPEND ls_fcat TO i_fieldcatalog.
    ENDFORM.
    *& Module USER_COMMAND_3000 INPUT
    text
    MODULE user_command_3000 INPUT.
    CASE ok_code.
    WHEN 'BACK'.
    LEAVE TO SCREEN 0.
    WHEN 'EXIT'.
    LEAVE PROGRAM.
    ENDCASE.
    ENDMODULE. " USER_COMMAND_3000 INPUT
    *& Module USER_COMMAND_3001 INPUT
    text
    MODULE user_command_3001 INPUT.
    CASE ok_code.
    WHEN 'SAVE'.
    LEAVE TO SCREEN 0.
    WHEN 'BACK'.
    LEAVE TO SCREEN 0.
    ENDCASE.
    ENDMODULE. " USER_COMMAND_3001 INPUT
    *& Module STATUS_3001 OUTPUT
    text
    MODULE status_3001 OUTPUT.
    SET PF-STATUS 'GUI'.
    SET TITLEBAR 'TITLE'.
    ENDMODULE. " STATUS_3001 OUTPUT
    preparing fields to be registered for f4 help.........................
    FORM prepare_f4.
    lt_f4-fieldname = 'designation'.
    lt_f4-register = 'X'.
    lt_f4-getbefore = 'X'.
    lt_f4-chngeafter = 'X'.
    APPEND lt_f4.
    ENDFORM.
    Hi
    For creating the F4 Help see the sample code and do accordingly
    See the following ex:
    TYPES: BEGIN OF TY_MBLNR,
    MBLNR LIKE MKPF-MBLNR,
    END OF TY_MBLNR.
    DATA: IT_MBLNR TYPE STANDARD TABLE OF TY_MBLNR WITH HEADER LINE.
    data: it_ret like ddshretval occurs 0 with header line.
    At selection-screen on value-request for s_mat-low.
    Select MBLNR from mkpf into table it_mblnr.
    CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
    EXPORTING
    DDIC_STRUCTURE = ' '
    RETFIELD = 'MBLNR'
    PVALKEY = ' '
    DYNPPROG = ' '
    DYNPNR = ' '
    DYNPROFIELD = ' '
    STEPL = 0
    WINDOW_TITLE =
    VALUE = ' '
    VALUE_ORG = 'S'
    MULTIPLE_CHOICE = ' '
    DISPLAY = ' '
    CALLBACK_PROGRAM = ' '
    CALLBACK_FORM = ' '
    MARK_TAB =
    IMPORTING
    USER_RESET =
    TABLES
    VALUE_TAB = IT_MBLNR
    FIELD_TAB =
    RETURN_TAB = IT_RET
    DYNPFLD_MAPPING =
    EXCEPTIONS
    PARAMETER_ERROR = 1
    NO_VALUES_FOUND = 2
    OTHERS = 3
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    IF SY-SUBRC = 0.
    read table it_ret index 1.
    move it_ret-fieldval to S_mat-low.
    ENDIF.
    Go through the test program.
    REPORT Ztest_HELP .
    TABLES : MARA.
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    PARAMETERS : P_MATNR(10) TYPE C.
    SELECTION-SCREEN END OF BLOCK B1.
    DATA : BEGIN OF ITAB OCCURS 0,
    MATNR TYPE MATNR,
    END OF ITAB.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_MATNR.
    SELECT MATNR
    FROM MARA
    INTO TABLE ITAB
    UP TO 10 ROWS.
    CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
    EXPORTING
    RETFIELD = 'MATERIAL NUMBER'
    DYNPPROG = SY-REPID
    DYNPNR = SY-DYNNR
    DYNPROFIELD = 'P_MATNR'
    VALUE_ORG = 'S'
    TABLES
    VALUE_TAB = ITAB
    EXCEPTIONS
    PARAMETER_ERROR = 1
    NO_VALUES_FOUND = 2
    OTHERS = 3.
    F4 help -- on editable alv field.
    The specified item was not found.
    Message was edited by:
            Karthikeyan Pandurangan

  • Short dump SAVE_NOT_ALLOWED while using CL_GUI_ALV_GRID in editable ALV

    I created an editable ALV field and when i changed the value in that field and click tab  or enter, then i am getting a shortdump. This is not happening regularly.
    can anyone let me know the reason for this.
    Sharath.

    Hi
    Set the handlers for the events DATA_CHANGED and DATA_CHANGED_FINISHED for your grid and handles changes in these methods accordingly.
    *...local class definition
                        for event data_changed of cl_gui_alv_grid
                        importing er_data_changed,
                        handle_data_changed_finished
                        for event data_changed_finished of cl_gui_alv_grid
    *...display the grid
        call method grid1->set_table_for_first_display
          exporting
            i_bypassing_buffer   = abap_true
            i_structure_name      = viewname
            is_print                      = gs_print
            is_layout                   = gs_layout
            it_toolbar_excluding = i_exclude
            i_save                      = 'A'
          changing
            it_outtab                   = <i_itab>
            it_fieldcatalog           = gt_fieldcat.
        if sy-subrc ne 0.
          exit.
        endif.
        set handler handle_double_click
                    handle_button_click
                    handle_user_command
                    handle_data_changed
                    handle_data_changed_finished
                    handle_onf4
                    handle_toolbar
                    for grid1.
    regards
    Isaac Prince

  • Search help for date field in Editable ALV

    Hello Friends,
    I am using editable alv using 'reuse_* '.
    I have used date as input field. While creating fieldcatlog also i have  declared dat as a mkpf-budat.
    But i am not getting serach help for date in output.
    Is it possible with reuse or i have to go by object oriented ?

    Hi,
    Just pass the Edit option of the fieldcatalog for those specific fields...
    fcat-edit = 'X'.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program       = sy-cprog
          i_callback_pf_status_set = 'PF_STATUS_SET'
          i_callback_user_command  = 'USER_COMMAND'    "<----  pass this
          i_callback_top_of_page   = 'TOP'
          is_layout                = it_layout
          it_fieldcat              = it_fcat
          i_default                = 'X'
          i_save                   = 'A'
          it_events                = it_event
        TABLES
          t_outtab                 = it_final
        EXCEPTIONS
          program_error            = 1
          OTHERS                   = 2.
    *&      Form  USER_COMMAND
    *       text
    *      -->R_UCOMM      text
    *      -->RS_SELFIELD  text
    FORM user_command USING r_ucomm LIKE sy-ucomm
                            rs_selfield TYPE slis_selfield.
      CASE r_ucomm.
        WHEN '&DATA_SAVE'.                "<-------check this
          PERFORM save_data.
      ENDCASE.
    ENDFORM.                    "USER_COMMAND

  • Edit a field in ALV tree in a subscreen of a module pool

    Hi
    I want to make a field editable in the ALV tree based on some condtions in a subscreen of a module pool.  I used the edit = 'X' field in the fieldcatalog still it  is showing the field as display and not edit.
    Please help me to get the field as editable and save it to the database table.
    Please not this is ALV TREE
    Regards,
    Mozila

    Hi Mayank,
    Thanks for the reply
    I am using oops method.
    I tried making the field which is to be made editable  as wa_fieldcatalog-edit = 'X'. But its not working. I didnt get you when you said  edit in layout object.
    I also went through the demo programs but these programs are not having editable fields.
    My code is as follows:
    IF tree4 IS INITIAL.
    * create container for alv-tree
      l_tree_container_name = 'TREE4'.
      CREATE OBJECT l_custom_container
        EXPORTING
          container_name              = l_tree_container_name
        EXCEPTIONS
          cntl_error                  = 1
          cntl_system_error           = 2
          create_error                = 3
          lifetime_error              = 4
          lifetime_dynpro_dynpro_link = 5.
    * create tree control
      CREATE OBJECT tree4
        EXPORTING
          i_parent                    = l_custom_container
          i_node_selection_mode       = cl_gui_column_tree=>node_sel_mode_multiple
          i_item_selection            = 'X'
          i_no_html_header            = 'X'
          i_no_toolbar                = 'X'
        EXCEPTIONS
          cntl_error                  = 1
          cntl_system_error           = 2
          create_error                = 3
          lifetime_error              = 4
          illegal_node_selection_mode = 5
          failed                      = 6
          illegal_column_name         = 7.
    * create hierarchy
      CALL METHOD tree4->set_table_for_first_display
        EXPORTING
          is_layout       = s_layo
        CHANGING
          it_sort         = it_sort
          it_outtab       = it_final
          it_fieldcatalog = it_fieldcat.
    ELSE.
      CALL METHOD tree4->refresh_table_display
        EXPORTING
          it_sort           = it_sort
        EXCEPTIONS
          program_error     = 1
          failed            = 2
          cntl_system_error = 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.
    endif.

  • Editable ALV - how to throw an error message for a specific line & field

    Hi all,
    I've implemented an editable ALV and also the ON_DATA_CHECK event to check the values, entered in the ALV. So this works fine and I can check the values.
    But now, I want to throw an error message corresponding to the field in the ALV, where the error occured.
    How can I throw this error message corresponding to a specific line/field in the ALV?
    I was using REPORT_ATTRIBUTE_ERROR_MESSAGE and REPORT_ELEMENT_ERROR_MESSAGE but without success.
    I'm also using a loop over the "CHANGES" in the ALV and within this loop, I use
    elem_alv = node_alv->get_element( index = <change>-element_index ) 
    to get the element for the message.
    CALL METHOD lo_message_manager->REPORT_ELEMENT_ERROR_MESSAGE
      EXPORTING
        MESSAGE_TEXT              = 'my message'
        ELEMENT                   = elem_alv
    *    ATTRIBUTES                =
    *    PARAMS                    =
    *    MSG_USER_DATA             =
    *    IS_PERMANENT              = ABAP_FALSE
    *    SCOPE_PERMANENT_MSG       = CO_MSG_SCOPE_CTXT_ELEMENT
    *    MSG_INDEX                 =
    *    CANCEL_NAVIGATION         =
    *    IS_VALIDATION_INDEPENDENT = ABAP_FALSE.
    2.) is it right, that for an editable ALV, I can't use the WDDOBEFOREACTION to do the checks?
    If I try to use this, I can't get the values of my ALV table to check it.
    Thanks,
    Andreas

    Hi Andreas,
    I have tried to replicate your problem and I am getting the desired output. I have a row by name TEMP_NEW in my ALV and I want to throw an error message whenever the user enters a value of 4 for that particular field. Please find my coding as below. The important thing is where we perform the actual comparison between the r_value and 4. r_value is defined in SALV_WD_S_TABLE_MOD_CELL as reference to type DATA. So suppose the user enters a value of say 3 in the TEMP_NEW field of the ALV then r_value would contain 3 but if you observe its type in debugging mode it would be as TYPE REF TO I and not TYPE I. So you cannot directly say something like:
    "if ls_modified_cells-r_value = 3" as this would lead to a syntax error. Define a field-symbol say <temp> and then use it to get the actual value into it by saying like:
    ASSIGN ls_modified_cells-r_value->* TO <temp>.
    Then you can use this <temp> for comparison in your IF statement like:
    IF  <temp> = 3.
    Find the entire coding as below:
    METHOD check_data.
      DATA: lr_node TYPE REF TO if_wd_context_node,
            lr_element TYPE REF TO if_wd_context_element,
            ls_modified_cells TYPE salv_wd_s_table_mod_cell.
      FIELD-SYMBOLS <temp> TYPE data.
    " get message manager
      DATA lo_api_controller     TYPE REF TO if_wd_controller.
      DATA lo_message_manager    TYPE REF TO if_wd_message_manager.
      lo_api_controller ?= wd_this->wd_get_api( ).
      CALL METHOD lo_api_controller->get_message_manager
        RECEIVING
          message_manager = lo_message_manager.
      lr_node = wd_context->get_child_node( name = 'NODE' ).
      LOOP AT r_param->t_modified_cells INTO ls_modified_cells.
        lr_element = lr_node->get_element( index = ls_modified_cells-index ).
        IF ls_modified_cells-attribute = 'TEMP_NEW'.
    " Get the value extracted into the field symbol from the reference variable
          ASSIGN ls_modified_cells-r_value->* TO <temp>.
    " Use the value present in this field-symbol for your comparison
          IF  <temp> = 4.
    " report message
            CALL METHOD lo_message_manager->report_attribute_error_message
              EXPORTING
                message_text   = 'Sample message text'
                element        = lr_element
                attribute_name = ls_modified_cells-attribute.
          ENDIF.
        ENDIF.
      ENDLOOP.
    ENDMETHOD.
    Hope this helps resolve your problem.
    Regards,
    Uday

  • Alv field with f4 help without using class

    Hi,
    Can any one give me a program of "Alv field with f4 help without using class".
    Thanking you in advance.

    hi
    <b>Linking F4 Help to Fields</b>
    For the last section, we will deal with linking F4 help to fields. It is easy. As usual, define, implement and register the event “onf4” at proper places in your code. For F4 help, you must register the fields whose F4 request will trigger the “onf4” event. For this you must prepare a table of type “LVC_T_F4” and register this table using the method “register_f4_for_fields”. While preparing table you must include a line for each field which will trigger F4 event. For each field in the structure;
    &#1048766; Pass the fieldname to ‘FIELDNAME’
    &#1048766; Set ‘REGISTER’ to make the field registered,
    &#1048766; Set ‘GETBEFORE’ to provide field content transport before F4 in editable mode
    &#1048766; Set ‘CHNGEAFTER’ to make the data changed after F4 in editable mode.
    DATA: lt_f4 TYPE lvc_t_f4 WITH HEADER LINE .
    lt_f4-fieldname = 'PRICE'.
    lt_f4-register = 'X' .
    lt_f4-getbefore = 'X' .
    APPEND lt_f4 .
    CALL METHOD gr_alvgrid->register_f4_for_fields
    EXPORTING
    it_f4 = lt_f4[] .
    Preparing table for the fields to be registered to trigger F4 event
    METHOD handle_on_f4 .
    PERFORM f4_help USING e_fieldname es_row_no .
    er_event_data->m_event_handled = 'X' .
    ENDMETHOD .
    A sample “onf4” method implementation
    Again, we set the attribute “er_event_data->m_event_handled” to prevent further processing of standard F4 help.
    regards
    Ravish
    <b>
    reward if useful</b>

  • Quan field editable alv

    HI,
    Ive made an editable alv using my z-table. The z-table has a field sqty which is of type 'QUAN' referring to 'sunit' field(type UNIT) of same ztable .
    Whenever i try to edit this sqty field it behaves weirdly. If i enter 123456 value in sqty , it takes it as 123.456 , or if i enter 1 in sqty it takes it as .001.
    Why does it divide by 1000 always. IS it something to do with unit conversion? how do i overcome this problem.
    I also had written a program to upload in this table using flat file, that program works fine.
    Can anyone guide me please.
    Bye

    Hi,
    There is a conversion routine attached to the Unit field. ( Conversion routine -CUNIT). Check in output characteristics of the domain.
    One of the ways is to clone the domain and datatype and use them without the conversion routine.
    Hope it helps.
    Thanks,
    Saipriya

  • Edit single field in single line in ALV

    Dear experts,
    I have an ALV with many lines.
    I need to edit one field in a few of those lines, depending on the data. How can I do that? I aldeady used the EDIT parameter of fieldcat, but it changed the whole column of the table.
    Please help.
    Thanks,
    Roxani

    Hi again,
    1. Just for info purpose.
    2. We can use colours   
    3. Not only the full row color,
      we can also manipulate the color in each cell.
    4.
    IMPORTANT THINGS
    a. Extra field in internal table
    clr TYPE slis_t_specialcol_alv,
    (this field will contain the colour codes)
    b. assign fieldname to alv layout
    alvly-coltab_fieldname = 'CLR'
    c. work area for colour
    DATA : clrwa TYPE slis_specialcol_alv.
    d. Populating the color
    Once again
    Loop at ITAB.
    *********logic
    if itab-field < 0 "---negative
    clrwa-fieldname = 'FIELDNAME'. "<--- FIELDNAME FOR COLOR
    clrwa-color-col = 6. <------- COLOUR 0-9
    APPEND clrwa TO itab-clr.
    MODIFY ITAB.
    endif.
    ENDLOOP.
    5. just copy paste in new program
    6.
    REPORT abc .
    NECESSARY / MUST
    TYPE-POOLS : slis.
    DATA : alvfc TYPE slis_t_fieldcat_alv.
    DATA : alvly TYPE slis_layout_alv.
    ITAB DECLARATION
    DATA : prg TYPE sy-repid.
    DATA : BEGIN OF itab OCCURS 0.
    INCLUDE STRUCTURE t001.
    DATA : clname(3) TYPE c,
    clr TYPE slis_t_specialcol_alv,
    END OF itab.
    DATA : clrwa TYPE slis_specialcol_alv.
    PARAMETERS : a TYPE c.
    DATA : flname TYPE slis_fieldname.
    SELECT
    START-OF-SELECTION.
    SELECT * FROM t001
    INTO CORRESPONDING FIELDS OF TABLE itab..
    LOOP AT itab..
    IF SY-TABIX <= 5.
    itab-clname = 'C50'.
    ELSE.
    itab-clname = 'C30'.
    ENDIF.
    MODIFY itab.
    ENDLOOP.
    LOOP AT ITAB.
    check itab-bukrs = '1000'
    clrwa-fieldname = 'BUTXT'.
    clrwa-color-col = 6.
    APPEND clrwa TO itab-clr.
    MODIFY ITAB.
    clrwa-fieldname = 'LAND1'.
    clrwa-color-col = 4.
    APPEND clrwa TO itab-clr.
    MODIFY ITAB.
    ENDLOOP.
    prg = sy-repid.
    flname = 'CLNAME'.
    alvly-info_fieldname = 'CLNAME'.
    alvly-coltab_fieldname = 'CLR'.
    LOOP AT ITAB.
    if sy-tabix = 3.
    clrwa-fieldname = 'BUTXT'.
    clrwa-color-col = 6.
    APPEND clrwa TO itab-clr.
    MODIFY ITAB.
    clrwa-fieldname = 'LAND1'.
    clrwa-color-col = 1.
    APPEND clrwa TO itab-clr.
    MODIFY ITAB.
    endif.
    ENDLOOP
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
    i_program_name = prg
    i_internal_tabname = 'ITAB'
    i_inclname = prg
    CHANGING
    ct_fieldcat = alvfc
    EXCEPTIONS
    inconsistent_interface = 1
    program_error = 2
    OTHERS = 3.
    minimum
    *CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
    it_fieldcat = alvfc
    TABLES
    t_outtab = itab
    EXCEPTIONS
    program_error = 1
    OTHERS = 2
    extra
    sy-uname = 'XYZAB'.
    prg = sy-repid.
    Excluding
    DATA : excl TYPE slis_t_extab.
    DATA : exclwa TYPE slis_extab.
    exclwa = '&OUP'.
    APPEND exclwa TO excl.
    exclwa = '&ODN'.
    APPEND exclwa TO excl.
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
    it_fieldcat = alvfc
    i_callback_program = sy-repid
    is_layout = alvly
    i_callback_user_command = 'ITAB_USER_COMMAND'
    it_excluding =
    excl
    i_save = 'A'
    TABLES
    t_outtab = itab
    EXCEPTIONS
    program_error = 1
    OTHERS = 2.
    *& Form itab_user_command
    text
    -->WHATCOMM text
    -->WHATROW text
    FORM itab_user_command USING whatcomm TYPE sy-ucomm whatrow TYPE
    slis_selfield.
    BREAK-POINT.
    ENDFORM. "itab_user_command
    regards,
    amit m.

Maybe you are looking for