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

Display conflicting cust./dev. object in transports



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Transport and Upgrade | Транспорт и Обновления
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Sun Nov 25, 2007 2:19 am    Post subject: Display conflicting cust./dev. object in transports Reply with quote

Display conflicting cust./dev. object in transports - useful for parallel projects

Code:
REPORT ZTRCONF2 NO STANDARD PAGE HEADING.
************************************************************************
* This program displays the conflicting development and customization
* objects of transports. It can be very useful in case of parallel
* projects going on in different systems/clients having a single
* consolidation client.
* The program reads from the application server two text files that
* contain transport numbers. Then it fetches the corresponding E071
*  - and in case of customization objects - E071K table entries.
* The tables can be in a local, or in a remote system, because the
* program uses database links to get the data. A corresponding db. link
* has to exist in the database. Then the program compares the objects
* and keys, and displays the conflicting ones with their transport
* number.
* In case of 2X100 transports with an average number of key
* entries/development objects of 50, 500.000 checks has to be carried
* out. Two keys can be conflicting if one key is a substring of the
* other - this check is a costly operation. Because of these reasons the
* program is carefully tuned and not too pretty. It uses nested
* EXEC SQL calls, because those are much faster then RFC calls like
* the TABLE_ENTRIES_GET_VIA_RFC.
************************************************************************
TABLES: E071,                          "Transports and contained objects
        E071K,              "Transports, cust. objects and keys
        RFCDES,                        "RFC destinations
        DD02L.
PARAMETERS:
    FILE_1(40) DEFAULT '/tmp/dev1trp.txt' LOWER CASE OBLIGATORY,
    FILE_2(40) DEFAULT '/tmp/dev2trp.txt' LOWER CASE OBLIGATORY.

DATA: TRNUM LIKE E070-TRKORR.
DATA: PGMID LIKE E071-PGMID,
      OBJECT LIKE E071-OBJECT,
      OBJNAME(40),
      OBJFUNC LIKE E071-OBJFUNC,
      TABKEY LIKE E071K-TABKEY.
* Internal tables
* Results from file #1
DATA: BEGIN OF ITAB_1 OCCURS 100,
      PGMID LIKE E071-PGMID,
      OBJECT LIKE E071-OBJECT,
      OBJNAME(50),
      OBJFUNC,
      TRKORR LIKE E071-TRKORR,
      TABKEY(60),
END OF ITAB_1.
* Results from file #2
DATA: BEGIN OF ITAB_2 OCCURS 10000,
      PGMID LIKE E071-PGMID,
      OBJECT LIKE E071-OBJECT,
      OBJNAME(50),
      OBJFUNC,
      TRKORR LIKE E071-TRKORR,
      TABKEY(60),
END OF ITAB_2.
DATA: BEGIN OF ITAB_R1 OCCURS 100,
      PGMID LIKE E071-PGMID,
      OBJECT LIKE E071-OBJECT,
      OBJNAME(50),
      TRKORR LIKE E071-TRKORR,
      TABKEY(60),
END OF ITAB_R1.
* Results from file #2
DATA: BEGIN OF ITAB_R2 OCCURS 10000,
      PGMID LIKE E071-PGMID,
      OBJECT LIKE E071-OBJECT,
      OBJNAME(50),
      TRKORR LIKE E071-TRKORR,
END OF ITAB_R2.
* The table of the merged results
DATA: BEGIN OF ITAB_3 OCCURS 100,
      TRKORR_1 LIKE E071-TRKORR,
      TRKORR_2 LIKE E071-TRKORR,
      P_O_N(60),
      TABKEY_1(60),
      TABKEY_2(60),
END OF ITAB_3.

*Use this part of the code to initially create the db. links
*exec sql.
*  create
*      database link ld1 connect to sapr3 identified by pwd using 'DV2'
* endexec.
*  exec sql.
*    create
*       database link ld2 connect to sapr3 identified by pwd using 'DV1'
*  endexec.
*exit.

* Read the file of system #1
OPEN DATASET FILE_1 FOR INPUT IN TEXT MODE.
DO.
  READ DATASET FILE_1 INTO TRNUM.
  IF SY-SUBRC <> 0. EXIT. ENDIF.
  CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
       EXPORTING
            PERCENTAGE = ''
            TEXT       = TRNUM.
  PERFORM REMOTE_SELECT_1.
