SlideShare uma empresa Scribd logo
1 de 95
SAP Scripts
Introduction
Script is a text composer.
Used to create the layout.
Script is Client and language dependent.
SAPScript Transaction codes
SE71 - Form painter
SE72 - Style maintenance
SE78 - SapScript Graphics Management
SO10 - Create standard text module
Ex 1 : Creating Delivery Note.
Go to Transaction code SE71 and enter the form name and
click on create.
 Click on Continue.
 Give the short description and save.
• A location in a page is called as window.
 Click on Setting->Form painter.
To Create new window click on create.
Rename the window name.
Paragraph format and Character format :
 Paragraph format : If you want to decide font
size and font style for a paragraph then use
Paragraph format .
• Character format : If you want to highlight the words
then use character format.
• Click on Heading Window and click on text.
• To check output .
• Utilities -> printing test.
• Enter output device as LP01 and click on print preview.
• To Upload the LOGO .
• Transaction code SE78.
• Double click on Bitmap Images.
• Click on Import.
• Mention the File path in File name.
• Enter the name for Logo.
• Click on Logo window and click
• Click on Insert -> Graphics.
• Click on Stored on Document Server.
• Enter the Logo name and Resolution.
• Script or Smart forms will get the data from program called
driver program or print program .
• SE38 -> Enter the program name and click on create.
• TABLES : LIKP , TVKO.
DATA : WA_SALES TYPE ADRC.
PARAMETERS : P_VBELN TYPE LIKP-VBELN.
START-OF-SELECTION.
PERFORM GET_DATA.
PERFORM PRINT_DATA.
• FORM GET_DATA .
* GET THE DATA FROM DELIVERY DOC HEADER
SELECT SINGLE * FROM LIKP
WHERE VBELN = P_VBELN.
* GET THE SALES ORG ADDRESS
SELECT SINGLE * FROM TVKO
WHERE VKORG = LIKP-VKORG.
* GET THE DATA FROM ADRESS TABLE ADRC
SELECT SINGLE * FROM ADRC
INTO WA_SALES WHERE ADDRNUMBER = TVKO-ADRNR.
ENDFORM. " GET_DATA
• FORM PRINT_DATA .
call function 'OPEN_FORM'
EXPORTING
* APPLICATION = 'TX'
* ARCHIVE_INDEX =
* ARCHIVE_PARAMS =
DEVICE = 'PRINTER'
* DIALOG = 'X'
FORM = 'ZBILLINGNOTE'
LANGUAGE = SY-LANGU
* OPTIONS =
* MAIL_SENDER =
* MAIL_RECIPIENT =
* MAIL_APPL_OBJECT =
* RAW_DATA_INTERFACE = '*'
* SPONUMIV =
* 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.
* Implement suitable error handling here
endif.
• * TO CALL PARTICULAR WINDOW
call function 'WRITE_FORM'
EXPORTING
ELEMENT = 'SALES'
* FUNCTION = 'SET'
* TYPE = 'BODY'
WINDOW = 'ADD1'
* 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.
* Implement suitable error handling here
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.
* Implement suitable error handling here
endif.
ENDFORM. " PRINT_DATA
• Click on window ADD1 and click on text.
• A group of fields will be defined as Text Element.
• Execute the program.
• To get Sold to party address.
• TABLES : LIKP , TVKO , KNA1.
DATA : WA_SOLD TYPE ADRC.
• * * * GET THE SOLD TO PARTY ADRESS
SELECT SINGLE * FROM KNA1
WHERE KUNNR = LIKP-KUNNR.
SELECT SINGLE * FROM ADRC
INTO WA_SOLD WHERE ADDRNUMBER = KNA1-ADRNR.
• call function 'WRITE_FORM'
EXPORTING
ELEMENT = 'SOLD'
* FUNCTION = 'SET'
* TYPE = 'BODY'
WINDOW = 'ADD2'
* 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.
* Implement suitable error handling here
endif.
• Click on window add2.
• Execute the program.
• Tab spaces in paragraph.
• Use of Character format and bar code.
• Click on Details Window and click on text.
• Execute
• Click on Window Col_head and click on text.
• Execute.
• Click on Main Window and text.
• Data : itab type table of lips,
wa type lips ,
• count(93) type c.
Standard Text : Request
• Transaction code SO10.
• Enter the Text Name and click on create.
• Go to Layout, condition window and click on text.
• Insert -> Text -> Standard.
• Execute the program.
• Click on Signature window and click on text.
• Click on footer window and click on text.
Commands in Scripts
Address.
• --------
• ------
Endaddress.
• Used to specify the postal address format depend on country.
• Also we can use.
• Address_into_printform
Top .
EndTop.
 Its acts like AT FIRST in control break statement.
Bottom.
EndBottom.
 Its acts like AT LAST and ENDAT.
