routine to fetch current day's filename , infopackage routine

Download Routine to Fetch Current Day's Filename , Infopackage Routine

Post on 27-Jan-2016

218 views

Category:

Documents

1 download

Embed Size (px)

DESCRIPTION

Routine to Fetch Current Day's Filename , Infopackage Routine

TRANSCRIPT

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.SummaryThis 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 SinghCompany: Vridhi Softech Services Private Limited, India.Created on: 24 December 2015 Author BioSanjeev Singh is a SAP BI Consultant at Vridhi Softech Services Private Limited, India.Business ScenarioYou 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.IntroductionWithin SAP-BI system there are info package routines available under "Extraction" tab page in datasource as well as in Infopackagewhich can be leveraged to capture file names as per current system date through the use of customized ABAP routine to generate file nameProcedure1. 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.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.PrerequisiteFiles should be placed on Application server with naming convention such as +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.

3.Enter the Description and type of Datasource

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 1.Enter thedetails for Adapter and Click on routineto generate a file name 3. Write an ABAP routine to fetch current day's file available on the Application server.1.Enter thename for routine. 2.Click Editor and write code in the space provided in ABAP editor.

3.Below is the ABAP code whichis 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 *- -------------------------------------------------------------------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, 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\'. 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.

5. Create an infopackage with similar setting as that of datasource.1. Right click on datasource to create infopackage.

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 consideration. 2. Once load finishes successfully, click on Monitor to view and verify the records as per the file available on the application server.