Mass Change SAP Printer in Job Steps Program

After some years, many SAP printers have been defined for many background job steps and when there came a user request to change the SAP printers, it is going to be a tedious process.  

This is a reference abap program to mass change sap printers in many of the background job steps.

REPORT zjobstepsmasschange MESSAGE-ID zbs_job LINE-SIZE 132.
*&---------------------------------------------------------------------*
*& Report  zjobstepsmasschange                                         *
*&---------------------------------------------------------------------*

TABLES:
        tsp03,                         "Spool Drucker-Deklaration
        usr02,                         "Logon-Daten
        tbtco.                         "Job-Zustandsübersichts-Tabelle
*        tbtcp.                        "Step-Uebersicht eines Batch-Jobs

DATA: "mögliche Programm- bzw. Stepstatus
  btc_running       LIKE tbtco-status VALUE 'R',
  btc_ready         LIKE tbtco-status VALUE 'Y',
  btc_scheduled     LIKE tbtco-status VALUE 'P',
  btc_released      LIKE tbtco-status VALUE 'S',
  btc_aborted       LIKE tbtco-status VALUE 'A',
  btc_finished      LIKE tbtco-status VALUE 'F',
  btc_put_active    LIKE tbtco-status VALUE 'Z',
  btc_unknown_state LIKE tbtco-status VALUE 'X'.

TYPES:                                                      "
  BEGIN OF tjob,
    jobname    LIKE tbtco-jobname,   "Job-Name
    jobcount   LIKE tbtco-jobcount,  "Job-Nummer
    sdluname   LIKE tbtco-sdluname,  "Job-Ersteller
    lastchname LIKE tbtco-lastchname,"Letzter Änderer        KXXX928655
    status     LIKE tbtco-status,    "Job-Status             KXXX927829
    jobclass   LIKE tbtco-jobclass,  "Jobklasse              KXXX928655
    execserver LIKE tbtco-execserver,"vorgeg. Ausf.-Server   KXXX931511
  END   OF tjob.

*TYPES:
* BEGIN OF tstep,                                        "KXXX939074
*   jobname   LIKE tbtcp-jobname,    "Job-Name
*   jobcount  LIKE tbtcp-jobcount,   "Job-Nummer
*   stepcount LIKE tbtcp-stepcount,  "Jobstep-Nummer
*   pdest     LIKE tbtcp-pdest,      "Ausgabegerät
*   authcknam LIKE tbtcp-authcknam,  "Benutzername im Step
*   pexpi     LIKE tbtcp-pexpi,      "Spool-Verweildauer,
*   priparkey like tbtcp-priparkey,  "Print parameters
* END OF tstep.                                          "KXXX939074

* DATA:               "Liste aller Jobs (mit fehlerhaften Drucker-Namen)
*      BEGIN OF jobs OCCURS 0,
*        jobname  LIKE tbtco-jobname,   "Job-Name
*        jobcount LIKE tbtco-jobcount,  "Job-Nummer
*        sdluname LIKE tbtco-sdluname,  "Job-Ersteller
*        lastchng LIKE tbtco-lastchname,"Letzter Änderer     KXXX928655
*        status   LIKE tbtco-status,    "Job-Status          KXXX927829
*        jclass   LIKE tbtco-jobclass,  "Jobklasse           KXXX928655
*      END   OF jobs.

CONSTANTS:
* Possible values for spool retention period:
ret_time TYPE string VALUE '123456789',                     "KXXX939074
* Possible Job Classes:
jclasses TYPE string VALUE 'ABC'.                           "KXXX939176

DATA:
  i_jobs TYPE STANDARD TABLE OF tjob
         INITIAL SIZE 1
         VALUE IS INITIAL,
  wa_job TYPE tjob.           "Ausgabebereich fuer Tabelle I_JOBS

