Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

cannot get converted PDF CONVERT_ABAPSPOOLJOB_2_PDF more than 99 pages

siongchao_ng
Contributor
0 Kudos

Hi all,

I am using FM CONVERT_ABAPSPOOLJOB_2_PDF to convert spool into PDF. Problem: more than 99 pages, this FM will trigger another spool to convert spool into PDF.

Now I have 2nd generated spool number with converted PDF data. How do I get this data? I need to attach this file into email so passing spool number into standard SAP program that can only run in foreground to download is not an option.

Look at the type. It is already converted PDF format. Any samples codes or FM that I get the PDF into an internal table?

1 ACCEPTED SOLUTION

siongchao_ng
Contributor

found the answer. use FM RSPO_RETURN_ABAP_SPOOLJOB_RAW

*    * handle more than 99 pages
    ELSE.
*   only more than 99 pages will trigger jobname
      CLEAR gv_87011990_100_status.
      IF gv_jobname_87011990_100 IS NOT INITIAL.
*        *      * do not get spool number while job is still running as correct spool number
* still not generated yet
        gv_87011990_100_status = 'R'.
        WHILE gv_87011990_100_status = 'R'.

*   if program running in foreground assumed it is for small number of records, no need wait long
*   else if background only call the FM BP_JOB_STATUS_GET every 5 minutes to avoid BP_JOB_ABORT dump
          IF sy-batch = space.
            WAIT UP TO 5 SECONDS.
          ELSE.
            WAIT UP TO 300 SECONDS.
          ENDIF.

          CALL FUNCTION 'BP_JOB_STATUS_GET'
            EXPORTING
              jobcount                   = gv_jobcount_87011990_100
              jobname                    = gv_jobname_87011990_100
*             READ_ONLY_STATUS           =
            IMPORTING
              status                     = gv_87011990_100_status
              has_child                  = gv_87011990_100_child
            EXCEPTIONS
              job_doesnt_exist           = 1
              unknown_error              = 2
              parent_child_inconsistency = 3
              OTHERS                     = 4.
          IF sy-subrc <> 0.
            EXIT.
          ENDIF.

*         if job fail, exit the loop
          IF gv_87011990_100_status = 'A'.

**     get the list of error variant
            gw_error_varid_87011990-variant = gw_varid5-variant.
            APPEND gw_error_varid_87011990 TO gt_error_varid_87011990.
            CLEAR gw_error_varid_87011990.

            EXIT.
          ENDIF.

        ENDWHILE.

*     * dont run the following if job fail
        IF gv_87011990_100_status = 'A'.

          gv_87011990_status = 'A'.

        ELSE.
          PERFORM f_get_spool_number USING sy-repid
                   sy-uname
                   'X'
          CHANGING mi_rqident.

          CALL FUNCTION 'RSPO_RETURN_ABAP_SPOOLJOB_RAW'
            EXPORTING
              rqident              = mi_rqident
              first_line           = 1
*             LAST_LINE            =
*             PAGES                =
            IMPORTING
              end_of_data          = lv_end_data
            TABLES
              buffer               = gt_tab_pdf_87011990
            EXCEPTIONS
              no_such_job          = 1
              not_abap_list        = 2
              job_contains_no_data = 3
              selection_empty      = 4
              no_permission        = 5
              can_not_access       = 6
              read_error           = 7
              OTHERS               = 8.
          IF sy-subrc <> 0.
* Implement suitable error handling here
          ENDIF.

        ENDIF.
      ENDIF.
    ENDIF.
  ENDIF.
2 REPLIES 2

Nikhil_Rao_ABAP
Participant
0 Kudos

Hello,

In your call to the function module: CONVERT_ABAPSPOOLJOB_2_PDF, have you tried passing the parameter NO_BACKGROUND = abap_true. This will force the function module to NOT go into job mode, even when the spool page count is large.

Kind Regards,

Nikhil

siongchao_ng
Contributor

found the answer. use FM RSPO_RETURN_ABAP_SPOOLJOB_RAW

*    * handle more than 99 pages
    ELSE.
*   only more than 99 pages will trigger jobname
      CLEAR gv_87011990_100_status.
      IF gv_jobname_87011990_100 IS NOT INITIAL.
*        *      * do not get spool number while job is still running as correct spool number
* still not generated yet
        gv_87011990_100_status = 'R'.
        WHILE gv_87011990_100_status = 'R'.

*   if program running in foreground assumed it is for small number of records, no need wait long
*   else if background only call the FM BP_JOB_STATUS_GET every 5 minutes to avoid BP_JOB_ABORT dump
          IF sy-batch = space.
            WAIT UP TO 5 SECONDS.
          ELSE.
            WAIT UP TO 300 SECONDS.
          ENDIF.

          CALL FUNCTION 'BP_JOB_STATUS_GET'
            EXPORTING
              jobcount                   = gv_jobcount_87011990_100
              jobname                    = gv_jobname_87011990_100
*             READ_ONLY_STATUS           =
            IMPORTING
              status                     = gv_87011990_100_status
              has_child                  = gv_87011990_100_child
            EXCEPTIONS
              job_doesnt_exist           = 1
              unknown_error              = 2
              parent_child_inconsistency = 3
              OTHERS                     = 4.
          IF sy-subrc <> 0.
            EXIT.
          ENDIF.

*         if job fail, exit the loop
          IF gv_87011990_100_status = 'A'.

**     get the list of error variant
            gw_error_varid_87011990-variant = gw_varid5-variant.
            APPEND gw_error_varid_87011990 TO gt_error_varid_87011990.
            CLEAR gw_error_varid_87011990.

            EXIT.
          ENDIF.

        ENDWHILE.

*     * dont run the following if job fail
        IF gv_87011990_100_status = 'A'.

          gv_87011990_status = 'A'.

        ELSE.
          PERFORM f_get_spool_number USING sy-repid
                   sy-uname
                   'X'
          CHANGING mi_rqident.

          CALL FUNCTION 'RSPO_RETURN_ABAP_SPOOLJOB_RAW'
            EXPORTING
              rqident              = mi_rqident
              first_line           = 1
*             LAST_LINE            =
*             PAGES                =
            IMPORTING
              end_of_data          = lv_end_data
            TABLES
              buffer               = gt_tab_pdf_87011990
            EXCEPTIONS
              no_such_job          = 1
              not_abap_list        = 2
              job_contains_no_data = 3
              selection_empty      = 4
              no_permission        = 5
              can_not_access       = 6
              read_error           = 7
              OTHERS               = 8.
          IF sy-subrc <> 0.
* Implement suitable error handling here
          ENDIF.

        ENDIF.
      ENDIF.
    ENDIF.
  ENDIF.