Friday, March 14, 2014
When we create Talent groups through upload programs
  1. Create Talent Group:  Need to create Talent Group object using function module RH_INSERT_INFTY. 
  2. Upload Talent Group Description. We use two main function modules to store comments (1)  SDOK_LOIO_CREATE_WITH_PHIO (2)  SDOK_PHIO_STORE_CONTENT. Once comments for Talent Group is stored, we have to create entry in HRP7420 table. Use function module  RH_INSERT_INFTY_EXP to insert record.  This table should contain Talent group object ID and comments information such as hrp7420-description_id and hrp7420-descr_class.

PERFORM upload_talent_group_description USING gs_data-description
                             CHANGING ls_hrp7420-description_id
                                      ls_hrp7420-descr_class
                                      gs_data-remarks.

*&---------------------------------------------------------------------*
*&      Form  upload_talent_group_description
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_LS_HRP7420_DESCRIPTION_ID  text
*----------------------------------------------------------------------*
FORM upload_talent_group_description USING pv_content
                         CHANGING pv_description_id TYPE p7420-description_id
                                   pv_descr_class    TYPE p7420-descr_class
                                   pc_remarks        TYPE text150.
  "Structures
  DATA:
        ls_kpro_loio_property      TYPE sdokpropty,
        ls_kpro_phio_property      TYPE sdokpropty,
        ls_phio_object_id          TYPE sdokobject,
        ls_file_info               TYPE sdokfilaci.
  "Internal tables
  DATA:
        lt_kpro_loio_properties    TYPE TABLE OF sdokpropty,
        lt_kpro_phio_properties    TYPE TABLE OF sdokpropty,
        lt_file_content_ascii      TYPE TABLE OF sdokcntasc,
        lt_file_info               TYPE TABLE OF sdokfilaci.
  "Variables
  DATA:
        lv_is_ok                   TYPE boole_d,
        lv_dummy_msg               TYPE symsg,
        lv_ex_text                 TYPE string,
        lv_language                TYPE spras,
        lv_kpro_phio_class_name    TYPE sdok_phcl,
        lv_output_binary_length    TYPE i,
        lv_docu_id                 TYPE sdok_docid,
        lv_class                   TYPE sdok_locl,
        lv_ok                      TYPE boole_d.
  "Ref Classes
  DATA:
        go_message_handler_att     TYPE REF TO cl_hrbas_message_list.
  "Constants
  CONSTANTS:
       lc_text_loio_class_name_part TYPE string VALUE 'TXT'.

  lv_kpro_phio_class_name = 'TXT_PHIO1'.
  pv_descr_class          = 'TXT_LOIO1'.

  CREATE OBJECT go_message_handler_att.

  CALL METHOD cl_hrtmc_document_utils=>get_new_id
    EXPORTING
      iv_document_type  = 'COMMENT'
    IMPORTING
      ev_document_class = lv_class
      ev_document_id    = lv_docu_id
      ev_is_ok          = lv_ok.

  " logical class properties
  ls_kpro_loio_property-name  = 'ORIGINAL_LANGUAGE'.
  ls_kpro_loio_property-value = sy-langu.
  INSERT ls_kpro_loio_property INTO TABLE lt_kpro_loio_properties.

  " physical class properties
  ls_kpro_phio_property-name  = 'STORAGE_CATEGORY'.
  ls_kpro_phio_property-value = 'HCM_TMC_CT'.
  INSERT ls_kpro_phio_property INTO TABLE lt_kpro_phio_properties.

  ls_kpro_phio_property-name  = 'LANGUAGE'.
  ls_kpro_phio_property-value = sy-langu.
  INSERT ls_kpro_phio_property INTO TABLE lt_kpro_phio_properties.


  " create new loio with phio
  DATA lv_loio_unique_id TYPE sdokloio-loio_id.
  lv_loio_unique_id = lv_docu_id.
  CALL FUNCTION 'SDOK_LOIO_CREATE_WITH_PHIO'
    EXPORTING
      loio_class          = pv_descr_class
      phio_class          = 'TXT_PHIO1'
      loio_unique_id      = lv_loio_unique_id
    IMPORTING
      phio_object_id      = ls_phio_object_id
    TABLES
      loio_properties     = lt_kpro_loio_properties
      phio_properties     = lt_kpro_phio_properties
    EXCEPTIONS
      missing_class       = 1
      bad_class           = 2
      missing_properties  = 3
      bad_relations       = 4
      bad_properties      = 5
      not_authorized      = 6
      duplicate_object_id = 7
      bad_storage_type    = 8
      exception_in_exit   = 9.
  IF sy-subrc <> 0.
    CASE sy-subrc.
      WHEN 1.
        pc_remarks = 'Missing Class'.
        EXIT.
      WHEN 2.
        pc_remarks = 'Bad Class'.
        EXIT.
      WHEN 3.
        pc_remarks = 'Missing Properties'.
        EXIT.
      WHEN 4.
        pc_remarks = 'Bad Relationship'.
        EXIT.
      WHEN 5.
        pc_remarks = 'Bad Properties'.
        EXIT.
      WHEN 6.
        pc_remarks = 'Not Authorized'.
        EXIT.
      WHEN 7.
        pc_remarks = 'Duplicate Object ID'.
        EXIT.
      WHEN 8.
        pc_remarks = 'Bad Storage Type'.
        EXIT.
      WHEN 9.
        pc_remarks = 'Exception in Exit'.
        EXIT.
    ENDCASE.
  ENDIF.

  pv_description_id = lv_loio_unique_id.

  " Prepare content
  CALL FUNCTION 'SCMS_STRING_TO_FTEXT'
    EXPORTING
      text      = pv_content
    IMPORTING
      length    = lv_output_binary_length
    TABLES
      ftext_tab = lt_file_content_ascii.

  " Isert file information to the physical content/file
  ls_file_info-file_size  = lv_output_binary_length.
  ls_file_info-binary_flg = abap_false.
  APPEND ls_file_info TO lt_file_info.


  " Store comment
  CALL FUNCTION 'SDOK_PHIO_STORE_CONTENT'
    EXPORTING
      object_id          = ls_phio_object_id
      raw_mode           = abap_false
    TABLES
      file_content_ascii = lt_file_content_ascii
      file_access_info   = lt_file_info
    EXCEPTIONS
      not_existing       = 1
      not_allowed        = 2
      not_authorized     = 3
      no_content         = 4
      bad_storage_type   = 5
      OTHERS             = 6.
  IF sy-subrc <> 0.
    CASE sy-subrc.
      WHEN 1.
        pc_remarks = 'Not Existing'.
        EXIT.
      WHEN 2.
        pc_remarks = 'Not Allowed'.
        EXIT.
      WHEN 3.
        pc_remarks = 'Not Authorized'.
        EXIT.
      WHEN 4.
        pc_remarks = 'No Content'.
        EXIT.
      WHEN 5.
        pc_remarks = 'Bad Storage Type'.
        EXIT.
      WHEN 6.
        pc_remarks = 'Un Identified Error' .
        EXIT.
    ENDCASE.
  ELSE.
  ENDIF.

ENDFORM.                    " upload_talent_group_description

0 comments:

Post a Comment

Your useful comments, suggestions are appreciated.Your comments are moderated.

Followers

Contact Form

Name

Email *

Message *

Web Dynpro ABAP Book

An SAP Consultant

Follow US


Want to Contribute ?

If you are interested in writing about the new stuff you learn everyday while working, please write to the.sap.consultants@gmail.com.

Click on Contribution for more details.