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: 

Please Help!! Error in document : BKPFF $ DEVCLNT

Former Member

Hi All Gurus,

I am trying to use BAPI - BAPI_ACC_DOCUMENT_POST to post to FB50.

I am using the below paramaters -

DOCUMENTHEADER

TABLES

ACCOUNTGL

CURRENCYAMOUNT

RETURN.

But I am getting the error - Error in document : BKPFF $ DEVCLNT. Can someone please help me with this. I have been breaking my head over this. Dont know what is going wrong! .

Thanks, Nina.

1 ACCEPTED SOLUTION

aaron_morden2
Contributor

The RETURN parameter is an internal table. Are you looping through it to display all of the error messages? There should be more of a message than just " Error in document : BKPFF $ DEVCLNT".

16 REPLIES 16

aaron_morden2
Contributor

The RETURN parameter is an internal table. Are you looping through it to display all of the error messages? There should be more of a message than just " Error in document : BKPFF $ DEVCLNT".

0 Kudos

Hi Aaron,

I checked the return table, I am getting 'G/L account 113020 is not defined in char'

Any suggestions?

Thanks, Nina.

0 Kudos

That GL Account is not defined in Chart of Accounts.

you must consult a FI-CO Consultant.

See the table SKA1...

Message was edited by:

Varun Verma

0 Kudos

Nina,

Make sure that you are passing the GL Account like this:

wa_accountgl-gl_account = '0000113020'.

0 Kudos

Hi Varun,

I checked in ska1, the account has been created. I tried with another account too, same problem.

0 Kudos

Hi Aaron,

I am passing the account through an internal table, and the credit account like you specified. It still does not help. Any suggestions?

0 Kudos

Hi

u should past your code where you fill the tables for the BAPI

Max

0 Kudos

Could you please post your program? Please use the code button when posting code, it makes it easier to read.

0 Kudos

Thanks for all your help, Aaron.

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

*T Y P E S *

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

TYPES: BEGIN OF t_indata,

t_ddate(8) TYPE c,

t_ref(17) TYPE c,

t_dbank(8) TYPE c,

t_disno(4) TYPE c,

t_glacnt(10) TYPE c,

t_descrip(50) TYPE c,

t_damt(13) TYPE c,

t_jobid(8) TYPE c,

t_rexpen(8) TYPE c,

t_tperiod(8) TYPE c,

t_tnumb(8) TYPE c,

t_ctrans(8) TYPE c,

t_ccenter(10) TYPE c,

END OF t_indata.

TYPES: BEGIN OF t_error,

t_ddate(8) TYPE c,

t_ref(17) TYPE c,

t_dbank(8) TYPE c,

t_disno(4) TYPE c,

t_glacnt(10) TYPE c,

t_descrip(50) TYPE c,

t_damt(13) TYPE c,

t_jobid(8) TYPE c,

t_rexpen(8) TYPE c,

t_tperiod(8) TYPE c,

t_tnumb(8) TYPE c,

t_ctrans(8) TYPE c,

t_ccenter(10) TYPE c,

message(100) type c, " Error message

END OF t_error.

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

*W O R K A R E A S *

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

DATA: w_indata TYPE t_indata,

w_error TYPE t_error.

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

*I N T E R N A L T A B L E S *

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

DATA: i_indata TYPE STANDARD TABLE OF t_indata WITH HEADER LINE,

i_error TYPE STANDARD TABLE OF t_error WITH HEADER LINE.

DATA: i_acgl LIKE BAPIACGL09 OCCURS 0 WITH HEADER LINE,

i_currency LIKE BAPIACCR09 OCCURS 0 WITH HEADER LINE,

i_return LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE.

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

*V A R I A B L E S *

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

DATA: v_file TYPE string,

v_string(1022), " To read data from file

v_ddate(10) TYPE c,

v_pdate(10) TYPE c,

v_dcre type wrbtr, " Dollar Amount credit conv

v_ddeb TYPE wrbtr, " Dollar Amount debit conv

v_lines TYPE i, " used for format message

v_msg(100), " used for Error message

v_ind TYPE i,

v_index type i.

DATA: V_DOCHEADER LIKE BAPIACHE09.

  • V_OBJ_TYPE LIKE BAPIACHE09-OBJ_TYPE,

  • V_OBJ_KEY LIKE BAPIACHE09-OBJ_KEY,

  • V_OBJ_SYS LIKE BAPIACHE09-OBJ_SYS.

