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

'DO VARYING' operator

Former Member
0 Likes
1,281

Hello, I have a problem with 'DO' operator. I am using expression in my program:

DATA old_pernr LIKE p9090-OLD_PERNR01. 
    DATA datp LIKE p9090-DATP01. 
    DO 50 TIMES VARYING old_pernr FROM it9090_old-OLD_PERNR01 NEXT it9090_old-OLD_PERNR02
                VARYING datp FROM it9090_old-datp01 NEXT it9090_old-datp02.
    .........
    ENDDO.

In '.........' section I need to update old_pernr field in the infotype 9090. But I don't have exact field name, it could be old_pernr13 or old_pernr25 depending on cycle iteration.

Do you know how to get the field name in that case ?

Thank You.

1 ACCEPTED SOLUTION
Read only

rainer_hbenthal
Active Contributor
0 Likes
1,201

Just modify the old_pernr temporary variable you defined for iterating. After DO loop, it will write back the value automatically in the right variable.

9 REPLIES 9
Read only

Former Member
0 Likes
1,201

Hi,

Inside the Do loop.

u have to add if old_pernr = '25'.

l_datp = datp.

endif.

Read only

rainer_hbenthal
Active Contributor
0 Likes
1,202

Just modify the old_pernr temporary variable you defined for iterating. After DO loop, it will write back the value automatically in the right variable.

Read only

MarcinPciak
Active Contributor
0 Likes
1,201

You may check what Rainer said, but I am not sure of that.

If that doesn't work you can use field symbols for this


field-symbols <pernr> type any.

data: fieldname type string,
        indx(2) type n.

    DO 50 TIMES VARYING old_pernr FROM it9090_old-OLD_PERNR01 NEXT it9090_old-OLD_PERNR02
                VARYING datp FROM it9090_old-datp01 NEXT it9090_old-datp02.
      write sy-index to indx.   "01, 02, 03 ...
      concatenate 'IT0909_OLD-PERNR' indx into fieldname.  "IT0909_OLD-PERNR01 ,02 ...
      assign (fieldname) to <pernr>.   "now <pernr> points to IT0909_OLD-PERNR01, 02...
      <pernr> =  ... "here if you assign somehthing it will automatically reflect in that field
    ENDDO.

Regards

Marcin

Read only

0 Likes
1,201

Much too complictaed. A simple old_pernr = 123456. will do.

>

> If the processing block is not exited within the loop, the content of the variable dobj at the end

> of the loop run is assigned to the previously assigned data object

>

Read only

Former Member
0 Likes
1,201

Thank You

Read only

0 Likes
1,201

What Rainer says is also correct but one thing need to be added. I guess it9090_old is an internal table with header line, so once you asssing value back to old_pernr it will reflect only in its header line, not in tables body


   DO 50 TIMES VARYING old_pernr FROM it9090_old-OLD_PERNR01 NEXT it9090_old-OLD_PERNR02
                VARYING datp FROM it9090_old-datp01 NEXT it9090_old-datp02.
     old_pernr = 'Some value'. "<- here indeed value will be transported back to it9090_old-old_pernr01,02,03 etc 
     "..but it will reflect only in header line, so you need to modify your table
     modify it9090_old.
    ENDDO.

Regards

Marcin

Read only

0 Likes
1,201

>

> What Rainer says is also correct but one thing need to be added. I guess it9090_old is an internal table with header line,

> Marcin

In terms of HR programming, it does not mean internal table but infotype

Read only

0 Likes
1,201

In terms of HR programming, it does not mean internal table but infotype

I know the difference. To be strict it is not an infotype but table representing it

Read only

Former Member
0 Likes
1,201

Rainer. I very amazed when got to know that it really works

Thought that it's too simple,