Resumen de la utilización de SAP Script
Iván Castillo
castillo.ivan@gmail.com
Creando Formulario Inicial
Se71
[Pag 171] El arte de programar en SAP…
MENU Crear Elemento
Por convención, simpre lapágina principal será llamada
MAIN.
Ventana es el espacio en el cual vamos a trabajar para poder crear nuestros formularios.
Con el menú elemento nuevo
Las Características al final de la pagina
Regresar con Cabecera
Seleccionamos Parametrizaciones básicas
Verificamos que la Pagina sea la principal.
Grabamos
Activamos el Formulario
…
Cadenas de caracteres:
Las cadenas de caracteres son elementos de edición para una parte de un párrafo y son insertadas directamente en el texto. El comienzo del ámbito de texto es marcado con
Se creo una nueva ventana para el CB
Referencia al Texto
Form: LVSBINPRINT
SE71
Una Pagina -> Muchas ventanas
Un Formulario -> Mucha páginas.
Ver el Formulario
…
&<FS_PROGRAMAS>-ID_PROG&
&<FS_PROGRAMAS>-NOMBRE_PROG&
LLAMAR UN FORMULARIO
CALL FUNCTION 'OPEN_FORM'
EXPORTING
DEVICE = 'device'
FORM = V_FORM
LANGUAGE = 'S'
OPTIONS = ITCPO
ARCHIVE_INDEX = TOA_DARA
DEVICE = 'PRINTER'
DIALOG = 'X'
EXCEPTIONS
CANCELED = 01.
Device: Es por donde saldrá el formulario:
ESCRIBIR EN UN FORMULARIO
Para enviar datos del programa al formulario se usa la función WRITE_FORM
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'ITEM'
WINDOW = 'MAIN'
EXCEPTIONS
OTHERS = 01.
Las tablas ITCPO, TOA_DARA y ITCPP son necesarias para poder ejecutar el SAPScript.
TABLES: ZPROGRAMAS,ITCPO,TOA_DARA,ITCPP.
La variable V_FORM contendrá el nombre del formulario, mientras que la variable V_SCRIPT nos sirve para determinar si el formulario está activo o no.
DATA: V_FORM(14) TYPE C,
V_SCRIPT.
Parámetro impresión, salida inmediata
Parámetro impresión, borrar tras salida
Parámetro impresión, tiempo de permanencia en SPOOL
Visualización de impresión.
ITCPO-TDIMMED = '*'.
ITCPO-TDDELETE = '*'.
ITCPO-TDLIFETIME = '7'.
ITCPO-TDPREVIEW = 'X'.
Iniciamos la ejecución del formulario.
CALL FUNCTION 'START_FORM'
EXPORTING
FORM= V_FORM
LANGUAGE= 'S'.
Si la variable V_SCRIPT está vacía, entonces debemos abrir el formulario, para esto utilizamos el módulo de funciones OPEN_FORM.
IFV_SCRIPT EQSPACE.
CALL FUNCTION 'OPEN_FORM'
EXPORTING
FORM= V_FORM
LANGUAGE= 'S'
OPTIONS= ITCPO
ARCHIVE_INDEX= TOA_DARA
DEVICE = 'PRINTER'
DIALOG = 'X'
EXCEPTIONS
CANCELED = 01.
IF SY-SUBRC NE 0.
EXIT.
ENDIF.
V_SCRIPT = 'X'.
ENDIF.
Hacemos un LOOPa la tabla interna T_ZPROGRAMAS y asignamos los valores al Field-Symbol
LOOP ATT_ZPROGRAMAS
ASSIGNING<FS_PROGRAMAS>.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT= 'ITEM'
WINDOW= 'MAIN'
EXCEPTIONS
OTHERS= 01.
ENDLOOP.
Con el módulo de funciones END_FORM indicamos que hemos terminado de utilizar la ventana. Si la variable V_SCRIPTno está vacía, cerramos el formulario con el módulo de funciones CLOSE_FORM.
CALL FUNCTION 'END_FORM'
IMPORTING
RESULT = ITCPP.
IFV_SCRIPT NESPACE.
CALL FUNCTION 'CLOSE_FORM'.
ENDIF.
Output Length
&symbol(length)&
Omitting the Leading Sign
&symbol(S)&
Leading Sign to the Left
&symbol(<)&
Leading Sign to the Right
&symbol(>)&
Omitting Leading Zeros
&symbol(Z)&
Space Compression
&symbol(C)&
Number of Decimal Places
&symbol(.N)&
Omitting the Separator for ‘Thousands’
&symbol(T)&
Specifying an Exponent for Floating Point Numbers
&symbol(EN)&
Right-Justified Output
&symbol(R)&
Fill Characters
&symbol(Ff)&f = fill character
Example: &KNA1-UMSAT(F*)& -> **700.00
Suppressing Output of Initial Values
&symbol(I)&
Ignoring Conversion Routines
&symbol(K)&
Date Mask
/: SET DATE MASK = 'date_mask'
Example:
/: SET DATE MASK = 'MMMM DD, YYYY'
&DATE& -> March 01, 1997
Time Mask
/: SET TIME MASK = 'time_mask'
Example:
/: SET TIME MASK = 'HH:MM'
&TIME& -> 10:08
Effect: draws a box of the specified size at the specified position.
Additions: 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.
/: 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).
Additions: 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.
Lista de todos los CB
Se creo el Formato del código de barras
C1 para el código de barras
Impresión de salida
Escaneando
-
Nueva
Nombre
Escojamos Rotado
Parámetros por defecto
Aparece nuestro CB
ELEMENT es el nombre del elemento de textos que deseamos enviarle datos ITEM
Unit: The following units of measurement may be used:
TW (twip)
PT (point)
IN (inch)
MM (millimeter)
CM (centimeter)
LN (line)
CH (character)
Conversion factors:
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
Example
/: 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 grayscale 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.
Example
/: 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 left upper coordinate 1.5 cm to the left and 1 cm up.