Some handy ABAP tricks
I am sharing some very useful ABAP tricks which I came across. Again, these might not be new for some people but still some of us are not aware of it.
“Somewhere, something incredible is waiting to be known” 🙂
Un-typed Field symbols
While dealing with un-typed field symbols of type ANY or ANY TABLE without any structure, I have seen most of people moving the data from the field symbols to an internal table and then the data manipulations are done on internal table.
While I came across a simple method of using field symbol while sorting and reading the data. We can specify the field name inside (‘Field name’). Doing this we can avoid the intermediate internal table and instead directly operate on the field symbol.
Similarly, we can use it for READ also.
Find the Enhancement name from the user-exit function module name.
While activating a customer exit, we need to have the SAP enhancement name to activate in CMOD. Now, it might be difficult to find out the SAP enhancement name from the function module name from the package name (traditional approach). A package name might have 100 or more exits enhancements and it might become herculean task. 😕
SAP has provided a table MODSAP wherein we can give the function module name and it will return the enhancement name. Then we can directly use the enhancement name to activate the exit.
Change status of any IDoc.
We can’t reprocess any successful idoc with 53 status. Now either way is we create a new idoc through WE19 and test again but that will generate a new idoc number or there might be a another scenario where few idocs are stuck in inbound queue. We can directly change the status of idocs in such cases and the successful idocs can be reprocessed again.
For that execute a report RC1_IDOC_SET_STATUS, provide the idoc number, old idoc status and new idoc status. There is also a test mode available to check if the new idoc status is possible.
Insert custom values in standard domains fixed values.
In the menu bar navigate to Goto > Fixed Value Append
Provide the append name and the specify the fields.
Performance tip while using FOR ALL ENTRIES when the data becomes large
While I was doing the performance analysis of a code in SAT tool, I noticed a strange thing while using FOR ALL ENTRIES. When the data in the FOR ALL ENTRIES tables becomes huge close to 100 thousand or more, in such cases it is better to fetch the whole data of the table instead of using FOR ALL ENTRIES. I notices a significant change in the above case.
But I must say this is not a conclusion but a subjective observation and it might be helpful in some cases.