Páginas

segunda-feira, 13 de junho de 2016

ABAP ON SAP HANA: PART I - PART II - PART III

ABAP on SAP HANA. Part I


POSTED BY: SAP YARD MAY 19, 2016

Introduction to SAP ABAP on HANA
We have heard enough about SAP HANA, in-memory concept, software/hardware innovation etc. In this article, we do not want to beat around the theories. As an ABAP developer, we would like to know how we can view ABAP objects (programs/FMs/tables) in HANA Studio and how we can create/change those objects there. This is the first part in the series of posts which would specifically target our SAP Technical folks, our ABAPer community.

As an ABAPer, I had these queries. I am sure, many of my ABAPer friends would have similar if not same questions. Hope these answers would provide some light to your existing knowledge about ABAP on SAP HANA. At the end of the last question of this article, you will learn and create your first ABAP program from HANA Studio and also execute it successfully to view the output.


Let’s move on.

Questions:
1. What is HANA Studio and what is the need of HANA Studio?
2. What is ADT and what is the need of ADT?
3. Seems ADT does the same thing like SE80 T-code. Then why do we really need ADT?
4. What are perspective in HANA Studio
5. In which perspective can we create/change/display ABAP programs?
6. How do we view ABAP programs in HANA Studio?
7. Can we edit the same program in GUI and in HANA Studio?
8. How can we write ABAP programs using ADT?

The below explanations are as per our understanding. We would like to appeal our experienced ABAPers to throw some more light to the below answers if they know more about it.

Q: What is HANA Studio and what is the need of HANA Studio?
1. HANA as a database has evolved manifold in the last few years. In order to keep pace with these hardware and software innovations, HANA Studio is introduced. HANA Studio provides the right environment for HANA administration, modeling and data provisioning.

Studio is needed so that the developers can create models, procedures etc using the Eclipse-based tool in HANA. Studio is also utilized to develop SQL Script which writes Application logic that would push down data-intensive queries and logic to HANA database and improves the overall performance of the system.

Studio also provides monitoring and other tracing facilities.

Also, the Studio gives freshness to developers who were bored with the blue GUI screen editor.  (on a lighter note)

Hopefully, you have some idea of HANA Studio and its need.

Q: What is ADT and what is the need of ADT?
2. ABAP Development Tool is the full form of ADT. ADT provides eclipse base ABAP Integrated Development Environment (IDE).

ADT does not come by default. It has to be installed as a plugin on Eclipse (in Studio -> Help -> Add New Software).

We need ADT because with ADT in Eclipse, the HANA Studio becomes super powerful. You can connect to different ABAP systems from single Eclipse User Interface. Isn’t it cool? With ABAP perspective in the studio, you can implement end-to-end in-memory solutions in Studio with the same UI.

One entry point and multiple benefits. Don’t you like it? 

Q: Seems ADT does the same thing like SE80 T-code. Then why do we really need ADT?
3. You are right. Both ADT and SE80 have same source code repository and locking mechanism and thus both compliment each other. But ADT is more powerful than SE80. Some advanced features likecreating external views for exposing HANA view to ABAP DDIC* (external views), creating Database proxy procedures* are available only when using ADT.

SE80 has been with SAP from birth. ADT is new and still has some enhanced features. SAP is continuously working on more exclusive features which would be possible only from ADT in future. So, ADT is the future


Q: What are perspective in HANA Studio?
4. In layman’s term, perspectives are predefined layouts for different roles. For example, we have ABAP perspective for ABAP developers. Java perspective for Java developers. Debug perspective for debugging. Modeler for modeling in SAP HANA. Administration console for Admin tasks etc. So, every member of the team would use the perspective as per his job role, responsibilities and activities they need to perform.

Q: In which perspective can we create/change/display ABAP programs?
5. You guessed it right!! ABAP perspective. So obvious, right? 
Bonus question  . Can we directly write and execute ABAP program in HANA studio?

No, it has to be connected to an ABAP system first. So, what helps Eclipse to connect to ABAP system? The answer is ABAP Project. Did you expect this answer?  ABAP project helps to connect the Eclipse base IDE to ABAP backend system. The project provides eclipse based frameworks for creating, processing and testing development objects.


In short, ABAP project represents a system logon and contains all ABAP development objects of the related system.



Check this image below. Project S4H_800_SIMPLE3_SAPYARD is our project which is connected to our S4H system.


