Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

RFC and read table in another destination

HI

I search a complete code to read a table using the function 'RFC_GET_TABLE_ENTRIES '

I can acess to another server using RFC without problem.

I need to read table 'tmsbuftxt ' and data ' TRKORR '.

my program looks like

TABLES:
       tmsbuftxt.

     DATA:
       i_tab512 TYPE tab512 OCCURS 0 WITH HEADER LINE,
       i_tmsbuftxt TYPE table of  tmsbuftxt,
       st_tmsbuftxt type tmsbuftxt.

     PARAMETERS p_dest LIKE rfcdes-rfcdest OBLIGATORY.

     START-OF-SELECTION.
       CLEAR i_tab512. REFRESH i_tab512.
       CALL FUNCTION 'RFC_GET_TABLE_ENTRIES'
         DESTINATION
           p_dest
         EXPORTING
    "     BYPASS_BUFFER           = ' '
     "     FROM_KEY                = ' '
     "     GEN_KEY                 = ' '
     "     MAX_ENTRIES             = 0
           table_name              = 'tmsbuftxt'
     "     TO_KEY                  = ' '
     "   IMPORTING
     "*     NUMBER_OF_ENTRIES       =
         TABLES
           entries                 = i_tab512
         EXCEPTIONS
           OTHERS                  = 1.

       i_tmsbuftxt[] = i_tab512[].



         LOOP AT i_tmsbuftxt INTO st_tmsbuftxt.
             Write : st_tmsbuftxt-TRKORR.
         ENDLOOP.

The problem is I dont know how to use the function correctly , I can choose the RFC I want but  my programm return nothing.

Anyone can corect this?

I just start develop abap since 1 month.

I just want write  st_tmsbuftxt-TRKORR. who is in another environnement using RFC.

Former Member
replied

Hello Guillaume,

welcome in this forum.

I try RFC_GET_TABLE_ENTRIES, but I think it is better to use RFC_READ_TABLE. Try this to get the numbers of the transports from another system:

"-Begin-----------------------------------------------------------------
  Program Z_TEST.

    Data Fields Type Standard Table Of RFC_DB_FLD.
    Data Field Type RFC_DB_FLD.
    Data Data Type Standard Table Of TAB512.
    Data Line Type TAB512.

    Field-FIELDNAME = 'TRKORR'.
    Append Field To Fields.

    Call Function 'RFC_READ_TABLE' Destination 'NONE'
      Exporting
        QUERY_TABLE = 'TMSBUFTXT'
      Tables
        FIELDS = Fields
        DATA = Data
      Exceptions
        TABLE_NOT_AVAILABLE = 1
        TABLE_WITHOUT_DATA = 2
        OPTION_NOT_VALID = 3
        FIELD_NOT_VALID = 4
        NOT_AUTHORIZED = 5
        DATA_BUFFER_EXCEEDED = 6
        Others = 7.

    If sy-subrc <> 0.

    Else.
      Loop At Data Into Line.
        Write: / Line.
      EndLoop.
    EndIf.

"-End-------------------------------------------------------------------

Let us know your results.

Cheers

Stefan

1 View this answer in context
Not what you were looking for? View more on this topic or Ask a question