Thursday, June 1, 2023

Mass Purchase Order Reprice with S/4 HANA

Introduction: 

In this blog, I will try to demonstrate the functionality of mass purchase order reprice in SAP S/4 HANA.

The pandemic lead to a massive shutdown followed by a slowdown and cause supply chain disruption. Disruption in the supply chain, raising fuel and freight costs often leads to frequent price changes from the vendors (especially oversees long lead time items). As a buyer, it’s important to catch up with frequent and fast changes to make sure the landed cost of the product is correct and 3-way match happens as accurately as possible. This blog will help on how to achieve the solution.

Prerequisites:

  • Price update from the vendor will be updated on Purchasing Info Record as a new valid condition record.

Standard SAP options:

Below is the standard SAP option that was explored:

  • Standard SAP has t-code: MEI1 which allows updating PO based on condition changes, but standard SAP looks at the PO creation date and condition validity period date and updates the price.
  • It was also found that once we process records using MEI1, it is deleting the Table: WIND entries for that vendor of all the items. That means as a buyer, if you want to work on certain items on the PO the next day, you lost visibility of price updates.

Both of the above challenges force me to think of a custom solution.

Solution Approach/Design:

  • Create a Fiori tile as per the below layout

Selection%20Layout

Selection Layout

    • No of Day in the Past*: Mandatory; This is for performance. From day of execution, how many days back do we want to go for the document date; by default 180 days.
    • Purchasing Group*: Mandatory; Multiple selection drop-down; Validation: T024- T024; E: Purchasing Group Required or E: Invalid Purchasing Group.
    • Purchasing Document Type: Optional; Multiple selection drop-down; Validation: T161- BSART; E: Invalid Document type.
    • Supplier: Optional; Multiple selection drop-down; Validation: LFA1- LIFNR; E: Invalid Supplier.
    • Supplier Subrange: Optional; Multiple selection drop-down; Validation: WYT1- LTSNR; E: Invalid Supplier Subrange.
    • Plant#: Optional; Multiple selection drop-down; Validation: T001W-WERKS; E: Invalid Plant.
    • Material Group#: Optional; Multiple selection drop-down; Validation: T023-MATKL; E: Invalid material group.
    • Material#: Optional; Multiple selection drop-down; Validation: MARC-MATNR; E: Invalid material.
    • Next Period Price/Currency: Optional;
    • Price Over-Ride: Optional
    • Future Cost Match: Optional; drop-down; values are Yes Or No
  • Fiori tile validates the data keyed in by the user and captures the appropriate error message in case of errors as stated above.
  • After validating input screen data, once the user clicks on go, the program does the following:
    • Based on the input, fetch the only open PO(s) undelete and without Free of Charge. Open PO(s) can be found where EKPO-ELIKZ not equal to X and undeleted PO(s) can be found where EKPO-LOEKZ is not equal to L and EKPO- REPOS = X (Excluding Free PO(s) as well).
    • Only fetch the PO(s) where item category EKPO-PSTYP not equal to 2 – Consignment and 7 – Stock Transfer (Basically, we don’t want consignment and stock transfer PO(s) as it doesn’t have net price).
  • Below are the fields and logic:
Field(s)Logic
 
Purchase OrderFrom EKPO-EBELN
VendorFrom EKKO-LIFNR
Vendor NamePass Vendor from EKKO to LFA1 and get LFA1-NAME1
Supplier SubrangeFrom EKPO-LTSNR
Supplier Subrange DescriptionPass Vendor and Subrange to WYT1 and get WYT1-LTSBZ
Purchasing GroupFrom EKKO-EKGRP
Purchasing Group NamePass the purchasing group code to T024 and get T024 – EKNAM.
Document TypeFrom EKKO-BSART
Item NoEKPO-EBELP
Item CategoryEKPO-PSTYP
MaterialEKPO-MATNR
Material GroupEKPO-MATKL
Material Group DescriptionPass material group to T023 and get T023- WGBEZ
PlantEKPO-WERKS
Material DescriptionMARA-MAKTX
PO Creation DateEKKO-AEDAT
PO QuantityEKPO-MENGE
Ordering UnitEKPO-MEINS
Conf. ControlEKPO-BSTAE
Inbound DeliveryPass PO number, item number, Confirm. Cat.: LA to EKES and get the inbound delivery number. If multiple found, then sort in descending order and get the latest one.
PO HistoryPass PO and item to EKBE and see entries found. If entry is there, then show the graph. Note: T-code: ME2N is prime example on how to show the graph. If developer can find, then we should leverage that.
PO Item Delivery DatePass PO and item number to EKET and get EKET-EINDT
Price OverwritePass PO to Table: EKKO and get the Doc. Condition No. (EKKO- KNUMV). Pass Condition No. To table: PRCD_ELEMENTS with PO item number and Inactive condition (KINAK) as blank and see if we have PBXX. If yes then show PBXX else blank
PO Net Price/CurrencyEKPO-NETPR/EKKO-WAERS (for example $2800/USD)
PO Price Unit/Ordering Price UnitEKPO-PEINH/EKPO-BPRME (for example 100/EA)
Current Period Validity Date (From – to)

