‎2006 Dec 14 5:41 AM
Hello All,
I'm using this BAPI to post accounting docs. I want to catch all errors the first time ie. if within a single doc the GL line item has incorrect GL a/c and AP line item has incorrect vendor no., the return table should fill both these errors with appropriate texts & values. At the moment I can get this BAPI only to fill one error at a time ie. in above scenario it will only report the incorrect GL a/c the first time....when this is corrected it will then report incorrect vendor a/c and so on...
Any idea how to get this BAPI to report all errors in the document that its trying to post the first time its called?
Cheers.
‎2006 Dec 14 7:04 AM
Hi Bondi,
Please check this program.
&----
*& Report ZASSET_CREATE
*&
&----
*&
*&
&----
REPORT zasset_create.
DATA:
input parameters to the bapi
input_key LIKE bapi1022_key,
gen_data LIKE bapi1022_feglg001,
gen_datax LIKE bapi1022_feglg001x,
posting_info LIKE bapi1022_feglg002,
posting_infox LIKE bapi1022_feglg002x,
posting_data LIKE bapifapo_gen_info,
acquis_data LIKE bapifapo_acq,
time_dep_data LIKE bapi1022_feglg003,
time_dep_datax LIKE bapi1022_feglg003x,
real_estate LIKE bapi1022_feglg007,
real_estatex LIKE bapi1022_feglg007x,
allocations LIKE bapi1022_feglg004,
allocationsx LIKE bapi1022_feglg004x,
extensionin TYPE TABLE OF bapiparex,
origindata LIKE bapi1022_feglg009,
origindatax LIKE bapi1022_feglg009x,
it_depreciationareas TYPE TABLE OF bapi1022_dep_areas,
wa_depreciationareas TYPE bapi1022_dep_areas,
occurs 0 with header line,
it_depreciationareasx TYPE TABLE OF bapi1022_dep_areasx,
wa_depreciationareasx TYPE bapi1022_dep_areasx,
occurs 0 with header line,
it_investment_support TYPE TABLE OF bapi1022_inv_support,
occurs 0 with header line,
output parameters from the bapi
asset_number LIKE bapi1022_1-assetmaino,
sub_number LIKE bapi1022_1-assetsubno,
out_return LIKE bapiret2,
out_return2 LIKE bapiret2.
input_key-companycode = 'CAT1'.
gen_data-assetclass = '00003000'.
gen_datax-assetclass = 'X'.
gen_data-descript = 'Testing BAPI'.
gen_datax-descript = 'X'.
gen_data-serial_no = '1111'.
gen_datax-serial_no = 'X'.
gen_data-base_uom = 'KG'.
gen_datax-base_uom = 'X'.
*Append the Depreciation keY VALUE EQUAL TO LINA to the internal table.
wa_depreciationareas-area = '01'.
wa_depreciationareas-descript = 'Book deprec.'.
wa_depreciationareas-dep_key = 'LINA'.
wa_depreciationareas-ulife_yrs = '2'.
wa_depreciationareas-ulife_prds = '3'.
wa_depreciationareas-exp_ulife_yrs = '5'.
wa_depreciationareas-exp_ulife_prds = '3'.
*wa_depreciationareas-EXP_ULIFE_SDEP_YRS
*wa_depreciationareas-EXP_ULIFE_SDEP_PRDS
*wa_depreciationareas-ORIG_ULIFE_YRS
*wa_depreciationareas-ORIG_ULIFE_PRDS
wa_depreciationareas-change_yr = '3'.
*wa_depreciationareas-dep_units = '3'.
*wa_depreciationareas-odep_start_date = '01012005'.
*wa_depreciationareas-sdep_start_date = '01012005'.
*wa_depreciationareas-INTEREST_START_DATE
*wa_depreciationareas-READINESS
*wa_depreciationareas-INDEX
wa_depreciationareas-AGE_INDEX
wa_depreciationareas-var_dep_portion = '200'.
wa_depreciationareas-scrapvalue = '20'.
*wa_depreciationareas-currency = 'USD'.
*wa_depreciationareas-currency_iso = 'USD'.
*wa_depreciationareas-NEG_VALUES
*wa_depreciationareas-GRP_ASSET
*wa_depreciationareas-GRP_ASSET_SUBNO
*wa_depreciationareas-ACQ_YR
*wa_depreciationareas-ACQ_PRD
*wa_depreciationareas-SCRAPVALUE_PRCTG
*
APPEND wa_depreciationareas TO it_depreciationareas.
CLEAR: wa_depreciationareas.
wa_depreciationareasx-area = '01'.
*wa_depreciationareasX-DESCRIPT = 'X'.
*wa_depreciationareasX-DEACTIVATE = 'X'.
wa_depreciationareasx-dep_key = 'X'.
wa_depreciationareasx-ulife_yrs = 'X'.
wa_depreciationareasx-ulife_prds = 'X'.
*wa_depreciationareasX-EXP_ULIFE_YRS = 'X'.
*wa_depreciationareasX-EXP_ULIFE_PRDS = 'X'.
*wa_depreciationareasX-EXP_ULIFE_SDEP_YRS = 'X'.
*wa_depreciationareasX-EXP_ULIFE_SDEP_PRDS = 'X'.
*wa_depreciationareasX-ORIG_ULIFE_YRS = 'X'.
*wa_depreciationareasX-ORIG_ULIFE_PRDS = 'X'.
wa_depreciationareasx-change_yr = 'X'.
*wa_depreciationareasx-dep_units = 'X'.
wa_depreciationareasx-odep_start_date = 'X'.
wa_depreciationareasx-sdep_start_date = 'X'.
*wa_depreciationareasX-INTEREST_START_DATE = 'X'.
*wa_depreciationareasX-READINESS = 'X'.
*wa_depreciationareasX-INDEX = 'X'.
*wa_depreciationareasX-AGE_INDEX = 'X'.
wa_depreciationareasx-var_dep_portion = 'X'.
wa_depreciationareasx-scrapvalue = 'X'.
*wa_depreciationareasx-currency = 'X'.
*wa_depreciationareasx-currency_iso = 'X'.
*wa_depreciationareasX-NEG_VALUES = 'X'.
*wa_depreciationareasX-GRP_ASSET = 'X'.
*wa_depreciationareasX-GRP_ASSET_SUBNO = 'X'.
*wa_depreciationareasX-ACQ_YR = 'X'.
*wa_depreciationareasX-ACQ_PRD = 'X'.
*wa_depreciationareasX-SCRAPVALUE_PRCTG = 'X'.
*
APPEND wa_depreciationareasx TO it_depreciationareasx.
CLEAR wa_depreciationareasx.
*Append the Depreciation keY VALUE EQUAL TO LINb to the internal table.
break mukherar.
CALL FUNCTION 'BAPI_FIXEDASSET_CREATE1'
EXPORTING
key = input_key
REFERENCE =
CREATESUBNUMBER =
POSTCAP =
CREATEGROUPASSET =
TESTRUN =
generaldata = gen_data
generaldatax = gen_datax
INVENTORY =
INVENTORYX =
POSTINGINFORMATION =
POSTINGINFORMATIONX =
TIMEDEPENDENTDATA =
TIMEDEPENDENTDATAX =
ALLOCATIONS =
ALLOCATIONSX =
ORIGIN =
ORIGINX =
INVESTACCTASSIGNMNT =
INVESTACCTASSIGNMNTX =
NETWORTHVALUATION =
NETWORTHVALUATIONX =
REALESTATE =
REALESTATEX =
INSURANCE =
INSURANCEX =
LEASING =
LEASINGX =
IMPORTING
COMPANYCODE = company_code
asset = asset_number
subnumber = sub_number
ASSETCREATED =
return = out_return
TABLES
depreciationareas = it_depreciationareas
depreciationareasx = it_depreciationareasx.
INVESTMENT_SUPPORT =
EXTENSIONIN =
.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT =
IMPORTING
RETURN =
.
WRITE: / 'Asset Number:',asset_number.
<b>Please allocate the points to me.</b>
‎2006 Dec 14 10:03 AM
Kiran,
Did you even read his question!??!!! What on earth Asset creation has to do with this issue?? <u><b>Please read before posting.</b></u>
bondi beach,
no, this is not possible with this BAPI till ECC6. It will produce one error at a time (unfortunately) and fill return table accordingly. It looks at the accounting document as a whole.
Regards.
‎2006 Dec 14 10:24 PM
Thanks, anyone else got any comments/suggestions about this 'problem'?
‎2006 Dec 15 12:03 AM
Hi,
the BAPI processed until error occurs and then stops processing because it makes no sense to continue.
If you want those erros to be reported, the only way will be to do the necessary analysis in the program bfore the BAPI is called. Then you are free to report alll errors found and if there is none you can still call the BAPI to find the next one.
Regards,
Clemens
‎2006 Dec 15 12:22 AM
Hi Bondi,
quick one before the cricket starts this arv, I have used this BAPI but analysed the most common errors and looped through BAPI_ACC_DOCUMENT_CHECK until correct or corrected. This was possible as I was using workflow for the update so I called a BO method to run BAPI_ACC_DOCUMENT_CHECK, and if any problems send to FI user, and if no errors then post.
Bit long winded but it has worked. You could take a similar approach by throwing the check BAPI in a do loop, moving your data to temp itabs, and model changes to the data in the temp itabs each loop while keeping the messages to return.
Have fun
Gareth
‎2006 Dec 15 2:21 AM
Hi Gareth,
Thanks for that. But the problem with this is how do I know which error is for the header and which ones for the line items? Also, this BAPI does not return the line number (row no.).
Cheers.