Application Development and Automation 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: 
Read only

Convert internal table to spool

Former Member
0 Kudos
5,754

Hi,

I'm getting an error after calling:

CALL FUNCTION 'SLVC_TABLE_PS_TO_SPOOL'

EXPORTING

i_file_length = file_length

IMPORTING

e_spoolid = spool_id

TABLES

it_textdata = objbin.

I use the spool_id as a parameter for CONVERT_ABAPSPOOLJOB_2_PDF but I'm getting the error 'Spool request # contains no ABAP list data'

Am I using the wrong spool id?

Any help appreciated.

1 ACCEPTED SOLUTION
Read only

Former Member
17 REPLIES 17
Read only

Former Member
0 Kudos
2,829

Hi,

Goto the transaction SP01 and check if the internal table list is generated for the spool id generated using 'SLVC_TABLE_PS_TO_SPOOL'

Vikranth

Read only

former_member404244
Active Contributor
0 Kudos
2,829

Hi,

Please check if the internal table objbin is having any data or not before passing to the FM 'SLVC_TABLE_PS_TO_SPOOL'. Also check SP01 by taking the spool number.

Regards,

Nagaraj

Read only

0 Kudos
2,829

Hi,

Yes objbin has data and when I display the spool request in SP01 it displays what I'm expecting.

Coul dit be anything to do with running it in debug rather than background as it keeps asking me for a device?

Read only

0 Kudos
2,829

hI,

Try this piece of code



* If print option is selected.
  IF p_print IS NOT INITIAL.
    MOVE c_x TO v_print.
  ELSE.
    CLEAR v_print.
  ENDIF.

* Setup the Print Parmaters
  CALL FUNCTION 'GET_PRINT_PARAMETERS'
    EXPORTING
      authority              = space
      immediately            = v_print
      new_list_id            = c_x
      no_dialog              = c_x
      user                   = sy-uname
    IMPORTING
      out_parameters         = v_print_parms
    EXCEPTIONS
      archive_info_not_found = 1
      invalid_print_params   = 2
      invalid_archive_params = 3
      OTHERS                 = 4.

  IF sy-subrc NE 0.
    CLEAR : v_print_parms.
  ENDIF.

* The printer destination has to be  set up
  IF v_print_parms-pdest = space.
    v_print_parms-pdest = lc_locl.
  ENDIF.
* Explicitly set line width, and output format so that
* the PDF conversion comes out OK
  v_print_parms-linsz = c_linsz.
 v_print_parms-paart = lc_paart.


* Declaration of local variables
  DATA : lv_bytecount  TYPE i,
         lv_cancel(1)  TYPE c,
         lv_filename1  LIKE rlgrap-filename.    "File name

* Declaration of local constants
  CONSTANTS: lc_pdf(4) TYPE c VALUE '.PDF'.


  CONCATENATE c_c
              sy-repid
              lc_pdf
      INTO lv_filename1.


* Convert Spool to PDF
  CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
    EXPORTING
      src_spoolid              = v_rqident
      no_dialog                = c_x
      dst_device               = v_print_parms-pdest
    IMPORTING
      pdf_bytecount            = lv_bytecount
    TABLES
      pdf                      = i_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.

Regards,

Nagaraj

Read only

venkat_o
Active Contributor
0 Kudos
2,829

Hi Rob, Check my program here to convert internal table to spool . It works fine. <li><b><u></u></b> Thanks Venkat.O

Read only

Former Member
0 Kudos
2,829

Hi,

I still get the error even tho I can see the spool data in sp01?

my code

REPORT  Z_MAIL_PAYSLIP.
*----------------------------------------------------------------------*
* Declaration Part *
*----------------------------------------------------------------------*
tables: PERNR, PV000, T549Q, V_T514D, HRPY_RGDIR.

infotypes: 0000, 0001, 0105, 0655.

data: begin of ITAB occurs 0,
  MTEXT(25) type C,
  PERNR like PA0001-PERNR,
  ABKRS like PA0001-ABKRS,
  ENAME like PA0001-ENAME,
  USRID_LONG like PA0105-USRID_LONG,
end of ITAB.

data: W_BEGDA like HRPY_RGDIR-FPBEG,
      W_ENDDA like HRPY_RGDIR-FPEND.

