2015 Dec 14 4:21 PM
Hello all,
I'm working in SRM 7.1 and having troubles to create a contract in status saved. I'm using the two BAPIS mentioned iat the title and BAPI TRANSACTION COMMIT but I'm just getting status 'in treatment'.
I've been searching a lot through the web but i don´t find anything that could help me. Please any other opcion anyone knows about?? Thanks a lot. Below my code:
CALL FUNCTION 'BBP_PD_CTR_RESET_BUFFER'.
CALL FUNCTION 'BBP_PD_CTR_CREATE'
EXPORTING
* I_REF_GUID = gs_header-guid
* I_BAPIMODE = 'X'
* I_PARK = 'X'
* I_SAVE = 'X'
* I_TESTRUN =
I_HEADER = ls_header
* I_SRC_GUID =
* I_SRC_OBJECT_TYPE =
IT_ATTACH = gt_attach
IT_CONDITIONS = gt_conditions1
* IV_NO_BADI_CALL =
IMPORTING
E_HEADER = gs_header_new
ET_ATTACH = gt_attach_new
ET_CONDITIONS = gt_conditions_new
TABLES
I_ITEM = gt_item1
I_PARTNER = gt_partner
I_LONGTEXT = gt_longtext
I_ORGDATA = gt_orgdata
I_TOL = gt_tol
I_HCF = gt_hcf
I_ICF = gt_icf
I_DIS = gt_dis
E_ITEM = gt_item_new
E_PARTNER = gt_partner_new
E_LONGTEXT = gt_longtext_new
E_ORGDATA = gt_orgdata_new
E_TOL = gt_tol_new
E_HCF = gt_hcf_new
E_ICF = gt_icf_new
E_DIS = gt_dis_new
E_STATUS = gt_status_new
E_MESSAGES = gt_messages_new
E_EXCHRATE = gt_exchrate_new
I_ACCOUNT = gt_account
.
* CALL FUNCTION 'BBP_PROCDOC_RESET_BUFFER'.
IF gs_header_new IS NOT INITIAL.
lv_cont = lv_cont + 1.
lv_guid = gs_header_new-guid.
CALL FUNCTION 'BBP_PD_CTR_SAVE'
EXPORTING
* IV_WORKITEM_ID =
* IV_USERTYPE =
IV_HEADER_GUID = lv_guid
* IV_CREATE_HIST_VERSION =
* IV_KEEP_OLD_CHANGER =
* IV_NEW_CHANGED_BY =
* IV_RESET_CHANGES =
.
IF sy-subrc EQ 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
ENDIF.
.
2015 Dec 14 4:34 PM
Hi Caroline,
to tell function BBP_PD_CTR_CREATE that "saved" contracts are allowed you need to pass Parameter I_PARK = 'X'. In the code above this line is commented out. If an error occurs (e.g. invalid supplier or so) and I_PARK was given as 'X' the Status of the contract gets "saved". If Parameter I_SAVE is set to SPACE the function should never try to set Status "Awaiting Approval" or "Released".
Have you checked table GT_MESSAGES_NEW? Did you get error Messages?
Regards
Oliver
2015 Dec 14 4:34 PM
Hi Caroline,
to tell function BBP_PD_CTR_CREATE that "saved" contracts are allowed you need to pass Parameter I_PARK = 'X'. In the code above this line is commented out. If an error occurs (e.g. invalid supplier or so) and I_PARK was given as 'X' the Status of the contract gets "saved". If Parameter I_SAVE is set to SPACE the function should never try to set Status "Awaiting Approval" or "Released".
Have you checked table GT_MESSAGES_NEW? Did you get error Messages?
Regards
Oliver
2015 Dec 15 12:38 AM
Hi Oliver,
thans a lot. May I ask you another question?. After I create the contract I'm trying to release, but I think I can't use BBP_PD_CTR_CREATE again. I've tried with BBP_PD_CTR_UPDATE, BBP_PD_CTR_STATUS_CHANGE, BBP_PROCDOC_STATUS_CHANGE, BBP_PD_CTR_STATUS_CHANGE_WF. None of this FM seems to be working. The WF is not been through. When I go to BBP_PD I do not see status I1141 or WF ID. Any idea why can this be happening?. Thanks again.
* CALL FUNCTION 'BBP_PD_CTR_STATUS_CHANGE_WF'
* EXPORTING
* IV_GUID =
* IV_STATUS = 1
** IV_WFL_STARTED_BY =
** IMPORTING
** EV_OBJECT_STATUS =
* TABLES
* ET_MESSAGES = gt_messages
** EXCEPTIONS
** INVALID_VALUE_FOR_STATUS = 1
** ERROR_IN_STATUS_CHANGE = 2
** OTHERS = 3
CALL FUNCTION 'BBP_PROCDOC_RESET_BUFFER'.
* CALL FUNCTION 'BBP_PD_CTR_STATUS_CHANGE'
* EXPORTING
* I_GUID = lv_guid
** IV_ITEM_GUID =
* I_ACTIVITY = lv_activity
** I_SAVE_DB = 'X'
** I_TEST_RUN =
* TABLES
* E_MESSAGES = gt_messages
* CHANGING
* E_CHANGED = lv_change
.
* --Set CONTRACT Status' --. 'Released' I1141
* CALL FUNCTION 'BBP_PROCDOC_STATUS_CHANGE'
* EXPORTING
* I_GUID = lv_guid
** IV_ITEM_GUID =
* I_ACTIVITY = lv_activity
* I_OBJECT_TYPE = lv_bus
* I_SAVE_DB = 'X'
** I_TEST_RUN =
** IV_MSG_SCENARIO =
* TABLES
* E_MESSAGES = gt_messages
* CHANGING
* E_CHANGED = lv_change
.
* Update contract with item data
CALL FUNCTION 'BBP_PD_CTR_UPDATE'
EXPORTING
I_HEADER = LS_HEADER_U
* I_PARK = LV_PARK
I_SAVE = 'X'
* IT_ATTACH = gt_ATTACH
* IT_CONDITIONS = gt_CONDITIONS
IMPORTING
ES_HEADER = GS_HEADER_NEW
* TABLES
* I_ITEM = LT_PD_ITEMS[]
* I_PARTNER = LT_PARTNER_D[]
* I_LONGTEXT = LT_PD_LONGTEXT_D[]
* I_ORGDATA = LT_PD_ORGDATA_D[]
* I_TOL = LT_TOLERANCE_D[]
* I_DIS = LT_DIST_D[]
* E_MESSAGES = LT_UP_MESSAGES[].
2015 Dec 15 8:27 AM
Hi Caroline,
I have no example for contracts but I have a similar process that orders purchase orders which are in Status "Saved". Based on that I would use function modules 'BBP_PD_CTR_UPDATE' and 'BBP_PD_CTR_SAVE' followed by a COMMIT WORK to start the approval workflow. It should be sufficient to pass I_HEADER with the contract Header Details,I_PARK = SPACE and I_SAVE = 'X' to 'BBP_PD_CTR_UPDATE'.
Let me know if that works for you.
Regards
Oliver
2015 Dec 15 12:27 PM
Hi Oliver,
I've did exact the same thing I did for create but using BBP_PD_CTR_UPDATE and passing parameter SAVE = 'X' and BELOW and below function SAVE and works perfectly. Thanks for all, your been very kind.
Kind regards.
Caroline.