DATA:
  i_jobsteps TYPE SORTED TABLE OF tbtcp                     "KXXX939074
             WITH UNIQUE KEY jobname jobcount stepcount
             INITIAL SIZE 1
             VALUE IS INITIAL,
  wa_jobstep TYPE tbtcp VALUE IS INITIAL.  "Ausgabebereich   KXXX939074

DATA:
*    i TYPE i,                         "Zähler
    nr_schedule TYPE i, "Anzahl geplanter Jobs               KXXX931800
    nr_released TYPE i, "Anzahl freigegebener Jobs           KXXX931800
    nr_suspendt TYPE i. "Anzahl suspendierter Jobs           KXXX931800

DATA:
    pri_params LIKE pri_params,      "für Checksummen
    arc_params LIKE arc_params,
    checksum   TYPE i.

DATA:                                                       "KXXX920914
    gs_pripar    TYPE pri_params,                           "KXXX920914
    gv_text(132) TYPE c,                                    "KXXX920914
    stepchng(1)  TYPE c VALUE IS INITIAL,                   "KXXX939074
    auxtext      TYPE string.                               "KXXX939176

* DATA: auxclass LIKE tbtco-jobclass, "Hilfsfeld f. Jobkl.   KXXX928655
*      auxcgusr LIKE tbtco-lastchname."Hilfsfeld f. letz.Änd. KXXX928655

SELECTION-SCREEN BEGIN OF BLOCK block_1 WITH FRAME TITLE text-101.
SELECT-OPTIONS:
    s_jobnam FOR  tbtco-jobname,            "Job-Namen
    s_crtusr FOR  tbtco-sdluname,           "Job-Ersteller KXXX928655
    s_lstchg FOR  tbtco-lastchname,         "letzt. Änd.   KXXX928655
*             DEFAULT sy-uname,              "aktuell. User KXXX928879
    s_tgtsrv FOR  tbtco-execserver          "Ziel-Server   KXXX931511
             DEFAULT ' ',
    s_jcls   FOR  tbtco-jobclass.           "Jobklasse     KXXX928655

PARAMETERS:
    schedule AS CHECKBOX DEFAULT 'X',         "Geplante Jobs
    released AS CHECKBOX DEFAULT ' ',         "Freigegebene Jobs
    suspendt AS CHECKBOX DEFAULT ' '.         "Suspended Jobs KXXX931341

SELECTION-SCREEN END OF BLOCK block_1.

SELECTION-SCREEN BEGIN OF BLOCK block_2 WITH FRAME TITLE text-102.
PARAMETERS:
*   neuer Benutzer im Step:
*   stepuser LIKE usr02-bname OBLIGATORY DEFAULT sy-uname,  "KXXX928879
    stepuser LIKE usr02-bname,                              "KXXX928879
*   neuer Druckername:
    p_dest  LIKE tsp03-padest,
*   neue Spool-Verweildauer:
    p_pexpi TYPE pexpi,                                     "KXXX938946
*   neuer Job-Ersteller:
*   newcrusr LIKE usr02-bname OBLIGATORY DEFAULT sy-uname,
    newcrusr LIKE usr02-bname,                              "KXXX928879
*   letzter Job-Änderer:
    newcgusr LIKE usr02-bname OBLIGATORY DEFAULT sy-uname,  "KXXX928655
*   neue Jobklasse:
    p_newcls LIKE tbtco-jobclass.
                                                            "KXXX928655
SELECTION-SCREEN END OF BLOCK block_2.

SELECTION-SCREEN BEGIN OF BLOCK block_3.
PARAMETERS testonly AS CHECKBOX DEFAULT 'X'. "Testschalter
SELECTION-SCREEN END OF BLOCK block_3.
 

*&---------------------------------------------------------------------*
*&                         AT SELECTION-SCREEN                         *
*&---------------------------------------------------------------------*

* Prüfung der Änderungen im Job:

* Prüfung, ob User-Id des neuen Job-Erstellers existiert:     KXXX939176
AT SELECTION-SCREEN ON newcrusr.
  IF newcrusr IS NOT INITIAL.
    SELECT SINGLE * FROM usr02 WHERE bname = newcrusr.
    IF sy-subrc NE 0.
      MESSAGE w173 WITH newcrusr.
    ENDIF.
  ENDIF.

