Application Development and Automation 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: 
Read only

Creating new position

Former Member
0 Likes
7,827

Hello All,

Is there a function module available that creates a new position in an organization?

I would appreciate your responses.

~Mark

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
6,424

Hi Mark,

Try using F.M. RH_GENERATE_POSITION_AT_ORG

It will create the position with user assigned to it in Org unit which you will pass to this F.M.

Hope this serves the purpose.

Rgeards,

Akshay

P.S. : Pls. reward with points if answer is helpful / solves the problem.

63 REPLIES 63
Read only

0 Likes
2,299

Hi Mark,

this parameter is optional.. you can leave it blank & the system will generate the new position id as per the default number range.

Regards,

Suresh Datti

Read only

0 Likes
2,299

OK. So to use this function I can only create a position if I know who will be assigned to that position? Can't I create an open position with this function module?

~Mark

Read only

0 Likes
2,299

Mark,

hopefully we can close out this thread with the following

piece of code.. except for the Org Unit all the other parameters are optional.. So, you can create open positions under this Org Unit.


report  zicn1.
data: w_posn_new type hrobject-objid.
call function 'RH_GENERATE_POSITION_AT_ORG'
  exporting
    act_orgunit  = '01002336'
    act_begda    = sy-datum
    act_endda    = '99991231'
  importing
    act_position = w_posn_new.
if sy-subrc eq 0.
  write:/ w_posn_new.
endif.

Regards,

Suresh Datti

Read only

0 Likes
2,299

Hi Suresh,

I just tried your code with my Org Unit. I get the following exception:

Exception condition "HOLDER_ALREADY_ASSIGNED" raised.

What does this mean and how can I resolve this?

Thanks for your help.

~Mark

Read only

0 Likes
2,299

Hi Mark,

Did you use the exact same code? or did you pass the ACT_HOLDER parameter also? What version are you on? I ma on 47 ext 2 and have just created three new positions under the same Org Unit without any issue.

Regards,

Suresh Datti

Read only

0 Likes
2,299

Yes, I used the same exact code but with a different Org ID. I am also on 47 (I Think).

~Mark

Read only

0 Likes
2,299

Hi Suresh,

What ABAP support pack are you using?

Regards,

~Mark

Read only

0 Likes
2,299

Hi Mark,

This error will come up only if you pass the ACT_HOLDER parameter and that holder is already assigned to a position. If you are passing only Org Unit, you should not be getting this error. Go into SE37, display this function module and put a break point at the statement 'IF act_holder IS INITIAL' ( line 106 in my system). Now execute the sample code I sent. The debug session will stop at this statement. See if there is a value in it.. I suspect it has your user name on it.. clear that value in debug mode..and press F8.. your new position should be created..

Regards,

Suresh Datti

Read only

0 Likes
2,299

SAP_ABA SAPKA62050

SAP_HR SAPKE47047

EA-HR SAPKGPHB28

Suresh

Read only

0 Likes
2,299

Hi Suresh,

When I execute the function RH_GENERATE_POSITION_AT_ORG

and I leave the ACT_HOLDER field blank, I get the exception, HOLDER_NOT_VALID. So I guess the issue might be with the ABAP Support level that we have because we are on 46 and you are on 50. Do u think that it might be the problem?

Regards,

~Mark

Read only

0 Likes
2,299

Mark,

That error is expected when you try to execute the function module via SE37. May be this parameter is not optional in your patch level.. display the function module .. click on import and see whether the Opt. checkbox is checked for the ACT_HOLDER parameter. If it is not checked, then this function module may not be of use to you.

If you are in the US (I see the flag on your Business Card), you can call me at 561-691-7098.

Regards,

Suresh Datti

Read only

0 Likes
2,299

Well, It is optional as the Opt. is checked. I am not sure what is causing this issue. I am not currently in the US. Should be back by next week.

Thanks for all your help though. May be there is something wrong with the system configuration at our end.

Regards,

~Mark

Read only

0 Likes
2,299

Mark,

Did you try to debug as suggested earlier?

Regards,

Suresh Datti

Read only

0 Likes
2,299

Hi Suresh,

Yes I tried the debug mode and I do see my ID In act_holder. When I delete my ID from there and hit F8 then I get the exception Exception condition "HOLDER_NOT_VALID" raised.

This is just driving me nuts.....:)

Thanks,

~Mark

Read only

0 Likes
2,299

Hi Mark,

