SAP FORM.:
1: t-code se71 to create new form for example zform001
2: using the 'page' button to create new page. such as for example N01A
3: create phatagraph format A1 and set the parameter for difference the item such as font tabs standard
4: frist click the window button and enter new screen ,in the screen create the main and sub1 window .you click left button and choice the create element to create the windows.
5: click the page windows button to enter page windows screen .to add some windows into the page and then set the position for the special window . the way like 4 step.
6: by the settings-----> format painter to enter graphic format painter to add some picture into the form. to close the graphical form. painter just like open it
7: in the page windows screen after you can double click the Main window ,the color of main window will became from black to blue color . now you can click text element button to input some content that you want to dispaly.
8: define the text element /E data and paragraphical format A1, at same time you should define the test element /E TIT and A1 in sub1 window
9: you activate the form. .but system will ask you set the default page and paragraph for the form.
following is the script. for form.
*&---------------------------------------------------------------------*
*& Report ZTEXTFORM *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
REPORT ZTEXTFORM .
DATA ALEX(20) TYPE C.
DATA ADDR(20) TYPE C.
DATA MYSYMBOL(25) TYPE C.
data spfli like spfli .
MYSYMBOL = 'BAIDU'.
ALEX = 'FLEXTRONICS COMPANY'.
ADDR = 'CHINA'.
CALL FUNCTION 'OPEN_FORM'
EXPORTING
* APPLICATION = 'TX'
* ARCHIVE_INDEX =
* ARCHIVE_PARAMS =
* DEVICE = 'PRINTER'
* DIALOG = 'X'
FORM = 'ZFORM001'
* LANGUAGE = SY-LANGU
* OPTIONS =
* 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
* 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 = 'TIT'
FUNCTION = 'SET'
TYPE = 'BODY'
WINDOW = 'SUB1'
* 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.
select * from spfli .
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'DATALIST'
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.
ENDSELECT.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'SYMBOLL'
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 = 'DATA'
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 = 'ADDRESS'
FUNCTION = 'SET'
TYPE = 'BODY'
WINDOW = 'SUB2'
* 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 =
* 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.
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/445851/viewspace-612984/ ,如需转载,请注明出处,否则将追究法律责任。