Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

BAPI Error

Former Member
0 Kudos

hi

I am implementing a BAPI using this program, in turn I get an error Object for PurchaseSched Agreement not created

Can you please guide me about the possible problem, the code may look complex but its just a simple BAPI with Input data


  DATA: ls_header  TYPE bapimeoutheader,
        ls_headerx TYPE bapimeoutheaderx,
        ls_item    TYPE bapimeoutitem,
        ls_itemx   TYPE bapimeoutitemx.

  data: lt_item   TYPE bapimeout_t_item,
        lt_itemx  TYPE bapimeout_t_itemx.

  DATA: ls_cond   TYPE bapimeoutcondition,
        ls_condx  TYPE bapimeoutconditionx.

  DATA: ls_shex   TYPE bapimeoutshippexp,
        ls_shexx  TYPE bapimeoutshippexp.


  DATA: tbl_return     TYPE TABLE OF bapiret2,
        tbl_return_hdr TYPE  bapiret2 .

  DATA: BEGIN OF wa_bapi_data,
        reswk TYPE ekko-reswk,
        evart TYPE evart,
        ekorg TYPE ekko-ekorg,
        ekgrp TYPE ekko-ekgrp,
        werks TYPE werks,
        kdatb TYPE ekko-kdatb,
        kdate TYPE ekko-kdate,
        ematn TYPE matnr,
        ktmng TYPE ekpo-ktmng,
        netpr TYPE ekpo-netpr,
        peinh TYPE ekpo-peinh,
        bprme TYPE ekpo-bprme,
        tcselflag TYPE tcselflag,
        inco1 TYPE ekpo-inco1,
        inco2 TYPE ekpo-inco2,
        mwskz TYPE ekpo-mwskz,
        evers TYPE ekpo-evers,
        bstae TYPE ekpo-bstae,
        plifz TYPE ekpo-plifz,
        webaz TYPE ekpo-webaz,
        END OF wa_bapi_data.

  ls_header-suppl_plnt = '0080'.
  ls_header-DOC_TYPE   = 'LU'.
  ls_header-purch_org  = 'ADC'.
  ls_header-pur_group  = '###'.
  ls_header-SUPPL_PLNT = '0020'.
  ls_header-vper_start = '01012007'.
  ls_header-vper_end   = '01019999'.
  ls_header-incoterms1   = ' '.
  ls_header-incoterms2   = ' '.

*  ls_item-ITEM_NO      = '0010'.
  ls_item-ematerial    = '4-26860-3250'.
  ls_item-plant        = '0080'.
  ls_item-target_qty   = '999999'.
  ls_item-net_price    = ' '.
  ls_item-price_unit   = ' '.
  ls_item-ORDERPR_UN   = ' '.
  ls_item-tax_code     = ' '.
  ls_item-shipping     = '01'.
  ls_item-conf_ctrl    = '0001'.
  ls_item-gr_pr_time   = ' '.
  ls_item-PLAN_DEL     = ' '.

  append ls_item to lt_item.

*Fill X structure

  ls_headerx-suppl_plnt =  'X'.
  ls_headerx-DOC_TYPE   =  'X'.
  ls_headerx-purch_org  =  'X'.
  ls_headerx-pur_group  =  'X'.
  ls_headerx-SUPPL_PLNT =  'X'.
  ls_headerx-vper_start =  'X'.
  ls_headerx-vper_end   =  'X'.
  ls_headerx-incoterms1 =  'X'.
  ls_headerx-incoterms2 =  'X'.

*  ls_itemx-ITEM_NO      = '0010'.
  ls_itemx-ematerial    =  '4-26860-3250'.
  ls_itemx-plant        =  'X'.
  ls_itemx-target_qty   =  'X'.
  ls_itemx-net_price    =  'X'.
  ls_itemx-price_unit   =  'X'.
  ls_itemx-ORDERPR_UN   =  'X'.
  ls_itemx-tax_code     =  'X'.
  ls_itemx-shipping     =  'X'.
  ls_itemx-conf_ctrl    =  'X'.
  ls_itemx-gr_pr_time   =  'X'.
  ls_itemx-PLAN_DEL     =  'X'.

  append ls_itemx to lt_itemx.

*  ls_shex-


  CALL FUNCTION 'BAPI_SAG_CREATE'
    EXPORTING
      header                      = ls_header
      headerx                     = ls_headerx
*     VENDOR_ADDRESS              =
*     HEAD_EXPORT_IMPORT          =
*     HEAD_EXPORT_IMPORTX         =
*     TESTRUN                     =
*     TECHNICAL_DATA              =
*   IMPORTING
*     PURCHASINGDOCUMENT          =
*     EXP_HEADER                  =
    tables
      RETURN                      = tbl_return
      item                        = lt_item
      itemx                       = lt_itemx
*     ACCOUNT                     =
*     ACCOUNTPROFITSEGMENT        =
*     ACCOUNTX                    =
*     SCHEDULE                    =
*     SCHEDULEX                   =
*     SC_COMPONENT                =
*     SC_COMPONENTX               =
*     SHIPPING                    =
*     SHIPPINGX                   =
*     SHIPPING_EXP                =
*     DELIVERY_ADDRESS            =
*     ITEM_COND_VALIDITY          =
*     ITEM_COND_VALIDITYX         =
*     ITEM_CONDITION              =
*     ITEM_CONDITIONX             =
*     ITEM_COND_SCALE_VALUE       =
*     ITEM_COND_SCALE_QUAN        =
*     EXPORT_IMPORT               =
*     EXPORT_IMPORTX              =
*     ITEM_TEXT                   =
*     HEADER_TEXT                 =
*     HEAD_COND_VALIDITY          =
*     HEAD_COND_VALIDITYX         =
*     HEAD_CONDITION              =
*     HEAD_CONDITIONX             =
*     HEAD_COND_SCALE_VAL         =
*     HEAD_COND_SCALE_QUAN        =
*     PARTNER                     =
*     PARTNERX                    =
*     EXTENSIONIN                 =
*     EXTENSIONOUT                =
            .

    LOOP AT Tbl_return INTO tbl_return_hdr WHERE type = 'E' OR type = 'A'.
        EXIT.
    ENDLOOP.

    IF sy-subrc = 0.
         CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
    ELSE.
        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
               EXPORTING
                 wait = 'X'.
    ENDIF.

1 REPLY 1

chaouki_akir
Contributor
0 Kudos

what transaction is giving you this error message ? SE37 ? SWO1 ? an other ?