cancel
Showing results for 
Search instead for 
Did you mean: 

how to use ITCSY structure for summation

Former Member
0 Kudos

can any one say how to use ITCSY structure for summation?

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

<b>script code</b>

/:PERFORM get_date IN PROGRAM zreport 
/:USING &VAL1&
/:USING &VAL2&
/:CHANGING &S_DATE&
/:ENDPERFORM  

<b>

The ABAP Code would be</b>


           REPORT zreport.
           TABLES ztab.
 
           FORM get_date TABLES in_tab STRUCTURE ITCSY out_tab 
           STRUCTURE ITCSY .
           data:  val1 type i.
           READ TABLE in_tab INDEX 1.
          val1 = in+tab1-value.    " Moving the value to a temporary variable
           IF sy-subrc EQ 0.
           READ TABLE out-tab INDEX 1.
          if sy-subrc = 0.
          out_tab-value = in_tab-val2 + val1.  " Caliculating the value
           MODIFY out_tab INDEX 1.
           ENDIF.
           ENDFORM.

Regards

Sudheer

Former Member
0 Kudos

Prakash,

For using routine in the sapscript v have to use itcsy.

i have given a demo pgm for ur reference.

/: PERFORM SUM IN PROGRAM ZPROGRAM

/: USING &VAR1&

/: USING &VAR2&

/: CHANGING &RESULT&

/: ENDPERFORM

In the program(ZPROGRAM), we need to write the form ....

FORM SUM TABLES INTAB STRUCTURE ITCSY

OUTTAB STRUCTURE ITCSY.

data: field1 type i,

field2 type i,

result type i.

TO read the values from the ITAB you have to use this logic.

READ TABLE INTAB WITH KEY NAME = 'VAR1'.

IF SY-SUBRC = 0.

FIELD1 = INTAB-VALUE.

ENDIF.

READ TABLE INTAB WITH KEY NAME = 'VAR2'.

IF SY-SUBRC = 0.

FIELD2 = ITAB-VALUE.

ENDIF.

RESULT = V_FIELD1 + V_FIELD2.

READ TABLE OUTTAB INDEX 1.

IF SY-SUBRC = 0.

OTAB-VALUE = RESULT.

MODIFY OUTTAB INDEX 1 .

ENDIF.

ENDFORM.

~~Guduri