Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

dynamically table for sapscript

Former Member
0 Likes
1,499

hi expects,

how could i create dynamical table for form in script.

6 REPLIES 6
Read only

Former Member
0 Likes
916

Hii you can create dynamic table for sap script using field symbols,

you have to do it in the driver program,

if you want i can give you the code for dynamic table creation,

please reward points

Read only

0 Likes
916

hi gurus,

please give me the coding for dynamic table creation in sap script.it will very helpful to me.

thank you

Read only

Former Member
0 Likes
916

Hi Vikaas

Its all I need to solve my problem, I´ve the same problem here. Could you post examples codes for us?

Tks

Marcelo Franç

Read only

0 Likes
916

hi expects ,

in my spec, i have to create a dynamically table for sap script.could any body help me.

thank you

Read only

0 Likes
916

Hi ,

check this out ,

TABLES: VBRK, VBRP, VBAK, VBAP, KNA1, KNVV.

DATA : IT_VBRK LIKE VBRK OCCURS 0 WITH HEADER LINE.

DATA : IT_VBRP LIKE VBRP OCCURS 0 WITH HEADER LINE.

DATA : IT_KNA1 LIKE KNA1 OCCURS 0 WITH HEADER LINE.

DATA : QUANT(4) TYPE P DECIMALS 2.

DATA : PRICE(4) TYPE P DECIMALS 2.

DATA : NO_LINES(4) TYPE P decimals 2.

*DATA : NO_LINES(2) TYPE N.

*selection-screen.

SELECT-OPTIONS: S_VBELN FOR VBRK-VBELN.

START-OF-SELECTION.

SELECT *

FROM VBRK

INTO TABLE IT_VBRK

WHERE VBELN IN S_VBELN.

IF NOT IT_VBRK[] IS INITIAL.

SELECT *

FROM VBRP

INTO TABLE IT_VBRP

FOR ALL ENTRIES IN IT_VBRK

WHERE VBELN = IT_VBRK-VBELN.

SELECT *

FROM KNA1

INTO TABLE IT_KNA1

FOR ALL ENTRIES IN IT_VBRK

WHERE KUNNR = IT_VBRK-KUNAG.

ENDIF.

END-OF-SELECTION.

CALL FUNCTION 'OPEN_FORM'

EXPORTING

DIALOG = 'X'

FORM = 'ZASH_SCRIPT_INV'

LANGUAGE = SY-LANGU

.

CLEAR : IT_VBRK, IT_VBRP, QUANT, PRICE.

*DESCRIBE TABLE IT_VBRP LINES NO_LINES.

*NO_LINES = ( NO_LINES + '3.5' ) + ( '0.2' * NO_LINES ).

LOOP AT IT_VBRK.

LOOP AT IT_VBRP WHERE VBELN = IT_VBRK-VBELN.

QUANT = IT_VBRP-FKIMG.

PRICE = IT_VBRP-NETWR.

NO_LINES = SY-TABIX.

NO_LINES = ( NO_LINES + '2.0' ) + ( '0.2' * NO_LINES ) + '0.3'.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = 'BODY'

FUNCTION = 'SET'

TYPE = 'BODY'

WINDOW = 'MAIN'.

ENDLOOP.

ENDLOOP.

CALL FUNCTION 'CLOSE_FORM'

then you can pass

/E BODY

/: SIZE HEIGHT '0.1' MM WIDTH '50' CH

/: BOX FRAME 10 TW XPOX '0.00' MM YPOS &NO_LINES& LN INTENSITY 200

HERE I AM TRYING TO DRAW VERTICAL LINE IN ORDER TO COMPLETE THE BOX DYNAMICALLY

LET ME KNOW IF YOU NEED ANYTHING ELSE.

Thanks

venki

HOPE THIS HELPS

Read only

Former Member
0 Likes
916

hi,

to pass the table to script means passing a field sting to script by using function module write_form.

example program,

TABLES: SPFLI,SFLIGHT.

