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

Workflow for Qaulification Profile creation



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> SAP Business Workflow
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1639

PostPosted: Sun Dec 16, 2007 12:57 am    Post subject: Workflow for Qaulification Profile creation Reply with quote

When I copied BUS7019 to ZSKILL...I deleted the key field "PersonType "
since I don't need it and I replaced in the source of the BO all the OBJECT-KEY-PersonType by 'P' and then deleted the events and created one "CHANGEDSUBPROFILE".

So my key fields of BO are now :
ZSKILL.PlanVersion
ZSKILL.PersonID
ZSKILL.QualificationID
ZSKILL.EndDate

Now in my copy of the function HR_EVENT_WF_SUBPROFILE_DEFICIT that I called ZHR_EVENT_WF_SUBPROFILE
I adapted the structure
DATA: BEGIN OF object_key,
planversion LIKE objec-plvar,
PersonID LIKE p1001-sobid,
QualificationID like objec-objid,
EndDate like objec-endda,
END OF object_key.

and then I added this code before calling the function 'SWE_EVENT_CREATE'
Code:
MOVE plog_tab_record-plvar TO object_key-planversion.
MOVE plog_tab_record-varyf+2(8) to object_key-PersonID.
MOVE plog_tab_record-OBJID to object_key-QualificationID.
MOVE plog_tab_record-endda to object_key-EndDate.

and I deleted what I don't needed in the function since my relationship between a person and Qualifiction will always be '032'.
I've put the whole function in the bottom.

Of course to make this work you have to create an entry in the table T777IBO
to link a qualification to your new BO.
(Q-1001-B032-ZSKILL).

And then the table T779X to link a qualification creation to your BO and to a function module (your copy ZHR_EVENT_WF_SUBPROFILE)

Object Type Q
Infotype 1001
Subtype B032
Update op. INS
Activity PDSP
Sequence no. 0
Object type ZSKILL
Event
Function Module ZHR_EVENT_WF_SUBPROFILE

so normally now when you create a qualification for your employee you should have your BO ZSKILL in the SWEL with your event.

Now I have also adapted to have more info and function.
For example a virtual attribute VALSCALETXT to have the text value of the scale of the qualification (ex: Fluent for a langage)
Creation : VALSCALETXT like T77TN-RAT_TEXT.

Code:
GET_PROPERTY VALSCALETXT CHANGING CONTAINER.
DATA : partic_tab like HRSOBID occurs 0 with header line,
QUALIF_TAB like HRVQUALIF occurs 0 with header line,
Q_SCALE_TAB like SCALE_STRU occurs 0 with header line,
SCALEID like SCALE_STRU-SCALE,
valscale like PT1045-RATING.
clear : QUALIF_TAB,QUALIF_TAB[],partic_tab,partic_tab[].
refresh : QUALIF_TAB,QUALIF_TAB[],partic_tab,partic_tab[].

partic_tab-plvar = OBJECT-KEY-PlanVersion.
partic_tab-otype = 'P'.
partic_tab-sobid = OBJECT-KEY-PersonID.
append partic_tab.

CALL FUNCTION 'RH_GET_QUALIFICATION'
EXPORTING
begda = '19000101'
endda = '99991231'
TABLES
partic_tab = partic_tab
qualif_tab = QUALIF_TAB
EXCEPTIONS
no_qualif_found = 01.
IF SY-SUBRC EQ 0.
LOOP AT QUALIF_TAB where QUAID eq OBJECT-KEY-QualificationID.
CALL FUNCTION 'RHPE_Q_SCALE_READ'
EXPORTING
PLVAR = OBJECT-KEY-PlanVersion
OTYPE = 'Q'
OBJID = OBJECT-KEY-QualificationID
BEGDA = '19000101'
ENDDA = '99991231'
TABLES
Q_SCALE_TAB = Q_SCALE_TAB.
IF SY-SUBRC EQ 0.
LOOP AT Q_SCALE_TAB where begda le sy-datum and
endda GE sy-datum.
move Q_SCALE_TAB-scale to SCALEID.
ENDLOOP.
move QUALIF_TAB-CHARA to valscale.
CALL FUNCTION 'RHPS_SCALE_PROFCY_TEXT_READ'
EXPORTING
SCALE_ID = SCALEID
RATING = valscale
IMPORTING
PROFC_TEXT = OBJECT-VALSCALETXT.
ENDIF.
ENDLOOP.
ENDIF.

SWC_SET_ELEMENT CONTAINER 'VALSCALETXT' OBJECT-VALSCALETXT.
END_PROPERTY.


Now I added also a method to delete the relationship between the qualification and the person (if the manager reject it in my workflow)

