Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member

This document will show you how to use AIF Customizing to define multiple conditional checks. Additionally the alternative with an ABAP function module will also be presented.

In SAP AIF you have the possibility to use checks to verify if the content of the specified field matches a certain condition. When a checks fails, you can stop processing and don't have to wait for a SAP BAPI message.

Checks can be located in Define Checks and defined by entering the namespace for which you want to create the check.

For certain business cases it is required that a certain field matches more conditions. In order to exemplify this, the following scenario will be used.

In order to process an Order IDoc the material number used by vendor in E1EDP19 -> IDTNR for qualifier QUALF “002” should meet the following criteria:

  • If the material number doesn’t exist in table ZAIF_MVKE_TBL then everything is ok and the order IDoc should be processed;
  • For QUALF “002” if the material number exists in table ZAIF_MVKE_TBL, the sales organization VKORG is “ZUS2”, the system-date sy-date is newer as the date from which distr.-chain-spec. material status is valid VMSTD and the distribution-chain-specific material status VMSTA is “02”, “03” or “04”, then the IDoc processing should be stopped, an error message outputted and the causing field(s) IDTNR marked in red.


In order to illustrate the use case better the following diagram was used:

In SAP AIF you can use customizing or you can define your own function module for your desired check. In this article both solutions will be presented.

Because only some data needs to be checked the preprocessing mode will be used. In this mode SAP AIF will execute the mapping logic on top of IDoc raw message data and there is limited maintenance effort in Customizing.

For this functionality you have to configure the ALE runtime to call the generic inbound process function of the SAP AIF. In this document http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/e0f445c1-deb8-3110-7ebf-9665f7c1ed94&override... you will find a good description on how you can do this.

To activate preprocessing, select the Preprocessing checkbox in Customizing for SAP Application Interface Framework under Interface Development -> Define Interfaces, like in the figure below:

For this check, you will need fields from the second structure level, so you have to define a  structure mapping like shown below.


In AIF you have the possibility to use checks to verify if the content of the specified field matches a certain condition. There are several places where checks can be used, for example in structure mappings or assigned to a function in an action.
Checks can be located in Define Checks and defined by entering the namespace for which you want to create the check.

Customizing solution


Now you can define checks for any field of the structure E1EDP19.
For that go to Assign checks. Here you can use the diagram above in order to follow the logic flow of the checks.

The first step is to check if the qualifier QUALF is 002. If this is the case then the next step will be processed.




In the figure below you can see how the check CHECK_MAT_EXIST is defined.



For the last step the check CHECK_MAT_COND was used which will give an error if for the defined condition:
material status VMSTA is “02”, “03” or “04”.



For the check an error msg. class was defined which raises a certain message in case of an error. For the error message the value of the field IDTNR will be used dynamically in the message.



These are all the necessary steps required for this check to work. At the end you can test the development with a large variety of options in order to see if you achieve the desired results.


Testing:


In the following figure you can see the entries in the table ZAIF_MVKE_TBL.      



Based on the content of the table ZAIF_MVKE_TBL we can see that multiple checks - defined in AIF customizing - fulfill the specified requirements.



Function module solution:


If you want to develop a check function module then the function module should have the same signature as the template /AIF/FILE_TEMPL_CHECK. Then you can write your own code in order tosolve the problem by using only one check. For the specified use case, the following ABAP-Code was used in order to solve the problem.


FUNCTION ZAIF_MATNR_CHECK .

data: lv_vmsta type VMSTA.

if VALUE2 = '002'.

select VMSTA into lv_vmsta from ZAIF_MVKE_TBL
where MATNR = VALUE1 and VKORG = 'ZUS2' and VMSTD <= SY-DATUM.
if sy-subrc = 0.
ERROR
= ABAP_TRUE.
else.
endif.
endselect.

endif.

ENDFUNCTION.


When you develop the code you should consider which fields from the IDoc you will use for your check. You can define up to five fields from Fieldname 1 to Fieldname 5 which will correspond to VALUE1 from VALUE5 in the function module with the specified template.




Then you go to the structure and assign the check like in the picture below. Here is important to enter the fields corresponding to the variables in the function module. With other words IDTNR comes in Fieldname 1 and QUALF in Fieldname 2. In order to check the raw data, select Check Raw data


Testing:


In order to compare the results from the function module with the results from the multiple checks the entries in the table weren’t modified and the order IDoc contains the same material numbers.


Based on the content of the table ZAIF_MVKE_TBL we can see that the function module fulfills the specified requirements and delivers the same result as the multiple checks.


Labels in this area