Skip to Content

BAPI_PO_CREATE1 - Error 06041 : Validity period of contract expired on


I've searched the foruns and SAP's KB but with no success and now I turn to the community for help.

The PO I'm creating has items that reference a contract and I'm creating the PO through BAPI_PO_CREATE1 but it keeps giving the error 06 041 (E06041) Validity period of contract expired on 16.04.2018 (that is in the makes no sense at all!).

I can't understand what I'm doing wrong or why this message error appears.

Any help would be welcomed! :)

This is the contract:

The return table of BAPI_PO_CREATE1 is this:

My code for creating the PO (the is_alug and is_head have their values filled from a xlsx):

  bs_head-COMP_CODE = is_head-c6.
  bs_head-DOC_TYPE = 'NB'.
*  bs_head-CREAT_DATE = sy-datum.
*  bs_head-CREATED_BY = sy-uname.
*  bs_head-ITEM_INTVL = '10'.
  bs_head-VENDOR = is_head-c3.
  bs_head-PURCH_ORG = is_head-c4.
  bs_head-PUR_GROUP = is_head-c5.
  bs_head-DOC_DATE = is_head-c2.
  bs_head-CURRENCY = 'EUR'.
  bs_head-REF_1 = 'xxxxx'.
  bs_head-OUR_REF = 'xxxx'.

  bs_headx-COMP_CODE = 'X'.
  bs_headx-DOC_TYPE = 'X'.
  bs_headx-CREAT_DATE = 'X'.
  bs_headx-CREATED_BY = 'X'.
  bs_headx-ITEM_INTVL = 'X'.
  bs_headx-VENDOR = 'X'.
  bs_headx-PURCH_ORG = 'X'.
  bs_headx-PUR_GROUP = 'X'.
  bs_headx-DOC_DATE = 'X'.
  bs_headx-CURRENCY = 'X'.
  bs_headx-REF_1 = 'X'.
  bs_headx-OUR_REF = 'X'.

    bs_item-PO_ITEM = is_alug-c2.
    bs_item-SHORT_TEXT = is_alug-c4.
    bs_item-MATERIAL = is_alug-c3.
    bs_item-PLANT = is_alug-c7.
    bs_item-MATL_GROUP = is_alug-c6.
    bs_item-QUANTITY = is_alug-c5.
*    bs_item-ITEM_CAT = ''.
*    bs_item-ACCTASSCAT = 'K'.
    bs_item-AGREEMENT = is_alug-c9.
    bs_item-AGMT_ITEM = is_alug-c10.
    APPEND bs_item TO bt_item.

    bs_itemx-PO_ITEM = is_alug-c2.
    bs_itemx-PO_ITEMX = 'X'.
    bs_itemx-SHORT_TEXT = 'X'.
    bs_itemx-MATERIAL = 'X'.
    bs_itemx-PLANT = 'X'.
    bs_itemx-MATL_GROUP = 'X'.
    bs_itemx-QUANTITY = 'X'.
*    bs_itemx-ITEM_CAT = 'X'.
*    bs_itemx-ACCTASSCAT = 'X'.
    bs_itemx-AGREEMENT = 'X'.
    bs_itemx-AGMT_ITEM = 'X'.
    APPEND bs_itemx TO bt_itemx.

    bs_rem-PO_ITEM = is_alug-c2.
    bs_rem-SCHED_LINE = '1'.
    bs_rem-DEL_DATCAT_EXT = 'T'.
    CONCATENATE is_alug-c8(2) '.' is_alug-c8+2(2) '.' is_alug-c8+4(4) INTO v_data.
    bs_rem-DELIVERY_DATE = v_data. "is_alug-c8.
    bs_rem-QUANTITY = is_alug-c5.
    bs_rem-STAT_DATE = is_alug-c8.
    APPEND bs_rem TO bt_rem.

    bs_remx-PO_ITEM = is_alug-c2.
    bs_remx-SCHED_LINE = '1'.
    bs_remx-PO_ITEMX = 'X'.
    bs_remx-SCHED_LINEX = 'X'.
    bs_remx-DEL_DATCAT_EXT = 'X'.
    bs_remx-DELIVERY_DATE = 'X'.
    bs_remx-QUANTITY = 'X'.
    bs_remx-STAT_DATE = 'X'.
    APPEND bs_remx TO bt_remx.

      POHEADER         = bs_head
      POHEADERX        = bs_headx
*      TESTRUN          = 'X'
      EXPHEADER        = bs_headext
      RETURN           = bt_ret
      POITEM           = bt_item
      POITEMX          = bt_itemx
      POSCHEDULE       = bt_rem
      POSCHEDULEX      = bt_remx.

       WAIT          = 'X'.

contract.png (8.5 kB)
bapiret.png (21.4 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Jan 26, 2017 at 02:56 PM

    if you only had shown your source data... just showing one half and let the people imagine the second half is not really helping to get quick solutions.

    If you go for example into SE91, enter there your 06 041 message and click where-used button then are taken so some programs, looking at the coding you can see what SAP compares, it compares header data fields: purchase order document date with contract end of validity date

     IF kekko-kdate NE 0 AND ekko-bedat > kekko-kdate.
          PERFORM enaco(sapfmmex) USING '06' '041'.
          CASE sy-subrc.
            WHEN 1.
              IF sy-binpt EQ space.
                MESSAGE w041 WITH kekko-kdate INTO gl_dummy.
                mmpur_message 'W' '06' '041' kekko-kdate '' '' ''.

    you could also find this coding in SAP notes with bug fixes, e.g. OSS note 749967 - ME21N: Warning message 06040 or 06041 disappears

    Based on that info you know at which date field you have to look: bs_head-DOC_DATE = is_head-c2.

    you actually do some twists and turns for the delivery date in your coding, but I don't see the same for the document date. Are you using 2 different date formats in the same source file? If not then you would probably need to do the same action with all date fields.

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Jürgen!

      Thank you! I've solved it!

      I was so focused on the item dates that forgot all about the document date............. :|

      Once I used FM CONVERT_DATE_TO_INTERNAL on field DOC_DATE (like I did on the item dates) the PO was created.

      Nothing like a new and fresh insight on our work when we're stuck!

      Thanks to all who replied! :)

  • Jan 25, 2017 at 07:55 PM

    I guess your format for the delivery date is not recognized. Try to clear the date category and enter the delivery date in format YYYYMMDD.


    Add comment
    10|10000 characters needed characters exceeded