Protect.
EndProtect.
New-Page.
 Download the script from one server and uploading into
another Server .
 Transaction code SE38.
Enter standard program name and execute.
Enter the object name as Form name and Mode as EXPORT .
Click on Execute
Mentioned the file path and name.
Click on Save.
 To Upload.
 SE38.
• Debugging the script.
• SE71 (stxh)
• Utilities -> activate debugger.
Converting Script OTF data to PDF
TYPES : BEGIN OF T_MAKT,
MATNR TYPE MAKT-MATNR,
SPRAS TYPE MAKT-SPRAS,
MAKTX TYPE MAKT-MAKTX,
END OF T_MAKT.
DATA : IT_MAKT TYPE TABLE OF T_MAKT,
WA_MAKT TYPE T_MAKT.
DATA : LC_OPTION TYPE ITCPO,
OTFDATA TYPE TABLE OF ITCOO,
FILE_SIZE TYPE I,
LINES TYPE TABLE OF TLINE .
SELECT-OPTIONS : S_MATNR FOR WA_MAKT-MATNR.
START-OF-SELECTION.
PERFORM FETCH_DATA.
PERFORM PRINT_DATA.
FORM FETCH_DATA .
SELECT MATNR SPRAS MAKTX FROM MAKT INTO TABLE IT_MA
KT
WHERE MATNR IN S_MATNR.
ENDFORM. " FETCH_DATA
FORM PRINT_DATA .
LC_OPTION-TDGETOTF = 'X'.
call function 'OPEN_FORM'
EXPORTING
* APPLICATION = 'TX'
* ARCHIVE_INDEX =
* ARCHIVE_PARAMS =
DEVICE = 'PRINTER'
DIALOG = 'X'
FORM = 'ZCONERT'
LANGUAGE = SY-LANGU
OPTIONS = LC_OPTION
* MAIL_SENDER =
* MAIL_RECIPIENT =
* MAIL_APPL_OBJECT =
* RAW_DATA_INTERFACE = '*'
* SPONUMIV =
* 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.
* Implement suitable error handling here
endif.
call function 'START_FORM'
EXPORTING
* ARCHIVE_INDEX =
FORM = 'ZCONERT'
* LANGUAGE = ' '
* STARTPAGE = ' '
* PROGRAM = ' '
* MAIL_APPL_OBJECT =
* IMPORTING
* LANGUAGE =
EXCEPTIONS
FORM = 1
FORMAT = 2
UNENDED = 3
UNOPENED = 4
UNUSED = 5
SPOOL_ERROR = 6
CODEPAGE = 7
OTHERS = 8
.
if SY-SUBRC <> 0.
* Implement suitable error handling here
endif.
LOOP AT IT_MAKT INTO WA_MAKT.
call function 'WRITE_FORM'
EXPORTING
ELEMENT = 'MAKT'
* 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.
* Implement suitable error handling here
endif.
ENDLOOP.
• call function 'CLOSE_FORM'
* IMPORTING
* RESULT =
* RDI_RESULT =
TABLES
OTFDATA = OTFDATA
EXCEPTIONS
UNOPENED = 1
BAD_PAGEFORMAT_FOR_PRINT = 2
SEND_ERROR = 3
SPOOL_ERROR = 4
CODEPAGE = 5
OTHERS = 6
.
if SY-SUBRC <> 0.
* Implement suitable error handling here
endif.
• call function 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
* MAX_LINEWIDTH = 132
* ARCHIVE_INDEX = ' '
* COPYNUMBER = 0
* ASCII_BIDI_VIS2LOG = ' '
* PDF_DELETE_OTFTAB = ' '
* PDF_USERNAME = ' '
IMPORTING
BIN_FILESIZE = FILE_SIZE
* BIN_FILE =
tables
OTF = OTFDATA
LINES = LINES
EXCEPTIONS
ERR_MAX_LINEWIDTH = 1
ERR_FORMAT = 2
ERR_CONV_NOT_POSSIBLE = 3
ERR_BAD_OTF = 4
OTHERS = 5
.
if SY-SUBRC <> 0.
* Implement suitable error handling here
endif.
• call function 'GUI_DOWNLOAD'
exporting
BIN_FILESIZE = FILE_SIZE
FILENAME ='C:Usersuser19DesktopTEST1.PDF'
FILETYPE = 'BIN'
* APPEND = ' '
* WRITE_FIELD_SEPARATOR = ' '
* HEADER = '00'
* TRUNC_TRAILING_BLANKS = ' '
* WRITE_LF = 'X'
* COL_SELECT = ' '
* COL_SELECT_MASK = ' '
* DAT_MODE = ' '
* CONFIRM_OVERWRITE = ' '
* NO_AUTH_CHECK = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* WRITE_BOM = ' '
* TRUNC_TRAILING_BLANKS_EOL = 'X'
* WK1_N_FORMAT = ' '
* WK1_N_SIZE = ' '
* WK1_T_FORMAT = ' '
* WK1_T_SIZE = ' '
* WRITE_LF_AFTER_LAST_LINE = ABAP_TRUE
* SHOW_TRANSFER_STATUS = ABAP_TRUE
* IMPORTING
* FILELENGTH =
TABLES
DATA_TAB = LINES
* FIELDNAMES =
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22
.
if SY-SUBRC <> 0.
* Implement suitable error handling here
endif.
ENDFORM. " PRINT_DATA
Total and SubTotal
• TYPES : BEGIN OF TY,
VBELN TYPE VBRP-VBELN,
POSNR TYPE VBRP-POSNR,
NETWR TYPE VBRP-NETWR,
END OF TY.
DATA : IT_VBRP TYPE TABLE OF TY,
WA_VBRP TYPE TY.
DATA : TOTAL TYPE VBRP-NETWR,
SUB_TOTAL TYPE VBRP-NETWR.
SELECT-OPTIONS : S_VBELN FOR WA_VBRP-VBELN.
• START-OF-SELECTION.
PERFORM FETCH_DATA.
PERFORM PRINT_DATA.
• FORM FETCH_DATA .
SELECT VBELN POSNR NETWR FROM VBRP INTO TABLE IT_V
BRP
WHERE VBELN IN S_VBELN.
ENDFORM.
• FORM PRINT_DATA .
call function 'OPEN_FORM'
EXPORTING
* APPLICATION = 'TX'
* ARCHIVE_INDEX =
* ARCHIVE_PARAMS =
DEVICE = 'PRINTER'
* DIALOG = 'X'
FORM = 'ZSUBNDTOT'
* LANGUAGE = SY-LANGU
* OPTIONS =
* MAIL_SENDER =
* MAIL_RECIPIENT =
* MAIL_APPL_OBJECT =
* RAW_DATA_INTERFACE = '*'
* SPONUMIV =
* 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.
* Implement suitable error handling here
endif.
• LOOP AT IT_VBRP INTO WA_VBRP.
call function 'WRITE_FORM'
EXPORTING
ELEMENT = 'TEXT_ALL'
* 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.
* Implement suitable error handling here
endif.
TOTAL = TOTAL + WA_VBRP-NETWR.
SUB_TOTAL = SUB_TOTAL + WA_VBRP-NETWR.
• AT END OF VBELN.
call function 'WRITE_FORM'
EXPORTING
ELEMENT = 'TEXT_SUB'
* 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.
* Implement suitable error handling here
endif.
CLEAR SUB_TOTAL.
ENDAT.
• CLEAR WA_VBRP.
ENDLOOP.
call function 'WRITE_FORM'
EXPORTING
ELEMENT = 'TEXT_TOTAL'
* 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.
* Implement suitable error handling here
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.
* Implement suitable error handling here
endif.
ENDFORM. " P
Uses of FM: CONTROL_FORMin SAP Script
• TYPES : BEGIN OF T_MAT,
MATNR TYPE MAKT-MATNR,
SPRAS TYPE MAKT-SPRAS,
MAKTX TYPE MAKT-MAKTX,
END OF T_MAT.
DATA : IT_MAKT TYPE TABLE OF T_MAT,
WA_MAKT TYPE T_MAT.
DATA : IN TYPE I.
SELECT-OPTIONS : S_MATNR FOR WA_MAKT-MATNR.
• START-OF-SELECTION .
PERFORM FETCH_DATA.
PERFORM PRINT_PAGE.
• FORM FETCH_DATA .
SELECT MATNR SPRAS MAKTX FROM MAKT INTO TABLE IT_M
AKT
WHERE MATNR IN S_MATNR.
ENDFORM. " FETCH_DATA
• FORM PRINT_PAGE .
call function 'OPEN_FORM'
EXPORTING
* APPLICATION = 'TX'
* ARCHIVE_INDEX =
* ARCHIVE_PARAMS =
DEVICE = 'PRINTER'
* DIALOG = 'X'
FORM = 'ZCONTROL'
* LANGUAGE = SY-LANGU
* OPTIONS =
.
if SY-SUBRC <> 0.
* Implement suitable error handling here
endif.
• LOOP AT IT_MAKT INTO WA_MAKT.
IN = IN + 1.
call function 'WRITE_FORM'
EXPORTING
ELEMENT = 'MATA'
* FUNCTION = 'SET'
TYPE = 'BODY'
WINDOW = 'MAIN'
* IMPORTING
* PENDING_LINES =
* EXCEPTIONS
* ELEMENT = 1
.
if SY-SUBRC <> 0.
* Implement suitable error handling here
endif.
•
IF IN = 10.
call function 'CONTROL_FORM'
exporting
COMMAND = 'NEW-PAGE'
* EXCEPTIONS
* UNOPENED = 1
* UNSTARTED = 2
* OTHERS = 3
.
if SY-SUBRC <> 0.
* Implement suitable error handling here
endif.
CLEAR IN.
ENDIF.
ENDLOOP.
• 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.
* Implement suitable error handling here
endif.
ENDFORM. " PRINT_PAGE
Sap scripts

