on 08-03-2016 11:45 PM
Hi,
I am building a program to perform PA actions manually (Rehire for example). I have been able to use the DCIF to create a new inserted record for the 0000 infotype but have run into a road block with getting any other infotypes to insert. The 0000 one inserts the new record as well as delimits the now old separation record. Nice. However, trying the same code process with other infotypes results in a short dump when using the MODIFY_PRIMARY_RECORD method of the container class. This is expected... per the warning in the help documentation:
https://help.sap.com/saphelp_erp60_sp/helpdata/en/ad/9ee2539c70424de10000000a174cb4/content.htm?fram...
So, after trying to discern how to create an empty container, assign it my new values, and do an 'insert' of some sort I can't seem to get a working model with all the right classes/interfaces. The help docs for Insert suggests using the A_GENERIC_UPDATE->INSERT method but I don't have any objects (or know which ones to instantiate) to get at this. I'm doing this as a stand alone custom application that isn't part of the existing PA code base. In essence, I'm not inside of an enhancement where this object (CL_HRPA_INFOTYPE_NNNN) is probably readily available.
Note, I've also been able to successfully use the HR_PAD_HIRE_EMPLOYEE class to create new employees. Other than it's using the DCIF, it doesn't really relate - but I thought I'd throw that in.
I've found a few examples on how to use the insert to update existing records but nothing on actually inserting a brand new record (similar to the 0000) that I did already. I think the 0000 worked fine due to providing the Action and Reason codes - which don't apply for the other infotypes.
My inquiry is to try and find a working code example of someone that's successfully used the DCIF to insert new records that are not of the 0000 type. I'm a little stumped/concerned that there's not much out there by way of examples... which makes me wonder how possible this is.
Anyone come across this or have a reference?
Thanks,
Bryan
Update. I was able to figure this out using the SAP Help documentation. Thing is that the insert function does not allow for using the business logic objects for SAP standard infotypes. It lets you do basically raw inserts or business logic inserts on your own custom infotypes... but not for SAP standard.
So, possibly the 'insert' function is really an update/modify that pairs up with a delimit. Going to need to spend some time looking into that now.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Bryan,
Quick question.
Are you using HR_CONTROL_INFTY_OPERATION to replace HR_PAD_HIRE_EMPLOYEE to initially create the employee as well for a hiring action? If so do you have a code sample?
I'm asking because I'm having issues with HR_PAD_HIRE_EMPLOYEE. The FM seems to work correctly as I get no returned errors or warnings but when I check the infotype tables I don't find anything.
Thanks in advance,
Arthur Parisius
Sure thing. My development is a bit modularized but I'll see what I can post that may be of some help. I'll try to get something posted back here shortly.
Actually, I guess should answer your question first. I am not using HR_CONTROL_INFTY_OPERATION for the hiring. I am using HR_PAD_HIRE_EMPLOYEE to build the initial employee. I do it for infotypes 0001, 0002, 0006, 0007, 0008, 0019, 0009, 0210, 0171, 9900 (custom), 0235, 0041, 0207, 0208, 0209, 0128, 0234, 9810 (custom), and 9820 (custom). I then use HR_CONTROL_INFTY_OPERATION to go back into the brand new employee and add in infotypes 0378, 2006, and 0017 since; 0378 and 0017 have other dependencies on other infotypes and 2006 doesn't work since it's non-DCIF.
Now that the employee is created I am using HR_CONTROL_INFTY_OPERATION for all other infotype updates. I tried a few other methods as I was pretty determined to try and keep all development using strictly DCIF classes but I hit way too many walls and had to retreat to just let HR_CONTROL_INFTY_OPERATION do the work.
Elegant it is not.
Quick background on the pieces:
1) zcl_pa035_par_action_01 - This is used to populate all the field values for each infotype prior to the calls to actually do them. I have each infotype as a separate object due to a bigger picture design to reuse a lot of this. But you can see what field values I'm populating for each infotype at least.
2) ZCL_PA035_NEW_INFOTYPE_0001 - The decorator that pulls the info setup in ACTION_01 (above) and maps it to what's needed for NEWHIRE (below).
3) zcl_pa035_employee_newhire - This is used to put all the pieces together and make the call to the HR_PAD_HIRE_EMPLOYEE and the follow to HR_CONTROL_INFTY_OPERATION.
4) The shell wrapper for HR_PAD_HIRE_EMPLOYEE just so you can see there's nothing in it that adds anything. It's all for dealing with the buffer problems.
I'll post the code for 0001, and 0002 (part of zcl_pa035_par_action_01) as I think those are the mins you need (I think). These are from zcl_pa035_par_action_01. Then I'll put the whole newhire class in here as it has pretty decent comments which might help make sense of it. If I chop that one up it might not make sense. Finally, the shell wrapper FM.
Keep an eye out on the * and " comment lines. I keep all the fields listed as I like to know wha'ts available but comment many of them out.
Hope it helps...
1) CLASS zcl_pa035_par_action_01 IMPLEMENTATION.
METHOD set_p0001.
* Mapping logic of PAR fields into the MODEL.
DATA wstr_data TYPE p0001.
* Variables for FEATURE logic
DATA wstr_structure TYPE pme07.
DATA wc_feature TYPE t549b-namen.
DATA wc_back TYPE char13.
DATA wobj_ref TYPE REF TO data.
DATA wobj_str TYPE REF TO cl_abap_structdescr.
DATA wtbl_t527a TYPE TABLE OF t527a.
FIELD-SYMBOLS <fs1> TYPE t527a.
FIELD-SYMBOLS <fs2> TYPE any.
**********************************************************************
wstr_data-endda = me->model->employee->p0000-endda." End Date
wstr_data-begda = me->model->employee->p0000-begda." Start Date
wstr_data-seqnr = '000'.
wstr_data-aedtm = sy-datum. " Changed On
wstr_data-uname = sy-uname." Name of Person Who Changed Object
**********************************************************************
wstr_data-bukrs = me->model->pardata-bukrs. "Company Code
wstr_data-werks = me->model->pardata-persa. "Personnel Area
wstr_data-persg = me->model->pardata-persg. "Employee Group
wstr_data-persk = me->model->pardata-persk. "Employee Subgroup
* GSBER Business Area
wstr_data-btrtl = me->model->pardata-btrtl. " Personnel Subarea
*** VDSK1 See Below *************************************************
* JUPER Legal Person
" Constant:
wstr_data-abkrs = 'UB'." Payroll Area
" Constant:
wstr_data-sacha = 'P01'. " Payroll Administrator
wstr_data-sachz = me->model->pardata-sachz. " Administrator for Time Recording
* Example: T01
* SNAME Employee's Name (Sortable by LAST NAME FIRST NAME)
wstr_data-sname = me->model->pardata-nachn && me->model->pardata-vorna.
wstr_data-ename = me->model->pardata-vorna. "Formatted Name of Employee or Applicant
* SBMOD Administrator Group
* KOKRS Controlling Area
* ANSVH Work Contract
* KOSTL Cost Center
*!!!! This gets cleared out below...!!!
wstr_data-kostl = me->model->position->kostl.
* ORGEH Organizational Unit
wstr_data-plans = me->model->pardata-plans. "Position
* Constant:
wstr_data-otype = 'S'. " Object Type
* STELL Job
* SBMOD Administrator Group
* KOKRS Controlling Area
wstr_data-kokrs = me->model->position->kokrs. " Object Type
* Example CITY
* FISTL Funds Center
* GEBER " Fund
* FKBER " Functional Area
* GRANT_NBR " Grant
* SGMNT " Segment for Segmental Reporting
* BUDGET_PD " FM: Budget Period
wstr_data-zzdiv_code = me->model->position->p1008-zzdiv_code.
wstr_data-zzdiv_name = me->model->position->p1008-zzdiv_name." Division Name
*********************************************************************
* FEATURE LOGIC
**********************************************************************
* Feature - VDSK1 Organizational Key
* Example: 10600000497300
* Struture:
* BUKRS
* WERKS
* BTRTL
* PERSG
* PERSK
* MOLGA
**********************************************************************
wstr_structure-bukrs = me->model->pardata-bukrs.
wstr_structure-persg = me->model->pardata-werks.
wstr_structure-btrtl = me->model->pardata-btrtl.
wstr_structure-persg = me->model->pardata-persg.
wstr_structure-persk = me->model->pardata-persk.
wstr_structure-molga = '10'.
wc_feature = 'VDSK1'.
CALL FUNCTION 'HR_FEATURE_BACKFIELD'
EXPORTING
feature = wc_feature " Feature Name
struc_content = wstr_structure " Feature Structure Contents
* kind_of_error = " Desired Reaction to Error
IMPORTING
back = wc_back " Return Value
* CHANGING
* status = " Back Value Status
* EXCEPTIONS
* dummy = 1
* error_operation = 2
* no_backvalue = 3
* feature_not_generated = 4
* invalid_sign_in_funid = 5
* field_in_report_tab_in_pe03 = 6
* others = 7
.
* IF sy-subrc <> 0.
** MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
** WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
* ENDIF.
* Now let's convert the Rule ID to a Creation Rule:
* (This gives us what fields to put together).
SELECT *
FROM t527a
INTO TABLE wtbl_t527a
WHERE rulid = wc_back.
SORT wtbl_t527a BY seqno.
LOOP AT wtbl_t527a ASSIGNING <fs1>.
REPLACE ALL OCCURRENCES OF 'P0001' IN <fs1>-sname WITH 'WSTR_DATA'.
ASSIGN (<fs1>-sname) TO <fs2>.
IF <fs2> IS ASSIGNED.
wstr_data-vdsk1 = wstr_data-vdsk1 && <fs2>.
ENDIF.
ENDLOOP.
* NOTE : Work around
* Currently we are getting error in CSKS validation for this field
* Clearing it out now until determined if needing to fix.
* This field is needed for VDSK1 value but can be deleted after use.
CLEAR wstr_data-kostl.
**********************************************************************
* Call the EMPLOYEE obj setter method...
me->model->employee->set_data( wstr_data ).
ENDMETHOD.
METHOD set_p0002.
DATA wstr_data TYPE p0002.
**********************************************************************
wstr_data-endda = me->model->employee->p0000-endda." End Date
wstr_data-begda = me->model->pardata-gbdat." Start Date
wstr_data-seqnr = '000'.
wstr_data-aedtm = sy-datum. " Changed On
wstr_data-uname = sy-uname." Name of Person Who Changed Object
**********************************************************************
"wstr_data-grpvl = '10'. " Grouping Value for Personnel Assignments
* INITS Initials
wstr_data-nachn = me->model->pardata-nachn. "Last Name
* NAME2 Name at Birth
* NACH2 Second Name
wstr_data-vorna = me->model->pardata-vorna. "First Name
* CNAME " Complete Name
* TITL2 Second Title
* NAMZU Other Title
* VORSW Name Prefix
* VORS2 Second Name Prefix
wstr_data-rufnm = me->model->pardata-rufnm." Nickname
* MIDNM Middle Name
wstr_data-midnm = me->model->pardata-midnm.
* KNZNM Name Format Indicator for Employee in a List
* ANRED Form-of-Address Key
wstr_data-gesch = me->model->pardata-gesch." Gender Key
wstr_data-gbdat = me->model->pardata-gbdat." Date of Birth
* GBLND Country of Birth
* GBDEP State
* GBORT Birthplace
* NATIO Nationality
* NATI2 Second Nationality
* NATI3 Third Nationality
* Constant:
wstr_data-sprsl = 'EN'. "COMMUNICATION LANGUAGE
* KONFE Religious Denomination Key
wstr_data-famst = me->model->pardata-famst." Marital Status Key
* FAMDT Valid From Date of Current Marital Status
* ANZKD Number of Children
* NACON Name Connection
* PERMO Modifier for Personnel Identifier
wstr_data-perid = me->model->pardata-perid." SSN.
* gbpas " Date of Birth According to Passport
* FNAMK First name (Katakana)
* LNAMK Last name (Katakana)
* FNAMR First Name (Romaji)
* LNAMR Last Name (Romaji)
* NABIK Name of Birth (Katakana)
* NABIR Name of Birth (Romaji)
* NICKK Koseki (Katakana)
* NICKR Koseki (Romaji)
wstr_data-gbdat = me->model->pardata-gbdat." Date of Birth
wstr_data-gbjhr = me->model->pardata-gbdat+0(4)." Year of Birth
wstr_data-gbmon = me->model->pardata-gbdat+4(2)." Month of Birth
wstr_data-gbtag = me->model->pardata-gbdat+6(2)." Birth Date (to Month/Year)
wstr_data-nchmc = me->model->pardata-nachn." Last Name (Field for Search Help)
wstr_data-vnamc = me->model->pardata-vorna."First Name (Field for Search Help)
* NAMZ2 "Name Affix for Name at Birth
**********************************************************************
* Call the EMPLOYEE obj setter method...
me->model->employee->set_data( wstr_data ).
ENDMETHOD.
2) class ZCL_PA035_NEW_INFOTYPE_0001 definition
public
inheriting from ZCL_PA035_NEW_INFOTYPE_DEC
final
create public .
public section.
methods BUILDHIREACTION
redefinition .
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
CLASS ZCL_PA035_NEW_INFOTYPE_0001 IMPLEMENTATION.
METHOD buildhireaction.
FIELD-SYMBOLS <fs_pnnnn> TYPE any.
DATA p0001 TYPE p0001.
**********************************************************************
* Always call the Super
**********************************************************************
super->buildhireaction(
EXPORTING
i_model = i_model
CHANGING
ct_prelp = ct_prelp ).
**********************************************************************
* Clean Start
**********************************************************************
CLEAR prelp_str.
**********************************************************************
* PERNR Personnel Number
p0001-infty = '0001'. " Infotype
p0001-subty = i_model->employee->p0001-subty." Subtype
p0001-objps = i_model->employee->p0001-objps." Object Identification
p0001-sprps = i_model->employee->p0001-sprps." Lock Indicator for HR Master Data Record
**********************************************************************
p0001-endda = i_model->employee->p0001-endda.
p0001-begda = i_model->employee->p0001-begda.
p0001-seqnr = i_model->employee->p0001-seqnr.
p0001-aedtm = i_model->employee->p0001-aedtm. " Changed On
p0001-uname = i_model->employee->p0001-uname." Name of Person Who Changed Object
**********************************************************************
* HISTO Historical Record Flag
* ITXEX Text Exists for Infotype
* REFEX Reference Fields Exist (Primary/Secondary Costs)
* ORDEX Confirmation Fields Exist
* ITBLD Infotype Screen Control
* PREAS Reason for Changing Master Data
* FLAG1 Reserved Field/Unused Field
* FLAG2 Reserved Field/Unused Field
* FLAG3 Reserved Field/Unused Field
* FLAG4 Reserved Field/Unused Field
* RESE1 Reserved Field/Unused Field of Length 2
* RESE2 Reserved Field/Unused Field of Length 2
"Grouping Value for Personnel Assignments
"p0001-grpvl = i_model->employee->p0001-grpvl.
**********************************************************************
p0001-bukrs = i_model->employee->p0001-bukrs. "Company Code
p0001-werks = i_model->employee->p0001-werks. "Personnel Area
p0001-persg = i_model->employee->p0001-persg. "Employee Group
p0001-persk = i_model->employee->p0001-persk. "Employee Subgroup
p0001-vdsk1 = i_model->employee->p0001-vdsk1. "Organizational Key
p0001-gsber = i_model->employee->p0001-gsber. "Business Area
p0001-btrtl = i_model->employee->p0001-btrtl. "Personnel Subarea
p0001-juper = i_model->employee->p0001-juper. "Legal Person
p0001-abkrs = i_model->employee->p0001-abkrs. "Payroll Area
p0001-ansvh = i_model->employee->p0001-ansvh." Work Contract
p0001-kostl = i_model->employee->p0001-kostl.
p0001-orgeh = i_model->employee->p0001-orgeh." Organizational Unit
p0001-plans = i_model->employee->p0001-plans." Position
p0001-stell = i_model->employee->p0001-stell." Job
p0001-mstbr = i_model->employee->p0001-mstbr." Supervisor Area
p0001-sacha = i_model->employee->p0001-sacha." Payroll Administrator
p0001-sachp = i_model->employee->p0001-sachp." administrator for hr master data
p0001-sachz = i_model->employee->p0001-sachz." Administrator for Time Recording
p0001-sname = i_model->employee->p0001-sname." Employee's Name (Sortable by LAST NAME FIRST NAME)
p0001-sname = i_model->employee->p0001-sname. "Formatted Name of Employee or Applicant
p0001-ename = i_model->employee->p0001-ename. "Formatted Name of Employee or Applicant
p0001-otype = i_model->employee->p0001-otype." Object Type
p0001-sbmod = i_model->employee->p0001-sbmod." Administrator Group
p0001-kokrs = i_model->employee->p0001-kokrs." Controlling Area
p0001-kokrs = i_model->employee->p0001-kokrs. "
p0001-fistl = i_model->employee->p0001-fistl." Funds Center
p0001-geber = i_model->employee->p0001-geber." " Fund
p0001-fkber = i_model->employee->p0001-fkber. " Functional Area
p0001-grant_nbr = i_model->employee->p0001-grant_nbr." Grant
p0001-sgmnt = i_model->employee->p0001-sgmnt." Segment for Segmental Reporting
p0001-budget_pd = i_model->employee->p0001-budget_pd." FM: Budget Period
p0001-zzdiv_code = i_model->employee->p0001-zzdiv_code. " Division
p0001-zzdiv_name = i_model->employee->p0001-zzdiv_name." Division Name
**********************************************************************
* Configure P0001 for submission.
**********************************************************************
ASSIGN p0001 TO <fs_pnnnn>.
*
CALL METHOD cl_hr_pnnnn_type_cast=>pnnnn_to_prelp
EXPORTING
pnnnn = <fs_pnnnn>
IMPORTING
prelp = prelp_str.
APPEND prelp_str TO ct_prelp.
CLEAR prelp_str.
ENDMETHOD.
ENDCLASS.
3) CLASS zcl_pa035_employee_newhire DEFINITION
PUBLIC
FINAL
CREATE PUBLIC .
PUBLIC SECTION.
INTERFACES zif_pa035_empactionstrategy .
ALIASES doemployeeaction
FOR zif_pa035_empactionstrategy~doemployeeaction .
CONSTANTS cc_done TYPE c VALUE 'X' ##NO_TEXT.
DATA tbl_prelp TYPE prelp_tab .
"! This is a call back function used by the call to
"! FM ZHR_PA035_HIRE_EMPLOYEE.
METHODS return_hire_data
IMPORTING
!p_task TYPE clike .
METHODS constructor .
PROTECTED SECTION.
PRIVATE SECTION.
**********************************************************
* Declarations for parallel processing task.
* Have to use a separate task due to the FM
* HR_PAD_HIRE_EMPLOYEE using the new DCIF and the
* HR_INFOTYPE_OPERATION which used the old ICF. They
* do not play nicely together so you have to separate
* out the calls due to buffer issues.
* See Thread: http://scn.sap.com/thread/1780075
**********************************************************
"! Holds Parameter ID ZPA035_IFTY_SELECT
DATA zpa035_ifty_select TYPE xuvalue .
* Call Back Parameters
DATA tbl_return TYPE hrpad_return_tab .
DATA tbl_key TYPE hrpad_bapipakey_tab .
DATA flg TYPE xfeld .
DATA return_hire TYPE c .
ENDCLASS.
CLASS ZCL_PA035_EMPLOYEE_NEWHIRE IMPLEMENTATION.
METHOD constructor.
* Override for what infotypes to create. Used in troubleshooting
* or special curcumstances. Just get a reference in case we need it.
GET PARAMETER ID 'ZPA035_IFTY_SELECT' FIELD zpa035_ifty_select.
ENDMETHOD.
METHOD return_hire_data.
CLEAR return_hire.
RECEIVE RESULTS FROM FUNCTION 'ZHR_PA035_HIRE_EMPLOYEE'
IMPORTING
e_return_tab = tbl_return " Table with Messages that Occurred
e_bapipakey_tab = tbl_key " Table with Keys for HR Master Data
e_is_ok = flg. " Booking Status ('X' = Successful)
* Simple flag that we have a successful return trip.
return_hire = cc_done.
ENDMETHOD.
METHOD doemployeeaction.
* This is the main method that creates the new employee.
* Lots happening in here.
DATA wobj_decorator_new TYPE REF TO zcl_pa035_hire_infotype.
DATA wobj_decorator_upd TYPE REF TO zcl_pa035_upd_infotype.
DATA wobj_pre_new TYPE REF TO zcl_pa035_hire_infotype.
DATA wobj_pre_upd TYPE REF TO zcl_pa035_upd_infotype.
DATA wstr_bapireturn TYPE bapireturn.
DATA wtbl_bapireturn1 TYPE bapireturn1_tabtype.
DATA wtbl_return TYPE hrpad_return_tab.
DATA wstr_return TYPE hrpad_return.
DATA wtbl_key TYPE hrpad_bapipakey_tab.
DATA wstr_key TYPE bapipakey.
DATA wc_flg TYPE xfeld.
DATA wc_msgv1 TYPE sy-msgv1.
**********************************************************************
* This method functions by completing a few steps:
* 1) Load up the data table for each of the infotypes that need to go
* 2) Call the actual FM to create the employee initially.
* 3) If successfully created, then proceed with building out the
* next infotypes that can only be created after an inintial employee
* is made. This is like step 1 but now to update instead of create.
* It's also different in that the create process is all at once where
* the update runs an FM call for each infotype attempted.
* 4) Run another infotype update to delimit the position.
* 5) Get/Return all the messages collected for display.
**********************************************************************
* Step 1 - Create the Employee. Build as many infotypes as possible
* that do not have any dependencies.
**********************************************************************
* Start Fresh
CLEAR tbl_prelp.
CLEAR return_hire.
i_model->employee->reset_messages( ).
i_model->set_success_flag( space ).
*0000 Run even though empty...
CREATE OBJECT wobj_decorator_new TYPE zcl_pa035_new_infotype_entry.
wobj_pre_new = wobj_decorator_new.
IF ( zpa035_ifty_select IS NOT INITIAL AND
zpa035_ifty_select CS '0001' ) OR
zpa035_ifty_select IS INITIAL.
*0001
CREATE OBJECT wobj_decorator_new TYPE zcl_pa035_new_infotype_0001
EXPORTING
io_decorator = wobj_pre_new.
wobj_pre_new = wobj_decorator_new.
ENDIF.
IF ( zpa035_ifty_select IS NOT INITIAL AND
zpa035_ifty_select CS '0002' ) OR
zpa035_ifty_select IS INITIAL.
*0002
CREATE OBJECT wobj_decorator_new TYPE zcl_pa035_new_infotype_0002
EXPORTING
io_decorator = wobj_pre_new.
wobj_pre_new = wobj_decorator_new.
ENDIF.
IF ( zpa035_ifty_select IS NOT INITIAL AND
zpa035_ifty_select CS '0006' ) OR
zpa035_ifty_select IS INITIAL.
*0006
CREATE OBJECT wobj_decorator_new TYPE zcl_pa035_new_infotype_0006
EXPORTING
io_decorator = wobj_pre_new.
wobj_pre_new = wobj_decorator_new.
ENDIF.
IF ( zpa035_ifty_select IS NOT INITIAL AND
zpa035_ifty_select CS '0007' ) OR
zpa035_ifty_select IS INITIAL.
*0007
CREATE OBJECT wobj_decorator_new TYPE zcl_pa035_new_infotype_0007
EXPORTING
io_decorator = wobj_pre_new.
wobj_pre_new = wobj_decorator_new.
ENDIF.
IF ( zpa035_ifty_select IS NOT INITIAL AND
zpa035_ifty_select CS '0008' ) OR
zpa035_ifty_select IS INITIAL.
*0008
CREATE OBJECT wobj_decorator_new TYPE zcl_pa035_new_infotype_0008
EXPORTING
io_decorator = wobj_pre_new.
wobj_pre_new = wobj_decorator_new.
ENDIF.
IF ( zpa035_ifty_select IS NOT INITIAL AND
zpa035_ifty_select CS '0019' ) OR
zpa035_ifty_select IS INITIAL.
*0019
CREATE OBJECT wobj_decorator_new TYPE zcl_pa035_new_infotype_0019
EXPORTING
io_decorator = wobj_pre_new.
wobj_pre_new = wobj_decorator_new.
ENDIF.
IF ( zpa035_ifty_select IS NOT INITIAL AND
zpa035_ifty_select CS '0009' ) OR
zpa035_ifty_select IS INITIAL.
*0009
CREATE OBJECT wobj_decorator_new TYPE zcl_pa035_new_infotype_0009
EXPORTING
io_decorator = wobj_pre_new.
wobj_pre_new = wobj_decorator_new.
ENDIF.
IF ( zpa035_ifty_select IS NOT INITIAL AND
zpa035_ifty_select CS '0210' ) OR
zpa035_ifty_select IS INITIAL.
*0210
CREATE OBJECT wobj_decorator_new TYPE zcl_pa035_new_infotype_0210
EXPORTING
io_decorator = wobj_pre_new.
wobj_pre_new = wobj_decorator_new.
ENDIF.
IF ( zpa035_ifty_select IS NOT INITIAL AND
zpa035_ifty_select CS '0171' ) OR
zpa035_ifty_select IS INITIAL.
*0171
CREATE OBJECT wobj_decorator_new TYPE zcl_pa035_new_infotype_0171
EXPORTING
io_decorator = wobj_pre_new.
wobj_pre_new = wobj_decorator_new.
ENDIF.
IF ( zpa035_ifty_select IS NOT INITIAL AND
zpa035_ifty_select CS '9900' ) OR
zpa035_ifty_select IS INITIAL.
*9900
CREATE OBJECT wobj_decorator_new TYPE zcl_pa035_new_infotype_9900
EXPORTING
io_decorator = wobj_pre_new.
wobj_pre_new = wobj_decorator_new.
ENDIF.
IF ( zpa035_ifty_select IS NOT INITIAL AND
zpa035_ifty_select CS '0235' ) OR
zpa035_ifty_select IS INITIAL.
*0235
CREATE OBJECT wobj_decorator_new TYPE zcl_pa035_new_infotype_0235
EXPORTING
io_decorator = wobj_pre_new.
wobj_pre_new = wobj_decorator_new.
ENDIF.
IF ( zpa035_ifty_select IS NOT INITIAL AND
zpa035_ifty_select CS '0041' ) OR
zpa035_ifty_select IS INITIAL.
*0041
CREATE OBJECT wobj_decorator_new TYPE zcl_pa035_new_infotype_0041
EXPORTING
io_decorator = wobj_pre_new.
wobj_pre_new = wobj_decorator_new.
ENDIF.
IF ( zpa035_ifty_select IS NOT INITIAL AND
zpa035_ifty_select CS '0207' ) OR
zpa035_ifty_select IS INITIAL.
*0207
CREATE OBJECT wobj_decorator_new TYPE zcl_pa035_new_infotype_0207
EXPORTING
io_decorator = wobj_pre_new.
wobj_pre_new = wobj_decorator_new.
ENDIF.
IF ( zpa035_ifty_select IS NOT INITIAL AND
zpa035_ifty_select CS '0208' ) OR
zpa035_ifty_select IS INITIAL.
*0208
CREATE OBJECT wobj_decorator_new TYPE zcl_pa035_new_infotype_0208
EXPORTING
io_decorator = wobj_pre_new.
wobj_pre_new = wobj_decorator_new.
ENDIF.
IF ( zpa035_ifty_select IS NOT INITIAL AND
zpa035_ifty_select CS '0209' ) OR
zpa035_ifty_select IS INITIAL.
*0209
CREATE OBJECT wobj_decorator_new TYPE zcl_pa035_new_infotype_0209
EXPORTING
io_decorator = wobj_pre_new.
wobj_pre_new = wobj_decorator_new.
ENDIF.
IF ( zpa035_ifty_select IS NOT INITIAL AND
zpa035_ifty_select CS '0128' ) OR
zpa035_ifty_select IS INITIAL.
*0128
CREATE OBJECT wobj_decorator_new TYPE zcl_pa035_new_infotype_0128
EXPORTING
io_decorator = wobj_pre_new.
wobj_pre_new = wobj_decorator_new.
ENDIF.
IF ( zpa035_ifty_select IS NOT INITIAL AND
zpa035_ifty_select CS '0234' ) OR
zpa035_ifty_select IS INITIAL.
*0234
CREATE OBJECT wobj_decorator_new TYPE zcl_pa035_new_infotype_0234
EXPORTING
io_decorator = wobj_pre_new.
wobj_pre_new = wobj_decorator_new.
ENDIF.
IF ( zpa035_ifty_select IS NOT INITIAL AND
zpa035_ifty_select CS '9810' ) OR
zpa035_ifty_select IS INITIAL.
*9810
CREATE OBJECT wobj_decorator_new TYPE zcl_pa035_new_infotype_9810
EXPORTING
io_decorator = wobj_pre_new.
wobj_pre_new = wobj_decorator_new.
ENDIF.
IF ( zpa035_ifty_select IS NOT INITIAL AND
zpa035_ifty_select CS '9820' ) OR
zpa035_ifty_select IS INITIAL.
*9820
CREATE OBJECT wobj_decorator_new TYPE zcl_pa035_new_infotype_9820
EXPORTING
io_decorator = wobj_pre_new.
wobj_pre_new = wobj_decorator_new.
ENDIF.
**********************************************************************
* Ok, let's go do them all...
wobj_decorator_new->buildhireaction(
EXPORTING i_model = i_model
CHANGING ct_prelp = tbl_prelp ).
**********************************************************************
* Step 2 - Create Employee in a separate work process
**********************************************************************
TRY.
* Call is made in separate task due to conflicts with buffering. The
* follow on UPDATE call can't be made in the same context as this
* new hire activity. So, we push the new hire to another work
* processes. Note: There is a call back method used to get back the
* return values.
CALL FUNCTION 'ZHR_PA035_HIRE_EMPLOYEE'
STARTING NEW TASK 'PA035'
DESTINATION 'NONE'
CALLING return_hire_data ON END OF TASK
EXPORTING
* i_employeenumber = " Personnel Number
i_referencepernr = i_model->persno_ref "Personnel Number
i_hiringdate = i_model->startdate " Start Date
i_actiontype = i_model->employee->p0000-massn " Action Type
i_reasonforaction = i_model->employee->p0000-massg " Reason for Action
i_pnnnn_tab = tbl_prelp " Table of Generic Infotypes
* i_pref_tab = " Assignment Values for HR Objects
i_nocommit = i_model->testmode " General Flag
* importing
* e_return_tab = wtbl_return " HR Master Data: Message List
* e_bapipakey_tab = wtbl_key " Table with Keys for HR Master Data
* e_is_ok = wc_flg. " Data element for domain BOOLE: TRUE (='X') and FALSE (=' ')
.
* Need to wait for the separate task to finish before continuing.
* The call back method RETURN_HIRE_DATA will update this flag.
WAIT UNTIL return_hire = cc_done.
CATCH cx_root. "Who knows what could go wrong.
CLEAR wstr_return.
IF 1 = 2. MESSAGE e017(zpa035). ENDIF. "For Where Used Navigation
CALL FUNCTION 'BALW_BAPIRETURN_GET1'
EXPORTING
type = 'E'
cl = 'ZPA035'
number = '017'
par1 = sy-msgv1
par2 = sy-msgv2
par3 = sy-msgv3
par4 = sy-msgv4
IMPORTING
bapireturn = wstr_return-bapireturn1
EXCEPTIONS
OTHERS = 1.
APPEND wstr_return TO wtbl_return.
ENDTRY.
* Get a local reference of the static return variables.
wtbl_return = tbl_return.
wtbl_key = tbl_key.
wc_flg = flg.
* Did we successfully create a new employee?
IF wc_flg = 'X'.
READ TABLE wtbl_key INDEX 1 INTO wstr_key.
wc_msgv1 = wstr_key-employeeno.
IF 1 = 2. MESSAGE s015(zpa035). ENDIF. "Where Used Navigation
CALL FUNCTION 'BALW_BAPIRETURN_GET1'
EXPORTING
type = 'S'
cl = 'ZPA035'
number = '015'
par1 = wc_msgv1
par2 = sy-msgv2
par3 = sy-msgv3
par4 = sy-msgv4
IMPORTING
bapireturn = wstr_return-bapireturn1
EXCEPTIONS
OTHERS = 1.
APPEND wstr_return TO wtbl_return.
* Tell the model that we have a winner!
IF i_model->testmode <> 'X'.
i_model->set_success_flag( 'X' ).
* Populate the model with the new employee no
i_model->employee->persno = wstr_key-employeeno.
ELSE.
* Prep any messages for return...
zcl_pa035_empaction_model=>add_message_1(
IMPORTING
ct_tblin = wtbl_return
CHANGING
ct_tblout = ct_return1
).
ENDIF.
ELSE.
* Prep any messages for return...
zcl_pa035_empaction_model=>add_message_1(
IMPORTING
ct_tblin = wtbl_return
CHANGING
ct_tblout = ct_return1
).
ENDIF.
* Step 1 complete...
* Only go on if successfully created employee and
* were not in test mode.
CHECK i_model->succcess_flag = 'X'.
CHECK i_model->testmode <> 'X'.
**********************************************************************
* Step 3 - Update the Employee. Now that the employee exist we can
* use that information to create/update the final set of
* infotypes.
**********************************************************************
* Run even though empty... this is the entry dummy...
CREATE OBJECT wobj_decorator_upd TYPE zcl_pa035_upd_infotype_entry.
wobj_pre_upd = wobj_decorator_upd.
* Used as a delay for attempting the lock...
DATA(wc_locksuccess) = wobj_decorator_upd->lock_employee(
EXPORTING
i_pernr = i_model->employee->persno
CHANGING
ct_return = wtbl_bapireturn1 ).
IF wc_locksuccess = abap_true.
*0378
IF i_model->employee->p0378 IS NOT INITIAL.
CREATE OBJECT wobj_decorator_upd TYPE zcl_pa035_upd_infotype_0378
EXPORTING
io_decorator = wobj_pre_upd.
wobj_pre_upd = wobj_decorator_upd.
ENDIF.
*2006
IF i_model->employee->p2006 IS NOT INITIAL.
CREATE OBJECT wobj_decorator_upd TYPE zcl_pa035_upd_infotype_2006
EXPORTING
io_decorator = wobj_pre_upd.
wobj_pre_upd = wobj_decorator_upd.
ENDIF.
*0017
IF i_model->employee->p0017 IS NOT INITIAL.
CREATE OBJECT wobj_decorator_upd TYPE zcl_pa035_upd_infotype_0017
EXPORTING
io_decorator = wobj_pre_upd.
wobj_pre_upd = wobj_decorator_upd.
ENDIF.
* Ok, let's go do them all...
wobj_decorator_upd->doupdateaction(
EXPORTING
i_model = i_model
CHANGING
it_return = wtbl_bapireturn1
).
*Release any lock on the employee record...
CALL FUNCTION 'HR_EMPLOYEE_DEQUEUE'
EXPORTING
number = i_model->employee->persno
* IMPORTING
* return =
* locking_user =
.
* Move return messages over to local message type structure.
LOOP AT wtbl_bapireturn1 INTO wstr_return-bapireturn1.
APPEND wstr_return TO wtbl_return.
ENDLOOP.
CLEAR wtbl_bapireturn1.
CLEAR wstr_return.
ELSE.
* Message - Inftypes not created...
CLEAR wstr_return.
IF 1 = 2. MESSAGE s057(zpa035). ENDIF. "Where Used Navigation
wstr_return-type = 'E'.
wstr_return-id = 'ZPA035'.
wstr_return-number = '057'.
APPEND wstr_return TO wtbl_return.
CLEAR wstr_return.
* Message - Action cancelled...
CLEAR wstr_return.
IF 1 = 2. MESSAGE s055(zpa035). ENDIF. "Where Used Navigation
wstr_return-type = 'E'.
wstr_return-id = 'ZPA035'.
wstr_return-number = '055'.
APPEND wstr_return TO wtbl_return.
CLEAR wstr_return.
ENDIF.
**********************************************************************
* Step 4 - Request to created the filled IT1007 on the position. At the
* same time delimit the open IT1007 record (if exists).
**********************************************************************
CALL FUNCTION 'ZPA_PA035_DELIMITVACANCY'
EXPORTING
i_position = i_model->position->position " Position
i_date_of_hire = i_model->startdate " Start Date
TABLES
p_return = wtbl_bapireturn1. " Table BAPIRET1
* Move return messages over to local message type structure.
LOOP AT wtbl_bapireturn1 INTO wstr_return-bapireturn1.
APPEND wstr_return TO wtbl_return.
ENDLOOP.
**********************************************************************
* Step 5 - Report back all the messages accumulated.
**********************************************************************
* Prep any more messages for return...
zcl_pa035_empaction_model=>add_message_1(
IMPORTING
ct_tblin = wtbl_return
CHANGING
ct_tblout = ct_return1
).
ENDMETHOD.
ENDCLASS.
4) FUNCTION ZHR_PA035_HIRE_EMPLOYEE
IMPORTING
VALUE(I_EMPLOYEENUMBER) TYPE PERNR_D OPTIONAL
VALUE(I_REFERENCEPERNR) TYPE PERNR_D OPTIONAL
VALUE(I_HIRINGDATE) TYPE BEGDA
VALUE(I_ACTIONTYPE) TYPE MASSN
VALUE(I_REASONFORACTION) TYPE MASSG OPTIONAL
VALUE(I_PNNNN_TAB) TYPE PRELP_TAB
VALUE(I_PREF_TAB) TYPE PREF_TAB OPTIONAL
VALUE(I_NOCOMMIT) TYPE FLAG DEFAULT 'X'
EXPORTING
VALUE(E_RETURN_TAB) TYPE HRPAD_RETURN_TAB
VALUE(E_BAPIPAKEY_TAB) TYPE HRPAD_BAPIPAKEY_TAB
VALUE(E_IS_OK) TYPE BOOLE_D.
CALL FUNCTION 'HR_PAD_HIRE_EMPLOYEE'
EXPORTING
* employeenumber = " Personnel Number
referencepernr = I_REFERENCEPERNR " Reference Personnel Number
hiringdate = i_hiringdate " Hiring Date
actiontype = i_actiontype " Action Type
reasonforaction = i_reasonforaction " Reason for Action
pnnnn_tab = i_pnnnn_tab " Table of Generic Infotypes
* pref_tab = " Assignment Values for HR Objects
nocommit = i_nocommit " Booking to DB (' ' = Yes, 'X' = No (Test))
IMPORTING
return_tab = e_return_tab " Table with Messages that Occurred
bapipakey_tab = e_bapipakey_tab " Table with Keys for HR Master Data
is_ok = e_is_ok. " Booking Status ('X' = Successful)
ENDFUNCTION.
User | Count |
---|---|
106 | |
14 | |
10 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 | |
2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.