SAP FPM Reusable Wiring Model Architecture **Part 2**
In the previous I explained the basic architetcture of Wiring, you can refer it SAP FPM Reusable Wiring Model Architecture **Part 1**
For the reusable architecture we will create the following classes:
- Data Class
- Connector Class
- Wiring Model Class
Data Class
Let’s start by creating a simple data object class which holds the data on wire. Say YCL_FPM_WIRE_DATAHDLR.
Create following attributes:
Attribute
|
Level
|
Visibility
|
Typing
|
Type
|
MS_DATA
|
Instance Attribute
|
Private
|
Type Ref To
|
DATA
|
MS_LEAD_DATA
|
Instance Attribute
|
Private
|
Type Ref To
|
DATA
|
MT_TABLE
|
Instance Attribute
|
Private
|
Type Ref To
|
DATA
|
MO_OBJECT
|
Instance Attribute
|
Private
|
Type Ref To
|
OBJECT
|
Then create the getter setters for the above attributes.
Method
|
SET_SELETION
|
Level
|
Instance Method
|
Visibility
|
Public
|
Parameters
|
IV_DATA IMPORTING Type DATA
|
FIELD-SYMBOLS <FS_DATA> TYPE ANY.
CREATE DATA MS_DATA LIKE IV_DATA.
ASSIGN MS_DATA->* TO <FS_DATA>. <FS_DATA> = IV_DATA. |
Method
|
GET_SELETION
|
Level
|
Instance Method
|
Visibility
|
Public
|
Parameters
|
EV_DATA Exporting Type DATA
|
FIELD-SYMBOLS <FS_DATA> TYPE ANY.
CLEAR EV_DATA. ASSIGN MS_DATA->* TO <FS_DATA>. IF NOT <FS_DATA> IS ASSIGNED. RETURN. ENDIF. EV_DATA = <FS_DATA>. |
Method
|
SET_LEAD_SELETION
|
Level
|
Instance Method
|
Visibility
|
Public
|
Parameters
|
IV_LEAD_DATA Importing Type DATA
|
FIELD-SYMBOLS <FS_DATA> TYPE ANY.
CREATE DATA MS_LEAD_DATA LIKE IV_LEAD_DATA. ASSIGN MS_LEAD_DATA->* TO <FS_DATA>. <FS_DATA> = IV_LEAD_DATA. |
Method
|
GET_LEAD_SELECTION
|
Level
|
Instance Method
|
Visibility
|
Public
|
Parameters
|
EV_DATA Exporting Type DATA
|
FIELD-SYMBOLS <FS_DATA> TYPE ANY.
CLEAR EV_DATA. ASSIGN MS_LEAD_DATA->* TO <FS_DATA>. IF NOT <FS_DATA> IS ASSIGNED. RETURN. ENDIF. EV_DATA = <FS_DATA>. |
Method
|
SET_COLLECTION
|
Level
|
Instance Method
|
Visibility
|
Public
|
Parameters
|
IV_TABLE_DATA Importing Type DATA
|
FIELD-SYMBOLS <FS_TABLE> TYPE STANDARD TABLE.
CREATE DATA MT_TABLE LIKE IV_TABLE_DATA. ASSIGN MT_TABLE->* TO <FS_TABLE>. <FS_TABLE> = IV_TABLE_DATA. |
Method
|
GET_COLLECTION
|
Level
|
Instance Method
|
Visibility
|
Public
|
Parameters
|
EV_TABLE_DATA Exporting Type DATA
|
FIELD-SYMBOLS <FS_TABLE> TYPE STANDARD TABLE.
ASSIGN MT_TABLE->* TO <FS_TABLE>. IF NOT <FS_TABLE> IS ASSIGNED. RETURN. ENDIF. EV_TABLE_DATA = <FS_TABLE>. |
Method
|
SET_OBJECT
|
Level
|
Instance Method
|
Visibility
|
Public
|
Parameters
|
IR_OBJECT Importing Type Ref To OBJECT
|
MO_OBJECT ?= IR_OBJECT.
|
Method
|
GET_OBJECT
|
Level
|
Instance Method
|
Visibility
|
Public
|
Parameters
|
ER_OBJECT Returning Type Ref To OBJECT
|
ER_OBJECT ?= MO_OBJECT.
|
Connector Class
Create class say YCL_FPM_CONNECTOR_COM and implement interface IF_FPM_CONNECTOR.
Create following attributes:
Attribute
|
Level
|
Visibility
|
Typing
|
Type
|
Value
|
MO_COLLECTION
|
Instance Attribute
|
Protected
|
Type Ref To
|
YCL_FPM_WIRE_DATAHDLR
|
|
MV_PORT_TYPE
|
Instance Attribute
|
Protected
|
Type
|
FPM_MODEL_PORT_TYPE
|
|
GC_NAMESPACE
|
Constant
|
Private
|
Type
|
FPM_MODEL_NAMESPACE
|
‘NS_FPM_COM’
|
Now let’s implement the methods:
Method
|
IF_FPM_CONNECTOR_RUN~GET_OUTPUT
|
RO_OUTPUT = MO_COLLECTION.
|
Method
|
IF_FPM_CONNECTOR_DEF~INITIALIZE
|
MV_PORT_TYPE = IV_PORT_TYPE.
CASE MV_PORT_TYPE. WHEN ‘LS’. IF_FPM_CONNECTOR_DEF~MV_WIRE_LABEL = ‘LEAD SELECTION’. WHEN ‘CO’. IF_FPM_CONNECTOR_DEF~MV_WIRE_LABEL = ‘COLLECTION’. WHEN ‘SE’. IF_FPM_CONNECTOR_DEF~MV_WIRE_LABEL = ‘SELECTION’. ENDCASE. |
Method
|
IF_FPM_CONNECTOR_DEF~SET_INPUT
|
MO_COLLECTION ?= IO_INPUT.
|
Add return statement to remaining interface methods.
Create following public static methods:
Method
|
CLASS_CONSTRUCTOR
|
Level
|
Static Method
|
Visibility
|
Public
|
IF_FPM_CONNECTOR~SV_NAMESPACE = GET_NAMESPACE( ). “Namespace FPM Common
|
Method
|
GET_NAMESPACE
|
Level
|
Static Method
|
Visibility
|
Public
|
Parameters
|
E_VALUE Returning
Type FPM_MODEL_NAMESPACE |
E_VALUE = GC_NAMESPACE.
|
Wiring Model Class
Create a class say YCL_FPM_WIR_MODEL_COM and implement the interface IF_FPM_FEEDER_MODEL.
Create following attributes:
Attribute
|
Level
|
Visibility
|
Typing
|
Type
|
MO_CONNECTOR
|
Instance Attribute
|
Public
|
Type Ref To
|
IF_FPM_CONNECTOR_RUN
|
MO_OUT_DATA_HANDLER
|
Instance Attribute
|
Public
|
Type Ref To
|
YCL_FPM_WIRE_DATAHDLR
|
MO_IN_DATA_HANDLER
|
Instance Attribute
|
Public
|
Type Ref To
|
YCL_FPM_WIRE_DATAHDLR
|
MT_OUTPORT
|
Instance Attribute
|
Public
|
Type
|
IF_FPM_FEEDER_MODEL=>TY_T_PORT
|
Now let’s implement the methods:
Method
|
IF_FPM_FEEDER_MODEL~GET_INPORT_KEY
|
FIELD-SYMBOLS: <LS_OBJECT_KEY> TYPE ANY.
CREATE DATA RR_OBJECT_KEY TYPE C LENGTH 1. ASSIGN RR_OBJECT_KEY->* TO <LS_OBJECT_KEY>. <LS_OBJECT_KEY> = ‘A’. |
Method
|
IF_FPM_FEEDER_MODEL~GET_OUTPORTS
|
ET_OUTPORT = MT_OUTPORT.
|
Method
|
IF_FPM_FEEDER_MODEL~SET_CONNECTOR
|
MO_CONNECTOR = IO_CONNECTOR.
|
Method
|
IF_FPM_FEEDER_MODEL~GET_NAMESPACE
|
RV_NAMESPACE = YCL_FPM_CONNECTOR_COM=>GET_NAMESPACE( ).
|
Create following methods:
Method
|
CONSTRUCTOR
|
CREATE OBJECT MO_OUT_DATA_HANDLER.
|
Method
|
SET_UP_PORTS
|
Level
|
Instance Method
|
Visibility
|
Public
|
Parameters
|
IV_PORT_TYPE Importing Type FPM_MODEL_PORT_TYPE
IV_PORT_DESC Importing Type FPM_MODEL_PORT_DESCRIPTION
|
FIELD-SYMBOLS:
<LS_PORT> LIKE LINE OF MT_OUTPORT, <LS_OBJECT_KEY> TYPE C. *—– COLLECTION OUTPORT
APPEND INITIAL LINE TO MT_OUTPORT ASSIGNING <LS_PORT>. <LS_PORT>–TYPE = IV_PORT_TYPE. CREATE DATA <LS_PORT>–OBJECT_KEY TYPE C. ASSIGN <LS_PORT>–OBJECT_KEY->* TO <LS_OBJECT_KEY>. <LS_OBJECT_KEY> = ‘A’. <LS_PORT>–IDENTIFIER = ‘A’. <LS_PORT>–DESCRIPTION = IV_PORT_DESC. |
Method
|
INIT_IN_WIRE
|
Level
|
Instance Method
|
Visibility
|
Public
|
IF MO_CONNECTOR IS BOUND.
MO_IN_DATA_HANDLER ?= MO_CONNECTOR->GET_OUTPUT( ). ENDIF. |
With this the reusable architecture is ready to be implemented with any feeder class and share data between two UIBB’s using wire. Follow over to the next topic to view how to implement wire using a simple example.
Wiring Reusable Architecture Implementation
We will implement the wire architecture in the following scenario:
“Let’s say there are two UIBB’s form & list component. The form component accepts an Airline Code from SFLIGHT table. It then selects all the records from the database and sends the table data via wire to list component.”
Step 1. Create FORM and LIST component’ feeder classes YCL_SFLIGHT_FEED_FORM and YCL_SFLIGHT_FEED_LIST respectively with their component configuration.

