Posts

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 th...

ABAP read excel(.XLSX) file to internal table in ABAP using CL_FDT_XL_SPREADSHEET

You are given a requirement to upload data to a custom DB table where the user provides you with the file path of the excel on his PC and the report loads the data from it to the Custom table. For experienced Abapers, the requirement is quite straightforward, except that the user wants to upload an XLSX file. There are not many options to read data from XLSX/XLS file. The TEXT_CONVERT_XLS_TO_SAP  function module is one of them but is a performance killer and uses OLE. In this post, I wanted to showcase How we can read data from the XLSX files using CL_FDT_SPOREADSHEET class. Let's start with uploading the file. Now that we have the file in xstring table, let's pass it to CL_FDT_XL_SPREADSHEET to get its object reference. From the object reference, we can retrieve each worksheet data. The data is returned in the form of an anonymous data object which can be dereferenced into a field symbol and passed to the target internal table. Below is the co...

Easily send emails from ABAP using Custom utility class ZCL_SEND_MAIL

in the previous post,s I shared how to use CL_BCS class to send emails . and I also shared how to use cl_bcs_message class to send email in user-exit and BADI . The standard libraries even though useful, are cumbersome to use so I have created a utility that combines the power of both CL_BCS and CL_BCS_MESSAGE to let you send an email with ease from anywhere in the system. Below are examples and source links to the utility class ZCL_SEND_MAIL A simple example: Sending email from user exit/Badi Link to Source:  ZCL_SEND_MAIL As usual, Hope you like the post and use the information in your day to day work.

ABAP convert internal table to excel (.xlsx) format and Send email or download

Reporting is incomplete without file interfacing. Sometimes the requirement is to send a file via email or download it to a PC. but what to do when the user requests the file in XLSX format? In today's post, I am sharing how to convert an internal table to .xlsx format and then send it to a PC or email. One of the quickest ways I found it been done is using SALV classes. Below is the Code snippet Now once you have the xstring with you, simply pass it to relevant libraries to handle the output. Downloading to PC: Sending via Email It's that simple. Hope you like the post and use it in your day to day work.

Send mail with out using commit work with cl_bcs_message class

 In my last post  Send mail using CL_BCS library  We explored the class to achieve mail sending functionalities. The class is a really powerful tool but it has a shortcoming i.e. it needs to commit work . It's not a problem most of the time unless you are working with User-Exit and BADI. In this post, I wanted to showcase the usage of CL_BCS_MESSAGE class. The class only collects data and depending upon how you set the attributes of the class object, function module SBCS_SEND or SBCS_SEND_UPDATE is called. This means we can use this class to send emails from User-exit or BADI. Below is a sample code. Hope You like the snippet and use this information in your day to day work.

Use CL_BCS library to send email with ABAP

Many a time you need a report for which the output needs to be an email. SO_NEW_DOCUMENT_SEND_API1 is heavily used to achieve the task but let's explore another way of achieving the same using CL_BCS. This post talks about how to use the CL_BCS library provided by SAP to easily send emails. CL_BCS Library The class serves as the interface from BCS to the applications. The methods of the class cater for the send functions. Using CL_BCS, You can: – Attach files to email – Build the HTML/raw of the body. – Set email’s Senders & Receiver – Send an email, etc. Let's see the steps one by one: Initiating CL_BCS: The first thing you need is to initiate a persistent send request. Creating BCS Document: Create the BCS document object which will be sent with the CL_BCS interface to BCS. In this case the Email. SET_DOCUMENT Once we have the document, It needs to be set to the send request. SET_SENDER Assign the sender to the send request. ADD_RECIPIENT Pass ...

ABAP Custom code generator dynamic pattern: ZCODEGEN

Image
 In My last post about  ABAP editor custom dynamic patterns . I talked about how to create new custom patterns to help you speed up various aspects of your day to day development. Today I wanted to share with you a Custom dynamic pattern Utility that I built. Here is what it looks like: Starting the pattern: The UI: Features: You can declare:   Types - With auto data declarations(Global/Local)    Data     Selection Screen - with Validation   Basic SQL queries  Setup Config to change prefixes of generated code. Here is an example of generating a simple report to fetch data based on MATNR from MARA . Declare Types: Press the get fields button: Select field and copy: Set data declaration checkboxes Move on to the selection screen tab. Get fields to choose from as a selection screen. Select field and copy and set obligatory and check table. Move to the SQL tab. Select fields for queries either directly or from local declared types, some for wh...

ABAP Editor/Workbench Custom Dynamic Patterns

Image
In my last post ABAP Editor dynamic patterns , We saw how we can use the patterns to our advantage. Today, I wanted to expand upon further features of dynamic patterns, which is the ability to write and add your own dynamic patterns. Let's say you want to define a template for the generation of DB validation code and provide your table name as input. Creating the Pattern. From the ABAP editor, Select Utilities > More Utilities > Edit Pattern > Create Pattern and enter a name for your pattern. Type name for the pattern: You will be presented with a text editor screen, Add the following code: *$&$MUSTER The above code tells the runtime to call a function module with the naming convention: <pattern_name>_editor_exit. > The next obvious step is to create the FM with the above-discussed name. The FM has a defined interface of a TABLES parameter BUFFER of type RSWSOURCET . The table is used to pass back the code to the editor. Insert Below c...