data: RETURN like BAPIRETURN1 occurs 0 with header line.

data: P_INFO like PC407,
      P_FORM like PC408 occurs 0 with header line.


data: P_IDX type I,
      MY_MONTH type T549Q-PABRP,
      STR_MY_MONTH(2) type C,
      MY_YEAR type T549Q-PABRJ,
      STR_MY_YEAR(4) type C,
      CRLF(2) type x value '0D0A'.

data: W_CMONTH(10) type C.

data: TAB_LINES type I,
      ATT_TYPE like SOODK-OBJTP.

data: begin of P_INDEX occurs 0,
        INDEX type I,
end of P_INDEX.

constants: begin of F__LTYPE, "type of line
   CMD like PC408-LTYPE value '/:',  "command
   TXT like PC408-LTYPE value 's',   "textline
end of F__LTYPE.

constants: begin of F__CMD, "commands
  NEWPAGE like PC408-LINDA value '',
end of F__CMD.

data: P_LIST like ABAPLIST occurs 1 with header line.

*data: OBJBIN like SOLISTI1 occurs 10 with header line,
data: OBJBIN like  LVC_S_1022 occurs 10 with header line,
      DOCDATA like SODOCCHGI1,
      OBJTXT like SOLISTI1 occurs 10 with header line,
      OBJPACK like SOPCKLSTI1 occurs 1 with header line,
      RECLIST like SOMLRECI1 occurs 1 with header line,
      OBJHEAD like SOLISTI1 occurs 1 with header line,
      it_mess_att LIKE solisti1 OCCURS 0 WITH HEADER LINE,
      gd_buffer type string,
      l_no_of_bytes TYPE i,
      l_pdf_spoolid LIKE tsp01-rqident,
      l_jobname     LIKE tbtcjob-jobname.

data: file_length  type int4,
      spool_id     type rspoid,
      line_cnt     type i.

*-------------------------------------------------------------------* * INITIALIZATION *
OBJBIN = ' | '.
append OBJBIN.

OBJPACK-HEAD_START = 1.

data: S_ABKRS like PV000-ABKRS.
data: S_PABRP like T549Q-PABRP.
data: S_PABRJ like T549Q-PABRJ.
*-------------------------------------------------------------------*
* SELECTION SCREEN                                                  *
*-------------------------------------------------------------------*
selection-screen begin of block BL1.
parameters: PAY_VAR like BAPI7004-PAYSLIP_VARIANT default 'ESS_PAYSLIPS' obligatory.
selection-screen end of block BL1.


START-OF-SELECTION.

  s_ABKRS = PNPXABKR.
  S_PABRP = PNPPABRP.
  s_pabrj = PNPPABRJ.

  w_begda = PN-BEGDA.
  w_endda = PN-ENDDA.

get pernr.
*                                 "Check active employees
  rp-provide-from-last p0000 space pn-begda  pn-endda.

  CHECK P0000-STAT2 IN PNPSTAT2.
*                                 "Check Payslip Mail flag
  rp-provide-from-last p0655 space pn-begda  pn-endda.

  CHECK P0655-ESSONLY = 'X'.

  rp-provide-from-last p0001 space pn-begda  pn-endda.

*                                 "Find email address
  RP-PROVIDE-FROM-LAST P0105 '0030' PN-BEGDA PN-ENDDA.

  if p0105-usrid_LONG ne ''.

    ITAB-PERNR      = P0001-PERNR.
    ITAB-ABKRS      = P0001-ABKRS.
    ITAB-ENAME      = P0001-ENAME.
    ITAB-USRID_LONG = P0105-USRID_LONG.

    append itab.
    clear itab.

  endif.



  "SY-UCOMM ='ONLI'

END-OF-SELECTION.
*------------------------------------------------------------------* start-of-selection.
  write : / 'Payroll Area        : ', S_ABKRS.
  write : / 'Payroll Period/Year : ',STR_MY_MONTH,'-',STR_MY_YEAR. write : / 'System Date : ', SY-DATUM.
  write : / 'System Time         : ', SY-UZEIT.
  write : / 'User Name           : ', SY-UNAME.
  write : / SY-ULINE.

  sort ITAB by PERNR.

  loop at ITAB.
    clear : P_INFO, P_FORM, P_INDEX, P_LIST, OBJBIN, DOCDATA, OBJTXT, OBJPACK, RECLIST, TAB_LINES.

    refresh : P_FORM, P_INDEX, P_LIST, OBJBIN, OBJTXT, OBJPACK, RECLIST.

