Co-Author
Ever since embedded steampunk is introduced, we have been trying lot of business scenario on the S/4 HANA public cloud stack.
Developing a custom RAP-based application is a crucial requirement that involves creating, updating a document, and pushing the Custom Adobe form of this document to the print queue. The primary focus is on creating and updating documents, and the specific use of a Custom Adobe form adds a layer of customization to the process. Overall, the goal is to seamlessly integrate these functionalities into a cohesive application to meet the specified requirements.
We will be discussing more about the creation of custom adobe form and pushing it to Print Queue on S/4 HANA Public cloud in this Blog.
Below application and set up should be available in your local machine before you start these developments.
List of services that are needed:
Step 1: Create a RAP based application to create a document. I have developed a Gate Entry App to create gate entry Inbound and Outbound Documents.
On click of create button a custom adobe form will be generated and pushed to Print Queue.
Step 2: Design your Custom Adobe form using Adobe life cycle designer and complete the binding. Save the form in .xdp Format.
Step 3: Upload this .xdp format form on template store via app “Maintain Form Templates”.
Note that form templates uploaded to the system via app “Maintain Form Templates” are not accessible in the cloud developer extensibility (see this limitation is documented here).
Step 4: Connecting the template store
In order to connect to our external template, store we need to setup a custom communication arrangement. To do this, open the ADT tools and login to the system. After this create a new Outbound Service (e.g. ZADSTEMPLSTORE_REST). Choose HTTP as type.
Now create a new custom communication scenario to connect to the template store. Make sure to press the publish button after every modification you do to this scenario. The allowed instances should only by one per client.
At first login to the Fiori Launchpad UI of the system and open the app Communication Systems.
Create a new Communication System (e.g. ID/Name: ADS_REST_API) and maintain all connection settings.
The system should be configured like this:
Auth. Endpoint: <uaa.url in service key>/oauth/authorize
Token Endpoint: <uaa.url in service key>/oauth/token
Create new users for outbound communication:
Authentication Method: OAuth 2.0
OAuth 2.0 Client ID: <uaa.clientid in service key>
Client Secret: <uaa.clientsecret in service key>
Almost done, now we simply open the app Communication Arrangements. We create a new arrangement using our custom scenario (ZADSTEMPLSTORE) and point to our custom communication system.
Step 6: Initialize the template store client.
We will be doing this in background framework in the late save phase of our RAP based application.
DATA(new) = NEW zcl_a5_background_process( ).
DATA background_process TYPE REF TO if_bgmc_process_single_op.
TRY.
background_process = cl_bgmc_process_factory=>get_default( )->create( ).
* background_process->set_operation( new ).
background_process->set_operation_tx_uncontrolled( new ).
background_process->save_for_execution( ).
CATCH cx_bgmc INTO DATA(exception).
"handle exception
ENDTRY.
Step 7 : Create a class by inheriting interface if_bgmc_op_single_tx_uncontr.
METHOD if_bgmc_op_single_tx_uncontr~execute.
try.
"Initialize Template Store Client
data(lo_store) = new ZCL_FP_TMPL_STORE_CLIENT(
"name of the destination (in destination service instance) pointing to Forms Service by Adobe API service instance
iv_service_instance_name = 'ZADSTEMPLATESTORE'
iv_use_destination_service = abap_false
).
"Initialize class with service definition
data(lo_fdp_util) = cl_fp_fdp_services=>get_instance( 'ZUI_C_A5_PR_FORM' ).
"Get initial select keys for service
data(lt_keys) = lo_fdp_util->get_keys( ).
lt_keys[ name = 'PURCHASEREQUISITION' ]-value = '0010000001'.
* data(lv_xml) = lo_fdp_util->read_to_xml( lt_keys ).
*Prepare your XML data
data(lv_xml_raw) = |<form1>| &&
|<PONumber>Ego ille</PONumber>| && .
DATA(lv_xml) = cl_web_http_utility=>encode_base64( lv_xml_raw ).
DATA(lv_xml_final) = conv xstring( lv_xml ).
data(ls_template) = lo_store->get_template_by_name(
iv_get_binary = abap_true
iv_form_name = 'Purchase_Req' "<= form object in template store
iv_template_name = 'PurchaseRequisition' "<= template (in form object) that should be used
).
cl_fp_ads_util=>render_4_pq(
EXPORTING
iv_locale = 'en_US'
iv_pq_name = 'YO1CLNT100Q' "<= Name of the print queue where result should be stored
iv_xml_data = lv_xml_final
iv_xdp_layout = ls_template-xdp_template
is_options = value #(
trace_level = 4 "Use 0 in production environment
)
IMPORTING
ev_trace_string = data(lv_trace)
ev_pdl = data(lv_pdf)
).
cl_print_queue_utils=>create_queue_item_by_data(
"Name of the print queue where result should be stored
iv_qname = 'YO1CLNT100Q'
iv_print_data = lv_pdf
iv_name_of_main_doc = 'PR Form'
).
catch cx_fp_fdp_error zcx_fp_tmpl_store_error cx_fp_ads_util.
endtry
ENDMETHOD.
We are creating print queue in background because of the limitation to call it in foreground. Class method cl_print_queue_utils=>create_queue_item_by_data, doesn’t push adobe form to print queue and goes into ABAP dump when it is called in foreground mode. This is the limitation as of now, hence we have to create print queue in background framework.
For class ZCL_FP_TMPL_STORE_CLIENT, refer code available in GitHub repository.
Step 8: Result
Now we are good to go, After the document is created in Step 1. Check the print queue in “Maintain Print Queue”.
SAP Cloud Print Manager Queue .
If printer is connected, then it will print your document or else you can find the generated PDF in the folder (mentioned at the time of SAP Cloud Print Manager Installation and Set up).
PDF:
I haven't done any data binding ,therefore no data is appearing in the form , However binding can be done and XML data can be mapped at code level.
Hope this will give you an overview of “how to print custom adobe form for a custom application developed on S/4 HANA Public Cloud”.
See Also:
SAP Forms service by Adobe in SAP BTP, ABAP environment | SAP Blogs
Best Regards,
Rahul Ranjan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
7 | |
5 | |
5 | |
4 | |
4 | |
4 | |
4 | |
4 | |
3 | |
3 |