Introduction
Advanced adobe uses OData services as data provider to fetch data from backend system. The OData service converts the data that it fetched from backend, converts the data into XML format, and returns it to the Adobe layout. Adobe layout uses that XML data to print the form using the concept of binding available at Adobe layer.
Process
Below are the steps to create an OData based Adobe form.
OData Service Details –
Open the adobe form (which is consuming OData as backend) in t-code SFP. In the properties tab, you can see the OData service maintained as Gateway service. Below is the screenshot for the same. In this document – I am going to use the Purchase Order Form as example.The Standard Data based adobe form for Purchase Order is MM_PUR_PURCHASE_ORDER.I have copied the standard form to ZMM_PUR_PURCHASE_ORDER.
In Order to use the gateway service of this project. We need to register the OData service in t- code /IWFND/MAINT_SERVICE.
◈ Click on Add Service button (As mentioned in below screenshot).
◈ A new screen will open up. Enter the service name as FDP_EF_PURCHASE_ORDER_SRV.
System Alias as LOCAL or the BACKEND SYSTEM ALIAS (if applicable).
After entering the above mentioned details. Click on Get Services button.
The corresponding service will be displayed in the final output. Simply select the SERVICE and click on Add Service button.
*If in case the service is already registered, the system will throw an information message. Saying – Already registered.
◈ After adding the service – Go to t-code /IWFND/MAINT_SERVICE again.
Now filter the data with service name – ZFDP_EF_PURCHASE_ORDER_SRV.
This step is just to check whether the service is registered successfully or not.Note – Sometimes the ICF node is deactivated. You need to activate it in t-code /IWFND/MAINT_SERVICE only. The screenshot is given below.
◈ Now, once the service is registered successfully. We need to write our custom code in the OData project. Which is accessed via t-code SEGW. If in case you don’t know the project name. Below are the details of steps that you can use to get the project name.
– Open table /IWBEP/I_SBD_SV in t-code SE11.
– Simply pass the service name that you got from the adobe form and pass it as /IWBEP/I_SBD_SV-TECHNICAL_NAME. You will get the project name.
◈ Now, open the project, which you got from above table in t-code SEGW.
◈ The project will open up.
◈ The Entities created under data model contains the required data for Purchase Order.
◈ Some important SAP notes.
◈ As per the SAP note – 2292646 – SAP S/4HANA output control – form templates with fragments. It is recommended to enhance the standard gateway service rather than creating custom one.
◈ Here is a small example to enhance the standard service by creating a custom entity set to print logo on the form.
– Create an entity type with only one field. Logo (say).
– Create required associations — Association – PurchaseOrderNode is the primary node of PO based service. Hence adding association (Cardinality) will decide whether the GET_ENTITY will trigger or GET_ENTITYSET will trigger.Follow the below steps –
A popup will come up.
Enter the required details.
In my case – I am creating an entity type of name mediaControl.
– After entering the details – Press OK.
– On pressing OK button – An entity type gets created under Data Model.
– If we expand the entity type. (in my case mediaControl). The properties are not available.
– Now, we need to create a property – LOGO.
– Double click on Properties Tab. A new view will open. On the right side.
There we can add the fields that are required to be added in the entity set.
In my case – I am creating a field name Logo of type Edm.String.
– Add the field LOGO in the properties tab.
– Now, the Entity set is added successfully. Save the project.
– Now in order to create the required data provider methods – we need to regenerate the project, in order to generate the runtime artifacts of mediaControl entity.
– Click on GENERATE (red) icon.
Check if there are any errors… If any resolve the same and then again click on regenerate icon.
– Now, Next step is to create the associations. However, it is not mandatory step. But, it is one of the factor, which decides the method ENTITY or ENTITYSET needs to be triggered.
Below is the screenshot of how to create associations.
– Select the Associations tab under Data Model folder. Right click on it. And select CREATE.
– A popup will open. Enter the Association Name.
In this case, I am creating ENTITYSET to print logo. Hence, the dependency is 1:1 considering PurchaseOrder as primary entity.
Now click NEXT.
In new window.
– Select the dependent property. In this case. It is LOGO.
– Select the field LOGO and click NEXT.
– In next window – You can see, all the properties already created. Press FINISH.
– After clicking the FINISH button, the Association and AssociationSet gets created.
– You will be able to see the log. If any error occurs, solve it and follow the same process again to create Association.
– If the operation is successful. You can see the created association under the node Associations.
– As the structure is now available in the form of ENTITYSET. Now the next step is to populate data into the ENTITYSET.
For that, we need to extend the Data provider class.
– You can find the Data provider classes under the node Runtime Artifacts in t-code SEGW.
For Purchase order, the class name is – CL_FDP_EF_PURCHASE_ORD_DPC_EXT.
– If we need to fill data in our custom ENTITYSET. Then we need to write code in DPC_EXT class. The method that we use to write code to populate data is similar to the name of ENTITYSET name.
For read operation we use GET_ENTITY method. For Query operation, we use GET_ENTITYSET method.
– Now, In order to write code. Double click on the class DPC_EXT under runtime artifacts. An ALV will open up.
– Double click on object name highlighted in the above screenshot.
– On clicking the object, The class will open up. Now go to the method relevant to our custom entity type.
OR
You can directly right click on the DPC_EXT class. Click on the option Go to Workbench. The class will open up. Select relevant method (mentioned in above screenshot).
OR
Directly open the DPC_EXT class in SE24. And write the code in relevant method.
– Now, the cardinality is 1:1. Hence, there will always be one record for one purchase order. Hence, we will enhance the GET_ENTITY method.
– Now, as we are enhancing the standard gateway service, we need to use implicit enhancements to populate our custom data. These classes are non-modifiable.
– In order to write our custom code – We need to redefine the method.
below are the steps.
1. Go to CHANGE mode.
2. Select the method, in which you are going to write our code. And click on Redefine button.
3. Please refer the below screenshot –
4. On clicking the redefine button – the window will open with some standard commented code. Which is non-modifiable.
Use implicit enhancement option to write custom code.
5. In Advanced Adobe, There is no option to create GRAPHIC Node. Because there is no provision of Context in advanced adobe. As available in ABAP based adobe form.
6. Hence, the alternative way to achieve this is – call the method
cl_ssf_xsf_utilities=>get_bds_graphic_as_bmp.
7. As we normally do in ABAP based adobe form. This method converts the image in hexadecimal format.
8. The additional step is – Call function module ssfc_base64_encode And pass the output of cl_ssf_xsf_utilities=>get_bds_graphic_as_bmp.
9. After execution of FM ssfc_base64_encode, The final output would be in a string format. This way, we can directly bind the string output to the IMAGE FIELD in our Adobe layout.
And, we can achieve the logo (available in SE78) in our form output.
Below is the code for the same.
-> Below is the code for the same :
---------------------------------------------------------------------------------------
DATA : lv_object type tdobjectgr value ‘GRAPHICS’,
lv_name type stxbitmaps-tdname value ‘SAP_LOGO’,
lv_id type tdidgr value ‘BMAP’,
lv_btype type tdbtype value ‘BCOL’,
lv_field type xstring,
gv_logo type string.
*Calling class to populate the test print. which is available in SE78.
call method cl_ssf_xsf_utilities=>get_bds_graphic_as_bmp
exporting
p_object = lv_object ” ‘GRAPHICS’
p_name = lv_name ” Name of the SE78 logo inside Quotes
p_id = lv_id ” ‘BMAP’
p_btype = lv_btype
receiving
p_bmp = lv_field ” v_field and g_logo must be typed xstring
exceptions
not_found = 1
internal_error = 2
others = 3.
*Converting the hexadecimal value of image to string format (Base64 Encoding)
CALL FUNCTION ‘SSFC_BASE64_ENCODE’
EXPORTING
bindata = lv_field
IMPORTING
b64data = gv_logo.
IF sy-subrc = 0.
er_entity-logo = gv_logo.
ENDIF.
--------------------------------------------------------------------------------------------
– After writing the code. Activate the enhancement and class.
– Important instructions regarding binding.
When we are binding the data in adobe layout, we need to know the ENTITY, ENTITYSET and PROPERTIES.
Sometimes, the ENTITYSET is different then what we use in adobe layout to bind the data. Hence, to get the exact name of the ENTITYSET. Open the MPC class and open the method DEFINE_ASSOCIATIONS.
Method will open up. Scroll down and go to NAVIGATIONS.
The highlighted property in above screenshot, is the updated entity type name, That we have to use to access the data in adobe.
Regarding Binding – In case of GET_ENTITY, the data can be accessed by entity_type only. But in case of entity_set, we need to use the path as -> EntitySet.EntityType[*].
– Now based on the examples discussed above for Media fetch.
The code is in place. Data is available in the respective ENTITYSETS.
But the method doesn’t gets triggered. The Logo doesn’t appear on the form.
In order to invoke those methods (Specially, in which the dependent property is not the primary key (like purchase order)).
in order to invoke the custom methods without having dependent property as primary key. We need to enhance the MPC_EXT class. Which is available under node Runtime Artifacts.
Because the model is now changed. After addition of one more entity.
Below are the steps to redefine the model –
1. Open CL_FDP_EF_PURCHASE_ORD_MPC_EXT class (t-code SE24).
2. In order to redefine the model, We need to redefine the corresponding method of MPC_EXT class. The method name to achieve the same is – DEFINE.
3. Go to change mode and Select the DEFINE method and click on redefine button.
4. Enhance the define method to add the required code mentioned below.
--------------------------------------------------------------------------
super->define( ).
--------------------------------------------------------------------------
– Same way – If we need to add any other field into the form, which standard is not providing. We need to create our custom entity set. Populate the data accordingly. Maintain the cardinality, redefine the required method. And bind it in the layout.
– Binding in the LAYOUT.
As the data is getting passed at runtime. When OData gets executed. Hence, While binding the data at layout, We cannot see the hierarchy. Hence we need to type the binding manually.
Email Templates –
The email templates can be accessed via FIORI tiles only.
The catalog for the FIORI tiles is – SAP_BASIS_TCR_T.
This needs to be added to your user ID. Security team helps you to add the catalog to your user ID.
When the catalog gets added successfully under the ID. You can see the tiles on your FIORI home page by executing the t-code – /UI2/FLP.
You can add the required tiles to your home page by click on Pin to Home page button.
When you execute the tile. You will get an error (Sometimes). Not able to fetch data.
In the details of error, You can find the service name.
In order to resolve the issue, You need to add the service in t-code – /IWFND/MAINT_SERVICE.
Same as mentioned in step – 1.
Regarding Email and print settings. Everything is maintained at BRF+ level.
E.g. Template, email address etc.
In order to use the email templates – Click on the FIORI application “Maintain Email templates”.
Click on predelivered email templates link. You can use standard or you can copy the same and make the required changes.
On clicking any of the email template – You can see the data sources i.e. the CDS view, that is going to provide data to the email body.
In my case, I have copied the PO default standard email template to custom one.
There are chances that you are not able to see all entries of Email templates in FIORI application.
This can happen only, If you front-end and back-end system is different.
The possible cause is – You have not maintained the destination system in /IWFND/MAINT_SERVICE t-code.
Creating Custom OData Service –
If in case, there is a requirement to create a custom OData Service out of standard one then —
For Purchase Order ->
1. Copy the project FDP_EF_PURCHASE_ORDER to custom one. Redefine the classes that are already defined in standard project. Because, the redefinition doesn’t get copied to custom project.
2. After redefining all the required methods. Register the Z service in /IWFND/MAINT_SERVICE as specified in step – 1.
The service can be retrieved from the SEGW project only. Just expand the project. Goto Runtime Artifacts.
3. The term ending with SRV is the technical service name.
4. Now assign the service name that you got in above step and assign it to the Adobe form in change mode.
5. Still, If you trigger the form, It will result into ERROR.
6. The last step is – Go to SPRO t-code -> SAP Reference IMG -> Cross Application Components -> Output Control.
7. Execute – Define Output Types…..
A new screen will open…..
8. Search PURCHASE_ORDER in the list
9. Double click on the PURCHASE_ORDER node. It will take you to the new screen… as available below.
10. In the above screen – There is a callback class, which ultimately call the OData Service.
If at all we are copying the standard gateway service to Z. Then we need to create a copy of callback class to Z.
11. Now open the copied class in t-code SE24.
12. Now access the method – GET_FDP_PARAMETER.
13. Double clicking the method, will take you to the source code.
14. At line number “12”, the standard service name is assigned. You need to change it to custom service in your custom class.
15. After activation of your custom class. Assign the z class in SPRO on place of standard callback class.
16. Now you can trigger your custom service.
Creating Custom Adobe Form –
The only process to create the adobe form is – Simply copy the standard form to Z.
Copy Email templates or Form templates in FIORI application
There are chances that you are not able to see all entries of Email templates in FIORI application. This can happen only, If you front-end and back-end system is different.
The possible cause is – You have not maintained the destination system in /IWFND/MAINT_SERVICE t-code.
Sometimes, while trying to copy the email template or form template, The copy button remains disabled.
In Order to resolve this, you need to implement an SAP note – 2283716.
This task is done from BASIS team.
BRF+ configuration.
The possible issue could be – Necessary KPRO settings that needs to be maintained in the system. This is Basis team’s task.
The required SAP notes that needs to be used in the to setup KPRO is -Required BRF+ configuration needs to be maintained to use the Output channel.
This is Functional person’s task.
Sometimes, Even after doing the required BRF+ configuration – The output channel doesn’t work. The output do not gets executed.
Error while previewing the output of adobe form.
1. If you are getting an error regarding adobe rendering issue or SOAP Execute the report FP_PDF_TEST_00. If it is throwing some error. Then the ADS server is not up and running.
BASIS team will help you fixing the issue.
If it is getting executed successfully. Then there is some issue with the layout.
The possible issues could be –
a. You are passing character type data to a numeric field.
b. The JAVASCRIPT code, that you have written contains syntax error.
c. You are trying to print data from an ENTITYSET with minimum count “1“. And, data is not available in the ENTITYSET. Because, the data is not maintained.
If you have an idea, that this ENTITYSET may not contain data. Simply remove the Min Count. (Uncheck the Min Count Checkbox).
Program Execution.
The above process to create OData based adobe form is for PURCHASE ORDER. Hence, we will be triggering the output from transaction ME23N.
1. Go to transaction ME21N and create a new Purchase Order.
2. As soon as you save the Purchase Order. The BRF+ settings gets triggered.
And the form template gets assigned to the PO.
If the output channels are properly configured, then the output gets triggered in the form of Email or spool.
In this case, Email and Print channel, both are configured. Hence, output is getting generated for both channels.
You can view the status in the messages screen of Purchase Order.
A.) Open PO in ME22 / 23. Open the required purchase order.
B.) Click on MESSAGES button, available in application toolbar.
C.) For this particular PO, the output channels are successfully processed. As the output status is “COMPLETED”.
3. Below is the screenshot of processed outputs.
A.) Print –
Email
C.) Print Preview –
In order to preview the PO output.
Go to Message screen (mentioned above) and click on PDF icon.
D.) The print preview will open up in PDF format.
Thanks for the interesting informationsap-pp training
ReplyDeleteHey Sabrina first of all thank so much for this tutor,
ReplyDeleteFor other side, I have a problem with bind manually my custom element with adobe form UI; I tried with many combination:
$.PurchaseOrderNode.Logo
$.PurchaseOrderNode.mediaControl.Logo
$.PurchaseOrderNode
$.PurchaseOrderNode.mediaControlSet.Logo
$.PurchaseOrderNode.mediaControlSet.mediaControl.LOGO
$.mediaControlSet.PurchaseOrderNode
$.mediaControlSet.PurchaseOrderNode.LOGO
Etc....
But i can't print that in the form.
I did debug and the DPC_EXT´s Methods are execute correctly.
can I explain me carefully?.
Thanks,
Thanks a ton for all your efforts..
ReplyDelete