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: 

How to use Bapi

Former Member
0 Kudos

Hi

How to use bapis

BAPI_COMPANYCODE_GET_PERIOD

BAPI_CCODE_GET_FIRSTDAY_PERIOD'

BAPI_GL_ACC_GETPERIODBALANCES'

2 REPLIES 2

Former Member
0 Kudos

BAPI_COMPANYCODE_GET_PERIOD:

To retrieve the fiscal year variant for a given date u can use the following function module

Retrieve fiscal year and period

The below code shows how to use function modules BAPI_COMPANYCODE_GET_PERIOD and

DETERMINE_PERIOD to retrieve fiscal year and fiscal period for a specific date.

*.......................................................................

*: Report: ZFISCALYR :

*: :

*: Author: www.SAPdev.co.uk :

*: :

*: Date : 2004 :

*: :

*: Description: Demonstrates how to return the corresponding fiscal :

*: year and posting period for a company code and posting :

*: date or posting date and fiscal year variant. :

*:.....................................................................:

REPORT zfiscalyr NO STANDARD PAGE HEADING.

TABLES: ekko.

PARAMETERS: p_bukrs TYPE ekko-bukrs,

p_bedat TYPE ekko-bedat.

DATA: gd_fiscalyr TYPE bapi0002_4-fiscal_year,

gd_fiscalp TYPE bapi0002_4-fiscal_period.

DATA: gd_fiscalyr2 TYPE T009B-BDATJ,

gd_fiscalp2 TYPE bapi0002_4-fiscal_period.

DATA: gd_periv TYPE t009-periv.

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

*START-OF-SELECTION.

START-OF-SELECTION.

  • get fiscal year and period - (requires date and company code)

CALL FUNCTION 'BAPI_COMPANYCODE_GET_PERIOD'

EXPORTING

companycodeid = p_bukrs

posting_date = p_bedat

IMPORTING

fiscal_year = gd_fiscalyr

fiscal_period = gd_fiscalp.

  • Alternative fiscal year function module

  • - (requires date and fiscal year variant code from T009 table)

*----


  • gets first entry in fiscal year variant table (will need to choose

  • correct one from table rather than just using first entry)

SELECT SINGLE periv

FROM t009

INTO gd_periv.

  • get fiscal year and period

CALL FUNCTION 'DETERMINE_PERIOD'

EXPORTING

date = p_bedat

  • PERIOD_IN = '000'

version = gd_periv

IMPORTING

period = gd_fiscalp2

year = gd_fiscalyr2

EXCEPTIONS

period_in_not_valid = 1

period_not_assigned = 2

version_undefined = 3

OTHERS = 4.************************************************************************

*END-OF-SELECTION.

END-OF-SELECTION.

WRITE:/ 'From function module: BAPI_COMPANYCODE_GET_PERIOD',

/ 'Fiscal year is:', gd_fiscalyr,

/ 'Fiscal period is:', gd_fiscalp.

SKIP.

WRITE:/ 'From function module: DETERMINE_PERIOD',

/ 'Fiscal year is:', gd_fiscalyr2,

/ 'Fiscal period is:', gd_fiscalp2.

BAPI_CCODE_GET_FIRSTDAY_PERIOD:

CALL FUNCTION 'BAPI_CCODE_GET_FIRSTDAY_PERIOD'

EXPORTING

companycodeid = v_bukrs

fiscal_period = marv-lfmon

fiscal_year = marv-lfgja

IMPORTING

first_day_of_period = v_postdate

return = i_return1.

BAPI_GL_ACC_GETPERIODBALANCES:

Please give me reward point...

Former Member
0 Kudos

Hi

<b>BAPI_COMPANYCODE_GET_PERIOD</b> For Company Code: Posting Date -> Period, Fiscal Year

<b>Functionality</b>

This method returns the corresponding fiscal year and posting period to a company code and posting date.

<b>Parameters</b>

COMPANYCODEID

POSTING_DATE

FISCAL_YEAR

FISCAL_PERIOD

RETURN

<b>BAPI_CCODE_GET_FIRSTDAY_PERIOD</b> For Company Code: First Day of Period

<b>Functionality</b>

For a company code, a fiscal year, and a period, this method returns the first day of the period as a complete date.

<b>Parameters</b>

COMPANYCODEID

FISCAL_PERIOD

FISCAL_YEAR

FIRST_DAY_OF_PERIOD

RETURN

<b>BAPI_GL_ACC_GETPERIODBALANCES</b> Posting period balances for each G/L account

Note!: The GetPeriodBalances method will no longer be supported. The functions will be replaced by the GetPeriodBalances method in object type BUS1028 of the general ledger.

If you have previously used this method, change the usage to that of the new method in object type BUS1028.

Use the method in object type BUS1028 the next time you use this function.

<b>Functionality</b>

This method returns the G/L account balances per posting period for a given fiscal year.

The user can choose whether a balance is returned in the transaction or company code currency except for G/L accounts managed in different transaction currencies. Only the company code currency is returned for such accounts.

The balance as determined by the system and the currency are returned with any problems appearing in the form of a return code.

<b>Notes</b>

The same authorization checks are carried out as take place when displaying information within an R/3 transaction.

The system does not convert the input parameter COMPANYCODE, meaning that leading blank characters within this parameter are not cleared. Likewise, no conversion is carried out for the parameter GLACCT. G/L account numbers must therefore be entered with the leading zeros (e.g. 0000113100).

Messages are displayed in the RETURN parameter the documentation for which contains the return values and their meaning.

<b>Parameters</b>

COMPANYCODE

GLACCT

FISCALYEAR

CURRENCYTYPE

BALANCE_CARRIED_FORWARD

RETURN

ACCOUNT_BALANCES

<b>Reward if usefull</b>