DATA: BEGIN OF FS_SFLIGHT,

CARRID TYPE SPFLI-CARRID,

CONNID TYPE SPFLI-CONNID,

FLDATE TYPE SFLIGHT-FLDATE,

CITYFROM TYPE SPFLI-CITYFROM,

CITYTO TYPE SPFLI-CITYTO,

END OF FS_SFLIGHT.

TABLES SCARR.

DATA T_SCARR LIKE STANDARD TABLE OF SCARR.

DATA: W_LINES TYPE I,

W_P TYPE I,

W_TEMP TYPE I .

DATA T_FLIGHT LIKE STANDARD TABLE OF FS_SFLIGHT.

SELECT SPFLI~CARRID

SPFLI~CONNID

SFLIGHT~FLDATE

SPFLI~CITYFROM

SPFLI~CITYTO

INTO CORRESPONDING FIELDS OF TABLE T_FLIGHT

FROM SPFLI AS SPFLI JOIN SFLIGHT AS SFLIGHT

ON SPFLICARRID = SFLIGHTCARRID AND

SPFLICONNID = SFLIGHTCONNID

.

CALL FUNCTION 'OPEN_FORM'

EXPORTING

  • APPLICATION = 'TX'

  • ARCHIVE_INDEX =

  • ARCHIVE_PARAMS =

  • DEVICE = 'PRINTER'

  • DIALOG = 'X'

FORM = 'YH648_060104'

  • LANGUAGE = SY-LANGU

  • OPTIONS =

  • MAIL_SENDER =

  • MAIL_RECIPIENT =

  • MAIL_APPL_OBJECT =

  • RAW_DATA_INTERFACE = '*'

  • SPONUMIV =

  • IMPORTING

  • LANGUAGE =

  • NEW_ARCHIVE_PARAMS =

  • RESULT =

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

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

DESCRIBE TABLE T_FLIGHT LINES W_LINES.

LOOP AT T_FLIGHT INTO FS_SFLIGHT.

ADD 1 TO W_TEMP.

  • IF W_LINES NE W_TEMP.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = 'BOXES'

  • FUNCTION = 'SET'

TYPE = 'TOP'

  • WINDOW = 'MAIN'

  • IMPORTING

  • PENDING_LINES =

  • 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

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

  • ELSE.

IF W_TEMP NE W_LINES.

AT NEW CONNID.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = 'DATA'

  • FUNCTION = 'SET'

TYPE = 'BODY'

  • WINDOW = 'MAIN'

  • IMPORTING

  • PENDING_LINES =

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

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

  • ENDIF.

ENDAT.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = 'DATA1'

  • FUNCTION = 'SET'

TYPE = 'BODY'

  • WINDOW = 'MAIN'

  • IMPORTING

  • PENDING_LINES =

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

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ELSE.

SELECT CARRID CARRNAME

FROM SCARR

INTO TABLE T_SCARR.

LOOP AT T_SCARR INTO SCARR.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = 'PROTECT1'

  • FUNCTION = 'SET'

  • TYPE = 'BODY'

WINDOW = 'WINDOW2'

  • IMPORTING

  • PENDING_LINES =

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

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDLOOP.

ENDIF.

ENDLOOP.

  • IF W_LINES NE W_TEMP.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = 'LAST'

  • FUNCTION = 'SET'

  • TYPE = 'TOP'

  • WINDOW = 'MAIN'

  • IMPORTING

  • PENDING_LINES =

  • 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

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CALL FUNCTION 'CLOSE_FORM'

  • IMPORTING

  • RESULT =

  • RDI_RESULT =

  • TABLES

  • OTFDATA =

EXCEPTIONS

UNOPENED = 1

BAD_PAGEFORMAT_FOR_PRINT = 2

SEND_ERROR = 3

SPOOL_ERROR = 4

CODEPAGE = 5

OTHERS = 6

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

to draw boxes on script the syntax will be

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.