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: 

How can I get multiple pdf file in single background job

Former Member
0 Kudos

Dear Experts,

I need to send a customer statement for each customer. If i excute back ground job, got single pdf file for entire customers. My requirment is, each customer should be get their statment only. That means 10 customers = 10 pdf file in a single job. Is there any idea?

Thanks in Advance.

Regards,

Arsath. A

12 REPLIES 12

Former Member
0 Kudos

Hi Azeez,

Design the form accordingly to each customer.Call the specific form for each customer according to some conditions only.Before calling the smart form or adobe form you should check for the customer and call the corresponding form.

Regards,

Simi A M

Former Member
0 Kudos

Hi,

Thanks for your immediate reply. but I could not refresh/clear the spool contents. If I am design in loop, the first customer get the exact their details then the second customer got first two customer details, like that Nth customer got up to Nth-customer details. My requirement is each customer should be getting only their details.

Thanks in Advance.

Regards,

Ahmed. A

former_member182040
Active Contributor
0 Kudos

if you can use FM CONVERT_OTF then u can put in to loop so u can send number of pdf file base on customer number i do like that its work fine.

0 Kudos

Hi kru,

I did the code as follows,

Loop at customer.

perform customer_statement.

perform spool_list.

perform convert_pdf.

perform send_mail.

endloop.

but it doesn't work... Please let me know, any idea...

Thanks & Regards,

Arsath. A

0 Kudos

START-OF-SELECTION.
CALL FUNCTION 'OPEN_FORM'
FETCH DATA INTO ITAB.

LOOP AT ITAB
CALL FUNCTION 'START_FORM'.

CALL FUNCTION 'CLOSE_FORM'
        IMPORTING
          RESULT  = w_result
        TABLES
          otfdata = it_otfdata.

PERFORM PDF
CALL FUNCTION 'OPEN_FORM'
ENDLOOP
CALL FUNCTION 'CLOSE_FORM'
    

FORM pdf .
  CLEAR gt_otf.
  REFRESH gt_otf ."
  gt_otf[] = it_otfdata[].
*• Convert the OTF DATA to SAP Script Text lines
  CLEAR gt_pdf_tab.

  CALL FUNCTION 'CONVERT_OTF'
   EXPORTING
     format                      = 'PDF'
     max_linewidth               = 132
*   ARCHIVE_INDEX               = ' '
*   COPYNUMBER                  = 0
*   ASCII_BIDI_VIS2LOG          = ' '
*   PDF_DELETE_OTFTAB           = ' '
   IMPORTING
     bin_filesize                = gv_bin_filesize
*   BIN_FILE                    =
    TABLES
      otf                         = gt_otf
      lines                       = gt_pdf_tab
   EXCEPTIONS
     err_max_linewidth           = 1
     err_format                  = 2
     err_conv_not_possible       = 3
     err_bad_otf                 = 4
     OTHERS                      = 5.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
   
  PERFORM send_mail.
ENDFORM.                    " PDF

Former Member
0 Kudos

Hi kru,

I did the code as follows,

Loop at customer.

perform customer_statement{Normal report - Not in ALV/Smartform}.

perform spool_list.

perform convert_pdf.

perform send_mail.

{Here, Is there any option to refresh/clear spool in frequently. My problem is, first time loop excuted only one customer. second time, its executed upto two customer. Here I need only second customer details}

endloop.

Please let me know, any idea...

Thanks & Regards,

Arsath. A

Edited by: Ahmed Arsath Abdul Azees on Mar 16, 2011 7:08 AM

0 Kudos

Hi,

you convert data into OTF SO pl check again my code i put close form out of loop

0 Kudos

Hi,

While preparing the spool list ( perform spool_list ) you need to pass it as a new spool.

pass 'X' to the parameter "NEW_LIST_ID" in FM "GET_PRINT_PARAMETERS" .

Regards,

Srini.

0 Kudos

