Registration

Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
http://scn.sap.com
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata

Purchase Order Release Strategy Data using ABAP Classes

Link to Content's target Space :

http://wiki.sdn.sap.com/wiki/display/ABAP/ABAP+Development+and+Programming.

Applies to:

Sample Program developed in ECC 5.0.

Summary

This post narrates the use of ABAP classes for Extracting Purchase Order Release Strategy Data.

Author(s):  Vinod Kumar T

   
Company:     NIIT Technologies Limited
Created on:    18.11.2010
Author(s) Bio
Vinod Kumar is an ABAP consultant working for NIIT Technologies Limited.

Table of Contents

Class/Interface & Methods Used

Class/Interface

Method

Description

CL_RECA_DDIC_DOMA

GET_VALUES

Get Fixed Values of Domain

CL_PO_HEADER_HANDLE_MM

SET_STATE

Set current state of Purchase Order

CL_PO_HEADER_HANDLE_MM

PO_INITIALIZE

Initialize/Refresh PO Environment

CL_PO_HEADER_HANDLE_MM

PO_READ

Read Purchase Order

CL_PO_HEADER_HANDLE_MM

GET_DATA

Get PO Header Data

CL_PO_HEADER_HANDLE_MM

IF_RELEASE_STATE_MM~GET_STRATEGY

Instance for PO Release Strategy

IF_RELEASE_STRATEGY_MM

GET_INFO

Complete information of Release Strategy

IF_RELEASE_STRATEGY_MM

GET_INFO_FOR_CODE

Details of Release Codes

CL_PO_HEADER_HANDLE_MM

IF_RELEASABLE_MM~GET_RESPONSIBLE

List of Person Responsible for Release (WF)

CL_PO_HEADER_HANDLE_MM

IF_RELEASE_STATE_MM~GET_INDICATOR

Release Indicator details

CL_PO_HEADER_HANDLE_MM

IF_RELEASE_STATE_MM~IS_RELEASED

Check whether PO is completely Released

CL_PO_HEADER_HANDLE_MM

IF_RELEASE_STATE_MM~CAN_RELEASE

Check whether PO can be released

CL_PO_HEADER_HANDLE_MM

IF_RELEASE_STATE_MM~CAN_RESET_RELEASE

Check whether Release Reset is possible

IF_RELEASE_STRATEGY_MM

GET_CODES_FROM_STATE

Release code details which are already Released

IF_RELEASE_STRATEGY_MM

GET_CODES_FOR_RELEASE

Release code details which are pending for release

Contents in Sample Code

Sample code is used to extract and display the data related to Purchase Order Release Strategy and the Existing state of Purchase order. 

Following information is displayed using this sample code.

  • Release Strategy Information
  • Release Code Details
  • Release Strategy indicators
  • Check whether PO is released?
  • Check whether PO can be released ?
  • Check whether Reset release is possible ?
  • Details of Release codes which are already released & pending for release

Comments

Sample code shows the method to extract the relevant information.  Further processing not mentioned in this post.

Sample Code

Error rendering macro 'code': Invalid value specified for parameter 'lang'
 *&---------------------------------------------------------------------*
*& Report  ZVK_CL_PO1
*&---------------------------------------------------------------------*
*& Report to Extract Purchase Release Strategy Details
*&---------------------------------------------------------------------*
REPORT  ZVK_CL_PO1 NO STANDARD PAGE HEADING.
TABLES : EKKO.
TYPE-POOLS : MMPUR, ABAP.

DATA : ZCL_PO TYPE REF TO CL_PO_HEADER_HANDLE_MM.
DATA : LT_DOMVAL TYPE RE_T_RSDOMAVAL,
       LS_DOMVAL TYPE DD07V.
** Definition for header **
DATA : LS_DOCUMENT   TYPE MEPO_DOCUMENT,
       LV_RESULT     TYPE MMPUR_BOOL,
       LS_MEPOHEADER TYPE MEPOHEADER.
** Definition for Release Parameters **
DATA : LV_RELEASED   TYPE MMPUR_BOOL,
       LV_INDICATOR  TYPE FRGKZ,
       LV_IND_DESC   TYPE FRGET,
       LV_FLREF      TYPE FFREF,
       LV_KZFAE      TYPE KZFAE,
       LV_TLFAE      TYPE TLFAE,
       LV_FIXBP      TYPE FIXBP,
       LV_FRANG      TYPE FRANG,
       LV_FRBST      TYPE FRBST.