*                                                  Retrieve Payroll results sequence number for this run
    select single * from HRPY_RGDIR where PERNR eq ITAB-PERNR
                                    and FPBEG ge W_BEGDA
                                    and FPEND le W_ENDDA
                                    and SRTZA eq 'A'.
*                                                  Produce payslip for those payroll results
    if SY-SUBRC = 0.
      call function 'GET_PAYSLIP'
        EXPORTING
          EMPLOYEE_NUMBER = ITAB-PERNR
          SEQUENCE_NUMBER = HRPY_RGDIR-SEQNR
          PAYSLIP_VARIANT = PAY_VAR
        IMPORTING
          RETURN          = RETURN
          P_INFO          = P_INFO
        TABLES
          P_FORM          = P_FORM.

      check RETURN is initial.

*                                                 remove linetype from generated payslip
      loop at p_form.
        objbin = p_form-linda.
        append objbin.
        line_cnt = line_cnt + 1.
      endloop.

      file_length = line_cnt * 1022.

*                                                 create spool file of paylsip
      CALL FUNCTION 'SLVC_TABLE_PS_TO_SPOOL'
        EXPORTING
          i_file_length = file_length
        IMPORTING
          e_spoolid     = spool_id
        TABLES
          it_textdata   = objbin.

      IF sy-subrc EQ 0.
        WRITE spool_id.
      ENDIF.

      DESCRIBE table objbin.

      DATA PDF LIKE TLINE OCCURS 100 WITH HEADER LINE.

      CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
        EXPORTING
          SRC_SPOOLID                    = spool_id
          NO_DIALOG                      = ' '
          DST_DEVICE                     = 'MAIL'
*      PDF_DESTINATION                =
*    IMPORTING
*      PDF_BYTECOUNT                  = l_no_of_bytes
*      PDF_SPOOLID                    = l_pdf_spoolid
*      LIST_PAGECOUNT                 =
*      BTC_JOBNAME                    =
*      BTC_JOBCOUNT                   =
        TABLES
          PDF                            = 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
             .
      IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.

*Download PDF file C Drive
  CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
      filename = 'C:\itab_to_pdf.pdf'
      filetype = 'BIN'
    TABLES
      data_tab = pdf.
* Transfer the 132-long strings to 255-long strings
*  LOOP AT pdf.
*    TRANSLATE pdf USING ' ~'.
*    CONCATENATE gd_buffer pdf INTO gd_buffer.
*  ENDLOOP.
*
*  TRANSLATE gd_buffer USING '~ '.
*
*  DO.
*    it_mess_att = gd_buffer.
*    APPEND it_mess_att.
*    SHIFT gd_buffer LEFT BY 255 PLACES.
*    IF gd_buffer IS INITIAL.
*      EXIT.
*    ENDIF.
*  ENDDO.

      OBJHEAD = 'Objhead'.
      append OBJHEAD.

* preparing email subject
      concatenate W_ENDDA(6)
                ' Payslip-'
                ITAB-ENAME+0(28)
                '('
                ITAB-PERNR+4(4) ')'
             into DOCDATA-OBJ_DESCR.

      DOCDATA-OBJ_NAME = 'Pay Slip'.
      DOCDATA-OBJ_LANGU = SY-LANGU.
      OBJTXT = 'Pay Slip.'.
      append OBJTXT.

*prepare email lines
      OBJTXT = DOCDATA-OBJ_DESCR.
      append OBJTXT.

      OBJTXT = 'Please find enclosed your current payslip.'.
      append OBJTXT.

* Write Attachment(Main)
* 3 has been fixed because OBJTXT has fix three lines
      read table OBJTXT index 3.
*    DOCDATA-DOC_SIZE = ( 3 - 1 ) * 255 + strlen( OBJTXT ).
      clear OBJPACK-TRANSF_BIN.
      OBJPACK-HEAD_START = 1.
      OBJPACK-HEAD_NUM = 0.
      OBJPACK-BODY_START = 1.
      OBJPACK-BODY_NUM = 3.
      OBJPACK-DOC_TYPE = 'RAW'.
      append OBJPACK.

