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

function module

Former Member
0 Likes
924

hai,

i am getting the errors when i ma attaching the SAPSCRIPT to my function module..

kindly inform me if there is error i my statements used..

FUNCTION ZSENDMAIL_SCRIPT.

*"----


""Local Interface:

*"----


----


  • DATABASE TABLES *

----


TABLES : ZHR_TABLE.

----


  • INTERNAL TABLE DECLARATIONS *

----


DATA: IT_TAB TYPE TABLE OF ZHR_TABLE INITIAL SIZE 0 WITH HEADER LINE,

WA_TAB TYPE ZHR_TABLE,

X_ITCPO TYPE ITCPO,

X_ITCPP1 TYPE ITCPO,

C_ADDR_TYPE type SOEXTRECI1-ADR_TYP value 'INT',

MAILADDRESS type ZHR_TABLE-EMPSUPERVISOR,

EMPNAME TYPE ZHR_TABLE-EMPNAME,

X_DOCDATA TYPE SODOCCHGI1,

  • CONSTANT :

MY_FORM(20) TYPE C VALUE ‘ZSEND_MAIL’,

C_DEVICE_PRINTER(7) type c value 'PRINTER',

C_RESET TYPE C VALUE ' ' ,

C_SEND_IMM(3) type c value 'IMM',

C_SET TYPE C VALUE 'X',

C_MAIN(4) type c value 'MAIN'.

C_NON_SPACE type c value '',

C_DOC_TYPE(3) type c value 'RAW',

C_FUNC_SET(3) type c value 'SET',

C_TYPE_BODY(4) Type c value 'BODY',

C_ELEMENT2(20) TYPE C VALUE ‘SCRIPTEMPNAME’ .

----


  • FIELD SYMBOL DECLARATIONS *

----


FIELD-SYMBOLS <FS1> TYPE ANY.

SELECT EMPNAME EMPSUPERIOR FROM ZHR_TABLE INTO TABLE IT_TAB.

LOOP IT_TAB INTO WA_TAB.

ASSIGN (WA_TAB-EMPNAME) TO <FS1>.

CALL FUNCTION 'TEXT_SYMBOL_SETVALUE'

EXPORTING

NAME = WA_TAB-EMPNAME

VALUE = <FS1>

VALUE_LENGTH = VALUE

REPLACE_SYMBOLS = C_SET.

  • CLEAR : WA_TAB-EMPNAME.

MAILADDRESS = WA_ITAB-EMPSUPERVISOR.

---- Subject of the email -


ELEMENT = C_ELEMENT2.

------ Printer settings structure -


X_ITCPO-TDDEST = C_NON_SPACE.

X_ITCPO-TDRDIDEV = C_NON_SPACE.

X_ITCPO-TDNEWID = C_SET.

X_ITCPO-TDSENDDATE = SY-DATUM.

X_ITCPO-TDSENDTIME = SY-UZEIT.

X_ITCPO-TDSCHEDULE = C_SEND_IMM.

X_ITCPO-TDIMMED = C_RESET.

------- Sapscript form to be called -


FORMNAME = MY_FORM.

----


Open form function module -

CALL FUNCTION 'OPEN_FORM'

EXPORTING

  • APPLICATION = 'TX'

  • ARCHIVE_INDEX =

  • ARCHIVE_PARAMS =

DEVICE = C_DEVICE_PRINTER

DIALOG = C_RESET

FORM = FORMNAME

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.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = ELEMENT

FUNCTION = C_FUNC_SET

TYPE = C_TYPE_BODY

WINDOW = C_MAIN

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.

------- calling function module close_form -


CALL FUNCTION 'CLOSE_FORM'

IMPORTING

RESULT = X_ITCPP2

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.

COMMIT WORK.

---- Mail is sent using the below called F.M. -


IT_TAB -transf_bin = space.

IT_TAB -head_start = 1.

IT_TAB -head_num = 0.

IT_TAB -body_start = 1.

IT_TAB -doc_type = C_DOC_TYPE.

APPEND WA_ITAB TO IT_TAB.

CALL FUNCTION 'SO_DOCUMENT_SEND_API1'

EXPORTING

DOCUMENT_DATA = X_DOCDATA

PUT_IN_OUTBOX = C_SET

SENDER_ADDRESS = MAILADDRESS

SENDER_ADDRESS_TYPE = C_ADDR_TYPE

COMMIT_WORK = C_SET

  • IMPORTING

  • SENT_TO_ALL =

  • NEW_OBJECT_ID =

  • SENDER_ID =

TABLES

PACKING_LIST = IT_TAB.

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.

ENDFUNCTION.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
853

Hi,

the parameters which you are using is some thing wrong..

'SO_DOCUMENT_SEND_API1'

also check the example mentioned in the documentation..

check this..

http://www.sapdevelopment.co.uk/reporting/email/emailhome.htm

regards

vijay

10 REPLIES 10
Read only

Former Member
0 Likes
853

hi Raj,

post us the error that you are getting ...

Regards,

Santosh

Read only

Former Member
0 Likes
854

Hi,

the parameters which you are using is some thing wrong..

'SO_DOCUMENT_SEND_API1'

also check the example mentioned in the documentation..

check this..

http://www.sapdevelopment.co.uk/reporting/email/emailhome.htm

regards

vijay

Read only

0 Likes
853
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
DOCUMENT_DATA = X_DOCDATA
PUT_IN_OUTBOX = C_SET
SENDER_ADDRESS = MAILADDRESS
SENDER_ADDRESS_TYPE = C_ADDR_TYPE
COMMIT_WORK = C_SET
* IMPORTING
* SENT_TO_ALL =
* NEW_OBJECT_ID =
* SENDER_ID =
TABLES
<b>PACKING_LIST = IT_TAB</b>.

IT_ITAB data should be of SOPCKLSTI1 type .

but it is differently declared..

some thing wrong with your coding also..

Regards

vijay

Read only

0 Likes
853

hi vijay,

can u please send me some program that converts into the SAPSCRIPT..and sends to the particular receiver.????

Read only

0 Likes
853

Hi,

generally we do this way....

first Get the OTF data, and then with that OTF data we cinvert PDFand then mail it. the PDF file will have the same output as script.

check this...

http://www.sapgenie.com/abap/pdf_creation.htm

also give the mail id ,i will send it..

Regards

vijay

Message was edited by: Vijay Babu Dudla

Read only

0 Likes
853

hi vijay...

my mail id is ssrajkumar2004@yahoo.com..plz clear me if have doubts further..thankx in advance..

Read only

0 Likes
853

Hi,

Check your mail. i sent the same Program..

Regards

vijay

Read only

Former Member
0 Likes
853

Hi,

In the NACE, in place of program name give the program name (function pool) , This one you can get from SE37->Attributes->General Data->Program Name.

<i>

Hope This Info Helps YOU.</i>

Regards,

Raghav

Read only

Former Member
0 Likes
853

How is FORMNAME defined??

Read only

Former Member
0 Likes
853

Hi,

I used the following FM to send mails with attachments:

SO_NEW_DOCUMENT_ATT_SEND_API1.

The FM interface is veru much similar to the one you are using. So try using this FM.

Regards,

Sumant.