Similarly, we can have multiple projects pointed to multiple systems from one HANA Studio UI.

Q: How do we view ABAP programs in HANA Studio?
6. Check there is an ABAP program YSAPYard in ABAP system (Left side). We can see the same program from our Project which is connected to the same ABAP system. Expand the System Libraryand go to your custom package and program.


Check, we can view the same program in GUI and HANA Studio.

Q: Can we edit the same program in GUI and in HANA Studio simultaneously?
7. No, we cannot edit the same program simultaneously. Both ADT and SE80 have same source code repository and locking mechanism (as mentioned in answer 3), therefore, we cannot interfere when other is editing it at the same time.

You get the below error in ADT if you try to edit the already opened program (in GUI).


Finally, the much-awaited question by the ABAPer.. 

Q. How can we write ABAP programs using ADT and execute it?
8. Select the Package where you want to save your program. Right-click on it and select ABAP Program.


Give the name and description of the program. Do not forget, the Z* or Y* naming convention holds good even while creating custom objects from ADT.


You need to choose the transport where you want to save your program.

Write your program and check the syntax and activate it. Most of the icon are similar to GUI. Done, your program is ready in Studio. Actually, you created the program just like in SE38/SE80, just the front end was different. You can go to your ABAP system and check, the new program exists there. 

Execute the RUN icon in HANA studio and your program would show the output.

Congrats, you created your first program in SAP HANA and executed it successfully. Although this was a dummy program, in actual projects as well, the process remains the same.

In subsequent posts, we would build real-time programs, learn about ABAP trace in SAP HANA Studio, Debugging in ADT, Optimized access on internal tables, Code Inspector, SQL Monitoring, ADBC, AMDP, CDS etc.


Please stay tuned for more ABAP on SAP HANA technical stuff.
Do you want SAP HANA Studio and HANA Database to practice?
If you want to explore a fully set-up SAP HANA Studio and database, please hit the Subscribe button on the top right side (and activate it) and drop us a note at mailsapyard@gmail.com. We are planning to allow our subscribers’ free access to SAP HANA system for couple of hours to get the look and feel of the system for free (for couple of hours only). After we get the list of interested users, we would provide the credentials and date/time when they can access it.

ABAP on SAP HANA. Part II

TOPICS:

POSTED BY: SAP YARD MAY 26, 2016

ADT Eclipse/HANA Studio for ABAPers
In the SAP ABAP on HANA Part I, we talked about some common questions and answers. We also created our first program in HANA Studio. In this article, we would get accustomed with the HANA Studio screen, various buttons and icons. How/Why to use them and also we would try to correlate the functionalities of HANA screen icons to that of classic GUI icons.

HANA Studio Toolbar

Most of the icons are self-explanatory.

Open ABAP Development Object: The system-wide search for development objects is possible.

Search: The workspace-wide search for development objects is possible. With this function, we can search for ABAP development objects across all usable ABAP projects.

A. What is NOT there in ADT Eclipse/HANA Studio, which was available in ABAP GUI editor?

1. Change/Display Icon
We were not able to figure out the change/display toggle icon in HANA Studio ABAP editor. Whenever we opened the program in our development system, it opened in change mode. If any reader knows about the change/display icon (or shortcuts) in eclipse, please do mention it in the comment section or email us and educate all.

2. Pattern Icon
Another significant button which we could not figure out in HANA Studio is the Pattern Icon. When we want to auto generate the FM/Class/Method or any custom pattern, we are so habituated to use this Pattern icon in ABAP editor. We were little surprised, not to find this commonly used button. But you need not be disappointed. Type initial letters of the syntax you want to use and then use Ctrl + Space andShift + Enter to insert the full signature (e.g. for function module / method selected).


3. Pretty Printer
There is no pretty printer icon. How would developers impress their team leads and quality reviewers without the pretty printer?  Do not worry, the pretty printer button might not be there, but the functionality still exists. Go to Windows -> Preference -> ABAP Development -> Source Code Editor -> Formatter to set up the formatting needs.


You might not see the Formatter option upfront. You need to click on Source Code Editors. Then you would see settings for different options (number 5 in above image) and Formatter is one of them.

Once you set the format, Shift + F1 is the shortcut for the desired formatting.

So, Pretty Printer in GUI = Shift + F1 in HANA Studio 

These are some commonly used icons/buttons which are missing in Eclipse ADT. Please note, this is not the whole elaborate list.


