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: 

creating many pdf into individual pdf's.

Former Member
0 Kudos
128

hi FRNDS.

iam COnverting SAPSCRIPT TO PDF.

here iam using STD PROG NAMED AS RSTXPDFT4.

BUT IAM GETTING ALL EMPLOYEE'S PDF FILE IN 1 PDF ONLY ,

HERE I WANT O/P OF EACH EMPLOYEE INDIVIUALLY, I.E

I need to split and download a spool file into PDF, but based on certain conditions, create multiple pdf files. Has U done this before or any tips or tricks?

The conditions could be: For every new EMPLOYEE NUMBER IN HEADER I need to create a saperate pdf file , so tht each employee's PDF can store in 1 folder. plz little urgent frnds....

1 REPLY 1

Former Member
0 Kudos
83

Hi,

Try this,

SELECTION-SCREEN BEGIN OF BLOCK B4 WITH FRAME TITLE TEXT-002.
  PARAMETERS: P_LINSZ LIKE SY-LINSZ DEFAULT 132, " Line size
              P_PAART LIKE SY-PAART DEFAULT 'X_65_132'.  " Paper Format
  PARAMETER PATH(40) DEFAULT 'D:\ITREP' OBLIGATORY.
SELECTION-SCREEN END OF BLOCK B4.


start-of-selection

    LOOP AT IT_MPAY.
      PERFORM CREATE_PDF_FILE USING IT_MPAY-EMP_NO IT_MPAY-CATEGORY.
    ENDLOOP.

&---------------------------------------------------------------------*
*&      Form  create_pdf_file
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_IT_MPAY_EMP_NO  text
*      -->P_IT_MPAY_CATEGORY  text
*----------------------------------------------------------------------*
FORM CREATE_PDF_FILE  USING    P_EMPNO
                               P_CATEGORY.
  DATA : E_EMPNO(6) TYPE C.

  E_EMPNO = P_EMPNO.
  SHIFT E_EMPNO LEFT DELETING LEADING '0'.

  CONCATENATE 'E' E_EMPNO '.pdf' INTO MC_FILENAME.

**-- Setup the Print Parmaters
  CALL FUNCTION 'GET_PRINT_PARAMETERS'
    EXPORTING
      AUTHORITY              = SPACE
      COPIES                 = '1'
      COVER_PAGE             = SPACE
      DATA_SET               = SPACE
      DEPARTMENT             = SPACE
      DESTINATION            = SPACE
      EXPIRATION             = '1'
      IMMEDIATELY            = SPACE
      IN_ARCHIVE_PARAMETERS  = SPACE
      IN_PARAMETERS          = SPACE
      LAYOUT                 = SPACE
      MODE                   = SPACE
      NEW_LIST_ID            = 'X'
      NO_DIALOG              = 'X'
      USER                   = SY-UNAME
    IMPORTING
      OUT_PARAMETERS         = MSTR_PRINT_PARMS
      VALID                  = MC_VALID
    EXCEPTIONS
      ARCHIVE_INFO_NOT_FOUND = 1
      INVALID_PRINT_PARAMS   = 2
      INVALID_ARCHIVE_PARAMS = 3
      OTHERS                 = 4.
**-- Make sure that a printer destination has been set up
**-- If this is not done the PDF function module ABENDS
  IF MSTR_PRINT_PARMS-PDEST = SPACE.
    MSTR_PRINT_PARMS-PDEST = 'DFLT'.
  ENDIF.
**-- Explicitly set line width, and output format so that
**-- the PDF conversion comes out OK
  MSTR_PRINT_PARMS-LINSZ = P_LINSZ.
  MSTR_PRINT_PARMS-PAART = P_PAART.

  SUBMIT ZMPIT_WORKSHEET TO SAP-SPOOL WITHOUT SPOOL DYNPRO
                   SPOOL PARAMETERS MSTR_PRINT_PARMS
                   WITH LDTFINYR = LDTFINYR
                   WITH CAT = P_CATEGORY
                   WITH EMP = P_EMPNO
                   WITH DECLRN = DECLRN
                   WITH ACTUAL = ACTUAL
                   WITH VACT = VACT
                   WITH VDEACT =  VDEACT
                   WITH DET1 = DET1
                   WITH SUM1 = SUM1
                   AND RETURN.
**-- Find out what the spool number is that was just created
  PERFORM GET_SPOOL_NUMBER USING SY-REPID
             SY-UNAME
    CHANGING MI_RQIDENT.

  CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
    EXPORTING
                    SRC_SPOOLID =  MI_RQIDENT
*                     no_dialog  = space
*                    dst_device = 'DFLT' " mstr_print_parms-pdest

    IMPORTING
      PDF_BYTECOUNT                  = MI_BYTECOUNT
    TABLES
                          PDF        = MTAB_PDF
    EXCEPTIONS
      ERR_NO_ABAP_SPOOLJOB           = 1
      ERR_NO_SPOOLJOB                = 2
      ERR_NO_PERMISSION              = 3
      ERR_CONV_NOT_POSSIBLE          = 4
      ERR_BAD_DESTDEVICE             = 5
      USER_CANCELLED                 = 6
      ERR_SPOOLERROR                 = 7
      ERR_TEMSEERROR                 = 8
      ERR_BTCJOB_OPEN_FAILED         = 9
      ERR_BTCJOB_SUBMIT_FAILED       = 10
      ERR_BTCJOB_CLOSE_FAILED        = 11
      OTHERS     = 12.


  CONCATENATE PATH '\' MC_FILENAME INTO W_FILE_PATH.

  CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
      BIN_FILESIZE = MI_BYTECOUNT     "w_bin_filesize
      FILENAME     = W_FILE_PATH
      FILETYPE     = 'BIN'
    TABLES
      DATA_TAB     = MTAB_PDF.         "mt_pdf_tab.

*---------------------------------------------------------------------*
*       FORM get_spool_number *
*---------------------------------------------------------------------*
*       Get the most recent spool created by user/report              *
*---------------------------------------------------------------------*
*  -->  F_REPID               *
*  -->  F_UNAME               *
*  -->  F_RQIDENT             *
*---------------------------------------------------------------------*
FORM GET_SPOOL_NUMBER USING F_REPID
     F_UNAME
                CHANGING F_RQIDENT.
  DATA:
    LC_RQ2NAME LIKE TSP01-RQ2NAME.
  CONCATENATE F_REPID+0(9)  F_UNAME+0(3) INTO LC_RQ2NAME .
  SELECT * FROM TSP01 WHERE  RQ2NAME = LC_RQ2NAME
   AND RQ1NAME = 'DFLT'
   ORDER BY RQIDENT DESCENDING.
    F_RQIDENT = TSP01-RQIDENT.
    EXIT.
  ENDSELECT.
  IF SY-SUBRC NE 0.
    CLEAR F_RQIDENT.
  ENDIF.
ENDFORM." get_spool_number

Rgds

Vijay

Edited by: vijay sathy on Mar 25, 2008 8:24 AM