Skip to content

Passing a range table ( SAP structure) as input to a function module(RFC) #9

@programmingaha

Description

@programmingaha

Hi,
First I want to thank you personally for sharing this awesome library.
I came across this issue yesterday.
Suppose you have a function module (Z_Function) in SAP that takes parameter "I_RANGE" which is based on this structure Z_Erdat.
The structure has these fields:
SIGN -> char -> length 1
Option -> char -> length 2
Low -> ERDAT -> DATS (date with 8 character length)
HIGHT -> ERDAT-> DATS (date with 8 character length)
I want to create this range table based on Z_Erdat and send it to Z_Function as parameter I_RANGE.
Following your code I created this:

` public class I_RANGE
{
public Z_Erdat erdat { get; set; }

}

public class Z_Erdat
{
    [RfcEntityProperty("SIGN", SapDataType = RfcDataTypes.CHAR, Length = 1)]
    public string Sign { get; set; }

    [RfcEntityProperty("OPTION", SapDataType = RfcDataTypes.CHAR, Length = 2)]
    public string Option { get; set; }

    [RfcEntityProperty("LOW", SapDataType = RfcDataTypes.DATE_8)]
    public DateTime Low { get; set; }

    [RfcEntityProperty("HIGH", SapDataType = RfcDataTypes.DATE_8)]
    public DateTime High { get; set; }
}

public class Z_FunctionInputParameter : IRfcInput
{
    [RfcEntityProperty("I_RANGE")]
    public I_RANGE range { get; set; }

}`

Based on these when I try to run ExecuteRFCAsync like below:

var result = await client.ExecuteRfcAsync<Z_FunctionInputParameter , Z_FunctionOutputParameter>("Z_Function", inputParameter);

I get the following error:
RfcException: SAP RFC Error: RFC_CONVERSION_FAILURE with message: I_Range of type RFCTYPE_TABLE cannot be converted to type RFC_STRUCTURE_HANDLE

In a nutshell, I want to pass the I_Range parameter which is based on a range structure Z_Erdat to function module Z_Function.
I appreciate your help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions