cancel
Showing results for 
Search instead for 
Did you mean: 

How to Get Dynamic Boxs in Scripts

Former Member
0 Kudos

I have Got a Problem.

For a Paricular Sales Document number ,i am Printing

Item data.

For Each Item Data , I want a box around it.

I am using Box comand ,But how to Pass dynamically Position values to table

components XPOS ,YPOS.

If ,not clear ,Ask me

Accepted Solutions (0)

Answers (6)

Answers (6)

Former Member
0 Kudos

Hi Satish,

Check this:

Boxes, Lines, Shading: BOX, POSITION, SIZE

Use the BOX, POSITION, and SIZE commands for drawing boxes, lines, and shading to print particular windows within a form or passages of text within a window in a frame or with shading.

The SAP printer drivers that are based on page-oriented printers (the HP LaserJet driver HPL2, the Postscript driver POST, the Kyocera Prescribe driver PRES) employ these commands when printing. Line printers and page-oriented printers not supported in the standard ignore these commands. You can view the resulting printer output in the SAPscript print preview.

Syntax:

/: BOX [XPOS] [YPOS] [WIDTH] [HEIGHT] [FRAME] [INTENSITY]

/: POSITION [XORIGIN] [YORIGIN] [WINDOW] [PAGE]

/: SIZE [WIDTH] [HEIGHT] [WINDOW] [PAGE]

BOX Command

Syntax

/: BOX [XPOS] [YPOS] [WIDTH] [HEIGHT] [FRAME] [INTENSITY]

Effect: draws a box of the specified size at the specified position.

Parameters: For each of XPOS, YPOS, WIDTH, HEIGHT, and FRAME, you must specify both a measurement and a unit of measurement. Specify the INTENSITY parameter as a percentage between 0 and 100.

XPOS, YPOS

Upper left corner of the box, relative to the values of the POSITION command.

Default: Values specified in the POSITION command.

The following calculation is performed internally to determine the absolute output position of a box on the page:

X(abs) = XORIGIN + XPOS

Y(abs) = YORIGIN + YPOS

WIDTH

Width of the box. Default: WIDTH value of the SIZE command.

HEIGHT

Height of the box. Default: HEIGHT value of the SIZE command.

FRAME

Thickness of frame.

Default: 0 (no frame).

INTENSITY

Grayscale of box contents as %.

Default: 100 (full black)

Measurements: You must specify decimal numbers as literal values (like ABAP numeric constants) by enclosing them in inverted commas. Use the period as the decimal point character. See also the examples listed below.

Units of measurement: The following units of measurement may be used:

TW (twip)

PT (point)

IN (inch)

MM (millimeter)

CM (centimeter)

LN (line)

CH (character).

The following conversion factors apply:

1 TW = 1/20 PT

1 PT = 1/72 IN

1 IN = 2.54 CM

1 CM = 10 MM

1 CH = height of a character relative to the CPI specification in the form header

1 LN = height of a line relative to the LPI specification in the form header

/: BOX FRAME 10 TW

Draws a frame around the current window with a frame thickness of 10 TW (= 0.5 PT).

/: BOX INTENSITY 10

Fills the window background with shading having a gray scale of 10 %.

/: BOX HEIGHT 0 TW FRAME 10 TW

Draws a horizontal line across the complete top edge of the window.

/: BOX WIDTH 0 TW FRAME 10 TW

Draws a vertical line along the complete height of the left hand edge of the window.

/: BOX WIDTH '17.5' CM HEIGHT 1 CM FRAME 10 TW INTENSITY 15

/: BOX WIDTH '17.5' CM HEIGHT '13.5' CM FRAME 10 TW

/: BOX XPOS '10.0' CM WIDTH 0 TW HEIGHT '13.5' CM FRAME 10 TW

/: BOX XPOS '13.5' CM WIDTH 0 TW HEIGHT '13.5' CM FRAME 10 TW

Draws two rectangles and two lines to construct a table of three columns with a highlighted heading section.

POSITION Command

Syntax

/: POSITION [XORIGIN] [YORIGIN] [WINDOW] [PAGE]

