Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Tax code in two positions of invoice

I have a bellow program and want to create invoices with 2 positions with tax code but it doesn't work

If I delete IT_ACCOUNTGL-ITEMNO_ACC = 1 then it work but only in second positions in

fb03 I see tax code ...not bad.

REPORT ACC_BAPI_TEST_BILLING LINE-SIZE 250.

SELECTION-SCREEN BEGIN OF BLOCK BL01 WITH FRAME TITLE TEXT-002.

PARAMETER:

CHECK_L DEFAULT 'X' AS CHECKBOX,

CHECK_A DEFAULT 'X' AS CHECKBOX,

POST DEFAULT 'X ' AS CHECKBOX,

REF_KEY LIKE BAPIACHE01-OBJ_KEY DEFAULT '0000000000TEST',

DEST LIKE BDI_LOGSYS-LOGSYS DEFAULT ' '.

SELECTION-SCREEN END OF BLOCK BL01.

DATA:

extension LIKE TABLE OF BAPIEXTC WITH HEADER LINE,

GD_DOCUMENTHEADER LIKE BAPIACHE01,

GD_CUSTOMERCPD LIKE BAPIACPA00,

IT_ACCOUNTRECEIVABLE LIKE BAPIACAR01 OCCURS 0 WITH HEADER LINE,

IT_ACCOUNTGL LIKE BAPIACGL01 OCCURS 0 WITH HEADER LINE,

IT_ACCOUNTTAX LIKE BAPIACTX01 OCCURS 0 WITH HEADER LINE,

IT_CRITERIA LIKE BAPIACKECR OCCURS 0 WITH HEADER LINE,

IT_VALUEFIELD LIKE BAPIACKEVA OCCURS 0 WITH HEADER LINE,

IT_CURRENCYAMOUNT LIKE BAPIACCR01 OCCURS 0 WITH HEADER LINE,

IT_RETURN LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE,

IT_SALESORDER LIKE BAPIACSO00 OCCURS 0 WITH HEADER LINE,

IT_SALESAMOUNT LIKE BAPIACCRSO OCCURS 0 WITH HEADER LINE,

IT_RECEIVERS LIKE BDI_LOGSYS OCCURS 0 WITH HEADER LINE.

PERFORM FILL_INTERNAL_TABLES.

IF CHECK_L = 'X'.

CALL FUNCTION 'BAPI_ACC_BILLING_CHECK'

DESTINATION DEST

EXPORTING

DOCUMENTHEADER = GD_DOCUMENTHEADER

TABLES

ACCOUNTRECEIVABLE = IT_ACCOUNTRECEIVABLE

ACCOUNTGL = IT_ACCOUNTGL

ACCOUNTTAX = IT_ACCOUNTTAX

CRITERIA = IT_CRITERIA

VALUEFIELD = IT_VALUEFIELD

RETURN = IT_RETURN

SALESORDER = IT_SALESORDER

SALESAMOUNT = IT_SALESAMOUNT

EXTENSION1 = EXTENSION

.

WRITE: / 'Result of check lines:'.

PERFORM SHOW_MESSAGES.

ENDIF.

IF CHECK_A = 'X'.

CALL FUNCTION 'BAPI_ACC_BILLING_CHECK'

DESTINATION DEST

EXPORTING

DOCUMENTHEADER = GD_DOCUMENTHEADER

TABLES

ACCOUNTRECEIVABLE = IT_ACCOUNTRECEIVABLE

ACCOUNTGL = IT_ACCOUNTGL

ACCOUNTTAX = IT_ACCOUNTTAX

CRITERIA = IT_CRITERIA

VALUEFIELD = IT_VALUEFIELD

CURRENCYAMOUNT = IT_CURRENCYAMOUNT

RETURN = IT_RETURN

SALESORDER = IT_SALESORDER

SALESAMOUNT = IT_SALESAMOUNT

EXTENSION1 = EXTENSION

.

WRITE: / 'Result of check all:'.

PERFORM SHOW_MESSAGES.

ENDIF.

IF POST = 'X'.

IF DEST = SPACE OR

DEST = GD_DOCUMENTHEADER-OBJ_SYS.

  • post synchron

CALL FUNCTION 'BAPI_ACC_BILLING_POST'

EXPORTING

DOCUMENTHEADER = GD_DOCUMENTHEADER

CUSTOMERCPD = GD_CUSTOMERCPD

TABLES

ACCOUNTRECEIVABLE = IT_ACCOUNTRECEIVABLE

ACCOUNTGL = IT_ACCOUNTGL

ACCOUNTTAX = IT_ACCOUNTTAX

CRITERIA = IT_CRITERIA

VALUEFIELD = IT_VALUEFIELD

CURRENCYAMOUNT = IT_CURRENCYAMOUNT

RETURN = IT_RETURN

SALESORDER = IT_SALESORDER

SALESAMOUNT = IT_SALESAMOUNT

EXTENSION1 = EXTENSION

.

WRITE: / 'Result of post:'.

PERFORM SHOW_MESSAGES.

ELSE.

  • post Idoc

IT_RECEIVERS-LOGSYS = DEST.

APPEND IT_RECEIVERS.

CALL FUNCTION 'ALE_ACC_BILLING_POST'

EXPORTING

DOCUMENTHEADER = GD_DOCUMENTHEADER

CUSTOMERCPD = GD_CUSTOMERCPD

TABLES

ACCOUNTRECEIVABLE = IT_ACCOUNTRECEIVABLE

ACCOUNTGL = IT_ACCOUNTGL

ACCOUNTTAX = IT_ACCOUNTTAX

CRITERIA = IT_CRITERIA

