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: 

report program

Former Member
0 Kudos

hi,

i am able to get the preview for the below program..But i am not getting the spool list..and want to check whether the following mail has been successfully sent to the receiver in sost transaction..kindly resolve this problem...i am also getting the runtime error for this..which is causing more problem..kindly try this program and suggest me a solution

*&----


**& Report ZKP_SAPSCRIPT *

**& *

*&----


**& *

*& *

&----


REPORT zkp_sapscript.

DATA : x_itcpo TYPE itcpo, "SAPscript output interface

x_itcpp1 TYPE itcpp, "SAPscript output parameters

x_itcpp2 TYPE itcpp,

c_std_text(8) TYPE c VALUE 'STD_TEXT', "variable that is used in SAP SCRIPT

it_packing_list TYPE TABLE OF sopcklsti1 INITIAL SIZE 0 WITH HEADER LINE,

it_objtxt TYPE TABLE OF solisti1 INITIAL SIZE 0 WITH HEADER LINE,

s_spool TYPE tsp01-rqident,

it_spool_file TYPE TABLE OF soli INITIAL SIZE 0 WITH HEADER LINE,

v_sender TYPE soextreci1-receiver VALUE 'KARTHIK.PRABHU@LNTINFOTECH.COM',

c_addr_type TYPE soextreci1-adr_typ VALUE 'INT',

it_reclist TYPE TABLE OF somlreci1 INITIAL SIZE 0 WITH HEADER LINE,

v_receiver TYPE somlreci1-receiver VALUE 'KARTHIK.PRABHU@LNTINFOTECH.COM',

x_docdata TYPE sodocchgi1,

tab_lines TYPE sy-tabix,

lin1 TYPE i.

------ Printer settings structure -


x_itcpo-tddest = ''.

x_itcpo-tdrdidev = ''.

x_itcpo-tdnewid = 'x'.

x_itcpo-tdsenddate = sy-datum.

x_itcpo-tdsendtime = sy-uzeit.

x_itcpo-tdschedule = 'imm'.

x_itcpo-tdimmed = ' '.

CALL FUNCTION 'OPEN_FORM'

EXPORTING

  • APPLICATION = 'TX'

  • ARCHIVE_INDEX =

  • ARCHIVE_PARAMS =

device = 'PRINTER'

dialog = 'X'

form = 'ZTEST_FORM7 '

language = sy-langu

options = x_itcpo

  • MAIL_SENDER =

  • MAIL_RECIPIENT =

  • MAIL_APPL_OBJECT =

  • RAW_DATA_INTERFACE = '*'

  • SPONUMIV =

  • IMPORTING

  • LANGUAGE =

  • NEW_ARCHIVE_PARAMS =

  • RESULT = X_ITCPP1

  • EXCEPTIONS

  • CANCELED = 1

  • DEVICE = 2

  • FORM = 3

  • OPTIONS = 4

  • UNCLOSED = 5

  • MAIL_OPTIONS = 6

  • ARCHIVE_ERROR = 7

  • INVALID_FAX_NUMBER = 8

  • MORE_PARAMS_NEEDED_IN_BATCH = 9

  • SPOOL_ERROR = 10

  • CODEPAGE = 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.

*Assigning the standard text name

CALL FUNCTION 'TEXT_SYMBOL_SETVALUE'

EXPORTING

name = c_std_text

value = 'ZTEST_STD1'

value_length = 0

replace_symbols = 'x'.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

element = 'E05_HEADER '

function = 'SET'

type = 'BODY'

window = 'MAIN'

  • IMPORTING

  • PENDING_LINES =

  • EXCEPTIONS

  • ELEMENT = 1

  • FUNCTION = 2

  • TYPE = 3

  • UNOPENED = 4

  • UNSTARTED = 5

  • WINDOW = 6

  • BAD_PAGEFORMAT_FOR_PRINT = 7

  • SPOOL_ERROR = 8

  • CODEPAGE = 9

  • OTHERS = 10

.

IF sy-subrc <> 0.

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

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

ENDIF.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

element = 'ELEMENT1'

function = 'SET'

type = 'BODY'

window = 'MAIN'

  • IMPORTING

  • PENDING_LINES =

  • EXCEPTIONS

  • ELEMENT = 1

  • FUNCTION = 2

  • TYPE = 3

  • UNOPENED = 4

  • UNSTARTED = 5

  • WINDOW = 6

  • BAD_PAGEFORMAT_FOR_PRINT = 7

  • SPOOL_ERROR = 8

  • CODEPAGE = 9

  • OTHERS = 10

.

IF sy-subrc <> 0.

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

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

ENDIF.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

element = 'E05_FOOTER '

function = 'SET'

type = 'BODY'