Mais conteúdo relacionado

Mais procurados

Sap sapscripts tips and tricks
Sap sapscripts tips and tricksSap sapscripts tips and tricks
Sap sapscripts tips and tricks
Kranthi Kumar
 
BATCH DATA COMMUNICATION
BATCH DATA COMMUNICATIONBATCH DATA COMMUNICATION
BATCH DATA COMMUNICATION
Kranthi Kumar
 
1000 solved questions
1000 solved questions1000 solved questions
1000 solved questions
Kranthi Kumar
 

Mais procurados (20)

Module pool programming
Module pool programmingModule pool programming
Module pool programming
 
Badis
Badis Badis
Badis
 
Sap Adobe Form
Sap Adobe FormSap Adobe Form
Sap Adobe Form
 
Sap sapscripts tips and tricks
Sap sapscripts tips and tricksSap sapscripts tips and tricks
Sap sapscripts tips and tricks
 
Smartforms interview questions with answers
Smartforms interview questions with answersSmartforms interview questions with answers
Smartforms interview questions with answers
 
BATCH DATA COMMUNICATION
BATCH DATA COMMUNICATIONBATCH DATA COMMUNICATION
BATCH DATA COMMUNICATION
 
Sap scripts
Sap scriptsSap scripts
Sap scripts
 
