SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Reads table entries from one system to another



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ABAP Dictionary
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Fri Sep 28, 2007 11:12 am    Post subject: Reads table entries from one system to another Reply with quote

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.

Code:
************************************************************************
* 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
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ABAP Dictionary All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.