Skip to Content

Help in BW Start Routine.

Hi Friends,

Could you please help in below.

I have to derive Parent Nodename based on Parent ID of a Org Unit, and I am writing Start routine based on Attribute DS 0ORGUNIT_ATTR.

Step 1 :

2nd-image.png

types : begin of t_orghier,
hieid type rshieid,
objvers type rsobjvers,
nodeid type rshienodid,
nodename type rsshnodenamestr,
parentid type rsparent,
datefrom type /bi0/oidatefrom,
dateto type /bi0/oidateto,
end of t_orghier.

data : lt_orghier type standard table of t_orghier.
data : ls_orghier type t_orghier.

SELECT HIEID OBJVERS NODEID NODENAME PARENTID DATEFROM DATETO from
/BI0/HORGUNITINTO TABLE t_orghierFOR ALL ENTRIES IN SOURCE_PACKAGE where
NODENAME EQ SOURCE_PACKAGE-orgeh.
OBJVERS EQ 'A'.
DATETO GE Sy-datum.
DATEFROM LE Sy-datum.

Could you please help how to read Internal table and get the Parent Id

Thanks

Sri

1st.png (30.6 kB)
2nd-image.png (22.6 kB)
3rd-image.png (10.8 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Mar 13, 2017 at 05:22 PM

    Hello Sri,

    You have come this far, I am sure if you look at a few more discussions about internal tables, you will be able to complete the code without any help :)

    You will have to do a second select from /BI0/HORGUNIT where NODEID = t_orghier-parentid and append the result to t_orghier table. This way you will have the orgunit and it's parne tdetails in one table.

    Now you can loop at SOURCE_PACKAGE or do this in your field routine

    read t_orghier into ls_orghier1 where NODENAME = SOURCE_PACKAGE-orgeh

    var_parent = ls_orghier1-PARENTID

    read t_orghier into ls_orghier2 where NODEID = var_parent

    result = ls_orghier2-NODENAME

    Endloop

    I have just given you the pseudo code, please go through more discussions on internal table and how to effectively use them(Binary search etc).

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Mar 13, 2017 at 02:36 PM

    check this option, download into a flatfile...thereafter you might load the flattened hierarchy into whatever you need:

    https://archive.sap.com/kmuuid2/0403a990-0201-0010-38b3-e1fc442848cb/How%20to%20Download%20a%20Hierarchy%20to%20a%20Flat%20File%20(NW2004).pdf

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Thomas,

      Thanks for reply, my requirement is to add attribute of Parent Org ( one level Up) Unit in 0ORGUNIT..

      Best regards

      Sri

  • Mar 14, 2017 at 11:34 AM

    Hi Benedict Venmani Felix,

    Thanks a lot for the reply,

    I have coded as below in End Routine, Small issue in Length I am getting following message

    E:When you use the addition "FOR ALL ENTRIES IN itab", the fields NODENAME" and "RESULT_PACKAGE-ORGUNIT" must have the same type and the Same length.

    But I am using standard tables elements and datatypes where NODENAME is SSTRING length 1333 where as ORGUNIT is datatype of CHAR length 8.

    below fine below my code.

    Thanks a lot for looking into below

    Declarion :

     types : begin of t_orghier,
     hieid type rshieid,
     objvers type rsobjvers,
     nodeid type rshienodid,
     nodename type rsshnodenamestr,
     parentid type rsparent,
     datefrom type /bi0/oidatefrom,
     dateto type /bi0/oidateto,
     end of t_orghier.
     data : lt_orghier type standard table of t_orghier.
     data : lt_orghier_main type standard table of t_orghier.
     data : ls_orghier1 type t_orghier.
     data : ls_orghier2 type t_orghier.

    Code :

    select hieid objvers nodeid nodename parentid datefrom dateto from/bi0/horgunit
     into table lt_orghier
     for all entries in result_package where
     nodename eq result_package-orgunit .
     objvers eq 'A'.
     dateto ge sy-datum.
     datefrom le sy-datum.
     sort lt_orghier by dateto ascending.
    lt_orghier[] = lt_orghier_main[].
     loop at result_package assigning <result_fields>.
     clear ls_orghier1.
     clear ls_orghier2.
     read table lt_orghier into ls_orghier1 with key
     nodename = <result_fields>-orgunit.
     read table lt_orghier into ls_orghier2 with key
     nodeid = <ls_orghier1>-parentid.
    if sy-subrc = 0.
    <result_fields>-/bic/zorgprnt = <ls_orghier2>-nodename.
    endif.
    endloop.
    
    
    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 04, 2017 at 10:33 AM

    Hi

    In the result package you will have one structure " _ty_s_tg_1"

    Take data type of orgunit from this structure and declare nodename with this data type/

    Also note there is no need to write 2 read statements as you have done...use only 1 read statement and also dont forget to use Binary search after that just before sy-subrc check

    Add comment
    10|10000 characters needed characters exceeded