* Prüfung, ob User-Id des neuen Job-Änderers existiert:       KXXX939176
AT SELECTION-SCREEN ON newcgusr.
  IF newcgusr IS NOT INITIAL.
    SELECT SINGLE * FROM usr02 WHERE bname = newcgusr.
    IF sy-subrc NE 0.
      MESSAGE e173 WITH newcgusr.
    ENDIF.
  ENDIF.

* Prüfung, ob gültige neue Jobklasse:                         KXXX939176
AT SELECTION-SCREEN ON p_newcls.
  IF ( p_newcls IS NOT INITIAL ) AND ( p_newcls CN jclasses ).
    CLEAR auxtext.
    CONCATENATE text-022 p_newcls INTO auxtext SEPARATED BY space.
    MESSAGE auxtext TYPE 'E'.
  ENDIF.
 

* Prüfung der Änderungen in Job-Steps:

* Prüfung, ob neuer Benutzer im Step existiert:               KXXX939176
AT SELECTION-SCREEN ON stepuser.
  IF stepuser IS NOT INITIAL.
    SELECT SINGLE * FROM usr02 WHERE bname = stepuser.
    IF sy-subrc EQ 0.
      stepchng = 'X'.
    ELSE.
      MESSAGE e173 WITH stepuser.
    ENDIF.
  ENDIF.

* Prüfung, ob vorgegebene Spool-Verweildauer numerisch ist:   KXXX939176
AT SELECTION-SCREEN ON p_pexpi.
  IF p_pexpi IS NOT INITIAL.
    IF p_pexpi CO ret_time.
      stepchng = 'X'.
    ELSE.
      CLEAR auxtext.
      CONCATENATE text-021 p_pexpi INTO auxtext SEPARATED BY space.
      MESSAGE auxtext TYPE 'E'. "Ungültige Spool-Verweildauer
    ENDIF.
  ENDIF.
 

*&---------------------------------------------------------------------*
*&                         START-OF-SELECTION                          *
*&---------------------------------------------------------------------*
* los geht's
START-OF-SELECTION.
*
  TRANSLATE s_crtusr TO UPPER CASE.                         "KXXX928655
  TRANSLATE s_lstchg TO UPPER CASE.                         "KXXX928655
  TRANSLATE s_tgtsrv TO UPPER CASE.                         "KXXX931511
  TRANSLATE s_jcls   TO UPPER CASE.                         "KXXX928655
  TRANSLATE stepuser TO UPPER CASE.
  TRANSLATE p_dest   TO UPPER CASE.                         "KXXX939074
  TRANSLATE newcrusr TO UPPER CASE.
  TRANSLATE newcgusr TO UPPER CASE.                         "KXXX928655
  TRANSLATE p_newcls TO UPPER CASE.                         "KXXX928655
  TRANSLATE testonly TO UPPER CASE.                         "KXXX939074

* Dynamische Listenüberschrift:
  IF testonly EQ space.
    MOVE 'Job-Änderungen:'(112) TO sy-tvar0.
  ELSE.
    MOVE 'TESTLAUF'(110) TO sy-tvar0.
  ENDIF.

* Neue Regel: AV darf das Programm auch in Produktion starten
* AUTHORITY-CHECK OBJECT 'S_BTCH_NAM' ID 'BTCUNAME' FIELD 'BATCHUSR'.

  CLEAR: sy-subrc.
* Berechtigungsprüfung nur, wenn User im Step auf anderen als
* startenden User geändert wird:                             KXXX929808
  IF ( stepuser IS NOT INITIAL ) AND ( stepuser NE sy-uname ).
    AUTHORITY-CHECK OBJECT 'S_BTCH_NAM' ID 'BTCUNAME' FIELD stepuser.
  ENDIF.

  IF sy-subrc <> 0.
    CASE sy-sysid(1).                                       "KXXX929831
      WHEN 'P'.                 "Abbruchmeldung in Produktivsystemen
        MESSAGE a099
        WITH text-010.
      WHEN OTHERS.              "Warnmeldung in anderen Systemen
        MESSAGE w099
        WITH text-012.
    ENDCASE.                                                "KXXX929831
  ENDIF.
 

  CLEAR: sy-subrc.

