Transcription

Template Function Modules of theSAP Application InterfaceFrameworkApplies to:SAP Application Interface FrameworkSummaryIn customizing of the SAP Application Interface Framework several places exist where function modules canbe maintained. Those function modules need to have the correct parameters. Therefore, template functionmodules are delivered with the SAP Application Interface Framework. This document provides you withinformation about those template function modules.Author:Verena WörnerCompany: SAP AGCreated on: 03 December 2012Author BioVerena Wörner is a developer for SAP Custom Development. She is a member of the development team forthe SAP Application Interface Framework.SAP COMMUNITY NETWORK 2012 SAP AGscn.sap.com1

Template Function Modules of the SAP Application Interface FrameworkTable of ContentsIntroduction . 3Function Modules in Define Interfaces . 3/AIF/FILE TEMPL CHECK MAPPING . 3/AIF/FILE TEMPL INIT MAPPING . 4/AIF/FILE TEMPL INIT PROCESS . 4Value Mappings . 5/AIF/FILE TEMPL VALMAPPING . 5Checks 5/AIF/FILE TEMPL CHECK . 5Define Structure Mapping . 7/AIF/FILE TEMPL MAP . 7Define Actions . 8/AIF/FILE TEMPL INIT ACTION . 8/AIF/FILE TEMPL PROCESS . 8Related Content . 10Copyright. 11SAP COMMUNITY NETWORK 2012 SAP AGscn.sap.com2

Template Function Modules of the SAP Application Interface FrameworkIntroductionIn the SAP Application Interface Framework, several places exist where function modules can be used.These function modules are usually called dynamically by the SAP Application Interface Framework andconsequently need to implement a specific, predefined signature. To support the interface developer increating the function modules, template function modules are delivered with the SAP Application InterfaceFramework. The template function modules can be found in function group /AIF/AIF TEMPLATES. Theinterface developer can copy the templates to a new function module and implement it.Alternatively you have the possibility to directly create your function module from the corresponding inputfield in customizing. You have to enter the name of the function module you would like to create. If thefunction module does not exist the system will ask you if you want to create it. The template function modulewill be copied to your new function module and you can implement it.Note that the templates have some parameters, where no type is specified, for example, for the raw or SAPdata structure. You might want to change the types according to your needs, for example, to benefit fromcode inspector checks. In this document, an overview of existing templates is given. The document explainswhere the templates are used and gives details about the function module’s parameters.Function Modules in Define Interfaces/AIF/FILE TEMPL CHECK MAPPINGTypeParameterDescriptionImportingRAW STRUCTContains the data of the source structureRETURN TAB MAPPINGContains the messages that occurred during mapping. In thefunction module, you can evaluate the errors that occurred duringmapping.SENDING SYSTEMOptional parameter. A field of the source structure needs to bemaintained in System Field in the interface definition. If thefunction module should behave differently for different senders,you can use this parameter to differentiate the behavior.TablesRETURN TABInsert messages, for example, if an error occurred, into this table(for example, with helper function /AIF/UTIL ADD MSG). Themessages are written to the application log.ChangingOUT STRUCTContains the data of the destination structure. With this functionmodule, you can change the mapped data. Using importingparameter RETURN TAB MAPPING, you may be able to correcterrors that occurred during mapping.The function module needs to be maintained in Check Function Module. The function module is executedafter the mapping and before the execution of the actions. You can use the function module to facilitate acertain behavior depending on the result of the mapping. For example, you could correct mapping errors inthe function module.SAP COMMUNITY NETWORK 2012 SAP AGscn.sap.com3

