Mostly SAP related…
Posts tagged SLS_LORD
Passing Custom Fields to Lean Order API
Mar 31st
I recently started working on the ERP Sales Order functionality in the CRM 5.0 WebClient. This is essentially a WebClient view which uses the ERP 6.0 Lean Order API(LORD) to perform all sales order functionality directly in the backend. The benefit is no messy replication of CRM Sales Orders, Config, Pricing and Enhancements.
The problem is that as with all ERP systems customers enhance VA01 over time and the Lean API does not cater for all scenarios, such as additional fields appended to VBAK which must be filled by the user. (UPDATE – See Note 1078575 for restrictions)
The problem is that there seems no(to my knowledge) way to extend the structures of the API to carry these from CRM to ERP in any traditional(i.e. passing parameters) way.
Then this SDN thread prompted me to investigate the innovative implementation of the Lean Order API and I learned something new: Global variables in SAP Programs are externally accessible!
So all you need to do is create a Remote Function module like the one below in ERP.
FUNCTION ZZ_ERPORDER_TRANSFER_FIELD.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(IV_CONTACT_NAME) TYPE ZZCONTACT DEFAULT 'My Abap Test'
*"----------------------------------------------------------------------
field-symbols: <fs_vbak> type vbak.
assign ('(SAPLSLS_LORD)VBAK') to <fs_vbak>.
if sy-subrc = 0.
<fs_vbak>-ZZCONTACT = IV_CONTACT_NAME.
endif.
ENDFUNCTION.The function module above accesses the global VBAK structure in Function Group SLS_LORD and updates it. This is riding rough shod over any concept of variable scope, so please think carefully before implementing this.
Now, all you need is to call the RFC Function Module from CRM. I used an implementation of BADI CRM_IC_ERP_BADI to accomplish this.
method IF_EX_CRM_IC_ERP_BADI~AFTER_CREATION.
call function 'ZZ_ERPORDER_TRANSFER_FIELD'
destination cl_crm_erp_il=>gv_rfc
EXPORTING
IV_CONTACT_NAME = 'Contact Name'.
endmethod.