* Nur Batch-Administratoren dürfen Jobkl. A oder B setzen:   KXXX928655
  IF ( p_newcls = 'A' OR p_newcls = 'B' ).
    AUTHORITY-CHECK OBJECT 'S_BTCH_ADM' ID 'BTCADMIN' FIELD 'Y'.
  ENDIF.

  IF sy-subrc <> 0.
    MESSAGE a099
    WITH text-020.
  ENDIF.                                                    "KXXX928655

* Eingaben prüfen;
* Fehler ausgeben und Parameter neu setzen, wenn gewünscht

* Änderungen in Job-Steps:

  IF NOT p_dest IS INITIAL.           "Neuer Druckername angegeben
    CLEAR: sy-subrc.                                        "KXXX929831
    SELECT SINGLE * FROM tsp03 WHERE padest = p_dest.
    IF sy-subrc EQ 0.                                       "KXXX939074
      stepchng = 'X'.                                       "KXXX939074
    ELSE.                                                   "KXXX939074
*    IF sy-subrc <> 0.
      FORMAT COLOR = 6. "Rot                                 KXXX939074
      WRITE: / 'Drucker'(001), p_dest, 'nicht vorhanden !'(003).
      FORMAT COLOR OFF.                                     "KXXX931810
      EXIT.
    ENDIF.
  ENDIF.

* alle geplanten Jobs holen:                                 KXXX927829
  IF schedule = 'X'.
    SELECT * FROM tbtco                                     "KXXX928655
    APPENDING CORRESPONDING FIELDS OF TABLE i_jobs          "KXXX928655
                    WHERE jobname  IN s_jobnam              "KXXX928655
                    AND   status   EQ btc_scheduled         "KXXX928655
                    AND   sdluname IN s_crtusr              "KXXX928655
                    AND lastchname IN s_lstchg              "KXXX928655
                    AND jobclass   IN s_jcls                "KXXX928655
                    AND execserver IN s_tgtsrv              "KXXX931511
              ORDER BY jobname.                             "KXXX928655
    MOVE sy-dbcnt TO nr_schedule.                           "KXXX931800
  ENDIF.

* alle freigegebenen Jobs holen:                             KXXX927829
  IF released = 'X'.
    SELECT * FROM tbtco                                     "KXXX928655
    APPENDING CORRESPONDING FIELDS OF TABLE i_jobs          "KXXX928655
                    WHERE jobname  IN s_jobnam              "KXXX928655
                    AND   status   EQ btc_released          "KXXX928655
                    AND   sdluname IN s_crtusr              "KXXX928655
                    AND lastchname IN s_lstchg              "KXXX928655
                    AND jobclass   IN s_jcls                "KXXX928655
                    AND execserver IN s_tgtsrv              "KXXX931511
              ORDER BY jobname.                             "KXXX928655
    MOVE sy-dbcnt TO nr_released.                           "KXXX931800
  ENDIF.

* alle suspendierten Jobs holen:                             KXXX931341
  IF suspendt = 'X'.
    SELECT * FROM tbtco                                     "KXXX931341
    APPENDING CORRESPONDING FIELDS OF TABLE i_jobs          "KXXX931341
                    WHERE jobname  IN s_jobnam              "KXXX931341
                    AND   status   EQ btc_put_active        "KXXX931341
                    AND   sdluname IN s_crtusr              "KXXX931341
                    AND lastchname IN s_lstchg              "KXXX931341
                    AND jobclass   IN s_jcls                "KXXX931341
                    AND execserver IN s_tgtsrv              "KXXX931511
              ORDER BY jobname.                             "KXXX931341
    MOVE sy-dbcnt TO nr_suspendt.                           "KXXX931800
  ENDIF.                                                    "KXXX931341

