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

bapi

Former Member
0 Likes
548

hi,

how do i get the billing doc number and its item number after i call this bapi,

BAPI_BILLINGDOC_CREATE.

thanks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
509

You could read it from the RETURN table....You get the VBELN and then read all data from table VBRK.

Greetings,

Blag.

4 REPLIES 4
Read only

Former Member
0 Likes
510

You could read it from the RETURN table....You get the VBELN and then read all data from table VBRK.

Greetings,

Blag.

Read only

Former Member
0 Likes
509

Hi ,

Your question is good , but you have to take those two fields from VBRK - Header table and VBRP - item level table the fields called VBELN and BELNR.

Use always Return Structure in BAPI called BAPITET2 structure.

if you give exact requirement i can provide you fruitfull answer.

Thank you.

Thanks & Regards

Ramana

Read only

Former Member
0 Likes
509

HI

  • Structures for BAPI

data: gm_header type bapi2017_gm_head_01.

data: gm_code type bapi2017_gm_code.

data: gm_headret type bapi2017_gm_head_ret.

data: gm_item type table of

bapi2017_gm_item_create with header line.

data: gm_return type bapiret2 occurs 0.

data: gm_retmtd type bapi2017_gm_head_ret-mat_doc.

clear: gm_return, gm_retmtd. refresh gm_return.

  • Setup BAPI header data.

gm_header-pstng_date = sy-datum.

gm_header-doc_date = sy-datum.

gm_code-gm_code = '06'. " MB11

  • Write 551 movement to table

clear gm_item.

move '551' to gm_item-move_type .

move '000000000040001234' to gm_item-material.

move '1' to gm_item-entry_qnt.

move 'EA' to gm_item-entry_uom.

move '0004' to gm_item-plant.

move '4000' to gm_item-stge_loc.

move '201' to gm_item-move_reas.

  • Determine cost center per plant

case xresb-werks.

when '0004'.

move '0000041430' to gm_item-costcenter.

when '0006'.

move '0000041630' to gm_item-costcenter.

when '0007'.

move '0000041731' to gm_item-costcenter.

when '0008'.

move '0000041830' to gm_item-costcenter.

endcase.

append gm_item.

  • Call goods movement BAPI

call function 'BAPI_GOODSMVT_CREATE'

exporting

goodsmvt_header = gm_header

goodsmvt_code = gm_code

importing

goodsmvt_headret = gm_headret

materialdocument = gm_retmtd

tables

goodsmvt_item = gm_item

return = gm_return.

call function 'BAPI_TRANSACTION_COMMIT'

exporting

wait = 'X'.

http://www.sap-img.com/abap/bapi-goodsmvt-create-to-post-goods-movement.htm

http://www.4ap.de/abap/bapi_goodsmvt_create.php

DATA : V_HEADER_TXT LIKE X_GOODS_MVT_HEAD-HEADER_TXT.

DATA : X_GOODS_MVT_HEAD LIKE BAPI2017_GM_HEAD_01,

X_GOODS_MVT_CODE LIKE BAPI2017_GM_CODE,

IT_GOODS_MVT_ITEM LIKE BAPI2017_GM_ITEM_CREATE OCCURS 0 WITH HEADER LINE,

IT_RETURN LIKE BAPIRET2 OCCURS 0

WITH HEADER LINE.

X_GOODS_MVT_HEAD-PSTNG_DATE = SY-DATUM.

X_GOODS_MVT_HEAD-DOC_DATE = SY-DATUM.

X_GOODS_MVT_HEAD-HEADER_TXT = V_HEADER_TXT.

CALL FUNCTION 'BAPI_GOODSMVT_CREATE'

EXPORTING

GOODSMVT_HEADER = X_GOODS_MVT_HEAD

GOODSMVT_CODE = X_GOODS_MVT_CODE

IMPORTING

MATERIALDOCUMENT = P_MATDOC

TABLES

GOODSMVT_ITEM = IT_GOODS_MVT_ITEM

RETURN = IT_RETURN.

u need to call this fm if the above is successful

IF NOT P_MATDOC IS INITIAL.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

V_BAPI_NO_ERR = 'X'.

ENDIF.

Regards

Laxmi

Read only

Former Member
0 Likes
509

Hi,

Please find the sample code for Billing document BAPI. Please award the points if it is working for you.

t_billing-salesorg = vbak-vkorg.

t_billing-DISTR_CHAN = vbak-vtweg.

t_billing-DIVISION = vbak-spart.

t_billing-DOC_TYPE = vbak-auart.

t_billing-ref_doc = vbak-vbeln.

t_billing-ref_item = vbap-posnr.

t_billing-doc_number = vbak-vbeln.

t_billing-ITM_NUMBER = vbap-posnr.

t_billing-ordbilltyp = 'BILLING TYPE'.

t_billing-price_date = sy-datum.

t_billing-ref_doc_ca = vbak-vbtyp.

t_billing-sold_to = vbak-kunnr.

t_billing-material = vbap-matnr.

t_billing-plant = vbap-werks.

APPEND t_billing.

CALL FUNCTION 'BAPI_BILLINGDOC_CREATEMULTIPLE'

TABLES

billingdatain = t_billing

return = t_return

success = t_success.

commit work.

Regards,

Bhaskar