Tuesday, February 18, 2020

ABAP Loop Types and Control statements

ABAP programming language provides the following types of loop to handle looping requirements.
S.No.Loop Type & Description
1WHILE loop
Repeats a statement or group of statements when a given condition is true. It tests the condition before executing the loop body.
2Do loop
The DO statement is useful for repeating particular task a specific number of times.
3Nested loop
You may use one or more loops inside any another WHILE or DO loop.

Loop Control Statements

Loop control statements change execution from its normal sequence. ABAP includes control statements that allow loops to be ended prematurely. It supports the following control statements.
S.No.Control Statement & Description
1CONTINUE
Causes the loop to skip the remainder of its body and starts the next loop pass.
2CHECK
If the condition is false, then the remaining statements after the CHECK are just ignored and the system starts the next loop pass.
3EXIT
Terminates the loop entirely and transfers execution to the statement immediately following the loop.

How to lock / save your data objects from multiple user access at a time

Lock Object is a feature offered by ABAP Dictionary that is used to synchronize access to the same data by more than one program. Data records are accessed with the help of specific programs. Lock objects are used in SAP to avoid the inconsistency when data is inserted into or changed in the database. Tables whose data records are to be locked must be defined in a Lock Object, along with their key fields.

Lock Mechanism

Following are the two main functions accomplished with the lock mechanism −
  • A program can communicate with other programs about data records that it is just reading or changing.
  • A program can prevent itself from reading data that has just been changed by another program.
lock request is first generated by the program. Then this request goes to the Enqueue server and the lock is created in the lock table. The Enqueue server sets the lock and the program is finally ready to access data.
Lock Request

Creating Lock Objects

Step 1 − Go to transaction SE11. The following screen opens.
Creating Lock Objects
Step 2 − Click ‘Lock Object’ radio button. Enter the name of lock object starting with E and click the Create button. Here we use EZLOCK12.
Step 3 − Enter the short description field and click on Tables tab.
Step 4 − Enter the table name in Name field and select the lock mode as Write Lock.
Step 5 − Click on Lock parameter tab, the following screen will appear.
Lock Parameter Tab
Step 6 − Save and activate. Automatically 2 function modules will generate. To check function modules, we can use Go to → Lock Modules.
Step 7 − Click Lock Modules and the following screen will open.
Lock Function Modules
The lock object is created successfully.
The key fields of a table included in a Lock Object are called lock arguments and they are used as input parameters in function modules. These arguments are used to set and remove the locks generated by the Lock Object definition.

Sunday, April 16, 2017

Forget SE16/SE16N, Try New - SE16H!

Thanks to SAP and the team to enhancing the product and providing the newbies.

The new transaction SE16H comes with new features which enables rapid tables check and small queries.

Generally, SAP Functional Consultants require transactions code like SE16 / SE16N / SQVI to check table’s value and to extract data.

SAP is now available with new transaction code SE16H which enables:
  • Tables check (consult and extract) like a classical SE16 or SE16N
  • Joint creation for small query
  • Rapid check of number of entries 

Here are two cases where this new features are explained

1- Query for entries for Accounting document 


This scenario is when we want to check entries for complete accounting document. We can query many finance tables but for this example we are using only two tables:
  • BKPF: Header data of accounting segment
  • BSEG: Accounting document segment
Launch SE16H with BSEG and create a join



Enter the criteria for your join

As described below, to have a complete finance document information, we will add the table BKPF as a join. Then, we will click on the yellow arrow to add the fields we want to add to the output.

As it is shown in this figure, we can apply filters on the fields we need. For example, we have put filter on fiscal year, company code and posting month. For these filters, we put a constant value but SE16H offers also other methods as displayed below.

After executing SE16H with the joint we have created, our financial data is displayed as below.

Please note that a layout have been used for the displayed result


2- Checking of number of entries - Group feature



Suppose, we want to have a quick view of the number of accounting entries by company code, we can  tick the field group as indicated below and execute.


Group and sort feature
Here, we want to have a quick view of number of document type used in the system for a single company code as shown below:


For more information on SE16H, please refer SAP Note : 1636416.

About Blog & Author

Hi Friends,

This is Nikhil and I am having 10 years of experience with SAP ABAP and worked across multiple verticals and industries.

Personally, I like to read and write many things and thus thought to start and share the ideas in my own blog with the community in the world of SAP.

The purpose of this blog is solely to share knowledge among the peers and help each others with more and more ideas and ways of doing same things in new manner or discovering new things which are upcoming in the market.

So Guys, Stay Connected!!

You can reach me via the blog.

Thanks,
Nikhil