Effect: Sets the origin for the coordinate system used by the XPOS and YPOS parameters of the BOX command. When a window is first started, the POSITION value is set to refer to the upper left corner of the window (default setting).

Parameters: If a parameter value does not have a leading sign, then its value is interpreted as an absolute value, in other words, as a value that specifies an offset from the upper left corner of the output page. If a parameter value is specified with a leading sign, then the new value of the parameter is calculated relative to the old value. If one of the parameter specifications is missing, then no change is made to this parameter.

XORIGIN, YORIGIN

Origin of the coordinate system.

WINDOW

Sets the values for the left and upper edges to match those of the current window (default setting).

PAGE

Sets the values for the left and upper edges to match those of the current output page (XORIGIN = 0 cm, YORIGIN = 0 cm).

/: POSITION WINDOW

Sets the origin for the coordinate system to the upper left corner of the window.

/: POSITION XORIGIN 2 CM YORIGIN '2.5 CM'

Sets the origin for the coordinate system to a point 2 cm from the left edge and 2.5 cm from the upper edge of the output page.

/: POSITION XORIGIN '-1.5' CM YORIGIN -1 CM

Shifts the origin for the coordinates 1.5 cm to the left and 1 cm up.

SIZE Command

Syntax

/: SIZE [WIDTH] [HEIGHT] [WINDOW] [PAGE]

Effect: Sets the values of the WIDTH and HEIGHT parameters used in the BOX command. When a window is first started, the SIZE value is set to the same values as the window itself (default setting).

Parameters: If one of the parameter specifications is missing, then no change is made to the current value of this parameter. If a parameter value does not have a leading sign, then its value is interpreted as an absolute value. If a parameter value is specified with a leading sign, then the new value of the parameter is calculated relative to the old value.

WIDTH, HEIGHT

Dimensions of the rectangle or line.

WINDOW

Sets the values for the width and height to the values of the current window (default setting).

PAGE

Sets the values for the width and height to the values of the current output page.

/: SIZE WINDOW

Sets WIDTH and HEIGHT to the current window dimensions.

/: SIZE WIDTH '3.5' CM HEIGHT '7.6' CM

Sets WIDTH to 3.5 cm and HEIGHT to 7.6 cm.

/: POSITION WINDOW

/: POSITION XORIGIN -20 TW YORIGIN -20 TW

/: SIZE WIDTH +40 TW HEIGHT +40 TW

/: BOX FRAME 10 TW

A frame is added to the current window. The edges of the frame extend beyond the edges of the window itself, so as to avoid obscuring the leading and trailing text characters.

Hope this resolves your query.

<REMOVED BY MODERATOR>

Regards

Edited by: Alvaro Tejada Galindo on Jul 8, 2008 11:15 AM

Former Member
0 Kudos

hi,

i have some issues before answering your query,

1> only item data should be printed in the boxes?

or

2>any other data also to be printed in the boxes below to the item boxes?

in 1st case, you can change the y position dynamically by using + with the value.

for eg. box xpos 2 cm ypos +3 ch width 30 ch height 3 ch.

you keep the above code in text element, and call the text element through write_form in a loop, so every time y position value get incremented by 3 characters,

in 2nd case, let me know your complete requirment,

Former Member
0 Kudos

Hi,

I am assuming you want to create the dynamic box in the MAIN window. Inside the window before the line items, create a command like this one:

BOX XPOS '0' CM YPOS '2.6' CM WIDTH '17' CM HEIGHT '2.2' CM FRAME 10 TW

Change the window height of your MAIN window to 1,00 LN, then you should create multiple copies of your main window. For example if the the original window height of your main window is 30,00 LN, create 30 copies of your main window and name then as MAIN, MAIN01,MAIN0.....MAIN29 including the original. It is better to use the unit LN.

This will serve as a dynamic box since every preceding 'MAIN' window will be forced to carry over each line to the next, eventually creating the dynamic box.

Hope this helps.

Former Member
0 Kudos

Pre-Setting BOX Position Arguments