window = 'MAIN'

  • IMPORTING

  • PENDING_LINES =

  • EXCEPTIONS

  • ELEMENT = 1

  • FUNCTION = 2

  • TYPE = 3

  • UNOPENED = 4

  • UNSTARTED = 5

  • WINDOW = 6

  • BAD_PAGEFORMAT_FOR_PRINT = 7

  • SPOOL_ERROR = 8

  • CODEPAGE = 9

  • OTHERS = 10

.

IF sy-subrc <> 0.

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

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

ENDIF.

CALL FUNCTION 'CLOSE_FORM'

IMPORTING

RESULT = x_itcpp2

  • RDI_RESULT =

  • TABLES

  • OTFDATA =

EXCEPTIONS

UNOPENED = 1

BAD_PAGEFORMAT_FOR_PRINT = 2

SEND_ERROR = 3

SPOOL_ERROR = 4

CODEPAGE = 5

OTHERS = 6

.

IF sy-subrc <> 0.

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

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

ENDIF.

***********************EXECUTES SUCCESSFULLY UNTIL THIS*********************************

------- spool no. of the spool generated -


s_spool = x_itcpp2-tdspoolid.

------- Fetching of the spool contents -


IF NOT s_spool IS INITIAL.

CALL FUNCTION 'RSPO_RETURN_SPOOLJOB'

EXPORTING

rqident = s_spool

first_line = 1

last_line = 1000

desired_type = 'RAW'

  • IMPORTING

  • REAL_TYPE =

  • SP_LANG =

TABLES

buffer = it_spool_file "mail content

  • BUFFER_PDF =

  • EXCEPTIONS

  • NO_SUCH_JOB = 1

  • JOB_CONTAINS_NO_DATA = 2

  • SELECTION_EMPTY = 3

  • NO_PERMISSION = 4

  • CAN_NOT_ACCESS = 5

  • READ_ERROR = 6

  • TYPE_NO_MATCH = 7

  • OTHERS = 8

.

IF sy-subrc <> 0.

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

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

ENDIF.

ENDIF.

CALCULATING THE NO OF RECORDS IN IT_SPOOL_FILE************

DESCRIBE TABLE it_spool_file LINES lin1.

*------ Filling the spool contents into internal table obtxt,-----

*------ whose contents will be displayed as the body of email -


*

IF lin1 GT 0.

LOOP AT it_spool_file.

it_objtxt-line = it_spool_file-line.

APPEND it_objtxt.

CLEAR it_objtxt.

CLEAR it_spool_file-line.

ENDLOOP.

ENDIF.

DESCRIBE TABLE it_objtxt LINES tab_lines.

READ TABLE it_objtxt INDEX tab_lines.

*------ Calculating doc. size which is email -


*

x_docdata-obj_name = 'ZTEST_STD1'.

x_docdata-obj_descr = 'HAI TEST'.

x_docdata-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( it_objtxt ).

*THIS SET OF CODE IS TO UPDATE THE RECEIVER EMAIL ADDRESS

CLEAR it_reclist.

REFRESH it_reclist.

it_reclist-receiver = v_receiver.

it_reclist-rec_type = 'U'.

it_reclist-copy = ' '.

it_reclist-blind_copy = ' '.

APPEND it_reclist.

*contains the document description

CLEAR it_packing_list.

REFRESH it_packing_list.

it_packing_list-transf_bin = space.

it_packing_list-head_start = 1.

it_packing_list-head_num = 0.

it_packing_list-body_start = 1.

DESCRIBE TABLE it_objtxt LINES it_packing_list-body_num.

it_packing_list-doc_type = 'RAW'.

APPEND it_packing_list.

*this is the function module which sends the mail

CALL FUNCTION 'SO_DOCUMENT_SEND_API1'

EXPORTING

document_data = x_docdata

put_in_outbox = 'X'

sender_address = v_sender "senders mail address

sender_address_type = 'INT'

commit_work = 'X'

  • IMPORTING

  • SENT_TO_ALL =

  • NEW_OBJECT_ID =

  • SENDER_ID =

TABLES

packing_list = it_packing_list

  • OBJECT_HEADER =

  • CONTENTS_BIN =

contents_txt = it_objtxt "this is the table which contains the content of the mail

  • CONTENTS_HEX =

  • OBJECT_PARA =

  • OBJECT_PARB =

receivers = it_reclist "contains the receivers mail id

  • 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 <> 0.

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

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

Message was edited by: rajkumar shanmuganathan

2 REPLIES 2

Former Member
0 Kudos

Hi

Use SCOT trx to check if your message was sent succeffully.

Which error do you get?

Max

0 Kudos

hi,

i am getting the run time error for that report program..kindly resolve that...