Skip to Content
avatar image
Former Member

Sample code for BADI implementation

Hi Guys,

Can any one help me how to implement Badi's Like

1. BAPI_PO_CREATE1,

2. BBP_CREATE_PO_BACK,

3. BBP_CREATE_BE_PO_NEW,

4. BBP_PROCESS_PO

..

Please post some sample code that will help me much.

Thanks in advance.

Regards,

Apparao A

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    avatar image
    Former Member
    May 28, 2007 at 01:36 PM

    Hi

    <b>Please go through this -></b>

    <u>BAPI_PO_CREATE1 / BAPI_PO_CREATE are not BADI. They are Standard SAP Function modules (See using SE37 Transaction in the R/3 back-end system).</u>

    <i><u>Sample code for BADI - BBP_CREATE_PO_BACK</u></i>

    <b>po-created-with-status-transfer-failed-esys</b>

    <i><u>Sample code for BADI - BBP_CREATE_BE_PO_NEW</u></i>

    method IF_EX_BBP_CREATE_BE_PO_NEW~FILL_PO_INTERFACE1.
    
      CALL FUNCTION 'BBP_CALL_OLD_BADI_BE_PO_CRT'
        EXPORTING
          is_sc_document = is_sc_document
          is_control     = is_control
        CHANGING
          cs_ctrl_att     = cs_ctrl_att
          cs_po1_document = cs_po1_document.
    
    endmethod.

    <i><u>Sample code for BADI - BBP_CREATE_BE_PO_NEW</u></i>

    method IF_EX_BBP_CREATE_BE_PO_NEW~FILL_PO_INTERFACE.
    
      CALL FUNCTION 'BBP_CALL_OLD_BADI_BE_PO_CRT'
        EXPORTING
          is_sc_document = is_sc_document
          is_control     = is_control
        CHANGING
          cs_ctrl_att    = cs_ctrl_att
          cs_po_document = cs_po_document.
    
    endmethod.

    <i><u>Sample code for BADI - BBP_PROCESS_PO</u></i>

    method IF_EX_BBP_PROCESS_PO~PROCESS_SMARTFORM.
    
    * smartformspecific data
      data: LV_FUNCTION_NAME   type RS38L_FNAM
          , LT_SDLN type BBPT_PD_SDLN
          , LT_SUBCON_COMP_DISPL type /SAPPSSRM/T_SUBCON_COMP_DISPL
          , LS_SF_PO type BBPS_SF_PO_OUTPUT
          .
    
      field-symbols: <LS_ITEM> type BBP_PDS_PO_ITEM_D
                   , <LV_SUBCON> type /SAPPSSRM/_SUBCON_ITEM
                   .
    
    
      LS_SF_PO = IS_SF_PO.
    
    
      loop at LS_SF_PO-IT_ITEM assigning <LS_ITEM>.
        assign component 'PS_SUBCON_ITEM' of structure <LS_ITEM>
            to <LV_SUBCON>.
        if SY-SUBRC <> 0 or <LV_SUBCON> = 'X'.
          exit.
        endif.
      endloop.
    
      if <LV_SUBCON> is assigned and <LV_SUBCON> = 'X'.
    
        call method /SAPPSSRM/CL_SUBCON=>SUBCON_COMP_TEXT_ADD
          exporting
            IV_HEADER_GUID = LS_SF_PO-HEADER-GUID
            IV_LANGUAGE    = LS_SF_PO-LANGU
          changing
            CT_LONGTEXT    = LS_SF_PO-IT_LONGTEXT.
    
      endif.
    
    * get the function name for this smart form
      call function 'SSF_FUNCTION_MODULE_NAME'
        exporting
          FORMNAME           = IP_SMART_FORM
        importing
          FM_NAME            = LV_FUNCTION_NAME
        exceptions
          NO_FORM            = 1
          NO_FUNCTION_MODULE = 2
          others             = 3.
    
    * SAPs smartform or a copy with SAPs interface is used
      call function LV_FUNCTION_NAME
        exporting
          ARCHIVE_INDEX_TAB    = CT_ARCHIVE_INDEX_TAB
          ARCHIVE_PARAMETERS   = IS_ARCHIVE_PARAMETERS
          CONTROL_PARAMETERS   = IS_CONTROL_PARAMETERS
          MAIL_APPL_OBJ        = IS_MAIL_APPL_OBJ
          MAIL_RECIPIENT       = IS_MAIL_RECIPIENT
          MAIL_SENDER          = IS_MAIL_SENDER
          OUTPUT_OPTIONS       = IS_OUTPUT_OPTIONS
          USER_SETTINGS        = IP_USER_SETTINGS
          SF_PO                = LS_SF_PO
        importing
          DOCUMENT_OUTPUT_INFO = ES_DOCUMENT_OUTPUT_INFO
          JOB_OUTPUT_INFO      = ES_JOB_OUTPUT_INFO
          JOB_OUTPUT_OPTIONS   = ES_JOB_OUTPUT_OPTIONS
        exceptions
          FORMATTING_ERROR     = 1
          INTERNAL_ERROR       = 2
          SEND_ERROR           = 3
          USER_CANCELED        = 4
          others               = 5.
    
      CV_SMARTRC = SY-SUBRC.
    
    endmethod.

    Hope this will help.

    Regards

    - Atul

    Add comment
    10|10000 characters needed characters exceeded