List Processing in ABAP
List Processing in ABAPList Processing in ABAP
List Processing in ABAP
 
SAP Modularization techniques
SAP Modularization techniquesSAP Modularization techniques
SAP Modularization techniques
 
Sap abap real time questions
Sap abap real time questionsSap abap real time questions
Sap abap real time questions
 
ABAP for Beginners - www.sapdocs.info
ABAP for Beginners - www.sapdocs.infoABAP for Beginners - www.sapdocs.info
ABAP for Beginners - www.sapdocs.info
 
Basic Debugging
Basic DebuggingBasic Debugging
Basic Debugging
 
Sap abap
Sap abapSap abap
Sap abap
 
Field symbols
Field symbolsField symbols
Field symbols
 
SAP BADI Implementation Learning for Functional Consultant
SAP BADI Implementation Learning for Functional ConsultantSAP BADI Implementation Learning for Functional Consultant
SAP BADI Implementation Learning for Functional Consultant
 
Sap User Exit for Functional Consultant
Sap User Exit for Functional ConsultantSap User Exit for Functional Consultant
Sap User Exit for Functional Consultant
 
SAP Adobe forms
SAP Adobe formsSAP Adobe forms
SAP Adobe forms
 
Sap abap
Sap abapSap abap
Sap abap
 
1000 solved questions
1000 solved questions1000 solved questions
1000 solved questions
 
Sapscript
SapscriptSapscript
Sapscript
 

Semelhante a Sap scripts

Chapter 04 sap script - output program
Chapter 04 sap script - output programChapter 04 sap script - output program
Chapter 04 sap script - output program
Kranthi Kumar
 
Example syntax alv grid list
Example syntax alv grid listExample syntax alv grid list
Example syntax alv grid list
Nur Khoiri
 
modularization-160202092213 (1).pdf
modularization-160202092213 (1).pdfmodularization-160202092213 (1).pdf
modularization-160202092213 (1).pdf
SreeramBaddila
 
Gift-VT Tools Development Overview
Gift-VT Tools Development OverviewGift-VT Tools Development Overview
Gift-VT Tools Development Overview
stn_tkiller
 
Complete reference to_abap_basics
Complete reference to_abap_basicsComplete reference to_abap_basics
Complete reference to_abap_basics
Abhishek Dixit
 
Abapprogrammingoverview 090715081305-phpapp02
Abapprogrammingoverview 090715081305-phpapp02Abapprogrammingoverview 090715081305-phpapp02
Abapprogrammingoverview 090715081305-phpapp02
wingsrai
 
Chapter 1abapprogrammingoverview-091205081953-phpapp01
Chapter 1abapprogrammingoverview-091205081953-phpapp01Chapter 1abapprogrammingoverview-091205081953-phpapp01
Chapter 1abapprogrammingoverview-091205081953-phpapp01
tabish
 
chapter-1abapprogrammingoverview-091205081953-phpapp01
chapter-1abapprogrammingoverview-091205081953-phpapp01chapter-1abapprogrammingoverview-091205081953-phpapp01
chapter-1abapprogrammingoverview-091205081953-phpapp01
tabish
 
