CALL FUNCTION 'BAPI_PS_INITIALIZATION'.
CALL FUNCTION 'BAPI_BUS2001_DELETE'
EXPORTING
I_PROJECT_DEFINITION = G_F_PROJECT_DEF
TABLES
ET_RETURN = P_G_T_RETURN.
CLEAR G_F_ERROR.
LOOP AT P_G_T_RETURN INTO G_R_RETURN.
IF G_R_RETURN-TYPE CA G_C_AEX."Error Type A E or X .
G_F_ERROR = G_C_X.
ENDIF.
ENDLOOP.
* Error handling / end processing
IF G_F_ERROR IS INITIAL.
*-- Post changes
REFRESH :L_T_RETURN2.
CALL FUNCTION 'BAPI_PS_PRECOMMIT'
TABLES
ET_RETURN = L_T_RETURN2.
*-- Check for errors
CLEAR G_R_RETURN.
LOOP AT L_T_RETURN2 INTO G_R_RETURN. "
IF G_R_RETURN-TYPE CA G_C_AEX.
G_F_ERROR = G_C_X.
ENDIF.
ENDLOOP.
APPEND LINES OF L_T_RETURN2 TO P_G_T_RETURN.
*-- Everything ok
IF G_F_ERROR IS INITIAL.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = G_C_X.
COMMIT WORK.
ELSE.
REFRESH:L_T_RETURN2.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
REFRESH L_T_RETURN2.
CALL FUNCTION 'BAPI_PS_PRECOMMIT'
TABLES
ET_RETURN = L_T_RETURN2.
APPEND LINES OF L_T_RETURN2 TO P_G_T_RETURN.
REFRESH L_T_RETURN2.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
ENDIF.
* Error occured
ELSE.
REFRESH:L_T_RETURN2.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
REFRESH L_T_RETURN2.
CALL FUNCTION 'BAPI_PS_PRECOMMIT'
TABLES
ET_RETURN = L_T_RETURN2.
APPEND LINES OF L_T_RETURN2 TO P_G_T_RETURN.
REFRESH L_T_RETURN2.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
ENDIF.
CALL FUNCTION 'BAPI_BUS2001_DELETE'
EXPORTING
I_PROJECT_DEFINITION = G_F_PROJECT_DEF
TABLES
ET_RETURN = P_G_T_RETURN.
CLEAR G_F_ERROR.
LOOP AT P_G_T_RETURN INTO G_R_RETURN.
IF G_R_RETURN-TYPE CA G_C_AEX."Error Type A E or X .
G_F_ERROR = G_C_X.
ENDIF.
ENDLOOP.
* Error handling / end processing
IF G_F_ERROR IS INITIAL.
*-- Post changes
REFRESH :L_T_RETURN2.
CALL FUNCTION 'BAPI_PS_PRECOMMIT'
TABLES
ET_RETURN = L_T_RETURN2.
*-- Check for errors
CLEAR G_R_RETURN.
IF G_R_RETURN-TYPE CA G_C_AEX.
G_F_ERROR = G_C_X.
ENDIF.
ENDLOOP.
APPEND LINES OF L_T_RETURN2 TO P_G_T_RETURN.
*-- Everything ok
IF G_F_ERROR IS INITIAL.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = G_C_X.
COMMIT WORK.
ELSE.
REFRESH:L_T_RETURN2.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
REFRESH L_T_RETURN2.
CALL FUNCTION 'BAPI_PS_PRECOMMIT'
TABLES
ET_RETURN = L_T_RETURN2.
APPEND LINES OF L_T_RETURN2 TO P_G_T_RETURN.
REFRESH L_T_RETURN2.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
ENDIF.
* Error occured
ELSE.
REFRESH:L_T_RETURN2.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
REFRESH L_T_RETURN2.
CALL FUNCTION 'BAPI_PS_PRECOMMIT'
TABLES
ET_RETURN = L_T_RETURN2.
APPEND LINES OF L_T_RETURN2 TO P_G_T_RETURN.
REFRESH L_T_RETURN2.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
ENDIF.
No comments:
Post a Comment