Application Development 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: 

parameterizing data objects

Former Member
0 Kudos
106

I am working ion a process where I have to total the credit and debit fields of the structure skc1a depending on the posting period that the user supplies. I think I can accomplish this with the DO/ENDDO process but i have a question concerning data object names. I would like to something like this and I am not sure if this will work or this is the right approach to handle this

p_poper id the object that the user has entered. this is the posting period that the data is be accumalated for. amount will be totaled beginning with period 1 and ending with period p_poper.

w_ctr = 00.

do p_poper times

w_ctr = w_ctr + 1.

<i>hopefully w_ctr will be 01</i>

w_totcred = w_totcred + iskc1a-um<b>w_ctr</b>s.

enddo.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
74

From the help on DO:

Example

DATA: BEGIN OF WORD, 
        ONE   VALUE 'E', 
        TWO   VALUE 'x', 
        THREE VALUE 'a', 
        FOUR  VALUE 'm', 
        FIVE  VALUE 'p', 
        SIX   VALUE 'l', 
        SEVEN VALUE 'e', 
        EIGHT VALUE '!', 
      END   OF WORD, 
      LETTER1, LETTER2. 
DO VARYING LETTER1 FROM WORD-ONE NEXT WORD-THREE 
   VARYING LETTER2 FROM WORD-TWO NEXT WORD-FOUR. 
  WRITE: LETTER1, LETTER2. 
  IF LETTER2 = '!'. 
    EXIT. 
  ENDIF. 
ENDDO. 



The resulting output is the character string 

"E x a m p l e !".

This may be what you want.

Rob

Message was edited by: Rob Burbank

5 REPLIES 5

Former Member
0 Kudos
74

Timothy,

Go with this:

*data: w_ctr(2) type n.

FIELD-SYMBOLS: <comp> TYPE ANY.

data: comp_ctr type i.

comp_ctr = 12.

do p_poper times

assign component comp_ctr of structure iskc1a to <comp>.

w_totcred = w_totcred + <comp>.

comp_ctr = comp_ctr + 5.

enddo.

0 Kudos
74

Timothy,

Have you resolved your issue?

If not, plz provide more details.

Former Member
0 Kudos
75

From the help on DO:

Example

DATA: BEGIN OF WORD, 
        ONE   VALUE 'E', 
        TWO   VALUE 'x', 
        THREE VALUE 'a', 
        FOUR  VALUE 'm', 
        FIVE  VALUE 'p', 
        SIX   VALUE 'l', 
        SEVEN VALUE 'e', 
        EIGHT VALUE '!', 
      END   OF WORD, 
      LETTER1, LETTER2. 
DO VARYING LETTER1 FROM WORD-ONE NEXT WORD-THREE 
   VARYING LETTER2 FROM WORD-TWO NEXT WORD-FOUR. 
  WRITE: LETTER1, LETTER2. 
  IF LETTER2 = '!'. 
    EXIT. 
  ENDIF. 
ENDDO. 



The resulting output is the character string 

"E x a m p l e !".

This may be what you want.

Rob

Message was edited by: Rob Burbank

0 Kudos
74

An easier example would be:


      do 16 times
          varying amount from actuals_int-hsl01 next actuals_int-hsl02.
        total = total + amount.
      enddo.

Rob

Former Member
0 Kudos
74

I have resolved my issue. I am using the following code and it is successful. thanks to all who helped me on this.

w_cramount = 0.

w_dbamount = 0.

w_totcred = 0.

w_totdeb = 0.

do p_poper times

varying w_cramount from iskc1a-um01s next iskc1a-um02s.

w_totcred = w_totcred + w_cramount.

enddo.

do p_poper times

varying w_dbamount from iskc1a-um01h next iskc1a-um02h.

w_totdeb = w_totdeb + w_dbamount.

enddo.