Saturday, August 5, 2017

Minimal ALV code to display data from internal table

Displaying data via ALV is very popular among ABAP programmers. ALV or so called SAP List Viewer (in fact it shouldn’t it be called SLV? funny though) is a user interface element for displaying tabular data in applications. It has a format data very familiar to SAP users. By default it offers a lot of functions like sorting, filtering, summing data in tables etc. Moreover it can be relatively easy enhanced by custom or application specific functions (custom button in ALV’s toolbar etc.). The ALV is sometimes called ALV grid control as the data is displayed in the table or grid.

There are few of Function Modules and classes/methods that can be used by ABAP programmer to leverage power of the ALV. In my case I was wondering what can be minimal ABAP code that could display data from internal table of ABAP program.

I came up with below to example program demonstrating minimal ABAP code for the ALV grid:

REPORT zmm_minimal_alv_01.
 
SELECT * FROM usr02 INTO TABLE @DATA(lt_users).
 
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
  EXPORTING
    i_structure_name = 'USR02'
    i_grid_title     = 'Title of the ALV grid:'
  TABLES
    t_outtab         = lt_users.

In the example a I’m passing an information about data to be displayed by a structure with general layout specifications for list layout. In this case the structure (USR02) is present in ABAP Dictionary. In case it would be a custom one no persistently present in the ABAP Dictionary I would need to either pass it via internal table (IMPORT param IS_LAYOUT) with the set of information to be outputted or to pass it via a field catalog (IMPORT param IT_FIELDCAT) in the form of an internal table.

By adding import param i_grid_title a title of the grid can be added:

REPORT zmm_minimal_alv_02.

SELECT * FROM usr02 INTO TABLE @DATA(lt_users).

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
  EXPORTING
    i_structure_name = 'USR02'
    i_grid_title     = 'Title of the ALV grid:'
  TABLES
    t_outtab         = lt_users.

By adding below import param it is possible to display the grid in new popup window and params can control position of that popup:

REPORT zmm_minimal_alv_03.
 
SELECT * FROM usr02 INTO TABLE @DATA(lt_users).
 
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
  EXPORTING
    i_structure_name = 'USR02'
    i_grid_title     = 'Title of the ALV grid:'
    i_screen_start_column = 10
    i_screen_start_line   = 20
    i_screen_end_column   = 200
    i_screen_end_line     = 50
  TABLES

    t_outtab         = lt_users.

Just to add also FM POPUP_WITH_TABLE_DISPLAY could be used to display data from the internal table in simple way however it is not the ALV.


Source code of the example can be found here: github.com/softy12/MINIMAL_ALV

Friday, August 4, 2017

T-code ST14 – all you ever wanted to know about your BW system

Today I ran into t-code ST14 which was very much of surprise to me. Actually the t-code provides all information about the BW system someone would ever be interested to know. Mostly all the information are from area of Data Volume Management (DVM) but they are very interesting I must emphasize. Normally one would need to dig into the system and use many reports, functions etc to collect all the information that the t-code provides. The t-code is called as Application Analysis tool.

The code itself is not only dedicated to BW systems. At introduction popup while t-code is started one can decide whether it shall be information about Basis, Security, CRM (if you run it on top of CRM system) and BW systems shown. In next I just focus on the BW option.
There are 4 main areas of the provided information:

·         Basis Information / Dataflow – info about many TOP 30 items like: Top 30 PSA analysis, ODS/DSO Objects (Active Data view), E or F -Fact or Dimension Tables, Aggregates, Master Data Tables, Other BW Tables, Other Tables, ODS/DSO Objects (Change Log view), ODS/DSO Objects (Total Size View), Cubes, Objects, InfoProviders with BWA index, HybridProviders (as of BW 7.30), Semantically Partitioned Objects (as of BW 7.3).

·         BW Evaluation / Customizing – info like follows: Total Size BW Objects, BW namespaces used in the system, Top 30 Cubes: result of SAP_INFOCUBE_DESIGNS, Top 30 Cubes: InfoCube Compression Rates, PSA: Age of Requests, PSA that contain REQU older than 4 months, Partitioning of E-fact tables, BW Archiving Objects, Upload from source systems (last 5 weeks), Overview InfoProviders, InfoProviders not loaded during last 4 months, InfoProviders with suspicious keywords in text, InfoProviders w/o suitable time characteristics

·         ABW Technical Processing Information – info about the tool itself, A – means application (analysis) for BW

·         HANA Tables – only in case the BW system is on HANA, info like Top 30 Tables within ROWSTORE