Code:
BEGIN_METHOD DELETERELATIONSHIP CHANGING CONTAINER.
DATA : TABPROF like HRPE_RELAQ occurs 0 with header line.
CLEAR : TABPROF,TABPROF[].
refresh : TABPROF,TABPROF[].

SELECT * from HRP1001 where plvar eq OBJECT-KEY-PlanVersion AND
otype eq 'P' AND
OBJID eq OBJECT-KEY-PersonID AND
RSIGN eq 'A' AND
RELAT eq '032' AND
endda eq OBJECT-KEY-ENDDATE and
SCLAS eq 'Q' and
SOBID eq OBJECT-KEY-QualificationID.
ENDSELECT.
IF SY-SUBRC EQ 0.
move 'Q' to TABPROF-TTYPE.
move OBJECT-KEY-QualificationID to TABPROF-TBJID.
move HRP1001-begda to TABPROF-SBEGD.
move HRP1001-endda to TABPROF-SENDD.
move HRP1001-begda to TABPROF-VBEGD.
move HRP1001-endda to TABPROF-VENDD.
append tabprof.

CALL FUNCTION 'RHPP_Q_PROFILE_DELETE'
EXPORTING
PLVAR = OBJECT-KEY-PlanVersion
OTYPE = 'P'
OBJID = OBJECT-KEY-PersonID
BEGDA = HRP1001-begda
ENDDA = HRP1001-endda
VTASK = 'D'
TABLES
PROFILE = TABPROF.
ENDIF.
END_METHOD.


And now this is the whole function : ZHR_EVENT_WF_SUBPROFILE

Code:
* Corrections
* DATE Correction Note Description User
* 05.12.02 ABAK013608 525980 no triggering of workflow for PZ31 Ludwig
* 22.07.03 ABAK017234 593025 no triggering for other otypes than 'P '
* 11.02.05 PABK008687 817979 Wrong object type in workflow container

FUNCTION ZHR_EVENT_WF_SUBPROFILE.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(BUSINESSOBJECT) LIKE T779W-BUSOB
*" VALUE(OPERATION) LIKE T779W-WFOPR
*" VALUE(LFCOD) LIKE T779W-LFCOD OPTIONAL
*" VALUE(PLOG_TAB_RECORD) LIKE HRDBTAB STRUCTURE HRDBTAB
*" TABLES
*" EVENTS_PER_OPERATION STRUCTURE HREVENTS
*" BEFORE_IMAGE STRUCTURE BEF_IMAGE
*" AFTER_IMAGE STRUCTURE AFT_IMAGE
*"----------------------------------------------------------------------
* Tables
DATA: BEGIN OF object_key,
planversion LIKE objec-plvar,
PersonID LIKE p1001-sobid,
QualificationID like objec-objid,
EndDate like objec-endda,
END OF object_key.

DATA: objkey LIKE sweinstcou-objkey.
DATA: l_objects LIKE hrsobid OCCURS 1 WITH HEADER LINE.
DATA: l_pos_objects LIKE hrsobid OCCURS 1 WITH HEADER LINE.
DATA: l_positions LIKE hrpe_profl OCCURS 1 WITH HEADER LINE.
DATA: l_pos_holder LIKE hrpe_prozt OCCURS 1 WITH HEADER LINE.
DATA: l_p_holder LIKE hrsobid OCCURS 1 WITH HEADER LINE.
DATA: l_quali_profiles LIKE hrpe_profq OCCURS 1 WITH HEADER LINE.
DATA: l_defizit_tab LIKE hrpe_profq OCCURS 1 WITH HEADER LINE.
DATA: l_requi_profiles LIKE hrpe_profq OCCURS 1 WITH HEADER LINE.
DATA: l_profil_old LIKE hrpe_profq OCCURS 1 WITH HEADER LINE.
DATA: l_profil_new LIKE hrpe_profq OCCURS 1 WITH HEADER LINE.

*-----------------------------------------------------------------------
* Variables
*-----------------------------------------------------------------------
DATA: l_defizit.
DATA: before_image_flag.
DATA: after_image_flag.
DATA: help_tabix1 LIKE sy-tabix.
DATA: help_objects_tabix LIKE sy-tabix.
DATA: h_tabix LIKE sy-tabix.
DATA: subrc LIKE sy-subrc.
DATA: dynpro_nr LIKE sy-dynnr.
DATA: repid_nr LIKE sy-repid.
DATA: profile_view LIKE t77pp_view-profile_view.
DATA: partid LIKE t77pp_part-partid.
* ----------------------------------------------------------------------
* Zuweisung der Profilsicht

