Friday, May 25, 2012

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. Interested ABAP'ers click on read more to read the post.




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









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.









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.

        Goto->Pagewindows-> Double click on FOOTER  window and click on  
        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


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.









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



BITMAP 'LOGO' OBJECT GRAPHICS ID BMAP TYPE BCOL









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



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:











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.

Categories

ABAP (1) ABAP Interview Questions (112) ABAP Open SQL Statements (1) ABAP Syntax Rules (6) ABAP WORKBENCH (2) ABAP-Interview-Questions (52) ALE IDOC (6) ALE IDOC Interview Questions (6) ale-idoc (6) ALE-IDOC-Interview-Questions (19) ALV Interview Questions (5) ALV-Interview-Questions (22) BADI (2) BAPI (1) BAPI Interview Questions (1) BAPI-Interview-Questions (14) BDC (6) BDC Interview Questions (6) BDC-Interview-Questions (9) big data (2) big data interview questions (1) Classical Reports Interview Question (3) Classical-Reports-Interview-Questions (22) Conditional Statements (1) Cross Applications (3) Cross-Applications (14) Data Dictionary (22) Data Type Questins (1) Data types (1) Data-Dictionary (48) Data-Type-Questins (6) Dialog programming (5) Dialog Programming Interview Questions (4) Dialog-Programming (30) DOMAIN Interview Questions (1) Domain-Interview-Questions (8) Function Module (2) hadoop (2) hadoop interview questions (2) hdfs (1) IDoc Tutorials (6) Interactive Report Interview Questions (4) Interactive-Reports-Interview-Questions (22) Internal Tables (1) interview questions (1) Lock Object Interview Questions (1) Lock-Objects-Interview-Questions (10) Logical Database (1) Modularization Interview Questions (4) Modularization-Interview-Questions (25) Module Pool Programming (5) Module-Pool-Programming (39) modules in sap (1) Object Oriented ABAP (19) Object Oriented ABAP Interview Questions (15) object-oriented-abap (2) Object-Oriented-ABAP-Interview-Questions (34) OOABAP (9) Reports (14) Reports Interview Questions (9) Reports-Interview-Questions (19) RFC (1) RFC Interview Questions (1) RFC-Interview-Questions (14) RICEF (1) RICEF Objects (1) SAP (4) SAP ABAP (4) SAP ABAP Interview Questions (42) SAP ABAP Introduction (46) SAP ABAP Message Types (2) SAP BADI Interview Questions (2) SAP Basics (71) SAP Books (2) SAP Certification (1) SAP CONSULTANTS (5) SAP CRM (1) SAP ENHANCEMENTS (3) SAP EXITS (2) SAP EXITS ( SAP ENHANCEMENTS ) Interview Questions (1) SAP Free Books (1) SAP HR (2) SAP Lock Object (1) sap modules (2) SAP Open SQL Statements (1) SAP R/3 Architecture (4) SAP Search help (1) SAP Smartforms (1) SAP Smartforms Interview Questions (2) SAP Tables (5) SAP Tcodes (10) SAP Views (1) SAP Webdynpro ABAP (12) SAP Work Processors (2) SAP Workflow (3) SAP-BADI-Interview-Questions (11) SAP-Enhancements (39) SAP-Exits (39) SAP-Exits-Enhancements-Interview Questions (3) SAP-HANA (1) SAP-HANA-Interview-Questions (1) SAP-Smartforms-Interview-Questions (2) SAP-Workflow (3) Scripts (3) Scripts Interview Questions (2) Scripts-Interview-Questions (32) Search Help Interview Questions (1) Search-Help-Interview-Questions (9) Smartforms (1) Table Maintenance Generator (1) Table-Maintenance-Generator (4) Tables in SAP (2) Tables Interview Questions (3) Tables-Interview-Questions (3) Type Group Interview Questions (1) Type-Group-Interview-Questions (7) Variable Declaration (1) Views Interview Questions (1) Views-Interview-Questions (5) Webdynpro (12) what is big data (1)

Protected Blog

 
This blog is not affiliated to SAP AG |SAP is trademark of SAP AG |The information collected from various sources use information with your own risk.