This what is happening... if the ACT_HOLDER is explicitly made initial, the function module expects values in the parameters NEW_ORG_STEXT & NEW_ORG_SHORT and throws up the INVALID ACT_HODLER error if they are initial. If we pass these two values, it actually creates a New Org Unit.. which is not what we want.. In the sapmle program even if we are not passing the ACT_HOLDER, by deafult it is set to sy-uname. I guess in the system where you tested this code, you are already assigned to a position and hence getting the error HOLDER_ALREADY_ASSIGNED. Whereas I am not assigned to any position and it works fine for me. Since this is just a prototype, you can pass a dummy Username (a valid User name that is not assigned to any position) as ACT_HOLDER and it should work for you. In real time, you can craete a batch id and use it to call the function module.

hope this helps.

Regards,

Suresh Datti

Message was edited by: Suresh Datti

Read only

0 Likes
2,299

Thanks Suresh for all your help. I will try to see if I can find an alternate way of creating a position Via another function module.

Regards,

~Mark

Read only

0 Likes
2,299

Mark,

Does that mean you are giving up on this function module? Why? All you need now is a dummy User that is not assigned to any position. Have your BASIS folks crete a dummy user. Schedule a background job that runs this Program under that id.


report  zicn1.
data: w_posn_new type hrobject-objid.
call function 'RH_GENERATE_POSITION_AT_ORG'
  exporting
    act_orgunit  = '01002336'
    act_begda    = sy-datum
    act_endda    = '99991231'
  importing
    act_position = w_posn_new.
if sy-subrc eq 0.
  write:/ w_posn_new.
endif.

Regards,

Suresh Datti

P.S. You are right Mark, this function module is of no use to youas it does not create open positions. I think we should go back to the RH_CREATE_POSITIONS and work on the SELECT steement.

Message was edited by: Suresh Datti

Message was edited by: Suresh Datti

Read only

0 Likes
2,299

Hi Suresh,

With RH_CREATE_POSITIONS it pops up a window which asks for Job abbrev and stuff. How can I avoid this popup window to use it in my program?

~Mark

Read only

0 Likes
2,299

Mark,

You probably cannot avoid that pop up.. It may be worth an effort to copy the logic in these functions & create a custom function module to suit your needs. Or may be you can do it using a combination of function calls. It ceratinly does not look like doable with a single function call.

Regards,

Suresh Datti

Read only

0 Likes
2,299

Thanks Suresh,

I will try it out. If you come across cetrain piece of code that does the same thing then please pass it on to me. I would appreciate that.

Thanks for all your help!!!

Regards,

~Mark

Read only

0 Likes
2,299

just couldn't give up Mark.. pl use the following..


report  zinc1.

data: w_objid type hrobjid,
      w_sobid type sobid value '01002533'.

call function 'RH_OBJECT_CREATE'
  exporting
    plvar               = '01'
    otype               = 'S'
    stext               = 'TEST'
    begda               = sy-datum
    endda               = '99991231'
  importing
    objid               = w_objid
  exceptions
    text_required       = 1
    invalid_otype       = 2
    invalid_date        = 3
    error_during_insert = 4
    error_ext_number    = 5
    undefined           = 6
    others              = 7.
if sy-subrc eq 0.
  call function 'RH_RELATION_MAINTAIN'
    exporting
      act_fcode           = 'INSE'
      act_plvar           = '01'
      act_otype           = 'S'
      act_objid           = w_objid
      act_rsign           = 'A'
      act_relat           = '003'
      act_sclas           = 'O'  "Obj Type of Orgn Unit
      act_sobid           = w_sobid
    exceptions
      maintainance_failed = 01.

  if sy-subrc = 0.
* relationship mainatined
    write:/ 'Position:', w_objid, 'was created under Org Unit:', w_sobid.
  else.
* relationship wasn't created.
  endif.
else.
* position not created
endif.

Regards,

Suresh Datti

Read only

0 Likes
2,299

Thanks Suresh,

Yes, it works. I guess I can use the same function RH_RELATION_MAINTAIN to assign employee to positions and jobs to positions as well.

Again thanks a lot for all your help so far.

~Mark

Read only

0 Likes
2,299

Mark,

I am glad it finally worked!!! and yes, you can use RH_RELATION_MAINTAIN to assign employee to positions and jobs.. Please close the thread as the issue has been resolved.

Regards,

Suresh Datti

Read only

Former Member
0 Likes
2,299

hi Use PP01 to create, PP02 to change postions.