Skip to content
Nov 12 16

Running ABAP Traces in the New Debugger

by admin
Recommend This Post! Tweet about this on TwitterShare on FacebookShare on LinkedInShare on Google+Pin on Pinterest

ABAPAnthony Cecchini is the President of Information Technology Partners (ITP), an SAP consulting company headquartered in Pennsylvania. ITP offers comprehensive planning, resource allocation, implementation, upgrade, and training assistance to companies. Anthony has over 20 years of experience in SAP business process analysis and SAP systems integration. His areas of expertise include SAP NetWeaver integration; ALE development; RFC, BAPI, IDoc, Dialog, and Web Dynpro development; and customized Workflow development. You can reach him at ajcecchini@itpsap.com.

Running Traces in the ABAP Debugger

I was recently on a Skype learning session at a client where the topic was “Advanced Debugging Techniques”. The developer delivering the live training was showing examples of using Debugger Scripting. For those that need a refresher on what that is, check out our blog post, Fast, and Easy SAP ABAP Debugger Scripting.

While explaining how to execute a statement trace for an SAP ABAP Program using the delivered script “RSTPDA_SCRIPT_STATEMENT_TRACE”, one of our new ABAP developers asked if there was a way to trace SQL, similar to running ST05. And this Blog post was born…

The Answer is a resounding YES! Not only can you trace SQL, but you can trace buffers, RFC’s, Enqueues, and the Classic SE30 ABAP Trace.

Lets run an example using the ST05 Performace trace. If you need a refresher on what this trace is, and how to interpret it take a look at our blog post ABAP Database SQL Analysis Using The Performance Trace parts one and two. Please note you also require ECC SAP_ABA release 702.

Running ST05 in the ABAP Debugger

First, we need to be debugging something with SQL. So for this blog post I am going to use a liitle program ztony_demo_traces. Here is the code below:

REPORT ztony_demo_traces.

TABLES: vbak.

SELECT *
FROM vbak
INTO vbak.
ENDSELECT.

BREAK-POINT.

SELECT SINGLE *
FROM vbak
INTO vbak
WHERE vbeln = '0000004969'.

BREAK-POINT.

OK, let’s put a BREAK_POINT on the first select and run the program. The debugger should pop up and land you in the Standard Tab.

read more…

Recommend This Post! Tweet about this on TwitterShare on FacebookShare on LinkedInShare on Google+Pin on Pinterest
Oct 25 16

New Features in ABAP 7.4 – Enhanced Search Helps

by admin
Recommend This Post! Tweet about this on TwitterShare on FacebookShare on LinkedInShare on Google+Pin on Pinterest

ABAPAnthony Cecchini is the President of Information Technology Partners (ITP), an SAP consulting company headquartered in Pennsylvania. ITP offers comprehensive planning, resource allocation, implementation, upgrade, and training assistance to companies. Anthony has over 20 years of experience in SAP business process analysis and SAP systems integration. His areas of expertise include SAP NetWeaver integration; ALE development; RFC, BAPI, IDoc, Dialog, and Web Dynpro development; and customized Workflow development. You can reach him at ajcecchini@itpsap.com.

Search Helps in ABAP 7.4

At some point in your ABAP career, you probably will develop a search help for a screen field to aid the user in entering correct data. In the “Classic” days (Everything old in SAP is Classic) these were called Match Codes.This blog post is not a tutorial on how to create a search help, please see the SAP ABAP 7.4 help for that. Instead, I am going to introduce you to some new functionality that became available in ABAP 7.4.

First, let’s quickly review what a search help is…

A Search Help, a repository object of ABAP Dictionary, is used to display all the possible values for a field in the form of a list. This list is also known as a hit list. You can select the values that are to be entered in the fields from this hit list instead of manually entering the value, which is tedious and error prone.

There are several types of Search helps:
Elementary search helps: This type implements a search path for determining the possible entries.
Collective search helps: This type contains several elementary search helps. A collective search help, therefore, provides several alternative search paths for possible entries.
Append search helps: This type can be used to enhance collective search helps delivered by SAP with customer-specific search paths without requiring a modification.

An example of an elementary search help is shown below. You will see the Search Help Icon icon next to the field. You enter a pattern and hit this icon or F4 and the hit list is displayed for you to choose from. (see below).

 Search help Screen
Search Help Hit List
So you want to find a book on ABAP, so you head over to your favorite browser and using Google start typing in ABAP and instantly you see search results. (see below)
google
What if this “type ahead” (Predictive) or “search engine like” functionality could be used in our ABAP 7.4 Search helps?

read more…

Recommend This Post! Tweet about this on TwitterShare on FacebookShare on LinkedInShare on Google+Pin on Pinterest
Sep 19 16

New Features in ABAP 7.4 – Internal Tables

by admin
Recommend This Post! Tweet about this on TwitterShare on FacebookShare on LinkedInShare on Google+Pin on Pinterest

