cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Issues when using BAdI SD_BIL_DATA_TRANSFER

MichaelNielsen
Explorer
0 Likes
719

We are using BAdI SD_BIL_DATA_TRANSFER to calculate a value for a custom field with data from a work package.

This is causing the billing document to not properly determine billing date (field is empty) and also the sales tax determination in the pricing procedure is not executed correctly (getting a 208 error)

I can add the billing date manually and when re-pricing the document, it determines sales tax correctly.

Any idea what causes this behaviour?

This is the code for the custom logic:

SELECT
SINGLE wbselementinternalid
  FROM i_projectbillingelemententry AS ent
 INNER JOIN i_projectbillingelemententrflw AS flw
    ON flw~projbillgelmntentritmuuid = ent~projbillgelmntentritmuuid
 WHERE flw~projectbillingrequest = @bil_doc_item-referencesddocument
   AND flw~billingdocrequestitemreference = @bil_doc_item-referencesddocumentitem
  INTO @DATA(lv_wbs) PRIVILEGED ACCESS.


SELECT
SINGLE yy1_monthlymax_cpd, yy1_quarterlymax_cpd, yy1_annualmax_cpd
  FROM i_workpackage AS fnl
 INNER JOIN i_wbselementbasicdata AS wbs
    ON  fnl~workpackage = wbs~wbselement
 WHERE wbs~wbselementinternalid = @lv_wbs
  INTO @DATA(ls_thresholds) PRIVILEGED ACCESS.

IF sy-subrc = 0.
  IF  bil_doc_item-billingquantity < ls_thresholds-yy1_monthlymax_cpd.
    bil_doc_item_res-YY1_TOBEBILLED_QTY_BDI = '0'.
  ELSE.
    bil_doc_item_res-YY1_TOBEBILLED_QTY_BDI = bil_doc_item-billingquantity - ls_thresholds-yy1_monthlymax_cpd.
  ENDIF.
  bil_doc_item_res-YY1_TOBEBILLED_QTY_BDIU = bil_doc_item-BASEUNIT.
ENDIF.

SELECT
SINGLE wbselementinternalid
FROM i_projectbillingelemententry AS ent
INNER JOIN i_projectbillingelemententrflw AS flw
ON flw~projbillgelmntentritmuuid = ent~projbillgelmntentritmuuid
WHERE flw~projectbillingrequest = @bil_doc_item-referencesddocument
AND flw~billingdocrequestitemreference = @bil_doc_item-referencesddocumentitem
INTO @DATA(lv_wbs) PRIVILEGED ACCESS.


SELECT
SINGLE yy1_monthlymax_cpd, yy1_quarterlymax_cpd, yy1_annualmax_cpd
FROM i_workpackage AS fnl
INNER JOIN i_wbselementbasicdata AS wbs
ON fnl~workpackage = wbs~wbselement
WHERE wbs~wbselementinternalid = @lv_wbs
INTO @DATA(ls_thresholds) PRIVILEGED ACCESS.

IF sy-subrc = 0.
IF bil_doc_item-billingquantity < ls_thresholds-yy1_monthlymax_cpd.
bil_doc_item_res-YY1_TOBEBILLED_QTY_BDI = '0'.
ELSE.
bil_doc_item_res-YY1_TOBEBILLED_QTY_BDI = bil_doc_item-billingquantity - ls_thresholds-yy1_monthlymax_cpd.
ENDIF.
bil_doc_item_res-YY1_TOBEBILLED_QTY_BDIU = bil_doc_item-BASEUNIT.
ENDIF.

 

Accepted Solutions (0)

Answers (0)