You can use the POSITION and SIZE commands to preset some arguments in the BOX command. POSITION presets the start point (upper left corner) of a box or line. SIZE specifies the width and height of a box.

You can use POSITION and SIZE to preset arguments, but you can also set the start point and size arguments of a box or line directly in the BOX command.

By default, if no positioning is specified, the upper left corner of a box or halftone or the top of a line is aligned with current SAPscript window. That is, the upper left corner of the box, halftone, or line starts at the upper left corner of the current window in the active form. By default, the height and width of a box are set to the height and width of the current window.

Use POSITION and SIZE to preset the arguments in a BOX command in the following situations:

The BOX command exceeds the 132-character (1 line in SAPscript) length limitation if you specify all arguments directly in the command. You may exceed this length limit if, for example, you use symbols in a command.

By pre-setting arguments with POSITION and SIZE, you can work around the limitation on the length of a command. You do not need to specify the preset arguments in the BOX command.

You want to use the enhanced capabilities of POSITION for adjusting the starting point of a box or line.

With BOX, you can specify an offset for the starting point only as a whole number (non-negative integer). This command would print a box starting 1 CM to the right and 1 CM down from the left upper corner of a window:

/: BOX XPOS '1' CM YPOS '1' CM

With POSITION; you can adjust the position of a line or box relative to a window much more precisely. In the POSITION command, you can specify positive and negative offsets and use non-integer numbers.

Example: The commands shown below position a box slightly to the left and slightly above a window. This leaves a margin between the edge of the box and the text in the window.

/: POSITION XORIGIN '-.2' CM YORIGIN '-.2' CM

/: SIZE WIDTH '.2' CM HEIGHT '.2' CM

/: BOX FRAME 10 TW

(Note that the box must be enlarged to accommodate the shift. If it is not enlarged, then it will not cover all of the window.)

You can also use POSITION to set the starting point to the upper left corner of the active page format. Example: POSITION PAGE moves the starting point from the active window to the active page format.

You want to use the relative sizing capabilities of SIZE to adjust the size of a box, line, or halftone.

With BOX, you can make only absolute size specifications. BOX HEIGHT, for example, overrides the default height setting to the height of the current window.

With SIZE, you can adjust the size of a box or a line with respect to its previously-set dimensions. The following commands would, for example, draw a frame 1 CM in from the margins of the paper:

/: POSITION PAGE

/: POSITION XORIGIN 1 CM YORIGIN 1 CM

/: SIZE PAGE

/: SIZE HEIGHT '-2' CM WIDTH '-2' CM

Boxes, Lines, Shading: BOX, POSITION, SIZE

Use the BOX, POSITION, and SIZE commands for drawing boxes, lines, and shading to print particular windows within a form or passages of text within a window in a frame or with shading.

The SAP printer drivers that are based on page-oriented printers (the HP LaserJet driver HPL2, the Postscript driver POST, the Kyocera Prescribe driver PRES) employ these commands when printing. Line printers and page-oriented printers not supported in the standard ignore these commands. You can view the resulting printer output in the SAPscript print preview.

Syntax:

/: BOX [XPOS] [YPOS] [WIDTH] [HEIGHT] [FRAME] [INTENSITY]

/: POSITION [XORIGIN] [YORIGIN] [WINDOW] [PAGE]

/: SIZE [WIDTH] [HEIGHT] [WINDOW] [PAGE]

BOX Command

Syntax

/: BOX [XPOS] [YPOS] [WIDTH] [HEIGHT] [FRAME] [INTENSITY]

Effect: draws a box of the specified size at the specified position.

Parameters: For each of XPOS, YPOS, WIDTH, HEIGHT, and FRAME, you must specify both a measurement and a unit of measurement. Specify the INTENSITY parameter as a percentage between 0 and 100.

XPOS, YPOS

Upper left corner of the box, relative to the values of the POSITION command.

Default: Values specified in the POSITION command.

The following calculation is performed internally to determine the absolute output position of a box on the page:

X(abs) = XORIGIN + XPOS

Y(abs) = YORIGIN + YPOS