ABAPAnthony Cecchini is the President of Information Technology Partners (ITP), an SAP consulting company headquartered in Pennsylvania. ITP offers comprehensive planning, resource allocation, implementation, upgrade, and training assistance to companies. Anthony has over 20 years of experience in SAP business process analysis and SAP systems integration. His areas of expertise include SAP NetWeaver integration; ALE development; RFC, BAPI, IDoc, Dialog, and Web Dynpro development; and customized Workflow development. You can reach him at ajcecchini@itpsap.com.

Internal Tables in ABAP 7.4

Internal tables are a core staple of programming in ABAP. In this blog, you’ll learn about some new ABAP code constructs that relate to internal tables introduced in ABAP 7.2 and ABAP 7.4.

Using Secondary Keys to Access Internal Tables in ABAP 7.4

All of us who have been developing in ABAP at one time or another have created a custom index on a database table. Why do we create a custom index or z-index? For performance… we recognize that a table could be queried in more ways then just by the primary key, so we setup customer indexes that we believe will be used by the Database Optimizer when determining the access path and thus make the query performant.

OK, back to internal tables, traditionally, if you wanted to read an internal table in two different ways (e.g.,looking for a material by Material Number or by Reference Number), then you either had to keep sorting the table just before a read, or have two identical tables sorted differently. Well now as of ABAP 7.2 can declare secondary keys for internal tables. The SAP Help states that using the secondary key could increases read access performance significantly. But, on the other hand, secondary keys also incur additional administration costs due to memory consumption and run-time.

For example, lets create a secondary index into the internal table IT_MARA for the column BISMT , this is just like having a secondary Z- index on BISMT in the database table definition. The internal table definition could be as shown below.
DATA: IT_MARA TYPE HASHED TABLE OF mara 
              WITH UNIQUE KEY matnr 
              WITH NON-UNIQUE SORTED KEY sort_key COMPONENTS bismt.

The SAP Help states that statements that previously only accessed the primary key have been enhanced so that access to secondary keys is now possible. Check out the help for a full list, but we will look at the READ TABLE statement here.

The code would look something like the below…

READ TABLE it_mara INTO wa_mara WITH KEY sort_key COMPONENTS bismt = lv_bismt.

Even though IT_MARA is a HASHED table, it is also a SORTED table with the key BISMT, so when we go looking for the record using BISMT a BINARY SEARCH is automatically performed.

 

Declaring Table Work Areas in ABAP 7.4

In release ABAP 7.4, the syntax for reading into a work area and looping through a table can now leverage INLINE DECLARATIONS, we discussed these in a prior ABAP 7.4 blog.

We learned that from 7.4 onward you no longer need to do a DATA declaration for elementary data types. It is exactly the same for the work areas, which are of course structures. Take a gander at the code below…

READ TABLE lt_mara WITH KEY matnr = lv_matnr INTO DATA(ls_mara).
LOOP AT lt_mara INTO DATA(ls_mara).

In the same way that you no longer need DATA declarations for table work areas, you also no longer need FIELD-SYMBOL declarations for the (common) situations in which you want to change the data in the work area while looping through an internal table. In ABAP 7.4, if you want to use field symbols for the work area, then the syntax is shown below…

READ TABLE lt_mara WITH KEY matnr = lv_matnr ASSIGNING FIELD-SYMBOL().
LOOP AT lt_mara ASSIGNING FIELD-SYMBOL().

Table Expressions in ABAP 7.4

What if I told you that you would never have to use the statement READ TABLE again to get a line out of an internal table?

read more…

Recommend This Post! Tweet about this on TwitterShare on FacebookShare on LinkedInShare on Google+Pin on Pinterest
Aug 14 16

New Features in ABAP 7.4 – Conditional Logic

by admin
Recommend This Post! Tweet about this on TwitterShare on FacebookShare on LinkedInShare on Google+Pin on Pinterest

ABAPAnthony Cecchini is the President of Information Technology Partners (ITP), an SAP consulting company headquartered in Pennsylvania. ITP offers comprehensive planning, resource allocation, implementation, upgrade, and training assistance to companies. Anthony has over 20 years of experience in SAP business process analysis and SAP systems integration. His areas of expertise include SAP NetWeaver integration; ALE development; RFC, BAPI, IDoc, Dialog, and Web Dynpro development; and customized Workflow development. You can reach him at ajcecchini@itpsap.com.

Conditional Logic in ABAP 7.4

The continuing theme in all of these posts, is how we can make our code thinner, more readable and transparent. Well, nothing clogs up the visual readability of your code like long IF-THEN-ELSE-ENDIF or CASE-WHEN-ENDCASE constructs. Well, in ABAP 7.4 we have some new Constructor Operators we can use in Constructor Expressions that will make our code easier to read, more compact, and safer to maintain.

