UPDATE project

This scenario we are updating start date finish date and project short text


Get the details of project and change the required fields 
    MOVE-CORRESPONDING G_R_PROJECT_DEFINITION  TO G_R_BAPI_CHANGE.
    G_R_BAPI_CHANGE-START         = P_F_PSTART.
    G_R_BAPI_CHANGE-FINISH        = P_F_PFINSH .
    G_R_BAPI_CHANGE-DESCRIPTION   = P_G_F_POST1.
*Fields that needs to be changed
    G_R_BAPI_UPD-DESCRIPTION = G_C_X.
    G_R_BAPI_UPD-START       = G_C_X.
    G_R_BAPI_UPD-FINISH      = G_C_X.

*Change project fields
    CALL FUNCTION 'BAPI_BUS2001_CHANGE'
      EXPORTING
        I_PROJECT_DEFINITION     = G_R_BAPI_CHANGE
        I_PROJECT_DEFINITION_UPD = G_R_BAPI_UPD
      TABLES
        ET_RETURN                = L_T_RETURN2.
  ENDIF.

  CLEAR G_F_ERROR.
  LOOP AT  L_T_RETURN2 INTO G_R_RETURN."Error Type A E or X .
    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.
* 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.
*    APPEND LINES OF l_t_return2 TO p_g_t_return.

*-- 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.
      P_f_PSTART = G_R_BAPI_CHANGE-START."Project planned start date
      P_F_PFINSH = G_R_BAPI_CHANGE-FINISH."Project planned finish date
      P_G_F_POST1 = G_R_BAPI_CHANGE-DESCRIPTION."PS: Short description
    ELSE.
      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.
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
    ENDIF.
* Error occured
  ELSE.
    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.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
  ENDIF.







No comments:

Post a Comment

/*Newer Post*/ Older Post Home