08-14-2018 8:51 PM
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'.
08-15-2018 12:39 AM
08-15-2018 8:21 AM
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
08-15-2018 8:22 AM
08-15-2018 8:28 AM
Here you can see the runtime error. For further details check comment below.
08-16-2018 12:42 AM
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.