4

I'm using SAP .NET Connector 3.0 to read data from SAP(R/3). I need to get some header texts from sales orders: enter image description here

A lot of information I found regarding READ_TEXT function which can be used for this purpose. Here you can find some sample how to do it by using ERPConnect. I'm trying to do the same and I have following function which returns IRfcTable:

static IRfcTable ReadFunction(string destName, int rowCount)
        {
            // get the destination
            RfcDestination dest = RfcDestinationManager.GetDestination(destName);

            IRfcFunction func = dest.Repository.CreateFunction("RFC_READ_TEXT");

            IRfcTable table = func.GetTable("TEXT_LINES");
            table.Insert();
            table.Insert();
            table.Insert();
            table.Insert();
            table[0].SetValue("TDOBJECT", "VBBK");
            table[1].SetValue("TDNAME", "3147856016");
            table[2].SetValue("TDID", "Z019");
            table[3].SetValue("TDSPRAS", "PL");
            func.Invoke(dest);
            return table;
        }

VBBK - means header objects, 3147856016 - sales order number, Z019 - ID for EDI Supplier text field, PL - language. As a result I'm retrieving some data, but field TDLINE is blank:

enter image description here
According to example this field should contain text.
Probably some parameters are incorrect. Here is a good post where I found how to obtain TDID parameter for each text field.
What I'm doing wrong?

UPDATE: According to vwegert answer below, code has been changed like:

        IRfcTable table = func.GetTable("TEXT_LINES");
        table.Insert();
        table[0].SetValue("TDOBJECT", "VBBK");
        table[0].SetValue("TDNAME", "3147856016");
        table[0].SetValue("TDID", "Z019");
        table[0].SetValue("TDSPRAS", "PL");
        func.Invoke(dest);
        return table;

Now parameters are correct. But TDLINE is still empty. Result:
enter image description here

1 Answer 1

1

The function module needs the following parameters:

  TDOBJECT    TDNAME       TDID       TDSPRAS
  ----------- ------------ ---------- -------
1 VBRK        3147856016   Z019       PL

You are calling it with the following parameters:

  TDOBJECT    TDNAME       TDID       TDSPRAS
  ----------- ------------ ---------- -------
1 VBRK        
2             3147856016   
3                          Z019       
4                                     L

This won't work - the function module will take the line containing a TDNAME, add TDBOJECT = 'DRAD', TDID = 'LTXT' and TDSPRAS = SY-LANGU and attempt to read that text. This will probably fail, resulting in the empty line you see. Also note that you need to supply the internal language designator, which is a single character.

Furthermore you are completely ignoring the MESSAGES parameter that will probably contain some messages that would have told you a lot about what went wrong.

5
  • Thanks a lot for your replay! Really, no need to create new rows to put each parameter. But TDLINE is still empty. I've updated my question. Regarding MESSAGES - is it separate table like TEXT_LINES?
    – mbigun
    Jan 3, 2014 at 15:50
  • I checked MESSAGES and following system error there Text 3147856016 ID Z019 language PT not found. I assume, some search parameter is incorrect. And also I noticed, that error contains language PT instead of PL.
    – mbigun
    Jan 3, 2014 at 15:58
  • Yes. TDLIN is empty because of language. In my case TDSPRAS = PL, and system takes only first symbol. I've changed TDSPRAS = L and now I retrieved this text. I'm really appreciate your for help. You saved a lot of time for me. Without this ERROR MESSAGE I couldn't identify the issue. Now it works!
    – mbigun
    Jan 3, 2014 at 16:09
  • Which function can be used to create or change existing SAP texts? Let's say I have same TDID = Z019 on sales order header and would like to assign new text for it. Can you, please, recomment some RFC enabled function for that?
    – mbigun
    Oct 10, 2014 at 23:13
  • @mbigun That should be a separate question, I think - and not hidden in some comments...
    – vwegert
    Oct 11, 2014 at 6:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.