VALUEFIELD = IT_VALUEFIELD

CURRENCYAMOUNT = IT_CURRENCYAMOUNT

SALESORDER = IT_SALESORDER

SALESAMOUNT = IT_SALESAMOUNT

EXTENSION1 = EXTENSION

RECEIVERS = IT_RECEIVERS.

WRITE: / 'IDoc created'.

ENDIF.

ENDIF.

COMMIT WORK.

----


  • Form fill_internal_tables

----


FORM FILL_INTERNAL_TABLES.

data belnr like bkpf-belnr.

CALL FUNCTION 'OWN_LOGICAL_SYSTEM_GET'

IMPORTING

OWN_LOGICAL_SYSTEM = GD_DOCUMENTHEADER-OBJ_SYS.

CALL FUNCTION 'NUMBER_GET_NEXT'

EXPORTING

nr_range_nr = '87'

object = 'RF_BELEG'

subobject = 'JD'

toyear = '2008'

IMPORTING

number = belnr

EXCEPTIONS

interval_not_found = 1

number_range_not_intern = 2

object_not_found = 3

quantity_is_0 = 4

quantity_is_not_1 = 5

interval_overflow = 6

buffer_overflow = 7

OTHERS = 8.

  • fill header

GD_DOCUMENTHEADER-OBJ_TYPE = 'BKPFF'.

GD_DOCUMENTHEADER-OBJ_KEY = belnr.

GD_DOCUMENTHEADER-USERNAME = SY-UNAME.

GD_DOCUMENTHEADER-HEADER_TXT = 'BAPI Test'.

GD_DOCUMENTHEADER-COMP_CODE = 'JD'.

GD_DOCUMENTHEADER-DOC_DATE = sy-datum.

GD_DOCUMENTHEADER-PSTNG_DATE = sy-datum.

GD_DOCUMENTHEADER-REF_DOC_NO = belnr.

  • fill AR (line 1)

IT_ACCOUNTRECEIVABLE-ITEMNO_ACC = 1.

IT_ACCOUNTRECEIVABLE-CUSTOMER = '0020001602'.

IT_ACCOUNTRECEIVABLE-ITEM_TEXT = 'AR BAPI Test'.

IT_ACCOUNTRECEIVABLE-GL_ACCOUNT = '0000132990'.

APPEND IT_ACCOUNTRECEIVABLE.

IT_CURRENCYAMOUNT-ITEMNO_ACC = 1.

IT_CURRENCYAMOUNT-CURR_TYPE = '00'.

IT_CURRENCYAMOUNT-CURRENCY = 'SKK'.

IT_CURRENCYAMOUNT-AMT_DOCCUR = 100.

IT_CURRENCYAMOUNT-EXCH_RATE_V = '0.5'.

APPEND IT_CURRENCYAMOUNT.

  • fill GL (line 2)

IT_ACCOUNTGL-ITEMNO_ACC = 1.

IT_ACCOUNTGL-GL_ACCOUNT = '0000132990'.

IT_ACCOUNTGL-ITEM_TEXT = 'GL BAPI Test1'.

IT_ACCOUNTGL-tax_code = 'N1'.

  • IT_ACCOUNTGL-COSTCENTER = '0001101021'.

APPEND IT_ACCOUNTGL.

IT_ACCOUNTGL-ITEMNO_ACC = 2.

IT_ACCOUNTGL-GL_ACCOUNT = '0000504100'.

IT_ACCOUNTGL-ITEM_TEXT = 'GL BAPI Test'.

IT_ACCOUNTGL-tax_code = 'N1'.

IT_ACCOUNTGL-COSTCENTER = '0001101021'.

APPEND IT_ACCOUNTGL.

IT_CURRENCYAMOUNT-ITEMNO_ACC = 2.

IT_CURRENCYAMOUNT-CURR_TYPE = '00'.

IT_CURRENCYAMOUNT-CURRENCY = 'SKK'.

IT_CURRENCYAMOUNT-AMT_DOCCUR = -100.

IT_CURRENCYAMOUNT-EXCH_RATE_V = '0.5'.

APPEND IT_CURRENCYAMOUNT.

extension-field1 = 'POSNR'.

extension-field2 = '0000000001'.

extension-field3 = 'BSCHL'.

extension-field4 = '40'.

APPEND extension.

extension-field1 = 'POSNR'.

extension-field2 = '0000000001'.

extension-field3 = 'SHKZG'.

extension-field4 = 'S'.

APPEND extension.

extension-field1 = 'POSNR'.

extension-field2 = '0000000002'.

extension-field3 = 'BSCHL'.

extension-field4 = '50'.

APPEND extension.

extension-field1 = 'POSNR'.

extension-field2 = '0000000002'.

extension-field3 = 'SHKZG'.

extension-field4 = 'H'.

APPEND extension.

ENDFORM. " fill_internal_tables

----


  • Form Show_messages

----


FORM SHOW_MESSAGES.

IF IT_RETURN[] IS INITIAL.

WRITE: / 'no messages'.

ELSE.

SKIP 1.

LOOP AT IT_RETURN.

WRITE: / IT_RETURN-TYPE,

(2) IT_RETURN-ID,

IT_RETURN-NUMBER,

(80) IT_RETURN-MESSAGE,

(20) IT_RETURN-PARAMETER,

(3) IT_RETURN-ROW,

IT_RETURN-FIELD.

ENDLOOP.

ENDIF.

ULINE.

ENDFORM. " Show_messages

Edited by: Kosmo on Sep 15, 2008 9:28 AM

Edited by: Kosmo on Sep 15, 2008 9:30 AM

Tags:
Former Member
Not what you were looking for? View more on this topic or Ask a question