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:
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
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
DEF_FILENAME = SPACE
MASK = ',*.*,*.*.'
MODE = 'O'
IMPORTING
FILENAME = P_FILE
EXCEPTIONS
INV_WINSYS = 1
NO_BATCH = 2
SELECTION_CANCEL = 3
SELECTION_ERROR = 4
OTHERS = 5.
IF SY-SUBRC = 4.
MESSAGE .......
ENDIF.
ENDFORM. " f3000_get_file_name
FORM F3100_FILE_EXISTS USING P_FILE.
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.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = loc_file
FILETYPE = 'ASC'
TABLES
DATA_TAB = g_t_data
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
NO_AUTHORITY = 6
UNKNOWN_ERROR = 7
BAD_DATA_FORMAT = 8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
OTHERS = 17.
IF SY-SUBRC <> 0.
MESSAGE .....
else.
MESSAGE .....
ENDIF.
open dataset w_dataset for output in text mode encoding default.
loop at g_t_data.
transfer g_t_data to w_dataset.
endloop.
close dataset w_dataset.
clear int_ins.
clear int_infopac.
clear int_msg.
clear int_src.
clear int_dtsrc.
int_ins-SIGN = 'I'.
int_ins-OPTION = 'EQ'.
int_ins-INFOSOURCELOW = <Infosource Name>.
append int_ins.
int_src-SIGN = 'I'.
int_src-OPTION = 'EQ'.
int_src-SOURCESYSTEMLOW = <Source system Name>.
append int_src.
CALL FUNCTION 'BAPI_IPAK_GETLIST'
TABLES
SELINFOSOURCE = int_ins
SELSOURCESYSTEM = int_src
INFOPACKAGE_LIST = int_infopac
RETURN = int_msg.
loop at int_infopac.
*--------------------------------------------------------------
* Clearing of the Standard parameter Tables
*--------------------------------------------------------------
clear int_det.
clear int_ret.
clear int_dlt.
clear int_sel.
clear int_thrdp.
clear int_flparam.
CALL FUNCTION 'BAPI_IPAK_GETDETAIL'
EXPORTING
INFOPACKAGE = int_infopac-INFOPACKAGE
IMPORTING
DETAILS = int_det
FILE_PARAMS = int_flparam
TABLES
SELECTIONS = int_sel
INFOCUBES = int_dlt
THIRD_PARTY_PARAMS = int_thrdp
RETURN = int_ret.
*--------------------------------------------------------
* 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.
wait up to 10 seconds.
CALL FUNCTION 'BAPI_ISREQUEST_GETSTATUS'
EXPORTING
REQUESTID = req
IMPORTING
TECHSTATUS = stt.
if stt EQ 'Y'.
MESSAGE .....
elseif stt EQ 'G'.
MESSAGE .....
elseif stt EQ 'R'.
MESSAGE .....
endif.
endif.
*--------------------------------------------------------
* 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.
wait up to 10 seconds.
CALL FUNCTION 'BAPI_ISREQUEST_GETSTATUS'
EXPORTING
REQUESTID = req
IMPORTING
TECHSTATUS = stt.
if stt EQ 'Y'.
MESSAGE .....
elseif stt EQ 'G'.
MESSAGE .....
elseif stt EQ 'R'.
MESSAGE .....
endif.
endif.
endif.
endloop.
ENDFORM. " f3200_get_data_from_file
Source URL:https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/2075
分享到:
相关推荐
6. BAPI_CHARACT_CREATE/BAPI_CHARACT_CHANGE/BAPI_CHARACT_DELETE/BAPI_CHARACT_RENAME/BAPI_CHARACT_GETDETAIL/BAPI_CHARACT_ADDLONGTEXT/BAPI_CHARACT_REMOVELONGTEXT/BAPI_CHARACT_GETLONGTEXT/CARD_...
固定资产导入模板——SAP_ABAP_FI_BAPI清单案例教程——固定资产创建_BAPI_FIXEDASSET_OVRTAKE
SAP_ABAP_FI_BAPI清单案例教程——采购付款/销售收款_BAPI_ACC_DOCUMENT_POST_F-02
云南鸿翔SAP培训------ABAP,abap的ppt,很好的资料哦
什么是BAPI BAPI: Business Application Programming Interface 商业应用程序接口 1.访问R3中业务对象与业务过程的标准编程接口。 2.BAPIs 实现了BOR中业务对象的方法 3.BAPIs 通过RFC-enable的功能模块实现。 4....
2. **BAPI的分类**:BAPI分为两类,即业务对象(Business Object)和事务代码(Transaction Code)。业务对象BAPI通常用于处理特定的业务实体,如客户、供应商等;而事务代码BAPI则对应SAP的事务码,用于执行特定的...
### BAPI-ACC-DOCUMENT-POST 结构字段扩展 #### 概述 在SAP系统中,`BAPI_ACC_DOCUMENT_POST` 是一个重要的业务应用程序接口(BAPI),用于执行财务凭证的过账处理。但在实际应用过程中,可能会遇到现有BAPI无法...
-----ABAP FAQs--------------------------------------------
这个名为"SAP资料集有ABAP-PP-MM-RFC-BAPI-JCO等.rar"的压缩包文件包含了多个与SAP相关的学习资料,涵盖了许多关键模块和技术,包括ABAP编程、生产计划(PP)、物料管理(MM)、远程功能调用(RFC)、业务对象接口...
ABAP开发中调用BAPI执行业务,有时会遇到所需字段在标准BAPI没提供,可以通过该方法实现字段扩展
例如,将 IMPORTING 参数 DESTINATION_FROM 和 DESTINATION_TO 分别关联到上下文节点 wdctx_destination_from 和 wdctx_destination_to,将 CHANGING 参数 FLIGHT_LIST 关联到 wdctx_flight_list。 6. **生成和调整...
ABAP_RFC_BAPI 培训教程详细解读 SAP R/3 系统提供了多种接口技术,其中 RFC(Remote Function Call)和 BAPI(Business Application Programming Interface)是常用的两种。RFC 主要分为本地 RFC 和远程 RFC,而 ...
【标题】BW-CODE.zip: 本压缩包包含有关如何编写高效且优雅的Business Warehouse (BW) 代码的资源,旨在帮助开发者优化SAP BW应用的性能和可维护性。通过对ABAP编程语言的深入理解和重塑,这个代码框架提供了一种纯...
在“web-dynpro-abap-ui-element-tree”这个主题中,我们主要探讨的是Web Dynpro ABAP中的UI元素树结构,以及如何在Chapter 1, Curriculum (CV) Introduction中理解和应用这些知识。 在Web Dynpro ABAP中,UI元素是...
SAP® BW: A Step-by-Step Guide ...Loading data from SAP R/3 into SAP BW Data maintenance Performance tuning, including parallel query option and data packet sizing Object transport
A complete description of the most important objects for ABAP from ABAP Dictionary. ABAP - Reference A complete description of all ABAP keywords in their relevant context. ABAP - Quick ...
Codemirror-abap CodeMirror编辑器的ABAP模式描述将ABAP语法高亮显示添加到编辑器中。安装npm install --save codemirror-abap用法构建工具在您的项目中导入codemirror-abap 。 import CodeMirror from 'codemirror'...
3. **程序结构**:ABAP程序由多个部分组成,如定义部分(DEFINITIONS),数据声明(DATA),处理部分(AT SELECTION-SCREEN, START-OF-SELECTION, FORM)等。 4. **函数模块**:是可重用代码的集合,可以在不同程序...
### ABAP4培训手册知识点概览 #### 一、ABAP4编程语言简介 ABAP4,全称为Advanced Business Application Programming 4th generation,是一种专为SAP R/3系统设计的面向对象的编程语言。它遵循SQL标准,是开发SAP...
根据提供的文件信息,我们可以深入探讨ABAP Workbench的概念及其在SAP R/3系统中的应用。这份材料显然是针对那些希望深入了解ABAP编程环境的专业人士设计的。以下是对这份文档涉及的关键知识点的详细解读: ### 一...