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: 

Contract start and end date in BAPI_CONTRACT_CREATEFROMDATA

Former Member
0 Kudos

HI,

I am using BAPI_CONTRACT_CREATEFROMDATA to create a contract from within a custom ABAP program. However I cannot figure out how to get the contract start and end dates into the contract header. I know that you can enter them into the ONTRACT_DATA_IN table parameter but these dates only appear on the line items and not the header.

Does anyone know which parameters on the function map to the contract header start and end dates.

Thanks.

1 ACCEPTED SOLUTION

sreeramkumar_madisetty
Active Contributor

Hi

While Creating the Contracts,Take the Structures of :

CONTRACT_HEADER_INX

CONTRACT_HEADER_IN.

there are fields CT_VALID_F and CT_VALID_T in structure CONTRACT_HEADER_IN needs to be filled.

Regards,

Sreeram

10 REPLIES 10

martin_voros
Active Contributor
0 Kudos

Hi,

there are fields CT_VALID_F and CT_VALID_T in structure CONTRACT_HEADER_IN. Have you tried to use these fields? Don't forget to fill structure CONTRACT_HEADER_INX.

Cheers

sreeramkumar_madisetty
Active Contributor

Hi

While Creating the Contracts,Take the Structures of :

CONTRACT_HEADER_INX

CONTRACT_HEADER_IN.

there are fields CT_VALID_F and CT_VALID_T in structure CONTRACT_HEADER_IN needs to be filled.

Regards,

Sreeram

0 Kudos

Thanks for the suggestions but I have in fact tried these fields (and yes I did remember the 'X's in the companion structure). However the dates do not appear.

Any other thoughts on where I might be going wrong?

0 Kudos

Hi,

there are also fields QT_VALID_F and QT_VALID_T for quotation or inquiry. So it looks like for different contract types you need to use different fields. This BAPI calls FM SD_SALESDOCUMENT_CREATE which has subroutine ms_move_header_in which maps from BAPI fields to internal fields. Here is a small part of this routine.


  MOVE order_header_in-qt_valid_f       TO e_vbakkom-angdt.
  MOVE order_header_in-qt_valid_t       TO e_vbakkom-bnddt.
  MOVE order_header_in-ct_valid_f       TO e_vbakkom-guebg.
  MOVE order_header_in-ct_valid_t       TO e_vbakkom-gueen.

When I check technical fields for the screen fields "Valid from" and "Valid to" in VA43 I get names GUEBG and GUEEN. So it still looks like you should use CT_VALID_F and CT_VALID_T.

I forgot to mention you can still debug BAPI to figure out where the problem is.

Good luck

Edited by: Martin Voros on Sep 11, 2009 9:57 AM

0 Kudos

It would seem that the BAPI is losing certain data on the way through. A MOVE-CORRESPONDING comand seems to ensure that the date gets lost.

This line is where it happens;

In Function SD_SALES_HEADER_MAINTAIN

  • 04. Vertragsdaten aus Schnittstelle zur Verarbeitung übernehmen

MOVE-CORRESPONDING FVBAKKOM TO VEDAKOM.

The first structure contains the dates but after the command executes those dates have not made it into the second structure.

I found that by putting the dates into the second struture (via the debugger) I could get the header dates written correctly.

Doesn't get me round my problem though.

Edited by: AlistairD55 on Sep 11, 2009 2:15 PM

0 Kudos

I think those on the header on not the right ones for you. You will have to fill in the start and end date for each item of the contract in the tables parameter CONTRACT_DATA_IN fields CON_ST_DAT, CON_EN_DAT.

0 Kudos

For header, use item number ITM_NUMBER = '000000'.

0 Kudos

Excellent. That did the trick. Many thanks indeed.

0 Kudos

Hi Alistair,

     Just want to check where did you change the ITM_NUMBER field, its not available in the header part in the BAPI header structure.

cheers,

Charlie

0 Kudos

Hi,

I am trying to use the same fields in quotation BAPI (BAPI_QUOTATION_CREATEFROMDATA2 ) to update contract start and end date, because of start date rule, contract start date and end date are not updating.

We have any rule field here to update, so then how to use this ct_valid_t and ct_valid_f fields to update contract dates.

Thanks,

Muthu.