Skip to Content
0
Former Member
Jul 08, 2010 at 06:26 PM

Extra job getting created in dynamic handling of jobs

59 Views

I have the below code and I notice an extra job that is being created in SM35. Any reasons/clues please

bdcjob will have A/P_ACCOUNTS_BDC

adrjob will have A/P_ACCOUNTS_ADDRESS

Name of the batch input session is A/P

The 3rd extra job that is coming up is 'A/P' and I did not open any job by that name.

Thanks for your help.

Kiran

 DATA: bdcjob TYPE tbtcjob-jobname,
      bdcnum TYPE tbtcjob-jobcount,
      adrjob TYPE tbtcjob-jobname,
      adrnum TYPE tbtcjob-jobcount,
      params LIKE pri_params,
      l_valid   TYPE c.

CHECK fileonly IS INITIAL.
MOVE: jobname TO bdcjob.
adrjob = 'A/P_ACCOUNTS_ADDRESS'.

IF NOT logtable[] IS INITIAL.
  IF NOT testrun IS INITIAL.
*   If its a test run, Non Batch-Input-Session
    SUBMIT rfbikr00 AND RETURN
                    USER sy-uname
                    WITH ds_name EQ file_o
                    WITH fl_check EQ 'X'.         "X=No Batch-Input
  ELSE.
*   Create a session which will be processed by a job
    SUBMIT rfbikr00 AND RETURN
                    USER sy-uname
                    WITH ds_name EQ file_o
                    WITH fl_check EQ ' '.
*   Open BDC Job
    CALL FUNCTION 'JOB_OPEN'
      EXPORTING
        jobname          = bdcjob
      IMPORTING
        jobcount         = bdcnum
      EXCEPTIONS
        cant_create_job  = 1
        invalid_job_data = 2
        jobname_missing  = 3
        OTHERS           = 4.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
      WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ELSE.
*     Submit RSBDCSUB to trigger the session in background mode
      SUBMIT rsbdcsub
        VIA  JOB    bdcjob
             NUMBER bdcnum
        WITH von     = sy-datum
        WITH bis     = sy-datum
        WITH z_verab = 'X'
        WITH logall  = 'X'
        AND RETURN.
      IF sy-subrc EQ 0.
*       Export data to a memory id. This data will be used by the program
*       that updates the address & email id
        EXPORT t_zzupdate TO SHARED BUFFER indx(st) ID 'MEM1'.
*       Get Print Parameters
        CALL FUNCTION 'GET_PRINT_PARAMETERS'
          EXPORTING
            no_dialog      = 'X'
          IMPORTING
            valid          = l_valid
            out_parameters = params.
*       Open a second job to trigger a program which updates addresses & email ids
        CALL FUNCTION 'JOB_OPEN'
          EXPORTING
            jobname          = adrjob
          IMPORTING
            jobcount         = adrnum
          EXCEPTIONS
            cant_create_job  = 1
            invalid_job_data = 2
            jobname_missing  = 3
            OTHERS           = 4.
        IF sy-subrc <> 0.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
          WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ELSE.
*         submit the program to update email id & long addresses
          SUBMIT zfpa_praa_address_update
                 VIA JOB adrjob
                 NUMBER  adrnum
                 TO SAP-SPOOL WITHOUT SPOOL DYNPRO
                     SPOOL PARAMETERS params
                        AND RETURN.
          IF sy-subrc EQ 0.
*           First close the dependent job(address update job). Dependency
*           is shown by using pred_jobcount & pred_jobname parameters
            CALL FUNCTION 'JOB_CLOSE'
              EXPORTING
                jobcount             = adrnum
                jobname              = adrjob
                pred_jobcount        = bdcnum
                pred_jobname         = bdcjob
              EXCEPTIONS
                cant_start_immediate = 1
                invalid_startdate    = 2
                jobname_missing      = 3
                job_close_failed     = 4
                job_nosteps          = 5
                job_notex            = 6
                lock_failed          = 7
                invalid_target       = 8
                OTHERS               = 9.
            IF sy-subrc <> 0.
              MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                      WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
            ENDIF.
          ENDIF.
        ENDIF.
      ENDIF.
*     Close the main job(BDC Job)
      CALL FUNCTION 'JOB_CLOSE'
        EXPORTING
          jobcount             = bdcnum
          jobname              = bdcjob
          strtimmed            = 'X'
        EXCEPTIONS
          cant_start_immediate = 1
          invalid_startdate    = 2
          jobname_missing      = 3
          job_close_failed     = 4
          job_nosteps          = 5
          job_notex            = 6
          lock_failed          = 7
          invalid_target       = 8
          OTHERS               = 9.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    ENDIF.
  ENDIF. 

Edited by: kiran dasari on Jul 9, 2010 12:58 AM