Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

7/3/2015 Abapinho » Arquivo » Steal data from a SALV

"

Supported by

Steal data from a SALV


2013­10­14

A friend of a friend of a friend said that a friend of his knew a friend who explained to him in a shady club bar in the docks
area of Lisbon how to steal data from a SALV.

Let’s assume there already exists a programme that displays your results in a SALV and they ask you to do something
more to those data. Such as saving them in a file, or whatever. Until a short while ago, I thought I would have to change
that programme and add some code to it before it presented the ALV, then get the data and do what I wanted with them.
But imagine it’s a standard programme that cannot be changed. What do I do? Make a copy of the standard? That’s
something to always be avoided.

The trick is to manipulate the environment around the ALV to ensure it is not displayed and then, without the SALV even
noticing, go and get the results from the memory. It’s far­fetched, but nothing complicated. I’ll teach you how it’s done:

The first deception is to run a very special command that causes the data of the SALV not to be displayed.

cl_salv_bs_runtime_info=> set(
display = abap_false
metadata = abap_false
data = abap_true ).

Sly. Veeeery sly.

Now that the environment is controlled you can order any programme to run that displays a SALV. Only, it won’t be
displayed. So, you can do something like this:

SELECT‐OPTIONS: so_budat FOR mkpf‐budat.


SUBMIT rm07mlbd WITH datum IN so_budat AND RETURN.

This report usually ends with a SALV. But not this time. This time it ends in silence.

Finally, to obtain the SALV data you need a second deception, a genuine sleight of hand:

http://abapinho.com/en/2013/10/roubar­salv/#more­2444 1/4
7/3/2015 Abapinho » Arquivo » Steal data from a SALV

DATA: ls_data TYPE REF TO data.

cl_salv_bs_runtime_info=>get_data_ref(
IMPORTING r_data = ls_data ).
ENDTRY.

And hey presto! The data of the SALV are in your possession. Now you can use them as you see fit:

FIELD‐SYMBOLS: <lt_data> TYPE table,


<l_data> TYPE data.
DATA: s_belege TYPE stab_belege.

ASSIGN ls_data‐>* TO <lt_data>.


LOOP AT <lt_data> ASSIGNING <l_data>.
MOVE‐CORRESPONDING <l_data> TO s_belege.
WRITE: / s_belege‐mblnr.
ENDLOOP.

FIELD‐SYMBOLS: <lt_data> TYPE table,


<l_data> TYPE data.
DATA: s_belege TYPE stab_belege.

ASSIGN ls_data‐>* TO <lt_data>.


LOOP AT <lt_data> ASSIGNING <l_data>.
MOVE‐CORRESPONDING <l_data> TO s_belege.
WRITE: / s_belege‐mblnr.
ENDLOOP.

Note that the GET_DATA_REF() method launches the exception CX_SALV_BS_SC_RUNTIME_INFO if something
fails, so it would be convenient to wrap your call in a TRY CATCH block.

Thank you Luís Rocha for sharing the information from your friend’s friend of a friend of a friend.

Greetings from Abapinho.

Like 11 people like this. Sign Up to see what your friends like.

Categoria Articles | Etiquetas: salv, secret | 4 comentários

4 comentários a “Steal data from a SALV”


1. Adriano Diz:
17 de October de 2013 às 01:37 PM

O gajo, deu um probleminha no eu field­symbol no útimo quadrinho, abraços ;)

2. Nuno Godinho Diz:


17 de October de 2013 às 02:39 PM

Obrigado Adriano! Era um problema de HTML que impedia mostrar os field­symbols. Agora, espero eu, já está ok.

3. Raphael Maia Diz:


28 de January de 2014 às 05:14 PM

Muito bom!

Mas acho que seria uma boa ideia executar o método: cl_salv_bs_runtime_info=>clear( ) depois desse roubo, para
não deixar rastros! Concorda?
:D

Caso contrario o usuário não vai poder executar nenhum ALV nesse ambiente até que seja feito um novo login.

4. Nuno Godinho Diz:


28 de January de 2014 às 05:22 PM

Raphael, acho que tens razão :)

http://abapinho.com/en/2013/10/roubar­salv/#more­2444 2/4
7/3/2015 Abapinho » Arquivo » Steal data from a SALV

Deixe um comentário

Nome (Obrigatório)

E­Mail (Não será publicado) (Obrigatório)

Página pessoal

Submeter comentário

Categories
Articles
Best practices
Código
Tips & Tricks
Stories
Notícias

Archives
Archives Select Month

Links
ABAP Ninja
ABAP Zombie
jobserve
OnSAP
Pedro Lima
SAP Notes Search
SAP Sites Updates
SDN

Pesquisa
ok

Português English

http://abapinho.com/en/2013/10/roubar­salv/#more­2444 3/4
7/3/2015 Abapinho » Arquivo » Steal data from a SALV

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

http://abapinho.com/en/2013/10/roubar­salv/#more­2444 4/4

You might also like