Validate WBS (code used in ME21)

The below ABAP code shows one use for COBL_CODINGBLOCK_CHECK which is a function module used by ME21(purchase order creation) during validation of WBS, Cost center or Internal order. The example below validates a WBS to see if it is technically closed (TECO).

Please note I am not entirly sure of the full use of this function module but this provides documentation of uses so far and a basis for further development.

  data: ld_cobl like cobl,
        it_mess type standard table of bapireturn1 initial size 0,
        wa_mess type bapireturn.
  ld_cobl-vorgn   = 'RMBE'.              "Value from ME21
  ld_cobl-awtyp      = 'PORD'.           "Value from ME21
  ld_cobl-budat      = sy-datum.
  ld_cobl-bukrs      = zimt_bukrs.       "Company code
  ld_cobl-werks      = zimt-werks.       "
  ld_cobl-process    = 'BEST'.           "Value from ME21
  ld_cobl-event      = 'CHECKALL'.       "Value from ME21
  ld_cobl-gjahr      = sy-datum(4).
  ld_cobl-PS_PSP_PNR = zimk-pspnr       "WBS internal number
* converts WBS internal number to external format
*                              e.g. 3426 to CP.222111.001 
*         EDIT_IMP  =  
            int_num   = ld_cobl-PS_PSP_PNR
           ext_num   = ld_cobl-ps_posid
           not_found = 1
           others    = 2.
  if sy-subrc eq 0.
    call function 'COBL_CODINGBLOCK_CHECK'
              check_cobl              = ld_cobl
*            PBO_COBL                =  
              cust_fields_dynp_checks = 'X'
              collect_messages        = 'X'
              external_fields_used    = ' '
*           CHECKED_COBL            =  
             t_messages               = it_mess  .
*   check if message has been returned
    loop at it_mess into wa_mess.
*     check if message is technically closed message (TECO)
      if sy-msgid = 'BS'  and
         sy-msgty = 'E'   and
         sy-msgno = '013' and
         sy-msgv1 = 'TECO'.
        message id sy-msgid type sy-msgty number sy-msgno
           with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

Related Articles

ABAP4_CALL_TRANSACTION sap function module
BAPI_ALM_ORDER_MAINTAIN sap BAPI / Function Module to create a work order
Function module BAPI_EMPLCOMM_CREATE to maintain the SAP HR communication infotype 0105
CLPB_EXPORT sap function module
CLPB_IMPORT sap function module
CONVERT_DATE_TO_EXTERNAL sap function module
CREATE_TEXT sap function module
CURRENCY_AMOUNT_DISPLAY_TO_SAP sap function module to Convert currency value from display to SAP
CURRENCY_AMOUNT_SAP_TO_DISPLAY FM to Convert currency value from SAP to display
DATE_COMPUTE_DAY sap function module
DATE_TO_DAY sap function module
DOCU_READ sap function module
ENQUEUE_READ sap function module
F4IF_INT_TABLE_VALUE_REQUEST sap function module
FILE_GET_NAME sap function module
SAP Application specific function modules
SAP Custom function modules
SAP field conversion function modules
SAP HR specific function modules
SAP development function modules
Retrieve employees address details (own data)
Function Module DYNP_VALUES_UPDATE to Change screen field contents
sxpg_command_execute FM to Execute external commands (FTP Scripts)
DETERMINE_PERIOD FM to Retrieve fiscal year and period
Function module HR_INFOTYPE_OPERATION to maintain SAP HR infotypes
RH_PM_GET_STRUCTURE FM to retrieve HR Organisation Structure
HR_READ_INFOTYPE SAP FM to Read infotype data
READ_TEXT FM to Read SAP texts
ADDR_PERS_COMP_COMM_MAINTAIN to Update sap users email address plus other details (own data)
HR_PERSONAL_WORK_SCHEDULE to Retrieve employees work schedule
NUMBER_GET_NEXT to get next number in number range sap function module
Generate random number using QF05_RANDOM_INTEGER SAP function module within your ABAP code
RSEC_GENERATE_PASSWORD SAP FM to generate user password
The SAP internet user functionality and Password BAPIs
SAPGUI_SET_FUNCTIONCODE sap function module to execute function code
SX_INTERNET_ADDRESS_TO_NORMAL SAP function module to check email format is correct