Quantcast
Channel: SCN : Document List - ABAP Development
Viewing all articles
Browse latest Browse all 935

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

$
0
0

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

1.png

    • Release Strategies

    2.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:

    3.png

    Create an internal type GTY_RELCODE with the below fields:

    4.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.

    5.png

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

    6.png

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

    7.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.

    8.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'.

    9.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.

    10.png

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

    11.png

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

    12.png

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

    13.png

    Executing the report program created for this:

    14.png

    Entering the customizing transport for locking the configuration changes:

    15.png

    The data gets saved.

    16.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

    17.png

    18.png

    19.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:

    20.png

    Create an internal type GTY_RELSTRAT with the below fields:

    21.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.

    22.png

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

    23.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.

    24.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:


    25.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.

    26.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.

    27.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.

    28.png

    29.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.

    30.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:

    31.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.


    32.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.

    33.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.

    34.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.

    35.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.

    36.png

    37.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:

    38.png

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

    39.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.

    40.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'.


    41.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.

    42.png

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

    43.png

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

    44.png

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

    45.png

    Executing the report program created for this:

    46.png

    Entering the customizing transport for locking the configuration changes:


    47.png

    The data gets saved.

    48.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

    49.png

    50.png

    51.png

    52.png

    53.png

    54.png

    55.png

    56.png



    REFERENCES

     

    http://help.sap.com/

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


    Viewing all articles
    Browse latest Browse all 935

    Trending Articles



    <script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>