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: 

Sapscript and OPEN_FORM

Former Member
0 Kudos

Hallo,

i use the FM OPEN_FORM to send some Sapscriptformular

per email. This works correct. The Formular is an Attachment in PDF. This is also correct.

Now i want to change the email-Header and the email-Text

to give the Receiver some Information.

Is there any Parameter in OPEN_FORM to do this, or

is there a special FM?

I hope anyone has an Idea.

Regards,

Dieter

6 REPLIES 6

Former Member
0 Kudos

Hai Dieter

Check with the following Code

CALL FUNCTION 'OPEN_FORM'

EXPORTING

  • application = 'TX'

  • ARCHIVE_INDEX =

  • ARCHIVE_PARAMS =

device = 'PRINTER'

dialog = ''

form = 'Z_Form'

language = sy-langu

OPTIONS = itcpo

  • MAIL_SENDER =

  • MAIL_RECIPIENT =

  • MAIL_APPL_OBJECT =

  • RAW_DATA_INTERFACE = '*'

  • IMPORTING

  • LANGUAGE =

  • NEW_ARCHIVE_PARAMS =

  • RESULT =

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

OTHERS = 11

.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

in Exporting Parameters pass the values to

MAIL_SENDER =

MAIL_RECIPIENT =

MAIL_APPL_OBJECT =

that will help your requirement

Thanks & regards

Sreenivasulu P

Former Member
0 Kudos

Hi Dieter,

Is this regarding HR module, which is transaction PB60, or etc relates to HR?

If so, you just can change the email subject but not the email body content.

