‎2006 Aug 16 6:32 AM
Hi,
Can any one tell me how we will do BADI's.If possible explain with a example.
points will be given.
Regards,
Amit Teja V
Message was edited by: amit teja
‎2006 Aug 16 6:33 AM
BAPI's are nothing function modules, so from ABAP you just make a call to the function.
Here is a example
http://www.sap-img.com/abap/bapi-goodsmvt-create-to-post-goods-movement.htm
Regards,
Ravi
Note : Please mark the helpful answers
‎2006 Aug 16 6:34 AM
‎2006 Aug 16 6:36 AM
‎2006 Aug 16 6:42 AM
Hi Amit,
BAPIs are just function modules with the exception that it can be called from other non sap systems. For example, in our company we have a billing system that calls a certain BAPI to get the required data and after that it processes it then it will generate a text file which we use to upload using BDC. You can also use BAPIs the same way you use function modules. Take a look at the example below:
DO lv_counter TIMES.
CALL METHOD me->conversion EXPORTING
year = <fs_asof>
rate_type = t_rate_type
from_curr = t_from_curr
to_curr = t_to_curr
IMPORTING
exch_rate = t_exch_rate.
wa_exch-year = <fs_asof>.
wa_exch-rate = t_rate_type.
wa_exch-from_curr = t_from_curr.
wa_exch-exch_rate = t_exch_rate-exch_rate_v.
INSERT wa_exch INTO TABLE it_exch.
CLEAR wa_exch.
IF sy-index = 1.
WRITE: (15) t_exch_rate-exch_rate_v LEFT-JUSTIFIED.
ELSEIF sy-index = 4 OR sy-index = 5 OR sy-index = 6.
ADD 1 TO lv_pos.
WRITE: AT lv_pos(15) t_exch_rate-exch_rate_v CENTERED.
ELSE.
WRITE: AT lv_pos(15) t_exch_rate-exch_rate_v CENTERED.
ENDIF.
CLEAR t_exch_rate-exch_rate_v.
SUBTRACT 1 FROM <fs_asof>.
ADD 20 TO lv_pos.
ENDDO.
METHOD conversion.
CALL FUNCTION 'HR_E_GET_FISC_YEAR_DATES'
EXPORTING
fisc_year = year
IMPORTING
FISC_FECINI =
fisc_fecfin = lv_date
EXCEPTIONS
ERROR = 1
OTHERS = 2
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
t_date = lv_date.
CALL FUNCTION 'BAPI_EXCHANGERATE_GETDETAIL'
EXPORTING
rate_type = rate_type
from_curr = from_curr
to_currncy = to_curr
date = t_date
IMPORTING
exch_rate = t_exch_rate
RETURN =
.
ENDMETHOD.
*In the example above, it calls the BAPI to get the exchange rate for a given currency and year.
Hope this helps...
P.S. Please award points for useful answers.
‎2006 Aug 16 6:57 AM
‎2006 Aug 16 8:08 AM