*

*

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

*C O N S T A N T S *

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

CONSTANTS: c_creacnt TYPE string VALUE '111444', " Liability account

c_del type x value '09', " for hash delimited file

c_fslash VALUE '\', " Used for Forward slash

c_bslash VALUE '/'. " Used for backward slash

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

*S E L E C T I O N S C R E E N

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

SELECTION-SCREEN SKIP.

SELECTION-SCREEN BEGIN OF BLOCK first WITH FRAME TITLE text-001.

PARAMETERS: p_fname LIKE rlgrap-filename OBLIGATORY DEFAULT 'C:\CorpCard.txt', " File name

rd_pserv RADIOBUTTON GROUP radi DEFAULT 'X', " Pres. Server

rd_aserv RADIOBUTTON GROUP radi. " App. Server

  • Error file

parameters: p_efile type rlgrap-filename default

'/tmp/CorpCard_error'.

SELECTION-SCREEN END OF BLOCK first.

**----


    • At selection-screen

**----


  • Check which file is selected

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fname.

  • Perform to get the current value of the selection screen

PERFORM get_current_value.

IF rd_aserv = 'X'.

MESSAGE i398 WITH 'Can not browse unix directories'(030).

ELSE.

  • F4 help for presentation server file name

PERFORM get_local_file_name USING 'P_FNAME' CHANGING p_fname.

ENDIF.

AT SELECTION-SCREEN.

  • perform to validate input file

PERFORM validate_filename USING p_fname.

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

  • S T A R T O F S E L E C T I O N *

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

START-OF-SELECTION.

  • Presentation File upload

if rd_pserv = 'X'.

perform upload_pre_file.

endif.

  • Unix File Upload

if rd_aserv = 'X'.

perform upload_unix_file.

endif.

  • Perform to populate the internal table to the bapi.

PERFORM populate_debit.

  • Perform to populate the internal table to the bapi.

PERFORM populate_credit.

  • Perform to process the input data and post to FB50

PERFORM post_data.

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

  • E N D O F S E L E C T I O N *

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

END-OF-SELECTION.

*if not i_error[] is initial.

  • perform to generate error file and send to application server

perform generate_error_report.

  • endif.

&----


*& Form get_current_value

&----


FORM get_current_value .

  • Local internal table for screen fields

DATA: BEGIN OF i_dynpfields OCCURS 0.

INCLUDE STRUCTURE dynpread.

DATA: END OF i_dynpfields.

CLEAR i_dynpfields.

REFRESH i_dynpfields.

i_dynpfields-fieldname = 'RD_ASERV'.

APPEND i_dynpfields.

CALL FUNCTION 'DYNP_VALUES_READ'

EXPORTING

dyname = sy-cprog

dynumb = sy-dynnr

TABLES

dynpfields = i_dynpfields

EXCEPTIONS

invalid_abapworkarea = 1

invalid_dynprofield = 2

invalid_dynproname = 3

invalid_dynpronummer = 4

invalid_request = 5

no_fielddescription = 6

invalid_parameter = 7

undefind_error = 8

double_conversion = 9

OTHERS = 10.

IF sy-subrc <> 0.

MESSAGE i398 WITH 'Unbale to read the selection screen values'(031)

.

ELSE.

READ TABLE i_dynpfields INDEX 1.

IF sy-subrc = 0.

MOVE i_dynpfields-fieldvalue TO rd_aserv.

ENDIF.

ENDIF.

ENDFORM. " get_current_value

&----


*& Form get_local_file_name

&----


FORM get_local_file_name USING p_file

CHANGING p_cfile.

  • Local variable

DATA: l_fname LIKE ibipparms-path, " File name

v_repid LIKE sy-repid.

l_fname = p_file.

v_repid = sy-repid.

CALL FUNCTION 'F4_FILENAME'

EXPORTING

program_name = v_repid

dynpro_number = sy-dynnr

field_name = p_file

IMPORTING

file_name = l_fname

EXCEPTIONS

OTHERS = 1.

IF sy-subrc = 0.

p_cfile = l_fname.

ENDIF.

ENDFORM. " get_local_file_name

&----


*& Form validate_filename

&----


FORM validate_filename USING p_fname TYPE any.

IF rd_aserv = 'X'.

  • Local variable for file length

DATA : l_len TYPE i.

l_len = STRLEN( p_fname ).

IF p_fname CA space.

IF sy-fdpos < l_len.

