Recently I was assigned an interesting development, the requirements was to have a button "View legacy Sales Order" on standard sales order screen (VA03) on SAP S/4 HANA system if user clicks that button the system should open VA03 - display sales order that got replicated in the legacy ECC system using a RFC - single sign on (Different system).
Below are the step by step development that I did to accomplish the same.
In t-code SE41 Copied the standard program SAPMV45B and status U to ZSAPMV45B and status ZU
Created a new button with a function code "ZXXX" in SE41 in copied program ZSAPMV45B and status ZU
It is important to add the screen flow for this in t-code VFBS for function codes
It is important to add the paths between process. locations for this in t-code VFBS
Created an implicit enhancement as below to enable the new GUI status in the module ‘MV45AF0C_CUA_SETZEN’ of SAPMV45A.
SET PF-STATUS 'ZU' OF PROGRAM 'ZSAPMV45B' EXCLUDING CUA_EXCLUDE. This button is enabled only for certain order types as specified in the TVARVC table.
Now the button is visible on the SO screen what happens next is the interesting thing at the click of this button. I created another explicit enhancement for click at module ‘MV45AF0F_FCODE_BEARBEITEN’ of SAPMV45A.
Here the following logic will help us to take it to legacy ECC sales order display.
There is output type determination defined in NACE in S/4 system – so every sales order that gets created in SAP S/4 HANA based on this output type assigned will create an outbound IDOC to ECC and creates a sales order there as the order is successfully saves in S/4.
RSNASTED itself determines the associated IDOC outbound function module, executes it to fill the EDIDx tables and passes the prepared IDOC to the port. You can call the standard processing routines from any ABAP, by executing the following call to the routine.
The Output types of order will have the Partners which is also the RFC destination of the legacy system that is defined in SM59.
Check the existence of RFC destination in table 'RFCDES'
If RFC exists check the ping to destination using FM ‘CAT_CHECK_RFC_DESTINATION’.
If ping is successful use the following BAPI to check the existence of legacy sales order ‘BAPI_SALESORDER_GETSTATUS’ using the RFC destination.
If BAPI call is successful, then call the custom RFC FM to run the BDC at RFC destination using CALL FUNCTION 'RFC_CALL_TRANSACTION_USING' STARTING NEW TASK 'UPDATE' DESTINATION RFCDEST – The tables has BT_DATA that contains the VA03 BDC recoding.
This will open up “VA03” if the order exists in legacy ECC else it will display order does not exist.
If Order exists and it will be displayed in Legacy ECC screen it will be in regular VA03.
Thank you for taking time to read this blog post, pls let me know if there were any other better options of doing this. I would also like to thank my employer and customer in for providing this opportunity.
Screenshots courtesy: All images are the screen shot of the system from my customer system, I have notified my customer manager about it and all client sensitive items are greyed out.