cancel
Showing results for 
Search instead for 
Did you mean: 

Drawing Boxes in Script - main window

Former Member
0 Kudos

hi,

In script, in main window <u>after table line item datas</u>, i want to draw a box in which i will place some text. On drawing box, it appears on top of that window which i dont want, since it should be placed after item details.

kapil.

Accepted Solutions (0)

Answers (5)

Answers (5)

former_member533584
Contributor
0 Kudos

hi,

use ypos &postion&.

some how u kow what is the hight required for i line item.

in program u declare varible position and mulitifly with number of line items.

before calling write form.

i hope this will solve ur prob .

Regards,

ananth

Former Member
0 Kudos

thanx for ur sugg.

here what i need is , the box should b dynamic , it should depend on number of line item datas that will b printed above this box.

zsolt_gerebenics
Discoverer
0 Kudos

I do not know this is still relevant for You or not but here is the solution what I did:

First of all I have to mention this requires SAP standard object modification. !!!

1.Start SE80 and get into STXC function group.

2.Select COP_RELATIVE_NUMBER subroutines and double click on that.

3.Click on Edit button and Get SSCR Object number from SAP.

4.Change interface of the COP_RELATIVE_NUMBER subroutines extending it with TYPE parameters

5.Change the first if Statement.

6.Extend the Relative case section with a new WHEN '#'.

7. Cange All COP_RELATIVE_NUMBER calls with new input parameter in CO_BOX, In CO_POSITION, In CO_SIZE.

From now in Your SAP script You can call BOX statement like this:

BOX XPOS ‘#10’ TW YPOS ‘#10’ TW …..

Will start drowing BOX from cursor current position plus 10 twip.

Numbers after the # sign are optional.

Solution works only with TW.


form co_box.
data: begin of bx,
        x    type i,
        y    type i,
        w    type i,
        h    type i,
        f    type i,
        i(3) type n,
      end of bx,
      next(10),
      xpos         type i,
      ypos         type i,
      is_relative like boolean.

  bx-x = ft-wpx.
  bx-y = ft-wpy.
  bx-w = ft-wpw.
  bx-h = ft-wph.
  while co-endline = false.
    perform cop_next using next 10.
    case next.
      when 'XPOS'.
*{   REPLACE        ED1K902054                                        1
*        perform cop_relative_number using is_relative xpos.
        perform cop_relative_number using is_relative xpos 'X'.
*}   REPLACE
        add xpos to bx-x.
      when 'YPOS'.
*{   REPLACE        ED1K902054                                        2
*        perform cop_relative_number using is_relative ypos.
        perform cop_relative_number using is_relative ypos 'Y'.
*}   REPLACE
        add ypos to bx-y.
      when 'WIDTH'.
        perform cop_number_value using bx-w.
      when 'HEIGHT'.
        perform cop_number_value using bx-h.
      when 'FRAME'.
        perform cop_number_value using bx-f.
      when 'INTENSITY'.
        perform cop_next using next 3.
        bx-i = next.
      when space. exit.
      when '.'.   exit.
      when others.
        perform cop_warning using subrc_param_unknown next.
    endcase.
  endwhile.
  perform cop_end.
  check co-error = false.
  perform pc_box using bx-x bx-y bx-w bx-h bx-f bx-i.
endform.

form co_position.
data: begin of pos,
        x type i,
        y type i,
      end of pos,
      next(10),
      relative like boolean,
      xpos     type i,
      ypos     type i.

  pos-x = ft-wpx.
  pos-y = ft-wpy.
  while co-endline = false.
    perform cop_next using next 10.
    case next.
      when 'XORIGIN'.
*{   REPLACE        ED1K902054                                        1
*        perform cop_relative_number using relative xpos.
        perform cop_relative_number using relative xpos 'X'.
*}   REPLACE
        if relative = true.
          add xpos to pos-x.
        else.
          pos-x = xpos.
        endif.
      when 'YORIGIN'.
*{   REPLACE        ED1K902054                                        2
*        perform cop_relative_number using relative ypos.
        perform cop_relative_number using relative ypos 'Y'.
*}   REPLACE
        if relative = true.
          add ypos to pos-y.
        else.
          pos-y = ypos.
        endif.
      when 'WINDOW'.
        pos-x = ft-tdwlefts.
        pos-y = ft-tdwtops.
      when 'PAGE'.
        pos-x = 0.
        pos-y = 0.
      when space. exit.
      when '.'.   exit.
      when others.
        perform cop_warning using subrc_param_unknown next.
    endcase.
  endwhile.
  perform cop_end.
  check co-error = false.
  ft-wpx = pos-x.
  ft-wpy = pos-y.