MESSAGE e398 WITH 'File name should not contain spaces'(032).

ENDIF.

ENDIF.

IF p_fname CA c_fslash.

MESSAGE e398 WITH 'File name should not contain \'(033).

ENDIF.

IF p_fname NA c_bslash. " No directory path given

MESSAGE w398 WITH 'File will be created in home directory'(034).

ENDIF.

ENDIF.

IF p_fname0(1) = c_fslash AND p_fname1 = space.

MESSAGE e398 WITH 'File name should not contain only /'(035).

ENDIF.

ENDFORM. " validate_filename

&----


*& Form upload_pre_file

&----


FORM upload_pre_file.

v_file = p_fname.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = v_file

filetype = 'ASC'

has_field_separator = 'X'

dat_mode = ' '

TABLES

data_tab = i_indata

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 e398 WITH 'Unable to upload the file'(002).

ENDIF.

ENDFORM. " upload_pre_file

&----


*& Form upload_unix_file

&----


FORM upload_unix_file .

open dataset p_fname for input in text mode encoding default.

if sy-subrc <> 0.

message i398 with 'File open error(012)'(012) p_fname.

stop.

else.

do.

clear: v_string.

read dataset p_fname into v_string.

case sy-subrc.

when 0.

split v_string at c_del

into i_indata-t_glacnt

i_indata-t_descrip

i_indata-t_damt

i_indata-t_ccenter.

append i_indata.

clear i_indata.

when 4.

exit.

when 8.

message i398 with 'Unable to Read the File'(008) p_fname.

stop.

endcase.

enddo.

close dataset p_fname.

endif.

ENDFORM. " upload_unix_file

&----


*& Form post_data

&----


FORM post_data .

V_DOCHEADER-BUS_ACT = 'RFBU'.

*V_DOCHEADER-OBJ_TYPE = 'BKPF'.

*V_DOCHEADER-OBJ_KEY = '$'.

V_DOCHEADER-USERNAME = 'VSAWANT'.

V_DOCHEADER-COMP_CODE = 'BP01'.

V_DOCHEADER-DOC_DATE = SY-DATUM.

V_DOCHEADER-PSTNG_DATE = SY-DATUM.

*V_DOCHEADER-FIC_PERIOD = '00'.

V_DOCHEADER-HEADER_TXT = 'Amex Card Upload'.

V_DOCHEADER-DOC_TYPE = 'SA'.

CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'

EXPORTING

DOCUMENTHEADER = V_DOCHEADER

  • CUSTOMERCPD =

  • CONTRACTHEADER =

  • IMPORTING

  • OBJ_TYPE = V_DOCHEADER-OBJ_TYPE

  • OBJ_KEY = V_DOCHEADER-OBJ_KEY

  • OBJ_SYS = V_DOCHEADER-OBJ_SYS

TABLES

ACCOUNTGL = i_acgl

  • ACCOUNTRECEIVABLE =

  • ACCOUNTPAYABLE =

  • ACCOUNTTAX =

CURRENCYAMOUNT = i_currency

  • CRITERIA =

  • VALUEFIELD =

  • EXTENSION1 =

RETURN = i_return.

  • PAYMENTCARD =

  • CONTRACTITEM =

  • EXTENSION2 =

  • REALESTATE = .

refresh i_acgl.

refresh i_currency.

clear i_acgl.

clear i_currency.

  • if V_DOCHEADER is initial.

i_error[] = i_indata[] .

read table i_return index 1.

i_error-message = i_return-message.

append i_error.

clear i_error.

  • else.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

wait up to 3 seconds.

  • endif.

ENDFORM. " post_data

&----


*& Form populate_debit

&----


FORM populate_debit .

DATA: l_debamt(16) type c.

clear: v_index,

l_debamt.

loop at i_indata from 2.

  • v_ddeb = i_indata-t_damt.

v_dcre = v_dcre + i_indata-t_damt.

v_index = v_index + 1.

i_acgl-ITEMNO_ACC = v_index.

i_acgl-GL_ACCOUNT = i_indata-t_glacnt.

i_acgl-ITEM_TEXT = i_indata-t_descrip.

i_acgl-DOC_TYPE = 'SA'.

i_acgl-COMP_CODE = 'BP01'.

i_acgl-COSTCENTER = i_indata-t_ccenter.

i_acgl-DE_CRE_IND = 'S'.

append i_acgl.

clear i_acgl.

  • write v_ddeb to l_debamt currency 'USD'.

