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: 

Using BAPI_CUSTOMERCONTRACT_CHANGE end of contract

DanielleinaD
Advisor
Advisor
0 Kudos

Hi experts,

it is no problem to test the BAPI via se37 and write data to the table. As i mentioned in the title i need to change the end of the contract date. I found another post that helped me understand the principle. I want to do the exact same thing as the guy in the post.

https://archive.sap.com/discussions/thread/1324687

Bu then if i want to use the FM in my report nothing works. I created an internal table of the type needed for contract_data_in. Now if i commit this internal table to the BAPI the runtime throws an error. How do i define the table that is needed for contract_data_in is there any example code that i can look up. The module looks easy to understand except how to define the table for contract_data_in.



    CALL FUNCTION 'BAPI_CUSTOMERCONTRACT_CHANGE'
      EXPORTING
        salesdocument         = vkbeln
        contract_header_in    = header
        contract_header_inx   = headerx
*       SIMULATION            =
*       BEHAVE_WHEN_ERROR     = ' '
*       INT_NUMBER_ASSIGNMENT = ' '
*       LOGIC_SWITCH          =
*       NO_STATUS_BUF_INIT    = ' '
      TABLES
        return                =  return
*       CONTRACT_ITEM_IN      =
*       CONTRACT_ITEM_INX     =
*       PARTNERS              =
*       PARTNERCHANGES        =
*       PARTNERADDRESSES      =
*       CONDITIONS_IN         =
*       CONDITIONS_INX        =
*       CONTRACT_CFGS_REF     =
*       CONTRACT_CFGS_INST    =
*       CONTRACT_CFGS_PART_OF =
*       CONTRACT_CFGS_VALUE   =
*       CONTRACT_CFGS_BLOB    =
*       CONTRACT_CFGS_VK      =
*       CONTRACT_CFGS_REFINST =
*       CONTRACT_TEXT         =
        contract_data_in      = t_contract
        contract_data_inx     = contractx
*       CONTRACT_KEYS         =
*       EXTENSIONIN           =
      .


*       CALL FUNCTION 'BAPI_Transaktion_commit'.
5 REPLIES 5

DoanManhQuynh
Active Contributor
What is the error? and how did you declare internal table.

DanielleinaD
Advisor
Advisor
0 Kudos

Hi Quynh,

here you can see my code. I dont know why there is a problem with some length which is incorrect.

DATA: ld_newContractEnd TYPE dats.
    TYPES: BEGIN OF KONTRAKT,

      zeile1 TYPE bapictr-ITM_NUMBER,
* 	  Type of contract end 	 
      zeile2 TYPE bapictr-CON_EN_DAT,
END OF KONTRAKT.

DATA t_contract TYPE TABLE OF KONTRAKT.
* working area
DATA wa_kontrakt LIKE LINE OF t_contract.
**************************************************************
wa_kontrakt-zeile1 = 000000.
wa_kontrakt-zeile2 = ld_newContractEnd.
* just for testing reasons 
insert wa_kontrakt INTO t_contract INDEX 1.

*Then commiting the t_contract to the BAPI

DanielleinaD
Advisor
Advisor
0 Kudos

Here are the screenshots

DanielleinaD
Advisor
Advisor
0 Kudos

Here you can see the runtime error. For further details check comment below.

DoanManhQuynh
Active Contributor

OK, as you can see in bapi, CONTRACT_DATA_IN have data structure BAPICTR, you want to use only ITM_NUMBER and CON_EN_DAT in there then you declared your own structure and pass it to bapi obviously t_contract and CONTRACT_DATA_IN wont have the same length and structure right?

what you have to do is just change the declare like this:

DATA wa_kontrakt TYPE BAPICTR.
DATA t_contract TYPE TABLE OF BAPICTR.