Enterprise Resource Planning Blogs by SAP
Get insights and updates about cloud ERP and RISE with SAP, SAP S/4HANA and SAP S/4HANA Cloud, and more enterprise management capabilities with SAP blog posts.
cancel
Showing results for 
Search instead for 
Did you mean: 
RahulR
Associate
Associate

Co-Author

@PrasanthM  

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.

i572750_0-1706535854615.png

i572750_1-1706535854625.png

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.

rahul_ranjan05_0-1706790175723.png

Step 3: Upload this .xdp format form on template store via app “Maintain Form Templates”.

i572750_3-1706535854646.png

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.

i572750_4-1706535854647.png

 

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.

i572750_5-1706535854652.png

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.

i572750_6-1706535854660.png

The system should be configured like this:

  1. System ID: <any name>
  2. System Name: <any name>
  3. Host Name: <uri in service key>

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.

i572750_7-1706535854670.png

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.

i572750_8-1706535854674.png

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.

GitHub - SAP-samples/forms-service-by-adobe-samples: Example projects to illustrate how the SAP Form...

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”.

i572750_9-1706535854683.png

SAP Cloud Print Manager Queue .

i572750_10-1706535854695.pngIf 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:

rahul_ranjan05_1-1706790402099.png

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

8 Comments