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.
Very informative and useful blog, Ravish.
Good one, Its always tricky with Forms and fragment, Thanks for sharing.
Nice one Ravish! You have shown that not all problems can be solved technically. Sometimes you have to be creative which you have been on our recent project. Thanks for coming up with this solution. I am sure it will benefit many!
Thanks Aditya. 🙂
Hi Ravish, This is very informative as we did a similar one in our last project but didn't used BRF+.
Thanks for sharing.
Hi Ravish Ranka ,
This is something I was expecting from community members to write some real time examples of new output management in S/4 HANA. I really liked your approach to go with standard flow and use pre-exits for custom based requirements. I also found few BADIs provided by SAP to fulfill various custom requirements. I am not sure if you have gone through those BADI's as well.
Thanks Prabhjot.. It will be good if you can share those BADI's ..
Hi Ravish and Prabhojit,
We had similar req. But instead of multiple copies, if its a initial trigger of the output type it must be 'Invoice' else it must be 'Reprint Invoice'. Generally in ECC everything will be captured in nast. But in S4 with BRF+ any suggestions...
In the class CL_APOC_OR_H_UTILITY method _GET_WATERMARK_NAME, there is a country specific logic to get duplicate printed on copies. You can use table APOC_D_OR_ITEM to check if output is already processed or not/. Hope it helps.
It helped to proceed further on this...Thank you.