B. Check the common/similar or near similar features in Vanilla ABAP editor and Eclipse/HANA Studio ABAP editor

1. Outline View
Let us start with the Outline View in HANA Studio. Check the outline view on the lower left corner of the studio.


The Outline view displays the internal structure of a program or class that is currently open in the ABAP source code editor. The Outline view is synonyms to the Object detailed screen of ABAP editor in SE80. Just like when we click any element on SE80, it takes to that element in the main program, similarly, the outline is synchronized with the contents of the editor. Hence, when an element in the Outline view is selected, we can navigate quickly to the corresponding position in the ABAP source code.

Just like in SE80 editor, for each element in Outline View in Studio, we can navigate to the declaration part in the source code editor or the implementation part (e.g. in the case of methods of a class).

2. Keyword Completion/Suggestion
Just like in GUI, ABAP editor on HANA studio suggests keywords as you type the syntax. The GUI shortcut Ctrl +Space holds good in eclipse too.


3. Where-Used List
This powerful feature is still available.

4. Revision History.
Like in GUI ABAP editor, we can compare changes from one transport of source code to another in ADT. Right click on the source code area of the program and choose Compare with -> Revision History.

4. Transport Organizer
Transport Organizer in ADT for Eclipse enables ABAP developers to perform the below Transport related operation through Studio.
i) Adding user to Transport request (TRs)
ii) Changing owner of TRs and tasks.
iii) Checking consistency
iv) Releasing and deleting TRs


Right-click on the transport to see all the activities you can perform. One example of adding a user under an existing transport is shown below.



Limitation of Transport Organizer in HANA Studio:
Transport request CANNOT be created within the Transport Organizer view of ABAP Development Tools.But, if you create/edit an object (say table/program/FM/package etc) in Studio ADT and it asks for a new transport, you can create new transport within that corresponding wizard. Remember, transports can be created from those wizards and not stand alone from Transport Organizer.

Advantage of Transport Organizer in HANA Studio:
The Search option in the Transport Organizer. Any object (table/program/FM/package etc) can be searched for, to check the TR and task it belongs to. In SAP GUI transaction SE10, we cannot search that easily. Although we have other t-codes and ways to figure it out. But the ease and user experience in Transport Organizer in HANA Studio is unmatched.



C. The new features in Eclipse/HANA Studio ABAP editor, which were not available in GUI editor.

1. Syntax Error Marker: 
Check the red cross on the left side of the code editor. This feature warns you of any error lines while you are typing your program and even before you hit the syntax checker. This comes really handy for the ABAPers to type the right syntax as and when he/she is.

2. Local code comparison: 
Compares current saved version with the selected saved version.

Right click on the code area of the program and choose Compare with -> Local History. Choose one of the previously saved version and see the comparison. This local change history gives the comparison between saves in the ADT, showing changes in the code as stored in the local workspace.

Check, the code difference can be so easily identified.

3. Rename elements/texts.
Although we have Find and Replace (or Ctrl + H) option in SAP GUI, but Eclipsed based ADT has better renaming experience. Just right click on the source editor and select Rename or hit Alt+Shift+R, to open the replace wizard.

Select the element you want to replace and hit Rename (Alt+Shift+R), give the new name for the element and hit Next.

Before it finishes, it would show the Original code and the new code after the change. It would also show all the lines which would be changed.

Hit Finish and the element is renamed throughout the entire source code.

Summary of some prominent misses and inclusions

Hope, with the help of this article, you have realised that we need not be scared of HANA Studio. It is old wine (ABAP) in a new bottle. In the next article, we would see how we can debug our ABAP program in Eclipse Studio and more.

ABAP on SAP HANA. Part III


POSTED BY: SAP YARD JUNE 5, 2016

ABAP Debugging using ADT (Eclipse/HANA Studio)
In ABAP on SAP HANA Part II, we made ourselves comfortable with the HANA Studio screen, icons and buttons. In this article, we will get exposed to Breakpoints and Debugging in ADT. If you have been working as an ABAPer for some time, it would not take much time for you to get familiar with theDebugger in ADT (Eclipse/HANA Studio). It the same wine in new bottle. 

ABAP debugger is completely integrated with Eclipse from Kernel 7.21, SAP Basis 7.31 SP4.

All the standard debugging features which were earlier available in GUI editor are also available in eclipse. Such as:
i) Set breakpoints
ii) Step through the code
iii) Display and change variable values
iv) View internal tables
v) Monitor the call stacks

