Posted: Sat Apr 12, 2008 10:25 am Post subject: using BW BAPI's to load data into Cube from SpreadSheets
1 Requirement Description
We had a requirement to load data from a Spread sheet directly onto a Cube through an ABAP Program using the BAPI s in SAP BW.
We required a dialog screen to give location of file and to mention whether the load is Plan or Actual. Plan data load would delete the previous loads and Actual would add upon the data. This is done by the settings at the info package level.
Once the code is executed it loads file on the application server, and executes the following BAPI s to load data onto the cube.
2 Relation Function List
BAPI_IPAK_GETLIST - We pass the name of the Info source and Source system to get the list of related info packages.
BAPI_IPAK_GETDETAIL - It is used to get details of the listed info packages
BAPI_IPAK_START - We pass the required info package name to start the load.
BAPI_ISREQUEST_GETSTATUS - To check the status of the request after an elapsed time and show a message regarding the same.
I am not an experienced ABAPer so the code has a lot of room for improvements, but as a BW guy I wanted to share the code because it was rather difficult in finding help on how to use the BAPI's
3 SourCode list:
Code:
REPORT FILEUPLOAD.
data: w_dataset(255) value <path and file name on Application server>,
req(30) type c,
stt type c,
g_t_data type STANDARD TABLE OF <same as transfer Structure>
with header line."#EC
data: int_message type standard table of BAPIRET2 with header line.
"#EC
* Declaration for BAPI_IPAK_GETLIST
data: int_ins type standard table of BAPI6102SL with header line,
int_infopac type standard table of BAPI6109L with header line,
int_msg type standard table of BAPIRET2 with header line,
int_src type standard table of BAPI6101SL with header line,
int_dtsrc type standard table of BAPI6109DSSL
with header line."#EC
* Declaration for BAPI_IPAK_GETDETAIL
data: int_det type standard table of BAPI6109 with header line,
int_ret type standard table of BAPIRET2 with header line,
int_dlt type standard table of BAPI6109IC with header line,
int_sel type standard table of BAPI6109SEL with header line,
int_thrdp type standard table of BAPI6109TCP with header line,
int_flparam type standard table of BAPI6109FILE
with header line."#EC
SELECTION-SCREEN BEGIN OF BLOCK BLOCK1.
PARAMETERS: P_FILE(255) type c.
SELECTION-SCREEN END OF BLOCK BLOCK1.
SELECTION-SCREEN COMMENT /1(30) text-h01.
PARAMETERS: Actual radiobutton group rg1,
Plan radiobutton group rg1.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
*Providing F4 help for upload File name.
PERFORM F3000_GET_FILE_NAME USING P_FILE.
AT SELECTION-SCREEN ON P_FILE.
* Check for file Existance on the Presentaion server
PERFORM F3100_FILE_EXISTS USING P_FILE.
START-OF-SELECTION.
* Get data from File to internal table.
PERFORM F3200_GET_DATA_FROM_FILE USING P_FILE.
FORM F3000_GET_FILE_NAME USING P_FILE.
* Displays Windows popup to get filename
DATA : P_EXISTS TYPE C.
* Check if File Exists on Presentation Server
CALL FUNCTION 'WS_QUERY'
EXPORTING
FILENAME = P_FILE
QUERY = 'FE'
IMPORTING
RETURN = P_EXISTS.
IF P_EXISTS = 0.
MESSAGE ....
ENDIF.
ENDFORM. " F3100_FILE_EXISTS
FORM F3200_GET_DATA_FROM_FILE USING P_FILE.
clear g_t_data.
data : loc_file type string.
loc_file = P_FILE.
*--------------------------------------------------------------
* Clearing of the Standard parameter Tables
*--------------------------------------------------------------
*--------------------------------------------------------
* When Actual Flag is on
*--------------------------------------------------------
if int_dlt-DELETEALLBEFORE <> 'X' and Actual EQ 'X'.
if int_flparam-FILENAME EQ <path and file name on Application server>.
clear req.
clear stt.
CALL FUNCTION 'BAPI_IPAK_START'
EXPORTING
INFOPACKAGE = int_infopac-INFOPACKAGE
IMPORTING
REQUESTID = req
TABLES
RETURN = int_message.
*--------------------------------------------------------
* When Plan Flag is on
*--------------------------------------------------------
elseif int_dlt-DELETEALLBEFORE EQ 'X' AND Plan EQ 'X'.
if int_flparam-FILENAME EQ <path and file name on Application server>.
clear req.
clear stt.
CALL FUNCTION 'BAPI_IPAK_START'
EXPORTING
INFOPACKAGE = int_infopac-INFOPACKAGE
IMPORTING
REQUESTID = req
TABLES
RETURN = int_message.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.