Dynamic resolution of Fields returned from an RFC #256
-
I am working to convert old .net framework code using sapnco to .net core with yanco. We have a set architecture where the our RFC handler is dynamically calling different RFC's by resolved name, ex
are all called via one generic API endpoint, in which invoke public static EitherAsync<RfcErrorInfo, TResult> CallFunction<TRInput, TResult>(
this IRfcContext context,
string functionName,
Func<Either<RfcErrorInfo, IFunction>, Either<RfcErrorInfo, TRInput>> Input,
Func<Either<RfcErrorInfo, IFunction>, Either<RfcErrorInfo, TResult>> Output,
CancellationToken cancellationToken = default) with Is there a way to dynamically resolve the available fields in the output lambda to map multiple varying models? I have seen the way to get multiple fields using the For instance, the zfunctions on SAP return their data in fields, some common, but all dependent on the type of data (employees, customers, orders) and the fields do not exist as tables or structures. Is it even possible to have a generic output function in this way? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
Forgot to mention: I saw the similar post #114 but that was answered using this solution using |
Beta Was this translation helpful? Give feedback.
-
To give you a better answer, could you please post the signature of the ABAP functions? Z_READ_EMPLOYEES A part of it would be enough to understand your use case. |
Beta Was this translation helpful? Give feedback.
-
When I created the question, I didn't have permission to share the signatures, but I do now :) For better context, we have a selection of forms that are pulling respective data from sap via read functions, in the same way as the original question. Several examples of the form signatures are below: z_read_persInfo *"*"Local Interface:
*" IMPORTING
*" VALUE(I_ROWGD) TYPE /SAPPSPRO/_GUID_CHAR
*" EXPORTING
*" VALUE(E_UGUID) TYPE ZUSRGUID
*" VALUE(E_NACHN) TYPE PAD_NACHN
*" VALUE(E_VORNA) TYPE PAD_VORNA
*" VALUE(E_MIDNM) TYPE PAD_MIDNM
*" VALUE(E_RUFNM) TYPE RUFNM
*" VALUE(E_GBDAT) TYPE GBDAT
*" VALUE(E_PERID) TYPE PRDNI
*" VALUE(E_STRAS) TYPE PAD_STRAS
*" VALUE(E_LOCAT) TYPE PAD_LOCAT
*" VALUE(E_ORT01) TYPE PAD_ORT01
*" VALUE(E_STATE) TYPE REGIO
*" VALUE(E_PSTLZ) TYPE PSTLZ_HR
*" VALUE(E_COUNTY) TYPE COUNC
*" VALUE(E_TELNR) TYPE TELNR
*" VALUE(E_ALTNR) TYPE TELNR
*" VALUE(E_EMAIL) TYPE COMM_ID_LONG
*" VALUE(E_EC_FNM) TYPE PAD_VORNA
*" VALUE(E_EC_LNM) TYPE PAD_NACHN
*" VALUE(E_EC_PPH) TYPE TELNR
*" VALUE(E_EC_APH) TYPE TELNR
*" VALUE(E_EC_REL) TYPE ZOBDT_ECREL
*" VALUE(E_RACE) TYPE RACKY
*" VALUE(E_GESCH) TYPE GESCH
*" VALUE(E_VETST) TYPE ZOBDT_VETST
*" VALUE(E_COMPLETE) TYPE BOOLE_D
*" VALUE(E_CLOSED) TYPE BOOLE_D
*"---------------------------------------------------------------------- z_read_0210 *"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(I_ROWGD) TYPE /SAPPSPRO/_GUID_CHAR
*" VALUE(I_TYPE) TYPE SUBTY
*" EXPORTING
*" VALUE(E_UGUID) TYPE ZUSRGUID
*" VALUE(E_LNMCH) TYPE LNMCH
*" VALUE(E_TXSTA) TYPE TXSTA_D
*" VALUE(E_EXAMT) TYPE EXAMT
*" VALUE(E_MULT_JOBS_IND) TYPE HRPAYUS_TAX_MULT_JOB_INDICATOR
*" VALUE(E_DEPS_TOTAL_AMT) TYPE HRPAYUS_DEPS_TOTAL_AMOUNT
*" VALUE(E_OTHER_INC_AMT) TYPE HRPAYUS_TAX_OTHER_INCOME_AMT
*" VALUE(E_DEDUCT_AMT) TYPE HRPAYUS_TAX_DEDUCT_AMT
*" VALUE(E_COMPLETE) TYPE BOOLE_D
*" VALUE(E_CLOSED) TYPE BOOLE_D
*"---------------------------------------------------------------------- z_read_acks *"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(I_ROWGD) TYPE /SAPPSPRO/_GUID_CHAR
*" EXPORTING
*" VALUE(E_RESULTS) TYPE DB2_T_STRING
*"---------------------------------------------------------------------- We have several other functions, these are just a few examples for variety. Thanks! |
Beta Was this translation helpful? Give feedback.
Hello,
Since you know the signatures in all cases, I would suggest to create different mapping methods for all cases, e.g.
(pseudo code):
f you prefer a fully dynamic method, you could also create some kind of dynamic evaluation of the fields. You already referred to the ToDictionary comment from here #114 (comment)
The IRfcRuntime also contains…