Fetching Data from Memory Stack Using New Tool (in Debugger)

Share on Facebook9Share on LinkedIn61Tweet about this on TwitterShare on Google+0
Please Share!!

Many times we receive a requirement to add validations for standard transactions wherein the field value is not directly accessible in user exit or BADI. So if you are also struggling with such requirement, your wait is over. Prapti is here to your rescue. 😉

In this article, we will be learning a short and simple trick to access screen values in standard transaction code.

Basically, we would exploit the Memory Stack at Run-Time using the New Tool in Debugger. If in any interview, someone asks you, do you know Memory Stack Programming? After going through this article, your answer should be a big confident affirmative. 😛

Following are the steps that need to be followed:

  1. Get the program name and field data from the screen (using F1)
  2. Add a breakpoint in the exit / BADI
  3. Execute the transaction and check the value at runtime using New Tool (Tools -> Special Tool -> Loaded Programs)
  4. Add code in the exit / BADI for fetching data from the screen field

Seeing is Believing. Let me take a very simple real time practical example. While creating a purchase order in SAP, there is a provision to add one-time vendor details. Our requirement is to add a Validation on PINCODE length.

We were using CHECK method of BADI ME_PROCESS_PO_CUST for validation in PO. But found that the address details were not accessible in the BADI.

We followed the 4 steps mentioned above. We found the program name and field data.

Added the debugger and executed the transaction. In the debugger tool, go to New Tool option.

new tool in debugger

Alert: If your debugger takes you to Standard Tab by default, then you would not find the “New Tool“. Do not panic. Just click Desktop 1 or Desktop 2 or Desktop 3 and New Tool would be right there for your service. 🙂

Also ReadA to Z of Integration of SAP Ariba with SAP ECC

Go to Loaded Programs option in Special Tools.

Loaded Program

Select Global Data tab where we will be able to see all the global variables of each program.

New Tool in SAP

Let us now find the program and field for Address data.

Yeah, we got the ADDR1_DATA values. So now we reached the last step – the code :).

Basically, we just dug deep into the memory stack at the run-time and looked for all programs that were loaded in the system for completion of the particular transaction. Using the New Tool, we found the Global Data. Once you have the Global Data, you can just fetch that data in your program using Field Symbol.

Hope you like this trick. This is a simple solution which we need to do in every project. If you are a beginner on SAP ABAP, bookmark this article. You would need this for your first Memory Stack Programming. 😛

You can implement this same trick to fetch any global data like table, structures, variables, objects etc.

Note: There is a limitation. If the variable, work area, table etc are NOT declared as Global on the loaded programs, then we CANNOT retrieve its value using the above method.

Also Check: How to write your first Program in HANA ABAP?

Now I want to hear from you. Do you have any Tip or Trick to share?

Please do not shy away from sharing your knowledge. Together we learn better. Please leave your quick feedback below. Please Like Us on Facebook and Share our Contents.

Share on Facebook9Share on LinkedIn61Tweet about this on TwitterShare on Google+0
Please Share!!

About the Author

Prapti Vyas
Prapti Vyas
Prapti is a senior IT Analyst. She has more than 5 years of experience in SAP ABAP and around 2 years in SAP PI. She is a vivid reader (mostly novels) and a versatile dancer. Dancing is her passion and her favourite past time. Please find more information about Prapti on LinkedIn.

12 Comments on "Fetching Data from Memory Stack Using New Tool (in Debugger)"

  1. Hi,
    Nice post, i am sd consultant i want to learn how to debbug programme or report error
    please post some helpful screens thanks in advance.

    Thanks
    sanchit

  2. A helpful post for beginners. 🙂

  3. Hello Prapti, very useful information to share on New Tool in debugging.
    Want to confirm whether the ASSIGN field symbol logic works if the particular program used in code in not in loaded program list in a some other scenario where the screen is not called at all.

  4. Nice article Prapti. I went through similar article 2 weeks back but you have explained the concept in simple words with good example.

    It will help everybody as we come across this situation many times.

    Regards,
    Anil

  5. Nice article Prapti. 2 weeks back only I came across this topic while reading in detail on field symbol and how it can be used to access unavailable fields in user exit. You made it very clear with good example.

  6. Massimo Olivieri | September 6, 2017 at 8:03 am | Reply

    very nice help, i have found this trick some year age on standard report…..yes some standard report use this trick.
    The same trick can be be use to read but also to write data,but it’s not consigliabile.

Leave a Reply to Massimo Olivieri Cancel reply

Your email address will not be published.


*