i_currency-ITEMNO_ACC = v_index.

i_currency-CURRENCY = 'USD'.

i_currency-AMT_DOCCUR = i_indata-t_damt.

append i_currency.

clear i_currency.

  • clear: v_ddeb.

endloop.

ENDFORM. " populate_debit

&----


*& Form populate_credit

&----


FORM populate_credit .

DATA: l_creamt(16) type c.

clear: l_creamt.

v_index = v_index + 1.

i_acgl-ITEMNO_ACC = v_index.

i_acgl-GL_ACCOUNT = c_creacnt.

  • i_acgl-ITEM_TEXT = .

i_acgl-DOC_TYPE = 'SA'.

i_acgl-COMP_CODE = 'BP01'.

i_acgl-DE_CRE_IND = 'H'.

append i_acgl.

clear: i_acgl.

  • write v_dcre to l_creamt currency 'USD'.

i_currency-ITEMNO_ACC = v_index.

i_currency-CURRENCY = 'USD'.

i_currency-AMT_DOCCUR = v_dcre.

append i_currency.

clear: i_currency.

clear: v_index.

ENDFORM. " populate_credit

&----


*& Form generate_error_report

&----


FORM generate_error_report .

data: credit(16) type c.

WRITE :/1 'Title: Corporate Card Upload'(006),

/ 'Program:'(007), sy-repid,

/ 'Date:'(008), SY-DATUM.

skip 1.

uline:/(200).

format color col_heading on.

write:/(1) sy-vline,

(8) 'Posting Date'(020),

(1) sy-vline,

(12) 'GL Account'(021),

(1) sy-vline,

(17) 'Description'(022),

(1) sy-vline,

(17) 'Dollar Amount'(023),

(1) sy-vline,

(17) 'Cost Center'(024),

(1) sy-vline,

(100) 'Error/Success Message'(028),

(1) sy-vline.

uline:/(200).

format color off.

write:/(1) sy-vline,

(8) sy-datum,

(1) sy-vline,

(12) '113000',

(1) sy-vline,

(17) 'Clearing Account',

(1) sy-vline,

(17) v_dcre,

(1) sy-vline,

(100) i_error-message,

(1) sy-vline.

uline:/(200).

loop at i_error from 2.

write:/(1) sy-vline,

(8) sy-datum,

(1) sy-vline,

(12) i_error-t_glacnt,

(1) sy-vline,

(17) i_error-t_descrip,

(1) sy-vline,

(17) i_error-t_damt,

(1) sy-vline,

(17) i_error-t_ccenter,

(1) sy-vline,

(100) i_error-message,

(1) sy-vline.

endloop.

uline:/(200).

clear: v_dcre.

0 Kudos

Change this:

CONSTANTS: c_creacnt TYPE string VALUE '111444', " Liability account

to

CONSTANTS: c_creacnt TYPE string VALUE '0000111444', " Liability account

You need the zeros in front. Make sure it is like this for all data you put into i_acgl-GL_ACCOUNT

0 Kudos

Hi Aaron,

Appreciate your help. I changed the same in the Internal table, and the hard coded GL Account. I am still gettting the error -

507G/L account 111444 is not defined in chart of accounts 0010.

Thanks, Nina.

0 Kudos

When displaying GL Account 111444 in SKA1, is the value of KTOPL = 0010?

0 Kudos

Hi Aaron,

I tried your suggestion of adding zeros in the beginning 0000111444 and that error is gone. I am now getting an error with Balance in Transaction Currency, so I think it is a problem wih the sign in the debits and credits. Did you experience this problem before?

Thankd, Nina.

0 Kudos

When filling the currency table, I fill these two amount fields:

wa_curramount-amt_doccur = '-5000.00'. " Amount (Always Negative)

wa_curramount-amt_base = '5000.00'. " Base Amount (Always Positive)

Try that.

Former Member
0 Kudos

Hi Aaron,

I checked the return table, I am getting 'G/L account 113020 is not defined in char'

Any suggestions?

Thanks, Nina.

Former Member
0 Kudos

Hi Nina,

You have declared this as string,

<b> CONSTANTS: c_creacnt TYPE string VALUE '111444', " Liability account</b>

Try to declare this c_creacnt as the type that you find in the FB50 transaction.

i.e. <b>CONSTANTS: c_creacnt TYPE <Field or Data element> VALUE '111444'.</b>

That could help.

Regards

Kathirvel