Skip to Content

Applies to

SAP Business Warehouse 7.0

Summary

In a BW support environment often there is a requirement to find the OHD or InfoSpoke from the name of the file it generates. This paper tries to address this problem with a simple and quick solution.

Author:        Rahul Rajagopalan Nair

Company:    Infosys

Created on:  12 March 2012

Author Bio

RN.jpg

Rahul is an SAP BI Consultant with Infosys with 5 years of experience. ABAP, BW Performance optimization and SAP Business Objects are his areas of interest.

Problem Statement

BW interacts with a lot of systems. Often the data is sent to SAP and Non SAP systems from BW by means of flat files. And OHDs and InfoSpokes are the primarily used for this purpose.

In a support environment I have encountered many situations where teams wait for a file to be sent from BW to their systems. And in most cases the affected team just knows the filename. In such cases the first thing that the BW support team needs to do is quickly find out which OHD or InfoSpoke generates the file.

Logic

In BW the file names are stored in a structured format. The logical path acts a technical name that holds the actual file path. E.g. the physical filename “ZCUSTSATTR_01_CUST_<DATE>_<TIME>.CSV” is stored with logical filename “ZCUSTSATTR_01_CUST”.

To generate the file on an application server, an OHD or an InfoSpoke utilizes the logical file name. E.g. OHD “ZCUSTSSLS” generates file at location “ZCUSTSATTR_01_CUST”.

Solution

The idea is to create a program that gets a list of OHDs & InfoSpokes from a filename. The program should be flexible enough to search not only based on logical names but also physical file names.

The program Z_BW_OHD_FILE – “Find OHD or InfoSpoke from File Name or File Path” makes use of tables RSBFILE & RSBSPOKE to find information about OHD/InfoSpoke and table FILENAMECI for information on file names & paths.

The code along with the selection texts is given in the ABAP Code section of this document.

User Guide

Search based on file name:

UG1.jpg

UG2.jpg

Search based on Logical File name

UG3.jpg

UG4.jpg

ABAP Code

*&———————————————————————*
*& Report  Z_OHD_FILE
*&
*&——————————————————————–&*
*& ABAP Name   : Z_OHD_FILE                                        &*
*& Changed By  : Rahul Rajagopalan Nair                               &*
*& Created On  : 02/17/2012                                           &*
*& Version     : 1.0                                                  &*
*& Description : This program will find a list of all OHDs            &*
*&               or InfoSpokes based on a file name/file path         &*
*&———————————————————————*

REPORT  Z_OHD_FILE.

*$***********************************************************************
*$*$  TABLES
*$*$*********************************************************************
TABLES :
RSBFILE, FILENAMECI.

*$***********************************************************************
*$*$  TYPE-POOLS
*$*$*********************************************************************
TYPE-POOLS :
SLIS.

*$***********************************************************************
*$*$  TYPE DEFINITIONS
*$*$*********************************************************************
TYPES :

BEGIN OF TY_FILE,
FILEINTERN 
TYPE FILENAME-FILEINTERN,
FILEEXTERN 
TYPE FILENAME-FILEEXTERN,
END OF TY_FILE,

BEGIN OF TY_RSBFILE,
OHDEST     
TYPE RSBFILE-OHDEST,
FILEINTERN 
TYPE RSBFILE-FILEINTERN,
END OF TY_RSBFILE,

BEGIN OF TY_RSBSPOKE,
INFOSPOKE  
TYPE RSBSPOKE-INFOSPOKE,
OHDEST     
TYPE RSBSPOKE-OHDEST,
END OF TY_RSBSPOKE,

BEGIN OF TY_OPTAB,
OHDEST     
TYPE RSBSPOKE-OHDEST,
DTYPE      
TYPE CHAR20,
FILEINTERN 
TYPE RSBFILE-FILEINTERN,
FILEEXTERN 
TYPE FILENAME-FILEEXTERN,
END OF TY_OPTAB.

*$***********************************************************************
*$*$  DATA DECLARATION
*$*$*********************************************************************

DATA :
IT_FILE    
TYPE STANDARD TABLE OF TY_FILE,
WA_FILE    
TYPE                   TY_FILE,
IT_RSBFILE 
TYPE STANDARD TABLE OF TY_RSBFILE,
WA_RSBFILE 
TYPE                   TY_RSBFILE,
IT_RSBSPOKE
TYPE STANDARD TABLE OF TY_RSBSPOKE,
WA_RSBSPOKE
TYPE                   TY_RSBSPOKE,
IT_OPTAB   
TYPE STANDARD TABLE OF TY_OPTAB,
WA_OPTAB   
TYPE                   TY_OPTAB.

DATA :
IT_FIELDCAT  
TYPE SLIS_T_FIELDCAT_ALV,
WA_FIELDCAT  
TYPE SLIS_FIELDCAT_ALV.   “Field Catalog

