SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Object oriented resolve rule responsibility class



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> HR
View previous topic :: View next topic  
Author Message
vga
Мастер
Мастер


Age: 160
Joined: 04 Oct 2007
Posts: 1218
Location: Санкт-Петербург

PostPosted: Mon Dec 01, 2008 5:30 pm    Post subject: Object oriented resolve rule responsibility class Reply with quote

Code:
METHOD call_rule_gen_request.  DATA:
    lo_container TYPE REF TO cl_swf_cnt_container,
    lt_agents TYPE tswhactor,
    lx_agents TYPE swhactor,
    lx_agent_details_full TYPE zcas_workflow_agent,
    lx_agent_details_short TYPE zcas_workflow_agent_short,
    lx_actors TYPE ZCAS_WORKFLOW_ACTORS.

  DATA:
    l_user_name TYPE xubname,
    l_pernr TYPE pernr_d,
    l_user_address TYPE addr3_val,
    l_user_usr03 TYPE usr03,
    t_adsmtp  TYPE STANDARD TABLE OF adsmtp,
    x_adsmtp  TYPE adsmtp,
    t_p0105  TYPE STANDARD TABLE OF p0105,
    x_p0105  TYPE p0105.

  CREATE OBJECT lo_container.

  IF iv_bukrs IS NOT INITIAL.
    TRY.
      CALL METHOD lo_container->if_swf_cnt_element_access_1~element_set_value
        EXPORTING
          name  = ‘BUKRS’
          value = iv_bukrs.
    ENDTRY.
  ENDIF.

  IF iv_object_type IS NOT INITIAL.
    TRY.
      CALL METHOD lo_container->if_swf_cnt_element_access_1~element_set_value
        EXPORTING
          name  = ‘ZCA_OBJECT_TYPE’
          value = iv_object_type.
    ENDTRY.
  ENDIF.

  CALL FUNCTION ‘RH_GET_ACTORS’
    EXPORTING
      act_object                = iv_rule
      actor_container_oo        = lo_container
    TABLES
      actor_tab                 = lt_agents
    EXCEPTIONS
      no_active_plvar           = 1
      no_actor_found            = 2
      exception_of_role_raised  = 3
      no_valid_agent_determined = 4
      no_container              = 5
      OTHERS                    = 6.

*  Get full details of each agent
  LOOP AT lt_agents INTO lx_agents.

    CLEAR: lx_agent_details_full,
           lx_agent_details_short,
           lx_actors.

*   actor type is personnel (P), get user id
    IF lx_agents-otype = ‘P’.

      l_pernr = lx_agents-objid.

      CALL FUNCTION ‘HR_READ_INFOTYPE’
        EXPORTING
*         TCLAS                 = ’A’
          pernr                 = l_pernr
          infty                 = ‘0105′
          begda                 = sy-datum
          endda                 = sy-datum
        TABLES
          infty_tab             = t_p0105
       EXCEPTIONS
         infty_not_found       = 1
         OTHERS                = 2
                .
      IF sy-subrc = 0.
        LOOP AT t_p0105 INTO x_p0105 WHERE subty = ‘0001′.
          WRITE: x_p0105-usrid TO l_user_name.
        ENDLOOP.
      ELSE.
        CONTINUE.
      ENDIF.

    ENDIF.
    IF lx_agents-otype = ‘US’.
      l_user_name = lx_agents-objid.
    ENDIF.

    if l_user_name is not initial.
      CONCATENATE ‘US’ l_user_name into lx_actors-initiator.
      APPEND lx_actors to et_actors.
    else.
      CONTINUE.
    endif.

    CALL FUNCTION ‘SUSR_USER_ADDRESS_READ’
      EXPORTING
        user_name              = l_user_name
      IMPORTING
        user_address           = l_user_address
        user_usr03             = l_user_usr03
      EXCEPTIONS
        user_address_not_found = 1
        OTHERS                 = 2.
    IF sy-subrc = 0.

      lx_agent_details_full-zname     =  l_user_address-name_text.
      lx_agent_details_short-zname     =  l_user_address-name_text.
      lx_agent_details_full-zposition = l_user_address-function.
      lx_agent_details_full-zcompany  = l_user_usr03-name3.
      lx_agent_details_full-zphone    = l_user_usr03-telnr.
      lx_agent_details_short-zphone    = l_user_usr03-telnr.

*     get email address
      CALL FUNCTION ‘ADDR_PERS_COMP_COMM_GET’
        EXPORTING
          address_number    = l_user_address-addrnumber
          person_number     = l_user_address-persnumber
          table_type        = ‘ADSMTP’
        TABLES
          comm_table        = t_adsmtp
        EXCEPTIONS
          parameter_error   = 1
          address_not_exist = 2
          person_not_exist  = 3
          internal_error    = 4
          OTHERS            = 5.
      IF sy-subrc = 0.
        LOOP AT t_adsmtp INTO x_adsmtp WHERE NOT flgdefault IS INITIAL.
          lx_agent_details_full-zemail = x_adsmtp-smtp_addr.
          lx_agent_details_short-zemail = x_adsmtp-smtp_addr.
        ENDLOOP.
      ENDIF.

      APPEND lx_agent_details_full TO et_agents_full.
      APPEND lx_agent_details_short TO et_agents_short.

    ENDIF.
  ENDLOOP.

ENDMETHOD.

 


      CALL METHOD zcl_ca_master_data_forms_util=>call_rule_gen_request
        EXPORTING
          iv_rule         = ‘AC90000017′
          iv_bukrs        = ls_request_details-bukrs
          iv_object_type  = ls_request_details-zwf_object_type
         IMPORTING
*          et_agents_short =
           et_agents_full  = lt_agents
          .   
Back to top
View user's profile Send private message Blog Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> HR All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.