cancel
Showing results for 
Search instead for 
Did you mean: 

Iss

Former Member
0 Kudos

Hi,

I am new to SAP NCo 3.0 and starting off.

I am trying to run an RFC call using asp.NET MVC4. I am trying to execute a RFC "ZM07_PO_RELEASE_STRATEGY" with the below parameters,

FUNCTION ZM07_PO_RELEASE_STRATEGY

(

EXPORT STATUS:CHAR1,

IMPORT BY_PASS_WF:CHAR1 [optional:null],

IMPORT I_ACTION:CHAR3,

IMPORT I_EBELN:CHAR10,

IMPORT I_FRGCO:CHAR2 [optional:null],

IMPORT I_REJREASON:CHAR255 [optional:null],

IMPORT I_WIID:NUM(12),

TABLES RETURN_MESSAGES:STRUCTURE BAPIRET2

)

from the above function how can I return the table?

Below is the code which i am trying to execute. When i run the program i am getting the error saying that "Current row is undefined for empty table".

Kindly help me by providing sample code to excute the above type of RFC call which need to update the status in SAP.

try

            {

                  RfcDestinationManager.UnregisterDestinationConfiguration(new SAPSystemConnection());

                  RfcDestinationManager.RegisterDestinationConfiguration(new SAPSystemConnection());

                  RfcDestination rfcPORelease = RfcDestinationManager.GetDestination("PORC");

                  RfcSessionManager.BeginContext(rfcPORelease);

                RfcRepository repositoryPORelease = rfcPORelease.Repository;

                 IRfcFunction POReleaseBapi = repositoryPORelease.CreateFunction("ZM07_PO_RELEASE_STRATEGY");

                IRfcTable POTable = POReleaseBapi.GetTable("RETURN_MESSAGES");

                 if (model.ActionType == "Approve")

                {

                    POReleaseBapi.SetParameterActive("BY_PASS_WF", false);

                    POReleaseBapi.SetValue("I_ACTION", "REL");

                    POReleaseBapi.SetValue("I_EBELN", POObj.PONum);

                    POReleaseBapi.SetValue("I_FRGCO", POObj.FRGCO);

                    POReleaseBapi.SetParameterActive("I_REJREASON", false);

                    POReleaseBapi.SetValue("I_WIID", POObj.WrkItmID);

                }

                else if (model.ActionType == "Reject")

                {

                    POReleaseBapi.SetParameterActive("BY_PASS_WF", false);

                    POReleaseBapi.SetValue("I_ACTION", "REJ");

                    POReleaseBapi.SetValue("I_EBELN", POObj.PONum);

                    POReleaseBapi.SetValue("I_FRGCO", POObj.FRGCO);

                    POReleaseBapi.SetValue("I_REJREASON", model.txtReason.ToString());

                    POReleaseBapi.SetValue("I_WIID", POObj.WrkItmID);

                }

                POReleaseBapi.Invoke(rfcPORelease);

 

                RfcSessionManager.EndContext(rfcPORelease);

            }

            catch (Exception ex)

            {

               

            }

Thanks

Mahesh

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member197445
Contributor
0 Kudos

Can you try adding this:

IRfcFunction commitBapi = repositoryPORelease.CreateFunction("BAPI_TRANSACTION_COMMIT");

commitBapi.Invoke(rfcPORelease);

before your "EndContext" statement?

Thanks.