Foro -Documentación -Código fuente -Contacto -Empleo

Buscar

Traducir

Amazon

ZTPTOBUF PDF Imprimir E-mail
Usar puntuación: / 0
MaloBueno 
Código fuente - Utilidades varias
Viernes, 27 de Febrero de 2004 10:03
Add change-requests to selected import buffer(s)
REPORT ZTPTOBUF MESSAGE-ID 38 NO STANDARD PAGE HEADING.

************************************************************************
*  Change request overview - Import to systems in TPPARAM              *
************************************************************************
*  Author                                                              *
*    Tomas Gustafsson - Implema AB                                     *
*  Description                                                         *
*    This is only a template. No support is given for this function!!! *
*                                                                      *
*    The program reads all released change request of the entered user *
*    The selected change request are then added to the import-buffer   *
*    of the target system.                                             *
************************************************************************

*----------------------------------------------------------------------*
* Ver Date     Who         What                                        *
*----------------------------------------------------------------------*
* 002 19980605 Tomas.G     Support for hostname longer than 8 char     *
* 003                                                                  *
*----------------------------------------------------------------------*

TABLES: TSYST,     " Systems
         E070,      " Change Requests and Tasks
         E07T.      " Change Request and Task texts

DATA I_TSYST LIKE TSYST OCCURS 0 WITH HEADER LINE. "Tables for main list
DATA I_E070  LIKE E070  OCCURS 0 WITH HEADER LINE. "Tables for main list
DATA I_E07T  LIKE E07T  OCCURS 0 WITH HEADER LINE. "Tables for main list


DATA: BEGIN OF I_SEL_TSYST OCCURS 0,"Table containing selected systems
         SYSNAME LIKE TSYST-SYSNAME,
      END OF I_SEL_TSYST,

      BEGIN OF I_SEL_E070 OCCURS 0, "Table containing selected requests
         TRKORR LIKE E070-TRKORR,
      END OF I_SEL_E070.

DATA: SELECT_LINE,                  "Line selected or not (' '/'X')
       MESSAGE_TEXT(20) VALUE 'Press F8 to continue', 
       LOCAL_REQUEST(9),             "Local SID plus % for generic read
       SELECT_ALL_SYSTEMS.           "Chose to add to all systems ?

* Result from os call in table form.
DATA: OS_RESULT LIKE BTCXPM OCCURS 0 WITH HEADER LINE,
       OS_CALL_STATUS LIKE BTCXP3-EXITSTAT. "Status from os call

DATA  TP_PARAMETER LIKE SXPGCOLIST-PARAMETERS. "parameters sent to tp

DATA: BEGIN OF VERSION_INFO OCCURS 0,
           "002
         LINE(80),
           "002
      END OF VERSION_INFO.
           "002

DATA: TARGET_SYSTEM LIKE BTCXP1-RECEIVER.
           "002

INCLUDE <SYMBOL>.                   "In order to print symbols

PARAMETERS: USERNAME LIKE SY-UNAME DEFAULT SY-UNAME.

START-OF-SELECTION.
* Check Authorization (Should be equal to SPAM)
   AUTHORITY-CHECK OBJECT 'S_TRANSPRT' 
                  ID 'TTYPE' FIELD 'UPGR'       "Upgrade/Installation
                  ID 'ACTVT' FIELD '61'.         "Export
  IF SY-SUBRC NE 0.
     MESSAGE E016 WITH 'You are not authorized to run this program'. 
  ENDIF.

* Read hostname (SY-HOST only support up to 8 char.)            "002
  CALL 'SAPCORE'  ID 'ID' FIELD 'VERSION'                        "002
                 ID 'TABLE' FIELD VERSION_INFO-*SYS*.           "002
  READ TABLE VERSION_INFO INDEX  8.                             "002
   TARGET_SYSTEM = VERSION_INFO-LINE+21(20).                     "002

* Create generic key for change requests in current system
  CONCATENATE SY-SYSID '%'  INTO LOCAL_REQUEST.
  CONDENSE LOCAL_REQUEST NO-GAPS.

  PERFORM READ_REQUESTS.
