In my last blog, Creation of Custom Extractors , I explained how to create a custom extractor using database table or view. But sometimes requirement are such that we need some custom fields also along with the database fields.
In this blog, I will explain how we can extend the extractor DataSource to include custom fields and how to fill those custom fields.
To explain this, I am taking the example of one of the datasource I extended to include some custom fields as per requirement.The Data Extractor “ZBW_PG_VENDOR_ATTR_LFA1_AUST” is created to fetch the data from a database view for table LFA1 as shown below.
(To check how to create one, click here).
ZPG_LFA1_AUST_V is the view created for LFA1 table.
We have added the fields we want, to the extractor , but now the question is where the data will come from in these fields.
To fill the extended datsource fields, SAP has provided an EXIT “EXIT_SAPLRSAP_002”. We can write out logic inside this exist to fill the custom fields.
Import parameter “i_datasource” of this exit holds the datasource name and table “I_T_DATA” holds all the data fetched from the database view or table. At this point, the custom fields will be empty in this table.
We need to fill the custom fields inside this exit and modify the I_T_DATA table as shown below.
Just one thing to note here is that, this exit is called for all the DataSources. So, our logic to fill in the fields should be executed only on our DataSource call as shown below.
So, this is how we can extend the datasource structure to include the custom fields and fill them as per our need.
I hope you will like this blog.