Posts

Showing posts from 2022

Abap predefined function line_index

As part of the ABAP  predefined functions  series, today I wanted to talk about the predefined function  LINE_INDEX . As the name suggests, the function returns the row index of an internal table found using table expressions. Syntax:   result =  line_index ( table_expression). Features : - If the row in question is not found, no exception is raised. The value 0 is returned instead. - Supports table expression chaining as long as the result of the expression is also table-like in     the case of nested tables. - Effectively, a functional replacement of READ TABLE statement followed by sy-tabix check. Notes :  - If a hashed table is specified then the result would be -1.  - If a hash key is specified then the result would be -1.   Example : you might think that it's not that impressive as it's not that hard or frequent to know an index of the row in internal tables till you have to know the index of a deeply nested table. below is an example illu

Abap Predefined function nmax and nmin

As part of the ABAP predefined functions series, today I wanted to talk about numerical Extremum functions: NMIN, and NMAX. These functions return the minimum/maximum values out of the input argument. Syntax: result = nmax|nmin ( val1 = arg1 val2 = arg2....val5 = arg5 ..val9 = arg9 ). Features: - All the input arguments are of type numeric data object/ numeric expressions. - A minimum of two arguments must be passed up to 9. Example: It's elementary to start undermining the function as an extreme of two can be easily calculated with a simple if-else: but what if 3, or 4 or more fields were involved: You can notice how the ifs are increasing but it's a simple method call to NMAX or NMIN to achieve the same. Below is a small ready-to-execute report to calculate the least or highest value of input values of up to 9 variables, As always, I hope this information helps you with your day-to-day work.

ABAP capture result of submitted program using cl_salv_bs_runtime_info

Image
Let's talk about a hypothetical scenario, You are meditating in your fortress of solitude. A wild customer appears virtually/physically.The person shows you a report output and wants you to fetch exact data as the report displays in your current development. Scared , you begin to analyse the code of the report to reuse its logic only to see your fear come out alive i.e. the report has all the logic embedded. Proudly , you suggest refactoring the report, extracting the logic globally, and using it for your objects. Swiftly , your hope helicopter is shot down by the customer's stinger missile of an increase in testing efforts and with support troops of "nearing the deadline" hand a lack of super users to confirm the original report works as intended post refactor. Now, If the above scenario is not so much hypothetical in your experience, you are left with some limited choices. 1. Copy the logic ( Hello dark side) 2. Somehow get

File data conversion made easy using ABAP custom utility class zcl_filedata_convert

In the last post, I talked about how to read XLSX files into an internal table and  convert internal to XLSX files . In this post, I wanted to share a custom utility class that can make tasks of data conversion as simple as a method call. The class is ZCL_FILEDATA_CONVERT. Below are a few of the code snippets showing its capabilities. Let's start with XLSX to the internal table. It automatically handles date and time fields for you. Internal table to XLSX similarly converting data from and to CSV or TSV or special separated file, It handles it all. Here is a link to source : ZCL_FILE_DATA_CONVERT Use it as it is or modify it to suit your needs. As always, hope you like the post and use its information in your day to day work.

SAP application component browser custom tool, Check application component hierarchy of any object

Image
As part of the  custom tools  series, today's post is about a tool that is helpful to both functional and technical counterparts. Have you ever wondered, which table or t-code belonged to which application component in SAP? Recently, I did and thought maybe others want to see that as well. But first, What is an application component? An application component is defined as a modular, deployable, and replaceable part of a software system that encapsulates its behaviour, data and exposes these through a set of interfaces.  In other words, In SAP, all sales and development related functions would be part of the SD application component, similar to other functions such as MM or LO (logistics). Now, coming back to the tool. Here is what the input looks like: You can input the application component name or an object name.  The other input defines what type of objects you want to browse or fetch. Example: I want to know where the MARA table be