‎2007 Oct 11 9:46 PM
Hi gurus,
I have created the below program to create accounting document using F-43 and for this I have used BAPI_ACCOUNT_POST,
data: begin of it_input_file occurs 0,
pos_date(10),
doc_type(2),
pos_per(2),
bukrs(4),
currency(3),
doc_date(10),
pos_key(2),
glaccount(10),
amount(16),
uname(20),
seq_num(5) type n,
fis_year(4),
end of it_input_file.
data: documentheader type BAPIACHE09,
obj_type type BAPIACHE09-OBJ_TYPE,
obj_key type BAPIACHE09-OBJ_KEY,
obj_sys type BAPIACHE09-OBJ_SYS,
accountgl like BAPIACGL09 occurs 0 with header line,
ACCOUNTPAYABLE like BAPIACAP09 occurs 0 with header line,
currencyamount like BAPIACCR09 occurs 0 with header line,
return like BAPIRET2 occurs 0 with header line,
return2 type BAPIRET2.
data: v_semfile like RLGRAP-FILENAME.
selection-screen begin of block b1 with frame title text-001.
parameters: p_ifname like rlgrap-filename obligatory,
p_numrec(3) type n default 899.
selection-screen end of block b1.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_ifname.
CALL FUNCTION 'F4_FILENAME' "allows user to select path/file
EXPORTING
program_name = 'ZFI_POST'
dynpro_number = syst-dynnr
field_name = 'p_ifname'
IMPORTING
file_name = p_ifname.
perform open_files.
perform load_data.
&----
*& Form open_files
&----
text
----
--> p1 text
<-- p2 text
----
FORM open_files .
v_semfile = p_ifname.
refresh it_input_file.
call function 'WS_UPLOAD'
EXPORTING
filename = v_semfile
filetype = 'DAT'
TABLES
data_tab = it_input_file
EXCEPTIONS
conversion_error = 1
file_open_error = 2
file_read_error = 3
invalid_type = 4
no_batch = 5
unknown_error = 6
invalid_table_width = 7
gui_refuse_filetransfer = 8
customer_error = 9
others = 10.
ENDFORM. " open_files
&----
*& Form load_data
&----
text
----
--> p1 text
<-- p2 text
----
FORM load_data .
loop at it_input_file.
move:
it_input_file-doc_date to documentheader-doc_date,
it_input_file-pos_date to documentheader-pstng_date,
it_input_file-doc_type to documentheader-doc_type,
it_input_file-bukrs to documentheader-comp_code,
it_input_file-pos_per to documentheader-fis_period,
it_input_file-fis_year to documentheader-fisc_year,
it_input_file-uname to documentheader-USERNAME.
move: it_input_file-glaccount to ACCOUNTGL-VENDOR_NO.
move: it_input_file-pos_key to ACCOUNTGL-ACCT_KEY.
move: it_input_file-amount to ACCOUNTPAYABLE-PYMT_AMT.
move: it_input_file-currency to currencyamount-CURRENCY,
it_input_file-amount to currencyamount-AMT_DOCCUR .
CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
EXPORTING
DOCUMENTHEADER = documentheader
IMPORTING
OBJ_TYPE = obj_type
OBJ_KEY = obj_key
OBJ_SYS = obj_sys
TABLES
ACCOUNTGL = accountgl
ACCOUNTPAYABLE = ACCOUNTPAYABLE
CURRENCYAMOUNT = currencyamount
RETURN = return.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT =
IMPORTING
RETURN = return2.
endloop.
ENDFORM. " load_data
My input file looks like this:
11102007 KR 6 1000 USD 11102007 31 A1 1000 test
and when I tried to run this program in debug mode, the Return statement returns the following values:
E |RW |609 |Error in document: BKPFF $ DE1CLNT150
E |RW <015FI/CO interface: Inconsistent FI/CO document header data for updating.
can you please help me how to get this thing resolve.
Thanks
Rajeev Gupta
‎2007 Oct 11 9:56 PM
Uploading a file and using those entries adds unneeded complexity for testing. You don't know whether the error is in your file, the internal table ot the BAPI call.
Try hardcoding the values you think should be there into the BAPI call. This will give you some idea of where the problem lies.
Rob
‎2007 Oct 11 9:58 PM
thanks for the reply Rob, can you please help me out by giving me an example for F-43 using BAPI_ACCOUNT_POST, I will really appreciate your time and efforts.
Thanks
Rajeev Gupta
‎2007 Oct 11 10:00 PM
‎2007 Oct 11 10:03 PM
So basically you want to hard code the values and then try running the program.
Ok I will do so .
Thanks
‎2007 Oct 11 10:09 PM
Yes - that's what I would do. When you have a problem, before you can solve it, you have to identify where the problem is. If you hardcode your values and still get the error, the problem is in the BAPI call, if you get no error (or a different one), the problem is in the file or internal table. It's a process of elimination, but easier than trying to do it all at once.
Rob
‎2007 Oct 11 10:14 PM
Hey thanks again for the reply....I have modified my code a lil bit :
loop at it_input_file.
move: '10112007' to documentheader-doc_date,
'10112007' to documentheader-pstng_date,
'KR' to documentheader-doc_type,
'1000' to documentheader-comp_code,
'6' to documentheader-fis_period,
'TEST' to documentheader-USERNAME.
move: 'V1' to ACCOUNTGL-VENDOR_NO.
move: '31' to ACCOUNTGL-ACCT_KEY.
move: 'USD' to currencyamount-CURRENCY,
'1000' to currencyamount-AMT_DOCCUR .
endloop.
Now I have a small question to offset the above entry I need to pass an entry with posting key '21', can you please tell me how to take care of that.
Thanks
Rajeev Gupta
‎2007 Oct 11 10:23 PM
You have to fill the accountgl structure, but before doing that, has your error disappeared?
Rob
‎2007 Oct 11 10:28 PM
Not yet.... I have modified my code like this:
data: begin of it_input_file occurs 0,
pos_date(10),
doc_type(2),
pos_per(2),
bukrs(4),
currency(3),
doc_date(10),
pos_key(2),
glaccount(10),
amount(16),
uname(20),
seq_num(5) type n,
fis_year(4),
end of it_input_file.
data: documentheader type BAPIACHE09,
obj_type type BAPIACHE09-OBJ_TYPE,
obj_key type BAPIACHE09-OBJ_KEY,
obj_sys type BAPIACHE09-OBJ_SYS,
accountgl like BAPIACGL09 occurs 0 with header line,
ACCOUNTPAYABLE like BAPIACAP09 occurs 0 with header line,
currencyamount like BAPIACCR09 occurs 0 with header line,
return like BAPIRET2 occurs 0 with header line,
return2 type BAPIRET2.
perform load_data.
move: '10112007' to documentheader-doc_date,
'10112007' to documentheader-pstng_date,
'KR' to documentheader-doc_type,
'1000' to documentheader-comp_code,
'6' to documentheader-fis_period,
'TEST' to documentheader-USERNAME.
move: 'V1' to ACCOUNTGL-VENDOR_NO.
move: '21' to ACCOUNTGL-ACCT_KEY.
move: 'USD' to currencyamount-CURRENCY,
'1000' to currencyamount-AMT_DOCCUR .
CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
EXPORTING
DOCUMENTHEADER = documentheader
IMPORTING
OBJ_TYPE = obj_type
OBJ_KEY = obj_key
OBJ_SYS = obj_sys
TABLES
ACCOUNTGL = accountgl
ACCOUNTPAYABLE = ACCOUNTPAYABLE
CURRENCYAMOUNT = currencyamount
RETURN = return.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT =
IMPORTING
RETURN = return2.
But I am getting the same set of errors:
Error in document: BKPFF $ CLNT150
FI/CO interface: Inconsistent FI/CO document header data for updating
‎2007 Oct 11 10:35 PM
So it looks like the problem is with this bit of code:
move: '10112007' to documentheader-doc_date,
'10112007' to documentheader-pstng_date,
'KR' to documentheader-doc_type,
'1000' to documentheader-comp_code,
'6' to documentheader-fis_period,
'TEST' to documentheader-USERNAME.
move: 'V1' to ACCOUNTGL-VENDOR_NO.
move: '21' to ACCOUNTGL-ACCT_KEY.
move: 'USD' to currencyamount-CURRENCY,
'1000' to currencyamount-AMT_DOCCUR .
Try moving sy-datum to the posting date and sy-uname to the username.
Rob
‎2007 Oct 11 10:40 PM
I tried doing that but I got the same error message........I am kind of stuck and I need to submit this thing tomorrow ...:(
‎2007 Oct 11 10:41 PM
OK - I think I see the problem. You are not supplying documentheader-bus_act. You should check the documentation for the BAPI to see what you should be using.
Maybe 'RFBU'.
Rob
Message was edited by:
Rob Burbank
‎2007 Oct 11 10:51 PM
Sorry to tell you BOB, problem is still unresolved.
Thanks
Rajeev Gupta
‎2007 Oct 11 10:55 PM
There may be other messages in the return structure. Make sure you look at and address them all.
Rob
‎2007 Oct 11 10:58 PM
there were only these messages, but I have one more concern while I was looking into table 'ACCOUNTPAYABLE', although I passed the vendor no. i.e. B1 but I couldn't see anything when I checked it in the debugging mode.
Thanks
Rajeev Gupta