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_PO_CREATE1 - Error 06041 : Validity period of contract expired on

Former Member
0 Kudos

Hello,

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 future....it 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.

    CALL FUNCTION 'BAPI_PO_CREATE1'
    EXPORTING
      POHEADER         = bs_head
      POHEADERX        = bs_headx
*      TESTRUN          = 'X'
    IMPORTING
      EXPPURCHASEORDER = bv_pc
      EXPHEADER        = bs_headext
    TABLES
      RETURN           = bt_ret
      POITEM           = bt_item
      POITEMX          = bt_itemx
      POSCHEDULE       = bt_rem
      POSCHEDULEX      = bt_remx.

  IF bv_pc IS NOT INITIAL.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
     EXPORTING
       WAIT          = 'X'.
  ENDIF.

1 ACCEPTED SOLUTION

JL23
Active Contributor

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.

7 REPLIES 7

nomssi
Active Contributor

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.

JNN

Former Member
0 Kudos

Hi,

Thank you for your help Jacques!

I tried with no date category and the delivery date in internal format but with no success. The same message error.

I also tried without the Schedule info and I get the contract validity expired also.

But if I do it through SE37 I get no error! I've checked all the variables on debug and compared them to the entries I made on SE37 and they all are the same. On SE37 no error, on program calling BAPI error.........

HELP! 😛

nomssi
Active Contributor

Use report FBGENDAT to active Write test data and terminate for function module BAPI_PO_CREATE1.

You will then be able to check your data in SE37. Don't forget to deactivate it after your investigation.

JNN

0 Kudos

Hi JNN,

Is it necessary to use this report? One can actually generate test data for a function module directly from the new SAPGUI debugger.

BR,

Suhas

nomssi
Active Contributor
0 Kudos

Hello Suhas,

the report saves the actual data passed to the function module as test data than can be used with transaction SE37 in test mode. So this is different from test data generation.

best regards,

JNN

JL23
Active Contributor

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.

Former Member
0 Kudos

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! 🙂