ABAP Coding

Home / SAP / Archive by category "ABAP Coding" (Page 8)

ABAP – Suppressing BAPI Messages

I just learned a fun trick when using a BAPI.  I’ve been designing a dynpro transaction and I used a BAPI to pull some information.  What I discovered is that certain BAPI’s have some messages that automatically get displayed, and also caused a weird behavior of leaving the screen (without requesting it.  ha ha ha).  So today I talk about suppressing BAPI messages within a method or form.

Well, I learned a quick fix for this, when calling a function, add the DESTINATION = ‘NONE’.

this will suppress the messages of the BAPI, and just execute the data retrieval I was looking for.

This is a quick one…  I hope you find it useful.

ABAP – Refresh ALV Grid

I recently had to go through and add a button to refresh ALV grid in a custom transaction.  I initially expected this to be easy.  And looking back, it actually is pretty easy, if you kept your program modular.  However, I had to handle things differently than I expected.

I thought I would need to do something with the refresh button that comes with the standard ALV grid.  However, after a some extensive google digging, I couldn’t find anything that told me how I could do that.  Everyone else took care of the issue by creating their own button.  Here’s the basic steps to do it yourself.

You will need to setup the following 2 handlers.  I created a local class to house these methods.  You can take care of it anyway you prefer.

DATA: l_event_receiver_grid TYPE REF TO lcl_event_receiver.
(where lcl_event_receiver is the local class)

SET HANDLER l_event_receiver_grid->on_toolbar_add_button
FOR grid.
SET HANDLER l_event_receiver_grid->on_user_command
FOR grid.

For the add_button:

DATA: ls_toolbar TYPE stb_button.
MOVE ‘ZRFO’ TO ls_toolbar-function.
MOVE ICON_REFRESH TO ls_toolbar-icon.
MOVE ‘Refresh’ to ls_toolbar-quickinfo.
MOVE ‘ ‘ TO ls_toolbar-disabled.
APPEND ls_toolbar TO e_object->mt_toolbar.
this adds a button that looks exactly like the standard refresh button.  You can feel free to play around with the look and feel, but this will get your started.

In the on_user_command, you will need to look at sy-ucomm, and find when it matches ZRFO (in this example).

refresh grid table.
rebuild the grid table

then call the display method.  For me, I uised the set_table_for_first_display method.  So updating the grid table and calling this is enough to perform the refresh.

This will give you a great start if you want to add a refresh button your custom transaction.

I hope you find this helpful.

Web Dynpro – Using the Code Wizard

Well, I believe I mentioned it in a previous post, but I’m still struggling with the differences between BSP and Web Dynpro.  AWDP is a fun tool, and I like it the more I get into it, the learning curve is still killing me 🙂  Today the Code Wizard is one of my recent discoveries.

For example, I figured out the whole context model, why you do it, etc.  But I had a hell of a time figuring out how to get the value into or out of the context variables I created.  I finally discovered the Web Dynpro Code Wizard…  which, with a few clicks, generated all of the code I needed to read or set the context node.  So simple, yet I hunted on-line for an hour, and eventually found it in the ABAP Web Dynpro book I purchased.

It turns out, you click the wizard button, select the node you want to work with, then tell it if you want to read it, set it, append it, etc…  hit the green check mark.  And magically, all the code I needed was inserted into my method.  Who knew it could be that easy.  LOL.

Anyway, if you’re playing with AWDP, take advantage of the code wizard.  it won’t create your whole application, but it’s great at the little stuff =)

thanks for reading,


Web Dynpro – Dynamically Changing the Web page Title

Well, as I begin digging into my first ABAP Web Dynpro program, I”m slowly starting to figure out what is going on.  Expect some posts on AWDP in the future, since it’s now becoming my latest hobby =)  Today’s challenge was dynamically changing the web page title.

tip number 1.  If you want to change the title of the web page, you know the title that shows up on the tab of Windows Explorer, you can’t do this dynamically until you have Netweaver 7.02 or later.  If you have at least this basis release, you can use the following command:

  wd_this->wd_get_api( )->get_component( )->get_application( )->set_window_title( wd_this->lv_title ).

Now the bad news is that if you don’t have 7.02 or later, you can only change it in the application description.

So, I just need to start tracking these little tidbits as I go.  As always, I’m learning things the hard way so you don’t have to.

Thanks for reading,


Web Dynpro – Initial Challenges

Wow, I have to admit, I thought after going through a book and doing some exercises, I’d have no problem converting a BSP application to Web Dynpro.  Was I ever wrong!!!  The learning curve is steeper than I expected.  It is very different, and admittedly, I haven’t wrapped my head around all the concepts of how it works.  But, if you know me, you know that I just keep plugging till I figure it out =)

