Enterprise Resource Planning Blogs by Members
Gain new perspectives and knowledge about enterprise resource planning in blog posts from community members. Share your own comments and ERP insights today!
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member

EXECUTIVE SUMMARY


Configuration of Release Codes and Release Strategies for a Purchase Order is a major task in the life of an MM functional. In an ideal situation, though this may be a one-time configuration, as per the business scenarios, the configurations need to be changed quite often. Certain projects can have a huge volume of such configurations to be made at a time.


At present, the only methodology available to make the configuration is the manual approach via SPRO configurations. Many have tried to implement an automated methodology for mass uploading of the release codes and strategies, but to no avail as there seemed to be no BAPI or Function Module available for the same. The only automated approach presently available, even online, is an LSMW approach. The main drawback of this LSMW approach is that it is specific to a particular project or method of configuration as it is based on the screen recordings. Hence it cannot be used like a generic tool.


This paper aims to give you a brief overview of a Function Module approach to achieve the desired result of uploading the Release Codes and Strategies from an input file in to the configuration tables. The below explanation and code snippets provided is not a complete end-to-end approach. However, it can be extended to suit the desired results.


BENEFICIARIES:


MM functional consultants who spend a lot of time to manually configure the complete set of Purchase Order Release Strategies and Release Codes


SYSTEM USED:

  1. ECC (Enterprise Central Component)


EXTERNAL INPUT FILE:

  1. Excel File which contains the input data in the desired format. There will be two separate input files for each of the below:
    • Release Codes

    • Release Strategies


STEPS TO BE PERFORMED:


A) ZCL_RELSTRAT_TOOL

For creating a simple tool for the desired result of mass upload of Release Strategy and Release Codes, I have created a class called ZCL_RELSTRAT_TOOL which contains all the methods used in the program. A few of the important methods used in this class are listed below and are also explained further in the paper.

READ_RELCODE

Read New Release Codes From File

UPLOAD_RELCODE

Upload New Release Codes Read From File

READ_RELSTRAT

Read New Release Strategies From File

UPLOAD_RELSTRAT_PREREQ

Upload Release Strategies Prerequisites

UPLOAD_RELSTRAT_STATUSES

Upload Release Strategies Statuses

LOCK_TR_PREREQ_STATUSES

Lock the Prerequisites and Statuses with the Transport

UPLOAD_RELSTRAT

Upload New Release Strategies Read From File


B) Release Codes

Let us first discuss on how to upload the release codes. Assuming that the Release Codes are uploaded via an Excel file in the below format:

Create an internal type GTY_RELCODE with the below fields:

This type is used to create the internal table GT_RELCODE which will store the values for the release codes read from the input file.

In this scenario, use the function module 'TEXT_CONVERT_XLS_TO_SAP' to read the file into the internal table, as seen below:

For uploading the release codes, we need to use the view 'VV_T16FC_2', as seen below.

The main function module used to uploading the Release Codes is 'VIEWPROC_V_T16FC'. Kindly make a note of the parameters being passed to it, as seen below. This code is to be written inside the above method of the class.

In the above function module, the values of DBA_SELLIST (Selection Criteria for DB access), DPL_SELLIST (Selection criteria for displaying), X_HEADER (Control block table for the view) and X_NAMTAB (Control block table for the view fields) parameters need to be fetched specially from the DDIC. These values can be obtained by using the function module 'VIEW_GET_DDIC_INFO'.

For the function module 'VIEWPROC_V_T16FC', it needs two more parameters, EXTRACT and TOTAL which are populated as below:

Note: Action is populated as 'N' which indicates New records to be uploaded.

LT_RELCODE_EXTRACT and LT_RELCODE_TOTAL as all declared of the same type GTY_RELCODE_EXTRACT as shown below:

LT_SELLIST, LT_HEADER, LT_NAMTAB and LT_EXCL_CUA_FUNCT are declared of the below types:

For testing the above logic, below screenshot shows the existing release codes configured in the system.

Executing the report program created for this:

Entering the customizing transport for locking the configuration changes:

The data gets saved.

Rechecking the SPRO configuration, we can see the new entries made and also the same made in T16FC and T16FD tables.


SPRO path:

Materials Management -> Purchasing -> Purchase Order -> Release Procedure for Purchase Orders -> Define Release Procedure for Purchase Orders

B) Release Strategies

Let us now discuss on how to upload the release strategies. Assuming that the Release Strategies are uploaded via an Excel file in the below format:

Create an internal type GTY_RELSTRAT with the below fields:

This type is used to create the internal table GT_RELSTRAT which will store the values for the release codes read from the input file.

In this scenario, use the function module 'TEXT_CONVERT_XLS_TO_SAP' to read the file into the internal table, as seen below:

Before uploading the Release Strategies, we first need to upload the Release Strategy Pre-Requisites, which gets updated into T16FV table, for which we can call the below class method.

The below codes are to be written inside the above method of the class.


Declare an internal table GT_T16FV which is of the type GTY_T16FV which is as below:


Loop through the entries of GT_RELSTRAT and if any of the fields from FRGC1 to FRGC8 is not blank, write the logic to populate the table GT_T16FV with the appropriate pattern along with the UPDKZ field as 'I'. Below is a sample record population.

Looping through the entries of GT_T16FV, if the UPDKZ field is 'I', do a direct insert into T16FV table. For updating T16FV, even SAP does a direct insert as per the standard program.

If the insert is successful, populate the entries of GT_E071K table also so that it updates the transport table E071K as well as populate GT_KO200 table so that it updates KO200 (Interface Structures for Objects in CTS) table.

Once the Release Strategy Pre-Requisites are uploaded, the next step is to upload the Release Strategy Statuses, which gets updated into the T16FK table, for which we call the below method of the class.

This code is to be written inside the above method of the class. Declare an internal table GT_T16FK which is of the type GTY_T16FK which is as below:

If a Release Strategy has 'n' Release Codes, then 'n+1' entries are maintained in the T16FK table with all entries having the Release Indicator (FRGKX) field as '2' and the last record having value as '1'. Also, the UPDKZ field is populated as 'I' as it is a new entry.


So, an appropriate logic needs to be framed for the same to populate the values in the GT_T16FK table. The below code snippet is only a part of the complete logic as the focus is only on the concept.


First, loop through GT_RELSTRAT and find out how many release codes are present. This is maintained in a counter LCNT_CODE which is incremented for each release code.


Then we declare another temporary counter LCNT_CODE_TMP which is initialized to 0. We repeat the entire process for LCNT_CODE times and build the status table. To ensure that in the next iteration, we do not build the same record, we increment the value of the LCNT_CODE_TMP and check if it is less than LCNT_CODE. We also have a flag LF_FLAG which is initially set to 0 and whenever we populate any record, we set it to 1. At the end, we clear the flag while appending the record to the status table GT_T16FK.

Below is the logic for changing the value of the FRGKZ field for the last record, which is also included at the end of the above DO-ENDO.

Looping through the entries of GT_T16FK, if the UPDKZ field is 'I', do a direct insert into T16FK table. For updating T16FK, even SAP does a direct insert as per the standard program.

If the insert is successful, populate the entries of GT_E071K table also so that it updates the transport table E071K as well as populate GT_KO200 table so that it updates KO200 (Interface Structures for Objects in CTS) table.

Once the Pre-Requisites and Statuses are uploaded, we can use the function module 'TR_OBJECTS_INSERT' to lock the both the tables in the transport by passing the GT_E071K and GT_KO200 tables, as seen below:

For uploading the release strategies, we need to use the view 'VV_T16FS_2', as seen below.

This code is to be written inside the above method of the class. The main function module used to uploading the Release Strategies is 'VIEWPROC_V_T16FS'. Kindly make a note of the parameters being passed to it, as seen below.

In the above function module, the values of DBA_SELLIST (Selection Criteria for DB access), DPL_SELLIST (Selection criteria for displaying), X_HEADER (Control block table for the view) and X_NAMTAB (Control block table for the view fields) parameters need to be fetched specially from the DDIC. These values can be obtained by using the function module 'VIEW_GET_DDIC_INFO'.


For the function module 'VIEWPROC_V_T16FS', it needs two more parameters, EXTRACT and TOTAL which are populated as below:

Note: Action is populated as 'N' which indicates New records to be uploaded.

LT_RELSTRAT_EXTRACT and LT_RELSTRAT_TOTAL as all declared of the same type GTY_RELSTRAT_EXTRACT as shown below:

LT_SELLIST, LT_HEADER, LT_NAMTAB and LT_EXCL_CUA_FUNCT are declared of the below types:

For testing the above logic, below screenshot shows the existing release strategies configured in the system.

Executing the report program created for this:

Entering the customizing transport for locking the configuration changes:


The data gets saved.

Rechecking the SPRO configuration, we can see the new entries made including the Pre-Requisites and the Statuses and also the same made in T16FS, T16FT, T16FV and T16FK tables.


SPRO path:

Materials Management -> Purchasing -> Purchase Order -> Release Procedure for Purchase Orders -> Define Release Procedure for Purchase Orders



REFERENCES

http://help.sap.com/

http://www.sdn.sap.com/irj/scn


NOTE: Attached is a TXT file containing maximum of the code snippet. This code was developed for a research and test purpose and can be tweaked accordingly to suit your requirement. However, kindly do not publish or submit this anywhere else as your own content.

11 Comments
Labels in this area