|
| 1 | +--- |
| 2 | +parser: v2 |
| 3 | +auto_validation: true |
| 4 | +time: 20 |
| 5 | +tags: [tutorial>intermediate, software-product>sap-s-4hana, tutorial>license] |
| 6 | +primary_tag: software-product>sap-application-interface-framework |
| 7 | +--- |
| 8 | + |
| 9 | +# Enhance an IDoc Interface with Preprocessing |
| 10 | +<!-- description --> Enhance an existing "monitoring only" IDoc interface to be able to carry out data checks and mappings using the preprocessing capability of SAP Application Interface Framework before actually calling the IDoc interface. |
| 11 | + |
| 12 | +## Prerequisites |
| 13 | + - You've set up SAP Application Interface Framework |
| 14 | + - SAP S/4HANA 2022 FPS02 or later; for lower releases, apply SAP note [3274990](https://launchpad.support.sap.com/#/notes/3274990) |
| 15 | + - You've completed the tutorial [Create a Simple IDoc Interface](aif-idoc-monitoring-interface-create) |
| 16 | + |
| 17 | +## You will learn |
| 18 | + - How to enhance an IDoc interface in SAP Application Interface Framework using the preprocessing capability |
| 19 | + - How to implement mappings in SAP Application Interface Framework |
| 20 | + |
| 21 | + |
| 22 | +## Intro |
| 23 | +In this tutorial, you will learn how to enhance a simple IDoc interface in SAP Application Interface Framework by enabling the preprocessing capability. The preprocessing capability allows you to not only monitor your IDoc interface but also to implement additional mappings, data checks, business logic, and so on, without changing your existing IDoc configuration, that is, without the need to change the existing partner profile. |
| 24 | + |
| 25 | +--- |
| 26 | + |
| 27 | +### Change existing interface |
| 28 | + |
| 29 | + |
| 30 | +1. Go to **Customizing** for SAP Application Interface Framework (transaction code `/AIF/CUST`) and navigate to **Interface Development** > **Define Interfaces**. In the upcoming dialog, enter your previously created namespace **`DEMO_1`**, and continue. |
| 31 | + |
| 32 | +2. Enable **Change** mode. Double-click the existing interface `FCUSTOMER` to open it. Deselect the **Move Corresponding Structures** flag and select the **Pre-Processing** flag. |
| 33 | + |
| 34 | + <!-- border --> |
| 35 | + |
| 36 | +3. **Save** your changes. |
| 37 | + |
| 38 | + |
| 39 | +### Select source and destination structures |
| 40 | + |
| 41 | + |
| 42 | +1. While in **Customizing** (transaction code `/AIF/CUST`), navigate to **Interface Development** > **Define Structure Mappings**. |
| 43 | + |
| 44 | +2. In the upcoming dialog, enter your previously created namespace **`DEMO_1`**, interface name **`FCUSTOMER`**, and interface version **`1`**. Choose **Continue**. |
| 45 | + |
| 46 | +3. Choose **New Entries** and enter the root node of your interface structure, here **`ZDEMO_1_FLCUSTOMER_CREATEFROMD`**. |
| 47 | + |
| 48 | + <!-- border --> |
| 49 | + |
| 50 | +4. Select the new entry and double-click **Assign Destination Structure** in the menu on the left. |
| 51 | + |
| 52 | +5. Choose **New Entries** and enter the **Number of Structure Mapping** **`10`**. As **Destination Structure**, enter the same root node of your interface structure, **`ZDEMO_1_FLCUSTOMER_CREATEFROMD`**. Finally, select the **Move Corresponding Fields** flag. |
| 53 | + |
| 54 | + <!-- border --> |
| 55 | + |
| 56 | +6. **Save** your changes. |
| 57 | + |
| 58 | + |
| 59 | +### Add a fixed value |
| 60 | + |
| 61 | +We would like to set a fixed discount when creating a new customer. |
| 62 | + |
| 63 | +1. While in **Define Structure Mappings**, with your destination structure `ZDEMO_1_FLCUSTOMER_CREATEFROMD` selected, double-click the node **Define Fix Values** in the menu on the left. In **Change mode**, choose **New Entries** to add a new fixed value, and enter or select the following details: |
| 64 | + |
| 65 | + | Field | Value |
| 66 | + | :---- | :---- |
| 67 | + | Field Name | **`E1SCU_CRE-E1BPSCUNEW-DISCOUNT`** |
| 68 | + | Namespace | **`DEMO_1`** |
| 69 | + | Name of Fix Value | **`FCUST_DISCOUNT`** |
| 70 | + |
| 71 | +2. Press **Enter**. Because the fix value doesn't exist yet, you are asked to create the new fix value. |
| 72 | + |
| 73 | + <!-- border --> |
| 74 | + |
| 75 | +3. **Save** the new entry. |
| 76 | + |
| 77 | +4. Double-click the new fix value to further define it. A new window opens in which you can enter the following information: |
| 78 | + |
| 79 | + | Field | Value |
| 80 | + | :---- | :----- |
| 81 | + | Fix Value Description | Enter a meaningful description, for example **`Flight customer discount`**. |
| 82 | + | Value | **`10`** |
| 83 | + |
| 84 | + <!-- border --> |
| 85 | + |
| 86 | + |
| 87 | +5. **Save** your changes and close the new window. |
| 88 | + |
| 89 | + |
| 90 | +### Define value mapping |
| 91 | + |
| 92 | + |
| 93 | +1. While in **Define Structure Mappings**, with your destination structure `ZDEMO_1_FLCUSTOMER_CREATEFROMD` selected, double-click the node **Define Field Mappings**. Create a new entry by choosing **New Entry** and define the field mapping as follows: |
| 94 | + |
| 95 | + | Field | Value |
| 96 | + | :---- | :----- |
| 97 | + | Field in Destination Structure | **`E1SCU_CRE-E1BPSCUNEW-CUSTTYPE`** |
| 98 | + | Field Name 1 | **`E1SCU_CRE-E1BPSCUNEW-CUSTTYPE`** |
| 99 | + | Namespace | **`DEMO_1`** |
| 100 | + | Value Mapping | **`VM_CUSTTYPE`** |
| 101 | + |
| 102 | + Since the value mapping doesn't exist yet, you are asked to create it. Confirm the dialog. |
| 103 | + |
| 104 | +2. Navigate to the reusable value mapping by double-clicking `VM_CUSTTYPE` and define it with the following information: |
| 105 | + |
| 106 | + | Field | Value |
| 107 | + | :--- | :---- |
| 108 | + | Value mapping description | **`Map customer type`** |
| 109 | + | Data Element for INT | **`S_CUSTTYPE`** |
| 110 | + | Number of External Values | **`1`** |
| 111 | + | Single or Multiple Value Mapping | **`Single`** |
| 112 | + | Customizing or Master Data | **`Master Data`** |
| 113 | + |
| 114 | + <!-- border --> |
| 115 | + |
| 116 | +3. Save the value mapping and navigate back to **Define Field Mappings**. Your field mapping should look like this: |
| 117 | + |
| 118 | + <!-- border --> |
| 119 | + |
| 120 | +4. **Save** your changes. |
| 121 | + |
| 122 | + |
| 123 | +### Maintain value mappings |
| 124 | + |
| 125 | +In the mapping, you created a value mapping for the customer type. Before you run the scenario, maintain the value mapping table entries. |
| 126 | + |
| 127 | +1. In **Maintenance of value mappings** (transaction code `/AIF/VMAP`), enter namespace **`DEMO_1`** and your value mapping name **`VM_CUSTTYPE`**. Press **Enter** and choose **Execute**. |
| 128 | + |
| 129 | + <!-- border --> |
| 130 | + |
| 131 | +2. Choose **Append** and add the following two new entries: |
| 132 | + |
| 133 | + | Index | External Value | B/P customer |
| 134 | + | :--- | :--- | :--- |
| 135 | + | **`1`** | **`1`** | **`P`** |
| 136 | + | **`2`** | **`2`** | **`B`** |
| 137 | + |
| 138 | +3. **Save** your changes. |
| 139 | + |
| 140 | + |
| 141 | +### Assign IDoc Types |
| 142 | + |
| 143 | + |
| 144 | +1. Go to **Customizing** for SAP Application Interface Framework (transaction code `/AIF/CUST`) and navigate to **Interface Development** > **Additional Interface Properties** > **Assign IDoc Types**. In the upcoming dialog, enter your previously created namespace **`DEMO_1`**, and continue. |
| 145 | + |
| 146 | +2. Double-click the existing interface `FCUSTOMER` to open it and select the **Preprocessing (IDoc Runtime)** flag. |
| 147 | + |
| 148 | + <!-- border --> |
| 149 | + |
| 150 | +3. **Save** your changes. |
| 151 | + |
| 152 | + |
| 153 | +### Test IDoc interface |
| 154 | + |
| 155 | +After the setup is complete, test your settings and verify that the IDoc monitoring is working as planned. |
| 156 | + |
| 157 | +1. Send in new test IDocs, for example using the **Test Tool for IDoc Processing** (transaction code `WE19`). |
| 158 | + |
| 159 | +2. In the test tool, maintain basic type `FLCUSTOMER_CREATEFROMDATA01`. |
| 160 | + |
| 161 | +3. Maintain the control record fields corresponding to your partner profile and the port created beforehand as follows: |
| 162 | + |
| 163 | + | Field name | Value |
| 164 | + | :---------------------------- | :------- |
| 165 | + | Receiver Port | `SAP<SID>` (`<SID>` being your system ID) |
| 166 | + | Receiver Partner Number | The partner number as specified in the partner profile |
| 167 | + | Receiver Type | `LS` |
| 168 | + | Sender Port | The port as specified before |
| 169 | + | Sender Partner Number | The partner number as specified in the partner profile |
| 170 | + | Sender Type | `LS` |
| 171 | + | Message Type | **`FLCUSTOMER_CREATEFROMDATA`** |
| 172 | + |
| 173 | +4. Maintain sample data record by entering at least customer name, form, street, postcode, city, country and customer type. As customer type, choose either `1` or `2`. |
| 174 | + |
| 175 | +5. Then, choose **Standard Inbound**. A dialog pops up informing you that the IDoc was passed to the application. |
| 176 | + |
| 177 | + <!-- border --> |
| 178 | + |
| 179 | +6. Check the results of your test in the **Interface Monitor** (transaction code `/AIF/IFMON`). When you select the summary line for your interface, you're forwarded to **Monitoring and Error Handling**, where you can see your selected test message(s). |
| 180 | + |
| 181 | + <!-- border --> |
| 182 | + |
| 183 | + As you can see, the flight customer has been successfully created. Note down the generated customer ID provided in the log message. You need it in the next step. |
| 184 | + |
| 185 | +7. To check that the mappings worked as expected, open the **SCUSTOM record display** (transaction code `BC_GLOBAL_SCUST_DISP`), and enter the beforehand copied customer ID into the filter, then choose **Display**. |
| 186 | + |
| 187 | + <!-- border --> |
| 188 | + |
| 189 | + In the data record, you can see that the customer type and the discount have been successfully mapped. |
| 190 | + |
| 191 | + <!-- border --> |
| 192 | + |
| 193 | + |
| 194 | +Congratulations! You have enhanced an IDoc interface with preprocessing in SAP Application Interface Framework. |
| 195 | + |
| 196 | + |
| 197 | +### Test yourself |
| 198 | + |
| 199 | + |
| 200 | + |
| 201 | + |
| 202 | + |
| 203 | +--- |
0 commit comments