* Create Message Attachment
      ATT_TYPE = 'PDF'.
      describe table OBJBIN lines TAB_LINES.
      read table OBJBIN index TAB_LINES.
*    OBJPACK-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + strlen( OBJBIN ).
      OBJPACK-TRANSF_BIN = 'X'.
      OBJPACK-HEAD_START = 1.
      OBJPACK-HEAD_NUM = 0.
      OBJPACK-BODY_START = 1.
      OBJPACK-BODY_NUM = TAB_LINES.
      OBJPACK-DOC_TYPE = ATT_TYPE.
      OBJPACK-OBJ_NAME = 'ATTACHMENT'.
      OBJPACK-OBJ_DESCR = 'Payslip'.
      append OBJPACK.

* Create receiver list refresh RECLIST.
      clear RECLIST.
      RECLIST-RECEIVER = itab-USRID_long.
      translate RECLIST-RECEIVER to lower case.
      RECLIST-REC_TYPE = 'U'.
      append RECLIST.

* Send the document
*SO_NEW_DOCUMENT_ATT_SEND_API1
      call function 'SO_DOCUMENT_SEND_API1'
        exporting
          DOCUMENT_DATA = DOCDATA
          PUT_IN_OUTBOX = 'X'
          COMMIT_WORK = 'X'
* IMPORTING
*   SENT_TO_ALL =
*   NEW_OBJECT_ID =
        tables
          PACKING_LIST  = OBJPACK
          OBJECT_HEADER = OBJHEAD
          CONTENTS_BIN  = pdf
          CONTENTS_TXT  = OBJTXT
*   CONTENTS_HEX =
*   OBJECT_PARA =
*   OBJECT_PARB =
          RECEIVERS = RECLIST
        exceptions
          TOO_MANY_RECEIVERS = 1
          DOCUMENT_NOT_SENT = 2
          DOCUMENT_TYPE_NOT_EXIST = 3
          OPERATION_NO_AUTHORIZATION = 4
          PARAMETER_ERROR = 5
          X_ERROR = 6
          ENQUEUE_ERROR = 7
          others = 8.

      if SY-SUBRC NE 0.
        ITAB-MTEXT = 'Message Not Sent to : '.
      else.
        ITAB-MTEXT = 'Message Sent to : '.
      endif.
*    else.
*
*      ITAB-MTEXT = 'Message Not Sent to : '.
*    endif.
    else.
      "SY-SUBRC Not = 0
      ITAB-MTEXT = 'Payroll data not found : '.
    endif.
    "end of SY-SUBRC = 0.

    modify ITAB.
  endloop. "end loop at ITAB

  sort ITAB by MTEXT PERNR.
  loop at ITAB.
    at new MTEXT.
      uline.
      write : / ITAB-MTEXT color 4 intensified on.
      write : / 'Emp. Code' color 2 intensified on,
             12 'Emp. Name' color 2 intensified on,
             54 'Email ID' color 2 intensified on.
    endat.
    write : / ITAB-PERNR, 12 ITAB-ENAME, 54 ITAB-USRID_LONG.
  endloop.

Read only

Former Member
0 Kudos
2,829

EPORT Z_MAIL_PAYSLIP.

----


  • Declaration Part *

----


tables: PERNR, PV000, T549Q, V_T514D, HRPY_RGDIR.

infotypes: 0000, 0001, 0105, 0655.

data: begin of ITAB occurs 0,

MTEXT(25) type C,

PERNR like PA0001-PERNR,

ABKRS like PA0001-ABKRS,

ENAME like PA0001-ENAME,

USRID_LONG like PA0105-USRID_LONG,

end of ITAB.

data: W_BEGDA like HRPY_RGDIR-FPBEG,

W_ENDDA like HRPY_RGDIR-FPEND.

data: RETURN like BAPIRETURN1 occurs 0 with header line.

data: P_INFO like PC407,

P_FORM like PC408 occurs 0 with header line.

data: P_IDX type I,

MY_MONTH type T549Q-PABRP,

