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: 

Purchase order IDOC relationship

Clemenss
Active Contributor
0 Kudos

Hi IDOCers,

in ME23N in the object services, I can click the refernce button and it will show me the the IDOC number and type in a small ALV grid.

Question: How can I retrieve the IDOC number for an order and/or vice versa?

TIA,

Clemens

3 REPLIES 3

former_member404244
Active Contributor
0 Kudos

Hi,

In WE02 tcode u can find the order number from the idoc number.generally we will find the idocs in the table edidd,edid4.So we need to give the message type ORDERS .But for a particular order number ,this is the idoc ,probably we may not get...

regards,

Nagaraj

Clemenss
Active Contributor
0 Kudos

... found it:

Involved tables are srrelroles and idocrel. Tables have to be joined back and forth.


* prepare reference table complete
  loop at pt_alv assigning <alv>.
    lv_objkey                             = <alv>-docnum.
* collect object keys
    insert lv_objkey into table lt_objkey.
    at last.
* at least one key - no empty select 4 all entries
      select srrelroles_idoc~objkey srrelroles_ekko~objkey
        into (lv_objkey_docnum, lv_objkey_ebeln)
        from srrelroles as srrelroles_idoc
        join idocrel
          on idocrel~role_a                   = srrelroles_idoc~roleid
        join srrelroles as srrelroles_ekko
          on srrelroles_ekko~roleid           = idocrel~role_b
* just to make sure
        join ekko on ekko~ebeln               = srrelroles_ekko~objkey
        for all entries in lt_objkey
        where srrelroles_idoc~objkey          = lt_objkey-table_line
          and srrelroles_idoc~objtype         = 'IDOC'
          and srrelroles_idoc~roletype        = 'INIDOC'.
        ls_docnum_ebeln-ebeln                 = lv_objkey_ebeln.
        ls_docnum_ebeln-docnum                = lv_objkey_docnum.
        insert ls_docnum_ebeln into table lt_docnum_ebeln.
      endselect.
    endat.
  endloop." at pt_alv assigning <alv>.

Regards,

Clemens

Clemenss
Active Contributor
0 Kudos

answered.