Showing posts with label ABAP. Show all posts
Showing posts with label ABAP. Show all posts

Saturday, May 9, 2020

Release Strategy in Purchase Order with Material Type characteristics

What is the Release Strategy? 
Before we start with the topic of Enhancement in Purchase Order, let us understand the basics of Release Strategy. Release Strategy is a facility provided by SAP on several important transactional documents by the way of which companies can ensure that these transactional documents are first checked & only after they are approved by concerned users, can they be further utilized down the process line as per the type of transactional document on which the Release Strategy is applied. 

A typical example can be of the Purchase Order(PO), which is an external purchasing document that requires verification/approval by some appropriate authority in the Company in the form of releasing the same (either a manual or a digital approval), after which the Company’s buyer can send this Purchase Order to the appropriate Vendor for Material / Services procurement.

SAP Reference: SAP Release Strategy

Release Strategy in Purchase Order

Release Strategies in Purchasing Documents like Purchase Order needs to be applied based on certain conditions like the total PO value, Ordering Plant, Company code, Purchasing Organization, Purchasing Document type, etc. To meet this requirement in SAP following steps are followed

Release Strategy - PO Value, Company, Material Type

Characteristics are created within these Classes(For Net Value, Company, Material Type) based on the respective Communication structure - CEKKO)

Append a Material type field in CEKKO - ZMTART




















Classes are created (Classes are useto group together characteristics that are to constitute a release condition for a release strategy. For Purchase Requisition, Purchase Orders, Service Entry Sheets, etc. based on their communication structure, viz., Purchase Requisitions (CEBAN), Purchase Orders (CEKKO) and Service Entry Sheets (CESSR))















Define Release Groups:

Release Groups are created via configuration (Release Group is a group of one or more Release Strategies and assigns the class. This permits the multiple usages of the same release strategy key)

SPRO -> MM -> Purchasing -> Purchase Order -> Release Procedure for Purchase Orders -> Define Release Procedure for Purchase Orders











Release Codes are created via configuration (Release Code identify who can release the external purchasing document. The Release Code is a two-character ID. Further, these Release codes are also assigned to individual user ids of Users based on the Business requirements (for e.g. in PO it is done via the authorization object: M_EINK_FRG))

Group 1 -Supervisor, Dept HOD & Finance Controller

Group 2 - Dept HOD, Finance Controller, CEO















Release Indicators are created via configuration (These Indicators are assigned to the Purchasing document after the release is affected. These indicators determine several possibilities like whether the document may be changed after the start of the release, and in cases, where changes are allowed, does a new release strategy gets determined in the event of changes in the characteristic values in the document and finally, they determine the status of the document, for e.g., if the purchasing document is released for further processing, i.e., a release is completely affected)













Release Strategies are then finally defined based on the Business requirement. Appropriate Release Groups & Release codes are used in a Release Strategy along with defining the Release Pre-requisites, Release Statuses & the Classification values required to completely specify a particular Release Strategy.























With the Release Pre-requisites, you specify the order in which the individual release points (individuals or departments) represented by the release codes may release the document, i.e., affect the final Release.

In this release strategy, the codes 01, 02, and 03 must successively release the purchase order. Read the table from left to right. For instance, the third line for release code 03: For code 03, release via code 01 and code 02 is a prerequisite. That is to say, the PO must be released via codes 01 and 02 before it can be released via code 03

























In the Release statuses, you specify the status a PO has after certain release points have effected release. Specify which release indicator/status a PO is to have after having been released via a certain release code



















In the Classification, you maintain the values assigned to the individual characteristics of a Release Strategy. Via the Characteristics and their values, you specify the POs to which your release strategy is assigned by the system when a PO is created or changed.

















The above details thus explain that when a Purchasing document like a PO is either created or changed (changes relevant to bringing a change in the value of the characteristics in the PO), a Release Strategy is applied to this PO or a New Release Strategy is determined, based on the Release Strategy configured for Purchase Orders in customizing