Initially, I set the goal of “simply” creating the initial login page.  Even that has been a challenge.  I haven’t quite figured out how I can layout a page the way I want.  For example, I’ll have a common header and footer for every page.  I found an application that seems to do just that (or close enough for my initial go-around), but digging through it to figure out what’s happening has been challenging.  I’ve been battling a cold as well, so that certainly makes my brain a little more foggy than usual, but I expected it would just fall into place…  well, not there yet, but I’m still hacking away.

Second was to recreate my navigation tree on the left side of the application.  This again is used for every single page, and pretty much drives the entire application.  This again I thought would be simple.  I did it in BSP, how hard could it be?  Well, pretty hard it turns out.  I’m working to understand the “Context” right now, which if I understand it correctly, is like variables, so my next mission is figure out how to populate the Context variables I created.  The funny thing is that once I grasp the Web Dynpro concepts, it should be a piece of cake because I’ll be able to reuse all of the ABAP methods I originally created for the BSP, just move the data to Web Dynpro…  This will be an ongoing post topic for me, so if you happen to be a Web Dynpro guru, and you recognize something, throw me a bone in the comments.  I’d really appreciate it.

Anyway, that’s all for today.  Thanks for reading,


ABAP – Using the SCREEN structure

lately in my development activities I’ve spent a lot of time developing screen.  One of the pieces of our latest product is a high end configuration screen to give the user as much control as they want for the final product.  Now as many of you know, I have no formal ABAP training, but it’s amazing what you can learn from books, the internet, and just good old trial and error.  Well, one of the things I’ve been using a lot is screens.  If you’re a developer, I’m sure this is old hat, but to me this has become invaluable.  In a previous post, I talk about how important it is to be consistent in naming your screen elements.  Today I’m going to step back and talk a little about the SCREEN structure.

For me, some of the big things I wanted to be able to dynamically control is if the element is visible in SE51 and if you can change it.  For this, there are simple fields in the SCREEN structure:

  • Invisible – setting this to 1 make the field disappear from the screen
  • input – setting this to 1 makes the field editable.

Now the big thing to remember is that if you are doing something dynamic, like I’ve done using tables to control the settings, you must lock the changes in.  Locking them in is very simple.  MODIFY SCREEN.  That simple statement, locks your changes in.  If you forget it, you’ll spend a lot of time being frustrated, wondering why the element isn’t behaving like you’re telling it to (believe me, I know this from experience.  ha ha ha).

Thanks for reading,


ABAP – Create an ABAP Custom Header Automatically for all your Programs

I found this cool post that showed me a way to have my own ABAP custom header default into every new program I created.  I thought I’d share it with you all (and add it to my note book :> ).

It’s really pretty easy.  Simply go to table: TSE05 (use SE16N, since no table maintenance has been defined).

If you want to update a program, use the following:

Next up, just make the changes as you’d like.  Feel free to add additional lines, move around what’s there, etc.  Now you don’t even need to paste your header into every program, just set up your boilerplate once, then you only need to populate in the information.  Just like that you have your own ABAP custom header that will populate every time you create a new program.

Happy Hacking,


Idiot Proofing your Software

Today I just want to talk about something that is pretty obvious to most people, but I hope to give you a few new ideas on it anyway.  The topic today is idiot proofing your application.  Now, let me go on record by saying idiot proofing your software is pretty much impossible, however, you still need to you best.  I had a friend that used to tell me, “you can monkey proof your software all you want, but they just hiring better monkeys”.

So do you just run through it once, and call it good since you know it’ll be broken anyway?  of course not.  For me, this has always been a challenge.  I’m part of a small business, and I’m the lone developer.  That means, I’ve gotten really good at fixing the things I know will happen, but it also means that I tend to get tunnel vision.  I believe it a common thing among developers, but the key is to avoid that trap.  So here are some of the ways I’m trying to improve my own products…

1.  Get someone that knows nothing about product to play with it.  If I could get her interested, my wife would be a perfect test subject.  She doesn’t use SAP, she knows nothing about service, but she does understand IT and software.  By getting someone with no idea what is supposed to happen means that they will push all the buttons you never expected anyone to push.  They will also look at it from a purely aesthetic perspective, something that I don’t do as well.

2.  Next, if you can, get someone that isn’t good with software, but understands the business.  this will give you the true test if you got the right info.  If someone looks at the information generated, and says “this would help me run my business”, then you’re onto something.

3.  finally, get another developer to look at your stuff.  they’ll look at some of the ways you’ve done things and ask “why?”  Often, we know a way to do something, so we don’t look for better ways.  Often I’ll go to someplace like tech-ed or even a blog post and notice a strange piece of code.  I look at it closer, next thing you know, I’ve found a better way to do something 🙂  The problem is that I don’t have the time to reveiw everything, and I’m biased, so I don’t see anything wrong with my approach.  But…  if someone else asks why did I do this, instead of that? well, it forces me to look at my stuff and either explain why it had to be done this way, or I may say…  hmmmm, that’s a better way.  Now I know a new way to do it.  ha ha ha

