"
Supported by

Serialization – Clone Dolly in ABAP

A ovelha Dolly

This article was written by José Vília:

The Dolly sheep was alive in ABAP and I didn’t know about it.

Having created a class instance, I’d like to share it with another totally independent program to use it as if the instance had been created there.

It’s an ABAP Dolly sheep factory we’re talking about here, people. Serialization in the ABAP world.

Ler o resto do artigo! »

Abracadabra reveals secret parameter

Here’s a not very orthodox wat to deal with a report’s selection screen.

Sometimes you may need to have a special parameter which you prefer to hide from normal users but still need access to. Example: a flag to activate a debug/trace mode. I’ll show you how you can do this by just typing the magic word, ABRACADABRA.

It goes like this:


DATA: unhide_parameters TYPE flag.

PARAMETERS: p_debug AS CHECKBOX.

AT SELECTION-SCREEN.
  CASE sy-ucomm.
    WHEN 'ABRACADABRA'.
      unhide_parameters = abap_true.
    WHEN 'NORMAL'.
      CLEAR unhide_parameters.
  ENDCASE.

AT SELECTION-SCREEN OUTPUT.
  LOOP AT SCREEN.
    IF screen-name = 'P_DEBUG' AND unhide_parameters IS INITIAL.
      screen-active = 0.
      MODIFY SCREEN.
    ENDIF.
  ENDLOOP.

Just type ABRACADABRA when you’re at the selection screen and your secret parameter will magically show. If needed, you can then type NORMAL to make it disappear again.

O Abapinho saúda-vos.

ALV Grid built in error protocol

We’re all lazy. It’s just human. Programmers are human. We’re often lazy when it comes to the way we program something. And usually being lazy when making a program will result in someone else having more work when maintaining it.

Let he who is free of laziness throw the first rock.

I won’t!

Ler o resto do artigo! »

PlantUML – Finally UML became simple to use

Foreword

When I say that I like to use UML class diagrams to document my code, people think I’m crazy.

Introduction

The UML has gained a bad reputation because people think that, first you make the classes diagram in UML and only then write the program. But that was in 1996, when you the good practices said the first thing to do was the whole technical spec, even if no one really did it.

Nowadays, fortunately, we are no longer ashamed to say that the very act of programming is already in itself a way of drawing.

Ler o resto do artigo! »

Classe para garantir segurança em programação dinâmica

I recently found a program which was generating an SQL statement by concatenating several variables with fixed SQL parts. But, either by not paying attention or simple ignorance, the person who did it, thought it would make sense to associate a text-symbol to each of these variables with. Something like this:

Ler o resto do artigo! »

SALV consistency report

Sometimes a SALV has inconsistencies which can go unnoticed. For example, if its structure has an amount field which doesn’t have an associated currency field:

Ler o resto do artigo! »

Go into a transaction skipping its selection screen

Once again SAPGui surprises me with yet another obscure shortcut I didn’t know about.

Let’s use the customer display transaction XD03 as an example:

  1. Go into the transaction’s selection screen with /NXD03
  2. Fill in the customer number an press ENTER to display its details
  3. Do whatever it is you want to do there and get out of it
  4. Suddenly… you remember that you needed to do something else there
  5. Instead of /NXD03 type /*XD03
  6. You’re now automagically inside the transaction, already looking at the details of the last displayed customer

It’s surprising that no one ever told me about this before.

I also tried it with FB03 and it works so it probably works with most of the normal transactions. Unfortunately, it doesn’t work with the ones I use the most: SE24, SE38 e SE11. What a pity.

Now go and tell everyone about this!

Thank you Sérgio Fraga for the tip.

Photo credit: Leonard J Matthews.

Greetings from Abapinho.

Copy a Code Inspector variant to another system

In my current customer, I have three development systems. There used to be only one. And that’s where I customized and fine tuned the Code Inspector variant I use to run Abap Test Cockpit.

When the other two appeared, before manually copying the variant into them, I decided to investigate a little bit. Much to my surprise, I found in GitHun project upDOWNci which does exactly what I needed: export and import Code InspectorLars for making this small but useful tool. Actually, thank you for the dozens of useful tools you’ve already given us. They’re quite impressive.

Greetings from Abapinho.

Physical vs logical folders

If in your report called APP1 you need to save a file in a server folder (ex.: /export/app1/) and you don’t want it to be a selection screen parameter, how do you do it?

Ler o resto do artigo! »

Automatically close the doors you open

You’re in the editor. You type ( or [ or { or ‘ and SAP is dumb and doesn’t close it right away like a proper IDE would.

Well,

Click on the lower right corner icon which gives you access to the SAPGui options where you configure code templates.

In the formatting option, activate Enable Auto Brackets and voilá, SAP will now automatically close any doors you open.

I don’t see why this isn’t set by default.

Thank you, Sérgio Fraga for the tip.

Greetings from Abapinho.

ABAP used to like inverting dates

Every day I learn something new in ABAP. Sometimes I’d rather not learn them. Like this one.

Table T056P has a date field. While SELECTing this table using the date as criteria I couldn’t get any result even though the code seemed correct. Using SE16N I found that the date range was also not working as expected: it would only should results if the final date was put in the LOW field and the initial date in the HIGH. Bizarre.

Ler o resto do artigo! »

The transaction who wanted to call another and couldn’t

John created transaction ZFB01 and associated it with program ZFB01 which, after doing some stuff, does a CALL TRANSACTION on FB01. Then came his friend Mike and ran transaction ZFB01.

He managed to start running it because he had permissions to do it. But half way through he got an error because he doesn’t have permissions to run transaction FB01.

Both John and Mike knew that the system administrators would never ever give Mike permission to run FB01.

Ler o resto do artigo! »

ASSERT vs Exception

If you read Abapinho you already know how much I like exception classes. But this is not the only ABAP mechanism for dealing with errors.

There is another one, called ASSERT, which should be used more often.

Ler o resto do artigo! »

Get the deepest text of chained exceptions

If you’re not already using ABAP Objects you’re chicken.

If you use them, I do hope you’re following the best practice of using class exceptions.

And if you’re using class exceptions you better understand the best way of using them, particularly the advantages of chaining them.

This said, here’s what brings us here today. In the post about chained exceptions I showed a way to get the text of the deepest exception in the chain by using a WHILE loop:

Ler o resto do artigo! »

How to not screw up when returning a REF TO DATA

I’ve been using more and more references in ABAP.

I used to use REF TO only for classes but I’ve been finding more and more advantages in using them for other data types. But, just like in C++, care must be used when dealing with data references. Things can easily go very wrong.

In this article, I’ll try to show you how to use and how not to use REF TO DATA. Let’s start by an example of how not to do it.

Ler o resto do artigo! »


About Abapinho
Abapinho runs on WordPress
Articles (RSS) e Comments (RSS).