* Read all systems, except current and SAP
  PERFORM READ_SID_FROM_TPPARAM.
  LOOP AT I_TSYST WHERE SYSNAME EQ SY-SYSID OR SYSNAME EQ 'SAP'.
    DELETE I_TSYST.
  ENDLOOP.

* Write information about which function key to press
  PERFORM INFO_F8.
  SKIP.

* First list available systems
   ULINE.
   I_TSYST-SYSNAME = 'ALL'. 
  WRITE: /   'Please select system(s)             select', 
          (3) I_TSYST-SYSNAME,
              SELECT_LINE AS CHECKBOX.
   ULINE.
  SKIP.

  LOOP AT I_TSYST.
    WRITE: /     SELECT_LINE AS CHECKBOX,
                  I_TSYST-SYSNAME,
            (50)  I_TSYST-DDTEXT.
  ENDLOOP.

* List available change requests, sorted by user.
  SKIP.
   ULINE.
  WRITE: / 'Please select change request(s)'. 

  LOOP AT I_E070.
     ON CHANGE OF I_E070-AS4USER.
       ULINE.
      SKIP.
      WRITE:: 'Requests changed by'. 
       FORMAT INTENSIFIED ON.
      WRITE: I_E070-AS4USER.
       FORMAT INTENSIFIED OFF.
       ULINE.
     ENDON.

    READ TABLE I_E07T WITH KEY LANGU = SY-LANGU TRKORR = I_E070-TRKORR.
    IF SY-SUBRC NE 0.
       I_E07T-AS4TEXT = 'Not found in logon language'. 
    ENDIF.
    WRITE: /    SELECT_LINE AS CHECKBOX,
                 I_E070-TRKORR,
                 I_E070-AS4DATE DD/MM/YYYY,
            (50) I_E07T-AS4TEXT.
  ENDLOOP.
   ULINE.

* Write information about which function key to press once more
  SKIP.
  PERFORM INFO_F8.

AT PF08.
* Check that user press F8 only at first screen.
   CHECK SY-LSIND = 1.
* Clear internal "work" tables
  REFRESH I_SEL_TSYST.
  REFRESH I_SEL_E070.

   SELECT_ALL_SYSTEMS = 'N'. 
* Read all lines of list and check if line where selected.
  DO.
     MOVE SPACE TO: I_E070-TRKORR,
                    I_TSYST-SYSNAME,
                    SELECT_LINE.
    READ LINE SY-INDEX FIELD VALUE SELECT_LINE
                                    I_E070-TRKORR
                                    I_TSYST-SYSNAME.
*   Avoid endless loop
    IF SY-SUBRC NE 0.
      EXIT.
    ENDIF.

*   Filter unselected lines
     CHECK SELECT_LINE = 'X'. 

*   System found ?
    IF SELECT_ALL_SYSTEMS = 'N'. 
      IF I_TSYST-SYSNAME NE SPACE.
        IF I_TSYST-SYSNAME EQ 'ALL'. 
           SELECT_ALL_SYSTEMS = 'Y'. 
          LOOP AT I_TSYST.
             I_SEL_TSYST-SYSNAME = I_TSYST-SYSNAME.
            APPEND I_SEL_TSYST.
          ENDLOOP.
        ELSE.
           I_SEL_TSYST-SYSNAME = I_TSYST-SYSNAME.
          APPEND I_SEL_TSYST.
        ENDIF.
      ENDIF.
    ENDIF.

*   Change request found ?
    IF I_E070-TRKORR NE SPACE.
       I_SEL_E070-TRKORR = I_E070-TRKORR.
      APPEND I_SEL_E070.
    ENDIF.
  ENDDO.

* Check if any system where selected
  READ TABLE I_SEL_TSYST INDEX 1.
  IF SY-SUBRC NE 0.
    WRITE: / 'Please select at least one system'. 
     CHECK 1 = 0.
  ENDIF.
* Check if any change request where selected
  READ TABLE I_SEL_E070 INDEX 1.
  IF SY-SUBRC NE 0.
    WRITE: / 'Please select at least one change request'. 
     CHECK 1 = 0.
  ENDIF.