Abapprogrammingoverview 090715081305-phpapp02
Abapprogrammingoverview 090715081305-phpapp02Abapprogrammingoverview 090715081305-phpapp02
Abapprogrammingoverview 090715081305-phpapp02
tabish
 
1582627
15826271582627
1582627
tabish
 

Semelhante a Sap scripts (20)

SAP Batch data communication
SAP Batch data communicationSAP Batch data communication
SAP Batch data communication
 
Chapter 04 sap script - output program
Chapter 04 sap script - output programChapter 04 sap script - output program
Chapter 04 sap script - output program
 
Modularization & Catch Statement
Modularization & Catch StatementModularization & Catch Statement
Modularization & Catch Statement
 
Stored procedure
Stored procedureStored procedure
Stored procedure
 
Example syntax alv grid list
Example syntax alv grid listExample syntax alv grid list
Example syntax alv grid list
 
modularization-160202092213 (1).pdf
modularization-160202092213 (1).pdfmodularization-160202092213 (1).pdf
modularization-160202092213 (1).pdf
 
Gift-VT Tools Development Overview
Gift-VT Tools Development OverviewGift-VT Tools Development Overview
Gift-VT Tools Development Overview
 
Complete reference to_abap_basics
Complete reference to_abap_basicsComplete reference to_abap_basics
Complete reference to_abap_basics
 
Batch input session
Batch input sessionBatch input session
Batch input session
 
Zmalv output type_v1.1
Zmalv output type_v1.1Zmalv output type_v1.1
Zmalv output type_v1.1
 
ABAP Programming Overview
ABAP Programming OverviewABAP Programming Overview
ABAP Programming Overview
 
Abapprogrammingoverview 090715081305-phpapp02
Abapprogrammingoverview 090715081305-phpapp02Abapprogrammingoverview 090715081305-phpapp02
Abapprogrammingoverview 090715081305-phpapp02
 
Chapter 1abapprogrammingoverview-091205081953-phpapp01
Chapter 1abapprogrammingoverview-091205081953-phpapp01Chapter 1abapprogrammingoverview-091205081953-phpapp01
Chapter 1abapprogrammingoverview-091205081953-phpapp01
 
chapter-1abapprogrammingoverview-091205081953-phpapp01
chapter-1abapprogrammingoverview-091205081953-phpapp01chapter-1abapprogrammingoverview-091205081953-phpapp01
chapter-1abapprogrammingoverview-091205081953-phpapp01
 
Chapter 1 Abap Programming Overview
Chapter 1 Abap Programming OverviewChapter 1 Abap Programming Overview
Chapter 1 Abap Programming Overview
 
Abapprogrammingoverview 090715081305-phpapp02
Abapprogrammingoverview 090715081305-phpapp02Abapprogrammingoverview 090715081305-phpapp02
Abapprogrammingoverview 090715081305-phpapp02
 
Refactoring
RefactoringRefactoring
Refactoring
 
List Processing in ABAP
List Processing in ABAPList Processing in ABAP
List Processing in ABAP
 
1582627
15826271582627
1582627
 
SAP ALE Idoc
SAP ALE IdocSAP ALE Idoc
SAP ALE Idoc
 

Último

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 

