Multiple copies labeling on fragmented form in New SAP S/4HANA output management
One of my customers had a requirement to print Invoice forms(Custom developed forms using New SAP S/4HANA output management) in the multiple copies with different label for each copy like below and all the copies were needed to print when invoice get saved or any changes happened.
- First Copy – Original
- Second Copy – Duplicate
- Third Copy – Triplicate
- Fourth Copy – Quadruplicate
In normal adobe forms there are ways to do it by looping the calling FM as below-
- Start spool Job via “FP_JOB_OPEN”.
- Loop N times.
- Call Adobe FM within this loop with text name as a separate parameter.
- Stop spool job via “FP_JOB_CLOSE”
But as in Adobe forms with fragment the forms are called via gateway service and we don’t have leverage to call same gateway service multiple times by using one output type at once.
So here I came across a tricky solution.I am taking example of sales invoice here.
We have created BRF+ configuration to setup multiple outputs – one for each copy that you wish to print. So, for example
ZOUTPUT_XXXX_X_1 for Original,
ZOUTPUT_XXXX_X_2 for Duplicate,
ZOUTPUT_XXXX_X_3 for Triplicate and so on.
The number of copies is set to 1 for each of these outputs in config. You can ask your functional consultant to do this configuration via OPD tcode in BRF+. Same form template is used across the all output type in OPD.
Once the configuration is done then, whenever you save the invoice, multiple outputs are activated each referring to a separate copy of the same form and therefore the OData Service is called once for each output for same invoice.
Our output for messages for invoice will look like this after save-
In you form template you need to bind your text field to an attribute of ODATA service. In this attribute we will set the value for copies such as ORIGINAL, DUPLICATE, TRIPLICATE and so on based on the output type triggered.
To get the output type at run time we need to enhance Inside the standard class CL_APOC_OR_H_UTILITY. This class is called before your ODATA service data provider called.
Implement a pre-exit enhancement on method _RENDER_DOCUMENT of class CL_APOC_OR_H_UTILITY. Inside the method capture the IR_OR_ITEM (Incoming Output Record reference) and transfer it into a global static variable of your class.
(In this case ZCL_SD_INVOICE_DATA which is later used in the OData Service to get the data of the output type.You can use export to memory as well and later you can import to your data provider class method.).
In the OData Service data provider method, use the static attribute ZCL_SD_PROFORMA_DATA=>GS_IR_OR_ITEM-OUTPUT_TYPE and based on the name in OUTPUT_TYPE, assign value to your ODATA entity attribute such as if ouput type name end with ‘_1’ then ORIGINAL and name end with ‘_2’ the DUPLICATE and so on. This attribute is binded to your form layout field to display different text based on copies of the form.
Output of the different form’s copies are as below.
You can use this approach to have multiple copies of form with different labels. It can be very useful when customer need separate copies printed at once when a invoice is saved. This approach can be used for different process(Invoice,sales order) where SAP S/4HANA output management is used to generate the forms.
Let me know your comments.