The last point is to do this early and often in your development cycle.  Point #2 is really something you should get before you even start programming.  Sketch what you’re thinking, and show it to a business person.  Ask if it would help… if not, why bother?

Anyway, this has been on my mind lately, so if you have some other good ideas, or are interested in playing with anything I’ve done, I’m always interested in having another set of eyes look at my stuff.



ABAP – Screen Elements Naming Convention

It’s been a while since I put a post out about code, and since I’ve been spending a lot of time creating screens lately, I thought I’d drop a quick tidbit out there for any of you programmers out there.  Lately, I’ve been creating screens to work as a configuration screen for one of our applications.  What this means is that there are lots of screen elements, radial buttons, etc in order to make it look good.  I have a table behind the scenes to hold all the information, but like normal screen design, you don’t make a table that goes 1 to 1 with the screen, it’s too inefficient.

Why do you care about any of this? Well, by following a standard naming convention, you can make life really easy on yourself.  Let me give you an example.  I have a screen with about 100 radial buttons (30 rows, some with 2 options, some with 3, some with 4).  Well, by following a naming convention with a standard prefix, putting the field name in the same spot, and adding the occasional suffix, you can dynamically read the field name and make it work for everything you put on the screen without having to read every line.

In your PBO, you can do something like this:
if screen-input = 0.
WHEN ‘3’.
<FIELD> = ‘X’.
WHEN ‘4’.
<FIELD> = ”.


Now, some of the key things to notice, one is that the loop continues if you can’t input anything.  this is purely to speed things up.  Next, by using the position, you can check for the prefix.  In this example, it’s CH_

Next, it finds the key field name to plug into the configuration table.  Next up, it checks to make sure that the table entry exists in the custom configuration table.  As long as it finds an entry, we use a field symbol to assign the value to the screen field.

The awesome part of this is that as long as you maintain a consistent naming scheme, you can set the values for multiple screens and reuse the code.

anyway, I hope this is useful for you.

If there’s anything we can do to help you out, please use the Contact Us Button above and let us know what we can do for you .

Thanks for reading,


Big Development Projects – Don’t Get Discouraged

I’ve been working on the latest piece of software for JaveLLin Solutions, and recently hit that frustrated/burned out point on it.  This piece is called Proximity, and the basics have already been designed for the transactions.  However, we are doing a major overhaul, adding some additional functionality and adding a configuration screen to give the user flexibility.  Now, I’ve been working on the redesign for the past few weeks.  Yesterday, I thought I had it wrapped up except for minor tweaks.  I handed it off to my partner (he’s done the specifications for this one), and he came back with a rather extensive list of things to add/update.  While is great, we are getting a better product, more robust solution, and just an overall system that should be easy to sell…  so how could this possibly be a problem???

The problem comes in purely from the amount of time I’ve spent, and of course, the disappoint of not being complete with something I thought was finally completed.  So, how do you avoid this letdown?  Let’s start with a few simple things you can do to get refreshed…

1.  Take some time away from this project.  While normally I recommend single tasking everything, sometimes when you’ve been working on the same initiative for weeks, you need to recharge the batteries.  Take me for example.  After I got the news, I almost picked up the keyboard again and angrily started hacking out the updates.  While this could work, my head isn’t in the game.  This would lead to not doing my best work.  So I’m taking the day off and doing some marketing stuff.  In fact, that’s why I’m blogging right now 🙂

2.  Try not to get too invested in your work.  For me, this is nearly impossible, but I’m trying really hard.  After spending weeks doing some great work and fun new enhancements, so suddenly get broadsided with a big new list of things to work on, can hit you personally.  Go back to number point 1…  and then review the changes.  Remember that this isn’t personal, it’s all about making the best product possible.

3.  Review the changes and determine what needs to happen right now, compared to what can wait.  Often things are nice to have, compared to required.  it’s important as a small shop to properly prioritize what needs to happen.  This means looking at what is currently being used by a customer (something you’ve already sold), what has “legitimate” leads for purchase (actual customer interest in the product, have looked at the product so far and decided they will purchase given some additional cleanup/functionality), then what is just something you “believe” customers will want.  Now I am very guilty of doing everything in that third bucket.  While this belief that customers will want it is important to brainstorm new ideas, the important thing is what customers REALLY want.  Of course, this becomes more challenging if you don’t have any actual customers yet.  Regardless, prioritize…  development time is a vital resource, be sure to use it wisely…

4.  Finally, find a way to re-energize yourself about the project.  Get excited about you’ve done, and how these little tweaks will make it even better.  Convince yourself, in any way that it takes, that this is the best use of your time =)

5.  Make the changes, and finish the project =)

I’m certainly open to additional methods you have any.  I’d love to hear from you.