ENDDO.
CLOSE DATASET FILE_1.

* Read the file of system #2
OPEN DATASET FILE_2 FOR INPUT IN TEXT MODE.
DO.
  READ DATASET FILE_2 INTO TRNUM.
  IF SY-SUBRC <> 0. EXIT. ENDIF.
  CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
       EXPORTING
            PERCENTAGE = ''
            TEXT       = TRNUM.

  PERFORM REMOTE_SELECT_2.
ENDDO.
CLOSE DATASET FILE_2.

CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
       EXPORTING
            PERCENTAGE = ''
            TEXT       = 'Processing the internal tables'.
* Merge itab_1 and itab_2 to itab_3
LOOP AT ITAB_1.
  LOOP AT ITAB_2 WHERE
    PGMID = ITAB_1-PGMID AND
    OBJECT = ITAB_1-OBJECT AND
    OBJNAME = ITAB_1-OBJNAME.
    IF ITAB_2-OBJFUNC = 'K'.
      IF ITAB_1-TABKEY CP ITAB_2-TABKEY OR
      ITAB_2-TABKEY CP ITAB_1-TABKEY.
        ITAB_3-TRKORR_1 = ITAB_1-TRKORR.
        ITAB_3-TRKORR_2 = ITAB_2-TRKORR.
        ITAB_3-P_O_N = ITAB_1-PGMID.
        ITAB_3-P_O_N+5 = ITAB_1-OBJECT.
        ITAB_3-P_O_N+10 = ITAB_1-OBJNAME.
        ITAB_3-TABKEY_1 = ITAB_1-TABKEY.
        ITAB_3-TABKEY_2 = ITAB_2-TABKEY.
        APPEND ITAB_3.
      ENDIF.
    ELSE.
      CLEAR ITAB_3.
      ITAB_3-TRKORR_1 = ITAB_1-TRKORR.
      ITAB_3-TRKORR_2 = ITAB_2-TRKORR.
      ITAB_3-P_O_N = ITAB_1-PGMID.
      ITAB_3-P_O_N+5 = ITAB_1-OBJECT.
      ITAB_3-P_O_N+10 = ITAB_1-OBJNAME.
      APPEND ITAB_3.
    ENDIF.
  ENDLOOP.
ENDLOOP.
* Print the header lines
WRITE: / 'Conflicting transport objects'.
SKIP.
WRITE: / 'Transport from system #1' COLOR 1.
WRITE: / 'Transport from system #2' COLOR 6.
WRITE: / 'Object                  ' COLOR 5.
WRITE: / 'Customization object key' COLOR 2.
SKIP.
* Creat a list based upon itab_3
SORT ITAB_3 BY TRKORR_1 TRKORR_2 P_O_N.
LOOP AT ITAB_3.
  AT NEW TRKORR_1.
    SKIP.
    WRITE: / ITAB_3-TRKORR_1 COLOR 1.
  ENDAT.
  AT NEW TRKORR_2.
    WRITE: /5 ITAB_3-TRKORR_2 COLOR 6.
  ENDAT.
  AT NEW P_O_N.
    WRITE: /10 ITAB_3-P_O_N COLOR 5.
  ENDAT.
  IF NOT ITAB_3-TABKEY_1 IS INITIAL OR NOT ITAB_3-TABKEY_1 IS INITIAL.
    WRITE: /15 ' ' COLOR 1 NO-GAP, 16 ITAB_3-TABKEY_1 COLOR 2.
    WRITE: /15 ' ' COLOR 6 NO-GAP, 16 ITAB_3-TABKEY_2 COLOR 2.
  ENDIF.
ENDLOOP.

*---------------------------------------------------------------------*
*       FORM REMOTE_SELECT_1                                          *
*---------------------------------------------------------------------*
FORM REMOTE_SELECT_1.
  EXEC SQL PERFORMING KULSO_LOOP.
    SELECT   PGMID, OBJECT, OBJ_NAME, OBJFUNC
             INTO :PGMID, :OBJECT, :OBJNAME, :OBJFUNC
             FROM E071@LD1 WHERE TRKORR = :TRNUM
  ENDEXEC.
