Skip to Content
Author's profile photo Former Member

Mass Upload of Purchase Order Release Codes and Release Strategies – A Function Module Approach

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

/wp-content/uploads/2014/10/1_568817.png

    • Release Strategies

/wp-content/uploads/2014/10/2_568818.png


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:

/wp-content/uploads/2014/10/3_568819.png

Create an internal type GTY_RELCODE with the below fields:

/wp-content/uploads/2014/10/4_568838.png

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.

/wp-content/uploads/2014/10/5_568839.png

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

/wp-content/uploads/2014/10/6_568840.png

For uploading the release codes, we need to use the viewVV_T16FC_2′, as seen below.

/wp-content/uploads/2014/10/7_568850.png

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.

/wp-content/uploads/2014/10/8_568851.png

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.

/wp-content/uploads/2014/10/9_568852.png

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.

/wp-content/uploads/2014/10/10_568856.png

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

/wp-content/uploads/2014/10/11_568857.png

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

/wp-content/uploads/2014/10/12_568858.png

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

/wp-content/uploads/2014/10/13_568859.png

Executing the report program created for this:

/wp-content/uploads/2014/10/14_568860.png

Entering the customizing transport for locking the configuration changes:

/wp-content/uploads/2014/10/15_568861.png

The data gets saved.

/wp-content/uploads/2014/10/16_568865.png

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

/wp-content/uploads/2014/10/17_568866.png

/wp-content/uploads/2014/10/18_568868.png

/wp-content/uploads/2014/10/19_568869.png

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:

/wp-content/uploads/2014/10/20_568870.png

Create an internal type GTY_RELSTRAT with the below fields:

/wp-content/uploads/2014/10/21_568871.png

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.

/wp-content/uploads/2014/10/22_568872.png

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

/wp-content/uploads/2014/10/23_568873.png

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.

/wp-content/uploads/2014/10/24_568874.png

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:


/wp-content/uploads/2014/10/25_568875.png

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.

/wp-content/uploads/2014/10/26_568876.png

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.

/wp-content/uploads/2014/10/27_568877.png

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.

/wp-content/uploads/2014/10/28_568878.png

/wp-content/uploads/2014/10/29_568879.png

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.

/wp-content/uploads/2014/10/30_568880.png

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:

/wp-content/uploads/2014/10/31_568881.png

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.


/wp-content/uploads/2014/10/32_568882.png

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.

/wp-content/uploads/2014/10/33_568887.png

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.

/wp-content/uploads/2014/10/34_568888.png

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.

/wp-content/uploads/2014/10/35_568892.png

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.

/wp-content/uploads/2014/10/36_568893.png

/wp-content/uploads/2014/10/37_568894.png

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:

/wp-content/uploads/2014/10/38_568895.png

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

/wp-content/uploads/2014/10/39_568896.png

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.

/wp-content/uploads/2014/10/40_568897.png

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.


/wp-content/uploads/2014/10/41_568898.png

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.

/wp-content/uploads/2014/10/42_568899.png

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

/wp-content/uploads/2014/10/43_568900.png

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

/wp-content/uploads/2014/10/44_568901.png

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

/wp-content/uploads/2014/10/45_568902.png

Executing the report program created for this:

/wp-content/uploads/2014/10/46_568903.png

Entering the customizing transport for locking the configuration changes:


/wp-content/uploads/2014/10/47_568904.png

The data gets saved.

/wp-content/uploads/2014/10/48_568905.png

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

/wp-content/uploads/2014/10/49_568906.png

/wp-content/uploads/2014/10/50_568907.png

/wp-content/uploads/2014/10/51_568908.png

/wp-content/uploads/2014/10/52_568909.png

/wp-content/uploads/2014/10/53_568910.png

/wp-content/uploads/2014/10/54_568911.png

/wp-content/uploads/2014/10/55_568912.png

/wp-content/uploads/2014/10/56_568913.png



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.

Assigned Tags

      11 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Jacques Nomssi Nzali
      Jacques Nomssi Nzali

      Hello George,

      thanks for taking the time.

      Just curious: why do you call this a "Function Module Approach" ?

      regards,

      JNN

      Note: code for method DOWNLOAD_PO_TEMPLATE( ) is missing from source file.

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Hi Jacques Nomssi

      Thank you for the appreciation.

      The standard methods available all over SCN and other sites whenever I searched for was using either a BDC or LSMW, and this would not be a generic approach and also not SAP advised.

      So I just took some interest and pains to see how exactly SAP is doing the same and found out the two main FMs - VIEWPROC_V_T16FC  and VIEWPROC_V_T16FS for Release Code and Release Strategy respectively and then devised a way to implement the same. Hence the name - Function Module Approach. For things like Pre-requisites and Status, even SAP is using INSERT statements, and hence I could not come up with anything for it.

      As for the DOWNLOAD_PO_TEMPLATE() method, I myself haven't written the code for it. This coding was done just to test if the logic researched was working or not and is not a complete application by itself. Lot of customization and tweaking would be necessary for deployment.

      Thanks and Regards,

      George Abraham

      Author's profile photo Former Member
      Former Member

      Hi Jacques Nomssi

      Could you please advice how could I download the .txt with the sample code?

      Thanks in advance!!!!

      Author's profile photo Former Member
      Former Member

      Hello Jacques Nomssi,

      Where can I get the TXT File?

      Tks!

      Leo

      Author's profile photo Dario Lato
      Dario Lato

      Hi George Abraham,

      This seems to be a very useful tool. Could you please let me know how can I download the .txt file with the sample code?

      Regards,

      Dario.

      Author's profile photo Jürgen Lins
      Jürgen Lins

      The community platform has changed after this blog was posted. The new platform does not allow attachments, and this just means the old attachment is not accessible anymore.

      Author's profile photo George Abraham
      George Abraham

      Hi Jürgen Lins,

      I am the author of this blog post. However, is there any way to push this to the new platform so that I can still track it under my posts. NOTE: somehow I was not able to access my previous account, so have created a new account.

      Author's profile photo Lajos Nagy
      Lajos Nagy

      Hi George Abraham,

      Could you please send me / upload the program? That would be really helpful.

      Author's profile photo Meng Ngee Er
      Meng Ngee Er

      Thank you, it's very helpful. I'm able to built customize program to upload Release Code and Release Strategy based on your blog.

      There is no need for the source file.

      Author's profile photo Ahmed El Shahat
      Ahmed El Shahat

      Did anybody get the code of these programs, I'm in a deep need of it.

      Author's profile photo Meng Ngee Er
      Meng Ngee Er

      Thank you, it's very helpful. I'm able to built customize program to upload Release Code and Release Strategy based on your blog.