cancel
Showing results for 
Search instead for 
Did you mean: 

itcsy

Former Member
0 Kudos

plz.explain me the itcsy structure.how to use this in modifyong latout and its fields.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi

ITCSY is a structure used to call a script from subroutine program

It contains following fields

NAME

VALUE

To call ABAP subroutines from within a form we use the

PERFORM... IN PROGRAM ... statement , the advantage of

using it is that the print program is not required to cahnge and we

can get the new data from the subroutine which is placed in a Z

report . To pass and get the values from th subroutine the

parameters are passed which are of type structure ITCSY.

e.g. /:PERFORM get_date IN PROGRAM zreport

/:USING &SALESORDER&

/:CHANGING &S_DATE&

/:ENDPERFORM

The date &S_DATE& ....

The ABAP Code would be

REPORT zreport.

TABLES ztab.

FORM get_date TABLES in_tab STRUCTURE ITCSY out_tab

STRUCTURE ITCSY .

READ TABLE in_tab INDEX 1.

SELECT some_date FROM ztab WHERE salesorder = in_tab-value.

IF sy-subrc EQ 0.

READ TABLE out-tab INDEX 1.

MOVE ztab-somedate TO out_tab-value

MODIFY out_tab INDEX 1.

ENDIF.

ENDFORM.

In the above code USING is used to pass the value to the

subroutine while changing is used to recieve the value from th

subroutine ,for further paramters we can use either USING or

CHANGING .

In the subroutine the type of paramter is always an internal table of

type ITCSY irrespective of the value passed.The VALUE field

of the internal table is used to fill and recieve the values .

The print program is used to print the actual form ,the functions the print program has to do include retrieving of data from database tables , selecting a FORM and printing of TEXT ELEMENTS in a desired sequence.

The function modules used in aprint prgram are :

OPEN_FORM

START_FORM

WRITE_FORM

CONTROL_FORM

END_FORM

CLOSE_FROM

To start printing a form we must use OPEN_FORM and in the end we should use CLOSE_FORM to complete the spool request.

Function modules in detail.

OPEN_FORM function module

This function module should be called first before any printing can take place , here we specify the name of the form and the print language.

CALL FUNCTION 'OPEN_FORM'

EXPORTING

DIALOG = 'X'

DEVICE = 'PRINTER'

FORM = form name

LANGUAGE = SY-LANGU

  • OPTIONS =

EXCEPTIONS

CANCELLED = 1

DEVICE = 2

FORM = 3

OTHERS = 11

.

IF SY-SUBRC NE 0.

MESSAGE ...

ENDIF.

In the above function module the parameter

FORM = Name of form

DEVICE = PRINTER (print using spool),TELEFAX (fax output)

SCREEN (output to screen)

OPTIONS = It is a structure of type ITCPO and it controls the various

attributes like number of copies , print preview etc.

START_FROM function module

This function module is called if we want to use different forms with similar characterstics in a single spool request,it must be closed by END_FORM function module.

CALL FUNCTION 'START_FORM'

EXPORTING

FORM =

LANGUAGE =

STARTPAGE =

EXCEPTIONS

FORM = 1

OTHERS = 7

.

IF SY-SUBRC NE 0.

MESSAGE ...

ENDIF.

WRITE_FORM Function module

This function module is used to write text in a window in the form using

text elements (/:E element). We can specify whether the text is to be appended , replaced or added and in which portion of the window it will be printed i.e TOP, BOTTOM ,BODY. In this function module actual printing takes place.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT =

FUNCTION =

TYPE =

WINDOW =

EXCEPTIONS

ELEMENT = 1

OTHERS = 9

.

IF SY-SUBRC NE 0.

MESSAGE ...

ENDIF.

Here in this function module the ELEMENT specifies which textelement is

printed . WINDOW specifies which window of the form to be print in.

TYPE specifies the output area of the window TOP,BOTTOM,BODY.

FUNCTION specifies whether the text is to be appended , replaced or added.

CLOSE_FORM function module

This function module should be called in the end and it has no exporting

parameter.

CALL FUNCTION 'CLOSE_FROM'

IMPORTING

  • RESULT =

EXCEPTIONS

UNOPENED = 1

OTHERS = 5

.

IF SY-SUBRC NE 0.

MESSAGE ...

ENDIF.

Here the result parameteer returns the status information and print/fax parameters after the form has been printed.

CONTROL_FORM function module

This function module is used to insert SAPScript control commands like NEW-PAGE etc from whithin the ABAP program.

CALL FUNCTION 'CONTROL_FORM'

EXPORTING

COMMAND =

EXCEPTIONS

UNOPENED = 1

OTHERS = 3

