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

RFC_GET_TABLE_ENTRIES

Former Member
0 Likes
2,795

I am trying to extract data from Custom tables from one instance of R/3 to another instance of R/3. I found across these function modules.

RFC_GET_TABLE_ENTRIES

RFC_READ_TABLE.

Which one would be better choice and why???

I've seen some threads which explains that using RFC_READ_TABLE we have parse the data again once it is read. Is it right...

Does there exist a option of specifying field separator.

Can I get a example of RFC_GET_TABLE_ENTRIES

I am trying to extract data from Custom tables from one instance of R/3 to another instance of R/3. I found across these function modules.

RFC_GET_TABLE_ENTRIES

RFC_READ_TABLE.

Which one would be better choice and why???

I've seen some threads which explains that using RFC_READ_TABLE we have parse the data again once it is read. Is it right...

Does there exist a option of specifying field separator.

Can I get a example of RFC_GET_TABLE_ENTRIES

4 REPLIES 4
Read only

Former Member
0 Likes
1,413

Hi Alexander,

Both the tables are used for different purpose.

RFC_GET_TABLE_ENTRIES is used to fetch all the data present in the databse table. you can give table name start and end condition.

RFC_READ_TABLE is used to get the structure of the databse table. that is it returns all the fields present in databse table there size offset etc.

So if you want to fetch the entries you need to use both the tables.

RFC_GET_TABLE_ENTRIES should be used to get table data and RFC_READ_TABLE to parse the data fetched by above said function moduel

Hope this helps.

Award forum points to helpful ansers

Read only

former_member194669
Active Contributor
0 Likes
1,413

Hi,

Both have limitation of maximum width of 512 of data.

And also it will not work with unicode systems. pl see SAP note 758278

aRs

Read only

Former Member
0 Likes
1,413

The following code is very simple and reads a table from one system to another and then adds or overwrites the local table with the remote table entries.

If this is of any use please award points thankyou.

************************************************************************

  • Screen Definition

************************************************************************

PARAMETERS:

PR_TABLE LIKE DD03L-TABNAME default 'Z*' obligatory,

P_DEST LIKE RFCDES-RFCDEST obligatory,

P_DEL AS CHECKBOX DEFAULT ' '.

************************************************************************

  • Internal Tables

************************************************************************

DATA: SEL_TAB LIKE BDSEL_STAT OCCURS 0 WITH HEADER LINE,

NAMETAB LIKE BDI_MFGRP OCCURS 0 WITH HEADER LINE,

TABENTRY LIKE BDI_ENTRY OCCURS 0 WITH HEADER LINE,

TABENTRY1 LIKE BDI_ENTRY OCCURS 0 WITH HEADER LINE,

T_DDFIELD LIKE DDFIELD OCCURS 0 WITH HEADER LINE.

************************************************************************

  • Data Definition

************************************************************************

*DATA: v_field LIKE zfield_map-fieldname.

DATA:V_ANSWER(1) TYPE C,

LINE(1023),

COUNT TYPE I.

************************************************************************

  • Field Symbols

************************************************************************

FIELD-SYMBOLS: <TAB_LINE> TYPE ANY,

<COMPONENT> TYPE ANY.

AT SELECTION-SCREEN ON PR_TABLE.

IF PR_TABLE(1) NE 'Z'.

MESSAGE E600(FR) WITH 'Must be Z or Y Table'.

ENDIF.

************************************************************************

  • Start-of-selection

************************************************************************

START-OF-SELECTION.

PERFORM GET_THE_TABLE_ENTRIES.

IF P_DEL EQ 'X'.

  • IF NOTHING FOUND POPUP BOX TO DECIDE WHETHER TO CREATE OR NOT ?

CALL FUNCTION 'POPUP_TO_DECIDE'

EXPORTING

DEFAULTOPTION = '1'

TEXTLINE1 = TEXT-001

TEXT_OPTION1 = TEXT-004

TEXT_OPTION2 = TEXT-005

TITEL = TEXT-006

START_COLUMN = 25

START_ROW = 6

CANCEL_DISPLAY = 'X'

IMPORTING

ANSWER = V_ANSWER.

  • IF THE ANSWER IS YES THEN GET REMOTE DEFINITION OF TABLE

IF V_ANSWER EQ '1'.

PERFORM DELETE_LOCAL_ENTRIES.

PERFORM UPDATE_LOCAL_TABLE.

ELSE.

PERFORM UPDATE_LOCAL_TABLE.

ENDIF.

else.

PERFORM UPDATE_LOCAL_TABLE.

ENDIF.

&----


*& Form GET_THE_TABLE_ENTRIES

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM GET_THE_TABLE_ENTRIES.

TRANSLATE P_DEST TO UPPER CASE.

CALL FUNCTION 'TABLE_ENTRIES_GET_VIA_RFC'

DESTINATION P_DEST

EXPORTING

LANGU = SY-LANGU

TABNAME = PR_TABLE

TABLES

SEL_TAB = SEL_TAB

NAMETAB = NAMETAB

TABENTRY = TABENTRY

EXCEPTIONS

INTERNAL_ERROR = 1

TABLE_HAS_NO_FIELDS = 2

TABLE_NOT_ACTIV = 3

NOT_AUTHORIZED = 4

OTHERS = 5

.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDFORM. " GET_THE_TABLE_ENTRIES

&----


*& Form UPDATE_LOCAL_TABLE

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM UPDATE_LOCAL_TABLE.

LOOP AT TABENTRY.

ASSIGN TABENTRY-ENTRY TO <TAB_LINE> CASTING TYPE (PR_TABLE).

WRITE: / 'Row', COUNT.

DO.

ASSIGN COMPONENT SY-INDEX OF STRUCTURE <TAB_LINE> TO <COMPONENT>.

