0% found this document useful (0 votes)
50 views

Sap Scripts 1. Program To Print The Material Detail For Given Material Number With Company and Customer Details. Creating Windows in Se71

This SAP script program prints material details for a given material number. It retrieves the material data from table MARA for the input material number and displays it in a SAP script form window. The program opens and closes the form, writes the material data to the form using the WRITE_FORM function, and handles any errors from the form functions.

Uploaded by

dhivya
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views

Sap Scripts 1. Program To Print The Material Detail For Given Material Number With Company and Customer Details. Creating Windows in Se71

This SAP script program prints material details for a given material number. It retrieves the material data from table MARA for the input material number and displays it in a SAP script form window. The program opens and closes the form, writes the material data to the form using the WRITE_FORM function, and handles any errors from the form functions.

Uploaded by

dhivya
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

SAP SCRIPTS

1. PROGRAM TO PRINT THE MATERIAL DETAIL FOR GIVEN


MATERIAL NUMBER WITH COMPANY AND CUSTOMER
DETAILS.
CREATING WINDOWS IN SE71.

CODING:
REPORT ZSAP_SCRIPT_DEMO.
types: begin of ty_mara,
matnr type matnr,
mtart type mtart,
matkl type matkl,
meins type meins,
end of ty_mara.
data: it_mara type TABLE OF ty_mara,
wa_mara type ty_mara.
parameters:

p_matnr type matnr.

select matnr mtart matkl meins from mara into CORRESPONDING FIELDS OF TABLE it
_mara

where matnr = p_matnr.


if sy-subrc = 0.
**open sap script**
CALL FUNCTION 'OPEN_FORM'
EXPORTING
DIALOG
FORM
LANGUAGE
EXCEPTIONS
CANCELED
DEVICE
FORM
OPTIONS
UNCLOSED
MAIL_OPTIONS
ARCHIVE_ERROR
INVALID_FAX_NUMBER
MORE_PARAMS_NEEDED_IN_BATCH
SPOOL_ERROR
CODEPAGE
OTHERS
.
IF sy-subrc eq 0.
loop at it_mara into wa_mara.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT
FUNCTION
TYPE
WINDOW
EXCEPTIONS
ELEMENT
FUNCTION
TYPE
UNOPENED
UNSTARTED
WINDOW
BAD_PAGEFORMAT_FOR_PRINT
SPOOL_ERROR
CODEPAGE
OTHERS
.

= 'X'
= 'ZSAP_SCRIPT_1 '
= SY-LANGU

=
=
=
=
=
=
=
=
=
=
=
=

1
2
3
4
5
6
7
8
9
10
11
12

=
=
=
=

'ELE1'
'SET'
'BODY'
'MAIN'

=
=
=
=
=
=
=
=
=
=

1
2
3
4
5
6
7
8
9
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
=
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.
ENDLOOP.
ELSE.
WRITE: / 'DATA IS NOT ABLE TO PRINT'.
ENDIF.
ENDIF.
*
*
*
*
*
*
*
*
*
*
*
*

OUTPUT:

You might also like