Skip to Content

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

Aug 22, 2017 at 09:21 AM


avatar image
Former Member

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.


353         Record has long text flag without corresponding long text

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/");
parameters.Add(RfcConfigParameters.SystemNumber, "00");
parameters.Add(RfcConfigParameters.Codepage, "1160");

//Declare Destination
RfcDestination dest = RfcDestinationManager.GetDestination(parameters);
RfcRepository repo = dest.Repository;
//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

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

Thank you for you support.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

avatar image
Former Member Aug 28, 2017 at 06:36 AM


10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Nov 02, 2017 at 09:13 AM


10 |10000 characters needed characters left characters exceeded