Note: Within PB00 pricing team is loading price in tables: A017 and A018. If the A017 record then gets trigger else it will go to A018.

*****************************************************

Logic: (Developer can explore functional module. I have tried using ME_GET_INFORECORD_CONDITIONS which works fine for PB00 and PB01)

Pass Application – KAPPL = M, Condition Type – KSCHL = PB00, Vendor – LIFNR, Material – MATNR, Purchasing Org – EKORG, Plant – WERKS, Info Type – from PO line to Table: A017 and get the condition record number where Valid From < = System Date and Valid To > = System Date. Pass all the records to KONP, sort by ascending order and select 1st non-delete record. If no record is  found then go to next.

Pass Application – KAPPL = M, Condition Type – KSCHL = PB00, Vendor – LIFNR, Material – MATNR, Purchasing Org – EKORG, Plant – WERKS, Info Type – from PO line to Table : A018 and get the condition record number where Valid From < = System Date and Valid To > = System Date. Pass all the records to KONP, sort by ascending order and select 1st non-delete record. If no record found, then go to next.

Also get A017-DATAB to A017-DATBI or A018-DATAB to A018-DATBI for valid record

Current Period Price/CurrencyFor the valid condition record get the KONP-KBETR/KONP-KONWA (For example $284/USD)
Current Period Price Unit/UoMAlso get the KONP-KPEIN/KONP-KMEIN (For example 100/LB)
Scale Exist? (Flag Yes or No)If KONP- KZBZG has value, then Scale Exist = Yes else No
Apply Updated CostCheckbox
Yes or No value for PO Price Vs. Next Period PriceCompare PO Net Price/Current, PO Price Unit/Ordering Price Unit with Next Period Price/Currency and Next Period Price Unit/UoM. If it’s matching, then show Yes else No.
Previous Period Validity Date (From – to)

Pass Application – KAPPL = M, Condition Type – KSCHL = PB00, Vendor – LIFNR, Material – MATNR, Purchasing Org – EKORG, Plant – WERKS, Info Type – from PO line to Table : A017 and get the condition record number where Valid From < System Date. Pass all the records to KONP, sort by descending order and select 1st non-delete record. If no record found then go to next.

Pass Application – KAPPL = M, Condition Type – KSCHL = PB00, Vendor – LIFNR, Material – MATNR, Purchasing Org – EKORG, Plant – WERKS, Info Type -from PO line to Table: A018 and get the condition record number where Valid From < System Date. Pass all the records to KONP, sort by descending order and select 1st non-delete record. If no record found, then go to next.

Also, get A017-DATAB to A017-DATBI or A018-DATAB to A018-DATBI for valid record

Previous Period Price/CurrencyFor the valid condition record get the KONP-KBETR/KONP-KONWA (For example $284/USD)
Previous Period Price Unit/UoMAlso get the KONP-KPEIN/KONP-KMEIN (For example 100/LB)
Yes or No value for PO Price Vs. Previous Period PriceCompare PO Net Price/Current, PO Price Unit/Ordering Price Unit with Previous Period Price/Currency and Previous Period Price Unit/UoM. If it’s matching, then Yes else No.
Purchasing Info Record

Pass PO number and line item to EKPO and get the EKPO- INFNR. Show that as Hyperlink and when user clicks on it, it should call T-code:ME13 (Fiori tile:

Display Purchasing Info Record). Pass the PIR Number, Purchase Organization and Plant to display the record.

Status LogSuccessful/Failed message
  • After displaying output and sorting output user will select checkbox for “apply updated cost”. Program should do following:
    • For selected PO & line items, it should say “Ready to update the price”? If user click YES, then go to next. If user click NO, then cancel the update.
    • Upon yes, update the price on PO for that item.
    • Developer can use functional module: BAPI_PO_CHANGE to update the price on PO.
    • For PO change, enter the condition type: PBXX to suggest price change.

Results after Implementing solution:

Selection%20Screen

Selection Screen

Buyers click on go after entering single or multiple purchasing groups

Output

Output

More%20fields%20in%20Output

More fields in the Output

