routine to fetch current day's filename , infopackage routine

13
How to write routine to fetch current day's filename Applies to: SAP BI 7.0 developers for carrying out tasks related to data loading and monitoring. Summary This document provides step by step approach to create infopackage/ datasource routine to fetch current day's file name present on the application server. Author(s): Sanjeev Singh Company: Vridhi Softech Services Private Limited, India. Created on: 24 December 2015 Author Bio Sanjeev Singh is a SAP BI Consultant at Vridhi Softech Services Private Limited, India. Business Scenario You have been tasked to load files available on application server on daily basis. File name contains the date appended to it which matches system date. You have not been able to identify a standard procedure that will accomplish this task for you. You need to deliver a solution to appropriately generate file names on daily basis through infopackage and load them to specified data targets.

Upload: sanjeev-singh

Post on 27-Jan-2016

280 views

Category:

Documents


2 download

DESCRIPTION

Routine to Fetch Current Day's Filename , Infopackage Routine

TRANSCRIPT

Page 1: Routine to Fetch Current Day's Filename , Infopackage Routine

How to write routine to fetch current day's filename

Applies to:

SAP BI 7.0 developers for carrying out tasks related to data loading and monitoring.

Summary

This document provides step by step approach to create infopackage/ datasource routine to fetch current day's file name present on the application server. 

Author(s):    Sanjeev Singh

Company:   Vridhi Softech Services Private Limited, India.

Created on: 24 December 2015

Author Bio

Sanjeev Singh is a SAP BI Consultant at Vridhi Softech Services Private Limited, India.

Business Scenario

You have been tasked to load files available on application server on daily basis.

File name contains the date appended to it which matches system date. You have not been able to identify a standard procedure that will accomplish this task for you.

You need to deliver a solution to appropriately generate file names on daily basis through infopackage and load them to specified data targets.

Introduction

Within SAP-BI system there are info package routines available under "Extraction" tab page in datasource as well as in Infopackage 

which can be leveraged to capture file names as per current system date through the use of customized ABAP routine to generate file name

Procedure

1. Create Generic Datasource for flatfile source system.2. Go to external tab page and maintain specific settings for Adapter and File name.3. Write an ABAP routine to fetch current day's file available on the Application server.

Page 2: Routine to Fetch Current Day's Filename , Infopackage Routine

4. Activate datasource and preview the records present in the file.5. Create an infopackage with similar setting as that of datasource.6. Schedule the infopackage and monitor to view file records in PSA.

Prerequisite

Files should be placed on Application server with naming convention such as <File Name>+<Current Day(YYYYMMDD)>

1.      Create Generic Datasource for flatfile source system.

The flat file datasource allows you to capture the file fields information and then to load data into the BI system.

1.Navigate to Source Systems->File. Expand File to select Flat file source system.

2.Double Click Flat File and create a datasource in appropriate Application Component.

Page 3: Routine to Fetch Current Day's Filename , Infopackage Routine

   

3.Enter the Description and type of Datasource

Page 4: Routine to Fetch Current Day's Filename , Infopackage Routine

4.Fill out the details in the " General"  tab page for datasource

 

2.       Go to "Extraction" tab page and maintain specific settings for Adapter and File name.

 In this tab page you need to fill in settings related to Delta Process, Adapter and routine for generating file name

Page 5: Routine to Fetch Current Day's Filename , Infopackage Routine

 1.Enter the details for Adapter and Click on routine to generate a file name

3.       Write an ABAP routine to fetch current day's file available on the Application server.

1.Enter the name for routine.

 

Page 6: Routine to Fetch Current Day's Filename , Infopackage Routine

2.Click Editor and write code in the space provided in ABAP editor.

 

3.Below is the ABAP code which is to be written at DataSource"Extraction" tabpage to fetch file name:program filename_routine.program filename_routine.program filename_routine.

  Global code

$$ begin of global - insert your declaration only below this line  - Enter here global variables and type declarations as well as additional form routines, which you may call from the main routine COMPUTE_FLAT_FILE_FILENAME below

*TABLES: ... DATA:   ...

*$$ end of global - insert your declaration only before this line   *- 

Page 7: Routine to Fetch Current Day's Filename , Infopackage Routine

-------------------------------------------------------------------form compute_flat_file_filename  using    p_infopackage  type rslogdpid           p_datasource   type rsoltpsourcer           p_logsys       type rsslogsys  changing p_filename     type RSFILENM           p_subrc        like sy-subrc.$$ begin of routine - insert your code only below this line        -

This routine will be called by the adapter,o when the infopackage is executed.

  DATA Z_FILENAME TYPE RSFILENM.  DATA ZFILE_13(100).  DATA: ZDATE LIKE SY-DATUM,        DD(2),        MM(2),        YY(4).  ZDATE = SY-DATUM.  Z_FILENAME =  'Application Server Path\<Filename>'.  YY = ZDATE+0(4).  MM = ZDATE+4(2).  DD = ZDATE+6(2).   CONCATENATE YY MM DD INTO ZFILE_13.  CONCATENATE Z_FILENAME '' ZFILE_13 '' '.csv' INTO Z_FILENAME.  p_filename = Z_FILENAME.p_subrc = 0.$$ end of routine - insert your code only before this line         -endform.

4.       Activate datasource and preview the records present in the file.

Page 8: Routine to Fetch Current Day's Filename , Infopackage Routine

5.       Create an infopackage with similar setting as that of datasource.

Page 9: Routine to Fetch Current Day's Filename , Infopackage Routine

1. Right click on datasource to create infopackage.

Page 10: Routine to Fetch Current Day's Filename , Infopackage Routine

2. Maintain all Infopackage settings similar to the one defined at the datasource level for fetching filename through 'ZTEST' routine.

6.       Schedule the infopackage and monitor to view file records in PSA.

1. Keep default settings for infopackage, go to Schedule tab and click on Start for dataloading.Alternatively, you can include the infopackag at process chain level as per your design

Page 11: Routine to Fetch Current Day's Filename , Infopackage Routine

consideration.

Page 12: Routine to Fetch Current Day's Filename , Infopackage Routine

2. Once load finishes successfully, click on Monitor to view and verify the records as per the file available on the application server.