DATA :
LV_ERR_MSG   
TYPE STRING.

*$***********************************************************************
*$*$  SELECTION SCREENS
*$*$*********************************************************************

SELECTION-SCREEN BEGIN OF BLOCK SB1 WITH FRAME TITLE TEXT-T01.
PARAMETERS :
R_FILE       
RADIOBUTTON GROUP rb1 USER-COMMAND com MODIF ID mod,
R_FNAM       
RADIOBUTTON GROUP rb1 DEFAULT ‘X’.
SELECTION-
SCREEN END   OF BLOCK SB1.

SELECTION-SCREEN BEGIN OF BLOCK SB2 WITH FRAME TITLE TEXT-T02.
SELECT-OPTIONS :
SO_FILE       
FOR RSBFILE-FILEINTERN DEFAULT ‘ZPLANTATTR_01_PLANT’.
SELECTION-
SCREEN END   OF BLOCK SB2.

SELECTION-SCREEN BEGIN OF BLOCK SB3 WITH FRAME TITLE TEXT-T03.
SELECT-OPTIONS :
SO_FNAM       
FOR FILENAMECI-FILEEXTERN DEFAULT ‘ZCUSTSATTR_01_CUST_<DATE>_<TIME>.CSV’.
SELECTION-
SCREEN END   OF BLOCK SB3.

*$***********************************************************************
*$*$  DYNAMIC SELECTION SCREEN OPTIONS
*$*$*********************************************************************

AT SELECTION-SCREEN OUTPUT .“ON RADIOBUTTON GROUP rb1.
“AT SELECTION-SCREEN ON RADIOBUTTON GROUP rb1.
LOOP AT SCREEN.

IF R_FILE EQ ‘X’.

IF SCREEN-NAME CS ‘SO_FNAM’.

SCREENINPUT = 0.

MODIFY SCREEN.

ENDIF.

ENDIF.

IF R_FNAM EQ ‘X’.

IF SCREEN-NAME CS ‘SO_FILE’.

SCREENINPUT = 0.

MODIFY SCREEN.

ENDIF.

ENDIF.

ENDLOOP.

ENDOF-SELECTION.

*$***********************************************************************
*$*$  PROGRAM LOGIC
*$*$*********************************************************************

IF R_FNAM = ‘X’.

“Search Based on File Name
“Name -> Path -> OHD/InfoSpoke

“Get File Paths from Names
SELECT FILEINTERN
FILEEXTERN
FROM FILENAMECI
INTO TABLE IT_FILE
WHERE FILEEXTERN IN SO_FNAM.

CHECK SY-SUBRC EQ 0.

SORT IT_FILE
BY FILEINTERN ASCENDING.

IF IT_FILE[] IS NOT INITIAL.

“Get OHD/InfoSpok from Paths
SELECT OHDEST
FILEINTERN
FROM RSBFILE
INTO TABLE IT_RSBFILE
FOR ALL ENTRIES IN IT_FILE
WHERE FILEINTERN = IT_FILE-FILEINTERN
AND OBJVERS = ‘A’.

CHECK SY-SUBRC EQ 0.

ENDIF.

ELSE.

“R_FILE = ‘X’.

“Search Based on File Path
“Path -> OHD/InfoSpoke
”        Path -> File Name

“Get OHDs/Infospkes basedon Path
SELECT OHDEST
FILEINTERN
FROM RSBFILE
INTO TABLE IT_RSBFILE
WHERE FILEINTERN IN SO_FILE
AND OBJVERS = ‘A’.

CHECK SY-SUBRC EQ 0.

IF IT_RSBFILE[] IS NOT INITIAL.

“Get File Names from Paths
SELECT FILEINTERN
FILEEXTERN
FROM FILENAMECI
INTO TABLE IT_FILE
FOR ALL ENTRIES IN IT_RSBFILE
WHERE FILEINTERN = IT_RSBFILE-FILEINTERN.

SORT IT_FILE
BY FILEINTERN ASCENDING.

ENDIF.

ENDIF.

“Get all Info Spokes from RSBSPOKE for all entries in RSBFILE for field OHDEST
SELECT  INFOSPOKE
OHDEST
FROM RSBSPOKE
INTO TABLE IT_RSBSPOKE
FOR ALL ENTRIES IN IT_RSBFILE
WHERE OHDEST = IT_RSBFILE-OHDEST
AND OBJVERS = ‘A’.

SORT IT_RSBSPOKE
BY OHDEST ASCENDING.

LOOP AT IT_RSBFILE INTO WA_RSBFILE .

CLEAR WA_OPTAB.
CLEAR WA_RSBSPOKE.
CLEAR WA_FILE.

“Get File Name from File Path
READ TABLE IT_FILE
INTO WA_FILE
WITH KEY FILEINTERN = WA_RSBFILE-FILEINTERN
BINARY SEARCH.

