2013 Dec 02 10:30 PM
Hello,
I'm trying to call the function "READ_TEXT", since i need the long text for a BOM line. I'm doing this by rpc
I want to retrieve the following data:
SELECT *
FROM STXL
WHERE TDNAME = '100M000024700000000500000010'
| MANDT | RLID | TDOBJECT | TDNAME | TDID | TDSPRAS | SRTF2 | CLUSTR | CLUSTD |
|---|---|---|---|---|---|---|---|---|
| 100 | TX | BOM | 100M000024700000000500000010 | MPO | N | 0 | 288 | ÿ € |
I try to call the function "READ_TEXT" with the following parameters:
CLIENT = 100
ARCHIVE_HANDLE= 0
OBJECT = "BOM"
ID = "MPO"
NAME = "100M000024700000000500000010"
LANGUAGE = "N"
But i keep getting the error: "Missing parameter with PERFORM.", what am i doing wrong?
Code:
secept.RfcConnector.RfcSession rfcsession = new secept.RfcConnector.RfcSession();
// connection settings
rfcsession.RfcSystemData.ConnectString = "ASHOST=" + server + " SYSNR=" + instance;
rfcsession.LogonData.User = user;
rfcsession.LogonData.Password = password;
rfcsession.LogonData.Language = "EN";
// connect
rfcsession.Connect();
if (rfcsession.Error) throw new Exception(rfcsession.ErrorInfo.Message);
// get the functionhandle
secept.RfcConnector.FunctionCall fc = rfcsession.ImportCall("READ_TEXT");
System.Diagnostics.Debug.Assert(!rfcsession.Error);
// set the parameters
fc.Importing["CLIENT"].value = 100;
fc.Importing["ARCHIVE_HANDLE"].value = 0;
fc.Importing["OBJECT"].value = "BOM";
fc.Importing["ID"].value = "MPO";
fc.Importing["NAME"].value = "100M000024700000000500000010";
fc.Importing["LANGUAGE"].value = "N";
// call the function
rfcsession.CallFunction(fc);
if (rfcsession.Error)
{
// ^^^ FAILS HERE!!!!!
// with message: "Missing parameter with PERFORM."
rfcsession.Disconnect();
throw new Exception(rfcsession.ErrorInfo.Message);
}
rfcsession.Disconnect();
2013 Dec 03 12:25 AM
Hi Eduard,
Your problem is that READ_TEXT is NOT a RFC. You should either find a RFC for this purpose or create a custom one to wrap READ_TEXT.
Regards,
Custodio
2013 Dec 03 12:24 AM
Hi,
My suggestion is create a rfc funcation on your destination site, and you still need to use this insite of your RFC funcation.
* CALL FUNCTION 'READ_TEXT'
* EXPORTING
** CLIENT = SY-MANDT
* id = ' MP0'
* language = '1'
* name = tdname
* object = ' '
** ARCHIVE_HANDLE = 0
** LOCAL_CAT = ' '
** IMPORTING
** HEADER =
* TABLES
* lines = lines
* EXCEPTIONS
* id = 1
* language = 2
* name = 3
* not_found = 4
* object = 5
* reference_check = 6
* wrong_access_to_archive = 7
* OTHERS = 8
where the tdname is the table for BOM header.
2013 Dec 03 12:25 AM
Hi Eduard,
Your problem is that READ_TEXT is NOT a RFC. You should either find a RFC for this purpose or create a custom one to wrap READ_TEXT.
Regards,
Custodio
2013 Dec 04 11:19 AM
I didn't "create a rfc funcation on your destination site", but when i use
the following code:
....
secept.RfcConnector.FunctionCall fc = rfcsession.ImportCall("READ_TEXT");
secept.RfcConnector.FunctionCall fc = rfcsession.ImportCall("READ_TEXT", true);
foreach (secept.RfcConnector.RfcParameter p in fc.Importing) System.Diagnostics.Debug.WriteLine("\timporting: '" + p.name + "'");
foreach (secept.RfcConnector.RfcParameter p in fc.Exporting) System.Diagnostics.Debug.WriteLine("\texporting: '" + p.name + "'");
foreach (secept.RfcConnector.RfcParameter p in fc.Changing) System.Diagnostics.Debug.WriteLine("\tchanging: '" + p.name + "'");
foreach (secept.RfcConnector.RfcParameter p in fc.Tables) System.Diagnostics.Debug.WriteLine("\ttables: '" + p.name + "'");
It outputs:
importing: 'ARCHIVE_HANDLE'
importing: 'CLIENT'
importing: 'ID'
importing: 'LANGUAGE'
importing: 'LOCAL_CAT'
importing: 'NAME'
importing: 'OBJECT'
exporting: 'HEADER'
tables: 'LINES'
To enable this function i followed the following steps:
1 - Goto the functionbuilder(SE37)
2 - Search for "READ_TEXT"
3 - Goto the function by pressing F8
4 - Under processtype the setting is now "normal functionblock" and should be changed to "remote usage functionblock"
To change this function i had to register on SSO, so i could change the function.
However, when i want to save the function i get the following error:
Therefore i will now try to wrap the function
2013 Dec 04 4:33 PM
The function is already wrapped in the function "RPC_READ_TEXT", the following code gave me the correct result:
// connection settings
rfcsession.RfcSystemData.ConnectString = "ASHOST=" + server + " SYSNR=" + instance;
rfcsession.LogonData.User = user;
rfcsession.LogonData.Password = password;
rfcsession.LogonData.Language = "EN";
// connect
rfcsession.Connect();
if (rfcsession.Error) throw new Exception(rfcsession.ErrorInfo.Message);
// SELECT *
// FROM STXL
// WHERE TDNAME = '100M000024700000000500000010'
// |----------|-----------|-----------|-----------------------------------|-----------|-----------|-----------|-----------|-----------|
// | MANDT | RLID | TDOBJECT | TDNAME | TDID | TDSPRAS | SRTF2 | CLUSTR | CLUSTD |
// |----------|-----------|-----------|-----------------------------------|-----------|-----------|-----------|-----------|-----------|
// | 100 | TX | BOM | 100M000024700000000500000010 | MPO | N | 0 | 288 | ÿ € |
// |----------|-----------|-----------|-----------------------------------|-----------|-----------|-----------|-----------|-----------|
// get the functionhandle
secept.RfcConnector.FunctionCall fc = rfcsession.ImportCall("RFC_READ_TEXT", true);
System.Diagnostics.Debug.Assert(!rfcsession.Error);
// enter the parameters
secept.RfcConnector.RfcFields newrow = fc.Tables["TEXT_LINES"].Rows.AddRow();
newrow["TDOBJECT"].value = "BOM";
newrow["TDNAME"].value = "100M000024700000000500000010";
newrow["TDID"].value = "MPO";
newrow["TDSPRAS"].value = "N";
// call the function
rfcsession.CallFunction(fc);
if (rfcsession.Error)
{
rfcsession.Disconnect();
throw new Exception(rfcsession.ErrorInfo.Message);
}
StringBuilder result = new StringBuilder();
foreach (secept.RfcConnector.RfcFields row in fc.Tables["TEXT_LINES"].Rows) {
string tdline = row["TDLINE"].value;
result.AppendLine(tdline);
}
System.Diagnostics.Debug.WriteLine("result:" + result);
rfcsession.Disconnect();
2013 Dec 03 12:26 AM
I think you may need to define a TABLES parameter into which the results of the function call will go.
This function returns the results in a tables parameter named LINES.
I'm not sure which technology you are using here, but a few years ago the DCOM RFC connector required me to call fc.DimAs("LINES") to return a table object which would contain the results of the function call. The call to DimAs needed to come before the function was executed.
This may be the missing parameter referred to in the error message.
2013 Dec 03 12:40 AM
Never mind. Custodio is correct. The function READ_TEXT is not remote enabled and that is the cause of the error.
2013 Dec 03 1:49 AM
You are also correct as the LINES table is mandatory.
Cheers,
Custodio
2013 Dec 04 11:13 AM
I'm using the SDK from the following website: rfcconnector.com , since it looked simple and i can try it for free.
I don't have a function to claim memory for the result: "LINES", but from the given example (Rfc Client [Rfc Connector] ) i get the impression that this is not necessary.
Can you give me the name of the technology you used?
2013 Dec 04 6:08 PM
Eduard,
I used the SAP DCOM Connector for a project back in my Visual Basic days.
This technology is now no longer supported (see oss note 533055). There is a .NET replacement technology (see oss note 506603).
Juan
2013 Dec 04 11:34 AM
Hi Eduard,
Please check the language TDSPRAS = 'N' as the FM READ_TEXT doesn't understand the language 'N'.
For Example, if the table has entry with language TDSPRAS = 'E', so we have to put 'EN' in FM READ_TEXT.
If hope you get my point, so please try the same and tell us if it improves.
Regards,
Nitish Barnwal
2013 Dec 04 12:58 PM
Hello Nitish,
I now know how to call this function from within the sapgui:
1 - Goto the functionbuilder(SE37)
2 - Search for "READ_TEXT"
3 - Goto the function by pressing F8
4 - Enter the parameters from above
5 - Execute the function by pressing F8
6 - The result is returned:
"LINES"
0 Gegevens
"Resultaat:"
10 Gegevens
TD | TDLINES
!!! ************* my data *************!!!
I therefore assume that i use the correct parameters, since it returns the data i was looking for