.

IF SY-SUBRC NE 0.

MESSAGE ...

ENDIF.

NOTE: The print program and the form are stored in the table TNAPR

To use graphics in the SAPScript FORMS they must be imported to R/3 system for this we use transaction SE78 or report RSTXLDMC and give the graphics a name . The image type is generally .TIF(tagged image format) or .BMP (windows bitmap file) .

The RSTXLDMC report is used to import images which are in Tagged Image Format (.TIF) into R/3 and saved as standard text (OBJECT TEXT and ID ST) in the system. Since these images (.TIF) are stored as standard text they can be included in the sapscript using the standard INCLUDE statement. The image to be used if is not in .TIF format than it should be converted to this format e.g. by using IMAGING program in WINDOWS.

Once converted to .TIF they can be used in RSTXLDMC report. The image is stored by the name of ZHEX-MARCO-name . The other parameters in this report e.g. are used to indicate the type of IMAGE

BCOL for color or BMON for mono color images.

e.g. /:INCLUDE ZHEX-MARCO-name OBJECT TEXT ID ST

After the graphics has been imported we can use the INCLUDE statement to include the graphics or use the menu Edit->Graphics->Create.

e.g. /:BITMAP logo OBJECT GRAPHICS ID BMAP .

The above include statement is inserted automatically if we use the menu command.

BOXES and LINES

To use boxes in the form or to create a table in the form we use BOX statement. a table can be constructed by using a combination of BOXes.

/:BOX XPOS val unit YPOS val unit WIDTH val HEIGHT val INTENSITY val FRAME val unit .

The Unit used in the sapscript cane be:

TW twip

MM milimeter

CM centimeter

LN line

CH character

IN inch

PT point

The parameters like WIDTH , XPOS etc should be followed by a proper unit.

The INTENSITY is in the percentage of the grey scale.

The FRAME parameter is the thickness of the frame the default value is 0.

e.g.

/:BOX XPOS '5' CM YPOS '2' CM WIDTH '14' CM HEIGHT '20' CM FRAME 20 TW INTENSITY 10.

e.g.

/:BOX INTENSITY 10

will fill the current window background with a shading of grey scale 10%..

To draw a horizontal line we set the HEIGHT parameter to the value of 0.

e.g.

/:BOX XPOS '5' CM HEIGHT 0 TW FRAME 10 TW.

This will draw a horizontal line across the top edge of the window.

To draw a horizontal line we should set the value of WIDTH parameter to 0.

e.g.

/:BOX XPOS '5' CM YPOS WIDTH '0' TW FRAME 10 TW.

This will draw a vertical line across the complete height of the left edge of the current window.

POSITION and SIZE

We can use POSITION and SIZE to set default position and size of the window and also for relative positioning. With POSITION we can use the paramters XORIGIN , YORIGIN ,WINDOW. With SIZE we can use WIDTH and HEIGHT and WINDOW and PAGE.

e.g.

/:POSITION XORIGIN '5' CM YORIGIN '5'CM

/:SIZE HEIGHT '5' CM WIDTH '14' CM

/:BOX FRAME 10 TW INTENSITY 10

POSITION WINDOW

We can use POSITION WINDOW to set the position relative to current window i.e to the left,top of the current window ,then we can use POSITION with XORIGIN and YORIGIN to specify the current position relative to the start of the window, we can use '+' and '-' with the values.

e.g.

/:POSITION WINDOW

/:POSITION XORIGIN '5' CM YORIGIN '5' CM

In the above example the position now becomes 5 CM left from the origin of the window and 5 CM from the top of the window.

WINDOW sets the value of the WIDTH and HEIGHT to current window and

PAGE sets the value of the WIDTH and HEIGHT to current page.

e.g.

/:SIZE WINDOW

e.g.

/:SIZE PAGE.

Check my reply here

Check this sample coding

see the sample sub routines and do accordingly
How to call a subroutine form SAPscripts

The Form :

/:PERFORM CDE_CENT IN PROGRAM ZKRPMM_PERFORM_Z1MEDRUCK

/:USING &EKKO-EBELN&

/:CHANGING &CDECENT&

/:ENDPERFORM


The report :

REPORT zkrpmm_perform_z1medruck .
DATA : BEGIN OF it_input_table OCCURS 10.
INCLUDE STRUCTURE itcsy.
DATA : END OF it_input_table.
* déclaration de la table output_table contenant les
variables exportées
DATA : BEGIN OF it_output_table OCCURS 0.
INCLUDE STRUCTURE itcsy.
DATA : END OF it_output_table.

DATA : w_ebeln LIKE ekko-ebeln,
* w_vbeln LIKE vbak-vbeln,
w_zcdffa LIKE vbak-zcdffa.

