Skip to Content
0
Former Member
Nov 22, 2005 at 08:53 AM

Dynamic Move statement

88 Views

DATA: t184 LIKE TABLE OF t184 WITH HEADER LINE.
DATA: BEGIN OF pstyd OCCURS 0,
  pstyd TYPE pstyd,
END OF pstyd.

LOOP AT t184.

  pstyd-pstyd = t184-psty1. APPEND pstyd.
  pstyd-pstyd = t184-psty2. APPEND pstyd.
  pstyd-pstyd = t184-psty3. APPEND pstyd.
  pstyd-pstyd = t184-psty4. APPEND pstyd.
  pstyd-pstyd = t184-psty5. APPEND pstyd.
  pstyd-pstyd = t184-psty6. APPEND pstyd.
  pstyd-pstyd = t184-psty7. APPEND pstyd.
  pstyd-pstyd = t184-psty8. APPEND pstyd.
  pstyd-pstyd = t184-psty9. APPEND pstyd.
  pstyd-pstyd = t184-psty10. APPEND pstyd.
  pstyd-pstyd = t184-psty11. APPEND pstyd.
  pstyd-pstyd = t184-pstyv. APPEND pstyd.

ENDLOOP.

How can I shorten the code. Somthing to this effect:

DATA name TYPE string.
FIELD-SYMBOLS <char> LIKE pstyd-pstyd.
LOOP AT t184.
  DO 12 TIMES.
    name = sy-index.
    IF name = '12'. name = ''. ENDIF.
    CONCATENATE 't184-pstyv' name INTO name.
    ASSIGN (name) TO <char>.
    Write <char> to pstyd-pstyd.
    APPEND pstyd.
  ENDDO.
ENDLOOP.

The above code is, of course, not working. I have posted it just to give an idea of what I want.