Escolar Documentos
Profissional Documentos
Cultura Documentos
Preliminary Program
Applies to:
SAP Business Intelligence 7.0. For more information, visit the Business Intelligence homepage.
Summary
The advantage of uploading flat files is the flexibility. This means that all kinds of sources of data can be
used to provide data for the SAP BI application. Flat files have also some particularities. Amongst them are
easy changes in the file structure, redundant data, lines without data and information in the filename. To
handle these particularities some considerations can be useful.
Author Bio
Guy Mathys enables companies to obtain information from SAP Business Intelligence (SAP
NetWeaver BW - SAP BI) for the last five years.
Table of Contents
Reason of a preliminary program ....................................................................................................................... 3
Functionalities ..................................................................................................................................................... 3
Details of the functionalities ................................................................................................................................ 4
Get a file. ......................................................................................................................................................... 4
Read data record ............................................................................................................................................ 5
Define delimiter ............................................................................................................................................... 5
Check on allowed characters .......................................................................................................................... 5
Check on records with all fields empty............................................................................................................ 5
Check on comma as field separator and as decimal. ..................................................................................... 6
Read data of the record into a table................................................................................................................ 6
Check field types ............................................................................................................................................. 7
Include filename in a field ............................................................................................................................... 7
Write the record............................................................................................................................................... 8
Other considerations........................................................................................................................................... 8
Related Content .................................................................................................................................................. 9
Help.sap.com .................................................................................................................................................. 9
Articles............................................................................................................................................................. 9
Blogs ............................................................................................................................................................... 9
Disclaimer and Liability Notice .......................................................................................................................... 10
Functionalities
A preliminary can handle several functionalities. The first group is getting the data. Then there is a checking
and converting the characters, fields and their separators and checking and skipping records. A whole file
can also be rejected. The last group is writing an improved file ready for upload. This all can be done
generating error messages.
1. Get a file.
This is to get a file based on the directory WA_DRCTR and file mask WA_FLMSK.
2. Read data record
Opens the dataset reads a record, closes the dataset .
3. define delimiter
The delimiter can be used to add fields later.
4. Check on allowed characters
Put the allowed characters in a work area. Replaces the not allowed character by a 0.
5. Check on records with all fields empty
Checks if the first 5 characters contains not a delimiter. If it does not contain delimiters it continues.
6. Check on comma as field separator and as decimal.
Some csv files have comma as a field separator. on top of that the comma is also used a the decimal sign.
For instance some records are like
Field1,”123,45”,Field3
This removes the inverted comma and changes the decimal comma in a decimal point.
7. Read data of the record into a table
This is useful to manipulate data in a table. This can be the check of field types.
8. Check field types
This checks the field type date , numeric, character of a field based on parameters in an internal table.
9. Include filename in a field
This enables to load the filename into a DSO and use it or part of it; For instance to exploit the date
timestamp that is in it.
10. Write the record
This writes a check record in the new file. This new file will be used to load.
Get a file.
This is to get a file based on the directory WA_DRCTR and file mask WA_FLMSK.
* The first file that matches the pattern
CALL 'C_SAPGPARAM'
ID 'NAME' FIELD WA_DRCTR
ID 'VALUE' FIELD WA_DIR_VALUE.
CALL 'C_DIR_READ_FINISH' " just to be sure
ID 'ERRNO' FIELD WA_FILE_ERRNO
ID 'ERRMSG' FIELD WA_FILE_ERRMSG.
CALL 'C_DIR_READ_START'
ID 'DIR' FIELD WA_DRCTR
ID 'FILE' FIELD WA_FLMSK
ID 'ERRNO' FIELD WA_FILE_ERRNO
ID 'ERRMSG' FIELD WA_FILE_ERRMSG.
IF SY-SUBRC <> 0.
ENDIF.
DO.
CALL 'C_DIR_READ_NEXT'
ID 'TYPE' FIELD WA_FILE_TYPE
ID 'NAME' FIELD WA_FILENAME
ID 'LEN' FIELD WA_FILE_LEN
ID 'OWNER' FIELD WA_FILE_OWNER
ID 'MTIME' FIELD WA_FILE_MTIME
ID 'MODE' FIELD WA_FILE_MODE
ID 'ERRNO' FIELD WA_FILE_ERRNO
ID 'ERRMSG' FIELD WA_FILE_ERRMSG.
IF SY-SUBRC = 0.
IF WA_FILE_TYPE(1) = 'f' OR " regular file
WA_FILE_TYPE(1) = 'F'.
EXIT.
ENDIF.
ELSEIF SY-SUBRC = 1.
RAISE FILE_NOT_FOUND.
EXIT.
ELSE.
ENDIF.
ENDDO.
Define delimiter
The delimiter can be used to add fields later.
IF WA_SPRTR IS INITIAL.
IF WA_LINE CA C_SMCLMN.
WA_SPRTR = C_SMCLMN.
ELSE.
WA_SPRTR = C_CMM.
ENDIF.
ENDIF.
ENDIF.
ESCAPE_NO_CLOSE = 1
ESCAPE_IMPROPER = 2
CONVERSION_ERROR = 3.
Other considerations
Amongst other considerations that will be explained later are:
• Using DSO for redundant data
• Making data uniform
• Using parameters
• Using file masks
• Sizing of data packages
• Limiting number of processes
• Converting xml to an internal table.
Related Content
Help.sap.com
Creating DataSources for File Source Systems
http://help.sap.com/saphelp_nw2004s/helpdata/en/43/01ed2fe3811a77e10000000a422035/frameset.htm
Articles
Gaurav Paul , Data Upload from Flat File to Business Intelligence 7.0 System
https://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/60debae1-84dd-2b10-e7bf-
bdedf1eabdf9&overridelayout=true
Aveek Ghose ,Flat File Interfaces in SAP
https://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/c0341dc1-515c-2910-f99b-
b575e9f74671&overridelayout=true
Anurag Krishna Dev , Making Flat File Data Sources Delta Capable By Using Routine In Info package
Selection.
https://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/a0b3f0e2-832d-2c10-1ca9-
d909ca40b54e&overridelayout=true
Blogs
Loading Text Files(.TXT) into BW with HEX option
https://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/4676
Hierarchy Upload from Flat files
https://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/3113
Binary File in BW: what I can do with control file
https://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/4803
How-to... Load a File into SAP NetWeaver BI Integrated Planning (Part 1)
https://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/6671
How-to... Load a File into SAP NetWeaver BI Integrated Planning (Part 2)
https://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/7708