You remember Constructor Operators… We discussed them in the last blog post New Features in ABAP 7.4 – Calling Methods and Functions. In That post we highlighted the CONV Constructor Operator and how we could use it to convert a local variable to a STRING. In this post, I’d like to talk about the Constructor Operators COND and SWITCH. Again, for a complete list see the SAP ABAP 7.4 help for more information.

Using COND as a Replacement for IF/ELSE in ABAP 7.4

Since CASE statements can only evaluate one variable at a time, we use the IF/ELSE construct when we need to check multiple conditions. Look at the example below…

DATA: lv_text(30).

IF lv_vehicle = '01' AND lv_type = 'C'.
    lv_text = 'Toyota'.
ELSE.
IF lv_vehicle ='02' AND lv_type = 'C'.
   lv_text = 'Chevy'
ELSE.
IF lv_vehicle ='03' AND lv_type = 'C'.
   lv_text = 'Range Rover'.

  ..
ENDIF.

In ABAP 7.4, you can achieve the same thing, but you can do this in a more economical way by using the COND constructor operator. This also means that you do not have to keep specifying the target variable again and again. We will also add an ABAP INLINE Declaration… by using the DATA statement to create the variable lv_text inline on the fly!

DATA(lv_text) = COND text30(
     WHEN lv_vehicle ='01' AND lv_type = 'C' THEN 'Toyota'
     WHEN lv_vehicle ='02' AND lv_type = 'C' THEN 'Chevy'
     WHEN lv_vehicle ='03' AND lv_type = 'C' THEN 'Range Rover').

Using SWITCH a Replacement for CASE in ABAP 7.4

Here, we’re getting the day of the week and using a CASE statement to turn the number into a string, such as “Monday”, to output at the top of a report.

data: l_indicator like scal-indicator,
      l_day(10) type c.

call function 'DATE_COMPUTE_DAY'
    exporting
        date = p_date
    importing
        day = l_indicator.
      
case l_indicator.
    when 1.
      l_day = 'Monday'.
    when 2.
      l_day = 'Tuesday'.
    when 3.
      l_day = 'Wednesday'.
    when 4.
      l_day = 'Thursday'.
    when 5.
      l_day = 'Friday'.
    when 6.
      l_day = 'Saturday'.
    when 7.
      l_day = 'Sunday'.
else.
     Raise exception type zcx_day_problem.
endcase.

With ABAP 7.4, we can simplify and accomplish the same thing by by using the new SWITCH constructor operator instead of the CASE sttatement. Like so…

read more…

Recommend This Post! Tweet about this on TwitterShare on FacebookShare on LinkedInShare on Google+Pin on Pinterest
Jul 18 16

New Features in ABAP 7.4 – Calling Methods and Functions

by admin
Recommend This Post! Tweet about this on TwitterShare on FacebookShare on LinkedInShare on Google+Pin on Pinterest

ABAPAnthony Cecchini is the President of Information Technology Partners (ITP), an SAP consulting company headquartered in Pennsylvania. ITP offers comprehensive planning, resource allocation, implementation, upgrade, and training assistance to companies. Anthony has over 20 years of experience in SAP business process analysis and SAP systems integration. His areas of expertise include SAP NetWeaver integration; ALE development; RFC, BAPI, IDoc, Dialog, and Web Dynpro development; and customized Workflow development. You can reach him at ajcecchini@itpsap.com.

Calling Methods and Functions in ABAP 7.4

This blog will discuss the new ABAP 7.4 functionalities that make calling functions and methods easier to code and easier to read. lets start with METHOD CHAINING.

Using Method Chaining in ABAP 7.4

You can now directly pass the returning value of one method call to a next method call without using any intermediate local variable. This is referred to as Method Chaining. Previously, we were only allowed to create a chain of statements using attributes of the class. Now you can include methods as well as attributes in a chained call. Method chaining is available since ABAP Release 7.0 EhP2.

Don’t get it confused with the chained statements, which You write using colon symbol colon symbol ( : ) .

We can directly pass the result of one method into the input parameter of another method without the need for an intermediate variable. Normally, we would declare a variable, fill it with the result of a method call, and pass that variable into another method. When using this new feature, we are able to reduce the amount of intermediate variables. This should improve code readability. Lets take an example.

CATCH zcx_exception INTO lo_exception.
lv_error_txt = lo_exception->get_error_msg( ).
zcl_my_screen_message=>display( im_error = lv_error_txt ).

By using Method Chaining, we can do away with having to declare the lv_error_txt variable by chaining the two method calls together.

CATCH zcx_exception INTO lo_exception.
zcl_my_screen_message=>display( im_error = lo_exception->get_error_msg( ) ).

read more…

Recommend This Post! Tweet about this on TwitterShare on FacebookShare on LinkedInShare on Google+Pin on Pinterest

Pin It on Pinterest

Share This