Template Function Modules of the SAP Application Interface Framework/AIF/FILE TEMPL INIT ines in which context the function module is called (for example,CONTEXT TRANSFORM)FINFContains the data of the interface definition of the current interface youare using (for example, raw data structure, sap data structure, andproxy class).SENDING SYSTEMOptional parameter. A field of the source structure needs to bemaintained in System Field in the interface definition. If the functionmodule should behave differently for different senders, you can usethis parameter to differentiate the behavior.TablesRETURN TABInsert messages, for example, if an error occurred, into this table (forexample, with helper function /AIF/UTIL ADD MSG). The messagesare written to the application log.ChangingDATAContains the destination structure. The destination structure should beempty since the function module is executed before the mapping.However, you may enrich the structure with data in the functionmodule.RAW STRUCTContains the data of the source structure. You can change the data inthe function module.CANCELException that can be raised by the function module in case of errors.However, it is recommended to add errors to return tab RETURN TAB.ExceptionsThe function module is executed before mapping in the SAP Application Interface Framework. You can usethe function module to manipulate data in the source or destination structure before the mapping is started.The template has to be used in Init Function Before Mapping in Customizing activity Define Interfaces./AIF/FILE TEMPL INIT ines in which context the function module is called (for example,CONTEXT PROCESS)FINFContains the data of the interface definition of the current interface youare using (for example, raw data structure, SAP data structure, andproxy class).SENDING SYSTEMOptional parameter. A field of the source structure needs to bemaintained in System Field in the interface definition. If the functionmodule should behave differently for different senders, you can usethis parameter to differentiate the behavior.TablesRETURN TABInsert messages, for example, if an error occurred, into this table (forexample, with helper function /AIF/UTIL ADD MSG). The messagesare written to the application log.ChangingDATAContains the data of the destination structure after mapping. You maychange the data in this function module.ExceptionsCANCELException that can be raised by the function module in case of errors.However, it is recommended to add errors to return tab RETURN TAB.The function module needs to be maintained in Init Function Before Processing. This function module iscalled after mappings were executed but before the processing of the action starts. You can use this functionmodule to manipulate the data in the destination structure before the processing of the action(s) starts.SAP COMMUNITY NETWORK 2012 SAP AGscn.sap.com4

Template Function Modules of the SAP Application Interface FrameworkValue Mappings/AIF/FILE TEMPL VALMAPPINGTypeParameterDescriptionImportingVALUE INThe fields defined in the field mapping (Fieldname 1 to Fieldname 5)are used as importing parameters.VALUE IN2VALUE IN3VALUE IN4VALUE IN5SENDING SYSTEMOptional parameter. A field of the source structure needs to bemaintained in System Field in the interface definition. You can enterdifferent values, based on the system the data comes from, intoparameter VALUE OUT.TablesRETURN TABInsert messages, for example, if an error occurred, into this table (forexample, with helper function /AIF/UTIL ADD MSG). The messagesare written to the application log.ChangingVALUE OUTValue that the field in the destination structure should have after themapping function is executed.ExceptionsNO VALUE FOUNDException that can be raised if the correct value could not be mapped.The function module is executed during mapping. There are several places where the template functionmodule is used: Customizing activity Define Value Mappings Customizing activity Define Field Mappings Customizing activity Interface Variants Define Variant Mappings Assign/Define Field MappingsChecks/AIF/FILE TEMPL CHECKTypeParameterDescriptionImportingDATA STRUCTContains the data of the current structure. In case the check is executedduring structure mapping, the current structure is either the SAP or rawdata structure. This is dependent on the Check raw data indicator in thecheck assignment. In case the check is executed in an action, thestructure is the destination structure. If the check is executed for acondition, the current structure is the source structure.DATA LINEContains the current line of the structure that is mappedDATA FIELDIf the check function is executed in the structure mapping or as conditionand at least Fieldname 1 is defined, this field contains the value of thefield defined in Fieldname 1.MSGTYMessage typeVALUE1Contain the values of the fields defined when the check is assigned(Fieldname 1 to Fieldname 5).VALUE2VALUE3VALUE4SAP COMMUNITY NETWORK 2012 SAP AGscn.sap.com5

