The code was written in R/3 4.6C but should work in any SAP version.
DATA: i_EDIDC like EDIDC, i_EDIDD like EDIDD occurs 0 with header line. CONSTANTS: c_EDIDD(21) value '(SAPLV55K)IDOC_DATA', c_EDIDC(21) value '(SAPLV55K)IDOC_CONTRL', c_E1ADRM1(7) value 'E1ADRM1' c_SHPCON(6) value 'SHPCON'. Field-symbols: <FC>, <FD> . clear: i_EDIDC, i_EDIDD. refresh: i_EDIDD. * Get the Control Record from memory assign (c_EDIDC) to <FC>. if SY-SUBRC = 0. i_EDIDC = <FC>. IF i_EDIDC-MESTYP = c_SHPCON. * None of the partner information can be passed directly from * the IDOC function, so we'll get it from memory. * Get IDOC data records from memory assign (c_EDIDD) to <FD>. i_EDIDD = <FD>. * Now you have the entire IDOC available to you without making * a DB select. read table i_EDIDD with key SEGNAM = c_E1ADRM1. * Load new value HERE... ENDIF. ENDIF.