‎2006 Dec 29 5:30 PM
Hi All,
I am trying to create Sales contracts using SD_SALESDOCUMENT_CREATE Function Module. I am having two issues and would like your help to resolve them:
1). Somehow the condition value of the line items are being multiplied by 10. For example if the price of line item is $40 and quantity is 5 then it should show as $200 in Condition Value in coditions tab but in fact it shows up as $2000 rather than $200, so, basically somewhere SAP is multiplying this value by 10. It is happening for all line items. Any idea why this will happen?
2). On billing plan tab the billing dates are generated based on the Start Date on the billing plan tab and that field somehow looks at the Contract Start Date under Contract data tab. Unfortunately this won't work for us because in some cases where we provide free service for three months before we want the billing to start, so, basically the contract start date is three months before the billing start date. When I set the contract start date using this above FM SAP automatically generates the billing dates based on that date. I then change the dates using BILLING_SCHEDULE_SAVE but when I go in transaction using VA42(Change contract) SAP changes the dates back to dates based on Contract start date.
Any ideas how I can resolve this?
Any ideas/suggestions will be greatly appreciated.
Regards.
‎2006 Dec 30 4:01 AM
Hi Anurag
The problem with the first point might be with the variable you have declared to populate the condition value in conditions. Please re-check the same. While debugging, check the exact value that you are passing to the FM: SD_SALESDOCUMENT_CREATE
Kind Regards
Eswar
‎2006 Dec 30 7:07 AM
Hello Aurang
I had a similar problem to solve. I needed to create a contract with a defined billing plan. Here is the (rather complex) coding I used for that:
FUNCTION z_billingplan_change .
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*" IMPORTING
*" VALUE(ID_SALESDOCUMENT) TYPE VBELN_VA
*" VALUE(IT_BILLING_PLAN) TYPE Z_FPLAVB_TTYP
*" VALUE(ID_COMMIT) TYPE AS4FLAG DEFAULT ' '
*" EXPORTING
*" REFERENCE(EO_MSGLIST) TYPE REF TO IF_RECA_MESSAGE_LIST
*"----------------------------------------------------------------------
* NOTE: structure z_fplavb consists of:
- ITM_NUMBER (of type POSNR_VA)
- structure FPLAVB
* define local data
DATA:
ls_plan TYPE z_fplavb,
ls_bufferread TYPE sado_buf_flagstring.
DATA:
* lt_return TYPE bapirettab,
* lo_msglist TYPE REF TO if_reca_message_list,
*
ld_fplnr_head TYPE fplnr, " Kopf-Fakturaplan
ld_fplnr_pos TYPE fplnr, " Position-Fakturaplan
ls_vbak TYPE vbak,
ls_vbkd TYPE vbkd,
ls_vbkdvb TYPE vbkdvb,
ls_vbrk TYPE vbrk,
lt_vbkd TYPE STANDARD TABLE OF vbkd,
lt_vbkdvb TYPE STANDARD TABLE OF vbkdvb,
*
ls_fpla TYPE fpla,
ls_fplt TYPE fplt,
ls_zfpla TYPE fplavb,
ls_zfplt TYPE fpltvb,
lt_zfpla_old TYPE STANDARD TABLE OF fplavb,
lt_zfplt_old TYPE STANDARD TABLE OF fpltvb,
lt_zfpla_new TYPE STANDARD TABLE OF fplavb,
lt_zfplt_new TYPE STANDARD TABLE OF fpltvb.
* initialization
OVERLAY ls_bufferread WITH 'XXXXX'.
* Create message handler
eo_msglist = cf_reca_message_list=>create( ).
* Read sales document (with locking, AUTH-Check)
CALL FUNCTION 'SD_SALES_DOCUMENT_READ'
EXPORTING
document_number = id_salesdocument
* PROCESSING_MODIFICATION = ' '
processing_bufferread = ls_bufferread
* RESULTS_INSERT = ' '
* SUPPRESS_AVAILIBILITY_DIA = 'X'
* SUPPRESS_TEXT_POPUP = 'X'
* i_block = 'X'
* STATUS_BUFFER_REFRESH = 'X'
* REQUISITION_BUFFER_REFRESH = 'X'
* CALL_ACTIVE = ' '
* I_NO_AUTHORITY_CHECK = ' '
* I_CALL_BAPI = ' '
* I_CRM_LOCK_MODE = ' '
IMPORTING
evbak = ls_vbak
evbkd = ls_vbkd
EXCEPTIONS
error_message = 1.
IF sy-subrc <> 0.
eo_msglist->add_symsg( ).
RETURN. " leave function module
ENDIF.
CALL FUNCTION 'SD_VBKD_READ_WITH_VBELN'
EXPORTING
i_vbeln = id_salesdocument
* I_BYPASSING_BUFFER = ' '
* I_REFRESH_BUFFER =
TABLES
et_vbkdvb = lt_vbkdvb
et_vbkd = lt_vbkd
EXCEPTIONS
record_not_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
eo_msglist->add_symsg( ).
RETURN. " leave function module
ENDIF.
* Get billing plan number of header
LOOP AT lt_vbkd INTO ls_vbkd
WHERE ( posnr IS INITIAL ).
EXIT.
ENDLOOP.
IF ( syst-subrc = 0 ).
ld_fplnr_head = ls_vbkd-fplnr.
ELSE.
CLEAR: ld_fplnr_head.
ENDIF.
LOOP AT lt_vbkd INTO ls_vbkd.
* Read billing plans (header and/or position)
CALL FUNCTION 'BILLING_SCHEDULE_READ'
EXPORTING
fplnr = ls_vbkd-fplnr
* I_VFKDAT =
* I_BFKDAT =
TABLES
zfpla = lt_zfpla_old
zfplt = lt_zfplt_old
EXCEPTIONS
error_message = 1.
IF sy-subrc <> 0.
eo_msglist->add_symsg( ).
RETURN. " leave function module
ENDIF.
ENDLOOP.
lt_zfpla_new = lt_zfpla_old.
CLEAR: ls_zfpla.
* Modify billing plan
LOOP AT it_billing_plan INTO ls_plan.
READ TABLE lt_vbkd INTO ls_vbkd
WITH KEY posnr = ls_plan-itm_number.
IF ( syst-subrc NE 0 ).
CONTINUE.
ELSE.
LOOP AT lt_zfpla_new INTO ls_zfpla
WHERE ( fplnr = ls_vbkd-fplnr ).
CLEAR: ls_zfpla-rfpln. " cut link to header billing plan
ls_zfpla-updkz = 'U'. " update
ls_zfpla-perio = ls_plan-perio. " change period
MODIFY lt_zfpla_new FROM ls_zfpla.
ENDLOOP.
ENDIF.
ENDLOOP.
CALL FUNCTION 'BILLING_SCHEDULE_SAVE'
TABLES
fpla_new = lt_zfpla_new
fpla_old = lt_zfpla_old
fplt_new = lt_zfplt_new
fplt_old = lt_zfplt_old.
CALL FUNCTION 'SD_ORDER_BILLING_SCHEDULE'
EXPORTING
i_vbeln = id_salesdocument
i_beleg_lesen = 'X'
i_commit = id_commit " committed later
i_termine_bis_zum_horizont = 'X'
* I_MEILENSTEINE_ZURUECKMELDEN =
i_aktualisieren = 'X'
* TABLES
* TMSTSD =
.
ENDFUNCTION.Regards
Uwe
‎2007 Jan 11 5:11 AM
Hi Uwe,
In the code that you have provided here, you are updating the billing plan by copying the billing schedule of the sales order/contract header. I am having a problem here as I don't even have the billing plan on the header level. I need to create it completely from scratch for the sales order items.
Can you please suggest something to help me out.
Thanks,
Rajeev