‎2009 Aug 05 11:31 AM
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.
‎2009 Aug 05 2:02 PM
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.
‎2009 Aug 05 1:23 PM
Hi,
Inside the Do loop.
u have to add if old_pernr = '25'.
l_datp = datp.
endif.
‎2009 Aug 05 2:02 PM
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.
‎2009 Aug 05 2:13 PM
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
‎2009 Aug 05 2:19 PM
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
>
‎2009 Aug 06 2:23 AM
‎2009 Aug 06 8:37 AM
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
‎2009 Aug 06 10:11 AM
>
> 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
‎2009 Aug 06 10:13 AM
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
‎2009 Aug 06 10:00 AM
Rainer. I very amazed when got to know that it really works
Thought that it's too simple,