Example for Filling the ExtensionIn Parameter



* *

* Example to show how to fill the EXTENSION_IN Structure in a BAPI *

* which uses table extension as possibility for a customer to extend *

* SAP functionality without modification. *

* *

* In this example we use the BAPI *


* *


data x_agencynumber type bapisadeta-agencynum.

data x_agencydata_in type bapisadtin.

data x_cus_data_in type travelag.

data begin of x_extensionin occurs 0.

include structure bapiparex.

data end of x_extensionin.

data begin of x_return occurs 0.

include structure bapiret2.

data end of x_return.

data x_bapi_te_sa type bapi_te_sa.

* only for this example we hardcode the data, normally you would

* write an own transaction to fill this fields.

x_agencydata_in-name = 'Galactic Travel Agency'.

x_agencydata_in-street = 'Lunatic'.

x_agencydata_in-postbox = '123456'.

x_agencydata_in-postcode = '984735'.

x_agencydata_in-city = 'Luna 1'.

x_agencydata_in-country = 'Moon'.

x_agencydata_in-region = 'Moon'.

x_agencydata_in-telephone = '30457584375374957'.

x_agencydata_in-url = 'http://lunatic.com'.

x_agencydata_in-langu = 'E'.

x_cus_data_in-planetype = 'Space Shuttle'.

x_cus_data_in-company = 'Moon Shuttle Service'.

x_cus_data_in-seatsmax = 24.

* now fill the key of the extension parameter

move 'BAPI_TE_SA' to x_extensionin-structure.

* now normally you fill the object key into the BAPI_TE_SA structure

* but in this case the create will give internal the key for the new

* travel agency, so here only a clear

clear x_bapi_te_sa-agencynum.

* but the other fields we have, so fill

move-corresponding x_cus_data_in to x_bapi_te_sa.

* fill the fields in the data part of x_extension in, take care that

* you have 960 bytes in pieces of 240 byte. Luckily we have less than

* 240 byte so we need only one move.

move x_bapi_te_sa to x_extensionin-valuepart1.

append x_extensionin.



AGENCYDATA_IN = x_agencydata_in


AGENCYNUMBER = x_agencynumber


EXTENSIONIN = x_extensionin

RETURN = x_return.



write : / 'Return messages in handling the bapi.'.

loop at x_return.

write : / 'return..:', x_return.


write : / 'The new travel agency has the number...:', x_agencynumber.