cancel
Showing results for 
Search instead for 
Did you mean: 

[SAP CATS2 BAPI] Difficulties with LONGTEXT Insert in CATSDB with SAPConnector .Net

Former Member
0 Kudos

Hello Guys,

I have a problem with the Data Insert of a Cats Record in the CATSDB. I want to develop a Application in C# for the Human Resource in my company. So I create a dummy Test Code to connect to SAP create a Insert in Cats and link the Insert from Cats with the Longtext in the Longtext Table.

The Problem is, that I get the Error that the Record has long text flag without corresponding long text (look down below). So all work only the Inserting of the Longtext in Longtext Table is failing by this Error. And I dont know why I occure this Error, because the Text is set with mandatory field properties for the Table Longtext.

Error: 

353         Record has long text flag without corresponding long text



Source-Code:
RfcConfigParameters parameters = new RfcConfigParameters();//Parameters for Connection Handle to SAP

//Enter Config Parameters for Connection Handle
parameters.Add(RfcConfigParameters.Name, "TestCon");
parameters.Add(RfcConfigParameters.User, "OTRS");
parameters.Add(RfcConfigParameters.Password, "abcdefghijklmnop");
parameters.Add(RfcConfigParameters.Client, "503");
parameters.Add(RfcConfigParameters.Language, "EN");
parameters.Add(RfcConfigParameters.AppServerHost, "/H/127.0.0.1/H/127.0.0.2/H/127.0.0.3");
parameters.Add(RfcConfigParameters.SystemNumber, "00");
parameters.Add(RfcConfigParameters.Codepage, "1160");

//Declare Destination
RfcDestination dest = RfcDestinationManager.GetDestination(parameters);
RfcRepository repo = dest.Repository;
try
{
//Call BAPI Function for inserting the CATS Record and set the properties for the Function
IRfcFunction insert = repo.CreateFunction("BAPI_CATIMESHEETMGR_INSERT");
insert.SetValue("profile", "ME/IS01");
insert.SetValue("testrun", "X");

//Call BAPI Function Commit to get a response from the SAP after processing the Insert Function
IRfcFunction commit = repo.CreateFunction("BAPI_TRANSACTION_COMMIT");
      
//Get Tables for inserting Cats Record and Longtext
IRfcTable catsRecordsIn = insert.GetTable("CATSRECORDS_IN");
IRfcTable longTextIn = insert.GetTable("LONGTEXT");

//Get Structure of the Table: "CATSRECORDS_IN"
IRfcStructure catsStruct = catsRecordsIn.Metadata.LineType.CreateStructure();
//Insert values into the Table Structure of "CATSRECORDS_IN"
catsStruct.SetValue("employeenumber", "919");
catsStruct.SetValue("workdate", "20170816");
catsStruct.SetValue("catshours", "8.00");
catsStruct.SetValue("REC_ORDER", "000544105013");
catsStruct.SetValue("acttype", "TVV01");
catsStruct.SetValue("longtext", "1");//set Longtextflag 

//Get Structure of the Table: "LONGTEXT"
IRfcStructure longTextInStruct = longTextIn.Metadata.LineType.CreateStructure();
//Insert values into the Table Structure of "LONGTEXT"
longTextInStruct.SetValue("ROW", 1);
longTextInStruct.SetValue("FORMAT_COL", "5");
longTextInStruct.SetValue("TEXT_LINE", "Test");

//Insert Table Structure with Values into the Tables
catsRecordsIn.Insert(catsStruct);
longTextIn.Insert(longTextInStruct);

//Invoke Insert to SAP
insert.Invoke(dest);
commit.Invoke(dest);
IRfcTable rtrn = insert.GetTable("RETURN");
//Close Connection to Destination
RfcSessionManager.EndContext(dest);
}
catch(RfcBaseException bex)
{
string str = String.Format("ERR:{0}==CODE_ERR: {1}",bex.ErrorCode,bex.Message, GetSAPErr(bex.ErrorCode));
MessageBox.Show(str);
}

Thank you for you support.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

#push

Former Member
0 Kudos

#push