* Keine Jobs für die gewählten Selektionskriterien gefunden: KXXX931800
  IF    ( nr_schedule EQ 0 )
    AND ( nr_released EQ 0 )
    AND ( nr_suspendt EQ 0 ).
    WRITE: / text-120 COLOR = 6 INTENSIFIED OFF.
    EXIT.
  ENDIF.
* --------------------------------------------------------  "KXXX931800

  SORT i_jobs.                                              "KXXX927829

  IF testonly NE space.        "Testlauf ohne Datenbankänderung
    FORMAT COLOR = 5 INTENSIFIED ON. "Grüner Hintergrund   KXXX931800
    WRITE: / text-110 NO-GAP, ':', text-111.
    FORMAT COLOR OFF.                                       "KXXX931800
    ULINE.                                                  "KXXX939074
    NEW-LINE.                                               "KXXX939074
  ENDIF.

  CLEAR wa_job.
  LOOP AT i_jobs INTO wa_job.

    WRITE:
     /01    wa_job-jobname,      "Job-Name                   KXXX928879
      34(8) wa_job-jobcount.     "Job-Kennnummer             KXXX928879

    CASE wa_job-status.                                     "KXXX927829
      WHEN btc_scheduled.
        WRITE 43 text-scd.            "Geplant
      WHEN btc_released.
        WRITE 43 text-rel.            "Freigegeben
      WHEN btc_put_active.                                  "KXXX931341
        WRITE 43 text-sus.            "Suspendiert           KXXX931341
      WHEN OTHERS.
        WRITE 43 text-ukn.            "Unbekannt
    ENDCASE.

    WRITE:
      52 wa_job-sdluname,       "Benutzername Job-Ersteller
      65 wa_job-lastchname,     "letzer Änderer              KXXX929831
      79 wa_job-jobclass.       "Jobklasse                   KXXX929831
 

* ---------------------------------------------------------------------
* Job-Steps aus Tabelle TBTCP lesen
    CLEAR i_jobsteps.                                       "KXXX939074
    CLEAR wa_jobstep.                                       "KXXX939074

    SELECT * FROM tbtcp
      INTO TABLE i_jobsteps
                WHERE jobname  = wa_job-jobname
                AND   jobcount = wa_job-jobcount
      ORDER BY stepcount.

    LOOP AT i_jobsteps INTO wa_jobstep.

* Obsolete section begin ----------------------------------- KXXX928879
*      WRITE:
*      /01    wa_jobstep-jobname,    "Job-Name
*       34(8) wa_jobstep-jobcount,   "Job-Kennnummer
*       43(4) wa_jobstep-stepcount,  "Jobstep-Kennnummer
*       52    wa_job-sdluname,       "Benutzername Job-Ersteller
*       67    wa_jobstep-authcknam.  "Benutzername Job-Step
* Obsolete  section end ------------------------------------ KXXX928879

*     Aktuelle Step-Daten:
      WRITE:
        /85(4)  wa_jobstep-stepcount, "Jobstep-Kennnummer   KXXX928879
         90(8)  wa_jobstep-pdest,     "Ausgabegerät         KXXX928879
        100(1)  wa_jobstep-pexpi,     "Spool-Verweildauer   KXXX938946
        105(17) wa_jobstep-authcknam. "Benutzer Job-Step    KXXX928879

* Obsolete section begin ----------------------------------- KXXX939074
*      IF    ( ( p_dest   IS INITIAL )
*          AND ( stepuser IS INITIAL )                       "KXXX929831
*          AND ( p_pexpi  IS INITIAL ) ).                    "KXXX938946
* Obsolete  section end ------------------------------------ KXXX939074

      IF stepchng NE 'X'.                                   "KXXX939074
        CONTINUE. "keine Änderungen im Step
      ENDIF.                                                "KXXX929831

