07-19-2005 5:08 PM
Hello,
I am trying to create a bapi, using the following example. http://www.sapgenie.com/abap/bapi/example.htm#step2
In the step2, source code attribute, I dont understand, how to write the " Include LZBAPIStatusu02.........".
can somebody please suggest me the steps to create that code. Thanks in advance.
regards,
Raj.
07-19-2005 5:15 PM
That line of code should have been generated for you in the LZBAPISTATUSUXX include program. The LZBAPIStatusu02 include program is the include program which stores the main line source code of your function module/BAPI. This is where your business logic is coded. Do you know what your business logic is?
In this example, the business logic is everything here.
DATA:
l_aufnr LIKE afko-aufnr,
l_objnr LIKE jest-objnr.
********************************************
* Check if order exists
********************************************
SELECT SINGLE aufnr
FROM afko
INTO l_aufnr
WHERE aufnr = BAPI_ORDER_STATUS_IMPORT-orderid.
IF sy-subrc NE 0.
CLEAR message.
message-msgty = 'E'.
message-msgid = 'Z3'.
message-msgno = '000'.
message-msgv1 = BAPI_ORDER_STATUS_IMPORT-orderid.
PERFORM set_return_message USING message
CHANGING return.
IF 1 = 2.
* The only reason to include this statement, that will obviously
* never execute, is that it will create a referecence so that you
* can find out where a particular message is being used. This
* functionality is used by the BAPIs programmed by SAP
MESSAGE e000(z3).
ENDIF.
ENDIF.
CHECK return IS INITIAL.
********************************************
* Read order status
********************************************
CONCATENATE 'OR' BAPI_ORDER_STATUS_IMPORT-orderid INTO l_objnr.
IF BAPI_ORDER_STATUS_IMPORT-i_excludeinactive = 'X'.
SELECT objnr stat inact
FROM jest
INTO TABLE t_bapistat
WHERE objnr = l_objnr AND
inact <> 'X'.
ELSE.
SELECT objnr stat inact
FROM jest
INTO TABLE t_bapistat
WHERE objnr = l_objnr.
ENDIF.
IF sy-subrc <> 0.
* No object status found
CLEAR message.
message-msgty = 'E'.
message-msgid = 'Z3'.
message-msgno = '001'.
message-msgv1 = BAPI_ORDER_STATUS_IMPORT-orderid.
PERFORM set_return_message USING message
CHANGING return.
IF 1 = 2.
MESSAGE e001(z3).
ENDIF.
ENDIF.
CHECK return IS INITIAL.
********************************************
* Read order status texts
********************************************
SELECT istat txt04 txt30
FROM tj02t
INTO TABLE t_tj02t
FOR ALL ENTRIES IN t_bapistat
WHERE istat = t_bapistat-stat AND
spras = BAPI_ORDER_STATUS_IMPORT-i_spras.
SORT t_tj02t BY istat.
LOOP AT t_bapistat INTO g_bapistat.
READ TABLE t_tj02t
WITH KEY istat = g_bapistat-stat BINARY SEARCH
INTO g_tj02t.
IF sy-subrc = 0.
MOVE:
g_tj02t-txt04 TO g_bapistat-txt04,
g_tj02t-txt30 TO g_bapistat-txt30.
MODIFY t_bapistat FROM g_bapistat TRANSPORTING txt04 txt30.
ENDIF.
ENDLOOP.
In SE80, just double click the function module name, click source code tab, what you see here is really the include in question. Put the code there.
Regards,
Rich Heilman
07-19-2005 5:50 PM
07-20-2005 9:08 PM