Upload Flat File in SAP-BI-BW
Upload Flat File in SAP-BI-BW
Upload Flat File in SAP-BI-BW
Applies to:
SAP BI/BW
Summary
This Article demonstrates the step by step process to upload Flat file to an ABAP Table then load the same
into SAP BI/BW objects via process
Author:
Obaidullah Shaikh
Company: AG Technologies
Created on: 15 September 2011
Author Bio
Obaidullah shaikh is a SAP BI Consultant with AG Technologies. He has good skill in technical
areas (ABAP) and he has experience of multiple custome reports development and has
experience of Migration/upgradation projects as well.
Table of Contents
Introduction ......................................................................................................................................................... 3
Create table ........................................................................................................................................................ 3
ABAP Program ................................................................................................................................................... 4
Create Data source ............................................................................................................................................. 6
Replicate that Datasource .................................................................................................................................. 7
Create Transformation ........................................................................................................................................ 7
Create Info Package ........................................................................................................................................... 8
Create DTP ......................................................................................................................................................... 8
Create Process chain ......................................................................................................................................... 9
Create an Event ................................................................................................................................................ 10
Start Condition of Process Chain .................................................................................................................. 10
Schedule the process chain .......................................................................................................................... 10
Create a T-Code ............................................................................................................................................... 11
Run that T-Code ............................................................................................................................................... 12
Select File ......................................................................................................................................................... 12
Check the Chain log ......................................................................................................................................... 13
Related Content ................................................................................................................................................ 14
Disclaimer and Liability Notice .......................................................................................................................... 15
Introduction
Most of the companies are maintaining some of the transactions in Flat file (Excel Sheet) and they want to
load that flat file to SAP BI, there are multiple ways to load Flat file into BW.
BI consultant will maintain the Data flow for that flat file and whenever file will come via an email or
any other way, BI person will load it manually on daily basis but this is not the right way to load flat
file.
BI consultant uses any tool to transfer the file from client to Application server and load from there
via process chain. But this is also not a best practice in all the types of operating system specially
Windows. Because while transferring the file virus will also move and that will create problem in
server so the best way is to transfer it via ABAP Code.
This document will discuss how can load data from file to ABAP table and then we will load the same
to BI object.
User just needs to run a Transaction code and select the corresponding file, he want to load.
Create table
Create a table in BW that will store the records structure of that table will same as flat file
ABAP Program
Write the following ABAP program in SE38
DATA S_FILE TYPE STRING.
To Get Path of csv file that need to loaded in BI
CALL FUNCTION 'WS_FILENAME_GET'
IMPORTING
FILENAME
= S_FILE.
ZTEST is ABAP TABLE in SAP BI System that will store the records coming from Flat file
TABLES ZTEST.
DATA: BEGIN OF WA1,
MAT(18) TYPE C,
PLANT(5) TYPE C,
END OF WA1,
ITAB LIKE TABLE OF WA1,
WA_FINAL LIKE ZTEST,
ITAB_FINAL LIKE TABLE OF WA_FINAL.
DATA STR TYPE STRING.
DELETE FROM ZTEST.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME
FILETYPE
= S_FILE
= 'ASC'
HAS_FIELD_SEPARATOR
= 'X'
TABLES
DATA_TAB
= ITAB .
DATA J TYPE I.
DATA L TYPE I.
CLEAR STR.
"The Following code will convert the data from internal table to Database Table
LOOP AT ITAB INTO WA1.
L = STRLEN( WA1-MAT ).
Since data is Comma separated that's why a record will be a string
e.g. M01, 1000 will be a single string that needs to be separated depending upon
"Commas in between the string
WHILE WA1-MAT+J(1) <> ',' .
CONCATENATE STR WA1-MAT+J(1) INTO STR.
J = J + 1.
ENDWHILE.
WA_FINAL-MAT = STR.
CLEAR STR.
J = J + 1.
WHILE J < L .
CONCATENATE STR WA1-MAT+J(1) INTO STR.
J = J + 1.
ENDWHILE.
WA_FINAL-PLANT = STR.
CLEAR STR.
APPEND WA_FINAL TO ITAB_FINAL.
J = 0.
INSERT INTO ZTEST VALUES WA_FINAL.
ENDLOOP.
"FM to Trigger Event that will trigger Process chain of Data load
DATA EVENT TYPE STRING.
EVENT = 'ZPATH_IP'.
CALL FUNCTION 'BP_EVENT_RAISE'
EXPORTING
EVENTID
= EVENT
You can also maintain generic delta also in this data source
Create Transformation
Create DTP
Create an Event
Create an event from SM64 that will trigger Chain.
Create a T-Code
Create a T-code from SE93. User will just need to run this t-code
Enter descrition and select start object as Program and selection screen(report transaction)
Select File
After running the T-code, A dialog will pop-up to select the file that is going to be loaded
Related Content
http://forums.sdn.sap.com/thread.jspa?threadID=1281874
https://www.sdn.sap.com/irj/scn/wiki?path=/display/SCM/Move%252ba%252bfile%252bfrom%252bsourc
e%252bto%252btarget%252bdirectories%252bin%252bAPO
https://www.sdn.sap.com/irj/scn/thread?messageID=7224879#7224879