Configuration Form
Configuraiton List
Test Output
Step 2. Assign YCL_FPM_WIR_MODEL_COM as super class to both the feeder classes.
Step 3. Create out ports for FORM feeder. Our requirement is to perform select query on SFLIGHT and send table data to LIST feeder. Therefore we will create a collection port. In the IF_FPM_GUIBB~INITIALIZE method of form feeder we write following code.
CALL METHOD SET_UP_PORTS
EXPORTING IV_PORT_TYPE = IF_FPM_FEEDER_MODEL=>CS_PORT_TYPE–COLLECTION IV_PORT_DESC = ‘COLLECTION’. |
Step 4. Next we perform select query on click of button and put all that data on wire using data object MO_OUT_DATA_HANDLER. We write the following code in GET_DATA.
DATA: LS_DATA TYPE SFLIGHT,
LT_SFLIGHT TYPE STANDARD TABLE OF SFLIGHT. IF IO_EVENT->MV_EVENT_ID EQ ‘ZSELECT_AIRLINE’. LS_DATA = CS_DATA. IF LS_DATA–CARRID IS NOT INITIAL. * –> SELECT QUERY SELECT * FROM SFLIGHT INTO TABLE LT_SFLIGHT WHERE CARRID EQ LS_DATA–CARRID. IF SY–SUBRC IS INITIAL. * –> SET DATA ON WIRE CALL METHOD MO_OUT_DATA_HANDLER->SET_COLLECTION EXPORTING IV_TABLE_DATA = LT_SFLIGHT. ENDIF. ENDIF. ENDIF. |
Remember data can be placed on wire via any method of the feeder class and not just GET_DATA.
Step 5. Now we connect the wires in application component configuration. (Follow the screen shot steps)
Step 6. In the LIST feeder we get data from wire using data handler object MO_IN_DATA_HANDLER. We write the following code in GET_DATA of list component.
DATA: LT_SFLIGHT TYPE STANDARD TABLE OF SFLIGHT.
IF IV_EVENTID->MV_EVENT_ID EQ ‘ZSELECT_AIRLINE’. *–> CHECK IN WIRE IS INITIALIZED. IF MO_IN_DATA_HANDLER IS NOT BOUND. CALL METHOD INIT_IN_WIRE. ENDIF. *–> GET DATA FROM WIRE. CALL METHOD MO_IN_DATA_HANDLER->GET_COLLECTION IMPORTING EV_TABLE_DATA = LT_SFLIGHT. CT_DATA = LT_SFLIGHT. EV_DATA_CHANGED = ABAP_TRUE.
ENDIF. |
Step 7. Next step is to just execute the application.
Hi,
Populate runtime data object to outport using method YCL_FPM_WIR_MODEL_COM~GET_OUTPORT_DATA.
*--Pass Data class reference, otherwise will not get reference of data class in target UIBB
RO_DATA = MO_OUT_DATA_HANDLER.
Thank you for pointing that.
It seems i missed that part to add, i will edit it.
Great blog. I thought to make one like this.