You are on page 1of 17

Ejemplo BOX en SAPSCRIPT

Box: -
      This command is used to draw the tables, horizontal lines & vertical lines.

Syntax of box: -

/:    BOX  xpos ‘<value>’ <unit> ypos ‘<value>’ <unit> width ‘<value>’ <unit> height


‘<value>’             <unit> intensity ‘<value>’ <unit>  frame ‘<value>’ <unit>. 

 Based on the given purchasing document number display the purchasing document item
details as shown below by using SAPSCRIPT. 

Execute se71.
Provide the form name    eg: ZF_BOX_COMMAND
Click on create.
Provide short description.
Now click on pages button in the application tool bar.
In the menu bar click on edit. Create element.
Provide page name and short description.
Click on save.
Now click on windows button in the application tool bar.
By default it shows the main window, now create the required variable windows.
In the menu bar click on edit. Create element.
Provide the window name and short description. Click on enter.
Now click on page windows button in the application tool bar.
In the menu bar click on edit. Click on create element then it shows the screen with
available windows.
Double click on header window and provide the details as follows. Click on save.
In the menu bar click on edit. Click on create element.
Double click on main window and provide the details as follows. Click on save.
Now click on paragraph formats button in the application tool bar.
Provide paragraph format name and description. Click on save.

Now design the main window as below.


                                                                         18.5 cm

Now click on page windows in the application tool bar.


Double click on main window and click on text elements in the application tool bar.
Provide details as below.

Click on back.
In this example use default paragraph format (P1) to print the data on the header/
title window.
Now you need to create the three more paragraph formats (eg. M1, M2 and F1 )to
print the data on the main window and footer window, why because you need to set
the tab positions to print the data in exact place in main window and footer window.
You can calculate tab positions as follows.
Click on paragraph formats in the application tool bar.
In the menu bar click on edit. Click on create element.

Provide paragraph format name and short description.


Now click on tabs button.
Now provide the tab positions as follows and click on down button to add other tab
positions.
Similarly create the paragraph format M2 for the main window data and F1 for footer
window.
Now develop the driver program.

*&---------------------------------------------------------------------*
*& Report  ZD_BOX_COMMAND
*&
*&---------------------------------------------------------------------*
REPORT ZD_BOX_COMMAND.
PARAMETER P_EBELN TYPE EKPO-EBELN.
TYPES: BEGIN OF TY_EKPO,
 EBELN TYPE EKPO-EBELN,
 EBELP TYPE EKPO-EBELP,
 MENGE TYPE EKPO-MENGE,
 MEINS TYPE EKPO-MEINS,
 NETPR TYPE EKPO-NETPR,
 END OF TY_EKPO.
DATA: WA_EKPO TYPE TY_EKPO,
 IT_EKPO TYPE TABLE OF TY_EKPO.
DATA V_TOTAL TYPE EKPO-NETPR.
SELECT EBELN EBELP MENGE MEINS NETPR
       FROM EKPO
       INTO TABLE IT_EKPO
       WHERE EBELN = P_EBELN.
* Start the form
CALL FUNCTION 'OPEN_FORM'
 EXPORTING
 FORM = 'ZF_BOX_COMMAND'.
*Print the data on header window
CALL FUNCTION 'WRITE_FORM'
 EXPORTING
 WINDOW = 'HEADER'.
*Print the data on main window
LOOP AT IT_EKPO INTO WA_EKPO.
 CALL FUNCTION 'WRITE_FORM'
 EXPORTING
 ELEMENT = 'AM'
 WINDOW = 'MAIN'.

V_TOTAL = V_TOTAL + WA_EKPO-NETPR.
ENDLOOP.
*Close the form
CALL FUNCTION 'CLOSE_FORM'.

Now open the form and click on page windows in the application tool bar.

Select the header window and click on text elements. provide the data as follows.

Here, you can print the data center if you set the alignment as center for paragraph
format P1 or
you can print directly like this.

Click on back.
Select the main window. Click on text elements and provide details as follows.
Here , i am given the element eg: 'AM' why because whenever we are working with
main window
first record information will be printed twice. To avoid that use this element and
pass the element
name to 'WRITE_FORM' function module as shown above.
Save, check and activate the form.
Execute the driver program.
The output is shown below.
The output data is overlapping with lines in the boxes to avoid that we need to use
the options like
'left margin', 'right margin', 'space before', 'space after' and alignment in the
paragraph formats.

Now provide details according to your layout design. In this example I am providing
according
to my layout design as follows.

OUTPUT:

You might also like