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

Table conversion

Former Member
0 Likes
433

Hi,

I have a screen maintained in the following format.


CCD          CCR
------------------------
XXX            1111
YYY           3333
ZZZ             7777

But it is maintained in the table as follows


Key      CCD1   CCR1    CCD2 CCR2  CCD3  CCR3
-----------------------------------------------------------------------------
k           XXX       1111      yyy   3333    zzz    7777 

how do i access these values in an internal table, in the follwing format


   xxx 1111
   yyy  3333 

and so on

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
394

DATA: BEGIN OF text, 
        word1 TYPE c LENGTH 4 VALUE 'AAAA', 
        word2 TYPE c LENGTH 4 VALUE 'BBBB', 
        word3 TYPE c LENGTH 4 VALUE 'CCCC', 
        word4 TYPE c LENGTH 4 VALUE 'DDDD', 
      END OF text. 

DATA: word  TYPE c LENGTH 4, 
      char1 TYPE c LENGTH 1, 
      char2 TYPE c LENGTH 1, 
      leng TYPE i. 

FIELD-SYMBOLS <word> LIKE text-word1. 
DATA inc TYPE i. 

DESCRIBE FIELD text LENGTH leng IN CHARACTER MODE. 
leng = leng / 2. 

DO leng TIMES VARYING char1 FROM text(1) 
                            NEXT text+2(1) RANGE text 
              VARYING char2 FROM text+1(1) 
                            NEXT text+3(1) RANGE text. 
  WRITE: char1, char2. 
  char1 = 'x'. 
  char2 = 'y'. 
ENDDO. 

DO 4 TIMES VARYING word FROM text-word1 NEXT text-word2. 
  WRITE / word. 
ENDDO. 

DO. 
  inc = sy-index  - 1. 
  ASSIGN text-word1 INCREMENT inc TO <word> RANGE text. 
  IF sy-subrc = 0. 
    WRITE / <word>. 
  ELSE. 
    EXIT. 
  ENDIF. 
ENDDO. 

2 REPLIES 2
Read only

former_member203501
Active Contributor
0 Likes
394

hi here they are using do varying ......means they may using the repretitive structures....look at the repetitive structures...

Read only

Former Member
0 Likes
395

DATA: BEGIN OF text, 
        word1 TYPE c LENGTH 4 VALUE 'AAAA', 
        word2 TYPE c LENGTH 4 VALUE 'BBBB', 
        word3 TYPE c LENGTH 4 VALUE 'CCCC', 
        word4 TYPE c LENGTH 4 VALUE 'DDDD', 
      END OF text. 

DATA: word  TYPE c LENGTH 4, 
      char1 TYPE c LENGTH 1, 
      char2 TYPE c LENGTH 1, 
      leng TYPE i. 

FIELD-SYMBOLS <word> LIKE text-word1. 
DATA inc TYPE i. 

DESCRIBE FIELD text LENGTH leng IN CHARACTER MODE. 
leng = leng / 2. 

DO leng TIMES VARYING char1 FROM text(1) 
                            NEXT text+2(1) RANGE text 
              VARYING char2 FROM text+1(1) 
                            NEXT text+3(1) RANGE text. 
  WRITE: char1, char2. 
  char1 = 'x'. 
  char2 = 'y'. 
ENDDO. 

DO 4 TIMES VARYING word FROM text-word1 NEXT text-word2. 
  WRITE / word. 
ENDDO. 

DO. 
  inc = sy-index  - 1. 
  ASSIGN text-word1 INCREMENT inc TO <word> RANGE text. 
  IF sy-subrc = 0. 
    WRITE / <word>. 
  ELSE. 
    EXIT. 
  ENDIF. 
ENDDO.