* Write information about which function key to press
  PERFORM INFO_F20.

* Write selected system(s)
  SKIP 2.
  WRITE: / 'The following target system(s) where selected'. 
   ULINE.
  LOOP AT I_SEL_TSYST.
    WRITE / I_SEL_TSYST-SYSNAME.
  ENDLOOP.
   ULINE.

* Write selected change request(s)
  SKIP 2.
  WRITE: / 'The following change request(s) where selected'. 
   ULINE.
  LOOP AT I_SEL_E070.
    WRITE / I_SEL_E070-TRKORR.
  ENDLOOP.
   ULINE.

* Write information about which function key to press
  SKIP 2.
  PERFORM INFO_F20.

AT PF20.
* Check that user press F8 only at first screen.
   CHECK SY-LSIND = 2.

* For every change request, add it to buffer of every system
* Note: Only for selected systems and change requests.
  LOOP AT I_SEL_E070.
    LOOP AT I_SEL_TSYST.
*     Create parameters for tp
      CLEAR TP_PARAMETER.
      CONCATENATE 'addtobuffer' 
                   I_SEL_E070-TRKORR
                   I_SEL_TSYST-SYSNAME
                  INTO TP_PARAMETER SEPARATED BY ' '. 
      CONDENSE TP_PARAMETER.

       FORMAT INTENSIFIED ON.
      WRITE: / 'tp',  (40) TP_PARAMETER.
       FORMAT INTENSIFIED OFF.

      PERFORM CALL_TP.
      IF OS_CALL_STATUS EQ 'E'. 
         FORMAT INTENSIFIED ON.
        LOOP AT OS_RESULT. WRITE: / OS_RESULT-MESSAGE. ENDLOOP.
         FORMAT INTENSIFIED OFF.
      ELSE.
        LOOP AT OS_RESULT. WRITE: / OS_RESULT-MESSAGE. ENDLOOP.
      ENDIF.
      SKIP.
    ENDLOOP.
  ENDLOOP.

*----------------------------------------------------------------------*
*       FORM READ_REQUEST                                              *
*----------------------------------------------------------------------*
*       Read released change request. Either all or for one user       *
*       Sorting:                                                       *
*         Username         ascending                                   *
*         Change request   descending                                  *
*----------------------------------------------------------------------*
*  -->  p1        text                                                 *
*  <--  p2        text                                                 *
*----------------------------------------------------------------------*
FORM READ_REQUESTS.
  IF USERNAME EQ SPACE.
  SELECT * FROM E070 INTO TABLE I_E070
                        WHERE TRKORR LIKE LOCAL_REQUEST
                        AND   TRSTATUS EQ 'R' 
                        AND   TRFUNCTION IN ('K','W','C','T')
                         ORDER BY AS4USER ASCENDING TRKORR DESCENDING.
  ELSE.
    SELECT * FROM E070 INTO TABLE I_E070
                        WHERE TRKORR LIKE LOCAL_REQUEST
                        AND   TRSTATUS EQ 'R' 
                        AND   TRFUNCTION IN ('K','W','C','T')
                        AND   AS4USER = USERNAME
                         ORDER BY AS4USER ASCENDING TRKORR DESCENDING.
  ENDIF.
  IF SY-SUBRC NE 0.
    WRITE: / 'No released change requests found', 
           / 'Check if the Correction and Transport system is setup'. 
    STOP.
  ENDIF.

* Read change request texts
  SELECT * FROM E07T INTO TABLE I_E07T
                      FOR ALL ENTRIES IN I_E070
                      WHERE LANGU = SY-LANGU
                      AND   TRKORR = I_E070-TRKORR.
ENDFORM.

