Mandatory field in Editable ALV

Hi everyone,
How to make a field as mandatory in an Editable ALV?
Is there any field catalog parameter avaialble??
or how can we do it.
Please give me a solution.
Regards
Hemanth

Hi!
I use this solution. With this code, you can manage the mandantory filels via fileld cat.
METHOD handle_data_changed.
    DATA: ls_fcat       TYPE lvc_s_fcat,
                structure     TYPE REF TO data,
                ls_modi       TYPE lvc_s_modi,
                tabix         TYPE i,
                index         TYPE sytabix,
                lr_str_desc   TYPE REF TO cl_abap_structdescr,
                ls_comp_desc  TYPE abap_compdescr,
                ls_structure  type ty_zt921_alv.
    FIELD-SYMBOLS: <itab>     TYPE ANY TABLE,
                   <struct>         TYPE ANY,
                   <fs_strukture>   TYPE ANY,
                   <fs_field>       TYPE ANY.
    IF e_onf4 IS INITIAL.
      READ TABLE er_data_changed->mt_fieldcatalog INTO ls_fcat
                                  INDEX 1.
      CREATE DATA structure TYPE (ls_fcat-ref_table).
      ASSIGN structure->* TO <struct> CASTING TYPE (ls_fcat-ref_table).
      ASSIGN er_data_changed->mp_mod_rows->* TO <itab>.
      LOOP AT <itab> ASSIGNING <struct>.
        MOVE-CORRESPONDING <struct> TO ls_structure.
        ASSIGN ls_structure TO   <fs_strukture>.
        lr_str_desc ?= cl_abap_typedescr=>describe_by_data( <fs_strukture> ).
        index = index + 1.
        LOOP AT lr_str_desc->components INTO ls_comp_desc.
          ASSIGN COMPONENT ls_comp_desc-name OF STRUCTURE <fs_strukture> TO <fs_field>.
          READ TABLE er_data_changed->mt_fieldcatalog
                      INTO ls_fcat
                      WITH KEY fieldname = ls_comp_desc-name
                               mark = 'X'.      
        IF sy-subrc = 0.
            IF <fs_field> IS INITIAL.           
            CALL METHOD er_data_changed->add_protocol_entry
              EXPORTING
                i_msgid     = 'ZH'
                i_msgno     = '044'
                i_msgty     = 'E'
*        i_msgv1     = text-m03          
                i_msgv2     = <fs_field>
*        i_msgv3     = text-m05          
                i_fieldname = ls_comp_desc-name
                i_row_id    = index.
              error_in_data = 'X'.
            ENDIF.
          ENDIF.
        ENDLOOP.
ENDLOOP.
ENDIF.
ENDMETHOD. "handle_before_user_command