IF SY-SUBRC = 0.

WA_OPTAB-FILEEXTERN = WA_FILE-FILEEXTERN.

ENDIF.

“Check if InfoSpoke
READ TABLE IT_RSBSPOKE
INTO WA_RSBSPOKE
WITH KEY OHDEST = WA_RSBFILE-OHDEST
BINARY SEARCH.

IF SY-SUBRC = 0.
“This is an Info Spoke
“Assign Infospke field to DEST Field

WA_OPTAB-OHDEST     = WA_RSBSPOKE-INFOSPOKE.
WA_OPTAB-FILEINTERN = WA_RSBFILE-FILEINTERN.
WA_OPTAB-DTYPE      = ‘INFOSPOKE’.

APPEND WA_OPTAB TO IT_OPTAB.

ELSE.
“This is an OHD

WA_OPTAB-OHDEST     = WA_RSBFILE-OHDEST.
WA_OPTAB-FILEINTERN = WA_RSBFILE-FILEINTERN.
WA_OPTAB-DTYPE      = ‘OHD’.

APPEND WA_OPTAB TO IT_OPTAB.

ENDIF.

ENDLOOP.

*$***********************************************************************
*$*$  DISPLAY OUTPUT
*$*$*********************************************************************

“*****************************************************************************
“Display – Start

CLEAR  WA_FIELDCAT.

WA_FIELDCAT-COL_POS       = 1.
WA_FIELDCAT-FIELDNAME     =
‘OHDEST’.
WA_FIELDCAT-REPTEXT_DDIC  =
‘OHD or InfoSpoke ‘.
WA_FIELDCAT-OUTPUTLEN     =
30.
WA_FIELDCAT-
KEY           = ‘X’.
WA_FIELDCAT-TABNAME       =
‘IT_OPTAB’.
APPEND WA_FIELDCAT
TO IT_FIELDCAT.
CLEAR  WA_FIELDCAT.

WA_FIELDCAT-COL_POS       = 2.
WA_FIELDCAT-FIELDNAME     =
‘DTYPE’.
WA_FIELDCAT-REPTEXT_DDIC  =
‘Type’.
WA_FIELDCAT-OUTPUTLEN     =
20.
WA_FIELDCAT-TABNAME       =
‘IT_OPTAB’.
APPEND WA_FIELDCAT
TO IT_FIELDCAT.
CLEAR  WA_FIELDCAT.

WA_FIELDCAT-COL_POS       = 3.
WA_FIELDCAT-FIELDNAME     =
‘FILEINTERN’.
WA_FIELDCAT-REPTEXT_DDIC  =
‘Logical File Path’.
WA_FIELDCAT-OUTPUTLEN     =
40.
WA_FIELDCAT-TABNAME       =
‘IT_OPTAB’.
APPEND WA_FIELDCAT
TO IT_FIELDCAT.
CLEAR  WA_FIELDCAT.

WA_FIELDCAT-COL_POS       = 4.
WA_FIELDCAT-FIELDNAME     =
‘FILEEXTERN’.
WA_FIELDCAT-REPTEXT_DDIC  =
‘File Name’.
WA_FIELDCAT-OUTPUTLEN     =
40.
WA_FIELDCAT-TABNAME       =
‘IT_OPTAB’.
APPEND WA_FIELDCAT
TO IT_FIELDCAT.
CLEAR  WA_FIELDCAT.

CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’
EXPORTING
I_CALLBACK_PROGRAM                =
‘SY-REPID’
I_GRID_TITLE                      =
‘OHD / InfoSpoke Filenames’
IT_FIELDCAT                       = IT_FIELDCAT
TABLES
T_OUTTAB                          = IT_OPTAB
EXCEPTIONS
PROGRAM_ERROR                     =
1
OTHERS                            = 2
.
IF SY-SUBRC <> 0.
CASE SY-SUBRC.
WHEN 1.
LV_ERR_MSG  =
‘Program Error During List Generation’.
WHEN 2.
LV_ERR_MSG  =
‘Unknown Error During List Generation’.
WHEN OTHERS.
LV_ERR_MSG  =
‘Other erros’.
ENDCASE.

MESSAGE LV_ERR_MSG TYPE ‘E’.
ENDIF.

“Display – End
“*****************************************************************************

Text Elements

Selection Texts:

ST1.jpg

Text Symbols:

ST2.jpg

 
 

Acknowledgements

I would like to thank Ravi Siddharth Gopalan, Ramji Krishnamoorthy, Anuj Srivastava, Twinkle Gupta, Tilak Marrapu, Ram Garigipati, Prakash Gundupalli and my entire team for their constant support and encouragement.

To report this post you need to login first.

1 Comment

You must be Logged on to comment or reply to a post.

Leave a Reply