----By Arjun
Business Req : Create a PO form with the below layout.
Detailed Steps:
1. Se71->Give formname ->ZV_PO ->create.
2. give Meaning->click on BASIC settings.
3. Select page format /landscape
Step 1 : Create a Page by name PAGE1
4. Click on PAGES->EDIT->CRATE ELEMENT->give page as page1 and meaning as
page1->>Give Next Page as Page1
5. click on WINDOWS(by default, main window will be added)
Step 2 : Create Required no of Window as per the layout given
6. click on EDIT->create element->give window name as TITLE and meaning as title.
Repeat the same step and add the below windows.
Step 7 : Write the code for Headings, Line item information, Grand total in
Mainwindow
Goto->Pagewindows->Double click on main window and click on texteditorCLICK ON GOTO CHANGE EDITOR--->write the below code.
Here
/:TOPENDTOP is used to print header information in the main window so that the it
flows on to every page .
/EBODY----this is used to print body. All the line item values .
/E-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 Vendor address in Address window
Goto->Pagewindows->Double click on ADDRESS window and click on
texteditor->write the below code.
Step 9 : Write the code for Printing Footer information in Footer window
Goto->Pagewindows->Double click on FOOTER window and click on
texteditor->write the below code.
FT--&ULINE(60)&
FT--ALL RIGHTS RESERVED TO <C1>IBM</> INDIA PVT.LTD
Here FT is paragraph format And
C1 is char format with bold.
Write the below text->click on save->go back and click on print preview.
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 ZV_PO_TEXT>press enter->
The code will be displayed automatically.
7. Click on Page windows-> Give Page as Page2->Click on EDIT->CRATE ELEMENT>Double click on Main Window, Page No Window, Footer Window so that the windows
would be added to the page2.
Step19 : Change the Driver Program for using STARTFORM AND END FORM
Write the below code in the above driver program i.e. just add the below code to the
above code CALL FUNCTION 'CLOSE_FORM'.
*&---------------------------------------------------------------------*
*& Report ZV_PO_DRIVER
*&
*&---------------------------------------------------------------------*
REPORT ZV_PO_DRIVER.
TABLES : ADRC,LFA1,EKKO.
PARAMETERS : P_EBELN TYPE EKKO-EBELN .
*DATA DECLARATIONS
DATA : WA_EKKO TYPE EKKO .
DATA : WA_EKPO TYPE EKPO .
DATA : IT_EKPO TYPE TABLE OF EKPO .
DATA : WA_LFA1 TYPE LFA1 .
DATA : WA_ADRC TYPE ADRC .
DATA : V_TOT TYPE EKPO-NETWR .
*READ PO HEADER DETAILS
SELECT SINGLE * FROM EKKO
INTO WA_EKKO
WHERE EBELN = P_EBELN .
*READ PO ITEM DETAILS
SELECT * FROM EKPO
INTO TABLE IT_EKPO
WHERE EBELN = P_EBELN .
READ TABLE IT_EKPO INTO WA_EKPO INDEX 1.
DO 100 TIMES .
APPEND WA_EKPO TO IT_EKPO .
ENDDO.
*READ VENDOR MASTER DATA TO FIND THE ADDRESS NUMBER
SELECT SINGLE * FROM LFA1 INTO WA_LFA1 WHERE LIFNR = WA_EKKOLIFNR .
SELECT SINGLE * FROM ADRC INTO WA_ADRC WHERE ADDRNUMBER =
WA_LFA1-ADRNR .
*OPEN THE FORM
CALL FUNCTION 'OPEN_FORM'
EXPORTING
FORM
= 'ZV_PO'
LANGUAGE = SY-LANGU.
*PRINT EACH ITEM IN MAIN WINDOW
LOOP AT IT_EKPO INTO WA_EKPO .
*CALCLUATE GRAND TOTAL
V_TOT = V_TOT + WA_EKPO-NETWR .
WA_EKPO-MATNR = 'APACHE-160' .
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'BODY'
WINDOW = 'MAIN'.
*PRIINT THETOTAL AFETR ANIN WINDOW BODY PAGE
AT LAST .
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'TOTAL'
WINDOW = 'MAIN'.
ENDAT.
ENDLOOP .
CALL FUNCTION 'END_FORM' .
*The start form is used to call another SAP SCRIPT form for printing
TERMS&CONDITIONS.
*This form can be reusable by al forms as it is only for printing
TREMS&CONDITIONS
CALL FUNCTION 'START_FORM'
EXPORTING
* ARCHIVE_INDEX
= ARCHIVE_INDEX
FORM
= 'ZV_PO_TERMS'
LANGUAGE
= SY-LANGU
.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'TERMS'
WINDOW = 'MAIN'.
CALL FUNCTION 'END_FORM' .