** Definition for Release Code Details
DATA : LT_RE_CODES   TYPE MEREL_T_CODES,
       LS_RE_CODES   TYPE MEREL_S_CODE,
       LT_RE_PREQ    TYPE MEREL_T_PREREQ,
       LS_RE_PREQ    TYPE MEREL_S_PREREQ,
       LT_RE_FINAL   TYPE MEREL_T_FINAL,
       LS_RE_FINAL   TYPE MEREL_S_FINAL.
DATA : LV_CONSIST    TYPE MMPUR_BOOL,
       LV_OVERALL    TYPE MMPUR_BOOL,
       LV_RE_ALLOWED TYPE MMPUR_BOOL.
** Definitions for Release Strategy **
DATA : ZIF_STRATEGY  TYPE REF TO IF_RELEASE_STRATEGY_MM.
DATA : LV_FRGGR      TYPE FRGGR,
       LV_FRGGT      TYPE FRGGT,
       LV_FRGSX      TYPE FRGSX,
       LV_FRGXT      TYPE FRGXT.
DATA : LT_CODE_DESC  TYPE MEREL_T_CODE_DESC,
       LS_CODE_DESC  TYPE MEREL_S_CODE_DESC.
DATA : LT_RE_ACTOR   TYPE TACTOR_TEXT,
       LS_RE_ACTOR   TYPE ACTOR_TEXT.
PARAMETERS : P_EBELN TYPE EKKO-EBELN.
** -------------------------------------------- **
** Domain value for KZFAE **
** -------------------------------------------- **
CL_RECA_DDIC_DOMA=>GET_VALUES(
  EXPORTING
    ID_NAME   = 'KZFAE'
    ID_LANGU  = SY-LANGU
  IMPORTING
    ET_VALUES = LT_DOMVAL
  EXCEPTIONS
    NOT_FOUND = 1
    OTHERS    = 2 ).
MOVE MMPUR_PO_PROCESS TO LS_DOCUMENT-PROCESS.
MOVE 'A' TO LS_DOCUMENT-TRTYP.
MOVE P_EBELN TO LS_DOCUMENT-DOC_KEY(10).
MOVE MMPUR_INITIATOR_CALL TO LS_DOCUMENT-INITIATOR-INITIATOR.
** Create Object of Purchase Order Class **
CREATE OBJECT ZCL_PO
  EXPORTING
    IM_PO_NUMBER = P_EBELN
  EXCEPTIONS
    FAILURE = 1
    OTHERS  = 2.
IF SY-SUBRC <> 0.
  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
IF ZCL_PO IS NOT INITIAL.
** Set the state to existing Purchase Order **
  ZCL_PO->SET_STATE( IM_STATE = CL_PO_HEADER_HANDLE_MM=>C_AVAILABLE ).
** Initialize the environment **
  ZCL_PO->PO_INITIALIZE( IM_DOCUMENT = LS_DOCUMENT ).
** Set value to the parameter FOR_BAPI
  ZCL_PO->FOR_BAPI = ABAP_TRUE.
** Read PO document **
  ZCL_PO->PO_READ(
    EXPORTING
      IM_TCODE     = 'ME23N'
      IM_TRTYP     = LS_DOCUMENT-TRTYP
      IM_AKTYP     = LS_DOCUMENT-TRTYP
      IM_PO_NUMBER = P_EBELN
      IM_DOCUMENT  = LS_DOCUMENT
    IMPORTING
      EX_RESULT    = LV_RESULT ).
  IF LV_RESULT = ABAP_TRUE.
** -------------------------------------------- **
** Get Header Data for Release Status **
** -------------------------------------------- **
    ZCL_PO->GET_DATA(
      IMPORTING
        EX_DATA = LS_MEPOHEADER
      EXCEPTIONS
        FAILURE = 1
        OTHERS  = 2 ).
** -------------------------------------------- **
** Create instance of Release Strategy Details **
** -------------------------------------------- **
    ZIF_STRATEGY = ZCL_PO->IF_RELEASE_STATE_MM~GET_STRATEGY( ).
    IF ZIF_STRATEGY IS NOT INITIAL.
