cancel
Showing results for 
Search instead for 
Did you mean: 

SAP NCo 3.0 Problem , Import two table to SAP RFC

Former Member
0 Kudos

Hello, i have a problem.

Because i must two table import to my rfc function.

But  didnt worked this method.

My code part is below.

AppServerHost = servername;

SystemNumber = "96";

User = "USER"

Password = "password";

Client = "210";

Language = "TR";

PoolSize = "1";

MaxPoolSize = "1";

IdleTimeout = "0";

            

CreateFunction = "ZTMTR_WAS_02";

                            try

                            {

                                RfcDestinationManager.RegisterDestinationConfiguration(new   MyBackendConfig());

                            }

                            catch

                            {

                            }

                            RfcDestination prd = RfcDestinationManager.GetDestination("PRD_000");

                            RfcRepository repo = prd.Repository;

                            IRfcFunction companyBapi = repo.CreateFunction(CreateFunction.ToString());

                            IRfcTable import2 = companyBapi.GetTable("ZBASLIK");

                            for (int i = 0; i < dtbaslik.Rows.Count; i++)

                            {

                                import2.Append();

                               

                                import2.SetValue("PERNR", dtbaslik.Rows[i]["pernr"].ToString());

                                import2.SetValue("SCHEMT", dtbaslik.Rows[i]["SCHEMT"].ToString());

                                import2.SetValue("BEGDA", dtbaslik.Rows[i]["begda"].ToString());

                                import2.SetValue("ENDDA", dtbaslik.Rows[i]["endda"].ToString());

                                import2.SetValue("KUNDE", dtbaslik.Rows[i]["kunde"].ToString());

                                import2.SetValue("ZORT1", dtbaslik.Rows[i]["zort1"].ToString());

                                import2.SetValue("ZLAND", dtbaslik.Rows[i]["zland"].ToString());

                                import2.SetValue("REINR", dtbaslik.Rows[i][7].ToString());

                                import2.SetValue("PERIO", dtbaslik.Rows[i][8].ToString());

                                import2.SetValue("PDVRS", dtbaslik.Rows[i][9].ToString());

                            }

                            IRfcTable import = companyBapi.GetTable("ZBELEG");

                         

                            for (int i = 0; i < dtbeleg.Rows.Count; i++)

                            {

                                import.Append();

                             

                                import.SetValue("BELNR", dtbeleg.Rows[i]["BELNR"].ToString());

                                import.SetValue("SPKZL", dtbeleg.Rows[i]["SPKZL"].ToString());

                                import.SetValue("BEART", dtbeleg.Rows[i]["BEART"].ToString());

                                import.SetValue("MWSKZ", dtbeleg.Rows[i]["MWSKZ"].ToString());

                                import.SetValue("BETRG", dtbeleg.Rows[i]["BETRG"].ToString());

                                import.SetValue("BLDAT", dtbeleg.Rows[i]["BLDAT"].ToString());

                                import.SetValue("BTEXT", dtbeleg.Rows[i]["BTEXT"].ToString());

                                import.SetValue("WAERS", dtbeleg.Rows[i]["WAERS"].ToString());

                                import.SetValue("KURSB", dtbeleg.Rows[i]["KURSB"].ToString());

                                import.SetValue("FFACT", dtbeleg.Rows[i]["FFACT"].ToString());

                                import.SetValue("TFACT", dtbeleg.Rows[i]["TFACT"].ToString());

                                import.SetValue("ANZFR", dtbeleg.Rows[i]["ANZFR"].ToString());

                                import.SetValue("LNDFR", dtbeleg.Rows[i]["LNDFR"].ToString());

                                import.SetValue("BERFR", dtbeleg.Rows[i]["BERFR"].ToString());

                                import.SetValue("RGION", dtbeleg.Rows[i]["RGION"].ToString());

                                import.SetValue("TXJCD", dtbeleg.Rows[i]["TXJCD"].ToString());

                                import.SetValue("PAYOT", dtbeleg.Rows[i]["PAYOT"].ToString());

                                import.SetValue("PAYCURR", dtbeleg.Rows[i]["PAYCURR"].ToString());

                             import.SetValue("ABOVE_LIMIT", dtbeleg.Rows[i]["ABOVE_LIMIT"].ToString());

                                import.SetValue("PROTECT", dtbeleg.Rows[i]["PROTECT"].ToString());

                                import.SetValue("pernr", dtbeleg.Rows[i]["pernr"].ToString());

                           

                            }

                            companyBapi.SetValue("FUNCTION", "3");

                            companyBapi.Invoke(prd);  // i didnt get any error.But rfc didnt worked.

                            IRfcTable test = companyBapi.GetTable("LOGTAB");

Normally , test table should contains rows.But didnt return any rows.

Not error or warning .

Could you help me please?

Accepted Solutions (0)

Answers (1)

Answers (1)

hynek_petrak
Active Participant
0 Kudos

Hi Aysegul,

Modify the code in a way:

1) Move this code away, best to the Main() function of the application

                            try

                            {

                                RfcDestinationManager.RegisterDestinationConfiguration(new   MyBackendConfig());

                            }

                            catch

                            {

                            }

2) Adjust the call by:

import2.Append();

import2.CurrentIndex = i;                              

IRfcDataContainer dc = import.CurrentRow;

dc.SetValue("PERNR", dtbaslik.Rows[i]["pernr"].ToString());

dc.SetValue("SCHEMT", dtbaslik.Rows[i]["SCHEMT"].ToString());

dc.SetValue("BEGDA", dtbaslik.Rows[i]["begda"].ToString());

3) Make a break point in the SAP Debugger to see what values are received and what values the FM is passing back.

Former Member
0 Kudos

Hi Hynek,

I tried your code but still didnt work.

Before

companyBapi.Invoke(prd);

companyBapi's values below.

{FUNCTION ZTMTR_WAS_02 (IMPORT PARAMETER FUNCTION=3, TABLES PARAMETER LOGTAB=null, TABLES PARAMETER LOGTEXT=null, TABLES PARAMETER ZAVANS=null, TABLES PARAMETER ZBASLIK=TABLE  [STRUCTURE ZTMTR003 { FIELD PERNR=47000000 FIELD SCHEMT=01 FIELD BEGDA=26.11.2014 FIELD ENDDA=26.11.2014 FIELD KUNDE=a FIELD ZORT1=a FIELD ZLAND=TR FIELD REINR= FIELD PERIO= FIELD PDVRS= }], TABLES PARAMETER ZBELEG=TABLE  [STRUCTURE ZTMTR007 { FIELD BELNR=000 FIELD SPKZL=1000 FIELD BEART= FIELD MWSKZ= FIELD BETRG=1,00 FIELD BLDAT=28.11.2014 FIELD BTEXT=a FIELD WAERS=TRY FIELD KURSB= FIELD FFACT= FIELD TFACT= FIELD ANZFR= FIELD LNDFR= FIELD BERFR=N FIELD RGION= FIELD TXJCD= FIELD PAYOT= FIELD PAYCURR= FIELD ABOVE_LIMIT= FIELD PROTECT= FIELD PERNR=4700000 }])}

Then

companyBapi.Invoke(prd);

companyBapi's values below.

{FUNCTION ZTMTR_WAS_02 (IMPORT PARAMETER FUNCTION=3, TABLES PARAMETER LOGTAB=TABLE , TABLES PARAMETER LOGTEXT=TABLE , TABLES PARAMETER ZAVANS=TABLE , TABLES PARAMETER ZBASLIK=TABLE  [STRUCTURE ZTMTR003 { FIELD PERNR=47000000 FIELD SCHEMT=01 FIELD BEGDA=26.11.2014 FIELD ENDDA=26.11.2014 FIELD KUNDE=a FIELD ZORT1=a FIELD ZLAND=TR FIELD REINR= FIELD PERIO= FIELD PDVRS= }], TABLES PARAMETER ZBELEG=TABLE  [STRUCTURE ZTMTR007 { FIELD BELNR=000 FIELD SPKZL=1000 FIELD BEART= FIELD MWSKZ= FIELD BETRG=1,00 FIELD BLDAT=28.11.2014 FIELD BTEXT=a FIELD WAERS=TRY FIELD KURSB= FIELD FFACT= FIELD TFACT= FIELD ANZFR= FIELD LNDFR= FIELD BERFR=N FIELD RGION= FIELD TXJCD= FIELD PAYOT= FIELD PAYCURR= FIELD ABOVE_LIMIT= FIELD PROTECT= FIELD PERNR=47000000 }])}

And export table below.

No rows return

hynek_petrak
Active Participant
0 Kudos

In my VS debugger the dates appear as YYYY-MM-DD.

Try to put, what you see above to SE37 and test whether the FM returns desired result.

MarkusTolksdorf
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Aysegul,

one important remark: When testing in sm37, do also some debugging and check whether the so-called alpha conversion adjusts some  language-dependent value to a different one understood by the function module. Something like that is not happening when calling with an RFC client, which means neither for NCo.

Best regards,

Markus

Former Member
0 Kudos

Hi,

I tried YYYY-MM-DD , YYYYMMDD, DDMMYYYY .

No changes was not.

I tried se37 with same parameters.

ZBASLIK

ZBELEG

I execute the program and LOGTAB returned 2 rows.And recorded my parameters.

This function was working with  the old SAP connector method.But now I'm adapting to sapnco 3.0.The old version of program is below.

What can i do?

Former Member
0 Kudos

Hi Markus,

I tried YYYY-MM-DD , YYYYMMDD, DDMMYYYY .

No changes was not.

I tried se37 with same parameters.

ZBASLIK

ZBELEG

I execute the program and LOGTAB returned 2 rows.And recorded my parameters.

This function was working with  the old SAP connector method.But now I'm adapting to sapnco 3.0.The old version of program is below.

What can i do?