STR_MY_MONTH(2) type C,

MY_YEAR type T549Q-PABRJ,

STR_MY_YEAR(4) type C,

CRLF(2) type x value '0D0A'.

data: W_CMONTH(10) type C.

data: TAB_LINES type I,

ATT_TYPE like SOODK-OBJTP.

data: begin of P_INDEX occurs 0,

INDEX type I,

end of P_INDEX.

constants: begin of F__LTYPE, "type of line

CMD like PC408-LTYPE value '/:', "command

TXT like PC408-LTYPE value 's', "textline

end of F__LTYPE.

constants: begin of F__CMD, "commands

NEWPAGE like PC408-LINDA value '',

end of F__CMD.

data: P_LIST like ABAPLIST occurs 1 with header line.

*data: OBJBIN like SOLISTI1 occurs 10 with header line,

data: OBJBIN like LVC_S_1022 occurs 10 with header line,

DOCDATA like SODOCCHGI1,

OBJTXT like SOLISTI1 occurs 10 with header line,

OBJPACK like SOPCKLSTI1 occurs 1 with header line,

RECLIST like SOMLRECI1 occurs 1 with header line,

OBJHEAD like SOLISTI1 occurs 1 with header line,

it_mess_att LIKE solisti1 OCCURS 0 WITH HEADER LINE,

gd_buffer type string,

l_no_of_bytes TYPE i,

l_pdf_spoolid LIKE tsp01-rqident,

l_jobname LIKE tbtcjob-jobname.

data: file_length type int4,

spool_id type rspoid,

line_cnt type i.

----


* INITIALIZATION *

OBJBIN = ' | '.

append OBJBIN.

OBJPACK-HEAD_START = 1.

data: S_ABKRS like PV000-ABKRS.

data: S_PABRP like T549Q-PABRP.

data: S_PABRJ like T549Q-PABRJ.

----


  • SELECTION SCREEN *

----


selection-screen begin of block BL1.

parameters: PAY_VAR like BAPI7004-PAYSLIP_VARIANT default 'ESS_PAYSLIPS' obligatory.

selection-screen end of block BL1.

START-OF-SELECTION.

s_ABKRS = PNPXABKR.

S_PABRP = PNPPABRP.

s_pabrj = PNPPABRJ.

w_begda = PN-BEGDA.

w_endda = PN-ENDDA.

get pernr.

  • "Check active employees

rp-provide-from-last p0000 space pn-begda pn-endda.

CHECK P0000-STAT2 IN PNPSTAT2.

  • "Check Payslip Mail flag

rp-provide-from-last p0655 space pn-begda pn-endda.

CHECK P0655-ESSONLY = 'X'.

rp-provide-from-last p0001 space pn-begda pn-endda.

  • "Find email address

RP-PROVIDE-FROM-LAST P0105 '0030' PN-BEGDA PN-ENDDA.

if p0105-usrid_LONG ne ''.

ITAB-PERNR = P0001-PERNR.

ITAB-ABKRS = P0001-ABKRS.

ITAB-ENAME = P0001-ENAME.

ITAB-USRID_LONG = P0105-USRID_LONG.

append itab.

clear itab.

endif.

"SY-UCOMM ='ONLI'

END-OF-SELECTION.

----


start-of-selection.

write : / 'Payroll Area : ', S_ABKRS.

write : / 'Payroll Period/Year : ',STR_MY_MONTH,'-',STR_MY_YEAR. write : / 'System Date : ', SY-DATUM.

write : / 'System Time : ', SY-UZEIT.

write : / 'User Name : ', SY-UNAME.

write : / SY-ULINE.

sort ITAB by PERNR.

loop at ITAB.

clear : P_INFO, P_FORM, P_INDEX, P_LIST, OBJBIN, DOCDATA, OBJTXT, OBJPACK, RECLIST, TAB_LINES.

refresh : P_FORM, P_INDEX, P_LIST, OBJBIN, OBJTXT, OBJPACK, RECLIST.

  • Retrieve Payroll results sequence number for this run

select single * from HRPY_RGDIR where PERNR eq ITAB-PERNR

and FPBEG ge W_BEGDA

and FPEND le W_ENDDA

and SRTZA eq 'A'.

  • Produce payslip for those payroll results

