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: 

BAPI KB11N problem while uploading

Former Member
0 Kudos

Hi,

while uploading primary account posting i am using the BAPI - BAPI_ACC_PRIMARY_COSTS_POST. its giving error message

E KI 280 Create account 500199 for 31.10.2006 as a cost element in controlling area ZCA1

E FI 320 Company was not supplied in Function Module interface

if i run it in se37 it creates document. guide me in this regard.

Thanks

Muthappan

1 ACCEPTED SOLUTION

Former Member
0 Kudos

SELECT SINGLE kostl

INTO lv_kostl_new

FROM csks

WHERE kokrs = p_kokrs

AND kostl = lv_kostl

<b>and datbi >= sy-datum (or the date it is being posted)

and datab <= sy-datum

</b>

IF sy-subrc = 0.

wa_doc_items-rec_cctr = lv_kostl_new.

ENDIF.

ENDIF.

6 REPLIES 6

Former Member
0 Kudos

do you happen to check the validity dates for the cost element in CSKB for the controlling area.

0 Kudos

NO how to check it? but in se37 it runs fine. what is the difference. i pasted my whole code. what is the need of checking validity dates. do i have to give company in this.

Thanks for your reply in this.

REPORT z99test_kb11n_upl .

DATA : wa_doc_header TYPE bapidochdru12p,

it_doc_items TYPE TABLE OF bapircitm,

wa_doc_items TYPE bapircitm.

DATA : it_return TYPE TABLE OF bapiret2,

wa_return TYPE bapiret2,

g_docno TYPE bapidochdru12p-doc_no,

SEND_CRITERIA type table of BAPIACKECR,

REC_CRITERIA type table of BAPIACKECR2,

CUSTOMER_FIELDS type table of BAPIEXTC.

.

TYPES : BEGIN OF ty_cojrnl,

skostl_old TYPE ekostl_old, "Old Cost center

kstar TYPE kstar, "Cost Element

wtgbtr TYPE ikpsu, "Amount

waers TYPE waers, "currency

skostl_new(12) TYPE c, "New Cost Element or Order

END OF ty_cojrnl.

DATA : it_cojrnl TYPE TABLE OF ty_cojrnl,

wa_cojrnl TYPE ty_cojrnl.

TYPES : BEGIN OF ty_csks,

kokrs TYPE csks-kokrs,

kostl TYPE csks-kostl,

END OF ty_csks.

DATA : it_csks TYPE TABLE OF ty_csks,

wa_csks TYPE ty_csks.

TYPES : BEGIN OF ty_aufk,

aufnr TYPE aufk-aufnr,

END OF ty_aufk.

DATA : it_aufk TYPE TABLE OF ty_aufk,

wa_aufk TYPE ty_aufk.

PARAMETERS: p_kokrs TYPE kokrs,

p_posdat TYPE co_budat,

p_period TYPE co_perio,

p_doctxt TYPE co_bltxt.

PARAMETERS: p_file LIKE rlgrap-filename OBLIGATORY.

  • DEFAULT 'C:\temp\FPS assesment.txt' obligatory.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

PERFORM get_filename CHANGING p_file.

AT SELECTION-SCREEN.

PERFORM validate_kokrs.

*************************************************

  • START OF SELECTION

*************************************************

START-OF-SELECTION.

  • Get all of the information held on the spreadsheets.

PERFORM get_data.

PERFORM process_data.

PERFORM post_data.

FORM get_filename CHANGING s_file.

CALL FUNCTION 'WS_FILENAME_GET'

EXPORTING

def_filename = s_file

  • DEF_PATH = ' '

mask = ',.,..'

  • MODE = ' '

  • TITLE = ' '

IMPORTING

filename = s_file

  • RC =

EXCEPTIONS

inv_winsys = 1

no_batch = 2

selection_cancel = 3

selection_error = 4

OTHERS = 5.

ENDFORM. " get_filename

FORM get_data .

DATA lv_filename TYPE string.

lv_filename = p_file.

break amuthappan.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = lv_filename

filetype = 'ASC'

has_field_separator = '#'

  • HEADER_LENGTH = '1'

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

TABLES

data_tab = it_cojrnl

EXCEPTIONS

file_open_error = 1

file_read_error = 2

no_batch = 3

gui_refuse_filetransfer = 4

invalid_type = 5

no_authority = 6

unknown_error = 7

bad_data_format = 8

header_not_allowed = 9

separator_not_allowed = 10

header_too_long = 11

unknown_dp_error = 12

access_denied = 13

dp_out_of_memory = 14

disk_full = 15

dp_timeout = 16

OTHERS = 17

.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

break amuthappan.