*-----------------------------------------------------*
* FORM CDE_CENT
*
*-----------------------------------------------------*
FORM cde_cent TABLES input output.

it_input_table[] = input[].
it_output_table[] = output[].

READ TABLE it_input_table INDEX 1.
MOVE it_input_table-value TO w_ebeln.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = w_ebeln
IMPORTING
output = w_ebeln.

SELECT SINGLE zcdffa FROM ekko
INTO w_zcdffa
WHERE ebeln = w_ebeln.

it_output_table-name = 'CDECENT'.
MOVE w_zcdffa TO it_output_table-value.
MODIFY it_output_table INDEX 1.

output[] = it_output_table[].

ENDFORM.
*************************************************************************
/: PERFORM <form> IN PROGRAM <prog>
/: USING &INVAR1&
/: USING &INVAR2&
......
/: CHANGING &OUTVAR1&
/: CHANGING &OUTVAR2&
......
/: ENDPERFORM

INVAR1 and INVAR2 are variable symbols and may be of any of the four SAPscript symbol types.

OUTVAR1 and OUTVAR2 are local text symbols and must therefore be character strings.


Example:
In script form

/: PERFORM READ_TEXTS IN PROGRAM 'Z08M1_FORM_EKFORM1'
/: USING &EKKO-EKORG&
/: USING &EKPO-WERKS&
/: USING &EKKO-EKGRP&
/: USING &EKKO-BSTYP&
/: CHANGING &COMPNAME&
/: CHANGING &SENDADR&
/: CHANGING &INVCADR&
/: CHANGING &COMPADR&
/: CHANGING &COVERLTR&
/: CHANGING &SHIPADR&
/: CHANGING &REMINDER&
/: CHANGING &REJECTION&
/: CHANGING &POSTADR&
/: CHANGING &LOGO&
/: ENDPERFORM


In program
*---------------------------------------------------------------------*
* FORM Read_texts - To extract the standard texts from the table *
*---------------------------------------------------------------------*

FORM READ_TEXTS TABLES IN_PAR STRUCTURE ITCSY
OUT_PAR STRUCTURE ITCSY.

DATA : L_EKORG TYPE EKORG,
L_WERKS TYPE WERKS_D,
L_BSTYP TYPE BSTYP,
L_EKGRP TYPE BKGRP.

READ TABLE IN_PAR WITH KEY 'EKKO-EKORG' .
CHECK SY-SUBRC = 0.
L_EKORG = IN_PAR-VALUE.


READ TABLE IN_PAR WITH KEY 'EKPO-WERKS' .
CHECK SY-SUBRC = 0.
L_WERKS = IN_PAR-VALUE.

READ TABLE IN_PAR WITH KEY 'EKKO-EKGRP' .
CHECK SY-SUBRC = 0.
L_EKGRP = IN_PAR-VALUE.


READ TABLE IN_PAR WITH KEY 'EKKO-BSTYP' .
CHECK SY-SUBRC = 0.
L_BSTYP = IN_PAR-VALUE.

CLEAR Z08M1_ORG_TEXTS.

SELECT SINGLE * FROM Z08M1_ORG_TEXTS WHERE EKORG = L_EKORG
AND WERKS = L_WERKS
AND EKGRP = L_EKGRP
AND BSTYP = L_BSTYP.
IF SY-SUBRC NE 0.
SELECT SINGLE * FROM Z08M1_ORG_TEXTS WHERE EKORG = L_EKORG
AND WERKS = L_WERKS
AND EKGRP = L_EKGRP
AND BSTYP = SPACE.
ENDIF.

READ TABLE OUT_PAR WITH KEY 'COMPNAME'.
OUT_PAR-VALUE = Z08M1_ORG_TEXTS-TXT_COMP.
MODIFY OUT_PAR INDEX SY-TABIX.

READ TABLE OUT_PAR WITH KEY 'SENDADR'.
OUT_PAR-VALUE = Z08M1_ORG_TEXTS-TXT_ADRS.
MODIFY OUT_PAR INDEX SY-TABIX.

READ TABLE OUT_PAR WITH KEY 'INVCADR'.
OUT_PAR-VALUE = Z08M1_ORG_TEXTS-TXT_INVC.
MODIFY OUT_PAR INDEX SY-TABIX.

READ TABLE OUT_PAR WITH KEY 'COMPADR'.
OUT_PAR-VALUE = Z08M1_ORG_TEXTS-TXT_CPAD.
MODIFY OUT_PAR INDEX SY-TABIX.