More%20Fields%20In%20Output

More Fields In the Output

As shown below, buyer can select one purchase order or multiple purchase orders and click on “Apply PO Cost”

Apply%20PO%20Cost

Apply PO Cost

Confirmation%20for%20Update

Confirmation for Update

Update%20Message

Update Message

Conclusion:

  • It’s allowing buyer to update the price on purchase order in mass and catch up with frequent price changes with vendors.
  • It will provide lot of efficiency to buyers across organization.
  • Landed cost of the provide will be correct and 3 way invoice will be more accurate and less back and forth with AP department.

How To Deactivate Storage Location In S/4 HANA

Introduction: 

To initiate, it’s worth considering how often clients have asked you to deactivate storage locations within a plant during your SAP career. This may have happened numerous times, prompting the following question: what’s the solution for deactivating them? Deleting the storage location after it’s been created isn’t the best because it can lead to database inconsistencies (Table: MARD has Material, Plant, and Storage Location combination). Therefore, one possible solution is to rename the storage location name as “DON’T USE,” which will make it clear to users that it’s no longer in use. After renaming it to “DON’T USE,” the storage location will still appear in the dropdown list, and the possibility that the user will create/extend materials to a storage location.

The configuration in S/4 HANA now allows for the deactivation of storage locations, a functionality not previously available in SAP. Note: This is performed on S4HANA ON PREMISE – 2021 Version.

Configuration:

IMG PathSPRO –> IMG –> Enterprise Structure –> Definition –> Materials Management –> Maintain storage location (T-code: OX09)

Validity

Validity

As shown above, SAP has now introduced Validity Field with Dropdown Value as

  • Blank – Valid. This means the entry is valid and is displayed in input help. The user can select this valid entry.
  • E – No Longer Valid. The entry is invalid and is no longer displayed in input help.
  • W – Deprecated. The entry will no longer be used in the future but is still displayed in input help. The system warns if the user selects this entry in input help.

Scenario 1: Change Validity from Blank to E – No Longer Valid

T-code: OX09

Configuration%20Change

Configuration Change

Configuration%20Change

Configuration Change

Configuration%20Change%20to%20E

Configuration Change to E

Validity%20E

Validity E

  • Create New Material using T-code: MM01.

MM01%20Validation

MM01 Validation

  • If we tried to extend the material to the storage location using T-code: MMSC, then values don’t appear.

MMSC%20Validation

MMSC Validation

Scenario 2: Change Validity from Blank to W – Deprecated

T-code: OX09

Configuration%20Change

Configuration Change

Configuration%20Change

Configuration Change

Configuration%20Change%20to%20W

Configuration Change to W

Validity%20W

Validity W

  • Create New Material using T-code: MM01.

MM01%20Validation

MM01 Validation

MM01%20Validation%20for%20SL

MM01 Validation for SL

  • If we try to extend the material to the storage location using T-code: MMSC, it will show a warning message.

MMSC%20Validation

MMSC Validation

Conclusion:

  • With SAP S/4 HANA, we can now use validity functionality to control the storage location validity Vs. just using a description.

Flexible Workflow for Sourcing and Procurement in SAP S/4HANA

Flexible Workflow is a new concept introduced in SAP S/4HANA with the objective of simplifying workflow configuration. Documents in Sourcing and Procurement, such as purchase requisition, purchase order, request for quotation, etc., usually go through an approval process. In the SAP ERP system, we used Release Procedure and, in some cases, SAP Business Workflow to accomplish this process. For example, the approval process for a PO could be as simple as the following: any PO exceeding $1000 requires a manager’s approval and any PO exceeding $5000 requires two levels of approval.  

Even though both Release Procedure and SAP Business Workflow are still available in S/4HANA, it is recommended that you use the new Flexible Workflow functionality in S/4HANA. The flexible workflow is based on a set of predefined workflow scenarios and tasks. This provides the functionality to define condition-based workflow for different processes in sourcing and procurement. It is possible to define single or multi step approval processes, and the relevant workflow items are made available in the My Inbox Fiori App for the approvers. Manage Workflows Fiori Apps are available for different purchasing documents, and these apps allow the Business process specialist to set up workflows based on the business requirement.

In this blog, I will explain the configuration steps and provide screenshots for workflows for Purchase Order. The steps to implement workflows for other purchasing documents are similar, and the information provided in this blog may be used as reference material. 

Prerequisites: 

  • Maintain Workflow ID and Task ID for Purchasing Documents 
  • Manage Workflows for Purchase order and Maintain Email template tile is available in the Fiori Launchpad 
  • Ensure that the automatic Customizing is active for the workflow functionality in SWU3 T- Code. 
  • My Inbox relevant customizing should be in place 
  • Business Partners with Personal Number must be generated for the user (Purchasing Manager) who is going to approve purchase documents in the system. 