WIDTH

Width of the box. Default: WIDTH value of the SIZE command.

HEIGHT

Height of the box. Default: HEIGHT value of the SIZE command.

FRAME

Thickness of frame.

Default: 0 (no frame).

INTENSITY

Grayscale of box contents as %.

Default: 100 (full black)

Measurements: You must specify decimal numbers as literal values (like ABAP numeric constants) by enclosing them in inverted commas. Use the period as the decimal point character. See also the examples listed below.

Units of measurement: The following units of measurement may be used:

TW (twip)

PT (point)

IN (inch)

MM (millimeter)

CM (centimeter)

LN (line)

CH (character).

The following conversion factors apply:

1 TW = 1/20 PT

1 PT = 1/72 IN

1 IN = 2.54 CM

1 CM = 10 MM

1 CH = height of a character relative to the CPI specification in the form header

1 LN = height of a line relative to the LPI specification in the form header

/: BOX FRAME 10 TW

Draws a frame around the current window with a frame thickness of 10 TW (= 0.5 PT).

/: BOX INTENSITY 10

Fills the window background with shading having a gray scale of 10 %.

/: BOX HEIGHT 0 TW FRAME 10 TW

Draws a horizontal line across the complete top edge of the window.

/: BOX WIDTH 0 TW FRAME 10 TW

Draws a vertical line along the complete height of the left hand edge of the window.

/: BOX WIDTH '17.5' CM HEIGHT 1 CM FRAME 10 TW INTENSITY 15

/: BOX WIDTH '17.5' CM HEIGHT '13.5' CM FRAME 10 TW

/: BOX XPOS '10.0' CM WIDTH 0 TW HEIGHT '13.5' CM FRAME 10 TW

/: BOX XPOS '13.5' CM WIDTH 0 TW HEIGHT '13.5' CM FRAME 10 TW

Draws two rectangles and two lines to construct a table of three columns with a highlighted heading section.

POSITION Command

Syntax

/: POSITION [XORIGIN] [YORIGIN] [WINDOW] [PAGE]

Effect: Sets the origin for the coordinate system used by the XPOS and YPOS parameters of the BOX command. When a window is first started, the POSITION value is set to refer to the upper left corner of the window (default setting).

Parameters: If a parameter value does not have a leading sign, then its value is interpreted as an absolute value, in other words, as a value that specifies an offset from the upper left corner of the output page. If a parameter value is specified with a leading sign, then the new value of the parameter is calculated relative to the old value. If one of the parameter specifications is missing, then no change is made to this parameter.

XORIGIN, YORIGIN

Origin of the coordinate system.

WINDOW

Sets the values for the left and upper edges to match those of the current window (default setting).

PAGE

Sets the values for the left and upper edges to match those of the current output page (XORIGIN = 0 cm, YORIGIN = 0 cm).

/: POSITION WINDOW

Sets the origin for the coordinate system to the upper left corner of the window.

/: POSITION XORIGIN 2 CM YORIGIN '2.5 CM'

Sets the origin for the coordinate system to a point 2 cm from the left edge and 2.5 cm from the upper edge of the output page.

/: POSITION XORIGIN '-1.5' CM YORIGIN -1 CM

Shifts the origin for the coordinates 1.5 cm to the left and 1 cm up.

SIZE Command

Syntax

/: SIZE [WIDTH] [HEIGHT] [WINDOW] [PAGE]

Effect: Sets the values of the WIDTH and HEIGHT parameters used in the BOX command. When a window is first started, the SIZE value is set to the same values as the window itself (default setting).

Parameters: If one of the parameter specifications is missing, then no change is made to the current value of this parameter. If a parameter value does not have a leading sign, then its value is interpreted as an absolute value. If a parameter value is specified with a leading sign, then the new value of the parameter is calculated relative to the old value.

WIDTH, HEIGHT

Dimensions of the rectangle or line.

WINDOW

Sets the values for the width and height to the values of the current window (default setting).

PAGE

Sets the values for the width and height to the values of the current output page.

/: SIZE WINDOW