Customer Exit for PO Release Strategy with Material Type option:


















Source Code:

*&---------------------------------------------------------------------*
*& Include          ZXM06U22
*&---------------------------------------------------------------------*

*******Custom code for PO Release strategy with Material Type***** "START

TABLES bekpo .
DATA c_bukrs(4TYPE VALUE 'BTZ1' "Company code
DATA v_ebeln TYPE ekko-ebeln .
DATA zmtart LIKE i_cekko-zmtart .
DATA BEGIN OF it_ekpo OCCURS .
         INCLUDE STRUCTURE bekpo.
       DATA END OF it_ekpo .

*BREAK-POINT .

CLEAR v_ebeln .
CLEAR it_ekpo[] .

IF i_cekko-bukrs c_bukrs .
  IF NOT it_bekpo IS INITIAL .
    it_ekpo[] it_bekpo[] .
    READ TABLE it_ekpo INDEX 1.
    v_ebeln it_ekpo-ebeln .

    IF NOT v_ebeln IS INITIAL .
      i_cekko-zmtart it_ekpo-mtart .
      ELSE .
        i_cekko-zmtart it_ekpo-mtart .
    ENDIF.
  ENDIF .
ENDIF.

e_cekko  i_cekko.

*******Custom code for PO Release strategy with Material Type********** "END

Customer Exit effect on Release Strategy Determination

Create a PO with Material Type - ROH, PO Value - 10,000 USD (23 M Tzs @ 2300 Tzs) .












To Release the PO, T code - ME29N (Individual PO Release)












Thursday, May 7, 2020

Table control using module programming (Dialog Programming)

Table Control:
Table control is a very useful tool when it comes to creating applications with user interactions.The program show how table control can be used to display and manipulate data. It will display sales order number, sales order line item and material number.

User is able to change material number, sort up, sort down or delete entries.


Table control can be created in two methods,

1. Using table control wizard

2. Manually creating the table control

In this example, table control is created manually (method 2) without using the wizard.

Steps to follow:

1. Go to transaction SE80 and create a program as 'ZSAPMVZTEST_MM_DS1'. Then create the screen, GUI Status (PF Status), GUI Title .

Screen Layout - 9001













Screen Layout - 9002












GUI Status (PF Status)

















Program:

*&---------------------------------------------------------------------*
*& Module Pool      ZSAPMVZTEST_MM_DS1
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*

 INCLUDE ZSAPMVZTEST_MM_DS1_TOP                  .    " Global Data
 INCLUDE ZSAPMVZTEST_MM_DS1_O01                  .  " PBO-Modules
 INCLUDE ZSAPMVZTEST_MM_DS1_I01                  .  " PAI-Modules
 INCLUDE ZSAPMVZTEST_MM_DS1_F01                  .  " FORM-Routines


-------------------------------------------------------------------------

*&---------------------------------------------------------------------*
*& Include ZSAPMVZTEST_MM_DS1_TOP                   - Module Pool      ZSAPMVZTEST_MM_DS1
*&---------------------------------------------------------------------*
PROGRAM zsapmvztest_mm_ds1.

TABLES vbak .
DATAok_code TYPE sy-ucomm .
DATA v_vbeln TYPE vbeln .
DATA v_line TYPE .
CONTROLS tc_vbap TYPE TABLEVIEW USING SCREEN 9002,
           tc_cols TYPE TABLEVIEW USING SCREEN 9002.
DATA col TYPE cxtab_column.
DATA fld_list LIKE tc_vbap-cols.
DATA fldname(100TYPE .

TYPES  BEGIN OF ty_vbap ,
           mark  TYPE ce_mark,
           vbeln TYPE vbap-vbeln,
           posnr TYPE posnr_va,
           matnr TYPE matnr,
           matwa TYPE matwa,
           pmatn TYPE pmatn,
           charg TYPE charg_d,
           matkl TYPE matkl,
           arktx TYPE arktx,
           pstyv TYPE pstyv,
           posar TYPE posar,
         END OF ty_vbap .

DATAit_vbap TYPE TABLE OF ty_vbap,
      wa_vbap TYPE          ty_vbap.

------------------------------------------------------------------------------
*&---------------------------------------------------------------------*
*& Include          ZSAPMVZTEST_MM_DS1_O01
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Module STATUS_9001 OUTPUT
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
MODULE status_9001 OUTPUT.
 SET PF-STATUS 'ZGUIS01'.
 SET TITLEBAR 'ZGUI01'.
ENDMODULE.
*&---------------------------------------------------------------------*
*& Module STATUS_9002 OUTPUT
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
MODULE status_9002 OUTPUT.
 SET PF-STATUS 'ZGUIS01'.
 SET TITLEBAR 'ZGUI01'.
 DESCRIBE TABLE it_vbap LINES v_line.
 tc_vbap-lines v_line.
ENDMODULE.
--------------------------------------------------------------------------------

*&---------------------------------------------------------------------*
*& Include          ZSAPMVZTEST_MM_DS1_I01
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_9001  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE user_command_9001 INPUT.

  CLEAR v_vbeln .

  CASE ok_code .
    WHEN 'SAVE' OR 'CANCEL' OR 'BACK' OR 'EXIT' .
      LEAVE PROGRAM .
    WHEN 'NEXT' .
*      BREAK-POINT .
      IF vbak-vbeln IS INITIAL .
        MESSAGE 'Please enter a value' TYPE 'E' .
      ELSE .
        SELECT SINGLE vbeln FROM vbak INTO v_vbeln
          WHERE vbeln vbak-vbeln .
*        IF NOT sy-subrc IS INITIAL
        IF v_vbeln IS INITIAL .
          MESSAGE 'SALES DOC. NOT VALID' TYPE 'E' .
        ELSE .
          PERFORM fetch_data .
          CALL SCREEN '9002' .
        ENDIF.
      ENDIF.

  ENDCASE .

ENDMODULE.
*&---------------------------------------------------------------------*
*&      Module  MODIFY_IT_VBAP  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE modify_it_vbap INPUT.

  MODIFY it_vbap FROM wa_vbap INDEX tc_vbap-current_line .

ENDMODULE.
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_9002  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE user_command_9002 INPUT.

  CASE ok_code .
    WHEN 'SAVE' OR 'CANCEL' OR 'EXIT' .
      LEAVE PROGRAM .
    WHEN 'BACK' .
      SET SCREEN .
      LEAVE TO SCREEN .
    WHEN 'INSR' .
      APPEND INITIAL LINE TO it_vbap .
    WHEN 'DELE' .
      DELETE it_vbap WHERE mark 'X'  .
    WHEN 'SORT' .
      REFRESH fld_list .
      LOOP AT tc_vbap-cols INTO col .
        IF col-selected 'X' .
          APPEND col TO fld_list .
        ENDIF.
      ENDLOOP .
      SORT fld_list BY index .
      CLEAR fldname .
      READ TABLE fld_list INDEX INTO col .
      fldname col-screen-name+8 .
      SORT it_vbap BY (fldname.
  ENDCASE.

ENDMODULE.

---------------------------------------------------------------------------------
*&---------------------------------------------------------------------*
*& Include          ZSAPMVZTEST_MM_DS1_F01
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form FETCH_DATA
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& -->  p1        text
*& <--  p2        text
*&---------------------------------------------------------------------*
FORM fetch_data .

  SELECT
           vbeln
           posnr
           matnr
           matwa
           pmatn
           charg
           matkl
           arktx
           pstyv
           posar
      FROM vbap
*      INTO TABLE it_vbap
      INTO CORRESPONDING FIELDS OF TABLE it_vbap
      WHERE vbeln vbak-vbeln.

ENDFORM.

--------------------------------------------------------------------------------
Creating Transaction:


















Output as Follows: