Retrieving missing data from user exit functions

Retrieving missing data from user exit functions

Have you been in a user exit function and the data you need wasn't passed on to you? You can easily grab the data from the memory stack using this little trick. Let's say that you need some IDoc information that was created from the function IDOC_INPUT_DELVRY... You can get it directly from the call stack like this.
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.

    Requires Free Membership to View

    When you register, you will start receiving targeted emails from my award-winning team of editorial writers. Our goal is to keep you informed on the hottest topics and biggest challenges faced by SAP professionals today.

    Hannah Smalltree, Editorial Director

    By submitting your registration information to SearchSAP.com you agree to receive email communications from TechTarget and TechTarget partners. We encourage you to read our Privacy Policy which contains important disclosures about how we collect and use your registration and other information. If you reside outside of the United States, by submitting this registration information you consent to having your personal data transferred to and processed in the United States. Your use of SearchSAP.com is governed by our Terms of Use. You may contact us at webmaster@TechTarget.com.

This was first published in November 2003

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.