Sap scripts

  • 2. Introduction Script is a text composer. Used to create the layout. Script is Client and language dependent. SAPScript Transaction codes SE71 - Form painter SE72 - Style maintenance SE78 - SapScript Graphics Management SO10 - Create standard text module
  • 3. Ex 1 : Creating Delivery Note. Go to Transaction code SE71 and enter the form name and click on create.
  • 4.  Click on Continue.
  • 5.  Give the short description and save.
  • 6. • A location in a page is called as window.  Click on Setting->Form painter.
  • 7.
  • 8.
  • 9. To Create new window click on create.
  • 11.
  • 12.
  • 13.
  • 14. Paragraph format and Character format :  Paragraph format : If you want to decide font size and font style for a paragraph then use Paragraph format .
  • 15.
  • 16.
  • 17.
  • 18. • Character format : If you want to highlight the words then use character format.
  • 19.
  • 20. • Click on Heading Window and click on text.
  • 21. • To check output . • Utilities -> printing test.
  • 22. • Enter output device as LP01 and click on print preview.
  • 23. • To Upload the LOGO . • Transaction code SE78. • Double click on Bitmap Images. • Click on Import.
  • 24. • Mention the File path in File name. • Enter the name for Logo.
  • 25. • Click on Logo window and click
  • 26. • Click on Insert -> Graphics.
  • 27. • Click on Stored on Document Server. • Enter the Logo name and Resolution.
  • 28. • Script or Smart forms will get the data from program called driver program or print program . • SE38 -> Enter the program name and click on create. • TABLES : LIKP , TVKO. DATA : WA_SALES TYPE ADRC. PARAMETERS : P_VBELN TYPE LIKP-VBELN. START-OF-SELECTION. PERFORM GET_DATA. PERFORM PRINT_DATA.
  • 29. • FORM GET_DATA . * GET THE DATA FROM DELIVERY DOC HEADER SELECT SINGLE * FROM LIKP WHERE VBELN = P_VBELN. * GET THE SALES ORG ADDRESS SELECT SINGLE * FROM TVKO WHERE VKORG = LIKP-VKORG. * GET THE DATA FROM ADRESS TABLE ADRC SELECT SINGLE * FROM ADRC INTO WA_SALES WHERE ADDRNUMBER = TVKO-ADRNR. ENDFORM. " GET_DATA
  • 30. • FORM PRINT_DATA . call function 'OPEN_FORM' EXPORTING * APPLICATION = 'TX' * ARCHIVE_INDEX = * ARCHIVE_PARAMS = DEVICE = 'PRINTER' * DIALOG = 'X' FORM = 'ZBILLINGNOTE' LANGUAGE = SY-LANGU * OPTIONS = * MAIL_SENDER = * MAIL_RECIPIENT = * MAIL_APPL_OBJECT = * RAW_DATA_INTERFACE = '*' * SPONUMIV = * 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. * Implement suitable error handling here endif.
  • 31. • * TO CALL PARTICULAR WINDOW call function 'WRITE_FORM' EXPORTING ELEMENT = 'SALES' * FUNCTION = 'SET' * TYPE = 'BODY' WINDOW = 'ADD1' * 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. * Implement suitable error handling here endif.
  • 32. • 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. * Implement suitable error handling here endif. ENDFORM. " PRINT_DATA
  • 33. • Click on window ADD1 and click on text. • A group of fields will be defined as Text Element.
  • 34. • Execute the program.
  • 35. • To get Sold to party address. • TABLES : LIKP , TVKO , KNA1. DATA : WA_SOLD TYPE ADRC. • * * * GET THE SOLD TO PARTY ADRESS SELECT SINGLE * FROM KNA1 WHERE KUNNR = LIKP-KUNNR. SELECT SINGLE * FROM ADRC INTO WA_SOLD WHERE ADDRNUMBER = KNA1-ADRNR.
  • 36. • call function 'WRITE_FORM' EXPORTING ELEMENT = 'SOLD' * FUNCTION = 'SET' * TYPE = 'BODY' WINDOW = 'ADD2' * 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. * Implement suitable error handling here endif.
  • 37. • Click on window add2.
  • 38. • Execute the program.
  • 39. • Tab spaces in paragraph.
  • 40. • Use of Character format and bar code.
  • 41.
  • 42. • Click on Details Window and click on text.
  • 44.
  • 45. • Click on Window Col_head and click on text.
  • 47. • Click on Main Window and text.
  • 48. • Data : itab type table of lips, wa type lips , • count(93) type c.
  • 49.
  • 50.
  • 51. Standard Text : Request • Transaction code SO10. • Enter the Text Name and click on create.
  • 52.
  • 53. • Go to Layout, condition window and click on text. • Insert -> Text -> Standard.
  • 54.
  • 55.
  • 56. • Execute the program.
  • 57. • Click on Signature window and click on text.
  • 58. • Click on footer window and click on text.
  • 59.
  • 60. Commands in Scripts Address. • -------- • ------ Endaddress.
  • 61. • Used to specify the postal address format depend on country. • Also we can use. • Address_into_printform
  • 62. Top . EndTop.  Its acts like AT FIRST in control break statement.
  • 63. Bottom. EndBottom.  Its acts like AT LAST and ENDAT.
  • 66.  Download the script from one server and uploading into another Server .  Transaction code SE38. Enter standard program name and execute.
  • 67. Enter the object name as Form name and Mode as EXPORT . Click on Execute Mentioned the file path and name. Click on Save.
  • 68.
  • 70.
  • 71.
  • 72. • Debugging the script. • SE71 (stxh) • Utilities -> activate debugger.
  • 73.
  • 74. Converting Script OTF data to PDF TYPES : BEGIN OF T_MAKT, MATNR TYPE MAKT-MATNR, SPRAS TYPE MAKT-SPRAS, MAKTX TYPE MAKT-MAKTX, END OF T_MAKT. DATA : IT_MAKT TYPE TABLE OF T_MAKT, WA_MAKT TYPE T_MAKT. DATA : LC_OPTION TYPE ITCPO, OTFDATA TYPE TABLE OF ITCOO, FILE_SIZE TYPE I, LINES TYPE TABLE OF TLINE . SELECT-OPTIONS : S_MATNR FOR WA_MAKT-MATNR.
  • 75. START-OF-SELECTION. PERFORM FETCH_DATA. PERFORM PRINT_DATA. FORM FETCH_DATA . SELECT MATNR SPRAS MAKTX FROM MAKT INTO TABLE IT_MA KT WHERE MATNR IN S_MATNR. ENDFORM. " FETCH_DATA
  • 76. FORM PRINT_DATA . LC_OPTION-TDGETOTF = 'X'. call function 'OPEN_FORM' EXPORTING * APPLICATION = 'TX' * ARCHIVE_INDEX = * ARCHIVE_PARAMS = DEVICE = 'PRINTER' DIALOG = 'X' FORM = 'ZCONERT' LANGUAGE = SY-LANGU OPTIONS = LC_OPTION * MAIL_SENDER = * MAIL_RECIPIENT = * MAIL_APPL_OBJECT = * RAW_DATA_INTERFACE = '*' * SPONUMIV = * 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. * Implement suitable error handling here endif.
  • 77. call function 'START_FORM' EXPORTING * ARCHIVE_INDEX = FORM = 'ZCONERT' * LANGUAGE = ' ' * STARTPAGE = ' ' * PROGRAM = ' ' * MAIL_APPL_OBJECT = * IMPORTING * LANGUAGE = EXCEPTIONS FORM = 1 FORMAT = 2 UNENDED = 3 UNOPENED = 4 UNUSED = 5 SPOOL_ERROR = 6 CODEPAGE = 7 OTHERS = 8 . if SY-SUBRC <> 0. * Implement suitable error handling here endif.
  • 78. LOOP AT IT_MAKT INTO WA_MAKT. call function 'WRITE_FORM' EXPORTING ELEMENT = 'MAKT' * 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. * Implement suitable error handling here endif. ENDLOOP.
  • 79. • call function 'CLOSE_FORM' * IMPORTING * RESULT = * RDI_RESULT = TABLES OTFDATA = OTFDATA EXCEPTIONS UNOPENED = 1 BAD_PAGEFORMAT_FOR_PRINT = 2 SEND_ERROR = 3 SPOOL_ERROR = 4 CODEPAGE = 5 OTHERS = 6 . if SY-SUBRC <> 0. * Implement suitable error handling here endif.
  • 80. • call function 'CONVERT_OTF' EXPORTING FORMAT = 'PDF' * MAX_LINEWIDTH = 132 * ARCHIVE_INDEX = ' ' * COPYNUMBER = 0 * ASCII_BIDI_VIS2LOG = ' ' * PDF_DELETE_OTFTAB = ' ' * PDF_USERNAME = ' ' IMPORTING BIN_FILESIZE = FILE_SIZE * BIN_FILE = tables OTF = OTFDATA LINES = LINES EXCEPTIONS ERR_MAX_LINEWIDTH = 1 ERR_FORMAT = 2 ERR_CONV_NOT_POSSIBLE = 3 ERR_BAD_OTF = 4 OTHERS = 5 . if SY-SUBRC <> 0. * Implement suitable error handling here endif.
  • 81. • call function 'GUI_DOWNLOAD' exporting BIN_FILESIZE = FILE_SIZE FILENAME ='C:Usersuser19DesktopTEST1.PDF' FILETYPE = 'BIN' * APPEND = ' ' * WRITE_FIELD_SEPARATOR = ' ' * HEADER = '00' * TRUNC_TRAILING_BLANKS = ' ' * WRITE_LF = 'X' * COL_SELECT = ' ' * COL_SELECT_MASK = ' ' * DAT_MODE = ' ' * CONFIRM_OVERWRITE = ' ' * NO_AUTH_CHECK = ' ' * CODEPAGE = ' ' * IGNORE_CERR = ABAP_TRUE * REPLACEMENT = '#' * WRITE_BOM = ' ' * TRUNC_TRAILING_BLANKS_EOL = 'X' * WK1_N_FORMAT = ' ' * WK1_N_SIZE = ' ' * WK1_T_FORMAT = ' ' * WK1_T_SIZE = ' ' * WRITE_LF_AFTER_LAST_LINE = ABAP_TRUE * SHOW_TRANSFER_STATUS = ABAP_TRUE * IMPORTING * FILELENGTH = TABLES DATA_TAB = LINES * FIELDNAMES = EXCEPTIONS FILE_WRITE_ERROR = 1 NO_BATCH = 2 GUI_REFUSE_FILETRANSFER = 3 INVALID_TYPE = 4 NO_AUTHORITY = 5 UNKNOWN_ERROR = 6 HEADER_NOT_ALLOWED = 7 SEPARATOR_NOT_ALLOWED = 8 FILESIZE_NOT_ALLOWED = 9 HEADER_TOO_LONG = 10 DP_ERROR_CREATE = 11 DP_ERROR_SEND = 12 DP_ERROR_WRITE = 13 UNKNOWN_DP_ERROR = 14 ACCESS_DENIED = 15 DP_OUT_OF_MEMORY = 16 DISK_FULL = 17 DP_TIMEOUT = 18 FILE_NOT_FOUND = 19 DATAPROVIDER_EXCEPTION = 20 CONTROL_FLUSH_ERROR = 21 OTHERS = 22 . if SY-SUBRC <> 0. * Implement suitable error handling here endif. ENDFORM. " PRINT_DATA
  • 83. • TYPES : BEGIN OF TY, VBELN TYPE VBRP-VBELN, POSNR TYPE VBRP-POSNR, NETWR TYPE VBRP-NETWR, END OF TY. DATA : IT_VBRP TYPE TABLE OF TY, WA_VBRP TYPE TY. DATA : TOTAL TYPE VBRP-NETWR, SUB_TOTAL TYPE VBRP-NETWR. SELECT-OPTIONS : S_VBELN FOR WA_VBRP-VBELN.
  • 84. • START-OF-SELECTION. PERFORM FETCH_DATA. PERFORM PRINT_DATA. • FORM FETCH_DATA . SELECT VBELN POSNR NETWR FROM VBRP INTO TABLE IT_V BRP WHERE VBELN IN S_VBELN. ENDFORM.
  • 85. • FORM PRINT_DATA . call function 'OPEN_FORM' EXPORTING * APPLICATION = 'TX' * ARCHIVE_INDEX = * ARCHIVE_PARAMS = DEVICE = 'PRINTER' * DIALOG = 'X' FORM = 'ZSUBNDTOT' * LANGUAGE = SY-LANGU * OPTIONS = * MAIL_SENDER = * MAIL_RECIPIENT = * MAIL_APPL_OBJECT = * RAW_DATA_INTERFACE = '*' * SPONUMIV = * 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. * Implement suitable error handling here endif.
  • 86. • LOOP AT IT_VBRP INTO WA_VBRP. call function 'WRITE_FORM' EXPORTING ELEMENT = 'TEXT_ALL' * 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. * Implement suitable error handling here endif. TOTAL = TOTAL + WA_VBRP-NETWR. SUB_TOTAL = SUB_TOTAL + WA_VBRP-NETWR.
  • 87. • AT END OF VBELN. call function 'WRITE_FORM' EXPORTING ELEMENT = 'TEXT_SUB' * 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. * Implement suitable error handling here endif. CLEAR SUB_TOTAL. ENDAT.
  • 88. • CLEAR WA_VBRP. ENDLOOP. call function 'WRITE_FORM' EXPORTING ELEMENT = 'TEXT_TOTAL' * 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. * Implement suitable error handling here 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. * Implement suitable error handling here endif. ENDFORM. " P
  • 89. Uses of FM: CONTROL_FORMin SAP Script • TYPES : BEGIN OF T_MAT, MATNR TYPE MAKT-MATNR, SPRAS TYPE MAKT-SPRAS, MAKTX TYPE MAKT-MAKTX, END OF T_MAT. DATA : IT_MAKT TYPE TABLE OF T_MAT, WA_MAKT TYPE T_MAT. DATA : IN TYPE I. SELECT-OPTIONS : S_MATNR FOR WA_MAKT-MATNR.
  • 90. • START-OF-SELECTION . PERFORM FETCH_DATA. PERFORM PRINT_PAGE. • FORM FETCH_DATA . SELECT MATNR SPRAS MAKTX FROM MAKT INTO TABLE IT_M AKT WHERE MATNR IN S_MATNR. ENDFORM. " FETCH_DATA
  • 91. • FORM PRINT_PAGE . call function 'OPEN_FORM' EXPORTING * APPLICATION = 'TX' * ARCHIVE_INDEX = * ARCHIVE_PARAMS = DEVICE = 'PRINTER' * DIALOG = 'X' FORM = 'ZCONTROL' * LANGUAGE = SY-LANGU * OPTIONS = . if SY-SUBRC <> 0. * Implement suitable error handling here endif.
  • 92. • LOOP AT IT_MAKT INTO WA_MAKT. IN = IN + 1. call function 'WRITE_FORM' EXPORTING ELEMENT = 'MATA' * FUNCTION = 'SET' TYPE = 'BODY' WINDOW = 'MAIN' * IMPORTING * PENDING_LINES = * EXCEPTIONS * ELEMENT = 1 . if SY-SUBRC <> 0. * Implement suitable error handling here endif.
  • 93. • IF IN = 10. call function 'CONTROL_FORM' exporting COMMAND = 'NEW-PAGE' * EXCEPTIONS * UNOPENED = 1 * UNSTARTED = 2 * OTHERS = 3 . if SY-SUBRC <> 0. * Implement suitable error handling here endif. CLEAR IN. ENDIF. ENDLOOP.
  • 94. • 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. * Implement suitable error handling here endif. ENDFORM. " PRINT_PAGE