‎2012 May 24 7:32 AM
Hi Experts,
I am using following BAPI FM in my z program.
'BAPI_AP_ACC_GETBALANCEDITEMS' with a date range.
I need to fetch clear items for a particular vendor in (01.05.2012 to 24.05.2012). but this fm give me the all value of fiscal year 2009,2010,2011 & 2012.
even I run this fm by Tcode se37 with the same import export parameters. This is giving correct values.
Please Help.
Thanks in advance.
Dinesh
‎2012 May 24 7:39 AM
‎2012 May 24 7:44 AM
DATA : lineitems1 like BAPI3008_2 occurs 0.
DATA : lineitems2 like lineitems1 with header line.
DATA : return like bapireturn.
DATA : comp_code like BAPI3008_1-COMP_CODE.
DATA : vendor like BAPI3008_1-VENDOR.
DATA : date_from like BAPI3008-FROM_DATE.
DATA : date_to like BAPI3008-TO_DATE.
DATA : year(4) type c,
month(2) type c,
date(2) type c.
year = s_budat2-low+0(4).
month = s_budat2-low+4(2).
date = s_budat2-low+6(2).
concatenate date month year into date_from.
clear: year , month, date.
year = s_budat2-high+0(4).
month = s_budat2-high+4(2).
date = s_budat2-high+6(2).
concatenate date month year into date_to.
comp_code = s_bukrs.
*key_date = s_budat1.
loop at s_lifnr.
vendor = s_lifnr-low.
CALL FUNCTION 'BAPI_AP_ACC_GETBALANCEDITEMS' "Vendor Account Clearing Transactions in a given Period
EXPORTING
COMPANYCODE = COMP_CODE
VENDOR = VENDOR
DATE_FROM = DATE_FROM
DATE_TO = DATE_TO
IMPORTING
RETURN = RETURN
TABLES
LINEITEMS = LINEITEMS1
. " BAPI_AP_ACC_GETBALANCEDITEMS
APPEND LINES OF LINEITEMS1 TO LINEITEMS2.
endloop.
‎2012 May 24 7:56 AM
Hi, you can use the table BSAK to fetch the vendor clreared lines.
Infact the fm 'BAPI_AP_ACC_GETBALANCEDITEMS' also uses the table BSAK to fetch the cleared lines. Try to debug the function module to find what went wrong in your case.
‎2012 May 24 12:36 PM
Hi ,
Don't change the date fields and try using FM like below.
CALL FUNCTION 'BAPI_AP_ACC_GETBALANCEDITEMS' "Vendor Account Clearing Transactions in a given Period
EXPORTING
COMPANYCODE = COMP_CODE
VENDOR = VENDOR
DATE_FROM = s_budat2-low
DATE_TO = s_budat2-high
IMPORTING
RETURN = RETURN
TABLES
LINEITEMS = LINEITEMS1.
‎2012 May 24 12:45 PM
Instead of concatenating directly assign as below:
DATE_FROM = s_budat2-low
DATE_TO = s_budat2-high
‎2012 May 24 12:58 PM
No result found.
s_budat2-low = '20120501'
s_budat2-high = '20120523'
it will take it as DATE_FROM = 20.12.50
DATE_TO = 20.12.05
‎2012 May 24 6:09 PM
The correct format of the date is: YYYYMMDD otherwise you will have problems with FMs.
Please try the following:
date_from = s_budat2-low.
date_to = s_budat2-high.
CALL FUNCTION 'BAPI_AP_ACC_GETBALANCEDITEMS' "Vendor Account Clearing Transactions in a given Period
EXPORTING
COMPANYCODE = COMP_CODE
VENDOR = VENDOR
DATE_FROM = DATE_FROM
DATE_TO = DATE_TO
IMPORTING
RETURN = RETURN
TABLES
LINEITEMS = LINEITEMS1
. " BAPI_AP_ACC_GETBALANCEDITEMS
Sorry for my english, it's not my first language.
Thanks!
‎2012 May 25 4:57 AM
Hi Dinesh,
You don't need to concatenate and then pass date_from and date_to as these date are in sy-datum format and perfectly fine to pass directly the to_date and from_date .
date_from = s_budat2-low.
date_to = s_budat2-high.
CALL FUNCTION 'BAPI_AP_ACC_GETBALANCEDITEMS'
EXPORTING
COMPANYCODE = COMP_CODE
VENDOR = VENDOR
DATE_FROM = DATE_FROM
DATE_TO = DATE_TO
IMPORTING
RETURN = RETURN
TABLES
LINEITEMS = LINEITEMS1 .
Please try this & let us know .
Regards,
yukti