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

Set or Reset the status of a Project Definition/ WBS element

$
0
0

The business might have large number of projects which need their status changed. In general, the statuses are updated one by one through standard SAP transactions, which is time consuming. Therefore, there may arise a need for a custom program to update status on a range of projects or multiple projects.


1. To set/reset a status for a Project definition, 'BAPI_BUS2001_SET_STATUS' is used.

 

2. To set/reset a status for a WBS element, 'BAPI_BUS2054_SET_STATUS' is used.

 

For the above BAPI to use in order to set or reset the status for Project Definition, we need to follow the below steps:


  • (1) Call 'BAPI_PS_INITIALIZATION'
  • (2) Call 'BAPI_BUS2001_SET_STATUS'
  • (3) Call 'BAPI_PS_PRECOMMIT'
  • (4) Call 'BAPI_TRANSACTION_COMMIT’


For the above BAPI to use in order to set or reset the status for WBS element, we need to follow the below steps:


  • (1) Call 'BAPI_PS_INITIALIZATION'
  • (2) Call 'BAPI_BUS2054_SET_STATUS'
  • (3) Call 'BAPI_PS_PRECOMMIT'
  • (4) Call 'BAPI_TRANSACTION_COMMIT’

 

 

Overview of 'BAPI_PS_INITIALIZATION’:

 

This BAPI is used to initialize the current processing unit. The functionality of this is to initialize the document tables, buffer and so on in the application.

The first step in a processing unit is initialization, which is done by calling the BAPI_PS_INITIALIZATION. Afterwards, the individual BAPIs listed below can be used several times, if required.


The processing unit ends when the final pre commit (BAPI BAPI_PS_PRECOMMIT) is executed with a subsequent COMMIT WORK or "BAPI_TRANSACTION_COMMIT".

 

 

Overview of 'BAPI_ BUS2001_SET_STATUS':

 

This BAPI is used to set/reset status for Project Definition.

 

With this, one system status and one user status can be reset each time, and one system status and one user status can be set each time for a project definition.

 

This can be called any number of times before BAPI_PS_PRECOMMIT and COMMIT WORK.Only one ProjectDefinition can be processed from a project.


 

Overview of 'BAPI_ BUS2054_SET_STATUS':

 

This BAPI is used to set/reset status for a WBS element. Status of Multiple WBS elements can be either set or reset using this call.

 

A status change only affects the current project. The BAPI can be called repeatedly until the current processing unit is closed using BAPI_PS_PRECOMMIT and COMMIT WORK.

 

 

Overview of 'BAPI_ PS_PRECOMMIT':

 

This is the last action before the commit work.The final checks are carried out here for all the objects created,changed and deleted in the current processing unit.

 

 

Overview of 'BAPI_TRANSACTION_COMMIT:

 

This method executes a COMMIT WORK command.

 

 

Pseudo code :

 

 

1. Project Definition

 

CALLFUNCTION'BAPI_PS_INITIALIZATION'.

IF sy-subrc EQ 0.


*  Input - Project definition
  PROJ_DEF = WA_INPUT_DATA-PROJECT.
  SET_SYS  = WA_INPUT_DATA-STATUS.

 

*  Call'BAPI_BUS2001_SET_STATUS' to set status
 
CALL FUNCTION 'BAPI_BUS2001_SET_STATUS'
   
EXPORTING
      PROJECT_DEFINITION = PROJ_DEF
      SET_SYSTEM_STATUS  = SET_SYS
   
IMPORTING
   
RETURN               = WA_RETURN
   
TABLES
      E_RESULT           = LT_RESULT.

  IF sy-subrc EQ 0.

    CALLFUNCTION'BAPI_PS_PRECOMMIT'.  

    IF sy-subrc EQ 0.

      CALLFUNCTION'BAPI_TRANSACTION_COMMIT'.

    ENDIF.

  ELSEIF WA_RETURN-TYPE EQ 'E'.

    CALL FUNCTION 'BAPI_PS_PRECOMMIT'
     
TABLES
        ET_RETURN = LT_PC_RET.
   
IF SY-SUBRC EQ 0.
      
READ TABLE LT_PC_RET INTO WA_PC_RET WITH KEY TYPE = 'E'.
      
IF SY-SUBRC EQ 0.
        
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
      ENDIF.
    ENDIF.

  ENDIF.

ENDIF.

 

 

2. WBS element

 

 

CALLFUNCTION'BAPI_PS_INITIALIZATION'.

IF sy-subrc EQ 0.


*  Input - WBS element

  WA_WBS_STATUS-WBS_ELEMENT = WA_INPUT_DATA-PROJECT.
  WA_WBS_STATUS-SET_SYSTEM_STATUS = WA_INPUT_DATA-STATUS.
 
APPEND WA_WBS_STATUS TO LT_WBS_STATUS.
 
CLEAR WA_WBS_STATUS.

 

*  Call'BAPI_BUS2054_SET_STATUS' to set status

  CALL FUNCTION 'BAPI_BUS2054_SET_STATUS'
   
IMPORTING
   
RETURN                 = WA_RETURN
   
TABLES
      I_WBS_SYSTEM_STATUS = LT_WBS_STATUS
      E_RESULT            = LT_RESULT.

  IF sy-subrc EQ 0.

    CALLFUNCTION'BAPI_PS_PRECOMMIT'.  

    IF sy-subrc EQ 0.

      CALLFUNCTION'BAPI_TRANSACTION_COMMIT'.

    ENDIF.

  ELSEIF WA_RETURN-TYPE EQ 'E'.

    CALL FUNCTION 'BAPI_PS_PRECOMMIT'
     
TABLES
        ET_RETURN = LT_PC_RET.
   
IF SY-SUBRC EQ 0.
      
READ TABLE LT_PC_RET INTO WA_PC_RET WITH KEY TYPE = 'E'.
      
IF SY-SUBRC EQ 0.
        
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
      ENDIF.
    ENDIF.

  ENDIF.

ENDIF.

 

 

With this, we understand the procedure in a programming perspective. The same can be achieved using SAP standard transaction CJ02 or CJ20N.

 



Viewing all articles
Browse latest Browse all 935

Trending Articles



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