if SY-SUBRC = 0.

call function 'GET_PAYSLIP'

EXPORTING

EMPLOYEE_NUMBER = ITAB-PERNR

SEQUENCE_NUMBER = HRPY_RGDIR-SEQNR

PAYSLIP_VARIANT = PAY_VAR

IMPORTING

RETURN = RETURN

P_INFO = P_INFO

TABLES

P_FORM = P_FORM.

check RETURN is initial.

  • remove linetype from generated payslip

loop at p_form.

objbin = p_form-linda.

append objbin.

line_cnt = line_cnt + 1.

endloop.

file_length = line_cnt * 1022.

  • create spool file of paylsip

CALL FUNCTION 'SLVC_TABLE_PS_TO_SPOOL'

EXPORTING

i_file_length = file_length

IMPORTING

e_spoolid = spool_id

TABLES

it_textdata = objbin.

IF sy-subrc EQ 0.

WRITE spool_id.

ENDIF.

DESCRIBE table objbin.

DATA PDF LIKE TLINE OCCURS 100 WITH HEADER LINE.

CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'

EXPORTING

SRC_SPOOLID = spool_id

NO_DIALOG = ' '

DST_DEVICE = 'MAIL'

  • PDF_DESTINATION =

  • IMPORTING

  • PDF_BYTECOUNT = l_no_of_bytes

  • PDF_SPOOLID = l_pdf_spoolid

  • LIST_PAGECOUNT =

  • BTC_JOBNAME =

  • BTC_JOBCOUNT =

TABLES

PDF = 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

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

*Download PDF file C Drive

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

filename = 'C:\itab_to_pdf.pdf'

filetype = 'BIN'

TABLES

data_tab = pdf.

  • Transfer the 132-long strings to 255-long strings

  • LOOP AT pdf.

  • TRANSLATE pdf USING ' ~'.

  • CONCATENATE gd_buffer pdf INTO gd_buffer.

  • ENDLOOP.

*

  • TRANSLATE gd_buffer USING '~ '.

*

  • DO.

  • it_mess_att = gd_buffer.

  • APPEND it_mess_att.

  • SHIFT gd_buffer LEFT BY 255 PLACES.

  • IF gd_buffer IS INITIAL.

  • EXIT.

  • ENDIF.

  • ENDDO.

OBJHEAD = 'Objhead'.

append OBJHEAD.

  • preparing email subject

concatenate W_ENDDA(6)

' Payslip-'

ITAB-ENAME+0(28)

'('

ITAB-PERNR+4(4) ')'

into DOCDATA-OBJ_DESCR.

DOCDATA-OBJ_NAME = 'Pay Slip'.

DOCDATA-OBJ_LANGU = SY-LANGU.

OBJTXT = 'Pay Slip.'.

append OBJTXT.

*prepare email lines

OBJTXT = DOCDATA-OBJ_DESCR.

append OBJTXT.

OBJTXT = 'Please find enclosed your current payslip.'.

append OBJTXT.

  • Write Attachment(Main)

  • 3 has been fixed because OBJTXT has fix three lines

read table OBJTXT index 3.

  • DOCDATA-DOC_SIZE = ( 3 - 1 ) * 255 + strlen( OBJTXT ).

clear OBJPACK-TRANSF_BIN.

OBJPACK-HEAD_START = 1.

OBJPACK-HEAD_NUM = 0.

OBJPACK-BODY_START = 1.

OBJPACK-BODY_NUM = 3.

OBJPACK-DOC_TYPE = 'RAW'.

append OBJPACK.

  • Create Message Attachment

ATT_TYPE = 'PDF'.

describe table OBJBIN lines TAB_LINES.

read table OBJBIN index TAB_LINES.

  • OBJPACK-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + strlen( OBJBIN ).

OBJPACK-TRANSF_BIN = 'X'.

OBJPACK-HEAD_START = 1.

OBJPACK-HEAD_NUM = 0.

OBJPACK-BODY_START = 1.

OBJPACK-BODY_NUM = TAB_LINES.

OBJPACK-DOC_TYPE = ATT_TYPE.

OBJPACK-OBJ_NAME = 'ATTACHMENT'.

OBJPACK-OBJ_DESCR = 'Payslip'.

