10-13-2008 12:38 PM
DATA: GWA_0008 TYPE PA0008,
LGART TYPE PA0008-LGA01,
BETRG TYPE PA0008-BET01.
SELECT SINGLE * FROM PA0008 INTO GWA_0008.
DO 40 TIMES
VARYING LGART FROM GWA_0008-LGA01 NEXT GWA_0008-LGA02
VARYING BETRG FROM GWA_0008-BET01 NEXT GWA_0008-BET02.
" CODE
ENDDO.
as 'do varying' is obselete now, what is the alternate for this statement?
10-13-2008 12:44 PM
I cant see that do varying is obsolete now. Where did you read that? I cant find anything about that in the online help.
10-13-2008 12:46 PM
this is what you need: ASSIGN + INCREMENT :
http://help.sap.com/abapdocu/en/ABAPASSIGN_MEM_AREA_DYNAMIC_DOBJ.htm#!ABAP_ALTERNATIVE_3@3@
Rainer: it is obsolate in Unicode environemnt
10-13-2008 12:46 PM
But you can still use these in your program since you are take care of these exceptions cause i have still DO VARYING Statements in ECC:
Cause: Impermissible access to tables, strings, field or object references within the range specified by the RANGE addition.
Runtime Error: DO_WHILE_VARY_ILLEGAL_ACCESS
Cause: Access to data outside the range specified by the RANGE addition.
Runtime Error: DO_WHILE_VARY_NOT_IN_RANGE
for more help jusr use F1 on DO VARYING there is option there with INCREMENT .
10-13-2008 12:49 PM
i don't like do varying logic, i generally go for Field-symbols logic inside do enddo.
10-13-2008 12:55 PM
Yes: alternate is by the use of ASSIGN + INCREMENT.
But may i have an replacement code for DO VARYING mentioned above, using ASSIGN + INCREMENT.
10-13-2008 12:59 PM
Do like this:
data: s_lgart(14) type c value 'GWA_0008-LGA ',
s_betrg(14) type c value 'GWA_0008-BET ',
index(2) type n.
field-symbols: <fs_lgart> TYPE PA0008-LGA01,
<fs_betrg> TYPE PA0008-BET01.
do 40 times.
index = sy-index. "01, 02, 03, 04...
s_lgart+12(2) = index. "GWA_0008-LGA01, GWA_0008-LGA02 ...
s_betrg+12(2) = index. "GWA_0008-BET01, GWA_0008-BET02...
assing s_lgart to <fs_betrg>.
assing s_betrg to <fs_lgart>.
"<fs_betrg> and <fs_lgart> now store respective values LGA01, BET01 (in first loop), LGA02, BET02 (in second) and so on...
"perform your action
enddo.
10-13-2008 1:08 PM
Hi Marcin,
It will come like this
DATA: S_LGART(5) TYPE C VALUE 'LGA ',
S_BETRG(5) TYPE C VALUE 'BET ',
INDEX(2) TYPE N.
FIELD-SYMBOLS: <FS_LGART>,
<FS_BETRG>.
DO 40 TIMES.
INDEX = SY-INDEX.
S_LGART+3(2) = INDEX.
S_BETRG+3(2) = INDEX.
ASSIGN COMPONENT S_LGART of STRUCTURE GWA_0008 TO <FS_BETRG>.
ASSIGN COMPONENT S_BETRG of STRUCTURE GWA_0008 TO <FS_LGART>.
ENDDO.
But I want an alternate using Assign with Increment statement.