Additional areas of information:
·         Extended Checks
·         BW Planning
·         Standard Tables
·         BPC Analysis
·         HANA Feasibility Check
·         BPC Monitoring Statistics

In case you are curios how the data into the tool is gathered. Here’s an explanation. A background job can be scheduled within the code to collect all the information. The job has name e.g. BW APPLICATION ANALYSIS 0x (x in case it run in parallel). Depending on the BW system size runtime of the job may differ. Once you have a data all different types of analysis are possible as described above.

It is a great tool which saves a lot of time as all useful information can be found at one place.
Needless to say that t-code is part of “Service tools for Applications ST-A/PI” (see my other blog here). Also the functions behind the t-code can be leveraged by Solution Manager while the data from the t-code can be downloaded to the Sol Man and further reported and analyzed there.

More information:

Tuesday, August 1, 2017

Return value of READ TABLE statements

Returning value or sometimes technically called sy-subrc is very important while programming in ABAP language. It is also important when it comes to READ TABLE statement of the ABAP.

Normally one would expect that the READ TABLE returns two values. Zero (0) in case the READ was successfully (at least one line was read) and four (4) in case it wasn’t. However there are more of the return values.

There is also value of eight (8). It is similar to 4. The 8 is returned in the case search was done with binary method and/or key was not fully qualified.

There is also value of two (2). The 2 is returned in the case the READ statement has an addition COMPARING. To demonstrate this in more detail I’m providing below example of ABAP program based on fragment code I found in online documentation.

REPORT ZMM_READ_TABLE.

DATA: BEGIN OF ls_line,
  col1 TYPE i,
  col2 TYPE i,
END OF ls_line.
DATA lt_tab LIKE HASHED TABLE OF ls_line WITH UNIQUE KEY col1.

WRITE: / 'DATA in TABLE:'.
WRITE: / 'lt_tab-col1'20 'lt_tab-col2'.
DO 4 TIMES.
  ls_line-col1 = sy-index.
  ls_line-col2 = sy-index ** 2.
INSERT ls_line INTO TABLE lt_tab.
WRITE: / ls_line-col1, 20 ls_line-col2.
ENDDO.
SKIP.

WRITE: / 'DATA to be FOUND in structure:'.
ls_line-col1 = 2. ls_line-col2 = 3.
WRITE: / 'ls_line-col1'20 'ls_line-col2'.
WRITE: / ls_line-col1, 20 ls_line-col2.

SKIP.
WRITE: / 'READ TABLE lt_tab FROM ls_line INTO ls_line. ==>'.
READ TABLE lt_tab FROM ls_line INTO ls_line.
WRITE: 'SY-SUBRC =', sy-subrc.
WRITE: / 'row found:', sy-tabix, ls_line-col1, ls_line-col2.

SKIP.
ls_line-col1 = 2. ls_line-col2 = 3.
WRITE: / 'READ TABLE lt_tab FROM ls_line INTO ls_line COMPARING col2. ==>'.
READ TABLE lt_tab FROM ls_line INTO ls_line COMPARING col2.
WRITE: 'SY-SUBRC =', sy-subrc.
WRITE: / 'row found:', sy-tabix, ls_line-col1, ls_line-col2.

SKIP.
ls_line-col1 = 2. ls_line-col2 = 3.
WRITE: / 'READ TABLE lt_tab FROM ls_line INTO ls_line COMPARING col1. ==>'.
READ TABLE lt_tab FROM ls_line INTO ls_line COMPARING col1.
WRITE: 'SY-SUBRC =', sy-subrc.

WRITE: / 'row found:', sy-tabix, ls_line-col1, ls_line-col2.


Monday, July 24, 2017

How to read data in XML form via ABAP?

In one of my blog posts about Intermediate result of APD process a question was raised via comments. User asked where is ABAP code used in APD processes stored. Of course I replied back with the table name (RSANT_PROCESS) where the code can be found. Then the user replied back with another comment saying that field XML of that table is not completely readable as only first 131 characters is visible.

What can be visible in the XML field if the table if it is browsed via t-code like SE11 is something like:

This is really not complete ABAP code I mean not complete content of the field. The thing is that the database fields in xml format needs to be read differently.  It needs to decoded to human readable format. For this we can employ few SAP standard function modules. These are following ones:

SCMS_STRING_TO_XSTRING – converts texts (XML) to binary format, delivered within SAP SCMS (Content Management Service)

SMUM_XML_PARSE - parsing XML document into a table structure, delivered within User Management of SAP Markets (it was SAP initiative around year 2000 which later merged with SAP Portals).

