Problem statement:
The availability control of an order or a project can be activated in the standard system only if the order or a WBS element of the project was already budgeted.
AVAC is not activated automatically at project creation.
Workaround proposed by SAP:
(Create a dummy budget or a solution by using a user status Profile
If this is not possible, you can use a user exit for releases higher than 4.6C (SAP_APPL) or for release 462 (IS-PS), so that you can activate the availability control on an order or a project, even if the object has not yet been budgeted. Activate the availability control using transaction KO31 (orders) or CJBN (projects).
Alternatively, you can activate the availability control by choosing 'Extras -> Availability Control -> Activate' in the budgeting transactions (KO22, KO24 and KO26 or CJ30, CJ37 and CJ38) and then saving (without budget).
Solution:
As soon as WBS element is created for the first time and user presses save button budget availability control gets activated automatically.
Mandatory Prerequisite:
SAP Note: 599813 must be successfully implemented beforehand. Refer code1 below for Badi implementation IM_behavoiour.
Details:
At project save 2 enhancement points will be used to activate AVAC at project save.
First enhancement point will get the project id from user and save it into a memory variable. Refer to code2 below.
Second enhancement point will call program to activate AVAC only if it is not already activated. Refer to code3 below.
Pseudo code
In Tcode Cj20n user will create project (definition + at least one WBS element). On event of pressing save button by the user, get project id (PROJ-PSPID) from SAPLCJWB. Export this project id to enhancement point in SAPLCNPB_M.
Pass project id (PROJ-PSPID) to PROJ table to get Project definition (internal) (PSPNR). Select object number (OBJNR) from PRPS where PRPS-PSPHI equals to PROJ-PSPNR.
Pass object number (OBJNR) to JEST to get INACT. If no rows are selected or INACT = ‘X’ then call program RBPFCPN1 and pass PROJ-PSPID.
Code 1:
BADI Definition | Implementation name | Methods | Comments |
IM_BEHAVIOUR | ZIM_BEHAVIOUR | GET_BEHAVIOUR | n/a |
In BADI ZIM_BEHAVIOUR
IF situation = 'ENABLE_AVC_WITHOUT_BUDGET'.
behaviour = 'X'.
ENDIF.
Code 2:
Enhancement | Main Program | Includes | Form Routines |
ZPS_UPDATE | SAPLCNPB_M | LCNPB_MF55 | |
In ZPS_UPDATE_1
data id TYPE c LENGTH 24 VALUE 'ZPS_001'.
EXPORT PROJ-PSPID to MEMORY id id.
Code 3:
Enhancement | Main Program | Includes | Form Routines |
ZPS_UPDATE | SAPLCNPB_M | LCNPB_MF55 | |
In ZPS_UPDATE
data: id TYPE c LENGTH 24 VALUE 'ZPS_001',
W_OBJNR TYPE J_OBJNR,
w_pspnr TYPE PS_INTNR,
W_INACT TYPE J_INACT.
IMPORT PROJ-PSPID from MEMORY id id.
IF PROJ-PSPID IS NOT INITIAL.
WAIT UP TO 1 SECONDS.
SELECT SINGLE pspnr
from proj INTO w_pspnr
WHERE pspid = proj-pspid.
IF sy-subrc = 0.
SELECT SINGLE OBJNR
FROM PRPS INTO W_OBJNR
WHERE psphi = w_pspnr.
IF W_OBJNR IS NOT INITIAL.
SELECT SINGLE INACT
FROM JEST INTO W_INACT
WHERE OBJNR = W_OBJNR
AND STAT = 'I0005'.
IF SY-SUBRC <> 0 OR W_INACT = 'X'.
SUBMIT RBPFCPN1 WITH CN_PROJN-LOW eq PROJ-PSPID AND RETURN.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
Benefits:
- AVAC automatically activates at project save.
- No user status is required to prevent PR/PO or other commitment to project without budget. This gives value to client also, as change for two users status is prevented and project stage transition becomes smooth.
Known issues:
- If we want to deactivate AVAC. Then user must not open project and click on save button otherwise AVAC will gets activated again.
- If server is slow and wait condition is 1 second plus user is creating project for first time; then it might be possible that project id is not saved to database table whereas it is passed to the memory variable. In this case AVAC will not get activated. To prevent this wait time can be increased.
Authors:-
Harsh Saxena
Consultant