Application Development and Automation 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: 
Read only

Debit Memos????

Former Member
0 Likes
927

Is there another SAP bapi other than the BAPI_SALESORDER_CREATEFROMDAT2 that would be able to create Debit Memos using Business Object: BUS2096?

BAPI_SALESORDER_CREATEFROMDAT2 creates the orders using BUS2032 which won't work for a Debit Memo.

Thanks........

1 ACCEPTED SOLUTION
Read only

Jelena_Perfiljeva
Active Contributor
0 Likes
801

Please use Search before posting. This question has already been asked at least twice:

7 REPLIES 7
Read only

Former Member
0 Likes
801

Hi,


*Changing the Object Status to Approve
CALL FUNCTION 'I_CHANGE_STATUS'
EXPORTING
objnr = is_vbakch-objnr
estat_inactive = c_e0001
estat_active = c_e0002
EXCEPTIONS
cannot_update = 1
OTHERS = 2.
IF sy-subrc EQ 0.
is_billing-salesorg = is_vbakch-vkorg.
is_billing-distr_chan = is_vbakch-vtweg.
is_billing-division = is_vbakch-spart.
is_billing-doc_type = is_vbakch-auart.
is_billing-ref_doc = is_vbakch-vbeln.
is_billing-bill_date = sy-datum.
is_billing-sold_to = is_vbakch-kunnr.
is_billing-ref_doc_ca = c_x.
APPEND is_billing TO it_billing.
ENDIF.
ENDLOOP.

* BAPI To create Billing for the Credit Memo.

CALL FUNCTION 'BAPI_BILLINGDOC_CREATEMULTIPLE'
TABLES
billingdatain = it_billing
return = it_returncg
success = it_bilsuccess.

Please use these for Credit memo or debitmemo creation using upload .. If u want i can send the coding also ..

Regards,

Srinivas.

Edited by: Srininas on Apr 6, 2010 7:16 PM

Read only

0 Likes
801

Sure if you could send me the coding I would like to understand how this works better.

Can you explain to me what the 'I_CHANGE_STATUS' does? and also what the 'BAPI_BILLINGDOC_CREATEMULTIPLE' is doing?

Read only

0 Likes
801

What component is this bapi in? I can't find it when searching transaction BAPI.

Read only

0 Likes
801
SELECT vbeln netwr waerk bname  kunnr  objnr  erdat auart vkorg vtweg spart
  FROM vbak
  INTO TABLE it_vbak
  WHERE auart IN (c_zcn,c_zdn,c_zcrl,c_zdrl)
    AND vkbur = tvkbz-vkbur
    AND vkorg = vbak-vkorg
    AND vtweg = vbak-vtweg.

  IF sy-subrc EQ 0.
    SORT it_vbak BY kunnr objnr.
    IF vbak-kunnr IS NOT INITIAL.
      DELETE it_vbak WHERE kunnr NE vbak-kunnr.
    ENDIF.
  ENDIF.
  IF it_vbak IS INITIAL.
    MESSAGE e000(ymsd) WITH text-001. "No Records Found'.
  ENDIF.

" fetching the Name of the Customer from KNA1 table.
  IF NOT it_vbak IS INITIAL.

    SELECT kunnr name1
    INTO TABLE it_kna1
    FROM kna1
    FOR ALL ENTRIES IN it_vbak
    WHERE kunnr = it_vbak-kunnr.
    IF sy-subrc = 0.
      SORT it_kna1 BY kunnr name1.
    ENDIF.

"Fetching the Status of the Order
    SELECT objnr
    INTO TABLE it_jest
    FROM jest
    FOR ALL ENTRIES IN it_vbak
    WHERE objnr = it_vbak-objnr
      AND stat = 'E0001'
      AND inact = space.
    IF sy-subrc = 0.
      SORT it_jest BY objnr.
    ENDIF.

  ENDIF.

"Modifying the table IT_VBAK with Customer Name.
"Deleting the Records from IT_VBAK where the Object Status is Not Found.
  LOOP AT it_vbak INTO is_vbak.
    w_tabix = sy-tabix.

    READ TABLE it_kna1 INTO is_kna1 WITH KEY kunnr = is_vbak-kunnr BINARY SEARCH.
    IF sy-subrc = 0.
      is_vbak-bname = is_kna1-name1.
      MODIFY it_vbak FROM is_vbak INDEX w_tabix TRANSPORTING bname.
    ENDIF.

    READ TABLE it_jest TRANSPORTING NO FIELDS WITH KEY objnr = is_vbak-objnr
                                                       BINARY SEARCH.
    IF sy-subrc NE 0.
      DELETE it_vbak INDEX w_tabix.
    ENDIF.

  ENDLOOP.

"Moving the Selected Orders into tabel IT_VBAKCH.
  LOOP AT it_vbak INTO is_vbak WHERE sel = c_x.
    w_tabix = sy-tabix.
    MOVE-CORRESPONDING is_vbak TO is_vbakch.
    MODIFY it_vbakch FROM is_vbakch INDEX w_tabix.
    IF sy-subrc <> 0 .
      APPEND is_vbakch TO it_vbakch.
    ENDIF.
  ENDLOOP.

LOOP AT it_vbakch INTO is_vbakch.

" Changing the Object Status to Approve
    CALL FUNCTION 'I_CHANGE_STATUS'
      EXPORTING
        objnr          = is_vbakch-objnr
        estat_inactive = c_e0001
        estat_active   = c_e0002
      EXCEPTIONS
        cannot_update  = 1
        OTHERS         = 2.
    IF sy-subrc EQ 0.
      is_billing-salesorg = is_vbakch-vkorg.
      is_billing-distr_chan = is_vbakch-vtweg.
      is_billing-division = is_vbakch-spart.
      is_billing-doc_type = is_vbakch-auart.
      is_billing-ref_doc = is_vbakch-vbeln.
      is_billing-bill_date = sy-datum.
      is_billing-sold_to = is_vbakch-kunnr.
      is_billing-ref_doc_ca = c_x.
      APPEND is_billing TO it_billing.
    ENDIF.
  ENDLOOP.

" BAPI To create Billing for the Credit Memo.

  CALL FUNCTION 'BAPI_BILLINGDOC_CREATEMULTIPLE'
    TABLES
      billingdatain = it_billing
      return        = it_returncg
      success       = it_bilsuccess.

Edited by: Srininas on Apr 6, 2010 8:39 PM

Edited by: Srininas on Apr 6, 2010 8:41 PM

Read only

Jelena_Perfiljeva
Active Contributor
0 Likes
802

Please use Search before posting. This question has already been asked at least twice:

Read only

0 Likes
801

Thanks.........

How do you refresh transaction "BAPI" so it will contain all the bapi's in the system? Reason I'm asking is because BAPI_SALESDOCU_CREATEFROMDATA wasn't listed in there when searching.

Read only

0 Likes
801

Is there a updated version to this BAPI_SALESDOCU_CREATEFROMDATA or is that the most current version?