1、 INACT like JEST-INACT TXT04 like TJ02T-TXT04 TXT30 likeTJ02T-TXT30 Export parameters RETURN like BAPIRETURN Step1:定义BAPI用到的结构体在此步骤里,BAPI中用到功能模块的表和参数均已在这里定义使用数据类型-结构定义以下结构:结构1:ZBAPI_ORDER_STATUS_IMPORT包含以下字段 ORDERID Order number (Keyfield) 订单号 SPRAS Language 语言结构2:ZBAPISTAT:OBJNR like JEST-OBJNR STA
2、T like J_STAT INACT like J_INACT TXT04 like J_TXT04 TXT30 like J_TXT30 OBJNR like J_OBJNRImportant note:You will have to define a structure for every parameter in the BAPI. You cannot use the same structures used in existing applications because BAPI structures are frozen when BAPIs are released and
3、 then there are restrictions on changing them. 你必须为每个BAPI中的参数定义结构,当BAPI被释放后是限制更改他们的,因为bapi会被冻结,所以你不能在存在的应用中使用同一个结构ZBAPI_ORDER_STATUS_IMPORT 结构1 ZBAPISTAT -结构2 第二步:写入功能模块Important notes: 每个BAPI必须有他们自己的函数组(功能组) 在属性tab里记住选择存取类型是Remote Enabled module,否则功能模块不能通过RFC来invoke它做为一个BAPI来使用 输入/输出参数仅仅能被BY VALUE
4、对于RFC enabled的功能模块 我们在此仅创建了一个BAPI,但你能创建相关的BAPI在同一模块池中,使得他们能共享全局信息功能模块的属性设定输入参数 这里定义功能模块的输入参数为订单输入参数的结构,即是引入结构ZBAPI_ORDER_STATUS_IMPORT做为bapi_order_status_import的参照Export Parameters Code Notes: The subroutine SET_RETURN_MESSAGE is a standard routine used for BAPIs that use the BAPIRETURN structure SE
5、T_RETURN_MESSAGE子程序是在BAPI中标准的子程序用来使用BAPIRETURN 结构 在FORM Z_BAPI_GET_ORDER_SYSTEM_STATUS里有个测试是IF 1=2,如果这测试结果为真,则信息就显示,但是这个条件永远不会为真,所以我们就不可能在BAPI里显示出这个信息,为什么要包含这个的原因是,为信息创建一个参照,因此这时SAP标准控制方法,拷贝公司代码层面的代码GetList BAPI. In form Z_BAPI_GET_ORDER_SYSTEM_STATUS there is a test IF 1 = 2. If the test is true a
6、message is displayed. The condition will obviously never be true, and we will never want to display a message in a BAPI. The reason why it is included is, that it create a reference for the message, so that the WHERE USED functionality can be used for the message. This is the SAP standard way to han
7、dle it, copied from the Company Code GetList BAPI. INCLUDE LZBAPISTATUSUXX * THIS FILE IS GENERATED BY THE FUNCTION LIBRARY. * NEVER CHANGE IT MANUALLY, PLEASE!INCLUDE LZBAPISTATUSU02. Z_BAPI_GET_ORDER_SYSTEM_STATUSINCLUDE LZBAPISTATUSTOP - Global data FUNCTION-POOL ZBAPISTATUS. MESSAGE-ID Z3Types:
8、begin of Type_tj02t, istat like tj02t-istat, txt04 like tj02t-txt04, txt30 like tj02t-txt30, end of type_tj02t.DATA:* Declarations for TABLE parameter T_BAPISTAT like ZBAPISTAT occurs 0, G_BAPISTAT like ZBAPISTAT,* Table for object texts t_tj02t type type_tj02t occurs 0, g_tj02t type type_tj02t.* St
9、ructure for return messages BEGIN OF MESSAGE, MSGTY LIKE SY-MSGTY, MSGID LIKE SY-MSGID, MSGNO LIKE SY-MSGNO, MSGV1 LIKE SY-MSGV1, MSGV2 LIKE SY-MSGV2, MSGV3 LIKE SY-MSGV3, MSGV4 LIKE SY-MSGV4, END OF MESSAGE.INCLUDE LZBAPISTATUSF01 - Subroutines *INCLUDE LZBAPISTATUSF01 .*-*&-* Form SET_RETURN_MESSA
10、GE* This routine is used for setting the BAPI return message.* The routine is a standard routine for BAPIs that handles the message* structure for the BAPIRETURN structure. It has been copied from the* BAPI Company Code Getlist* -P_MESSAGE text* -P_RETURN textform SET_RETURN_MESSAGE USING VALUE(P_ME
11、SSAGE) LIKE MESSAGE CHANGING P_RETURN LIKE BAPIRETURN. CHECK NOT MESSAGE IS INITIAL. CALL FUNCTION BALW_BAPIRETURN_GET EXPORTING TYPE = P_MESSAGE-MSGTY CL = P_MESSAGE-MSGID NUMBER = P_MESSAGE-MSGNO PAR1 = P_MESSAGE-MSGV1 PAR2 = P_MESSAGE-MSGV2 PAR3 = P_MESSAGE-MSGV3 PAR4 = P_MESSAGE-MSGV4* LOG_NO =
12、* LOG_MSG_NO = IMPORTING BAPIRETURN = P_RETURN EXCEPTIONS OTHERS = 1.endform. SET_RETURN_MESSAGEFUNCTION Z_BAPI_GET_ORDER_STATUS FUNCTION z_bapi_get_order_system_status.*-Local interface: VALUE(I_AUFNR) TYPE AUFNR VALUE(I_SPRAS) TYPE SPRAS DEFAULT SY-LANGU VALUE(I_EXCLUDEINACTIVE) TYPE CHAR1 OPTIONA
13、L VALUE(RETURN) TYPE BAPIRETURN TABLES T_BAPISTAT STRUCTURE ZBAPISTAT-* VALUE(RETURN) TYPE BAPIRET2 DATA: l_aufnr LIKE afko-aufnr, l_objnr LIKE jest-objnr.* Check if order exists SELECT SINGLE aufnr FROM afko INTO l_aufnr WHERE aufnr = BAPI_ORDER_STATUS_IMPORT-orderid. IF sy-subrc NE 0. CLEAR messag
14、e. message-msgty = E. message-msgid = Z3 message-msgno = 000 message-msgv1 = BAPI_ORDER_STATUS_IMPORT-orderid. PERFORM set_return_message USING message CHANGING return. IF 1 = 2.* The only reason to include this statement, that will obviously* never execute, is that it will create a referecence so t
15、hat you* can find out where a particular message is being used. This* functionality is used by the BAPIs programmed by SAP MESSAGE e000(z3). ENDIF. CHECK return IS INITIAL.* Read order status CONCATENATE OR BAPI_ORDER_STATUS_IMPORT-orderid INTO l_objnr. IF BAPI_ORDER_STATUS_IMPORT-i_excludeinactive
16、= X SELECT objnr stat inact FROM jest INTO TABLE t_bapistat WHERE objnr = l_objnr AND inact ELSE. WHERE objnr = l_objnr. IF sy-subrc API methods - Add method and write the name of the functionmodule in the dialogbox. Next the dialogbox show below will be shown. This is the start screen of the BAPI w
17、izard. Proceed with wizard by pressing the button. After you have finished the wizard, tyou will notice that the ZGetOrderStatus has been added to the business object:You can doubleclick on the method to see its properties. To use the business object you must change the Object type status to Implemented. Use menu Edit-Change releases status-Object type-To implemented. No you can test thge object (Press F8). Not
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1