cancel
Showing results for 
Search instead for 
Did you mean: 

watermark in SAP script

Former Member
0 Kudos

Hi all, iam facing a problem in implimenting the watermark in sap script.

i have used the following code in print program to impliment this. Actually what is happening is it is printing each record and water mark in each page and second record and again water mark in second page. my requirement is i should get water mark in all pages and records get printed accordingly .

i have created an instance of main window in the script and used the following code in print program. can any one help me out in this case.

please give me the suggestions in this case.

REPORT zwatermark_script .

TABLES:mara.

SELECT-OPTIONS:s_matnr FOR mara-matnr.

DATA:BEGIN OF it_mara OCCURS 0,

mandt LIKE mara-mandt,

matnr LIKE mara-matnr,

ersda LIKE mara-ersda,

END OF it_mara.

DATA:wa_itab LIKE it_mara.

START-OF-SELECTION.

SELECT mandt

matnr

ersda

FROM mara

INTO TABLE it_mara

WHERE matnr IN s_matnr.

END-OF-SELECTION.

CALL FUNCTION 'OPEN_FORM'

EXPORTING

form = 'ZMARK_SCRIPT'

language = sy-langu.

LOOP AT it_mara.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

element = 'WATERMARK'

  • FUNCTION = 'SET'

  • TYPE = 'BODY'

window = 'MAIN'.

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 'CONTROL_FORM'

EXPORTING

command = 'NEW-WINDOW'.

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.

  • Write main contents

CALL FUNCTION 'WRITE_FORM'

EXPORTING

element = 'ELE'

  • 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

  • OTHERS = 9 .

IF sy-subrc <> 0.

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

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

ENDIF.

ENDLOOP. "LOOP AT it_mara

CALL FUNCTION 'CLOSE_FORM'.

IF sy-subrc <> 0.

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

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

ENDIF.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

I mean like below

SELECT SINGLE maktx FROM makt INTO makt-maktx WHERE

matnr eq traptab-matnr.

PERFORM set_text_symbol USING:

'&MABDR-MAKTX&' makt-maktx.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

element = 'POS_ZEILE'

function = 'APPEND'

window = 'MAIN'

EXCEPTIONS

OTHERS = 7.

Former Member
0 Kudos

Hi Ramu

In ur code, where u pass the text element fields? once u pass the text fields in ur code, after that assign the same text field into form and try.