Passing Custom Fields to Lean Order API
March 31, 2009I 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.






Hi Johan, thanks a lot for this code. but unfortunately in my
Antonio | March 3, 2011Hi Johan,
thanks a lot for this code.
but unfortunately in my system this badi is not called from the standard.
i have implemented and activated the bady for populate a custom field on ECC side.
but he badi is not triggered and the field is not populate
Did you have any idea?
thanks a lot for your cooperation.
Antonio
Hi Antonio Apologies, for only coming here now. This code is
johanvz | April 14, 2011Hi Antonio
Apologies, for only coming here now. This code is meant as workaround on the LORD1 interface and shouldn’t be used on LORD2(available with ECC6 EHP4). You must use Lord2 if its available. Also, the Badi you refer to was specific to version 5 if I recall and there are new badi’s available in CRM 7(think they are available in the IMG).
Regards
Johan.