Skip to Content
Technical Articles
Author's profile photo Hyung Jin Youn

Simple Report by calling function module SE16N_EXTERNAL_CALL

Purpose 

I have been asked to make simple reports just for retrieving data from tables with all nice functions which you can use at SE16N, SE16H sort of SE transactions .

Well, there are many fancy UI report tools that you can create a fancy report, which are something like POWL or Fiori List, FPM, and WebUI. Of course, if you are good at using conventional SAP report tools like Report Painter, SAP QUERY, QuickView, and so on .. Wouldn’t be any problem considering that SAP has been providing  lots of report tools for user to avoid building SAP reports from scratch.

But, What is the simplest way to meet user’s requirements if end users do not want to know how to use the fancy report tools, and just want to call a transaction?  And want to something like SE16N outputs and the out-of-box functions only ? Moreover, user wants simple UI interface with customer selection criteria & layout variant on top of the SE16N ?

 

Adopting SAP stand functions 

Answer is simple, Call  SE16N_EXTERNAL_CALL.

Here is the very simple steps to make a customer SE16N report.

  1. Create a report transaction
  2. Create a report calling FM ‘SE16N_EXTERNAL_CALL’
  3. Restricted the selection criteria and input parameters,

Optionally,  you can preset the layout, filter, group by, sub-sum, and all functions come with SE16N

 

Example

In my reference program, I restricted 2 selection-options as input Selection Criteria

 

REPORT xxxxxx….

**// Definition
TABLES  lfbk.
DATA lr_stab TYPE TABLE OF se16n_seltab WITH HEADER LINE.
DATA   lc_se16n_tab TYPE  se16n_tab VALUE ‘LFBK’.

 

*—–> Pick selection criteria from field list of table LFBK 

SELECT-OPTIONS s_bankn FOR lfbkbankn .
SELECT-OPTIONS s_lifnr FOR lfbklifnr             NO INTERVALS NOEXTENSION.

**// START-OF-SELECTION.
START-OF-SELECTION.

 

*—-> you can check of the authorization of tcode SE16N, but it’s optional.   

*** Authorization Check
** Check for SE16N access when it called by customer t-codes
*  IF sy-tcode NE ‘SE16N’.                                   “1757450
*    CALL FUNCTION ‘AUTHORITY_CHECK_TCODE’
*      EXPORTING
*        tcode  = ‘SE16N’
*      EXCEPTIONS
*        ok     = 0
*        not_ok = 1.
*    IF sy-subrc NE 0.
*      MESSAGE e059(eu) WITH ‘SE16N’.  ” no authority
*    ENDIF.
*  ENDIF.                                                    “1757450

 

*—-> Build Selection Tab for Sel-Option S_BANKN & S_LIFNR 

** Build SelTab
lr_stab[] CORRESPONDING #s_bankn[]  ).
** Fill the Field Name in SelTab
lr_stabfield ‘BANKN’.
MODIFY lr_stab TRANSPORTING field WHERE field EQ space  .

lr_stab[] CORRESPONDING #(  BASE lr_stab[] )  s_lifnr[]  ).
lr_stabfield ‘LIFNR’.
MODIFY lr_stab TRANSPORTING field WHERE field EQ space  .

 

*—–> Call the SE16N function Module

**// END-OF-SELECTION.
END-OF-SELECTION.

**// Call SE16N with a restriction of selection criteria
CALL FUNCTION ‘SE16N_EXTERNAL_CALL’
EXPORTING
i_tab     lc_se16n_tab
*     i_variant = p_vari
*     I_HANA_ACTIVE             =
*     I_DBCON   =
*     I_OJKEY   =
*     i_max_lines = p_max_l
*     I_GUI_TITLE =
*     I_FCAT_STRUCTURE          =
*     I_LAYOUT_GROUP            =
*     I_NO_LAYOUTS              =
*     I_DISPLAY_ALL             = ‘ ‘
*     I_TEMPERATURE             = ‘ ‘
*     I_TEMPERATURE_COLD        = ‘ ‘
*     I_SESSION_CONTROL         =
*     I_EDIT    = ‘ ‘
*     I_NO_CONVEXIT             = ‘ ‘
*     I_CHECKKEY  = ‘ ‘
*     I_FORMULA_NAME            = ‘ ‘
TABLES
it_seltab lr_stab
*     IT_SUM_UP_FIELDS          =
*     IT_GROUP_BY_FIELDS        =
*     IT_ORDER_BY_FIELDS        =
*     IT_AGGREGATE_FIELDS       =
*     IT_TOPLOW_FIELDS          =
*     IT_SORTORDER_FIELDS       =
*     IT_CALLBACK_EVENTS        =
*     IT_OUTPUT_FIELDS          =
*     IT_HAVING_FIELDS          =
EXCEPTIONS
no_values 1
OTHERS    2.

*//  No Need to populate error
IF sysubrc <> 0.
MESSAGE w002(wusl).
* Implement suitable error handling here
ENDIF.

 

 

Output

This screen becomes ….

 

 

 

Like These with the same layout of SE16N

 

 

 

 

With this kind of simple ABAP report, you can limit user’s access to SE16N and assign different access of SAP tables by the Authorization object S_TCODE.

Hope this makes SAP life a bit easier.

 

Comment : It’s been over 10 years since the last time when  I built ABAP reports , so my coding style might be old-fashioned,

 

 

 

 

Assigned Tags

      4 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Matthew Billingham
      Matthew Billingham

      A few things:

      If you use the {} button on the blog editor, it makes your code more readable, like this.

      **// Definition
      TABLES  lfbk.
      DATA : lr_stab TYPE TABLE OF se16n_seltab WITH HEADER LINE.

      As far as your 10 year old coding style - time for an upgrade! 😀

      HEADER LINE tables are obsolete and have been for 20 years or so. You should not use them in new code. You should a work area of type SE16N_SELTAB. Of course you need to change some of your table handling.

      Likewise, TABLES is obsolete. You can replace it with

      DATA LFBK TYPE LFBK.

      Or, better,

      DATA G_LFBK TYPE LFBK.

       

      Author's profile photo Hyung Jin Youn
      Hyung Jin Youn
      Blog Post Author

      yep I stopped using WITH HEADLINE. I just used that as I am so lazy to make a WA in MODIFY statement 🙂

      Thanks for your advise.

       

       

       

      Author's profile photo Jelena Perfiljeva
      Jelena Perfiljeva

      Thanks for sharing!

      I'd argue that using SAP Query (SQ01) is actually much simpler in this case. It requires 0 code, you literally just select your tables and drag-and-drop the fields. Personally, I think SQ01 is awesome but I'm not sure if there is a solid replacement for it in HANA world.

      Author's profile photo Hyung Jin Youn
      Hyung Jin Youn
      Blog Post Author

      Obviously, SAP Query or QuickView are much easier to someone like us who know the tools, and simply we can assign a ztcode to the query.  Unfortunately, End users like the uniform ALV layout of SE16N ...exactly same one. 🙂