Archiv der Kategorie: SAP PRESS TOPIC

SALV Table – Display table data in a popup window

This is an easy way to fetch data and show it in a table popup using the class cl_salv_table. Enjoy.


DATA: lr_alv TYPE REF TO cl_salv_table.
DATA: lr_functions TYPE REF TO cl_salv_functions_list.
DATA: lt_t100a TYPE STANDARD TABLE OF t100a.

* fetch data
clear lt_t100a.
SELECT * FROM t100a INTO TABLE lt_t100a uP TO 20 ROWS.


cl_salv_table=>factory(
IMPORTING
r_salv_table = lr_alv
CHANGING
t_table = lt_t100a ).

*set funtion toolbar
lr_functions = lr_alv->get_functions( ).
lr_functions->set_default( 'X' ).

* Set pop-up-dimensions
lr_alv->set_screen_popup(
start_column = 75
end_column = 150
start_line = 2
end_line = 9 ).


*Calling the display-method
lr_alv->display( ).

Enjoy the snippet.

SAP ABAP: Converting a floating point number to a packed field

In some cases we need to convert float values. Here’s a simple example.

DATA :
lv_in TYPE atflv VALUE ‚2.1000000000000000E+01‘,
lv_out     TYPE cha_class_viewsollwert.

CLEAR lv_out.
CALL FUNCTION ‚QSS0_FLTP_TO_CHAR_CONVERSION‘
EXPORTING
i_number_of_digits   2
i_fltp_value         lv_in
i_screen_fieldlength 16
IMPORTING
e_char_field         lv_out.
WRITE /  lv_out.

output :  21.00

Exporting HR organizational structure to a stri… | SCN

Exporting HR organizational structure to a string variable

created by Samuli Kaski on Apr 20, 2012 2:41 PM, last modified by Samuli Kaski on Apr 20, 2012 3:52 PM Version 3

Overview

 

In this document I give a quick’n’dirty ABAP solution for storing the HR organizational structure in a string variable.

 

Coding

 

The coding is pretty straight forward and it should be easy to change or enhance it further. In the example I’m using the IDES organizational structure.

 

data lt_postree_objec    type table of objec.

data ls_postree_objec    type objec.

data lt_postree_struc    type table of struc.

data ls_postree_struc    type struc.

data lv_tot_str          type string.

data lv_tmp_str          type string.

data lv_tmp_str2         type string.

data lv_level            type i.

data lv_char60           type c length 60.

call function ‚RH_STRUC_GET‘

exporting

act_otype    = ‚O‘

act_objid    = ‚00000300‘          “ org. unit IDES US

act_wegid    = ‚O-S-P‘

tables

result_objec = lt_postree_objec

result_struc = lt_postree_struc.

clear lv_tot_str.

clear lv_char60.

lv_char60 = ‚Object‘.

concatenate lv_char60

‚Object ID‘

cl_abap_char_utilities=>cr_lf

into lv_tot_str

separated by cl_abap_char_utilities=>horizontal_tab

respecting blanks.

concatenate lv_tot_str

cl_abap_char_utilities=>cr_lf

into lv_tot_str.

loop at lt_postree_struc into ls_postree_struc.

clear ls_postree_objec.

read table lt_postree_objec into ls_postree_objec

with key otype = ls_postree_struc-otype

objid = ls_postree_struc-objid.

clear: lv_tmp_str,

lv_tmp_str2.

if ls_postree_struc-level gt 1.

lv_level = 1.

while lv_level lt ls_postree_struc-level.

concatenate lv_tmp_str ‚   ‚ into lv_tmp_str respecting blanks.

add 1 to lv_level.

endwhile.

concatenate lv_tmp_str ‚`–‚ into lv_tmp_str respecting blanks.

concatenate ‚(‚ ls_postree_objec-otype ‚)‘ into lv_tmp_str2.

concatenate lv_tmp_str lv_tmp_str2 ls_postree_objec-stext

into lv_tmp_str separated by space.

else.

concatenate ‚(‚ ls_postree_objec-otype ‚)‘ into lv_tmp_str2.

concatenate lv_tmp_str2 ls_postree_objec-stext

into lv_tmp_str separated by space.

endif.

clear lv_char60.

lv_char60 = lv_tmp_str.

concatenate lv_char60

ls_postree_struc-objid

cl_abap_char_utilities=>cr_lf

into lv_tmp_str

separated by cl_abap_char_utilities=>horizontal_tab

respecting blanks.

concatenate lv_tot_str lv_tmp_str into lv_tot_str.

endloop.

 

At the end of execution lv_tot_str string variable will contain the whole organizational structure.

 

Screenshot

 

And this is how it will look if exported to text file, at the left the view in PPOSE.

via Exporting HR organizational structure to a stri… | SCN.