Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Calling READ_TEXT

Former Member
0 Kudos
1,777

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  RLIDTDOBJECTTDNAMETDID    TDSPRAS SRTF2   CLUSTR  CLUSTD 
100    TX     BOM      100M000024700000000500000010    MPO     N 0288     ÿ €

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();

1 ACCEPTED SOLUTION
Read only

custodio_deoliveira
Active Contributor
0 Kudos
1,236

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

11 REPLIES 11
Read only

former_member186413
Participant
0 Kudos
1,236

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.

READ_TEXT (SAP Library - BC SAPscript: Printing with Forms)

Read only

custodio_deoliveira
Active Contributor
0 Kudos
1,237

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

Read only

0 Kudos
1,236

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: 

  • FL393 - You can only use LIKE and TYPE to specify types in RFC

Therefore i will now try to wrap the function

Read only

0 Kudos
1,236

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();
Read only

juan_suros
Contributor
0 Kudos
1,236

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.

Read only

0 Kudos
1,236

Never mind. Custodio is correct. The function READ_TEXT is not remote enabled and that is the cause of the error.

Read only

0 Kudos
1,236

You are also correct as the LINES table is mandatory.

Cheers,

Custodio

Read only

0 Kudos
1,236

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?

Read only

0 Kudos
1,236

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

Read only

Former Member
0 Kudos
1,236

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

Read only

0 Kudos
1,236

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