BAPI for posting cost into CJR2 “Resource cost post”

BAPI for posting cost into CJR2 “Resource cost post”

























At top (data declaration)


L_R_HEADER     TYPE BAPIPLNHDR,
  L_R_COOBJECT   TYPE  BAPIACIOBJ,
  L_T_COOBJECT   TYPE STANDARD TABLE OF BAPIACIOBJ,

*Post the effort into CJR2 Tcode
  CALL FUNCTION 'BAPI_COSTACTPLN_POSTACTINPUT'
    EXPORTING
      HEADERINFO     = L_R_HEADER header table that contain
*      delta          = g_c_x  "Add in the exiting value
    TABLES
      INDEXSTRUCTURE = L_T_INDEXSTR
      COOBJECT       = L_T_COOBJECT
      PERVALUE       = L_T_PERVALUE
      RETURN         = P_G_T_RETURN.

Header details

  L_R_HEADER-CO_AREA        = '0010'.   "Controlling area
  L_R_HEADER-FISC_YEAR      = P_L_F_YEAR. "Fiscal year
  L_R_HEADER-PERIOD_FROM    = '1'.
  L_R_HEADER-PERIOD_TO      = '12'.
  L_R_HEADER-VERSION        = '0'.     " Version
  L_R_HEADER-PLAN_CURRTYPE  = 'O'.     "'O'-Object currency

  L_R_COOBJECT-OBJECT_INDEX = '1'.  "Object index
  L_R_COOBJECT-WBS_ELEMENT  = Project ID or WBSID.
  APPEND L_R_COOBJECT TO L_T_COOBJECT.
  CLEAR L_R_COOBJECT.

Now populate the quantity field

  "For H1 Acty type
  READ TABLE P_L_T_INPUT INTO G_R_INPUT INDEX 1.
  IF SY-SUBRC = 0.
    L_R_INDEXSTR-OBJECT_INDEX  = '1'.
    L_R_INDEXSTR-VALUE_INDEX   = '1'.
    APPEND  L_R_INDEXSTR TO L_T_INDEXSTR.
    CLEAR   L_R_INDEXSTR.
    L_F_VAL_INDEX = '1'."value index
    L_F_ACT       = 'H1'."Activity type
    PERFORM FILL_QTY  USING G_R_INPUT     " Work area of internal table
                            P_L_F_COST    " Cost center
                            L_F_ACT       " Activity type
                            L_F_VAL_INDEX " value index
                            P_G_F_UNIT    " Unit
                 CHANGING   L_T_PERVALUE. " Qty values
  ENDIF.

  "For H2 Acty type
  READ TABLE P_L_T_INPUT INTO G_R_INPUT INDEX 2.
  IF SY-SUBRC = 0.
    L_R_INDEXSTR-OBJECT_INDEX  = '1'.
    L_R_INDEXSTR-VALUE_INDEX   = '2'.
    APPEND  L_R_INDEXSTR TO L_T_INDEXSTR.
    CLEAR   L_R_INDEXSTR.
    L_F_VAL_INDEX = '2'.      "value index
    L_F_ACT       = 'H2'."Activity type
    PERFORM FILL_QTY USING G_R_INPUT     Work area of internal table
                            P_L_F_COST    " Cost center
                            L_F_ACT       Activity type
                            L_F_VAL_INDEX  value index
                            P_G_F_UNIT    " Unit
                 CHANGING   L_T_PERVALUE. " Qty values
  ENDIF.

Same for other activity types……………….

  IF P_G_T_RETURN [] IS INITIAL.
    COMMIT WORK AND WAIT.
  Endif.

FM pop up to confirm


CALL FUNCTION 'POPUP_TO_CONFIRM'
        
EXPORTING
          
TITLEBAR      'Confirm'
          text_question 
'Are you sure to delete Project from database?'
          TEXT_BUTTON_1 
g_c_Yes
          TEXT_BUTTON_2 
g_c_NO
        
IMPORTING
          ANSWER        
g_f_answer.

      
if g_f_answer eq '1'.
          Do something

Elseif g_f_answer eq '2'.

Do some other logic
Endif.

Standard text FM



DATA:
        L_F_TDNAME 
TYPE TDOBNAME,
        L_S_THEAD  
TYPE THEAD.

  L_S_THEAD
-TDOBJECT   G_C_PMS."PMS
  L_S_THEAD
-TDID       G_C_ID ."LTXT
  L_S_THEAD
-TDSPRAS    SY-LANGU.
  L_S_THEAD
-TDLINESIZE G_C_LSIZE.
  L_S_THEAD
-TDTXTLINES G_C_LINES.
  L_F_TDNAME 
P_G_F_OBJNR. “Object number where this standard text will be saved (internal number can be checkedin SHXT table)

  
CALL FUNCTION 'CREATE_TEXT'
    
EXPORTING
      FID         
L_S_THEAD-TDID
      FLANGUAGE   
SY-LANGU
      FNAME       
L_F_TDNAME
      FOBJECT     
L_S_THEAD-TDOBJECT
      SAVE_DIRECT 
G_C_X
      FFORMAT     
'*'
    
TABLES
      FLINES      
P_G_T_LINES
    
EXCEPTIONS
      NO_INIT     
1
      NO_SAVE     
2
      
OTHERS      3.
  
IF SY-SUBRC <> 0.
    
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  
ENDIF.

FM to initiate a work flow

FM to initiate a work flow
SWE_EVENT_CREATE
 

/*Newer Posts*/ Older Posts Home