Here complete example on how to read ABAP code for particular APD process in SAP BW system:


DATA: ls_rsant_process TYPE rsant_process,
      lv_xml           TYPE string,
      ls_xml_xstr      TYPE xstring,
      lt_result_xml    TYPE STANDARD TABLE OF smum_xmltb,
      ls_result_xml    TYPE smum_xmltb,
      lt_ret           TYPE STANDARD TABLE OF bapiret2,
      lo_alv           TYPE REF TO cl_salv_table,
      lo_col           TYPE REF TO cl_salv_columns_table,
      lo_fun           TYPE REF TO cl_salv_functions_list.

PARAMETERS: p_apd TYPE rsan_process OBLIGATORY.

SELECT SINGLE * FROM rsant_process INTO ls_rsant_process WHERE objvers = 'A' AND process = p_apd.
lv_xml = ls_rsant_process-xml.

CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
    EXPORTING
      text           = lv_xml
      mimetype       = 'text/xml'
   IMPORTING
     buffer         = ls_xml_xstr
   EXCEPTIONS
     failed         = 1
     others         = 2.

CALL FUNCTION 'SMUM_XML_PARSE'
  EXPORTING
    xml_input       = ls_xml_xstr
  TABLES
    xml_table       = lt_result_xml
    return          = lt_ret.

CALL METHOD cl_salv_table=>factory
  IMPORTING r_salv_table = lo_alv
  CHANGING t_table = lt_result_xml.

lo_col = lo_alv->get_columns( ).
lo_col->set_optimize( ) .
lo_fun = lo_alv->get_functions( ).
lo_fun->set_all( ).
CALL METHOD lo_alv->display.


Source code available at: github.com/softy12/ZMM_READ_XML_DATA

Tuesday, July 18, 2017

Scheduling Process Chains via copying its jobs

In my other blog post I mentioned how to schedule Process Chains with restrictions. This basically covers scenarios that things like SAP Factory calendar is used to base the scheduling on. Also this is about scenarios when the job shall not be executed on e.g. weekends-workdays etc.

Similarly there might be requirements on how to schedule the PC several times a day but there is no periodicity of these runs. Had it been the case periodicity is there than just a settings within job’s Start Time dialog box (like every minute/hour/day/…) can be leveraged -> see mu screenshot in here. These settings can be found under Periodic Values button in that pop-up window.

However as the periodicity is not given what can be done to schedule the job? Actually there is a possibility to just schedule one job for any given specific time and once there is a job scheduled via copying the job we replicate other schedules for the same PC for different start times that we need to have the PC running. This can be achieved via t-code SM37. There in its menu called Job there is an item Repeat scheduling available.

Once the job is copied just a start condition needs to be changed in the SM37 and that it!


Monday, July 17, 2017

How to check what is your SAP system type?

SAP system type is an function of the system in the SAP system group from the point of view of the Transport Organizer.

What is the SAP system type or sometimes referred as SAP system class can be revealed from parameters of SAP system. These parameters itself are normally set via system profile parameters function (t-codes RZ10 / RZ11).

1. transport/systemtype defines if the system belongs from a transport point-of-view to the world of SAP development systems (param value = SAP) or if it is a customer system (value = "CUSTOMER" and it is default value). The parameter is set during installation of the system. The parameter affects the transport behavior of the system (e.g. range of transport request numbers) on the correction system (working in the SAP namespace SSCR, etc.), and on upgrade behavior (keyword modifications).

2. auth/sap_test_system parameter indicates that the SAP system is special test system.  If so value of the param is set to ON.

3. auth/fa_test_system parameter indicates that the SAP system is type of test system marked as final assembly system. If so value is set to ON.
If any of these parameters are present in the SAP system it means that the system is based on ABAP Stack.


As alternative to t-codes RZ10 / RZ11 function module TR_SYS_PARAMS can be used to check of what is value of transport/systemtype among other technical information like System Change Option, SID, Change Option for Client-Dependent Customizing Objects, Change Option for Repository Objects in Logon Client, Client Role, Recording Client for Switch BC Sets.

Sunday, July 16, 2017

What is TLOGO in SAP BW terms?

I mentioned the TLOGO term in my previous post. I just add short explanation of what it means. The TLOGO just represents different BW object types. TLOGO most likely refers to Transportable Object Type. To dig deeper to that, there are always two logical transport objects that represents the BW objects. There are the objects:

·        customer

·        delivery TLOGO object

The BW writes the TLOGO object as per the system settings to the transport request when transporting the particular object.

For more details see domain RSTLOGO in data dictionary.