Salient Properties of ADT breakpoints:
The breakpoints in ADT are User External breakpoints, so:
i) They are valid in your ABAP project
ii) Programs running under your ABAP user
iii) On all App servers in the backend system

Two types of breakpoints in ADT:
1. Static Breakpoint
Static breakpoints are set at a particular line of the code. A static breakpoint stays with the line of code at which you set it. If you delete code lines above the breakpoint, it slides along with the relocated code at that particular line.

2. Dynamic Breakpoint
Dynamic breakpoints are determined at run time. They are triggered when the running program reaches a particular ABAP statement e.g. loop, perform, select, calls, submits etc.


Please note: Dynamic breakpoints take effect for all programs that run under your user. You need to be careful to remove the dynamic breakpoint once you have finished your analysis. Or else, it would stop for any application where the dynamic breakpoint condition is found. And we are sure, you do not want speed breakers in a highway.  We can always limit the scope of dynamic breakpoints to the scope of the debugger.

Advantage of ADT debugger:
One feature of the debugger in ADT is that you can work with the source code in debug mode as you work in ABAP perspective. That means, when you see a bug in the code during debugging, you can correct your code in the same editor in the same screen. Unlike traditional GUI debugger, where you need to go to SE38/SE37/SE80 etc in a separate session to change the code.

Hands On Section:
Enough of preaching!! Well, above are the theories and I am sure you would be more interested in looking at the actual screens. Let us have a quick look at the Debugger screen and substantiate our understanding.

1. Check the icons/buttons which you can see during debugging:

All the buttons are self-explanatory.
Resume button : Run to the next breakpoint or to the end of the program.
Terminate button : Abort the execution of the program in the debugger. Program execution ends.
Disconnect button : Run to the end of the program, ignoring any intervening breakpoints.
Step Into (F5) button : Execute the next single ABAP instruction in the program in the debugger.
Step Over (F6) button : Execute the next ABAP statement. If the next step is a procedure call, run the entire procedure.
Step Return (F7) button : Run until the current procedure returns to its caller or until the program ends.
Run to Line (Shift F8) button : Run to the statement on which the cursor is positioned. Breakpoints in between will be respected or not is set in Windows->Preferences->ABAP Development->Debug.

Also, check ABAP on HANA. Part II to get accustomed to HANA Studio.

2. Put Static Breakpoint
Double click on the area shown below or right click and choose Toggle Breakpoint or press Ctrl + Shift + B.

3. Execute the program
You would get this pop-up. Select OK and continue. The debugger stops at the breakpoint.

4. Check the Variables view, Debugger editor, Breakpoints view, Debug perspective etc
You can change the values of variables at the run time as you used to do in ABAP GUI debugger. You can also move the cursor over the variable to display its value.

5. Check the ABAP Internal Table (Debugger) view
Double click on the internal table name and see the values in the internal table view.


You can also right click on the internal table name and choose Open Data Preview to see the values of the internal table.

6. Let’s set a Dynamic Breakpoint
Go to the Breakpoints View and Add dynamic breakpoints at the statements you need. Type the statment in the search area and get your dynamic statements.

See two examples of dynamic breakpoint below.

7. Manage the Breakpoint Properties of a particular breakpoint
Manage breakpoints using Breakpoints View. Right click on the breakpoint and choose the Breakpoint Properties and choose the restriction you want.

8. Manage the Debug Properties for the user/session
You can change the user for which external breakpoints are effective. Breakpoints cab also be effective for the entire project independent of the users.

Hopefully, this article was successful in giving you the overview of Debugging in HANA ADT. For experienced ABAPers, it is the same thing as in ABAP GUI, with some good additions. For freshers, you need some system to get your hands dirty and learn.

As declared in our previous post, we are planning to allow our subscribers’ free access to SAP HANA system for a couple of hours to get the look and feel of the system for free (for a couple of hours only). We are still compiling the list. After we get the total list of interested users, we would provide the credentials and date/time when they can access it. In the next article, we would see how we can perform ABAP Profiling/Tracing in Eclipse Studio and more.

If you want to get such useful articles directly to your inbox, please SUBSCRIBE. We respect your privacy and take protecting it seriously.

If you liked this post, please hit the share buttons and like us on facebook.

Check our series on SAP ABAP on HANA

Other articles on HANA

Nenhum comentário:

Postar um comentário

Observação: somente um membro deste blog pode postar um comentário.