Dear Readers this post explains the Script Tutorial Real Time Scenario on Creation of Purchase Order, in this post i'm explained step by step procedure to create Script on Purchase Order. This post gives the complete idea about the creation of Script for beginners. Lets's go through this post for more details about creation of script. Interested ABAP'ers click on read more to read the post.
Dear Readers this post explains the Script Tutorial Real Time Scenario on Creation of Purchase Order, in this post i'm explained step by step procedure to create Script on Purchase Order. This post gives the complete idea about the creation of Script for beginners. Lets's go through this post for more details about creation of script.
Business Requirement for Creation of Script.
Create a Purchase Order Script Form with below layout.
Now Let's Start step by step procedure to create Script Form.
5. click on WINDOWS
Click on EDIT
--> select CRATE ELEMENT (by default, MAIN window will be added)
Main Window will be added by default.
Create another window by going to EDIT --> Create Element
Give the window name as TITLE , Description as Window for Title.
Click on paragraph Formats Button.
Write Below code under text editor
Goto->Pagewindows-> Double click on FOOTER window and click on
Box is used to create box.
Goto->Pagewindows->Double click on ADDRESS window and click on texteditor->write the below code.
Now we have to Upload the Logo to display on Script.
Uploading Logo Using SE78 Tcode.
Goto SE78
--> Form Graphics
--> Stored on Document Server
--> select Graphics
--> Graphics
--> Click on Bitmap Images
--> Import (Left Green Button)
Click on F4 to select the Bitmap Image from computer to SAP Document Server.
Only bitmap images are displayed no other formats are displayed.
Select the URL of the Image and Give the Name and Description of the Image.
Select the Radio button Color bitmap Image.
Click on Enter to upload the logo. The Logo will be uploaded.
To cheek the the Image whether it is uploaded or not, Give the image name and select color bitmap image and click on the Print Preview (F8) button.
The uploaded image will be displayed as below.
BITMAP 'LOGO' OBJECT GRAPHICS ID BMAP TYPE BCOL
Now we have to create Standard Text for this Script Using "SO10" Tcode.
We can write the text directly in the window. But in the real time we use a concept called standard Text.
Goto SO10
--> Give name
--> Provide Text ID as 'ST'
--> click on Create
--> go to EDIT
--> Change Editor
--> Write some text in Text editor,
save and activate the standard text.
Footer window as below.
Dear ABAP'ers if any Suggestions, Comments, Doubts feel free to leave a comment in the below comment box.
Script Tutorial Real Time Scenario on Purchase Order Creation
Dear Readers this post explains the Script Tutorial Real Time Scenario on Creation of Purchase Order, in this post i'm explained step by step procedure to create Script on Purchase Order. This post gives the complete idea about the creation of Script for beginners. Lets's go through this post for more details about creation of script.
Business Requirement for Creation of Script.
Create a Purchase Order Script Form with below layout.
Follow below steps to creation of Script Form.
Step 1 : Create a Page by name PAGE1
Step 2 : Create Required no of Window as per the layout given
Step 3: Create Page Windows and specify height/width
Step 4 : Create Paragraph Formats
Step 5 : Create a TABS for Paragraph Formats
Step 6 : Create a Character Format
Step 7 : Write the code for Printing Headings, Line item information,
Grand total in Mainwindow
Step 8 : Write the code for Printing Vendor address in Address window
Step 9 : Write the code for Printing Footer information in Footer window
Step 10 : Write the code for Printing Logo in Logo window
Step 11 : Similarly, Write the code for Printing PO Details/PageNo/Title
Step 12 : Print the standard text using SO10 Tcode
Step13 : Arrange all the windows as per the given Layout.
Step14 : Create a Driver Program
Step15 : EXECUTE THE driver program
Step16 : Create a Second Page Layout
Step17 : Increase the height of MAIN window
Step18 : Printing Terms&Conditions using STARTFORM AND END FORM
Step19 : Change the Driver Program for using STARTFORM AND END FORM
Now Let's Start step by step procedure to create Script Form.
Detailed Steps:
1. Go to Se71 Tcode
-->Give formname -->ZPO_SCRIPT, Click on --> Create Button.
A pop-up message will be displayed, no need to do any thing press Enter Button.
2. give Meaning (Description for the script)
->click on BASIC settings.
3. Select page format Landscape
Specify Page Format, First Page, Default Paragraph.
Step 1 : Create a Page by name PAGE1
4. Click on PAGES
Click on EDIT --> select CRATE ELEMENT
Give page as PAGE1 and meaning as Main Page->>
Give Next Page as Page1
Click on EDIT
--> select CRATE ELEMENT (by default, MAIN window will be added)
Main Window will be added by default.
Create another window by going to EDIT --> Create Element
Give the window name as TITLE , Description as Window for Title.
Step 2 : Create Required no of Window as per the layout given
6. click on EDIT->create element->give window name as logo and meaning as window for logo.
Repeat the same step for all the required windows.
Step 3: Create Page Windows and specify height/width
7. Click on Page windows
Click on EDIT->CRATE ELEMENT->Double click on each window
so that the window would be added to the page.
Give the appropriate height, width, left / right margin as below for each window
Repeat the same procedure for all Page Windows.
Step 4 : Create Paragraph Formats
Create the paragraph Formats as below.
Click on paragraph Formats Button.
Click on EDIT->CRATE ELEMENT
Give the Paragraph Format and specify the description
Maintain the Font Attributes
( Font Family, Size, Bold, Italic, Underline ) as required.
Step 5 : Create a TABS for Paragraph Formats
Give Tabs for HEADER paragraph format as below. Tabs are nothing but positions to display data.
Create 5 Tabs with required positions.
Create all required Paragraph Formats as below.
Step 6 : Create a Character Format
Create character format as below.
Click on EDIT --> Create Element --> Give Character Format and
Description and Maintain Font Attributes as requirement
Step 7 : Write the code for Title, Headings, Line item information,
Grand Total in Mainwindow
Goto->Pagewindows
For Title
Select Title Page Window and click on Text Editor
CLICK ON GOTO CHANGE EDITOR--->write the below code
Write the Below Code under editor
TL --> Paragraph Format and " PURCHASE ORDER " is the title.
Now Select the Main Window, Select the editor and write below code.
Write Below code under text editor
Here,
HD is a Paragraph format for Header data.
/: TOP…ENDTOP is used to print header information in the main window so that
the it flows on to every page .
/E (Text Element) BODY----this is used to print body. All the line item values .
/E (Text Element) Total----used to print total at the end of main window .
This element is called after the loop..endloop..so that Grand total is printed immediately after the main window .
Step 8 : Write the code for Printing Footer information in Footer window
Select Footer in Page windows and write code for Footer in text editor.
texteditor-> write the below code.
FT--&ULINE(60)&
FT--ALL RIGHTS RESERVED TO <C1>ABC COMPANY</> LIMITED
Here FT is paragraph format and CH is char format with bold.
Box is used to create box.
Step 9 : Write the code for Printing PO Details/PageNo/Title
Similarly, for all windows write the below code in the text editor
Goto->Pagewindows->Double click on PO_NO window and click on texteditor
->write the below code
DF-- PO No : &wa_ekko-ebeln&
DF-- PO Date : &wa_ekko-aedat&
Goto->Pagewindows->Double click on PAGE_NO window and click on texteditor->write the below code
DF--Page.No : &PAGE&/&SAPSCRIPT-FORMPAGES(C)&
Step 10 : Write the code for Printing Vendor address in Address window
Now we have to Upload the Logo to display on Script.
Uploading Logo Using SE78 Tcode.
Goto SE78
--> Form Graphics
--> Stored on Document Server
--> select Graphics
--> Graphics
--> Click on Bitmap Images
--> Import (Left Green Button)
Click on F4 to select the Bitmap Image from computer to SAP Document Server.
Only bitmap images are displayed no other formats are displayed.
Select the URL of the Image and Give the Name and Description of the Image.
Select the Radio button Color bitmap Image.
Click on Enter to upload the logo. The Logo will be uploaded.
To cheek the the Image whether it is uploaded or not, Give the image name and select color bitmap image and click on the Print Preview (F8) button.
The uploaded image will be displayed as below.
Step 11 : Write the code for Printing Logo in Logo window
Goto->Pagewindows
->Double click on LOGO window and click on texteditor
->write the below code or Click on INSERT->GRAPHICS
->Select Stored on Document Server
->Give Name 'LOGO' (Image name Uploaded through SE78)
->Give object : GRAPHICS ID : BMAP
Select color Bitmap Image->Press Enter
The Below syntax will come automatically
Step 12 : Print the standard text using SO10 Tcode
Now we have to create Standard Text for this Script Using "SO10" Tcode.
We can write the text directly in the window. But in the real time we use a concept called standard Text.
Goto SO10
--> Give name
--> Provide Text ID as 'ST'
--> click on Create
--> go to EDIT
--> Change Editor
--> Write some text in Text editor,
save and activate the standard text.
Go back to script
Goto -->Pagewindows
-->Double click on TEXT window and click on texteditor
-->write the below text.
/: INCLUDE ZV_PO_TEXT OBJECT TEXT ID ST THIS IS STD TEXT THRU SO10 TXN.
Or
CLick on Insert->Text->Standard
A pop will appear->give text name as ZPO_STD_TEXT-> Press Enter
The code will be displayed automatically.
Step13 : Arrange all the windows as per the given Layout
Finally, Lets Re-arrange all the window positions again by going to Graphical Form Painer.
Click on SETTINGS
-->FORM PAINTER
-->Select Checkbox Graphical Form Painter And press enter.
The form should look as below. If not arrange all the windows as below by dragging and dropping.
Arrange all the windows like below screen shot by dragging and dropping the windows as per our business requirement.
Footer window as below.
Now goback to PC EDITOR.
Minimize the above window and Settings
--> Form Painter
--> Un check the Graphical Form Painter, now pc editor will be displayed.
Click on Save to Save the Script and Activate script.
To Activate Click on Form Button --> Activate Script.
Step14 : Create a Driver Program in SE38 to print Script Form
Driver Program for script.
*&---------------------------------------------------------------------*
*& Report ZPO_SCRIPT_DP
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZPO_SCRIPT_DP NO STANDARD PAGE HEADING.
****** TABLES USED
TABLES : EKKO, EKPO, LFA1, ADRC.
********** DATA DECLARETIONS
DATA : I_EKPO TYPE TABLE OF EKPO,
WA_EKKO TYPE EKKO,
WA_EKPO TYPE EKPO,
WA_LFA1 TYPE LFA1,
WA_ADRC TYPE ADRC,
V_TOT TYPE EKPO-NETWR.
****** PARAMETER FOR EBELN SELECTION
PARAMETERS : P_EBELN TYPE EBELN.
******* SELECTING PO HEADER DATA
SELECT SINGLE * FROM EKKO INTO WA_EKKO WHERE EBELN = P_EBELN.
******* SELECTING PO ITEM DATA
SELECT * FROM EKPO INTO TABLE I_EKPO WHERE EBELN = P_EBELN.
********* FETCHING VENDOR DATA FOR ADDRESS USING EKKO
SELECT SINGLE * FROM LFA1 INTO WA_LFA1 WHERE LIFNR = WA_EKKO-LIFNR.
********** FETCHING VENDOR ADDRESS FROM ADRC TABLE USING VENDOR
SELECT SINGLE * FROM ADRC INTO WA_ADRC WHERE ADDRNUMBER = WA_LFA1-ADRNR.
********** READING DATA PO ITEM TABLE TO WORK AREA
READ TABLE I_EKPO INTO WA_EKPO INDEX 1.
******* TO READ DATA 100 TIMES FOR DEMO PURPOSE
DO 100 TIMES.
APPEND WA_EKPO TO I_EKPO.
ENDDO.
********* CALLING THE SCRIPT USING OPEN_FORM
CALL FUNCTION 'OPEN_FORM'
EXPORTING
FORM = 'ZPO_SCRIPT'
LANGUAGE = SY-LANGU.
********** LOOP THE ITAB TO WA TO READ DATA
LOOP AT I_EKPO INTO WA_EKPO.
****** FOR CALCULATING THE TOTAL
V_TOT = V_TOT + WA_EKPO-NETWR.
******* WRITING THE DATA ON SCRIPT
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'BODY '
WINDOW = 'MAIN'.
******** TO DISPLAY TOTAL AT END OF THE SCRIPT
AT LAST.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'TOTAL'
WINDOW = 'MAIN'.
ENDAT.
ENDLOOP.
******* TO CLOSE THE FORM WHICH IS OPENED BY OPEN FORM
CALL FUNCTION 'CLOSE_FORM'.
*& Report ZPO_SCRIPT_DP
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZPO_SCRIPT_DP NO STANDARD PAGE HEADING.
****** TABLES USED
TABLES : EKKO, EKPO, LFA1, ADRC.
********** DATA DECLARETIONS
DATA : I_EKPO TYPE TABLE OF EKPO,
WA_EKKO TYPE EKKO,
WA_EKPO TYPE EKPO,
WA_LFA1 TYPE LFA1,
WA_ADRC TYPE ADRC,
V_TOT TYPE EKPO-NETWR.
****** PARAMETER FOR EBELN SELECTION
PARAMETERS : P_EBELN TYPE EBELN.
******* SELECTING PO HEADER DATA
SELECT SINGLE * FROM EKKO INTO WA_EKKO WHERE EBELN = P_EBELN.
******* SELECTING PO ITEM DATA
SELECT * FROM EKPO INTO TABLE I_EKPO WHERE EBELN = P_EBELN.
********* FETCHING VENDOR DATA FOR ADDRESS USING EKKO
SELECT SINGLE * FROM LFA1 INTO WA_LFA1 WHERE LIFNR = WA_EKKO-LIFNR.
********** FETCHING VENDOR ADDRESS FROM ADRC TABLE USING VENDOR
SELECT SINGLE * FROM ADRC INTO WA_ADRC WHERE ADDRNUMBER = WA_LFA1-ADRNR.
********** READING DATA PO ITEM TABLE TO WORK AREA
READ TABLE I_EKPO INTO WA_EKPO INDEX 1.
******* TO READ DATA 100 TIMES FOR DEMO PURPOSE
DO 100 TIMES.
APPEND WA_EKPO TO I_EKPO.
ENDDO.
********* CALLING THE SCRIPT USING OPEN_FORM
CALL FUNCTION 'OPEN_FORM'
EXPORTING
FORM = 'ZPO_SCRIPT'
LANGUAGE = SY-LANGU.
********** LOOP THE ITAB TO WA TO READ DATA
LOOP AT I_EKPO INTO WA_EKPO.
****** FOR CALCULATING THE TOTAL
V_TOT = V_TOT + WA_EKPO-NETWR.
******* WRITING THE DATA ON SCRIPT
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'BODY '
WINDOW = 'MAIN'.
******** TO DISPLAY TOTAL AT END OF THE SCRIPT
AT LAST.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'TOTAL'
WINDOW = 'MAIN'.
ENDAT.
ENDLOOP.
******* TO CLOSE THE FORM WHICH IS OPENED BY OPEN FORM
CALL FUNCTION 'CLOSE_FORM'.
Save and Activate the Program.
Now Execute the Program and give PO number as : 3000000007
The Output of the Script form is look likes below:
First Page:
Last Page:
Previous Posts:
For More Real Time Interview Questions See Below Posts
Dear ABAP'ers if any Suggestions, Comments, Doubts feel free to leave a comment in the below comment box.
"You found the information helpful and want to say thanks? Your donation is enough to inspire us to do more. Thanks a bunch!"
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.