The different TLOGOs can be also spotted in t-code RSA1 in Metadata Repository.

As of version BW 74 there are following different BW object types present:


CTRT   Currency Translation Type
UOMT  Quantity Conversion Type
AREA   InfoArea
APCO  Application
ROUT  Routine
RSFO  BW Formula
IOBJ    InfoObject
IOBC   InfoObject Catalog
ODSO  DataStore Object (classic)
ADSO  DataStore Object (advanced)
CUBE   InfoCube
AGGR  Aggregate
HYBR   HybridProvider
LPOA   Semantically Partitioned Object
ISET    InfoSet
COPR  Local CompositeProvider
ODPE  Operational Data Provider (ESH-Based)
FBPA   Open ODS View
MPRO  MultiProvider
HCPR   CompositeProvider
ALVL   Aggregation Level
DAPA  Data Archiving Process
ISTD   3.x InfoSource
ISCS   Communication Structure
TRCS   InfoSource
UPDR  Update Rules
LSYS   Source System
ISFS   3.x DataSource
RSDS  DataSource
INSP   Inspection Plan
ISMP   Transfer Rules
ISTS   Transfer Structure
DEST   Open Hub Destination
ELEM   Query Element
HAAP   SAP HANA Analysis Process
TRFN   Transformation
ISIP    InfoPackage
ISIG    InfoPackage Group
RASE   Reporting Agent Setting
RAPA   Reporting Agent Scheduling Package
RRCA  RRI InfoCube Receiver
RRQA  RRI Query Receiver
XLWB  Workbook
SPOK  InfoSpoke
EVEN   Event Processing Chain
DDAS  Data Access Service
RSPT   Process Chain Starter
RSPI   Interrupt Process
WWPA Web Design Time Parameter Metadata
WWIB  Web Design Time Item Metadata
QVIW  Query View
EREL   Enterprise Report: Reusable Element
ERPT   Enterprise Report
ITEM   Web Item (Format SAP BW 3.x)
BITM   BEx Web Item
TMPL   Web Template (Format SAP BW 3.x)
BTMP  BEx Web Template
KPDF   KPI Definition
KPCE   KPI Catalog Entry
BRSE   Broadcast Setting
ANMO  Mining Model
ANSO  Model Source
DMMO Data Model (currently not used)
ANPR  Analysis Process
ACGR  Role
CRWB  Crystal Report
AQBG  InfoSet Query User Group
AQSG  InfoSet
AQQU  InfoSet Query
DTPA   Data Transfer Process
PLST   Planning Function Type
PLSE   Planning Function
PLSQ   Planning Sequence
THEM  Theme
PLCR   Characteristic Relationships
THJT   Key Date of Type Derivation
DMOD Data Flow
RSPV   Process Variants
RSPC   Process Chain
PLDS   Data Slices
ENHO  Enhancement/Append
ASOB  Analytics Security Object (BI Analysis Authorization)
RRUL   Remodeling Rule
RDAC  Configuration for Real-Time Data Acqusition
APPS   Appplication Set (BPC - Transport)
BIXP   Conversion Object
XCLS   Xcelsius Dashboard
AAOE  Analysis Office Excel Workbook
AAOP  Analysis Office PowerPoint
TRPR   Operational Data Provider
AZAP   Analysis Application
ENVM  BPC Unified Environment
MODL  BPC Model
TEAM  BPC Team
WKSP  BPC Workspace
BBPF   BPC BPF
BDAP  BPC Data Access Profile
AZEX   Design Studio Extension
AINX   Local Provider
AABC  AVA Global Setting
AADT  AVA Global Setting
AAPP   Model
AAPS   Environment
ABPC   Business Unit
ABPF   BPF
ABRU  Business Rule
ACGA  Configuration
ACGP  Configuration
ACGS  BPC System Configuration
ACLB   Library
ACTR   Control
ADAF  Data Access Profile
ADEE   BPC Deletion Enttiy
ADEI   Deletion Item
ADEL   BPC Deletion
ADIM   Dimension
ADMC  Data Manager Data File
ADMD  Data Manager File Folder
ADMF  Data Manager File
ADML  Data Manager Package Link
ADMP  Data Manager Package
ADTG  Drill Through
AFLD   File Folder
AFLE   Files
AFLG   Business Unit
AFLC   Category
AJUT   Journal Template
AKPI   AVA KPI Setting
AMBR  Dimension member
AMPF  ToBeDeleted
ARTP   Templates
ASPD  Script Folder
ASPF   Script File
ASPR   Script Logic
ATEM  Team
ATPF   Task Profile

AWSS  Workstatus