*      IF NOT ( ( dest IS INITIAL ) AND ( stepuser IS INITIAL ) ).

      WRITE: / 'Job-Step geändert auf'(004) COLOR = 3.      "KXXX928879

      IF stepuser IS NOT INITIAL.
* Berechtigungsprüfung, ob der User, der diesen Report aufgerufen hat,
* den bestehenden User im Step ändern darf:
        CLEAR: sy-subrc.                                    "KXXX929827
        IF wa_jobstep-authcknam NE sy-uname.                "KXXX929827
          AUTHORITY-CHECK
              OBJECT 'S_BTCH_NAM'
              ID 'BTCUNAME'
             FIELD wa_jobstep-authcknam.                    "KXXX929827
        ENDIF.                                              "KXXX929827

        IF sy-subrc <> 0.                                   "KXXX929827
*           IF sy-sysid(1) EQ 'P'.
          MESSAGE a099                                      "KXXX929827
          WITH text-011.
*           ENDIF.                                          "KXXX929827
        ENDIF.                                              "KXXX929827

        wa_jobstep-authcknam = stepuser.      "Benutzer im Step ändern
*        WRITE: 105 wa_jobstep-authcknam COLOR = 3. "Gelb   KXXX928879
      ENDIF.

*     Programm-Testlauf ohne Datenbankänderung:
      IF testonly NE space.                                 "KXXX939074

        IF p_dest IS NOT INITIAL.
          WRITE  90(8) p_dest COLOR 3. "Gelb
        ENDIF.

        IF p_pexpi IS NOT INITIAL.
          WRITE 100(1) p_pexpi COLOR 3. "Gelb
        ENDIF.

        IF stepuser IS NOT INITIAL.
          WRITE: 105 stepuser COLOR = 3. "Gelb
        ENDIF.

        CONTINUE.
      ENDIF.                                                "KXXX939074
 

      IF ( ( p_dest IS NOT INITIAL ) OR ( p_pexpi IS NOT INITIAL ) ).
        CLEAR gs_pripar.                                    "KXXX920914

        CALL FUNCTION 'LOAD_PRINT_PARAMETERS'               "KXXX920914
          EXPORTING
            key            = wa_jobstep-priparkey
          IMPORTING
            out_parameters = gs_pripar
          EXCEPTIONS
            error_occured  = 1
            OTHERS         = 2.

        IF sy-subrc NE 0.                                   "KXXX938946
          CONCATENATE wa_jobstep-jobname text-005           "KXXX920914
                      INTO gv_text
                      SEPARATED BY space.
          WRITE gv_text.                                    "KXXX920914
          EXIT.                                             "KXXX920914
        ENDIF.                                              "KXXX920914
 

        IF p_dest IS NOT INITIAL.
*       Änderung Drucker im Step
          gs_pripar-pdest  = p_dest.                        "KXXX920914
          wa_jobstep-pdest = p_dest.                        "KXXX938946
*          WRITE: 90 p_dest COLOR = 3. "Gelb                  KXXX939074
        ENDIF.

        IF p_pexpi IS NOT INITIAL.                          "KXXX938946
*       Änderung Spool-Verweildauer
          gs_pripar-pexpi  = p_pexpi.
          wa_jobstep-pexpi = p_pexpi.
