sapdev logo background
sapdev logo sapdev logo
Comments

Retrieve SAP HR Organisation unit relationship within HRP1001




Here is a diagram detailing the org structure relationship values within table HRP1001. I.e. If you have an org unit and what to now its parent org unit you would look for an '002' relationship(RELAT) of specification(RSIGN) equal to 'A'. If your wanted to know it child org unit you would use the same relationship of '002' but of specification 'B'.


The following ABAP code shows how this information would be used to retireve data within SAP. So if you start with and org unit and want to find its parent you would implement the following SAP code.

ld_orgeh = Current Org Unit, SOBID would then contain the parent Org Unit.

* Get next level up within org structure 
     select relat sobid
          from hrp1001
          into CORRESPONDING FIELDS OF TABLE it_hrp1001
         WHERE otype = 'O'
           AND objid = ld_orgeh
           AND plvar = '01'
           AND RSIGN = 'A'
           AND RELAT = '002'
           AND istat = '1'
           AND begda LE sy-datum
           AND endda GE sy-datum.

The same as if you want to find the child Org Unit it would be the same code and relationship, but working the other way and using the B specification.

ld_orgeh = Current Org Unit, SOBID would then contain the Child Org Unit.

* Get next level down within org structure 
     select relat sobid
          from hrp1001
          into CORRESPONDING FIELDS OF TABLE it_hrp1001
         WHERE otype = 'O'
           AND objid = ld_orgeh
           AND plvar = '01'
           AND RSIGN = 'B'
           AND RELAT = '002'
           AND istat = '1'
           AND begda LE sy-datum
           AND endda GE sy-datum.

>> Add relationship entry to HRP1001 SAP table
>> get oganisation unit text



comments powered by Disqus