You are on page 1of 6

Simple Box

/: BOX FRAME 10 TW

You can use the POSITION and SIZE commands to set default parameters for a box.

You can write:

/: POSITION XORIGIN '11.21' YORIGIN '5.31' MM
/: SIZE HEIGHT '2' MM WIDTH '76' MM
/: BOX FRAME 10 TW INTENSITY 10

This can be useful if you gave several boxes that share the same parameters.

If you want to set the position relatively to the window use POSITION WINDOW
to set the position to the top/left start of the window. Then use POSITION
to set the current position relatively to the start of the Window.

Note that you uses "+" or "-" in the ORIGIN position to the set the position relatively.

/: POSITION WINDOW
/: POSITION XORIGIN '+5' MM YORIGIN '+10' MM

the position is now 5 MM from the left and 10 MM from the top of the window

Drawing a line. You can draw a line by setting the Height or Widths to 0
and add a frame. E.g. a horizontal line:

/: SIZE HEIGHT '0' MM WIDTH '200' MM

Printing internal table contents dynamically in SAPScript

ere is a Script in which an internal table is displayed with each record enclosed with a box and can grow
according to the no of records given as the input.

Scenario: 1

Here the input is given as 4 records

And the Script is displaying the 4 records with each record enclosed in a Box Scenario: 2 Here the no of records chosen is 12 Observe that now 12 records are enclosed with the boxes. .

maktx type maktx. CALL FUNCTION 'OPEN_FORM' EXPORTING FORM = 'ZSCRIPT_NEW' 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 . * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF. . data:begin of itab occurs 0. select matnr maktx from makt into table itab up to i rows. matnr type matnr. IF sy-subrc <> 0. end of itab. PARAMETERS:P_SNO TYPE I.And now follows the listing of the code which is the Driver program for the above Script *&-------------------------------------------------------------* *& Report ZSCRIPT *&-------------------------------------------------------------* REPORT ZSCRIPT. loop at itab. move p_sno to i. data:i type i.

. ENDIF. Now the details of the LAYOUT The Script is designed with two pages FIRST and NEXT with a Main window laid on it (I have not enclosed the details of the steps involved in creating the Pages) In the following Text element I have used two Box commands one enclosing MATNR and one enclosing MAKTX but as they are both laid next to each other the out come is a single BOX enclosing MATNR and MAKTX with a vertical separator Line1:Sapscript-counter_0 is the variable which I am using to dynamically increase the YPOS for drawing the BOX around each record as and when the internal table grows Line2:Element begins Line3:the first BOX command which is enclosing the MATNR. IF sy-subrc <> 0.observe that here the sapscript_counter is incremented by 1 which is achieved by &SAPSCRIPT-COUNTER_0(+)& Line4: again the sapscript-counter value is reinitialized to its previous value as the next BOX enclosing MAKTX has to be at the same YPOS as that of the BOXenclosing MATNR Line5: another BOX command this time to enclose MAKTX Line6: writing of the internal table variables MATNR and MAKTX to enable them to be displayed on the output Text Element . ENDIF. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. IF sy-subrc <> 0. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. endloop. CALL FUNCTION 'CLOSE_FORM' .CALL FUNCTION 'WRITE_FORM' EXPORTING ELEMENT = 'ELEMENT ' FUNCTION = 'SET' TYPE = 'BODY' WINDOW = 'MAIN' 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 .

ELEMENT 3. DEFINE &SAPSCRIPT-COUNTER_0& = &SAPSCRIPT-COUNTER_0(-)& 5. BOX YPOS &SAPSCRIPT-COUNTER_0(+)& LN WIDTH '2' CM HEIGHT '1' LN FRAME 10 TW 4. PAGE WINDOWS.PARAGRAPH . &itab-matnr& &itab-maktx& I am also giving the screen shot for the text element MAIN in Character editor I have omitted all the regular steps involved to build the LAYOUT(like creation of PAGES. BOX YPOS &SAPSCRIPT-COUNTER_0(+)& LN XPOS '2'CM WIDTH '10' CM HEIGHT '1'LN FRAME 10 TW 6.WINDOWS.MAIN 1.CHARACTER) to come out as an entity just to avoid the clutter and focus on the utilization of SAPSCRIPT-COUNTER variable. DEFINE &SAPSCRIPT-COUNTER_0& = -1 2. .