Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Upload Flat File in SAP-BI-BW

Download as pdf or txt
Download as pdf or txt
You are on page 1of 15

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.

SAP COMMUNITY NETWORK


2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com


1

Upload Flat File in SAP BI/BW

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

SAP COMMUNITY NETWORK


2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com


2

Upload Flat File in SAP BI/BW

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

SAP COMMUNITY NETWORK


2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com


3

Upload Flat File in SAP BI/BW

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.

SAP COMMUNITY NETWORK


2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com


4

Upload Flat File in SAP BI/BW

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

SAP COMMUNITY NETWORK


2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com


5

Upload Flat File in SAP BI/BW

Create Data source


Create a DataSource in SAP BI (RSO2 T-code)

You can also maintain generic delta also in this data source

SAP COMMUNITY NETWORK


2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com


6

Upload Flat File in SAP BI/BW

Replicate that Datasource


Replicate the Datasource from RSDS and activate it

Create Transformation

SAP COMMUNITY NETWORK


2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com


7

Upload Flat File in SAP BI/BW

Create Info Package

Create DTP

SAP COMMUNITY NETWORK


2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com


8

Upload Flat File in SAP BI/BW

Create Process chain

SAP COMMUNITY NETWORK


2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com


9

Upload Flat File in SAP BI/BW

Create an Event
Create an event from SM64 that will trigger Chain.

Start Condition of Process Chain

Schedule the process chain

SAP COMMUNITY NETWORK


2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com


10

Upload Flat File in SAP BI/BW

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)

Enter the ABAP Program name (ZINS_PATH)

SAP COMMUNITY NETWORK


2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com


11

Upload Flat File in SAP BI/BW

Run that T-Code

Select File
After running the T-code, A dialog will pop-up to select the file that is going to be loaded

SAP COMMUNITY NETWORK


2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com


12

Upload Flat File in SAP BI/BW

Check the Chain log


Data is successfully loaded to BW

SAP COMMUNITY NETWORK


2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com


13

Upload Flat File in SAP BI/BW

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

SAP COMMUNITY NETWORK


2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com


14

Upload Flat File in SAP BI/BW

Disclaimer and Liability Notice


This document may discuss sample coding or other information that does not include SAP official interfaces and therefore is not
supported by SAP. Changes made based on this information are not supported and can be overwritten during an upgrade.
SAP will not be held liable for any damages caused by using or misusing the information, code or methods suggested in this document,
and anyone using these methods does so at his/her own risk.
SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the content of this technical article or
code sample, including any liability resulting from incompatibility between the content within this document and the materials and
services offered by SAP. You agree that you will not hold, or seek to hold, SAP responsible or liable with respect to the content of this
document.

SAP COMMUNITY NETWORK


2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com


15

You might also like