cancel
Showing results for 
Search instead for 
Did you mean: 

How to Pass Table Structure Parameters to the Function using .net?

Former Member
0 Kudos

We have the following Function for validation.

Function Z_RFC_ZGUFINET_MAIN

IMPORTING

VALUE(GUFI_IMPORT) TYPE ZGUGINETIMP_TT

TABLES

      DOMESTIC_HD TYPE ZGUFIHDR_TT

     ZERROR_HD TYPE ZMAXERRORHD_TT

I don't have issue in passing table parameter But unable to set the import structure datatype.

Could you please help me to pass the table structure value as a parameter?

Thanks in advance.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Dear sateesh,

FYR please see my wiki in SDN.

http://wiki.sdn.sap.com/wiki/pages/editpage.action?pageId=263291953

Best Regards,

Harish.Y

Former Member
0 Kudos

Hi sateesh,

can you send your code then i will modify it. because i didn't understand what you say exactly.

Best Regards,

Harish.y

Former Member
0 Kudos

Hi Harish,

     Thanks for the reply.

I have found the solution .

Dim Con As New SAPConnection

            Dim rfcdest As RfcDestination

            Dim rfcRep As RfcRepository

            Dim rfcFunction As IRfcFunction

            Dim rfcTable As IRfcTable

            Dim rfcTable1 As IRfcTable

            Dim ImportParm As IRfcTable

            Dim metadata As RfcStructureMetadata

            rfcdest = Con.mrfcDestination

            rfcRep = Con.ConRepository

            'Create Function

            rfcFunction = rfcRep.CreateFunction("Z_RFC_ZGUFINET_MAIN")

            'Set the import parameter

            ImportParm = rfcFunction.GetTable("GUFI_IMPORT")

            ImportParm.Insert()

            ImportParm.SetValue("FILENAME", "")

            ImportParm.SetValue("ZVALIDATE", "V")

            ImportParm.SetValue("ZINDICATOR", "GLB1D")

            ImportParm.SetValue("SUPP_VALIDATIONS", "")

            rfcFunction.SetValue("GUFI_IMPORT", ImportParm)

    metadata = rfcRep.GetStructureMetadata("ZGUFINETDHDR_LT")

            rfcTable = rfcFunction.GetTable("DOMESTIC_HD")

            Dim i As Integer = -1

            Dim col As DataColumn

            Dim obj As Object = DBNull.Value

            Dim dr1 As DataRow

            For Each dr1 In dtHDR.Rows

                Dim myStructRow As IRfcStructure = metadata.CreateStructure()

                i = i + 1

                For Each col In dtHDR.Columns

                    obj = dr1(col)

                    myStructRow.SetValue(col.ToString(), obj)

                Next

                rfcTable.Append(myStructRow)

            Next

            'Set LineItem

            i = -1

            metadata = rfcRep.GetStructureMetadata("ZGUFINETDLI_LT")

            rfcTable1 = rfcFunction.GetTable("DOMESTIC_ITEM")

            ' rfcTable.Insert()

            'rfcTable.SetValue("LINE_COL", "LINE")      ' Program Name

            'rfcTable.SetValue("KBLPOS", "1")       ' Dynpro Number

            'rfcTable.SetValue("NEWBK", "")    ' X if a screen

            'rfcTable.SetValue("GSBER", "")         ' Field Name

            'rfcTable.SetValue("KOSTL", "")

            'rfcFunction.Invoke(rfcdest)

            For Each dr1 In dtLine.Rows

                Dim myStructRow As IRfcStructure = metadata.CreateStructure()

                i = i + 1

                For Each col In dtLine.Columns

                    Debug.Print(col.ToString())

                    obj = dr1(col)

                    myStructRow.SetValue(col.ToString(), obj)

                Next

                rfcTable1.Append(myStructRow)

            Next

            RfcSessionManager.BeginContext(rfcdest)

            rfcFunction.Invoke(rfcdest)

            mDomesticHeaderError = Con.GetDataTableFromRFCTable(rfcFunction.GetTable("ZERROR_HD"))

            ' mDomesticLineItemError = Con.GetDataTableFromRFCTable(rfcFunction.GetTable("ZERROR_LI"))

            mDomesticLineItemError = Con.GetResultsFromRFCTable(rfcFunction.GetTable("ZERROR_LI"))