Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Programmatically create a relationship between two positions in HR

Former Member
0 Kudos

Hi,

I have a requirement to create relationships in HRP1001 between two given positions with a start and end date.

I need to write an upload program to do this but want to avoid Batch Input if possible.

Are there any relevant function modules that can do what transaction PP01 does?

Many Thanks

David

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Try using this code

LOOP AT T_MAINTAIN INTO WA_MAINTAIN.

WA_MAINTAIN-FCODE = 'INSE'.

WA_MAINTAIN-PLVAR = '01'.

WA_MAINTAIN-ISTAT = '1'.

*Relate account to project

IF WA_MAINTAIN-OTYPE = 'O' AND WA_MAINTAIN-SCLAS = 'O'.

WA_MAINTAIN-RSIGN = 'B'.

WA_MAINTAIN-RELAT = '002'.

*Relate position to project

ELSEIF WA_MAINTAIN-OTYPE = 'O' AND WA_MAINTAIN-SCLAS = 'S'.

WA_MAINTAIN-RSIGN = 'B'.

WA_MAINTAIN-RELAT = '003'.

*Relate job to position

ELSEIF WA_MAINTAIN-OTYPE = 'S' AND WA_MAINTAIN-SCLAS = 'C'.

WA_MAINTAIN-RSIGN = 'B'.

WA_MAINTAIN-RELAT = '007'.

*Relate employee to position

ELSEIF WA_MAINTAIN-OTYPE = 'S' AND WA_MAINTAIN-SCLAS = 'P'.

WA_MAINTAIN-RSIGN = 'A'.

WA_MAINTAIN-RELAT = '008'.

ENDIF.

*Relate position to position

ELSEIF WA_MAINTAIN-OTYPE = 'S' AND WA_MAINTAIN-SCLAS = 'S'.

WA_MAINTAIN-RSIGN = 'A'.

WA_MAINTAIN-RELAT = '002'.

ENDIF.

WA_MAINTAIN-ENDDA = '99991231'.

*FM to create relationship

CALL FUNCTION 'RH_RELATION_MAINTAIN'

EXPORTING

ACT_FCODE = WA_MAINTAIN-FCODE

ACT_PLVAR = WA_MAINTAIN-PLVAR

ACT_OTYPE = WA_MAINTAIN-OTYPE

ACT_OBJID = WA_MAINTAIN-OBJID

ACT_ISTAT = WA_MAINTAIN-ISTAT

ACT_RSIGN = WA_MAINTAIN-RSIGN

ACT_RELAT = WA_MAINTAIN-RELAT

ACT_SCLAS = WA_MAINTAIN-SCLAS

ACT_SOBID = WA_MAINTAIN-SOBID

ACT_BEGDA = WA_MAINTAIN-BEGDA

ACT_ENDDA = WA_MAINTAIN-ENDDA

ACT_PROZT = WA_MAINTAIN-PROZT

EXCEPTIONS

MAINTAINANCE_FAILED = 1

OTHERS = 2.

IF SY-SUBRC <> 0.

  • WRITE : WA_INPUT-OBJID.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDLOOP.

9 REPLIES 9

Former Member
0 Kudos

HI,

Please try Fm RH_RELATION_MAINTAIN.

Regards

Sumit Agarwal

Former Member
0 Kudos

Hi,

I hope the below link will help you.

Thanks,

Khushboo.

Former Member
0 Kudos

Hi,

Try using this code

LOOP AT T_MAINTAIN INTO WA_MAINTAIN.

WA_MAINTAIN-FCODE = 'INSE'.

WA_MAINTAIN-PLVAR = '01'.

WA_MAINTAIN-ISTAT = '1'.

*Relate account to project

IF WA_MAINTAIN-OTYPE = 'O' AND WA_MAINTAIN-SCLAS = 'O'.

WA_MAINTAIN-RSIGN = 'B'.

WA_MAINTAIN-RELAT = '002'.

*Relate position to project

ELSEIF WA_MAINTAIN-OTYPE = 'O' AND WA_MAINTAIN-SCLAS = 'S'.

WA_MAINTAIN-RSIGN = 'B'.

WA_MAINTAIN-RELAT = '003'.

*Relate job to position

ELSEIF WA_MAINTAIN-OTYPE = 'S' AND WA_MAINTAIN-SCLAS = 'C'.

WA_MAINTAIN-RSIGN = 'B'.

WA_MAINTAIN-RELAT = '007'.

*Relate employee to position

ELSEIF WA_MAINTAIN-OTYPE = 'S' AND WA_MAINTAIN-SCLAS = 'P'.

WA_MAINTAIN-RSIGN = 'A'.

WA_MAINTAIN-RELAT = '008'.

ENDIF.

*Relate position to position

ELSEIF WA_MAINTAIN-OTYPE = 'S' AND WA_MAINTAIN-SCLAS = 'S'.

WA_MAINTAIN-RSIGN = 'A'.

WA_MAINTAIN-RELAT = '002'.

ENDIF.

WA_MAINTAIN-ENDDA = '99991231'.

*FM to create relationship

CALL FUNCTION 'RH_RELATION_MAINTAIN'

EXPORTING

ACT_FCODE = WA_MAINTAIN-FCODE

ACT_PLVAR = WA_MAINTAIN-PLVAR

ACT_OTYPE = WA_MAINTAIN-OTYPE

ACT_OBJID = WA_MAINTAIN-OBJID

ACT_ISTAT = WA_MAINTAIN-ISTAT

ACT_RSIGN = WA_MAINTAIN-RSIGN

ACT_RELAT = WA_MAINTAIN-RELAT

ACT_SCLAS = WA_MAINTAIN-SCLAS

ACT_SOBID = WA_MAINTAIN-SOBID

ACT_BEGDA = WA_MAINTAIN-BEGDA

ACT_ENDDA = WA_MAINTAIN-ENDDA

ACT_PROZT = WA_MAINTAIN-PROZT

EXCEPTIONS

MAINTAINANCE_FAILED = 1

OTHERS = 2.

IF SY-SUBRC <> 0.

  • WRITE : WA_INPUT-OBJID.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDLOOP.

0 Kudos

Thyagu,

This is really useful.

Does this FM allow you to run it in test mode so errors can be detected before calling it for real.

I cannot see any parameters that allow me to do that.

I've found FM RH_INSERT_INFTY which seems to allow me to do this but I get an error when calling it.

"Error during insert"

Regards

David

0 Kudos

David,

There is no option for any test mode kind of thing in this FM.....all the validations kind of thing must be done before using this FM in the report....this FM internally performs an BDC....

These are the errors u usuall get,

1.invalid date(date format),

2.wrong data(objid,relationship,relat,rsign),

3 Costcenter mismatch,

When assigning employee to position these validations must be done...

4.employee too far into past(this happens due to difference in payroll control period and employee control period),

5.PA lock,

6.ESS lock.

7.Payroll lock.

Here,

2 and 3 can be changed while we execute,

4 can be changed by changing the date,

5 & 6 should be validated in our report.

0 Kudos

Thyagu,

Are there any function modules that can be used for performing validations on the proposed relationships before calling RH_RELATION_MAINTAIN?

I have tried FM RH_INSERT_INFTY. This FM allows the setting of a test mode but this doesn't seem to work and actually creates the relationships regardless of any master data existing whereas RH_RELATION_MAINTAIN does at least throw an error is a position does not exist.

Many Thanks

David

0 Kudos

David,

I think there is no FM for performing validations....u can just test whether an position exist or not...in FM RH_SELECT_OBJECTS_FOR_OTYPE...through which u can test existence of an object.....there is no FM for testing relationship....

As i said before...all the validations can be done before getting into that FM....RH_RELATION_MAINTAIN....

RH_RELATION_MAINTAIN internally performs an BDC of t-code 'PP01'...in proceesing mode 'A'(display of screens)...hence u can change while executing it.....

Regards,

Thyagu.N

0 Kudos

Thanks Thyagu.

Former Member
0 Kudos

use RH_OM_PP01_INFTY_CHECK function module