*          WRITE: 100 p_pexpi COLOR = 3. "Gelb                KXXX939074
        ENDIF.                                              "KXXX938946
 

        CALL FUNCTION 'STORE_PRINT_PARAMETERS'              "KXXX920914
          EXPORTING
            in_parameters = gs_pripar
            applikation   = 'B'
          IMPORTING
            key           = wa_jobstep-priparkey
          EXCEPTIONS
            error_occured = 1
            OTHERS        = 2.

        IF sy-subrc NE 0.                                   "KXXX938946
          CONCATENATE wa_jobstep-jobname text-006           "KXXX920914
                      INTO gv_text
                      SEPARATED BY space.
          WRITE gv_text.                                    "KXXX920914
          EXIT.                                             "KXXX920914
        ENDIF.                                              "KXXX920914

        MOVE-CORRESPONDING wa_jobstep TO pri_params.
        PERFORM compute_checksum(saplspri) USING    pri_params
                                           CHANGING checksum.
        IF checksum <> pri_params-prchk.
          pri_params-prchk = checksum.
          MOVE-CORRESPONDING pri_params TO wa_jobstep.
        ENDIF.
        IF pri_params-armod > '1'.
          MOVE-CORRESPONDING wa_jobstep TO arc_params.
          PERFORM compute_checksum(saplspri) USING    arc_params
                                             CHANGING checksum.
          IF checksum <> arc_params-acheck.
            arc_params-acheck = checksum.
            MOVE-CORRESPONDING arc_params TO wa_jobstep.
          ENDIF.
        ENDIF.

*        IF p_dest IS NOT INITIAL.
*          WRITE  90(8) wa_jobstep-pdest COLOR 3. "Gelb      KXXX928879
*        ENDIF.
*
*        IF p_pexpi IS NOT INITIAL.                          "KXXX938946
*          WRITE 100(1) wa_jobstep-pexpi COLOR 3. "Gelb
*        ENDIF.                                              "KXXX938946
 

* auskommentiert:                                            KXXX928879
*        IF p_dest IS INITIAL AND stepuser IS INITIAL.
*          CONTINUE.
*        ENDIF.

*      IF NOT ( ( p_dest IS INITIAL ) AND ( stepuser IS INITIAL ) ).
      ENDIF.

      CLEAR: sy-subrc.
      UPDATE tbtcp FROM wa_jobstep.   "Datenbank-Update

      IF sy-subrc EQ 0.                                     "KXXX939074

        IF p_dest IS NOT INITIAL.
          WRITE:  90 wa_jobstep-pdest COLOR = 3. "Gelb
        ENDIF.

        IF p_pexpi IS NOT INITIAL.
          WRITE: 100 wa_jobstep-pexpi COLOR = 3. "Gelb
        ENDIF.

        IF stepuser IS NOT INITIAL.
          WRITE: 105 wa_jobstep-authcknam COLOR = 3. "Gelb
        ENDIF.

      ELSE.                                                 "KXXX939074
        WRITE:  80 'Datenbank-Update fehlgeschlagen'(007)
               COLOR = 6. "Rot                              KXXX931511
      ENDIF.
*      ENDIF.
*    ENDSELECT.
    ENDLOOP.

    IF ( ( newcrusr IS NOT INITIAL )                        "KXXX931511
      OR ( newcgusr IS NOT INITIAL )                        "KXXX931511
      OR ( p_newcls IS NOT INITIAL ) ).                     "KXXX931511
*      ( p_newcls EQ 'A' OR p_newcls EQ 'B' OR p_newcls EQ 'C' ) ).
      WRITE: / 'Job geändert auf'(008) COLOR = 4. "Blaugrün  KXXX928879
    ENDIF.                                                  "KXXX928879