Differences and Advantages between Classic Release strategy and Flexible Workflow: 

Strategy  Operation Starting Condition  Validity Period Step Sequence Class/ Characteristics HCM Required Deadline 
Classic Release Strategy SAP GUI  Net Value, CO-Code, PUR.Grp, Material group, Currency etc., No No Yes No No 
Flexible Workflow Fiori APP  Cost center, Currency, Company Code, Net order Value, PUR.Group etc.,  Yes Yes No Yes Yes 

 

Flexible Workflow for Purchase Order – Configuration steps: 

Step – 1  Flexible Scenario Activation MM Consultant 
Step – 2  Activate Flexible Workflow for Document Types  MM consultant 
Step – 3  Maintain Task Names and Decision Points ABAP Consultant 
Step – 4  Client Dependent Configuration Basis Consultant 
Step – 5  Perform Task Specific Configuration ABAP Consultant 
Step – 6  Activate Push Notification 2.0 ABAP Consultant 
Step – 7  Manage Workflows for Document Types MM Consultant 

 

  1. Automatic Workflow Customizing 

SPRO => IMG => Material Management => Purchasing => Purchase Order => Flexible Workflow For Purchase Order => Maintain Standard Settings 

This Customizing activity has the following areas 

  • Runtime Environment 
  • Definition Environment 
  • Additional Settings and Services 
  • Classify Tasks as General 

Open the Manage Workflow for Purchase Orders. The application is blank with the message “There are currently no scenarios available”. 

2.  Activate flexible workflow scenarios 

SPRO => IMG => Material Management => Purchasing => Purchase Order => Flexible Workflow for Purchase Order => Scenario Activation 

Activate the workflow scenario ID as shown in the table below. Scenarios will become visible in the Manage Workflows for Purchase Order Fiori App once activated here. 

Scenario ID Workflow Name 
WS02000238 Release of Purchase Order (Manual) 

 

3.  Activate Flexible Workflow for Purchase Order Doc. Types 

SPRO => IMG => Material Management => Purchasing => Purchase Order => Flexible Workflow for Purchase Order => Activate Flexible Workflow for Purchase Orders

 

4.  HR-BP-User synchronization: 

It is the prerequisite to use HR and BP to assign the task of releasing PO for a user, assign a user to the Personnel number with the communication type. 

Step:1  Create a Personnel Number with the transaction PA30: 

Maintain the Communication as System User ID Name.

Click on Overview see their details.

 

Step: 2   Create a business partner with the transaction BP 

  • Create the Business partner as a Person 
  • In the Standard BP Role of 000000 we can assign the ID Type and Personnel Number in the Identification tab as shown in the below picture. 

At the end-run report /SHCM/RH_SYNC_BUPA_EMPL_ SINGLE to synchronize created master data. 

 

  • Back End Settings Maintain Before HR-BP-User synchronization:

Step: 3   Define Personal Areas 

SPRO => IMG => Enterprise Structure => Definition => Human Resources Management => Personnel Areas 

Click on Personal areas

Select the line item click on details 

 

Step: 4   Define Personal Subareas 

SPRO => IMG => Enterprise Structure => Definition => Human Resources Management => Personnel Subareas. 

Click on Create Personal Subareas 

Click on New entries create new one 

 

Step: 5   Assignment of Personnel Area to Company Code 

SPRO => IMG => Enterprise Structure => Assignment => Human Resources Management => Assignment of Personnel Area to Company Code. 

 

Search in the APP Finder for which Process we have to create. Here I’m doing Manage Flexible workflow for Purchase Order. 

4.  Manage Workflow for Purchase Order: Setup Required Pre-conditions and Step Sequence.  

Click the Add button to create a new workflow for purchase orders. This will open the Nelw workflow page 

Enter Workflow Name, Description, Valid From, Valid To. Enter the Start Condition for the workflow.

To add the Step sequence, click the add button in the Step Sequence Section. In the New Step page, Enter the Step Name and Step Type as Release of Purchase Order. 

5.  For Recipients Select User for Assignment By. For the user field, select a user from the Search help. 

There are two options: 

  1. One of the Recipients – If one Recipients is Approved the Flexible workflow is released. 
  1. All of the Recipients – If there are multiple Approvers all Recipients are to be released then only the Flexible Workflow is released. 

If we know the User ID, we can directly enter the username in the search box or else we can click on the Go button to see the existing users in the system. 

 

