Blogs

Loading Dropdown value in HCM Forms from Generic Services
Mukesh mani
Business Card
Company: Kaar Technologies
Posted on Nov. 06, 2009 02:32 AM in SAP Interactive Forms by Adobe

Subscribe.Subscribe
Print. Print
Permalink Permalink

Loading Dropdown value in HCM Forms from Generic Services

In design process HRASR_DT create the field for the dropdown for example to load the vacant position PLANS.

Create a Generic service for your process and bind the service to your process.

image 

Add the following interfaces into the Class.

IF_BADI_INTERFACE

IF_HRASR00GEN_SERVICE

Create an attribute for the dropdown in the generic service attribute.

img2 

Create a method GET_FIELDS_OF_OPERATION in the Generic service with following parameter.

img3

Do the following coding in GET_FIELDS_OF_OPERATION method.

  CLEAR fieldnames.
  CASE operation.
    WHEN c_oper_set_init_data. "operation for the
      APPEND c_fieldname_position_new TO fieldnames.
    WHEN OTHERS.
      ASSERT 1 = 0. "called for an operation, that is not supported

  ENDCASE.

Do the following coding in IF_HRASR00GEN_SERVICE~GET_FIELD_INFO

 

  DATA field_info TYPE hrasr00gs_field_info.
  DATA service_field TYPE fieldname.

  CLEAR field_infos.

  LOOP AT service_fields INTO service_field.

    CASE service_field.
      WHEN c_fieldname_position_new.
        field_info-fieldname = c_fieldname_position_new.
        field_info-field_data_element_name = c_dtel_position_new.
        field_info-supports_value_help = false.
        field_info-supports_default_value = true.
        APPEND field_info TO field_infos.
    ENDCASE.

  ENDLOOP.

You have to build custom function module to retrieve the vacant list of positions for OM. In the generic service class in the method

 

IF_HRASR00GEN_SERVICE~GET_HELP_VALUES load the value for the dropdown with the help of the function module.

Define the following in private section

  types:
    begin of t_position,
           position_id type plans,
           position_text type stext,
         end of t_position .
  types:
    t_position_tab type standard table of t_position .

 

Do the coding in IF_HRASR00GEN_SERVICE~GET_HELP_VALUES.

  DATA service_field_value_wa TYPE hrasr00gensrv_dataset.
  DATA field_catalog TYPE hrpad_f4help_table_column_tab.
  DATA field_catalog_wa TYPE hrpad_f4help_table_column.

  DATA positions TYPE t_position_tab.
  DATA positions_wa TYPE t_position.
  DATA positions_ref TYPE REF TO data.
  FIELD-SYMBOLS <positions> TYPE ANY.


  FIELD-SYMBOLS <help_dataset_wa> TYPE hrasr00gs_help_dataset.
  FIELD-SYMBOLS <service_field_value_wa> TYPE hrasr00gensrv_dataset.

  LOOP AT help_datasets ASSIGNING <help_dataset_wa>.
    CASE <help_dataset_wa>-fieldname.
      WHEN c_fieldname_position_new.              "open positions

*       create field catalog
        CLEAR field_catalog.
        CLEAR field_catalog_wa.
        field_catalog_wa-fieldname = c_column_name_pos_id.
        field_catalog_wa-headertitle = 'Position No'.
        APPEND field_catalog_wa TO field_catalog.

        CLEAR field_catalog_wa.
        field_catalog_wa-fieldname = c_column_name_pos_text.
        field_catalog_wa-headertitle = 'Description'.
        APPEND field_catalog_wa TO field_catalog.

        <help_dataset_wa>-field_catalog = field_catalog.


        CALL FUNCTION 'ZF_VACANCY_LIST' "Custom Function Module
          EXPORTING
            i_user_id      = sy-uname
*          IMPORTING
*            e_return       = bapi_return
          TABLES
            t_vacancy_list = positions.

        LOOP AT positions INTO positions_wa.
          CONCATENATE positions_wa-position_id positions_wa-position_text INTO positions_wa-position_text SEPARATED BY space.
          MODIFY positions FROM positions_wa.
        ENDLOOP.

*       create reference to table with positions (available outside this method)
        CREATE DATA positions_ref TYPE t_position_tab.
        ASSIGN positions_ref->* TO <positions>.
        <positions> = positions.
        <help_dataset_wa>-data = positions_ref.

*       column names in data table
        <help_dataset_wa>-keycolumnname = c_column_name_pos_id.
        <help_dataset_wa>-valuecolumnname = c_column_name_pos_text.
    ENDCASE.
  ENDLOOP.

Bind the attribute in the dropdown in SFP transaction.

img4

Mukesh mani -joined Kaar Technologies as a Senior Software Engineer.


Add to: del.icio.us | Digg | Reddit


Comment on this article
Comment on this weblog