*   Besitzer (=letzter Änderer) sowie ggf. Ersteller und
*   Klasse des Jobs ändern:

    IF newcrusr IS NOT INITIAL.  "neuer Job-Ersteller       KXXX928879

      FORMAT COLOR = 4. "Blaugrün
      WRITE:
                 52 newcrusr,
                 65 newcgusr.                               "KXXX928655
      CASE p_newcls.                                        "KXXX928655
        WHEN 'A' OR 'B' OR 'C'.                             "KXXX928655
          WRITE: 79 p_newcls.                               "KXXX928655
      ENDCASE.                                              "KXXX928655
      FORMAT COLOR OFF.

      IF testonly = space.            "Job-Änderung

        CASE p_newcls.                                      "KXXX928655
          WHEN 'A' OR 'B' OR 'C'.             "Neue Jobklasse KXXX928655
            UPDATE tbtco                                    "KXXX928655
              SET   lastchdate = sy-datum                   "KXXX929033
                    lastchtime = sy-uzeit                   "KXXX929033
                    lastchname = newcgusr                   "KXXX928655
                    sdluname   = newcrusr                   "KXXX928655
                    jobclass   = p_newcls                   "KXXX928655
              WHERE jobname    = wa_job-jobname             "KXXX928655
                AND jobcount   = wa_job-jobcount.           "KXXX928655

          WHEN OTHERS.                 "Jobklasse beibehalten KXXX928655
            UPDATE tbtco
              SET   lastchdate = sy-datum                   "KXXX929033
                    lastchtime = sy-uzeit                   "KXXX929033
                    lastchname = newcgusr                   "KXXX928655
                    sdluname   = newcrusr
              WHERE jobname    = wa_job-jobname
                AND jobcount   = wa_job-jobcount.
        ENDCASE.                                            "KXXX928655
        IF sy-subrc NE 0.
          FORMAT COLOR = 6. "Rot                             KXXX931800
          WRITE:/ 'Fehler bei Update TBTCO. Returncode:'(009),
                  sy-subrc.                                 "KXXX931511
          FORMAT COLOR OFF.                                 "KXXX931800
        ENDIF.
      ENDIF.

    ELSE.                        "Kein neuer Job-Ersteller KXXX928879
      FORMAT COLOR = 4. "Blaugrün
      WRITE:
*                52 newcrusr,
                 65 newcgusr.                               "KXXX928655
      CASE p_newcls.                                        "KXXX928655
        WHEN 'A' OR 'B' OR 'C'.                             "KXXX928655
          WRITE: 79 p_newcls.                               "KXXX928655
      ENDCASE.                                              "KXXX928655
      FORMAT COLOR OFF.

      IF testonly = space.            "Job-Änderung
        CASE p_newcls.                                      "KXXX928655
          WHEN 'A' OR 'B' OR 'C'.            "Neue Jobklasse KXXX928655
            UPDATE tbtco                                    "KXXX928655
              SET   lastchdate = sy-datum                   "KXXX929033
                    lastchtime = sy-uzeit                   "KXXX929033
                    lastchname = newcgusr                   "KXXX928655
*                   sdluname   = newcrusr
                    jobclass   = p_newcls                   "KXXX928655
              WHERE jobname    = wa_job-jobname             "KXXX928655
                AND jobcount   = wa_job-jobcount.           "KXXX928655

          WHEN OTHERS.                "Jobklasse beibehalten KXXX928655
            UPDATE tbtco
             SET   lastchdate = sy-datum                    "KXXX929033
                   lastchtime = sy-uzeit                    "KXXX929033
                   lastchname = newcgusr                    "KXXX928655
*                   sdluname   = newcrusr
              WHERE jobname    = wa_job-jobname
                AND jobcount   = wa_job-jobcount.
        ENDCASE.                                            "KXXX928655
        IF sy-subrc NE 0.
          FORMAT COLOR = 6. "Rot                             KXXX931800
          WRITE:/ 'Fehler bei Update TBTCO. Returncode:'(009),
                  sy-subrc.
          FORMAT COLOR OFF.                                 "KXXX931800
        ENDIF.

      ENDIF.

    ENDIF.
    ULINE.

    CLEAR wa_job.
  ENDLOOP.

* fertig ...

---

ABAP Tips

 

See Also
Estimate Guidelines for ABAP programs

Get help for your ABAP problems
Do you have a ABAP Question?

ABAP Books
ABAP Certification, BAPI, Java, Web Programming, Smart Forms, Sapscripts Reference Books

More ABAP Tips

Main Index
SAP Basis, ABAP Programming and Other IMG Stuff

All the site contents are Copyright © www.erpgreat.com and the content authors. All rights reserved.
All product names are trademarks of their respective companies.  The site www.erpgreat.com is in no way affiliated with SAP AG. 
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk. 
 The content on this site may not be reproduced or redistributed without the express written permission of 
www.erpgreat.com or the content authors.