*----------------------------------------------------------------------*
*       FORM CALL_TP                                                   *
*----------------------------------------------------------------------*
*       Call program tp via operating system                           *
*----------------------------------------------------------------------*
*  -->  tp_parameter     *  the parameter for tp. E g "showbuffer C11" *
*  <--  os_call_status   *  returned os-call status O=Ok E=Error       *
*  <--  os_result        *  internal table with output from call       *
*----------------------------------------------------------------------*
FORM CALL_TP.
    CALL FUNCTION 'SXPG_COMMAND_EXECUTE' 
         EXPORTING
               COMMANDNAME = 'ZTP' 
               ADDITIONAL_PARAMETERS = TP_PARAMETER
               TARGETSYSTEM = TARGET_SYSTEM      "002
         IMPORTING
               STATUS = OS_CALL_STATUS
         TABLES
               EXEC_PROTOCOL = OS_RESULT
         EXCEPTIONS
               NO_PERMISSION = 1
               COMMAND_NOT_FOUND = 2
               PARAMETERS_TOO_LONG = 3
               SECURITY_RISK = 4
               WRONG_CHECK_CALL_INTERFACE = 5
               PROGRAM_START_ERROR = 6
               PROGRAM_TERMINATION_ERROR = 7
               X_ERROR = 8
               PARAMETER_EXPECTED = 9
               TOO_MANY_PARAMETERS = 10
               ILLEGAL_COMMAND = 11
               WRONG_ASYNCHRONOUS_PARAMETERS = 12
               CANT_ENQ_TBTCO_ENTRY = 13
               JOBCOUNT_GENERATION_ERROR = 14
               OTHERS = 15.
ENDFORM.

*----------------------------------------------------------------------*
*       FORM READ_SID_FROM_TPPARAM                                     *
*----------------------------------------------------------------------*
*       Read system names from TPPARAM files (TSYST not up-to-date.    *
*----------------------------------------------------------------------*
*  <--  i_tsyst    * Interna table with system names                   *
*----------------------------------------------------------------------*
FORM READ_SID_FROM_TPPARAM.
  DATA: TEXTLINE(255),
         TEMP_LENGTH LIKE SY-FDPOS,
*       Yes, I know. It's quick and it's dirty....
         FILENAME(64) VALUE '/usr/sap/trans/bin/TPPARAM'. 

  REFRESH I_TSYST.
   OPEN DATASET FILENAME IN TEXT MODE FOR INPUT.
  DO.
    READ DATASET FILENAME INTO TEXTLINE.
    IF SY-SUBRC NE 0.
      EXIT.
    ENDIF.
     CHECK TEXTLINE(1) NE '#'. 
    IF TEXTLINE CS '/dbhost'. 
       TEMP_LENGTH = SY-FDPOS.
       MOVE TEXTLINE(TEMP_LENGTH) TO I_TSYST-SYSNAME.
      CONDENSE I_TSYST-SYSNAME.
      APPEND I_TSYST.
    ENDIF.
  ENDDO.
   CLOSE DATASET FILENAME.

* Check if any system was found
  READ TABLE I_TSYST INDEX 1.
  IF SY-SUBRC NE 0.
    WRITE: / 'No systems found in file TPPARAM'. 
    STOP.
  ENDIF.
ENDFORM.

*----------------------------------------------------------------------*
*       FORM INFO_F8                                                   *
*----------------------------------------------------------------------*
*       Tell user to use F8 to continue                                *
*----------------------------------------------------------------------*
FORM INFO_F8.
   FORMAT INTENSIFIED ON.
  WRITE: /  SYM_RIGHT_HAND AS SYMBOL,
          5  'Press F8 to continue', 
          27 SYM_LEFT_HAND AS SYMBOL.
   FORMAT INTENSIFIED OFF.
ENDFORM.

*----------------------------------------------------------------------*
*       FORM INFO_F20                                                  *
*----------------------------------------------------------------------*
*       Tell user to use F20 to continue                               *
*----------------------------------------------------------------------*
FORM INFO_F20.
   FORMAT INTENSIFIED ON.
  WRITE: /  SYM_RIGHT_HAND AS SYMBOL,
          5  'Press F20 (shift+F8) to continue', 
          40 SYM_LEFT_HAND AS SYMBOL.
   FORMAT INTENSIFIED OFF.
ENDFORM.

*** End of ZTPTOBUF ***
Comentarios
Buscar
¡Sólo los usuarios registrados pueden escribir comentarios!

3.26 Copyright (C) 2008 Compojoom.com / Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved."

 
home search