6. If we can’t get any User ID, then we have to check the below Configuration.

i.  Activate HR Integration –> Goto SM30 –> Maintain table T77S0 –> search for entry group: HRALX, sem. abbr.: HRAC and set the value abbreviation value to X

ii.  Go to the customizing path
SPRO -> Cross-Application Components -> SAP Business Partner -> Business Partner -> Basic Settings -> Identification Numbers -> Define Identification Categories. 

iii.  unset Identification Categories for HCM0001 for Disp. Only.

 

7.  If we maintain all the Pre-requisites correctly the Deadline tab is triggered. 

Exception Handling: 

8.  If the Approver Reject the workflow what is the action result is to be taken is maintained here. 

 9.   click the Add Button to Add the above step to the workflow. 

10.  Click the Save button to save the workflow. 

11.  Click the Activate Button for the workflow to be activated. 

The System defines in the Sequence order. So, we need to maintain flexible workflow at the top or else we can Inactivate the other person’s Flexible Workflow. 

Click the Define Order button to ensure that the workflow gets triggered if the Start conditions are met.

12.  Create a Purchase order in the Manage Purchase order application. We can see the Approval Details for the Purchase Order in the Approval Details tab. 

13.  Open the My Inbox application for If the relevant task is not visible do the below steps. 

14.  Goto SAP Gateway Service Enablement –> Content –> Workflow Settings –> Maintain Task Names and Decision Options. 

i.  In the Step Name: Overview 

ii.  Select the above entry and click on Decision Keys and maintain the two Decision keys as below. 

15.  Assign Agents and Activate Event Linkages for Workflow ID WS 00800238 and TS 00800531 

SAP NetWeaver –> Application Server –> Business Management –> SAP Business –>Workflow –> Perform task-specific Customizing 

i.  Navigate to the SAP application component MM-PUR-PO 

ii.  Click Assign Agents –> select line with TS00800531 –> Click Attributes and select General Task–>click Transfer.

iii.  Click Activate Event Linking–>Expand the hierarchy to display the relevant event for WS00800238 –>Activate the linkage for the listed event by clicking on the Deactivated button.

Now create the Purchase order in ME21N T- Code 

Based on the Document Type and the starting conditions that we maintained in the FIORI App the Flexible workflow is triggered. 

Here Flexible Workflow is trigger and check the Approver details.

Check Task ID and Status.

The Approver has logged in to the FIORI APP and in the Inbox App he gets the notifications. He went to the Inbox App and released the document (Either Approve/Reject). 

iv.  Once done the task will be visible in the My Inbox application, but still, there is no mail received by the recipient. 

16.  Now let’s set up the Email transmission. The prerequisite to set up the Email is as below: 

i.  In Transaction Code S_ATO_SETUP, set up Adaptation Transport organizer with specific data using ZZ1_ as prefix and sandbox prefix as ZZ9_. 

After maintaining the prefix and sandbox prefix click on the setup specific data to create setup.

 

ii.  SOST and SCOT configuration should be in place

These are the initial screens of SOST and SCOT. These two transcations are done by the Basis team.

Transaction code SOST is used to display and administer of all messages sent using SAPconnect. The program displays send requests that are being sent, or have already been sent by using SAPconnect. In this transaction, a send request always contains just one recipient.

Mainly SCOT Transcation code is the one where we can get the notifications through Mail ID, FAX etc.,

To add/create the Mail ID.

iii.  Ensure Email address is maintained for the users in su01.

17.  Open the Maintain Email Template application. In the pre-delivered section find the template SWF_CRT_NOTIFY_RECIPIENTS. 

18.  Copy the above-mentioned template for each of the workflow scenarios. e.g., YY1_00800238_CRT_ALL for PO. This workflow template will be triggered to notify the recipients of the newly created PO, or whenever there is a PO task for approval. 

19.  Copy the pre-delivered template SWF_WORKFLOW_COMPLETE_NOTIFY for each of the workflow scenarios. e.g., YY1_00800238_COMPLETE_POSITIVE for PO. These workflow templates will be triggered to notify the recipients of the completed POs, whether completed positively or negatively.

Test again by creating a PO. If the mail is still not getting triggered Report RSWF_OUTPUT_MANAGEMENT needs to be executed manually with parameter productive in order to release the emails manually.

With this, we conclude the configuration required for Flexible Workflow for Purchase Order including the email trigger functionality. Please do share in the comments if there are issues apart from the ones mentioned in the blog. 

Conclusion: Flexible workflows can be customized through the scenarios that can be created and made suitable according to the needs of your processes without needing any development. Also, key users can make changes and edit these scenarios without needing developers.