ENDFORM.
*---------------------------------------------------------------------*
*       FORM KULSO_LOOP                                               *
*---------------------------------------------------------------------*
FORM KULSO_LOOP.
* If the object is TABU, VDAT or TDAT (customization)
  IF OBJFUNC = 'K'.
    EXEC SQL PERFORMING BELSO_LOOP.
      SELECT   TABKEY
               INTO :TABKEY
               FROM E071K@LD1 WHERE
               TRKORR = :TRNUM AND
               PGMID = :PGMID  AND
               MASTERTYPE = :OBJECT AND
               MASTERNAME = :OBJNAME
    ENDEXEC.
* Repository objects (no CORR: transport that contains other transport)
  ELSEIF PGMID <> 'CORR'.
    CLEAR ITAB_1-TRKORR.
    ITAB_1-TRKORR  = TRNUM.
    ITAB_1-PGMID   = PGMID.
    ITAB_1-OBJECT  = OBJECT.
    ITAB_1-OBJNAME = OBJNAME.
    ITAB_2-OBJFUNC = ''.
    COLLECT ITAB_1.
  ENDIF.
ENDFORM.
*---------------------------------------------------------------------*
*       FORM BELSO_LOOP                                               *
*---------------------------------------------------------------------*
FORM BELSO_LOOP.
  ITAB_1-TRKORR  = TRNUM.
  ITAB_1-PGMID   = PGMID.
  ITAB_1-OBJECT  = OBJECT.
  ITAB_1-OBJNAME = OBJNAME.
  ITAB_2-OBJFUNC = 'K'.
  ITAB_1-TABKEY  = TABKEY+3.
  COLLECT ITAB_1.
ENDFORM.

*---------------------------------------------------------------------*
*       FORM REMOTE_SELECT_2                                          *
*---------------------------------------------------------------------*
FORM REMOTE_SELECT_2.
  EXEC SQL PERFORMING KULSO_LOOP_2.
    SELECT   PGMID, OBJECT, OBJ_NAME, OBJFUNC
             INTO :PGMID, :OBJECT, :OBJNAME, :OBJFUNC
             FROM E071@LD2 WHERE TRKORR = :TRNUM
  ENDEXEC.
ENDFORM.
*---------------------------------------------------------------------*
*       FORM KULSO_LOOP_2                                             *
*---------------------------------------------------------------------*
FORM KULSO_LOOP_2.
* If the object is TABU, VDAT or TDAT (customization)
  IF OBJFUNC = 'K'.
    EXEC SQL PERFORMING BELSO_LOOP_2.
      SELECT   TABKEY
               INTO :TABKEY
               FROM E071K@LD2 WHERE
               TRKORR = :TRNUM AND
               PGMID = :PGMID  AND
               MASTERTYPE = :OBJECT AND
               MASTERNAME = :OBJNAME
    ENDEXEC.

* Repository objects (no CORR: transport that contains other transport)
  ELSEIF PGMID <> 'CORR'.
    CLEAR ITAB_2-TRKORR.
    ITAB_2-TRKORR  = TRNUM.
    ITAB_2-PGMID   = PGMID.
    ITAB_2-OBJECT  = OBJECT.
    ITAB_2-OBJFUNC = ''.
    ITAB_2-OBJNAME = OBJNAME.
    COLLECT ITAB_2.
  ENDIF.
ENDFORM.
*---------------------------------------------------------------------*
*       FORM BELSO_LOOP_2                                              *
*---------------------------------------------------------------------*
FORM BELSO_LOOP_2.
  ITAB_2-TRKORR  = TRNUM.
  ITAB_2-PGMID   = PGMID.
  ITAB_2-OBJECT  = OBJECT.
  ITAB_2-OBJNAME = OBJNAME.
  ITAB_2-OBJFUNC = 'K'.
  ITAB_2-TABKEY  = TABKEY+3.
  COLLECT ITAB_2.
ENDFORM.
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 -> Transport and Upgrade | Транспорт и Обновления 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.