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: 

how to pass data to BAPI_BILLINGDOC_CREATEFROMDATA

Former Member
0 Kudos

Hi ,

i am trying to create an invoice create automation using bapi

  BAPI_BILLINGDOC_CREATEFROMDATA .Please let me know  the data from which tables i need to get.

My sample code i am giving here. At the red colored stmt debugging getting stucked.

Please tell me my mistakes .

   FORM create_invoice .

  SELECT vbeln auart vkorg vtweg
          spart fkara kunnr
          vgbel
      FROM vbak
         INTO CORRESPONDING FIELDS OF TABLE it_vbak 
             WHERE vbeln IN r_vbeln
         AND  auart IN r_fkart .
  IF sy-subrc EQ 0.
    SORT it_vbak[] BY vbeln ."tt_billing_data_in[] by vkorg .
  ENDIF.
  IF it_vbak[] IS NOT INITIAL .
    SELECT vbeln werks matnr kwmeng
      INTO CORRESPONDING FIELDS OF TABLE it_vbap
      FROM vbap
      FOR ALL ENTRIES IN it_vbak
      WHERE vbeln = it_vbak-vbeln .
    IF sy-subrc EQ 0.
      SORT it_vbap[] BY vbeln .
    ENDIF.
  ENDIF.

  LOOP AT it_vbak INTO wa_vbak.
    READ TABLE it_vbap INTO wa_vbap WITH KEY vbeln = wa_vbak-vbeln.
    IF sy-subrc EQ 0.
      READ TABLE it_create WITH KEY vbeln = wa_vbak-vbeln .
      MOVE : wa_vbak-vkorg TO wa_bapi-vkorg,
             wa_vbak-vtweg TO wa_bapi-vtweg ,
             wa_vbak-spart TO wa_bapi-spart,
             wa_vbak-auart TO wa_bapi-auart ,
             wa_vbak-fkara TO wa_bapi-fkara,
             it_create-fkdat TO wa_bapi-fkdat ,
             wa_vbak-kunnr TO wa_bapi-kunag,
             wa_vbap-werks TO wa_bapi-werks ,
             wa_vbak-vgbel TO wa_bapi-vgbel ,
             wa_vbap-matnr TO wa_bapi-matnr ,
             wa_vbap-kwmeng TO wa_bapi-kwmeng .

      APPEND wa_bapi TO it_bapi.
      CLEAR wa_bapi.
    ENDIF.
  ENDLOOP.

  LOOP AT it_bapi INTO wa_bapi.
    MOVE-CORRESPONDING wa_bapi TO t_billing_data_in .
  ENDLOOP.

  LOOP AT it_create .


    CALL FUNCTION 'BAPI_BILLINGDOC_CREATEFROMDATA'
* EXPORTING
*   POSTING                 =
      TABLES
        billing_data_in         =  t_billing_data_in
*    condition_data_in       = t_condition_data
        returnlog_out           = t_returnlog_out
        ccard_data_in           = t_ccard_data_in
              .




    " IF wa_fkart IS NOT INITIAL.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
*      EXPORTING
*        WAIT          =
*     IMPORTING
*         return        = wa_bapiret2
            .

Thanks in advance.

2 REPLIES 2

naresh_bammidi
Contributor
0 Kudos

Hi,

Can you please tell me what is the error you are getting.

Thanks

Naresh

raymond_giuseppi
Active Contributor
0 Kudos

How many records did you get from VBAK (Where is the status check on VBUK, I only see a selection on order type and number)

NB: FOR ALL ENTRIES is not an accelerator (on the contrary)

Regards,

Raymond