Here is the code for your reference on adding the subject, just create a subroutine called 'fill_customer_subject' in ZPAP3CUS (this is called by SAPMPAP3 (Transaction PB60).

FORM fill_customer_subject

USING p_p0001 STRUCTURE p0001

p_memoact STRUCTURE memoact

CHANGING p_i_subject TYPE tdtitle.

DATA l_tdtitle(60).

CLEAR l_tdtitle.

CONCATENATE 'EMAIL SUBJECT: '

p_p0001-ename(20)

INTO l_tdtitle

SEPARATED BY space.

CONDENSE l_tdtitle.

CLEAR p_i_subject.

p_i_subject = l_tdtitle.

ENDFORM.

cheers,

Patrick

naimesh_patel
Active Contributor
0 Kudos

hello,

fill structure ITCPO,

itcpo-TDTITLE = 'header'.

and pass it to OPEN_FORM

Regards,

Naimesh

Former Member
0 Kudos

HI

GOOD

I DONT THINK IT IS POSSIBLE THROUGH OPEN_FORM , BECAUSE THERE IS NO SUCH PARAMTER IN OPEN_FORM WHERE WE CAN PASS THE PARAMETER TO GET THE RESULT AS YOU HAVE MENTIONED IN YOUR QUERY.

THIS LINK WILL GIVE YOU SOME MORE IDEA ABOUT OPEN_FORM

http://help.sap.com/saphelp_nw04/helpdata/en/d6/0dba1a494511d182b70000e829fbfe/content.htm

http://www.sap-img.com/sapscripts/a-sample-sap-scripts-reports.htm

THANKS

MRUTYUN

Former Member
0 Kudos

Hallo,

i think, there is no right solution to use OPEN/CLOSE_FORM. Therfore i try it on this way.

First i OPEN_FORM with DR_PARAM_TDGETOTF = 'X' to get the result in an internal table.

At CLOSE_FORM i use the parameter TABLE with OTFDATA (like ITC00).

Then i will use table OTFDATA to send an email via

SO_DUCUMENT_SEND_API1 as an attachment.

Now i get new problems.

I will put the OTFDATA in CONTENTS_BIN (like SOLISTI1)but i know, i have to convert otf to PDF. But FM CONVERT_OTF doesn't fit because the Structure from ORFDATA and CONTENTS_BIN are different.

I get the mail but the attachment is not a real PDF.

Can anyone help me or has an Code-Example.

Thanks.

Regards Dieter

Former Member
0 Kudos

Hallo,

i solve it.

Thanks for all help.

Regards Dieter

Here my Code-Extract:

***************************************

REPORT ZTEST.

*

DATA: BEGIN OF DR_PARAM.

INCLUDE STRUCTURE ITCPO.

DATA: END OF DR_PARAM.

*

DATA: OTFDATA LIKE SOLI OCCURS 0 WITH HEADER LINE.

DATA: PDFDATA LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE.

DATA: PDF_FILESIZE LIKE SOOD-OBJLEN.

*

*

DATA: OBJ_PACK LIKE SOPCKLSTI1 OCCURS 0 WITH HEADER LINE,

OBJ_HEAD LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,

OBJ_BIN LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,

OBJ_TXT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,

REC_LIST LIKE SOMLRECI1 OCCURS 0 WITH HEADER LINE,

DOC_DATA LIKE SODOCCHGI1.

*

************************************************************************

*

DR_PARAM-TDDEST = 'LOCAL'. "Ausgabegerät

DR_PARAM-TDIMMED = ' '. "Sofort ausgeben

DR_PARAM-TDPREVIEW = 'X'. "Druckvoschau

DR_PARAM-TDGETOTF = 'X'. "Ausgabe in Tabelle

*

CALL FUNCTION 'OPEN_FORM'

EXPORTING

DEVICE = 'PRINTER'

DIALOG = ' '

OPTIONS = DR_PARAM

FORM = 'ZTEST'

LANGUAGE = SY-LANGU

EXCEPTIONS

CANCELED = 01

DEVICE = 02

OTHERS = 03.

*

IF SY-SUBRC <> 0. WRITE: / SY-SUBRC. EXIT. ENDIF.

*

CALL FUNCTION 'WRITE_FORM'

EXPORTING

WINDOW = 'ADDRESS'

EXCEPTIONS

WINDOW = 1.

*

IF SY-SUBRC <> 0. WRITE: / SY-SUBRC. EXIT. ENDIF.

*

CALL FUNCTION 'WRITE_FORM'

EXPORTING

WINDOW = 'MAIN'

ELEMENT = 'ANSCHREIBEN_ANFANG'

EXCEPTIONS

WINDOW = 1.

*

IF SY-SUBRC <> 0. WRITE: / SY-SUBRC. EXIT. ENDIF.

*

.... Here are more 'WRITE_FORM'

...

CALL FUNCTION 'CLOSE_FORM'

TABLES

OTFDATA = OTFDATA.

*

  • exit.

*

CALL FUNCTION 'SX_OBJECT_CONVERT_OTF_PDF'

EXPORTING

FORMAT_SRC = 'OTF'

FORMAT_DST = 'PDF'

DEVTYPE = ''

LEN_IN = ''

IMPORTING

LEN_OUT = PDF_FILESIZE

TABLES

CONTENT_IN = OTFDATA

CONTENT_OUT = PDFDATA.

*

  • prepare email (example)

DOC_DATA-OBJ_NAME = 'Report: ZTEST'.

CONCATENATE SY-SYSID '/' SY-MANDT ':'

'Übertragung von Testdaten'

INTO DOC_DATA-OBJ_DESCR SEPARATED BY SPACE.

  • email-User (U)

CLEAR REC_LIST.

CLEAR REC_LIST.

REC_LIST-RECEIVER = 'test@test.de'.

REC_LIST-REC_TYPE = 'U'.

APPEND REC_LIST.

*

  • PACKING_LIST

CLEAR OBJ_PACK.

OBJ_PACK-TRANSF_BIN = ' '.

OBJ_PACK-BODY_START = 01.

OBJ_PACK-BODY_NUM = 02.

OBJ_PACK-DOC_TYPE = 'RAW'.

APPEND OBJ_PACK.

*

CLEAR OBJ_PACK.

OBJ_PACK-TRANSF_BIN = 'X'.

OBJ_PACK-BODY_START = 01.

DESCRIBE TABLE PDFDATA LINES OBJ_PACK-BODY_NUM.

OBJ_PACK-DOC_TYPE = 'PDF'.

OBJ_PACK-DOC_SIZE = PDF_FILESIZE.

OBJ_PACK-OBJ_NAME = 'Attachment'.

OBJ_PACK-OBJ_DESCR = 'Test'.

APPEND OBJ_PACK.

*

OBJ_TXT-LINE = '1. Line of email'.

APPEND OBJ_TXT.

OBJ_TXT-LINE = '2. Line of email'.

APPEND OBJ_TXT.

*

LOOP AT PDFDATA.

OBJ_BIN-LINE = PDFDATA-LINE.

APPEND OBJ_BIN.

ENDLOOP.

CALL FUNCTION 'SO_DOCUMENT_SEND_API1'

EXPORTING

DOCUMENT_DATA = DOC_DATA

PUT_IN_OUTBOX = 'X'

COMMIT_WORK = 'X'

TABLES

PACKING_LIST = OBJ_PACK

CONTENTS_TXT = OBJ_TXT

CONTENTS_BIN = OBJ_BIN

RECEIVERS = REC_LIST

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.

*

CASE SY-SUBRC.

...

ENDCASE.

*

  • Programmende

*

Message was edited by: Dieter Gröhn