Sets WIDTH and HEIGHT to the current window dimensions.

/: SIZE WIDTH '3.5' CM HEIGHT '7.6' CM

Sets WIDTH to 3.5 cm and HEIGHT to 7.6 cm.

/: POSITION WINDOW

/: POSITION XORIGIN -20 TW YORIGIN -20 TW

/: SIZE WIDTH +40 TW HEIGHT +40 TW

/: BOX FRAME 10 TW

A frame is added to the current window. The edges of the frame extend beyond the edges of the window itself, so as to avoid obscuring the leading and trailing text characters.

Tips and Guidelines

To ensure in forms that boxes, lines, and shading fit correctly with text, follow these guidelines:

In your form design, match graphical elements and windows to each other. By default, a box defined in a window has the dimensions and starting point of the window.

Defining a window for each graphical element that you want to include facilitates using boxes, lines, and shading, since the graphical element and the window have the same dimensions and positioning.

Example: If a window is defined with the dimensions 6 CM high and 8 CM wide, then this statement in the text element of the window paints a 10 halftone with the same dimensions. The shading is oriented on the upper left corner of the window.

/: BOX INTENSITY 10

Use the POSITION command to adjust the position of a box or line relative to a window.

For example, these commands in a form window would allow more room above the first line of text in the window. The box would start 0.2 CM above the top of the window.

/: POSITION YORIGIN '-0.2' CM

/: SIZE HEIGHT '+0.2' CM

/: BOX INTENSITY 5

Make sure to increase the size of the box to accommodate an offset. Otherwise, the box will not cover all of the window.

In the example above, the SIZE command increases the height of the box by 0.2 CM to accommodate the positioning of the box above the window.

Draw a horizontal line by setting the HEIGHT in a BOX command to 0. Draw a vertical line by setting WIDTH to 0.

/: BOX FRAME 10 TW WIDTH 0 TW HEIGHT '10' CM

Vertical line 10 CM long

/: BOX FRAME 10 TW WIDTH '10' CM HEIGHT 0 TW

Horizontal line 10 CM long

Adjust the tabs in a window to match the position of lines and boxes.

For example, you define a table with the commands shown below. The vertical lines in the table are drawn in at 10 CM and 13.5 CM from the left edge of the window:

/: BOX WIDTH '17.5' CM HEIGHT '13.5' CM FRAME 10 TW

/: BOX WIDTH '17.5' CM HEIGHT 1 CM FRAME 10 TW INTENSITY 15

/: BOX XPOS '10.0' CM WIDTH 0 TW HEIGHT '13.5' CM FRAME 10 TW

/: BOX XPOS '13.5' CM WIDTH 0 TW HEIGHT '13.5' CM FRAME 10 TW

In the paragraph formats that you use to fill the table, you would define tabs at the positions shown below. With these tabs, your input would start right-justified in the first, second, and third columns of the table. You must ensure that your input is not too long to fit in the columns defined with the lines:

Format TB Fill table

Tabs: 1 9.5 CM RIGHT

2 13.0 CM RIGHT

3 17.0 CM RIGHT

Refer this link for more info about boxes lines and shading.

http://help.sap.com/saphelp_47x200/helpdata/en/d1/80318f454211d189710000e8322d00/frameset.htm

Regards,

former_member181962
Active Contributor
0 Kudos

Hi satish,

YOu have to predefine the widths and heights for each columnd of the item.

The width of the columns should not be changed for any particu;ar item.

Refer this link for more info about boxes lines and shading.

http://help.sap.com/saphelp_47x200/helpdata/en/d1/80318f454211d189710000e8322d00/frameset.htm

Regards,

Ravi

Former Member
0 Kudos

Hi,

/: BOX WIDTH &WIDTH& CM HEIGHT &HEIGHT& CM FRAME 10 TW

/: BOX WIDTH &WIDTH& CM HEIGHT &HEIGHT& CM FRAME 10 TW

You need to fill these WIDTH and HEIGHT values based on your conditions, even you can write a perform before this one and caliculate the Width and height then pass the values back to the Script and use them

Regards

Sudheer