endform.

form co_size.
data: begin of dim,
        w type i,
        h type i,
      end of dim,
      next(10),
      relative     like boolean,
      width        type i,
      height       type i.

  dim-w = ft-wpw.
  dim-h = ft-wph.
  while co-endline = false.
    perform cop_next using next 10.
    case next.
      when 'WIDTH'.
*{   REPLACE        ED1K902054                                        1
*        perform cop_relative_number using relative width.
        perform cop_relative_number using relative width 'X'.
*}   REPLACE
        if relative = true.
          add width to dim-w.
        else.
          dim-w = width.
        endif.
      when 'HEIGHT'.
*{   REPLACE        ED1K902054                                        2
*        perform cop_relative_number using relative height.
        perform cop_relative_number using relative height 'Y'.
*}   REPLACE
        if relative = true.
          add height to dim-h.
        else.
          dim-h = height.
        endif.
      when 'WINDOW'.
        dim-w = ft-tdwwidths.
        dim-h = ft-tdwheights.
      when 'PAGE'.
        dim-w = form_header-tdpagwidth.
        dim-h = form_header-tdpagheigh.
      when space. exit.
      when '.'.   exit.
      when others.
        perform cop_warning using subrc_param_unknown next.
    endcase.
  endwhile.
  perform cop_end.
  check co-error = false.
  ft-wpw = dim-w.
  ft-wph = dim-h.
endform.


*{   REPLACE        ED1K902054                                        3
*form cop_relative_number using is_relative like boolean
*                               val         type i.
form cop_relative_number using is_relative like boolean
                               val         type i
                               type        type c.
*}   REPLACE
data: num type f,
      next(10).
  clear is_relative.
  perform cop_next using next 10.
*{   REPLACE        ED1K902054                                        1
*  if next(1) cn '+-.0123456789 '.
  if next(1) cn '#+-.0123456789 '.
*}   REPLACE
    perform cop_warning using subrc_param_unknown next.
    clear: is_relative, val.
    exit.
  else.
    if next+1(9) cn '.0123456789 '.
      perform cop_warning using subrc_param_unknown next.
      clear: is_relative, val.
      exit.
    else.
      case next(1).
        when '+'.
          is_relative = true.
          num = next+1(9).
        when '-'.
          is_relative = true.
          num = next+1(9).
          num = -1 * num.
*{   INSERT         ED1K902054                                        2
        when '#'.
          is_relative = true.
          num = next+1(9).
          case type.
            when 'X'.
              num = ( ft-line_width  - ft-rem_width ) + num.
            when 'Y'.
              num = ( ft-fill_height - ft-rem_height ) + num.
          endcase.
*}   INSERT
        when others.
          num = next.
      endcase.
    endif.
  endif.
  perform cop_num_val using num.
  val = num.
endform.

former_member533584
Contributor
0 Kudos

hi,

i think u need to entered a value for ypos.

BOX XPOS 16 MM <b>YPOS 92</b> MM WIDTH '18.1' CM HEIGHT '13.4'CM FRAME 10 TW

regards,

ananth

Former Member
0 Kudos

Hi,

Go through the following link.

http://help.sap.com/saphelp_47x200/helpdata/en/d2/cb3d07455611d189710000e8322d00/frameset.htm

You can also look at the following documentation.

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

Reward if it helps you.

Regards,

Sandhya

Former Member
0 Kudos

<b>BOX, POSITION, SIZE:</b> Boxes, lines, shading

The BOX, POSITION and SIZE commands are for drawing boxes, lines and shadows. These commands can be used to specify that within any particular layout set, window or passage of window text can be output in a frame or with shadowing.

The SAP printer drivers that are based on page-oriented printers (the HP LaserJet PCL-5 driver HPLJ4, the

Postscript driver POST, the Kyocera Prescribe driver PRES) employ these commands when creating output. Line printers and non-supported page-oriented printers ignore these commands. The resulting output may be viewed in the SAPscript print previewer.

Syntax:

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

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

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

BOX

Syntax:

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

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

Parameters: For each parameter (XPOS, YPOS, WIDTH, HEIGHT and FRAME), both a measurement and a unit of measure must be specified. The INTENSITY parameter should be entered as a percentage between 0 and 100.

•&#61472;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

•&#61472;WIDTH: Width of the box.

Default: WIDTH value of the SIZE command.

•&#61472;HEIGHT: Height of the box.

Default: HEIGHT value of the SIZE command.

•&#61472;FRAME: Thickness of frame.

Default: 0 (no frame).

•&#61472;INTENSITY: Grayscale of box contents as %.

Default: 100 (full black)

Regards,

Santosh