0 Kudos

Dear,

Sorry. I Couldn't reach my goal. Here I have attaced that code. Could u please read & advise me...

LOOP AT cust_mail. "No. of customers

clear: p_email1, p_kunnr,bsad_tab1, bsid_tab.

perform get_ac_state. "output - Normal Report

  • new-page.

commit work.

  • ITCPO-TDDELETE = ''.

  • ITCPO-TDNEWID = 'X'.

new-page print off.

IF sy-batch EQ 'X'. " for backgroung job

PERFORM get_job_details.

PERFORM obtain_spool_id.

PERFORM convert_spool_to_pdf.

PERFORM process_email.

ENDIF.

Endloop.

FORM get_job_details.

  • Get current job details

CALL FUNCTION 'GET_JOB_RUNTIME_INFO'

IMPORTING

eventid = gd_eventid

eventparm = gd_eventparm

external_program_active = gd_external_program_active

jobcount = gd_jobcount

jobname = gd_jobname

stepcount = gd_stepcount

EXCEPTIONS

no_runtime_info = 1

OTHERS = 2.

ENDFORM.

----


  • FORM obtain_spool_id *

----


FORM obtain_spool_id.

CHECK NOT ( gd_jobname IS INITIAL ).

CHECK NOT ( gd_jobcount IS INITIAL ).

  • perform create_spool.

clear : it_tbtcp, wa_tbtcp.

refresh: it_tbtcp.

SELECT * FROM tbtcp

INTO TABLE it_tbtcp

WHERE jobname = gd_jobname

AND jobcount = gd_jobcount

AND stepcount = gd_stepcount

AND listident <> '0000000000'

ORDER BY jobname

jobcount

stepcount.

READ TABLE it_tbtcp INTO wa_tbtcp INDEX 1.

IF sy-subrc = 0.

message s004(zdd) with gd_spool_nr.

gd_spool_nr = wa_tbtcp-listident.

MESSAGE s004(zdd) WITH gd_spool_nr.

ELSE.

MESSAGE s005(zdd).

ENDIF.

ENDFORM.

----


  • FORM convert_spool_to_pdf *

----


FORM convert_spool_to_pdf.

CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'

EXPORTING

src_spoolid = gd_spool_nr

no_dialog = c_no

dst_device = c_device

IMPORTING

pdf_bytecount = gd_bytecount

TABLES

pdf = it_pdf_output

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.

CHECK sy-subrc = 0.

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

LOOP AT it_pdf_output.

TRANSLATE it_pdf_output USING ' ~'.

CONCATENATE gd_buffer it_pdf_output INTO gd_buffer.

ENDLOOP.

TRANSLATE gd_buffer USING '~ '.

  • clear : it_mess_att.

  • refresh : it_mess_att.

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.

clear: gd_buffer.

  • refresh: gd_buffer.

*CALL FUNCTION 'BAL_DSP_OUTPUT_INIT'

  • EXPORTING

  • I_S_DISPLAY_PROFILE = it_pdf_output

*refresh it_pdf_output.

*free it_pdf_output.

.

ENDFORM.

FORM process_email.

******

ENDFORM.

-


In this case, first loop execute only first customer(create PDF).

second time, its execute first two customers( in PDF file),

Nth time, its create the PDF file for 1st custmer to Nth customer).

Actual requirement is send to Each customer have got their own details only.

Thanks in Advance...

Regards,

Arsath. A

0 Kudos

Hi,

After sending email we can delete the spool request in runtime. We can use this FM RSPO_R_RDELETE_SPOOLREQ . We need to pass spool no only.

If we delete the spool in runtime then we will not get the previous customer entries. Please try once and let us know.

Thanks

Chandan

0 Kudos

Hi,

Its created first customer only. Second time in Loop, we got error message & look in sm37, "spool request does not exist.

Job also cancelled due to process termination".

Thanks & Regards,

Arsath. A