** -------------------------------------------- **
** Get Release Strategy Information **
** -------------------------------------------- **
      CLEAR : LV_FRGGR, LV_FRGGT, LV_FRGSX, LV_FRGXT.
      REFRESH : LT_RE_CODES, LT_RE_FINAL, LT_CODE_DESC.
      ZIF_STRATEGY->GET_INFO(
        IMPORTING
          EX_GROUP           = LV_FRGGR
          EX_GROUP_DESC      = LV_FRGGT
          EX_STRATEGY        = LV_FRGSX
          EX_STRATEGY_DESC   = LV_FRGXT
          EX_CODES           = LT_RE_CODES
          EX_PREREQUISITES   = LT_RE_PREQ
          EX_FINAL           = LT_RE_FINAL
          EX_CONSISTENT      = LV_CONSIST
          EX_OVERALL_RELEASE = LV_OVERALL ).
      WRITE :/ 'Release Strategy Info'.
      WRITE :/ '====================='.
      WRITE :/ 'Release Group    => ', LV_FRGGR, LV_FRGGT.
      WRITE :/ 'Release Strategy => ', LV_FRGSX, LV_FRGXT.
** -------------------------------------------- **
** Get Release Code Description**
** -------------------------------------------- **
      IF LT_RE_CODES[] IS NOT INITIAL.
        WRITE :/ 'Release Code Details'.
        WRITE :/ '********************'.
        ZIF_STRATEGY->GET_INFO_FOR_CODE(
          EXPORTING
            IM_CODES     = LT_RE_CODES
          RECEIVING
            RE_CODE_DESC = LT_CODE_DESC ).
        LOOP AT LT_CODE_DESC INTO LS_CODE_DESC.
          WRITE :/ LS_CODE_DESC-REL_CODE, ' => ',
                   LS_CODE_DESC-DESCRIPTION.
** Get Person Responsible for workflow **
          REFRESH : LT_RE_ACTOR.
          ZCL_PO->IF_RELEASABLE_MM~GET_RESPONSIBLE(
            EXPORTING
              IM_CODE     = LS_CODE_DESC-REL_CODE
            RECEIVING
              RE_ACTORTAB = LT_RE_ACTOR ).
          IF LT_RE_ACTOR[] IS NOT INITIAL.
            WRITE :/ 'Person Responsible'.
            WRITE :/ '******************'.
            LOOP AT LT_RE_ACTOR INTO LS_RE_ACTOR.
              WRITE :/ LS_RE_ACTOR.
            ENDLOOP.
          ENDIF.
        ENDLOOP.
      ENDIF.
** -------------------------------------------- **
** Get Codes for Final Release **
** -------------------------------------------- **
      IF LT_RE_FINAL[] IS NOT INITIAL.
        WRITE :/ 'Code for Final Release'.
        WRITE :/ '**********************'.
        LOOP AT LT_RE_FINAL INTO LS_RE_FINAL.
          LOOP AT LS_RE_FINAL-CODES INTO LS_RE_CODES.
            CLEAR : LS_CODE_DESC.
            READ TABLE LT_CODE_DESC INTO LS_CODE_DESC
                                    WITH KEY REL_CODE = LS_RE_CODES-REL_CODE.
            IF SY-SUBRC EQ 0.
              WRITE :/ LS_CODE_DESC-REL_CODE, ' => ',
                       LS_CODE_DESC-DESCRIPTION.
            ENDIF.
          ENDLOOP.
        ENDLOOP.
      ENDIF.
      ULINE /1(50).

** -------------------------------------------- **
** Get release Indicators **
** -------------------------------------------- **
      CLEAR : LV_INDICATOR, LV_IND_DESC, LV_FLREF, LV_KZFAE,
              LV_TLFAE, LV_FIXBP, LV_FRANG, LV_FRBST.
      ZCL_PO->IF_RELEASE_STATE_MM~GET_INDICATOR(
        IMPORTING
          EX_INDICATOR      = LV_INDICATOR
          EX_INDICATOR_DESC = LV_IND_DESC
          EX_FLREF          = LV_FLREF
          EX_KZFAE          = LV_KZFAE
          EX_TLFAE          = LV_TLFAE
          EX_FIXBP          = LV_FIXBP
          EX_FRANG          = LV_FRANG
          EX_FRBST          = LV_FRBST ).

      WRITE :/ 'Release Indicators'.
      WRITE :/ '=================='.
      WRITE :/ 'Indicator                 => ', LV_INDICATOR, LV_IND_DESC.
      WRITE :/ 'Key for Release           => ', LV_FLREF.
      CLEAR : LS_DOMVAL.
      READ TABLE LT_DOMVAL INTO LS_DOMVAL WITH KEY DOMVALUE_L = LV_KZFAE.
      IF SY-SUBRC EQ 0.
        WRITE :/ 'PO Change while Release   => ' ,LS_DOMVAL-DDTEXT.
      ENDIF.
      WRITE :/ 'Tolerance Values change   =>', LV_TLFAE.
      WRITE :/ 'Fixed for Req.Planning    =>', LV_FIXBP.
      WRITE :/ 'Released for RFQ Proc.    =>', LV_FRANG.
      WRITE :/ 'Released for Issue of PO  =>', LV_FRBST.
      ULINE /1(50).