Similar Messages

  • Mandatory Fields on Editable ALV Grid

    Hi. I am using oops method to make an editable ALV grid.
    How do I sent some columns for mandatory data entry?
    Here are my declarations
    gs_layout TYPE lvc_s_layo, "Layout declaration
    go_grid TYPE REF TO cl_gui_alv_grid,  "Grid
    go_custom_container TYPE REF TO cl_gui_custom_container,"Container
    go_fieldcat type lvc_t_fcat, "Field Catalog
    Thanks,
    Shareen

    Hi Shareen Hegde ,
    Try this program.
    report zshail_alv_new .
    tables: sflight.
    type-pools: icon.
    data: pt_sort type lvc_t_sort.
    data: my_column type table of lvc_s_ceno with header line.
    data: t_hype type LVC_T_HYPE.
    class shail_event definition.
    public section.
    methods:
    handle_toolbar for event toolbar of cl_gui_alv_grid
    importing e_object e_interactive,
    handle_user_command for event user_command of cl_gui_alv_grid importing
    e_ucomm,
    handle_contextmenu_request for event context_menu_request of
    cl_gui_alv_grid importing e_object.
    endclass.
    class shail_event implementation.
    method handle_toolbar.
    perform handler_toolbar using e_object e_interactive.
    endmethod.
    method handle_user_command.
    perform handler_user_command using e_ucomm.
    endmethod.
    method handle_contextmenu_request.
    perform handler_contextmenu_request using e_object.
    endmethod.
    endclass.
    data: go_container type ref to cl_gui_custom_container,
          go_grid type ref to cl_gui_alv_grid,
          field_catalog type lvc_t_fcat,
          layout type lvc_s_layo.
    data: begin of itab occurs 0.
    include structure sflight.
    data: end of itab.
    data: obj type ref to shail_event.
    data: button_exclude type ui_functions.
    start-of-selection.
    call screen 200.
    *&      Module  STATUS_0100  OUTPUT
          text
    module status_0100 output.
    SET PF-STATUS 'xxxxxxxx'.
    SET TITLEBAR 'xxx'.
    if go_container is initial.
    create object go_container
      exporting
       PARENT                      =
        container_name              = 'ALV_CONTAINER'
       STYLE                       =
       LIFETIME                    = lifetime_default
       REPID                       =
       DYNNR                       =
       NO_AUTODEF_PROGID_DYNNR     =
    EXCEPTIONS
       CNTL_ERROR                  = 1
       CNTL_SYSTEM_ERROR           = 2
       CREATE_ERROR                = 3
       LIFETIME_ERROR              = 4
       LIFETIME_DYNPRO_DYNPRO_LINK = 5
       others                      = 6
    if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    create object go_grid
      exporting
       I_SHELLSTYLE      = 0
       I_LIFETIME        =
        i_parent          = go_container
       I_APPL_EVENTS     = space
       I_PARENTDBG       =
       I_APPLOGPARENT    =
       I_GRAPHICSPARENT  =
       I_USE_VARIANT_CLASS = SPACE
       I_NAME            =
    EXCEPTIONS
       ERROR_CNTL_CREATE = 1
       ERROR_CNTL_INIT   = 2
       ERROR_CNTL_LINK   = 3
       ERROR_DP_CREATE   = 4
       others            = 5
    if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    create object obj.
    set handler obj->handle_toolbar for go_grid.
    set handler obj->handle_user_command for go_grid.
    set handler obj->handle_contextmenu_request for go_grid.
    select * from sflight into corresponding fields of table itab.
    perform catalog_fill changing field_catalog.
    perform layout_fill changing layout.
    perform prepare_sort_table changing pt_sort.
    call method go_grid->set_table_for_first_display
      exporting
       I_BYPASSING_BUFFER            =
       I_BUFFER_ACTIVE               =
       I_CONSISTENCY_CHECK           =
       I_STRUCTURE_NAME              = 'SFLIGHT'
       IS_VARIANT                    =
       I_SAVE                        =
       I_DEFAULT                     = 'X'
        is_layout                     = layout
       IS_PRINT                      =
       IT_SPECIAL_GROUPS             =
        it_toolbar_excluding          = button_exclude
        IT_HYPERLINK                  = t_hype
       IT_ALV_GRAPHICS               =
       IT_EXCEPT_QINFO               =
      changing
        it_outtab                     = itab[]
        it_fieldcatalog               = field_catalog
        it_sort                       = pt_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.
    else.
    call method go_grid->refresh_table_display
    EXPORTING
       IS_STABLE      =
       I_SOFT_REFRESH =
    EXCEPTIONS
       FINISHED       = 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.
    endmodule.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
          text
    module user_command_0100 input.
    case sy-ucomm.
    when 'BACK'.
    LEAVE TO SCREEN 0.
    endcase.
    endmodule.                 " USER_COMMAND_0100  INPUT
    *&      Form  CATALOG_FILL
          text
         <--P_FIELD_CATALOG  text
    form catalog_fill changing p_field_catalog.
    data ls_fcat type lvc_s_fcat .
    ls_fcat-fieldname = 'CARRID' .
    ls_fcat-inttype = 'C' .
    ls_fcat-outputlen = '20' .
    ls_fcat-coltext = 'Carrier ID' .
    ls_fcat-web_field = 'carrid_handle'.
    ls_fcat-edit = 'X'.
    *ls_fcat-emphasize = 'C310'.   "needed for column coloring
    append ls_fcat to field_catalog .
    clear ls_fcat .
    ls_fcat-fieldname = 'FLDATE' .
    ls_fcat-ref_table = 'SFLIGHT' .
    ls_fcat-ref_table = 'FLDATE' .
    ls_fcat-outputlen = '20' .
    ls_fcat-coltext = 'Flight Date' .
    ls_fcat-web_field = 'fldate_handle'.
    append ls_fcat to field_catalog .
    clear ls_fcat .
    ls_fcat-fieldname = 'PRICE' .
    ls_fcat-ref_table = 'SFLIGHT' .
    ls_fcat-ref_table = 'PRICE' .
    ls_fcat-outputlen = '20' .
    ls_fcat-coltext = 'Airfare' .
    append ls_fcat to field_catalog .
    clear ls_fcat .
    ls_fcat-fieldname = 'SEATSMAX' .
    ls_fcat-ref_table = 'SFLIGHT' .
    ls_fcat-ref_table = 'SEATSMAX' .
    ls_fcat-outputlen = '20' .
    ls_fcat-coltext = 'Maximum seats' .
    append ls_fcat to field_catalog .
    endform.                    " CATALOG_FILL
    *&      Form  LAYOUT_FILL
          text
         <--P_LAYOUT  text
    form layout_fill changing p_layout type lvc_s_layo.
    p_layout-zebra = 'X' .
    p_layout-grid_title = 'Flights' .
    p_layout-smalltitle = 'X' .
    p_layout-no_merging = 'X'.
    *p_layout-sel_mode = 'A'.
    *p_layout-info_fname = 'rowcolor'.
    endform.                    " LAYOUT_FILL
    *&      Form  exclude_std_buttons
          text
         <--P_BUTTON_EXCLUDE  text
    form exclude_std_buttons changing p_button_exclude type ui_functions.
    the various buttons are details,sort asc,sort desc,find,set filter,
    total, subtotal,
    print,view,export,changelayout,display graphic, eu documentation
    MC_FC_DETAIL,MC_FC_FIND,MC_FC_FILTER,MC_FC_GRAPHIC,MC_FC_SORT_ASC,
    MC_FC_SORT_DSC,MC_FC_SUBTOT,MC_FC_SUM,MC_FC_PC_FILE,MC_FC_VIEWS
    data: ls_exclude type ui_func.
    ls_exclude = cl_gui_alv_grid=>mc_fc_detail.
    append ls_exclude to p_button_exclude.
    ls_exclude = cl_gui_alv_grid=>mc_fc_find.
    append ls_exclude to p_button_exclude.
    ls_exclude = cl_gui_alv_grid=>mc_fc_filter.
    append ls_exclude to p_button_exclude.
    ls_exclude = cl_gui_alv_grid=>mc_fc_graph.
    append ls_exclude to p_button_exclude.
    ls_exclude = cl_gui_alv_grid=>mc_fc_sort_asc.
    append ls_exclude to p_button_exclude.
    ls_exclude = cl_gui_alv_grid=>mc_fc_sort_dsc.
    append ls_exclude to p_button_exclude.
    ls_exclude = cl_gui_alv_grid=>mc_fc_subtot.
    append ls_exclude to p_button_exclude.
    ls_exclude = cl_gui_alv_grid=>mc_fc_sum.
    append ls_exclude to p_button_exclude.
    ls_exclude = cl_gui_alv_grid=>mc_fc_print.
    append ls_exclude to p_button_exclude.
    ls_exclude = cl_gui_alv_grid=>mc_fc_views.
    append ls_exclude to p_button_exclude.
    endform.                    " exclude_std_buttons
    *&      Form  handle_toolbar
          text
         -->P_E_OBJECT  text
         -->P_E_INTERACTIVE  text
         -->P_ENDMETHOD  text
    form handler_toolbar using    p_e_object type ref to
    cl_alv_event_toolbar_set
                                 p_e_interactive                   .
    data: ls_toolbar type stb_button.
    clear ls_toolbar.
    move 'PER' to ls_toolbar-function. "#EC NOTEXT
    move icon_display_text to ls_toolbar-icon.
    move 'Test Info'(201) to ls_toolbar-quickinfo.
    move 'Test Info'(201) to ls_toolbar-text.
    move ' ' to ls_toolbar-disabled. "#EC NOTEXT
    append ls_toolbar to p_e_object->mt_toolbar.
    endform.                    " handle_toolbar
    *&      Form  handle_user_command
          text
         -->P_E_UCOMM  text
    form handler_user_command using    p_e_ucomm.
    case p_e_ucomm.
    when 'PER'.
    perform selected_columns.
    when 'CREA'.
    message i001(zmess).
    endcase.
    endform.                    " handle_user_command
    *&      Form  prepare_sort_table
          text
         <--P_PT_SORT  text
    form prepare_sort_table changing p_pt_sort type lvc_t_sort.
    data: ls_sort type lvc_s_sort.
    ls_sort-spos = '1'.
    ls_sort-fieldname = 'FLDATE'.
    ls_sort-up = space.
    ls_sort-down = 'X'.
    append ls_sort to p_pt_sort.
    endform.                    " prepare_sort_table
    *&      Form  handler_contextmenu_request
          text
         -->P_E_OBJECT  text
    form handler_contextmenu_request using    p_e_object type ref to
    cl_ctmenu.
    *CALL METHOD p_e_object->hide_functions
    EXPORTING
       fcodes = LT_FCODES
    CALL METHOD p_e_object->clear
    *break-point.
    CALL METHOD p_e_object->add_function
      EXPORTING
        fcode       = 'CREA'
        text        = 'Add Function'
       ICON        =
       FTYPE       =
       DISABLED    =
       HIDDEN      =
       CHECKED     =
       ACCELERATOR =
    endform.                    " handler_contextmenu_request
    *&      Form  selected_columns
          text
    -->  p1        text
    <--  p2        text
    form selected_columns.
    CALL METHOD go_grid->get_selected_cells_id
       IMPORTING
         ET_CELLS = my_column[]
    loop at my_column.
    this will specify the id of the selected cell
    message i001(zmess) with my_column-row_id.
    message i002(zmess) with my_column-col_id.
    endloop.
    endform.                    " selected_columns
    *&      Form  display_values
          text
         -->P_ROW_ID  text
    *&      Form  prepare_hyp_tab
          text
         <--P_T_HYPE  text
    form prepare_hyp_tab changing p_t_hype type lvc_t_hype.
    endform.                    " prepare_hyp_tab
    *&      Module  STATUS_0200  OUTPUT
          text
    module STATUS_0200 output.
    SET PF-STATUS 'xxxxxxxx'.
    SET TITLEBAR 'xxx'.
    endmodule.                 " STATUS_0200  OUTPUT
    *&      Module  USER_COMMAND_0200  INPUT
          text
    module USER_COMMAND_0200 input.
    CASE SY-UCOMM.
    WHEN 'NEXT'.
    CALL SCREEN 100.
    WHEN 'EXIT'.
    LEAVE PROGRAM.
    ENDCASE.
    endmodule.                 " USER_COMMAND_0200  INPUT
    Good Luck and REWARD ME for the same
    Thanks
    Ashok.N

  • How to make a filed mandatory of an editable ALV

    Hi Guru,
    Pls tell me how to make a filed mandatory of an editable ALV so that while a new records is inserted the mandatory fields are filled.

    hi,
    You can make fields as mandatory fields using data changed event.
    validate the entered or blank entries of a column in data changed event and call method 'add_protocol_entry' to raise errors.
    Check the program : BCALV_EDIT_03 & BCALV_EDIT_04for more details.
    Refer to this link....
    about field in alv
    obligatory field editable in ALV

  • 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

  • Reference field in editable alv

    hi to all experts,
    in my alv report there are 2 editable fields chckbox and menge
    im building up the catalog with the fields description as QTY TO PRINT
    if i assign the reference fieldname and reference tabname to field catalog im getting error description does not match the target field after im getting the error field symbol not assigned please help

    the fieldcatalog table is empty
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
       EXPORTING
         i_program_name               = repid
         i_internal_tabname           = 'it_output'
      I_STRUCTURE_NAME             =
      I_CLIENT_NEVER_DISPLAY       = 'X'
         i_inclname                   = repid
      I_BYPASSING_BUFFER           =
      I_BUFFER_ACTIVE              =
        CHANGING
          ct_fieldcat                  = it_fieldcat
       EXCEPTIONS
         inconsistent_interface       = 1
         program_error                = 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.

  • Mark fields (columns) in editable ALV Grid as mandatory

    Hi,
    could you please help me to set up a column in an editable alv grid as mandatory? I had a look in several references and also did not find anything in the fieldcatalog structure.
    Best regards,
    Fabian

    Hello Fabian
    Here is some coding to explain what I meant.
    *& Report  ZUS_SDN_ALV_ERROR_LOG
    REPORT  zus_sdn_alv_error_log.
    DATA:
      er_data_changed    TYPE REF TO cl_alv_changed_data_protocol.
    START-OF-SELECTION.
    * Dynpro is empty (contains no elements)
      CALL SCREEN '0100'.
    END-OF-SELECTION.
    *&      Module  PBO_0100  OUTPUT
    *       text
    MODULE pbo_0100 OUTPUT.
    * Event DATA_CHANGED was fired due to changes in the editable ALV grid
      IF ( er_data_changed IS BOUND ).
    * User did not change any values
      ELSE.
        CREATE OBJECT er_data_changed
    *      EXPORTING
    *        I_CONTAINER =
    *        I_CALLING_ALV = <your ALV grid instance>
      ENDIF.
    * That is how your code probably looks like
    *  LOOP AT gt_outtab INTO gs_outtab.
    *    IF ( gs_outtab-obligatory IS INITIAL ).
    *      CALL METHOD go_alvlog->add_protocol_entry
    *        EXPORTING
    *          i_msgid     = '00'
    *          i_msgty     = 'E'
    *          i_msgno     = '398'
    *          I_MSGV1     = 'Field OBLIGATORY must not be empty'
    **          I_MSGV2     =
    **          I_MSGV3     =
    **          I_MSGV4     =
    *          i_fieldname = 'OBLIGATORY'
    **          I_ROW_ID    =
    *          I_TABIX     = syst-tabix
    *    ENDIF.
    *  ENDLOOP.
    * Generate a protocol for testing purposes
      DO 5 TIMES.
        CALL METHOD er_data_changed->add_protocol_entry
          EXPORTING
            i_msgid     = '00'
            i_msgty     = 'E'
            i_msgno     = '398'
            i_msgv1     = 'Field OBLIGATORY must not be empty'
    *          I_MSGV2     =
    *          I_MSGV3     =
    *          I_MSGV4     =
            i_fieldname = 'OBLIGATORY'
            i_row_id    = syst-index
            i_tabix     = syst-index
      ENDDO.
      CALL METHOD er_data_changed->display_protocol
    *    EXPORTING
    *      I_CONTAINER =
    ENDMODULE.                 " PBO_0100  OUTPUT
    Please note that this report dumps as soon as you close the log popup. However, this will not happen within your event handler method.
    Regards
      Uwe

  • To capture the selected rows along with edited field contents in alv report

    Dear All,
             I do have requirement where, in alv report output one field is editable and need to save the content of the edited field along with the selected rows.
             For example If there are 10 records displayed in the alv output with 20 fields.
    Out of this 20 fields one field (say XYZ) is editable. Also i have already created a new pushbutton (say ABC) on alv output. Now in the alv output if we maintain some value in the field (XYZ ) for the 2nd and 4th record and select this two records, and when clicked on the pushbutton (ABC) it has to update the DB table.
          I am using the Func Module  'REUSE_ALV_GRID_DISPLAY'. 
          Your early reply with sample code would be appreciated.
    Thanks in Advance.

    HI Naveen ,
    There is an import parameter "i_callback_program" in the function module,
    plz pass the program name to it.
    Capture the command by passing a field of type sy-ucomm to "I_CALLBACK_USER_COMMAND ".  Check the returned command and
    and program a functionality as desired.
    u can try the event double_click or at line selection. there u can use READLINE command to c if the line has been selected.
    In case it is , process the code segment.
    Regards
    Pankaj

  • To edit the field in the ALV report

    Hi,
        i want to edit the field of the ALV report what i need to do for that..
    Thanks & Regards
    Ashu Singh

    hi,
    check the code,
    REPORT  zalv_fcat.* Output table T006 structure declarationTYPES : BEGIN OF ty_t006.
            INCLUDE STRUCTURE t006.
    TYPES : END OF ty_t006.*Internal table and wa declaration for T006
    DATA : it_t006 TYPE STANDARD TABLE OF ty_t006,
           wa_t006 TYPE ty_t006.*declarations for ALV
    DATA: ok_code               TYPE sy-ucomm,
    fieldcatalog for T006
          it_fielcat           TYPE lvc_t_fcat,
    fieldcatalog for fieldcatalog itself:
          it_fielcatalogue           TYPE lvc_t_fcat,
          it_layout           TYPE lvc_s_layo.*declaration for toolbar function
    DATA:   it_excl_func        TYPE ui_functions.
    Controls to display it_t006 and corresponding fieldcatalog
    DATA: cont_dock TYPE REF TO cl_gui_docking_container,
          cont_alvgd     TYPE REF TO cl_gui_alv_grid.*controls to display the fieldcatalog as editable alv grid and container
    DATA: cont_cust TYPE REF TO cl_gui_custom_container,
          cont_editalvgd     TYPE REF TO cl_gui_alv_grid.*intialization event
    INITIALIZATION.*start of selection event
    START-OF-SELECTION.
    LOCAL CLASS Definition for data changed in fieldcatalog ALV
    CLASS lcl_event_receiver DEFINITION.
      PUBLIC SECTION.
        METHODS handle_data_changed
          FOR EVENT data_changed OF cl_gui_alv_grid
          IMPORTING er_data_changed.
    ENDCLASS.                    "lcl_event_receiver DEFINITION
    LOCAL CLASS implementation for data changed in fieldcatalog ALV
    CLASS lcl_event_receiver IMPLEMENTATION.
      METHOD handle_data_changed.
      ENDMETHOD.                    "handle_data_changed
    ENDCLASS.                    "lcl_event_receiver IMPLEMENTATION*data declaration for event receiver
    DATA: event_receiver TYPE REF TO lcl_event_receiver.*end of selection event
    END-OF-SELECTION.*setting the screen for alv output for table display and
    *changed fieldcatalalogue display
    SET SCREEN 600.
    On this statement double click  it takes you to the screen painter SE51. Enter the attributes
    *Create a Custom container and name it CCONT and OK code as OK_CODE.
    *Save check and Activate the screen painter.
    *Now a normal screen with number 600 is created which holds the ALV grid.
    PBO of the actual screen , Here we can give a title and customized menus
    *Go to SE41 and create status 'STATUS600' and create THE function code 'SUBMIT'
    *and 'EXIT' with icons and icon texts
    Also create a TitleBar 'TITLE600' and give the relevant title.&----
    *&      Module  STATUS_0600  OUTPUT
    MODULE status_0600 OUTPUT.
      SET PF-STATUS 'STATUS600'.
      SET TITLEBAR 'TITLE600'.
    CREATE ALV GRID CONTROL IF DOES NOT EXISTS INITIALLY
      IF cont_dock IS INITIAL.
        PERFORM create_alv.
      ENDIF.ENDMODULE.                             " STATUS_0600  OUTPUT* PAI module of the screen created. In case we use an interactive ALV or
    *for additional functionalities we can create OK codes and based on the
    *user command we can do the coding as shown below
    *&      Module  USER_COMMAND_0600  INPUT
    MODULE user_command_0600 INPUT.
      CASE ok_code.
        WHEN 'SUBMIT'.
    *TO GET THE CURRENT FIELDCATALOGUE FROM THE FRONTEND
          CALL METHOD cont_alvgd->set_frontend_fieldcatalog
            EXPORTING
              it_fieldcatalog = it_fielcat.
    *refresh the alv
          CALL METHOD cont_alvgd->refresh_table_display.
    *to Send Buffered Automation Queue to Frontend
          CALL METHOD cl_gui_cfw=>flush.*Exit button clicked to leave the program
        WHEN 'EXIT'.
          LEAVE PROGRAM.  ENDCASE.ENDMODULE.                             " USER_COMMAND_0600  INPUT&----
    *&      Form  CREATE_ALV
    &----FORM create_alv.*create a docking container and dock the control at the botton
      CREATE OBJECT cont_dock
          EXPORTING
               dynnr = '600'
               extension = 100
               side = cl_gui_docking_container=>dock_at_bottom.*create the alv grid for display the table
      CREATE OBJECT cont_alvgd
          EXPORTING
               i_parent = cont_dock.*create custome container for alv
      CREATE OBJECT cont_cust
          EXPORTING
               container_name = 'CCONT'.
    *create alv editable grid
      CREATE OBJECT cont_editalvgd
          EXPORTING
               i_parent = cont_cust.* register events for the editable alv
      CREATE OBJECT event_receiver.
      SET HANDLER event_receiver->handle_data_changed FOR cont_editalvgd.  CALL METHOD cont_editalvgd->register_edit_event
        EXPORTING
          i_event_id = cl_gui_alv_grid=>mc_evt_modified.*building the fieldcatalogue for the initial display
      PERFORM build_fieldcat CHANGING it_fielcat it_fielcatalogue.*building the fieldcatalogue after the user has changed it
      PERFORM change_fieldcat CHANGING it_fielcatalogue.*fetch data from the table
      PERFORM fetch_data.*    Get excluding functions for the alv editable tool bar  APPEND cl_gui_alv_grid=>mc_fc_loc_append_row TO it_excl_func.
      APPEND cl_gui_alv_grid=>mc_fc_loc_insert_row TO it_excl_func.
      APPEND cl_gui_alv_grid=>mc_fc_loc_cut TO it_excl_func.
      APPEND cl_gui_alv_grid=>mc_fc_sort TO it_excl_func.
      APPEND cl_gui_alv_grid=>mc_fc_sort_asc TO it_excl_func.
      APPEND cl_gui_alv_grid=>mc_fc_sort_dsc TO it_excl_func.
      APPEND cl_gui_alv_grid=>mc_fc_subtot TO it_excl_func.
      APPEND cl_gui_alv_grid=>mc_fc_sum TO it_excl_func.
      APPEND cl_gui_alv_grid=>mc_fc_graph TO it_excl_func.
      APPEND cl_gui_alv_grid=>mc_fc_info TO it_excl_func.
      APPEND cl_gui_alv_grid=>mc_fc_print TO it_excl_func.
      APPEND cl_gui_alv_grid=>mc_fc_filter TO it_excl_func.
      APPEND cl_gui_alv_grid=>mc_fc_views TO it_excl_func.
      APPEND cl_gui_alv_grid=>mc_mb_export TO it_excl_func.
      APPEND cl_gui_alv_grid=>mc_mb_sum TO it_excl_func.
      APPEND cl_gui_alv_grid=>mc_mb_sum TO it_excl_func.
      APPEND cl_gui_alv_grid=>mc_mb_paste TO it_excl_func.
      APPEND cl_gui_alv_grid=>mc_fc_find TO it_excl_func.
      APPEND cl_gui_alv_grid=>mc_fc_loc_copy  TO it_excl_func.
    *Alv display for the T006 table at the bottom
      CALL METHOD cont_alvgd->set_table_for_first_display
        CHANGING
          it_outtab       = it_t006[]
          it_fieldcatalog = it_fielcat[].
    optimize column width of grid displaying fieldcatalog
      it_layout-cwidth_opt = 'X'.* Get fieldcatalog of table T006 - alv might have
    modified it after passing.
      CALL METHOD cont_alvgd->get_frontend_fieldcatalog
        IMPORTING
          et_fieldcatalog = it_fielcat[].to Send Buffered Automation Queue to Frontend  CALL METHOD cl_gui_cfw=>flush. Display fieldcatalog of table T006 in editable alv grid
      CALL METHOD cont_editalvgd->set_table_for_first_display
        EXPORTING
          is_layout            = it_layout
          it_toolbar_excluding = it_excl_func
        CHANGING
          it_outtab            = it_fielcat[]
          it_fieldcatalog      = it_fielcatalogue[].
    ENDFORM.                               " CREATE_alv
    *&      Form  fetch_data
    FORM fetch_data.* select data of T006
      SELECT * FROM t006 INTO TABLE it_t006 UP TO 50 ROWS.
    ENDFORM.                               " fetch_data
    *&      Form  BUILD_FIELDCAT
    FORM build_fieldcat CHANGING it_fldcat TYPE lvc_t_fcat
                                       it_fcat TYPE lvc_t_fcat.
    Fieldcatalog for table T006: it_fldcat
    to generate the fields automatically  CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
          i_structure_name       = 'T006'
        CHANGING
          ct_fieldcat            = it_fldcat[]
        EXCEPTIONS
          inconsistent_interface = 1
          program_error          = 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.*----
    Fieldcatalog for table LVC_T_FCAT:it_fcat
    Generate fieldcatalog of fieldcatalog structure.
    This fieldcatalog is used to display fieldcatalog 'it_fldcat'
    on the top of the screen.  CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
          i_structure_name       = 'LVC_S_FCAT'
        CHANGING
          ct_fieldcat            = it_fcat[]
        EXCEPTIONS
          inconsistent_interface = 1
          program_error          = 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.
    ENDFORM.                               " BUILD_FIELDCAT
    *&      Form  CHANGE_FIELDCAT
    *after the user has modified the fieldcatalogue we build another fieldcat
    *for the modified alv display
    FORM change_fieldcat CHANGING it_fcat TYPE lvc_t_fcat.  DATA ls_fcat TYPE lvc_s_fcat.  LOOP AT it_fcat INTO ls_fcat.
        ls_fcat-coltext = ls_fcat-fieldname.
        ls_fcat-edit = 'X'.    IF ls_fcat-fieldname = 'COL_POS' OR ls_fcat-fieldname = 'FIELDNAME'.
          ls_fcat-key = 'X'.
        ENDIF.    MODIFY it_fcat FROM ls_fcat.
      ENDLOOP.
    ENDFORM.                               " CHANGE_FIELDCAT
    ref:saptechnical tutorial.
    Regards,
    Anirban

  • Mandatory Field in ALV Grid

    Hello,
    i've a editbale alv grid.
    Is it possible to set a field/colum as mandatory field?
    Best regards,
    TomSd

    Hi,
    Have a look at the report BCALV_EDIT_03.
    In this report the program logic is such that if the user enters an incorrect value an error is displayed.
    Instead you can check if the field of your ALV filelds are null and validate them accordingly.
    Regards,
    Sandeep

  • Urgent : Problem with Editable  ALV Grid  for Quantity and Currency Fields

    Hi All,
    I am using Editable ALV Grid display and have quantity and value as editable fields in the display.
    When user changes these values these values are not changing properly .
    For the quantity field the domain is MENG13 with 3 deciamal places and here  if we enter 500 it takes it as 0.500   .
    The same problem is for the currency field. Here the Domain is WERT7 with 3 decimal places.
    Here also it takes last 2 digits after decimal places by default.
    Please advice how to get proper values in this case from ALV editable fields.
    Thanks and Regards
    Harshad
    Edited by: Harshad Rahirkar on Dec 25, 2007 7:39 AM

    for all the currency field , it will display like that only.
    u have to manipulate uin program before displaying.
    if they are giving 500, in program multiply with 100 and move it to table.
    when u are getting from table, divinde and display.
    this is what I am doing.
    Reward if helpfull.

  • 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

  • How to remove mandatory field for Last Name in Personal Data Editing Screen

    Hello All,
    CUrrently we are using BP_ ERP5ESS1.31 SP5 & SAP_ESS  603 SP5.
    All my ESS Services are Displaying fine and working from Portal.I am having the requirement like I need to make Last Name as Non-Mandatory field in Personal Data. While Editing the PD Screen, there  i will find the * mark for Last Name filed, i checked through the Global Personalization Make as Mandatory is Not Personalized its showing, i think its defualt prpoerty,so i am unable make any changes from Portal w.r.t Global Personalization.
    I checked in SPRO-- Personal Admin> Custmomizing User Interfaces>Change Screen Modifications, there i find the respective Module pool for those Infotypes and country Specific..
    I cheked forModulePool MP000200--> P0002 and Variable Key-40(For India)  P0002 - NACHIN -- LastName only OF Radio Button is Selected all other Rado buttons are not selected.
    I Checked in V_T588MFPROPS view there for 0002 Infotype P0002 -- NACHN Mandatory check box is Checked all other check boxes are Unchecked.
    How to make that Last Name field as Non-Mandatory in Personal Data Edit Screen, where i need to make the changes.'
    Please list out the Steps..Where i need to do the configuration. And i assigned all the required ESS roles on the backend.
    Thanks in Advance
    Adapag

    Hi,
    I don't think supressing through Global Personalization will change the business logic. Within the Business Logic it checks for the mandatory field.
    After the changes I guess you need to make the changes accordingly.
    The below link might be of some help.
    http://wiki.sdn.sap.com/wiki/pages/viewpage.action?spaceKey=profile&title=ESSPersonalInformationUIenhancementwithoutmodification&decorator=printable
    Please correct if I am wrong.
    Cheers-
    Pramod

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

  • Alv grid: editable individaul fields or editable rows

    Hi All,
    i want to have the individual fields in an ALV or a complete row editable...
    Currently i am using the REUSE_ALV_GRID_DISPLAY where in the fieldcatalog if i use the edit=X then the whole column is editable...
    But instead i want the particular field or the entire row to be editable...
    Also let me know if it is possible using the SALV classes(Alv using classes? if so provide the releavant class and method)
    Can anyone provide the solution regarding this...
    Thanks
    Shiva

    Hi,
    The fields you want editable just set the fieldcatlog parameter edit = 'X' for that field.
    This will make that field only editable .
    Below is the sample code where only specific fields are editable .
    This code will also help you in many aspects.
    REPORT  ZMSTR0022.
    CONSTANTS: C_FORM_NAME TYPE TDSFNAME VALUE 'ZMST_PER_APPL'.
    TABLES :ZMST_PERMIT.
    TYPE-POOLS: SLIS.
    TYPE-POOLS :VRM.                           "Value Request Manager
    TYPES:BEGIN OF STRU_ZMST_PERMIT,
         CHECKBOX(1) TYPE C,                    " Checkbox
         ZPIDNUM TYPE ZMST_PERMIT-ZPIDNUM,   " Permit ID No.
         ZARBDSC TYPE ZMST_PERMIT-ZARBDSC,   " Arabic description
         ZENGDSC TYPE ZMST_PERMIT-ZENGDSC,   " English description
         ZENQUAN TYPE ZMST_PERMIT-ZENQUAN,   " Qty in English
         ZARQUAN TYPE ZMST_PERMIT-ZARQUAN,   " Qty in Arabic
         ZENUOM  TYPE ZMST_PERMIT-ZENUOM,    " UoM
         ZTARIFF TYPE  ZMST_PERMIT-ZTARIFF,  " Tariff No
         ZARRPRT TYPE ZMST_PERMIT-ZARRPRT,   " Port code
         ZPRT_NAME(60) TYPE C,               " Port name in Arabic
         ZPERNUM TYPE ZMST_PERMIT-ZPERNUM,   " Reference No
         ZEFFDT  TYPE ZMST_PERMIT-ZEFFDT,    " Valid from
         ZEXPDT  TYPE ZMST_PERMIT-ZEXPDT,    " Valid to
         ZARB_DT(15) TYPE C,                 " Arabic Date of letter
         ZNAME_AUTH(50) TYPE C,              " Name of Authority
         ZPERM_MIN(50) TYPE C,               " Permit Ministry
         END OF STRU_ZMST_PERMIT.
    TYPES:BEGIN OF STRU_PERMIT,
          ZPIDNUM TYPE ZMST_PERMIT-ZPIDNUM,  " Permit ID No.
          ZENGDSC TYPE ZMST_PERMIT-ZENGDSC,  " English description
          ZARBDSC TYPE ZMST_PERMIT-ZARBDSC,  " Arabic description
          ZTARIFF TYPE  ZMST_PERMIT-ZTARIFF, " Tariff No
          ZPERNUM TYPE ZMST_PERMIT-ZPERNUM,  " Reference No
          ZARRPRT TYPE ZMST_PERMIT-ZARRPRT,  " Port code
          ZEFFDT  TYPE ZMST_PERMIT-ZEFFDT,   " Valid from
          ZEXPDT  TYPE ZMST_PERMIT-ZEXPDT,   " Valid to
          END OF STRU_PERMIT.
    TYPES: BEGIN OF STRU_FORM_PERMIT,
           ZARBDSC TYPE ZMST_PERMIT-ZARBDSC,   " Arabic description
           ZENGDSC TYPE ZMST_PERMIT-ZENGDSC,   " English description
           ZENQUAN TYPE ZMST_PERMIT-ZENQUAN,   " Qty in English
           ZARQUAN TYPE ZMST_PERMIT-ZARQUAN,   " Qty in Arabic
           ZENUOM  TYPE ZMST_PERMIT-ZENUOM,    " UoM
           ZTARIFF TYPE  ZMST_PERMIT-ZTARIFF,  " Tariff No
           ZPRT_NAME(60) TYPE C,               " Port name in Arabic
           END OF STRU_FORM_PERMIT.
    DATA: IT_PERMIT TYPE TABLE OF STRU_PERMIT.
    DATA: IT_ZMST_PERMIT TYPE TABLE OF STRU_ZMST_PERMIT,
          WA_ZMST_PERMIT LIKE LINE OF IT_ZMST_PERMIT,
          IT_FORM_PERMIT TYPE TABLE OF STRU_FORM_PERMIT,
          WA_FORM_PERMIT LIKE LINE OF IT_FORM_PERMIT.
    DATA: WA_LAYOUT   TYPE SLIS_LAYOUT_ALV,
          WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
          IT_FIELDCAT TYPE TABLE OF SLIS_FIELDCAT_ALV.
    DATA: W_FORM TYPE RS38L_FNAM.
    DATA: W_NAME_AUTH(50),
          W_ZARBDT(15),
          W_ZENGDT(10),
         W_ZPRT_NAME(70).
    DATA: W_PARAM TYPE SSFCTRLOP.
    DATA:W_NAME1 TYPE DFIES-FIELDNAME,
          W_NAME2 TYPE HELP_INFO-DYNPROFLD .
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-023.
    SELECT-OPTIONS:S_PIDNUM FOR ZMST_PERMIT-ZPIDNUM ,
                   S_ENGDSC FOR ZMST_PERMIT-ZENGDSC NO INTERVALS LOWER CASE,
                   S_ARBDSC FOR ZMST_PERMIT-ZARBDSC NO INTERVALS LOWER CASE,
                   S_TARIFF FOR ZMST_PERMIT-ZTARIFF NO INTERVALS,
                   S_PERNUM FOR ZMST_PERMIT-ZPERNUM NO INTERVALS,
                   S_ARRPRT FOR ZMST_PERMIT-ZARRPRT NO INTERVALS MATCHCODE OBJECT ZMST_PORTS.
    PARAMETER:P_PERTYP(2) TYPE C AS LISTBOX VISIBLE LENGTH 20.
    SELECTION-SCREEN END OF BLOCK B1.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_PIDNUM-LOW.
      W_NAME2 = 'S_PIDNUM-LOW'.
      W_NAME1 = 'ZPIDNUM'.
      PERFORM F4_HELP USING W_NAME1 W_NAME2 .         "calling subroutine to provide desired F4 help
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_PIDNUM-HIGH.
      W_NAME2 = 'S_PIDNUM-HIGH'.
      W_NAME1 = 'ZPIDNUM'.
      PERFORM F4_HELP USING W_NAME1 W_NAME2 .         "calling subroutine to provide desired F4 help
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_ENGDSC-LOW.
      W_NAME2 = 'S_ENGDSC'.
      W_NAME1 = 'ZENGDSC'.
      PERFORM F4_HELP USING W_NAME1 W_NAME2 .         "calling subroutine to provide desired F4 help
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_ARBDSC-LOW.
      W_NAME2 = 'S_ARBDSC'.
      W_NAME1 = 'ZARBDSC'.
      PERFORM F4_HELP USING W_NAME1 W_NAME2 .         "calling subroutine to provide desired F4 help
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_TARIFF-LOW.
      W_NAME2 = 'S_TARIFF'.
      W_NAME1 = 'ZTARIFF'.
      PERFORM F4_HELP USING W_NAME1 W_NAME2 .         "calling subroutine to provide desired F4 help
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_PERNUM-LOW.
      W_NAME2 = 'S_PERNUM'.
      W_NAME1 = 'ZPERNUM'.
      PERFORM F4_HELP USING W_NAME1 W_NAME2 .         "calling subroutine to provide desired F4 help
    AT SELECTION-SCREEN.
      IF SY-UCOMM = 'ONLI'.
        PERFORM CHECK_INPUT.                            "calling subroutine to check inputs on selection screen
      ENDIF.
    INITIALIZATION.
      PERFORM VAL_PERTYP.
    START-OF-SELECTION.
      PERFORM FILL_FIELDCAT.                          "calling subroutine for filling fieldcatalog
    If Permit ministry is blank then fetch data from ZMST_PERMIT otherwise from ZMST_PERMITHI--
      IF P_PERTYP IS INITIAL.
        PERFORM FETCH_PERMIT.                         "calling subroutine to fetch data from ZMST_PERMIT
      ELSE.
        PERFORM FETCH_PERMITHI.                       "calling subroutine to fetch data from ZMST_PERMITHI
      ENDIF.
    END-OF-SELECTION.
    *&      Form  fill_fieldcat
          text
    -->  p1        text
    <--  p2        text
    FORM FILL_FIELDCAT .
    -passing the parameters of layout--
      WA_LAYOUT-ZEBRA = 'X'.
      WA_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
      WA_LAYOUT-BOX_FIELDNAME = 'CHECKBOX'.
      WA_LAYOUT-BOX_TABNAME = 'IT_ZMST_PERMIT'.
    -Passing the parameters of fieldcatalog--
      WA_FIELDCAT-FIELDNAME = 'ZPIDNUM'.
      WA_FIELDCAT-TABNAME = 'IT_ZMST_PERMIT'.
      WA_FIELDCAT-SELTEXT_M = TEXT-001.
      APPEND WA_FIELDCAT TO IT_FIELDCAT.
      CLEAR WA_FIELDCAT.
      WA_FIELDCAT-FIELDNAME = 'ZARBDSC'.
      WA_FIELDCAT-TABNAME = 'IT_ZMST_PERMIT'.
      WA_FIELDCAT-SELTEXT_M = TEXT-002.
      WA_FIELDCAT-EDIT = 'X'.
      WA_FIELDCAT-LOWERCASE = 'X'.
      WA_FIELDCAT-OUTPUTLEN = 120.
      APPEND WA_FIELDCAT TO IT_FIELDCAT.
      CLEAR WA_FIELDCAT.
      WA_FIELDCAT-FIELDNAME = 'ZENGDSC'.
      WA_FIELDCAT-TABNAME = 'IT_ZMST_PERMIT'.
      WA_FIELDCAT-SELTEXT_M = TEXT-003.
      WA_FIELDCAT-EDIT = 'X'.
      WA_FIELDCAT-LOWERCASE = 'X'.
      WA_FIELDCAT-OUTPUTLEN = 120.
      APPEND WA_FIELDCAT TO IT_FIELDCAT.
      CLEAR WA_FIELDCAT.
      WA_FIELDCAT-FIELDNAME = 'ZENQUAN'.
      WA_FIELDCAT-TABNAME = 'IT_ZMST_PERMIT'.
      WA_FIELDCAT-SELTEXT_M = TEXT-004.
      WA_FIELDCAT-EDIT = 'X'.
      WA_FIELDCAT-LOWERCASE = 'X'.
      APPEND WA_FIELDCAT TO IT_FIELDCAT.
      CLEAR WA_FIELDCAT.
      WA_FIELDCAT-FIELDNAME = 'ZARQUAN'.
      WA_FIELDCAT-TABNAME = 'IT_ZMST_PERMIT'.
      WA_FIELDCAT-SELTEXT_M = TEXT-005.
      WA_FIELDCAT-EDIT = 'X'.
      WA_FIELDCAT-LOWERCASE = 'X'.
      APPEND WA_FIELDCAT TO IT_FIELDCAT.
      CLEAR WA_FIELDCAT.
      WA_FIELDCAT-FIELDNAME = 'ZENUOM'.
      WA_FIELDCAT-TABNAME = 'IT_ZMST_PERMIT'.
      WA_FIELDCAT-SELTEXT_M = TEXT-006.
      WA_FIELDCAT-EDIT = 'X'.
      WA_FIELDCAT-LOWERCASE = 'X'.
      APPEND WA_FIELDCAT TO IT_FIELDCAT.
      CLEAR WA_FIELDCAT.
      WA_FIELDCAT-FIELDNAME = 'ZTARIFF'.
      WA_FIELDCAT-TABNAME = 'IT_ZMST_PERMIT'.
      WA_FIELDCAT-SELTEXT_M = TEXT-007.
      WA_FIELDCAT-EDIT = 'X'.
      WA_FIELDCAT-OUTPUTLEN = 15.
      WA_FIELDCAT-LOWERCASE = 'X'.
      APPEND WA_FIELDCAT TO IT_FIELDCAT.
      CLEAR WA_FIELDCAT.
      WA_FIELDCAT-FIELDNAME = 'ZARB_DT'.
      WA_FIELDCAT-TABNAME = 'IT_ZMST_PERMIT'.
      WA_FIELDCAT-SELTEXT_L = TEXT-013.
      WA_FIELDCAT-EDIT = 'X'.
      WA_FIELDCAT-LOWERCASE = 'X'.
      APPEND WA_FIELDCAT TO IT_FIELDCAT.
      CLEAR WA_FIELDCAT.
      WA_FIELDCAT-FIELDNAME = 'ZNAME_AUTH'.
      WA_FIELDCAT-TABNAME = 'IT_ZMST_PERMIT'.
      WA_FIELDCAT-SELTEXT_M = TEXT-014.
      WA_FIELDCAT-EDIT = 'X'.
      WA_FIELDCAT-OUTPUTLEN = 50.
      WA_FIELDCAT-LOWERCASE = 'X'.
      APPEND WA_FIELDCAT TO IT_FIELDCAT.
      CLEAR WA_FIELDCAT.
      WA_FIELDCAT-FIELDNAME = 'ZPRT_NAME'.
      WA_FIELDCAT-TABNAME = 'IT_ZMST_PERMIT'.
      WA_FIELDCAT-SELTEXT_M = TEXT-009.
      WA_FIELDCAT-EDIT = 'X'.
      WA_FIELDCAT-OUTPUTLEN = 60.
      WA_FIELDCAT-LOWERCASE = 'X'.
      APPEND WA_FIELDCAT TO IT_FIELDCAT.
      CLEAR WA_FIELDCAT.
      WA_FIELDCAT-FIELDNAME = 'ZARRPRT'.
      WA_FIELDCAT-TABNAME = 'IT_ZMST_PERMIT'.
      WA_FIELDCAT-SELTEXT_M = TEXT-008.
      APPEND WA_FIELDCAT TO IT_FIELDCAT.
      CLEAR WA_FIELDCAT.
      WA_FIELDCAT-FIELDNAME = 'ZPERNUM'.
      WA_FIELDCAT-TABNAME = 'IT_ZMST_PERMIT'.
      WA_FIELDCAT-SELTEXT_M = TEXT-010.
      APPEND WA_FIELDCAT TO IT_FIELDCAT.
      CLEAR WA_FIELDCAT.
      WA_FIELDCAT-FIELDNAME = 'ZEFFDT'.
      WA_FIELDCAT-TABNAME = 'IT_ZMST_PERMIT'.
      WA_FIELDCAT-SELTEXT_M = TEXT-011.
      APPEND WA_FIELDCAT TO IT_FIELDCAT.
      CLEAR WA_FIELDCAT.
      WA_FIELDCAT-FIELDNAME = 'ZEXPDT'.
      WA_FIELDCAT-TABNAME = 'IT_ZMST_PERMIT'.
      WA_FIELDCAT-SELTEXT_M = TEXT-012.
      APPEND WA_FIELDCAT TO IT_FIELDCAT.
      CLEAR WA_FIELDCAT.
      WA_FIELDCAT-FIELDNAME = 'ZPERM_MIN'.
      WA_FIELDCAT-TABNAME = 'IT_ZMST_PERMIT'.
      WA_FIELDCAT-SELTEXT_M = TEXT-019.
      WA_FIELDCAT-OUTPUTLEN = 50.
      WA_FIELDCAT-LOWERCASE = 'X'.
      APPEND WA_FIELDCAT TO IT_FIELDCAT.
      CLEAR WA_FIELDCAT.
    ENDFORM.                    " fill_fieldcat
    *&      Form  alv_disp
          text
    -->  p1        text
    <--  p2        text
    FORM ALV_DISP .
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          I_CALLBACK_PROGRAM       = 'ZMSTR0022'
          I_CALLBACK_PF_STATUS_SET = 'PF_STATUS'
          I_CALLBACK_USER_COMMAND  = 'USER_COMMAND'
          I_GRID_TITLE             = TEXT-015
          IS_LAYOUT                = WA_LAYOUT
          IT_FIELDCAT              = IT_FIELDCAT
          I_SAVE                   = 'A'
        TABLES
          T_OUTTAB                 = IT_ZMST_PERMIT
        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.                    " alv_disp
    *&      Form  PF_STATUS
          text
      This subroutine sets the GUI status
    FORM PF_STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB.
      SET PF-STATUS 'ZSTANDARD_FULLSCREEN'.
    ENDFORM.                    "PF_STATUS
    *&      Form  USER_COMMAND
    FORM USER_COMMAND USING R_UCOMM TYPE SY-UCOMM  RS_SELFIELD TYPE SLIS_SELFIELD.
    *For Printing Smartform
      IF R_UCOMM = 'PRT'.
        CLEAR WA_FORM_PERMIT.
        REFRESH IT_FORM_PERMIT.
        LOOP AT IT_ZMST_PERMIT INTO WA_ZMST_PERMIT WHERE CHECKBOX = 'X'.
          MOVE-CORRESPONDING WA_ZMST_PERMIT TO WA_FORM_PERMIT.
          APPEND WA_FORM_PERMIT TO IT_FORM_PERMIT .
    *Check for First occurence of Name of authority
          IF WA_ZMST_PERMIT-ZNAME_AUTH NE SPACE.
            IF W_NAME_AUTH = ' '.
              W_NAME_AUTH = WA_ZMST_PERMIT-ZNAME_AUTH.
            ENDIF.
          ENDIF.
    *Check for First occurence of Arabic date
          IF WA_ZMST_PERMIT-ZARB_DT NE SPACE.
            IF W_ZARBDT = ' '.
              W_ZARBDT = WA_ZMST_PERMIT-ZARB_DT.
            ENDIF.
          ENDIF.
          IF WA_ZMST_PERMIT-ZPRT_NAME NE SPACE.
            IF W_ZPRT_NAME = ' '.
              MOVE WA_ZMST_PERMIT-ZPRT_NAME TO W_ZPRT_NAME.
              CONDENSE W_ZPRT_NAME.
            ENDIF.
          ENDIF.
          CLEAR : WA_FORM_PERMIT, WA_ZMST_PERMIT.
        ENDLOOP.
        CONCATENATE SY-DATUM0(4) '/' SY-DATUM4(2) '/' SY-DATUM+6(2) INTO W_ZENGDT.
    *Printing    Subroutine
        IF NOT IT_FORM_PERMIT[] IS INITIAL.
          PERFORM PRINT_FORM.
        ELSE.
          MESSAGE TEXT-018 TYPE 'I'.
        ENDIF.
      ENDIF.
    ENDFORM.                    "user_command
    *&      Form  F4_HELP
          text
    -->  p1        text
    <--  p2        text
    FORM F4_HELP USING: W_VAR TYPE DFIES-FIELDNAME
                        W_VAR1 TYPE HELP_INFO-DYNPROFLD .
    Fetching data from zmst_permit for F4 help on PERMIT ID No.--
      IF IT_PERMIT[] IS INITIAL.
        SELECT ZPIDNUM
               ZENGDSC
               ZARBDSC
               ZTARIFF
               ZPERNUM
               ZARRPRT
               ZEFFDT
               ZEXPDT
               FROM ZMST_PERMIT INTO CORRESPONDING FIELDS OF TABLE IT_PERMIT.
      ENDIF.
      CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
        EXPORTING
          RETFIELD        = W_NAME1 " 'ZPIDNUM'
          DYNPPROG        = 'ZMSTR0022'
          DYNPNR          = SY-DYNNR
          DYNPROFIELD     = W_NAME2 "'S_PIDNUM'
          VALUE_ORG       = 'S'
        TABLES
          VALUE_TAB       = IT_PERMIT
        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.
    ENDFORM.                                                    " F4_HELP
    *&      Form  check_input
          text
    -->  p1        text
    <--  p2        text
    FORM CHECK_INPUT .
      IF S_PIDNUM[] IS INITIAL AND
         S_ENGDSC[] IS INITIAL AND
         S_ARBDSC[] IS INITIAL AND
         S_TARIFF[] IS INITIAL AND
         S_PERNUM[] IS INITIAL AND
         S_ARRPRT[] IS INITIAL .
        MESSAGE TEXT-016 TYPE 'E'.
        LEAVE TO TRANSACTION 'ZMSTR022'.
      ENDIF.
    ENDFORM.                    " check_input
    *&      Form  print_form
          text
    -->  p1        text
    <--  p2        text
    FORM PRINT_FORM .
      CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
        EXPORTING
          FORMNAME           = C_FORM_NAME
        IMPORTING
          FM_NAME            = W_FORM
        EXCEPTIONS
          NO_FORM            = 1
          NO_FUNCTION_MODULE = 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.
      W_PARAM-LANGU ='AR'.
      CALL FUNCTION W_FORM
        EXPORTING
          CONTROL_PARAMETERS = W_PARAM
          W_NAME_AUTH        = W_NAME_AUTH
          W_ZARBDT           = W_ZARBDT
          W_ZENGDT           = W_ZENGDT
          W_ZPRT_NAME        = W_ZPRT_NAME
        TABLES
          IT_FORM_PERMIT     = IT_FORM_PERMIT
        EXCEPTIONS
          FORMATTING_ERROR   = 1
          INTERNAL_ERROR     = 2
          SEND_ERROR         = 3
          USER_CANCELED      = 4
          OTHERS             = 5.
      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.                    " print_form
    *&      Form  fetch_Permit
          text
    -->  p1        text
    <--  p2        text
    FORM FETCH_PERMIT .
    -Fetching data from zmst_permit based on the inputs on selection screen--
      SELECT
           ZPIDNUM
           ZARBDSC
           ZENGDSC
           ZENQUAN
           ZARQUAN
           ZENUOM
           ZTARIFF
           ZARRPRT
           ZPERNUM
           ZEFFDT
           ZEXPDT
           FROM ZMST_PERMIT INTO CORRESPONDING FIELDS OF TABLE IT_ZMST_PERMIT
           WHERE ZPIDNUM IN S_PIDNUM
           AND   ZENGDSC IN S_ENGDSC
           AND   ZARBDSC IN S_ARBDSC
           AND   ZTARIFF IN S_TARIFF
           AND   ZPERNUM IN S_PERNUM
           AND   ZARRPRT IN S_ARRPRT.
      IF SY-SUBRC <> 0.
        MESSAGE TEXT-017 TYPE 'I'.
        LEAVE TO TRANSACTION 'ZMSTR022'.
      ELSE.
        LOOP AT IT_ZMST_PERMIT INTO WA_ZMST_PERMIT.
          WA_ZMST_PERMIT-ZPERM_MIN = TEXT-020.
          MODIFY IT_ZMST_PERMIT INDEX SY-TABIX FROM WA_ZMST_PERMIT TRANSPORTING ZPERM_MIN .
        ENDLOOP.
        PERFORM ALV_DISP.        " calling subroutine for ALV display
      ENDIF.
    ENDFORM.                    " fetch_Permit
    *&      Form  fetch_permithi
          text
    -->  p1        text
    <--  p2        text
    FORM FETCH_PERMITHI .
    -Fetching data from zmst_permit based on the inputs on selection screen--
      SELECT
           ZPIDNUM
           ZARBDSC
           ZENGDSC
           ZENQUAN
           ZARQUAN
           ZENUOM
           ZTARIFF
           ZARRPRT
           ZPERNUM
           ZEFFDT
           ZEXPDT
           FROM ZMST_PERMITHI INTO CORRESPONDING FIELDS OF TABLE IT_ZMST_PERMIT
           WHERE ZPIDNUM IN S_PIDNUM
           AND   ZENGDSC IN S_ENGDSC
           AND   ZARBDSC IN S_ARBDSC
           AND   ZTARIFF IN S_TARIFF
           AND   ZPERNUM IN S_PERNUM
           AND   ZARRPRT IN S_ARRPRT
           AND  ZPERTYP  = P_PERTYP.
      IF SY-SUBRC <> 0.
        MESSAGE TEXT-017 TYPE 'I'.
        LEAVE TO TRANSACTION 'ZMSTR022'.
      ELSE.
        LOOP AT IT_ZMST_PERMIT INTO WA_ZMST_PERMIT.
          CASE P_PERTYP.
            WHEN 'I'.
              WA_ZMST_PERMIT-ZPERM_MIN = TEXT-021.
              MODIFY IT_ZMST_PERMIT INDEX SY-TABIX FROM WA_ZMST_PERMIT TRANSPORTING ZPERM_MIN .
            WHEN 'H'.
              WA_ZMST_PERMIT-ZPERM_MIN = TEXT-022.
              MODIFY IT_ZMST_PERMIT INDEX SY-TABIX FROM WA_ZMST_PERMIT TRANSPORTING ZPERM_MIN .
          ENDCASE.
        ENDLOOP.
        PERFORM ALV_DISP.        " calling subroutine for ALV display
      ENDIF.
    ENDFORM.                    " fetch_permithi
    *&      Form  val_PERTYP
          text
    -->  p1        text
    <--  p2        text
    FORM VAL_PERTYP .
      DATA: W_NAME TYPE VRM_ID,
            IT_LIST TYPE VRM_VALUES,
            WA_VALUE LIKE LINE OF IT_LIST.
      WA_VALUE-KEY = ' '.
      WA_VALUE-TEXT = TEXT-020.
      APPEND WA_VALUE TO IT_LIST.
      CLEAR WA_VALUE.
      WA_VALUE-KEY = 'I'.
      WA_VALUE-TEXT = TEXT-021.
      APPEND WA_VALUE TO IT_LIST.
      CLEAR WA_VALUE.
      WA_VALUE-KEY = 'H'.
      WA_VALUE-TEXT = TEXT-022.
      APPEND WA_VALUE TO IT_LIST.
      CLEAR WA_VALUE.
      W_NAME = 'P_PERTYP'.
      P_PERTYP = ' '.
      CALL FUNCTION 'VRM_SET_VALUES'
        EXPORTING
          ID              = W_NAME
          VALUES          = IT_LIST
        EXCEPTIONS
          ID_ILLEGAL_NAME = 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.                    " val_PERTYP

  • 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

Maybe you are looking for