CALL FUNCTION 'RHP6_PROFILE_TECHNIC_INFO_GET'
IMPORTING
e_profile_view = profile_view.
* E_VIEW_REPID =
* E_HEAD_DYNNR =
* E_HEAD_REPID =
* E_PART_DYNNR =
* E_PART_REPID =
* E_PART_TEXT =
* E_MAINTAIN =
* E_COMMIT_FLG =
* E_POPUP =

* case PLOG_TAB_RECORD-subty+1(3). "Verknüpfung
PERFORM read_t77s0_parameters_for_pe.
READ TABLE before_image INDEX 1 TRANSPORTING NO FIELDS.
IF sy-subrc = 0.
before_image_flag = 'X'.
ELSE.
READ TABLE after_image INDEX 1 TRANSPORTING NO FIELDS.
IF sy-subrc = 0.
after_image_flag = 'X'.
ENDIF.
ENDIF.
IF before_image_flag = 'X'.
* Alle Planstellen von Stellen lesen
LOOP AT before_image.
l_objects-plvar = before_image-plvar.
l_objects-otype = before_image-varyf(2).
l_objects-sobid = before_image-varyf+2(8).
APPEND l_objects.
ENDLOOP.
ELSE.
LOOP AT after_image.
l_objects-plvar = after_image-plvar.
l_objects-otype = after_image-varyf(2).
l_objects-sobid = after_image-varyf+2(8).
APPEND l_objects.
ENDLOOP.
ENDIF.
$plvar = plog_tab_record-plvar.
$gdate = sy-datum.

CASE plog_tab_record-subty+1(3). "Verknüpfung

WHEN '032'.
dynpro_nr = '2100'.
repid_nr = 'SAPLRHPP'.
PERFORM read_profile_partid(saplrhp6)
USING profile_view
l_objects-otype "Object_Key-OBJTYPE
dynpro_nr
repid_nr
partid
subrc.
IF sy-subrc <> 0.
dynpro_nr = '2101'.
repid_nr = 'SAPLRHPP'.
PERFORM read_profile_partid(saplrhp6)
USING profile_view
l_objects-otype "Object_Key-OBJTYPE
dynpro_nr
repid_nr
partid
subrc.
IF sy-subrc <> 0.
dynpro_nr = '2102'.
repid_nr = 'SAPLRHPP'.
PERFORM read_profile_partid(saplrhp6)
USING profile_view
l_objects-otype "Object_Key-OBJTYPE
dynpro_nr
repid_nr
partid
subrc.
* Correction: ABAK013608 525980
* Correction for the workflow for the web transaction PZ31 and PZ32.
* With the dummy partid '0001' and dynpro_nr '0003' the internet
* transactio PZ31 is working for changed subprofile.
IF sy-subrc <> 0.
dynpro_nr = '2101'. "Dynpro of PZ31/PZ32 Web transaction
repid_nr = 'SAPLRHPP'. "Just defined as dummy id for Workfl
profile_view = 'PD'.
PERFORM read_profile_partid(saplrhp6)
USING profile_view
l_objects-otype "Object_Key-OBJTYPE
dynpro_nr
repid_nr
partid
subrc.
ENDIF. "dynpro_nr = '2101' for simulation of Web Ta PZ31
ENDIF. "dynpro_nr = '2101'.
ENDIF. "dynpro_nr = '2102'.

ENDCASE. "case PLOG_TAB_RECORD-subty1(3)

IF dynpro_nr <> '3100' AND dynpro_nr <> '3101'
AND NOT partid IS INITIAL.

* Mohamed FREDJ
MOVE plog_tab_record-plvar TO object_key-planversion.
MOVE plog_tab_record-varyf+2(8) to object_key-PersonID.
MOVE plog_tab_record-OBJID to object_key-QualificationID.
MOVE plog_tab_record-endda to object_key-EndDate.

MOVE object_key TO objkey.
CLEAR before_image_flag.
READ TABLE before_image INDEX 1 TRANSPORTING NO FIELDS.
IF sy-subrc = 0.
before_image_flag = 'X'.
CALL FUNCTION 'SWE_EVENT_CREATE'
EXPORTING
objtype = businessobject
objkey = objkey
event = 'CHANGEDSUBPROFILE'
EXCEPTIONS
OBJTYPE_NOT_FOUND.
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.
READ TABLE after_image INDEX 1 TRANSPORTING NO FIELDS.
IF sy-subrc = 0.
CALL FUNCTION 'SWE_EVENT_CREATE'
EXPORTING
objtype = businessobject
objkey = objkey
event = 'CHANGEDSUBPROFILE'
EXCEPTIONS
OBJTYPE_NOT_FOUND.
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.
ENDIF.
ENDIF.

ENDFUNCTION.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> SAP Business Workflow 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.