Template Function Modules of the SAP Application Interface FrameworkVALUE4TablesChangingT IFCHECKContains the Customizing data of the check assignment. This parameteris filled if the check function is executed during structure mapping.T IFACTContains the Customizing data of the assigned action for which thecheck function is executed. This parameter is only filled if the check isassigned to an action in the Customizing activity Define Actions.T ACCHECKContains the Customizing data of the check assigned to the currentaction. This parameter is only filled if the check is assigned to an actionin the Customizing activity Define Actions.T FUNCContains the Customizing data of the function, whose executiondepends on the result of the check. This parameter is only filled if thecheck is assigned to an action in the Customizing activity Define Actions.T FMAPCONDContains the Customizing data of the Conditional Mapping. Thisparameter is only filled if the check is assigned to a conditional fieldmapping.T CHECKContains the Customizing data of the assigned check. This field isalways filled.T TABCHKContains the Customizing data of the single check that is currentlyexecuted.SENDING SYSTEMOptional parameter. A field of the source structure needs to bemaintained in System Field in the interface definition. If the functionmodule should behave differently for different senders, you can use thisparameter to differentiate the behavior.RETURN TABInsert messages, for example, if an error occurred, into this table (forexample, with helper function /AIF/UTIL ADD MSG). The messages arewritten to the application log.DATA TABLETable that contains all data of the current structure that is mapped. Youcan change this data in your check function.ERRORIndicator for indicating if the check was successful. Needs to be set by adeveloper. If ERROR abap true, the check is treated as unsuccessful.You can use this function module to execute any type of check and return the result to the SAP ApplicationInterface Framework. There are the following places within Customizing where this template is used asfollows: Customizing activity Define Structure Mapping Assign Checks Customizing activity Define Structure Mapping Define Conditions Customizing activity Define Actions Customizing activity Interface Variants Define Variant MappingSAP COMMUNITY NETWORK 2012 SAP AGscn.sap.com6

Template Function Modules of the SAP Application Interface FrameworkDefine Structure Mapping/AIF/FILE TEMPL MAPTypeParameterDescriptionImportingRAW STRUCTContains the source structure of the interface.RAW LINEContains the row of the table/structure of the source structure forwhich the after mapping function is currently executed.SMAPContains the Customizing data of the current structure mapping.INTRECContains the record type of the current structureSENDING SYSTEMOptional parameter. A field of the source structure needs to bemaintained in System Field in the interface definition. If the functionmodule should behave differently for different senders, you can usethis parameter to differentiate the behavior.TablesRETURN TABInsert messages, for example, if an error occurred, into this table (forexample, with helper function /AIF/UTIL ADD MSG). The messagesare written to the application log.ChangingOUT STRUCTContains the destination structureDEST LINEContains the data of the current line in the destination structure. Youmight change the data of this parameter in this function module.DEST TABLEContains the data of the current structure in a tableAPPEND INDICATORIndicator for indicating if a line should be added to the destinationtable. Usually, if an error occurs in a value mapping, the line is notadded to the destination structure and the indicator is blank. If youwant to add the line anyway, you have to set this indicator.The function module is processed after or before the mapping of the current structure. This template is usedin the Customizing activity Define Structure Mapping for function after mapping and function before mappingin Assign Destination Structure.SAP COMMUNITY NETWORK 2012 SAP AGscn.sap.com7

Template Function Modules of the SAP Application Interface FrameworkDefine Actions/AIF/FILE TEMPL INIT nes in which context the function module is called (for example,CONTEXT TRANSFORM)FINFContains the Customizing data of the current interfaceACTIONContains the name of the current actionSENDING SYSTEMOptional parameter. A field of the source structure needs to bemaintained in System Field in the interface definition. If the functionmodule should behave differently for different senders, you can usethis parameter to differentiate the behavior.TablesRETURN TABInsert messages, for example, if an error occurred, into this table (forexample, with helper function /AIF/UTIL ADD MSG). The messagesare written to the application log.ChangingDATAContains the data of the destination structure after mapping. You canadapt the data in your function module.ExceptionsCANCELException that can be raised by the function module in the case oferrors. However, it is recommended to add errors to return tabRETURN TAB.The template can be used in the Customizing activity Define Actions. The function module is executed at thebeginning of each action call before the action function modules are called. How often this processingfunction is executed is finally determined during runtime, based on the content of the message that ismapped and the main component type the action handles. If the component type is a structure, the functionis executed only once. In the case of the main component type being a table, the function module isexecuted for every dataset in the table./AIF/FILE TEMPL icator for indicating if the action is executed in test mode. You can setthis indicator, for example, to prevent database updates if the action isexecuted in test mode. Furthermore, you can use it to pass it to BAPIssupporting test calls.SENDING SYSTEMOptional parameter. A field of the source structure needs to bemaintained in System Field in the interface definition. If the functionmodule should behave differently for different senders, you can use thisparameter to differentiate the behavior.TablesRETURN TABInsert messages, for example, if an error occurred, into this table, (forexample, with helper function /AIF/UTIL ADD MSG). The messages arewritten to the application log.ChangingDATAContains the data of the destination structure after mappingCURR LINEContains the data of the current line. When copying the template youshould at least change the type of CURR LINE to the main componenttype.SUCCESSIndicator for indicating if the action was executed successfully.OLD MESSAGESContains messages that might have occurred in past processing of theactionSAP COMMUNITY NETWORK 2012 SAP AGscn.sap.com8