IF SY-SUBRC <> 0.

EXIT.

ENDIF.

WRITE <COMPONENT>.

ENDDO.

ASSIGN COMPONENT 'MANDT' OF STRUCTURE <TAB_LINE> TO <COMPONENT>.

<COMPONENT> = SY-MANDT.

MODIFY (PR_TABLE) FROM <TAB_LINE>.

ENDLOOP.

ENDFORM. " UPDATE_LOCAL_TABLE

&----


*& Form DELETE_LOCAL_ENTRIES

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM DELETE_LOCAL_ENTRIES.

SELECT * FROM (PR_TABLE) INTO TABENTRY1.

ASSIGN TABENTRY1-ENTRY TO <TAB_LINE> CASTING TYPE (PR_TABLE).

DELETE (PR_TABLE) FROM <TAB_LINE>.

ENDSELECT.

ENDFORM. " DELETE_LOCAL_ENTRIES

Read only

0 Likes
1,413


************************************************************************
* Screen Definition
************************************************************************
PARAMETERS:
PR_TABLE LIKE DD03L-TABNAME default 'Z*' obligatory,
P_DEST LIKE RFCDES-RFCDEST obligatory,
P_DEL AS CHECKBOX DEFAULT ' '.

************************************************************************
* Internal Tables
************************************************************************
DATA: SEL_TAB LIKE BDSEL_STAT OCCURS 0 WITH HEADER LINE,
NAMETAB LIKE BDI_MFGRP OCCURS 0 WITH HEADER LINE,
TABENTRY LIKE BDI_ENTRY OCCURS 0 WITH HEADER LINE,
TABENTRY1 LIKE BDI_ENTRY OCCURS 0 WITH HEADER LINE,
T_DDFIELD LIKE DDFIELD OCCURS 0 WITH HEADER LINE.


************************************************************************
* Data Definition
************************************************************************
*DATA: v_field LIKE zfield_map-fieldname.
DATA:V_ANSWER(1) TYPE C,
LINE(1023),
COUNT TYPE I.

************************************************************************
* Field Symbols
************************************************************************
FIELD-SYMBOLS: <TAB_LINE> TYPE ANY,
<COMPONENT> TYPE ANY.

AT SELECTION-SCREEN ON PR_TABLE.

IF PR_TABLE(1) NE 'Z'.
MESSAGE E600(FR) WITH 'Must be Z or Y Table'.
ENDIF.
************************************************************************
* Start-of-selection
************************************************************************
START-OF-SELECTION.


PERFORM GET_THE_TABLE_ENTRIES.


IF P_DEL EQ 'X'.

* IF NOTHING FOUND POPUP BOX TO DECIDE WHETHER TO CREATE OR NOT ?
CALL FUNCTION 'POPUP_TO_DECIDE'
EXPORTING
DEFAULTOPTION = '1'
TEXTLINE1 = TEXT-001
TEXT_OPTION1 = TEXT-004
TEXT_OPTION2 = TEXT-005
TITEL = TEXT-006
START_COLUMN = 25
START_ROW = 6
CANCEL_DISPLAY = 'X'
IMPORTING
ANSWER = V_ANSWER.

* IF THE ANSWER IS YES THEN GET REMOTE DEFINITION OF TABLE
IF V_ANSWER EQ '1'.
PERFORM DELETE_LOCAL_ENTRIES.
PERFORM UPDATE_LOCAL_TABLE.
ELSE.
PERFORM UPDATE_LOCAL_TABLE.
ENDIF.
else.
PERFORM UPDATE_LOCAL_TABLE.
ENDIF.



*&---------------------------------------------------------------------*
*& Form GET_THE_TABLE_ENTRIES
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM GET_THE_TABLE_ENTRIES.

TRANSLATE P_DEST TO UPPER CASE.


CALL FUNCTION 'TABLE_ENTRIES_GET_VIA_RFC'
DESTINATION P_DEST
EXPORTING
LANGU = SY-LANGU
TABNAME = PR_TABLE
TABLES
SEL_TAB = SEL_TAB
NAMETAB = NAMETAB
TABENTRY = TABENTRY
EXCEPTIONS
INTERNAL_ERROR = 1
TABLE_HAS_NO_FIELDS = 2
TABLE_NOT_ACTIV = 3
NOT_AUTHORIZED = 4
OTHERS = 5
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

ENDFORM. " GET_THE_TABLE_ENTRIES

*&---------------------------------------------------------------------*
*& Form UPDATE_LOCAL_TABLE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM UPDATE_LOCAL_TABLE.
LOOP AT TABENTRY.

ASSIGN TABENTRY-ENTRY TO <TAB_LINE> CASTING TYPE (PR_TABLE).

WRITE: / 'Row', COUNT.
DO.
ASSIGN COMPONENT SY-INDEX OF STRUCTURE <TAB_LINE> TO <COMPONENT>.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
WRITE <COMPONENT>.

ENDDO.
ASSIGN COMPONENT 'MANDT' OF STRUCTURE <TAB_LINE> TO <COMPONENT>.
<COMPONENT> = SY-MANDT.

MODIFY (PR_TABLE) FROM <TAB_LINE>.
ENDLOOP.
ENDFORM. " UPDATE_LOCAL_TABLE
*&---------------------------------------------------------------------*
*& Form DELETE_LOCAL_ENTRIES
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DELETE_LOCAL_ENTRIES.

SELECT * FROM (PR_TABLE) INTO TABENTRY1.

ASSIGN TABENTRY1-ENTRY TO <TAB_LINE> CASTING TYPE (PR_TABLE).

DELETE (PR_TABLE) FROM <TAB_LINE>.

ENDSELECT.

ENDFORM. " DELETE_LOCAL_ENTRIES