HCM Process and Forms - Drop Down List box with Round Trip

...Previous

Now we have created our custom service. The next step would be creating the fields for drop down (Personnel Area and Personnel Sub area) and then assign these fields to our custom service, so that we will get the values from the Adobe Form when they select the Personnel Area a round trip triggers. Based on the value selected in the Personnel Area we can populate the Personnel Sub area drop down.

The Field I0001_WERKS and I0001_BTRTL has been created in the class ZCL_DROP_DOWN and bring those fields and assign to the form. So in our BADI class ZCL_DROP_DOWN we need to create the operation that needs to perform and also create the fields that needs to come in the custom service. In the class I have implemented the following methods to perform this activity.

The method IF_HRASR00GEN_SERVICE~GET_FIELD_INFO, IF_HRASR00GEN_SERVICE~GET_OPERATIONS and IF_HRASR00GEN_SERVICE~GET_HELP_VALUES .. Write the following code.

 To get the Value help, we need to write the logic in this method IF_HRASR00GEN_SERVICE~GET_HELP_VALUES. (Logic written in this method)

METHOD if_hrasr00gen_service~get_help_values.

  
TYPESBEGIN OF ls_werks,
         persa 
TYPE persa,
         name1 
TYPE pbtxt,
         
END   OF ls_werks,
         tt_werks 
TYPE TABLE OF ls_werks .

  
TYPESBEGIN OF ls_btrtl,
         btrtl 
TYPE btrtl_001p,
         btext 
TYPE btrtx,
         
END   OF ls_btrtl,
         tt_btrtl 
TYPE TABLE OF ls_btrtl .

  
DATA ls_field_catalog TYPE hrpad_f4help_table_column.
  
DATA lt_field_catalog TYPE hrpad_f4help_table_column_tab.
  
DATA lo_ref_werks     TYPE REF TO data.
  
DATA lo_ref_btrtl     TYPE REF TO data.
  
DATA lt_werks         TYPE TABLE OF ls_werks.
  
DATA lt_btrtl         TYPE TABLE OF ls_btrtl.
  
DATA ls_field_value   LIKE LINE OF service_field_values.

  
FIELD-SYMBOLS: <ls_help_dataset>     TYPE hrasr00gs_help_dataset,
                 <lt_werks>            
TYPE any,
                 <lt_btrtl>            
TYPE any.

  
"Fetch Personnel Area
  
SELECT persa name1 FROM t500p INTO TABLE lt_werks.

  
READ TABLE service_field_values INTO ls_field_value WITH KEY fieldname = 'I0001_WERKS'.
  
IF sy-subrc EQ 0 AND ls_field_value-fieldvalue IS NOT INITIAL.
    
SELECT btrtl btext FROM t001p INTO TABLE lt_btrtl WHERE werks = ls_field_value-fieldvalue.
  
ENDIF.

  
LOOP AT help_datasets ASSIGNING <ls_help_dataset>.
    
CASE <ls_help_dataset>-fieldname.
      
WHEN 'I0001_WERKS'.

        
"create field catalog
        ls_field_catalog-fieldname   = 
'PERSA'.
        ls_field_catalog-headertitle = 
'PERSONNEL AREA'.
        
APPEND ls_field_catalog TO lt_field_catalog.

        ls_field_catalog-fieldname   = 
'NAME1'.
        ls_field_catalog-headertitle = 
'Personnel Area Description'.
        
APPEND ls_field_catalog TO lt_field_catalog.

        <ls_help_dataset>-field_catalog = lt_field_catalog.

        
"create reference to table
        
CREATE DATA lo_ref_werks TYPE tt_werks.
        
ASSIGN lo_ref_werks->* TO <lt_werks>.
        <lt_werks> = lt_werks.
        <ls_help_dataset>-
data = lo_ref_werks.
        <ls_help_dataset>-keycolumnname = 
'PERSA'.
        <ls_help_dataset>-valuecolumnname = 
'NAME1'.

      
WHEN 'I0001_BTRTL'.
        ls_field_catalog-fieldname   = 
'BTRTL'.
        ls_field_catalog-headertitle = 
'PERSONNEL SUB_AREA'.
        
APPEND ls_field_catalog TO lt_field_catalog.

        ls_field_catalog-fieldname   = 
'BTEXT'.
        ls_field_catalog-headertitle = 
'Personnel SubArea Description'.
        
APPEND ls_field_catalog TO lt_field_catalog.

        <ls_help_dataset>-field_catalog = lt_field_catalog.

        
"create reference to table
        
CREATE DATA lo_ref_btrtl TYPE tt_btrtl.
        
ASSIGN lo_ref_btrtl->* TO <lt_btrtl>.
        <lt_btrtl> = lt_btrtl.
        <ls_help_dataset>-
data = lo_ref_btrtl.
        <ls_help_dataset>-keycolumnname = 
'BTRTL'.
        <ls_help_dataset>-valuecolumnname = 
'BTEXT'.

    
ENDCASE.
  
ENDLOOP.

ENDMETHOD.  

Now come to our Form Scenario (Tcode: HRASR_DT) and select the backend-Service ZDROP_DOWN and click the “Service Fields” button. Select the operation “V_HELP” from the drop down and give the Field group name as “V_HELP” and select the fields I0001_WERKS and I0001_BTRTL.

Now go to the FORM – and you can still see its inactive. Click on change button and it will go to the SFP transaction and display the adobe form. (Don’t directly go to SFP and activate/change the FORM. Its recommend that always go via HRASR_DT if you want to change to FORM, as the ISR will get changed if you add or remove any fields in the form scenario).

Click here to continue...

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image