cancel
Showing results for 
Search instead for 
Did you mean: 

Updating contract Payment terms

0 Kudos

Hi.

 

I have this piece of code

 

 

          DATA: LD_VBELN TYPE VBELN, " Document number
          LS_BAPISDH1 TYPE BAPISDH1, " Contract header data
          LS_BAPISDH1X TYPE BAPISDH1X, " Contract header data (change flag)
          LT_BAPISDITM TYPE TABLE OF BAPISDITM WITH HEADER LINE, " Contract item data
          LT_BAPISDITMX TYPE TABLE OF BAPISDITMX WITH HEADER LINE, " Contract item data (change flag)
          lt_return TYPE TABLE OF bapiret2,
          ls_return TYPE bapiret2.
          
          LD_VBELN = gv_ekko-ebeln. "document number
          LS_BAPISDH1X-UPDATEFLAG = 'U'.
          LT_BAPISDITM-ITM_NUMBER = '000010'.
          LT_BAPISDITM-PMNTTRMS = ''. "Clear Payment terms
          APPEND LT_BAPISDITM.
          CLEAR LT_BAPISDITM.

          LT_BAPISDITMX-ITM_NUMBER = '000010'.
          LT_BAPISDITMX-UPDATEFLAG = 'U'.
          LT_BAPISDITMX-PMNTTRMS = 'X'.
          APPEND LT_BAPISDITMX.
          CLEAR LT_BAPISDITMX.

          " BAPI call to update the customer material number in the sales order
          CALL FUNCTION 'BAPI_CUSTOMERCONTRACT_CHANGE'
            EXPORTING
              SALESDOCUMENT = LD_VBELN
              CONTRACT_HEADER_IN = LS_BAPISDH1
              CONTRACT_HEADER_INX = LS_BAPISDH1X
            TABLES
              RETURN = LT_RETURN
              CONTRACT_ITEM_IN = LT_BAPISDITM
              CONTRACT_ITEM_INX = LT_BAPISDITMX.

          " BAPI to commit the sales order update in the database
          CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
            EXPORTING
              WAIT = 'X'.

          LOOP AT lt_return INTO ls_return.
            WRITE: / ls_return-type, ls_return-message.
          ENDLOOP.

 

But I'm getting this error

"E SD document XYZ is not in the database or has been archived"

The ekko and ekpo lines exists.

Any idea?

 

 

 

View Entire Topic
raymond_giuseppi
Active Contributor
0 Kudos

It seems you are using a SD contract BAPI (VA42) to update a MM purchase contract (ME32K) ?

  • What is your exact requirement
  • For MM contract use BAPI_CONTRACT_CHANGE
  • Move the LOOP at RETURN table for error message (type 'E') BEFORE the COMMIT.
Ryan-Crosby
Active Contributor
0 Kudos
Yep, definitely the wrong BAPI for a purchase order update.
0 Kudos

Hi.
Explaining.
I have the document number that cames from EKKO / EKPO table (ebeln).
What do you suggest to update the contract info (in this case the Terms of Payment)?

I have this:

          lv_contract_no = gv_ekko-ebeln. " Contract number
          l_HEADER-pmnttrms = ''. " New payment term value
          l_HEADERX-pmnttrms = 'X'. " Mark field for update

*          PMNTTRMS
          " Update payment terms
          CALL FUNCTION 'BAPI_CONTRACT_CHANGE'
            EXPORTING
              PURCHASINGDOCUMENT = lv_contract_no
              HEADER = l_HEADER
              HEADERX = l_HEADERX

            TABLES
              return = lt_return.

But I'm getting this

marcobranco1975_5_0-1714642408216.png

Any idea, what I'm doing wrong?!?!?!
Thanks in advance.
Marco

raymond_giuseppi
Active Contributor
0 Kudos

Which kind of PO document are you trying to change (there are different BAPIs)

Value of EKKO-BSTYP is

Lower ValueShort DescriptionTransactionBAPI
ARequest for QuotationME43 
FPurchase OrderME23NBAPI_PO_CHANGE
KContractME33KBAPI_CONTRACT_CHANGE
LScheduling AgreementME33LBAPI_SAG_CHANGE
RRFQ  
OQuotation  
CCentral Contract  
PCentral Purchsae Order  
NCentral Request for Quotation  
TCentral Supplier Quotation  
0 Kudos

HI

It's type L (Scheduling Agreement).

What is your suggestion? To update Contract Terms of Payment?
Thanks in advance

Marco Branco

 

raymond_giuseppi
Active Contributor
0 Kudos
Try BAPI_SAG_CHANGE