READ TABLE OUT_PAR WITH KEY 'COVERLTR'.
OUT_PAR-VALUE = Z08M1_ORG_TEXTS-TXT_COVR.
MODIFY OUT_PAR INDEX SY-TABIX.

READ TABLE OUT_PAR WITH KEY 'SHIPADR'.
OUT_PAR-VALUE = Z08M1_ORG_TEXTS-TXT_SHIP.
MODIFY OUT_PAR INDEX SY-TABIX.

READ TABLE OUT_PAR WITH KEY 'REMINDER'.
OUT_PAR-VALUE = Z08M1_ORG_TEXTS-TXT_RMDR.
MODIFY OUT_PAR INDEX SY-TABIX.

READ TABLE OUT_PAR WITH KEY 'REJECTION'.
OUT_PAR-VALUE = Z08M1_ORG_TEXTS-TXT_RJCT.
MODIFY OUT_PAR INDEX SY-TABIX.

READ TABLE OUT_PAR WITH KEY 'POSTADR'.
OUT_PAR-VALUE = Z08M1_ORG_TEXTS-TXT_POST.
MODIFY OUT_PAR INDEX SY-TABIX.

READ TABLE OUT_PAR WITH KEY 'LOGO'.
OUT_PAR-VALUE = Z08M1_ORG_TEXTS-TXT_LOGO.
MODIFY OUT_PAR INDEX SY-TABIX.

ENDFORM.
*************************************************************************
REPORT ZMPO1 .

form get_freight tables in_par structure itcsy out_par structure itcsy.
tables: ekko,konv,t685t.
data: begin of itab occurs 0,
ebeln like ekko-ebeln,
knumv like ekko-knumv,
end of itab.
data: begin of itab1 occurs 0,
knumv like konv-knumv,
kposn like konv-kposn,
kschl like konv-kschl,
kbetr like konv-kbetr,
waers like konv-waers,
kwert like konv-kwert,
end of itab1.
data: begin of iout occurs 0,
kschl like konv-kschl,
vtext like t685t-vtext,
kbetr like konv-kbetr,
kwert like konv-kwert,
end of iout.

data v_po like ekko-ebeln.
read table in_par with key 'EKKO-EBELN'.
if sy-subrc = 0.
v_po = in_par-value.

select
ebeln
knumv
from ekko
into table itab
where ebeln = v_po.

if sy-subrc = 0.
loop at itab.
select
knumv
kposn
kschl
kbetr
waers
kwert
into table itab1
from konv
where knumv = itab-knumv and
kappl = 'M'.
endloop.

loop at itab1.
if itab1-kposn <> 0.
select single * from t685t
where kschl = itab1-kschl
and kappl = 'M'
and spras = 'EN'.
iout-vtext = t685t-vtext.
iout-kschl = itab1-kschl.
iout-kbetr = itab1-kbetr.
iout-kwert = itab1-kwert.
append iout.
clear iout.
endif.
endloop.
sort itab1 by kposn.

loop at iout.
sort iout by kschl.
if ( iout-kschl eq 'GSDC' OR
iout-kschl eq 'GSFR' OR
iout-kschl eq 'GSIR' ).
at end of kschl.
read table iout index sy-tabix.
sum.
* write:/ iout-kschl,iout-vtext,iout-kwert.
out_par-name = 'A1'.
out_par-value = iout-vtext.
append out_par.

out_par-name = 'A2'.
out_par-value = iout-kwert.
append out_par.
endat.
endif.
endloop.
endif.
endif.
endform.

* IN THE FORM I AM WRITING THIS CODE.

/:DEFINE &A1& = ' '
/:DEFINE &A2& = ' '
/:PERFORM GET_FREIGHT IN PROGRAM ZMFORM_PO1
/:USING &EKKO-EBELN&
/:CHANGING &A1&
/:CHANGING &A2&
/:ENDPERFORM
* &A1&
* &A2&

This Code is to be written in the PO form under ADDRESS window.
--------------------------------------------------------------

/:DEFINE &A1& = ' '
/:DEFINE &A2& = ' '
/:DEFINE &A3& = ' '
/:DEFINE &A4& = ' '
/:DEFINE &A5& = ' '
/:DEFINE &A6& = ' '
/:PERFORM GET_VENDOR IN PROGRAM ZMFORM_PO
/:USING &EKKO-EBELN&
/:CHANGING &A1&
/:CHANGING &A2&
/:CHANGING &A3&
/:CHANGING &A4&
/:CHANGING &A5&
/:CHANGING &A6&
/:ENDPERFORM
* &A1&
* &A2&
* &A3&
* &A4&
* &A5&
* &A6&

Regards

Pavan

Message was edited by:

Pavan praveen