ENDFORM. " get_data

FORM process_data .

DATA : lv_kostl TYPE csks-kostl,

lv_kostl_new type csks-kostl.

*Header details

wa_doc_header-co_area = p_kokrs.

wa_doc_header-docdate = p_posdat.

wa_doc_header-postgdate = p_posdat.

wa_doc_header-period = p_period.

wa_doc_header-doc_hdr_tx = p_doctxt.

wa_doc_header-username = sy-uname.

PERFORM get_kostl_aufnr.

*it_doc_items

  • WTGBTR type IKPSU, "Amount

  • waers type waers, "currency

  • skostl_new type EKOSTL_NEW, "New Cost Element or Order

LOOP AT it_cojrnl INTO wa_cojrnl.

*Old cost center

wa_doc_items-send_cctr = wa_cojrnl-skostl_old.

wa_doc_items-cost_elem = wa_cojrnl-kstar.

wa_doc_items-value_tcur = wa_cojrnl-wtgbtr.

wa_doc_items-trans_curr = wa_cojrnl-waers.

*For internal order check

READ TABLE it_aufk INTO wa_aufk

WITH KEY aufnr = wa_cojrnl-skostl_new.

IF sy-subrc = 0.

wa_doc_items-rec_order = wa_cojrnl-skostl_new.

ELSE.

lv_kostl = wa_cojrnl-skostl_new.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = lv_kostl

IMPORTING

OUTPUT = lv_kostl

.

SELECT SINGLE kostl

INTO lv_kostl_new

FROM csks

WHERE kokrs = p_kokrs

AND kostl = lv_kostl.

IF sy-subrc = 0.

wa_doc_items-rec_cctr = lv_kostl_new.

ENDIF.

ENDIF.

APPEND wa_doc_items TO it_doc_items.

CLEAR: wa_doc_items,lv_kostl.

ENDLOOP.

ENDFORM. " process_data

FORM validate_kokrs .

DATA lv_kokrs TYPE kokrs.

SELECT SINGLE kokrs

INTO lv_kokrs

FROM tka01

WHERE kokrs = p_kokrs.

IF sy-subrc NE 0 OR lv_kokrs IS INITIAL.

MESSAGE e899(sd) WITH 'Invalid controlling area'.

ENDIF.

ENDFORM. " validate_KOKRS

FORM get_kostl_aufnr .

IF NOT it_cojrnl[] IS INITIAL.

*select kokrs

  • kostl

  • from csks

  • into table it_csks

  • for all entries in it_cojrnl

  • where kokrs = p_kokrs

  • and kostl = it_cojrnl-skostl_new.

SELECT aufnr

FROM aufk

INTO TABLE it_aufk

FOR ALL ENTRIES IN it_cojrnl

WHERE aufnr = it_cojrnl-skostl_new.

ENDIF.

ENDFORM. " get_kostl_aufnr

FORM post_data .

CALL FUNCTION 'BAPI_ACC_PRIMARY_COSTS_POST'

EXPORTING

doc_header = wa_doc_header

ignore_warnings = ' '

IMPORTING

doc_no = g_docno

TABLES

doc_items = it_doc_items

return = it_return

SEND_CRITERIA = SEND_CRITERIA

REC_CRITERIA = REC_CRITERIA

CUSTOMER_FIELDS = CUSTOMER_FIELDS

.

IF it_return[] IS INITIAL.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

  • EXPORTING

  • WAIT =

  • IMPORTING

  • RETURN =

.

ELSE.

LOOP AT it_return INTO wa_return.

WRITE : / wa_return-type,

wa_return-id,

wa_return-number,

wa_return-message.

ENDLOOP.

ENDIF.

ENDFORM. " post_data

Former Member
0 Kudos

SELECT SINGLE kostl

INTO lv_kostl_new

FROM csks

WHERE kokrs = p_kokrs

AND kostl = lv_kostl

<b>and datbi >= sy-datum (or the date it is being posted)

and datab <= sy-datum

</b>

IF sy-subrc = 0.

wa_doc_items-rec_cctr = lv_kostl_new.

ENDIF.

ENDIF.

0 Kudos

No i am getting the same problem. do i have to include compnay code also in this. i am getting error as

E KI 280

Create account 500199 for 31.10.2006 as a cost element in controlling area ZCA1

E FI 320

Company was not supplied in Function Module interface

0 Kudos

I solved now. leading zeros is not there in cost element and cost center thats the problem.

Thank you for your response.

Regards

Muthappan

Former Member
0 Kudos

Hello,

this bapi isn't working for different positions in the order (or didn't I see it)

is there any other which consider also the Position of the receiving order?

Thanks in advance

Stephan