** -------------------------------------------- **
** Check whether the PO is released ?
** -------------------------------------------- **
      CLEAR : LV_RELEASED.
      LV_RELEASED = ZCL_PO->IF_RELEASE_STATE_MM~IS_RELEASED( ).
      IF LV_RELEASED EQ ABAP_TRUE.
        WRITE :/ 'PO ', P_EBELN, ' Is released'.
      ELSE.
        WRITE :/ 'PO ', P_EBELN, ' Is Not released'.
      ENDIF.
** -------------------------------------------- **
** Check PO Release is possible?
** -------------------------------------------- **
      CLEAR : LV_RE_ALLOWED.
      LV_RE_ALLOWED = ZCL_PO->IF_RELEASE_STATE_MM~CAN_RELEASE( ).
      IF LV_RE_ALLOWED EQ ABAP_TRUE.
        WRITE :/ 'PO ', P_EBELN, ' Can be released'.
      ELSE.
        WRITE :/ 'PO ', P_EBELN, ' Cannot/Already be released'.
      ENDIF.
** -------------------------------------------- **
** Check PO Reset-Release is possible?
** -------------------------------------------- **
      CLEAR : LV_RE_ALLOWED.
      LV_RE_ALLOWED = ZCL_PO->IF_RELEASE_STATE_MM~CAN_RESET_RELEASE( ).
      IF LV_RE_ALLOWED EQ ABAP_TRUE.
        WRITE :/ 'PO ', P_EBELN, ' Release Reset Possible'.
      ELSE.
        WRITE :/ 'PO ', P_EBELN, ' Release Reset Not Possible'.
      ENDIF.
      ULINE /1(50).
** -------------------------------------------- **
** Get Release Codes which are already Released **
** -------------------------------------------- **
      REFRESH : LT_RE_CODES.
      LT_RE_CODES = ZIF_STRATEGY->GET_CODES_FROM_STATE( IM_FRGZU = LS_MEPOHEADER-FRGZU ).
      WRITE :/ 'Codes That have been Released'.
      WRITE :/ '*****************************'.
      LOOP AT LT_RE_CODES INTO LS_RE_CODES.
        CLEAR : LS_CODE_DESC.
        READ TABLE LT_CODE_DESC INTO LS_CODE_DESC
                                WITH KEY REL_CODE = LS_RE_CODES-REL_CODE.
        IF SY-SUBRC EQ 0.
          WRITE :/ LS_CODE_DESC-REL_CODE, ' => ',
                   LS_CODE_DESC-DESCRIPTION.
        ENDIF.
      ENDLOOP.
      ULINE /1(50).
** -------------------------------------------- **
** Get Codes which are pending for Release **
** -------------------------------------------- **
      REFRESH : LT_RE_CODES.
      LT_RE_CODES = ZIF_STRATEGY->GET_CODES_FOR_RELEASE( IM_FRGZU = LS_MEPOHEADER-FRGZU ).
      WRITE :/ 'Codes That can affect Release'.
      WRITE :/ '*****************************'.
      LOOP AT LT_RE_CODES INTO LS_RE_CODES.
        CLEAR : LS_CODE_DESC.
        READ TABLE LT_CODE_DESC INTO LS_CODE_DESC
                                WITH KEY REL_CODE = LS_RE_CODES-REL_CODE.
        IF SY-SUBRC EQ 0.
          WRITE :/ LS_CODE_DESC-REL_CODE, ' => ',
                   LS_CODE_DESC-DESCRIPTION.
        ENDIF.
      ENDLOOP.
      ULINE /1(50).
    ELSE.
      WRITE :/ 'Release Strategy Not applicable for PO'.
    ENDIF.
  ENDIF.
ENDIF.
 

Related Content

 

Useful Information

Purchase Order Release Strategy data using ABAP Classes