append OBJPACK.

  • Create receiver list refresh RECLIST.

clear RECLIST.

RECLIST-RECEIVER = itab-USRID_long.

translate RECLIST-RECEIVER to lower case.

RECLIST-REC_TYPE = 'U'.

append RECLIST.

  • Send the document

*SO_NEW_DOCUMENT_ATT_SEND_API1

call function 'SO_DOCUMENT_SEND_API1'

exporting

DOCUMENT_DATA = DOCDATA

PUT_IN_OUTBOX = 'X'

COMMIT_WORK = 'X'

  • IMPORTING

  • SENT_TO_ALL =

  • NEW_OBJECT_ID =

tables

PACKING_LIST = OBJPACK

OBJECT_HEADER = OBJHEAD

CONTENTS_BIN = pdf

CONTENTS_TXT = OBJTXT

  • CONTENTS_HEX =

  • OBJECT_PARA =

  • OBJECT_PARB =

RECEIVERS = RECLIST

exceptions

TOO_MANY_RECEIVERS = 1

DOCUMENT_NOT_SENT = 2

DOCUMENT_TYPE_NOT_EXIST = 3

OPERATION_NO_AUTHORIZATION = 4

PARAMETER_ERROR = 5

X_ERROR = 6

ENQUEUE_ERROR = 7

others = 8.

if SY-SUBRC NE 0.

ITAB-MTEXT = 'Message Not Sent to : '.

else.

ITAB-MTEXT = 'Message Sent to : '.

endif.

  • else.

*

  • ITAB-MTEXT = 'Message Not Sent to : '.

  • endif.

else.

"SY-SUBRC Not = 0

ITAB-MTEXT = 'Payroll data not found : '.

endif.

"end of SY-SUBRC = 0.

modify ITAB.

endloop. "end loop at ITAB

sort ITAB by MTEXT PERNR.

loop at ITAB.

at new MTEXT.

uline.

write : / ITAB-MTEXT color 4 intensified on.

write : / 'Emp. Code' color 2 intensified on,

12 'Emp. Name' color 2 intensified on,

54 'Email ID' color 2 intensified on.

endat.

write : / ITAB-PERNR, 12 ITAB-ENAME, 54 ITAB-USRID_LONG.

endloop.

Read only

0 Kudos
2,829

Hi,

Please Check this =>

Faisal

Read only

Former Member
0 Kudos
2,829

Not answered

Read only

Former Member
Read only

0 Kudos
2,829

Thanks for the reply guys.

I've tried adding in the print parameters function and I'm checking that I do have data in the spool but I still get the error?

Read only

0 Kudos
2,829

Hi,

Check the below link

http://www.sapdev.co.uk/reporting/rep_spooltopdf.htm

Regards,

Nagaraj

Read only

Former Member
0 Kudos
2,829

Hi ,

Try using Function Module,

JIT03_WRITE_TEXT_TO_SPOOL

Hope it helps

Regards

Mansi

Read only

Former Member
0 Kudos
2,829

why dont you debug and check what is being passed to your FM

Read only

0 Kudos
2,829

I have been debugging. The output from the table to spool conversion [objbin] has data in it, and if I check the spool id in sp01 it does have the data, when I pass the spool id to CONVERT_ABAPSPOOLJOB_2_PDF I get the error saying no ABAP list data.

I've tried using a write statement to create the spool and that works but I need the data from an internal table...

Read only

0 Kudos
2,829

Hello Rob,

The problem lies with the FM SLVC_TABLE_PS_TO_SPOOL. The spool generated by this FM is not a ABAP LIST and just a binary document. But for the FM CONVERT_ABAPSPOOLJOB_2_PDF to convert the spool to pdf, the spool should be in the ABAP List format. Thats the reason why you are getting the error 'No ABAP List Data'.

To confirm this, just use a simple write statement in your report and schedule it as a background job. Now pass this spool id to the FM CONVERT_ABAPSPOOLJOB_2_PDF in SE37 and check. It will work. Thats because the spool generated as a result of the background job is a ABAP list

Vikranth

Read only

0 Kudos
2,829

That's what I thought as well.

I've got round it by writing out each line from my internal table to a spool manually.

Thanks for the help all.