Template Function Modules of the SAP Application Interface FrameworkThis template should be used for every function of the Customizing activity Define Actions DefineFunctions. Note that you should not raise an error. Instead, you should fill return table RETURN TAB withyour messages. If there is a message of type E or A in the return table, the SAP Application InterfaceFramework implies that the function call was not successful. However, you may overwrite this behavior. Youcan set the SUCCESS indicator to “Y” explicitly to indicate success even though the RETURN TAB containserror messages. You can set the SUCCESS indicator to N explicitly to indicate failure even thoughRETURN TAB does not contain error messages.SAP COMMUNITY NETWORK 2012 SAP AGscn.sap.com9

Template Function Modules of the SAP Application Interface FrameworkRelated ContentCookbook for the SAP Application Interface FrameworkSAP COMMUNITY NETWORK 2012 SAP AGscn.sap.com10

Template Function Modules of the SAP Application Interface FrameworkCopyright Copyright 2012 SAP AG. All rights reserved.No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP AG.The information contained herein may be changed without prior notice.Some software products marketed by SAP AG and its distributors contain proprietary software components of other software vendors.Microsoft, Windows, Excel, Outlook, and PowerPoint are registered trademarks of Microsoft Corporation.IBM, DB2, DB2 Universal Database, System i, System i5, System p, System p5, System x, System z, System z10, System z9, z10, z9,iSeries, pSeries, xSeries, zSeries, eServer, z/VM, z/OS, i5/OS, S/390, OS/390, OS/400, AS/400, S/390 Parallel Enterprise Server,PowerVM, Power Architecture, POWER6 , POWER6, POWER5 , POWER5, POWER, OpenPower, PowerPC, BatchPipes,BladeCenter, System Storage, GPFS, HACMP, RETAIN, DB2 Connect, RACF, Redbooks, OS/2, Parallel Sysplex, MVS/ESA, AIX,Intelligent Miner, WebSphere, Netfinity, Tivoli and Informix are trademarks or registered trademarks of IBM Corporation.Linux is the registered trademark of Linus Torvalds in the U.S. and other countries.Adobe, the Adobe logo, Acrobat, PostScript, and Reader are either trademarks or registered trademarks of Adobe SystemsIncorporated in the United States and/or other countries.Oracle is a registered trademark of Oracle Corporation.UNIX, X/Open, OSF/1, and Motif are registered trademarks of the Open Group.Citrix, ICA, Program Neighborhood, MetaFrame, WinFrame, VideoFrame, and MultiWin are trademarks or registered trademarks ofCitrix Systems, Inc.HTML, XML, XHTML and W3C are trademarks or registered trademarks of W3C , World Wide Web Consortium, MassachusettsInstitute of Technology.Java is a registered trademark of Oracle Corporation.JavaScript is a registered trademark of Oracle Corporation, used under license for technology invented and implemented by Netscape.SAP, R/3, SAP NetWeaver, Duet, PartnerEdge, ByDesign, SAP Business ByDesign, and other SAP products and services mentionedherein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and other countries.Business Objects and the Business Objects logo, BusinessObjects, Crystal Reports, Crystal Decisions, Web Intelligence, Xcelsius, andother Business Objects products and services mentioned herein as well as their respective logos are trademarks or registeredtrademarks of Business Objects S.A. in the United States and in other countries. Business Objects is an SAP company.All other product and service names mentioned are the trademarks of their respective companies. Data contained in this documentserves informational purposes only. National product specifications may vary.These materials are subject to change without notice. These materials are provided by SAP AG and its affiliated companies ("SAPGroup") for informational purposes only, without representation or warranty of any kind, and SAP Group shall not be liable for errors oromissions with respect to the materials. The only warranties for SAP Group products and services are those that are set forth in theexpress warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting anadditional warranty.SAP COMMUNITY NETWORK 2012 SAP AGscn.sap.com11

SAP Application Interface Framework Summary In customizing of the SAP Application Interface Framework several places exist where function modules can be maintained. Those function modules need to have the correct parameters. Therefore, template function modules ar