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: 

let me knew bapi for the t-code FB1D ?!!!

seohyeongkug
Explorer
0 Kudos
560

I already make a BDC for FB1D. but i need a BAPI.

Please let me know bape for the FB1D !!!

1 REPLY 1

seohyeongkug
Explorer
0 Kudos
102

I want to make CLEARING DOCUMENTS for t-code FB70. (DOC TYPE : DR)

SO, I tried to create FB1D or F-32 using BAPI_ACC_DOCUMENT_POST and CLEAR_DOCUMENTS.

However, the item line is created differently from the accounting slip created by bdc.

*PV_BELNR = FB70 DOC NUMBER

IF PV_TCODE = 'FB1D'.
LV_BLART = 'AB'.
ELSE. " IF PV_TCODE = 'FB70'.
LV_BLART = 'DR'.
ENDIF.
GV_BLART = LV_BLART.

CLEAR: GS_HEADER.
REFRESH: GT_ACCOUNTGL, GT_CURRENCYAMOUNT, GT_ACCOUNTRECEIVABLE,
GT_EXTENSION, GT_EXTENSION2, GT_RETURN.

PERFORM FILL_HEADER USING LV_BLART PV_BELNR PS_ACCT .

PERFORM FILL_ACCOUNTAR USING '1' LV_BLART PS_ACCT.
PERFORM FILL_CURRENCYAMOUNT USING '1' 'S' LV_BLART PS_ACCT.
PERFORM FILL_EXTENSION USING '1' PV_BELNR PS_ACCT.

PERFORM FILL_ACCOUNTAR USING '2' LV_BLART PS_ACCT.
PERFORM FILL_CURRENCYAMOUNT USING '2' 'H' LV_BLART PS_ACCT.
* .

CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
EXPORTING
DOCUMENTHEADER = GS_HEADER
IMPORTING
OBJ_TYPE = GV_ME_FITY
OBJ_KEY = GV_ME_FIKE
OBJ_SYS = GV_ME_FISY
TABLES
ACCOUNTGL = GT_ACCOUNTGL
ACCOUNTRECEIVABLE = GT_ACCOUNTRECEIVABLE
CURRENCYAMOUNT = GT_CURRENCYAMOUNT
EXTENSION1 = GT_EXTENSION
RETURN = PT_RETURN.


FORM FILL_HEADER USING PV_BLART
PV_BELNR
PS_ACCT STRUCTURE ZFIS_FB70.

GS_HEADER-BUS_ACT = 'RFBU'.
GS_HEADER-COMP_CODE = GV_BUKRS. "'3000'.
GS_HEADER-USERNAME = SY-UNAME.
GS_HEADER-DOC_DATE = SY-DATUM.
GS_HEADER-PSTNG_DATE = SY-DATUM.
GS_HEADER-TRANS_DATE = SY_DATUM.
GS_HEADER-FISC_YEAR = SY_DATUM(04).
GS_HEADER-HEADER_TXT = PS_ACCT-BKTXT. "
GS_HEADER-DOC_TYPE = PV_BLART. "BLART

ENDFORM. " FILL_HEADER


FORM FILL_ACCOUNTAR USING PY_TABIX
PV_BLART
PS_ACCT STRUCTURE ZFIS_FB70.

CLEAR: GT_ACCOUNTRECEIVABLE.
GT_ACCOUNTRECEIVABLE-ITEMNO_ACC = PY_TABIX.
GT_ACCOUNTRECEIVABLE-CUSTOMER = PS_ACCT-KUNNR.
GT_ACCOUNTRECEIVABLE-GL_ACCOUNT = PS_ACCT-HKONT. "G/L Account '1160101'
GT_ACCOUNTRECEIVABLE-COMP_CODE = PS_ACCT-BUKRS. "Company code '3000'.
GT_ACCOUNTRECEIVABLE-BUS_AREA = PS_ACCT-GSBER. "business Area '3171'
GT_ACCOUNTRECEIVABLE-BUSINESSPLACE = PS_ACCT-BUPLA. "Business Place '370'.
GT_ACCOUNTRECEIVABLE-ITEM_TEXT = PS_ACCT-SGTXT. "item text
GT_ACCOUNTRECEIVABLE-SP_GL_IND = PS_ACCT-UMSKZ. "'E'

IF PV_BLART = 'AB' AND PY_TABIX = '1'.
ELSE.
GT_ACCOUNTRECEIVABLE-TAX_CODE = PS_ACCT-MWSKZ. "TAX CODE 'A0'
ENDIF.

GT_ACCOUNTRECEIVABLE-PROFIT_CTR = PS_ACCT-PRCTR. "Profit Center

APPEND GT_ACCOUNTRECEIVABLE.

ENDFORM. " FILL_ACCOUNTAR


FORM FILL_CURRENCYAMOUNT USING PV_TABIX
PV_SHKZG
PV_BLART
PS_ACCT STRUCTURE ZFIS_FB70.

CLEAR: GT_CURRENCYAMOUNT.
GT_CURRENCYAMOUNT-ITEMNO_ACC = PV_TABIX.
GT_CURRENCYAMOUNT-CURR_TYPE = '00'. "
GT_CURRENCYAMOUNT-CURRENCY = PS_ACCT-WAERS. "
GT_CURRENCYAMOUNT-CURRENCY_ISO = PS_ACCT-WAERS. "

IF PV_SHKZG = 'H'.
PS_ACCT-WRBTR = PS_ACCT-WRBTR * -1.
ENDIF.
GT_CURRENCYAMOUNT-AMT_DOCCUR = PS_ACCT-WRBTR. "
GT_CURRENCYAMOUNT-TAX_AMT = 0. "VAT

APPEND GT_CURRENCYAMOUNT.

ENDFORM. " FILL_CURRENCYAMOUNT


FORM FILL_EXTENSION USING PY_TABIX
PV_BELNR
PS_ACCT STRUCTURE ZFIS_FB70.

DATA: wa_extension TYPE BAPIEXTC,
ext_value(960) TYPE c,
wa_accit TYPE accit,
l_ref TYPE REF TO data.

*Populate the Extension table
GT_EXTENSION-FIELD1 = PY_TABIX. " Item number
GT_EXTENSION-FIELD2 = PV_BELNR.
GT_EXTENSION-FIELD3 = PS_ACCT-BUDAT(04).
GT_EXTENSION-FIELD4 = '001'.

APPEND GT_EXTENSION.
ENDFORM. " FILL_EXTENSION