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

problem with spoolfile

Former Member
0 Likes
1,075

hi there,

in a abap in the end-of-selection i do some sum up in a list with the write statement.

write: .........................
write:.........................

directly after that i call a program which converts the spoolfile of the batch-job into an pdf-file and mail it.

the big problem with that: sometimes i get corrupted pdf-files as the spoolfile is not finished at this time.

how can i avoid that. how do i know when the spoolfile is finished to convert it into pdf ?

my workaround now is the following: before doing the pdf-conversion i have a

WAIT UP TO 60 SECONDS.

so i wait 60 seconds. but i think that is a 'quick and dirty' solution.

any ideas ???

reg, martin

7 REPLIES 7
Read only

Former Member
0 Likes
1,011

Hi,

How are you fetching the spool number?

Can you share the code for troubleshooting.

Regards

Karthik D

Read only

0 Likes
1,011
write: / '**', prt-bukr,
              (9) prt-lrhm under prt-lrhm,
              (9) prt-lore under prt-lore,
              (9) prt-lfre under prt-lfre,
              (9) prt-brhm under prt-brhm,
              (9) prt-bzin under prt-bzin,
              (9) prt-bfzg under prt-bfzg,
              (9) prt-bfre under prt-bfre,
              (9) prt-grhm under prt-grhm,
              (9) prt-gore under prt-gore,
              (9) prt-gfre under prt-gfre.
    endat.
  endloop.


  wait up to 60 seconds.

  if sy-batch = 'X' and p_mail = 'X'.

    call function 'GET_JOB_RUNTIME_INFO'
      importing
        eventid                 = lf_eventid
        eventparm               = lf_eventparm
        external_program_active = lf_external_program_active
        jobcount                = lf_jobcount
        jobname                 = lf_jobname
        stepcount               = lf_stepcount
      exceptions
        no_runtime_info         = 1
        others                  = 2.
    if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.

    select single * from tbtcp where jobname = lf_jobname
                               and jobcount = lf_jobcount
                               and stepcount = lf_stepcount.
*
    if sy-subrc = 0.
      lf_spono = tbtcp-listident.
    else.
      lf_spono = 0.
    endif.

after that i do i submit of an Z-abap which creates the pdf with lf_spono as spoolnumber.

reg, Martin

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,011

Hello Martin,

Where is your NEW-PAGE PRINT OFF stmt?

I think you are missing that.

BR,

Suhas

Read only

0 Likes
1,011

i have the new-page print off in it, but it is of NO USE !!!

a new-page print off without a new-page print on is not working.

and new-page print on should NOT be used anymore. i got a warning when activating abap-code !

reg, Martin

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,011

Hello,

Then try:

NEW-PAGE.
WRITE: /'Test Suhas'.
NEW-PAGE PRINT OFF.

Does this help?

BR,

Suhas

Read only

venkat_o
Active Contributor
0 Likes
1,011

Hi, <li>Try this way to get spool no


 REPORT ztest_notepad.
 "Variables
 DATA:
    l_lay    TYPE pri_params-paart,
    l_lines  TYPE pri_params-linct,
    l_cols   TYPE pri_params-linsz,
    l_val    TYPE c.
"Types
 TYPES:
    t_pripar TYPE pri_params,
    t_arcpar TYPE arc_params.
 "Work areas
 DATA:
    lw_pripar TYPE t_pripar,
    lw_arcpar TYPE t_arcpar.

 PARAMETERS : p_data(10).

 START-OF-SELECTION.

   l_lay   = 'X_65_132'.
   l_lines = 65.
   l_cols  = 132.

   CALL FUNCTION 'GET_PRINT_PARAMETERS'
     EXPORTING
       in_archive_parameters  = lw_arcpar
       in_parameters          = lw_pripar
       layout                 = l_lay
       line_count             = l_lines
       line_size              = l_cols
       no_dialog              = 'X'
     IMPORTING
       out_archive_parameters = lw_arcpar
       out_parameters         = lw_pripar
       valid                  = l_val
     EXCEPTIONS
       archive_info_not_found = 1
       invalid_print_params   = 2
       invalid_archive_params = 3
       OTHERS                 = 4.
   IF l_val  NE space AND sy-subrc = 0.
     lw_pripar-prrel = space.
     lw_pripar-primm = space.
     NEW-PAGE PRINT ON
       NEW-SECTION
       PARAMETERS lw_pripar
       ARCHIVE PARAMETERS lw_arcpar
       NO DIALOG.
   ENDIF.
   WRITE 'Output in spool'.
   NEW-PAGE PRINT OFF.
   CALL FUNCTION 'ABAP4_COMMIT_WORK'.
   write sy-spono.
<li>Use CONVERT_ABAPSPOOLJOB_2_PDF function module to convert spool to PDF. <li>Use SO_NEW_DOCUMENT_ATT_SEND_API1 function module to send mail that PDF as attachment. Thanks Venkat.O

Read only

Former Member
0 Likes
1,011

EXAMPLE:


 tYPE-POOLS: slis.

TYPES: BEGIN OF str_mara,
matnr TYPE mara-matnr,
ersda TYPE mara-ersda,
ernam TYPE mara-ernam,
laeda TYPE mara-laeda,
aenam TYPE mara-aenam,
vpsta TYPE mara-vpsta,
END OF str_mara.

DATA: i_mat TYPE TABLE OF str_mara,
wa_mat LIKE LINE OF i_mat.
DATA:params LIKE pri_params.

DATA: days(1) TYPE n VALUE 2,
valid TYPE c.

DATA: obj TYPE REF TO cl_salv_table.
SELECT matnr
ersda
ernam
laeda
aenam
vpsta
UP TO 4999 ROWS
FROM mara INTO CORRESPONDING FIELDS OF TABLE i_mat.

TRY.
CALL METHOD cl_salv_table=>factory
IMPORTING
r_salv_table = obj
CHANGING
t_table = i_mat.
CATCH cx_salv_msg .
ENDTRY.

CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
* destination = 'QAS'
list_name = 'ZTEST_VERTEX'
list_text = 'TEST'
no_dialog = 'X'
immediately = ' '
expiration = days
IMPORTING
* OUT_ARCHIVE_PARAMETERS =
out_parameters = params
valid = valid
* VALID_FOR_SPOOL_CREATION =
EXCEPTIONS
archive_info_not_found = 1
invalid_print_params = 2
invalid_archive_params = 3
OTHERS = 4
.
IF sy-subrc ne 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.

TRY .
NEW-PAGE PRINT ON PARAMETERS params NO DIALOG.
CATCH cx_sy_nested_print_on .
ENDTRY.

CALL METHOD obj->display.

NEW-PAGE PRINT OFF.