‎2006 Oct 17 4:08 PM
Hi,
I have the following structure :
4 keys followed by 94 data columns.
Ex: A B C D 1 2 3 4 ....
and I would like to convert it into
A B C D sy-datum 1
A B C D sy-datum-1 2
Can anyone help me with the code.
thanks
amit
‎2006 Oct 17 5:42 PM
Hi,
I tried this 4 keys and additional three fields..It worked..
DATA: BEGIN OF S_STRUC,
KEY1,
KEY2,
KEY3,
KEY4,
FIRST TYPE CHAR10 VALUE 'FIRST',
SECOND TYPE CHAR10 VALUE 'SECOND',
THRIRD TYPE CHAR10 VALUE 'THIRD',
END OF S_STRUC.
DATA: ITAB LIKE S_STRUC OCCURS 0 WITH HEADER LINE.
DATA: V_INT TYPE INT4.
FIELD-SYMBOLS: <FS>, <FS1>.
DO 3 TIMES.
V_INT = SY-INDEX + 4.
ITAB-KEY1 = 'A'.
ITAB-KEY2 = 'B'.
ITAB-KEY3 = 'C'.
ITAB-KEY4 = 'D'.
ASSIGN COMPONENT V_INT OF STRUCTURE S_STRUC TO <FS>.
ASSIGN COMPONENT V_INT OF STRUCTURE ITAB TO <FS1>.
<FS1> = <FS>.
APPEND ITAB.
ENDDO.
LOOP AT ITAB.
WRITE: / ITAB.
ENDLOOP.
Thanks,
Naren
Message was edited by: Narendran Muthukumaran
‎2006 Oct 17 4:15 PM
Hi,
Try this..
DATA: ITAB LIKE STRUCTURE OCCURS 0 WITH HEADER LINE.
DATA: V_INT TYPE INT4.
FIELD-SYMBOLS: <FS>, <FS1>.
DO 90 TIMES.
V_INT = SY-INDEX + 4.
ITAB-KEY1 = 'A'.
ITAB-KEY2 = 'B'.
ITAB-KEY3 = 'C'.
ITAB-KEY4 = 'D'.
ASSIGN COMPONENT V_INT OF STRUCTURE S_STRUC TO <FS>.
ASSIGN COMPONENT V_INT OF STRUCTURE ITAB TO <FS1>.
<FS1> = <FS>.
APPEND ITAB.
ENDDO.
Thanks,
Naren
‎2006 Oct 17 5:28 PM
Naren,
Thanks , but I maybe not reading the code correctly.
If V_INT is incremented by 4
ASSIGN COMPONENT V_INT OF STRUCTURE S_STRUC TO <FS>.
this statement will correctly get me the first column in the first run but in the second run it will skip the next 3 columns .
Am i missing something.
thanks again for the quick response.
regards
amit
‎2006 Oct 17 5:39 PM
Hi,
If you see the incrementing part..I am incrementing sy-index + 4.
Which means..First time it will be 5..Second time it will be 6..
Thanks,
Naren
‎2006 Oct 17 5:42 PM
Hi,
I tried this 4 keys and additional three fields..It worked..
DATA: BEGIN OF S_STRUC,
KEY1,
KEY2,
KEY3,
KEY4,
FIRST TYPE CHAR10 VALUE 'FIRST',
SECOND TYPE CHAR10 VALUE 'SECOND',
THRIRD TYPE CHAR10 VALUE 'THIRD',
END OF S_STRUC.
DATA: ITAB LIKE S_STRUC OCCURS 0 WITH HEADER LINE.
DATA: V_INT TYPE INT4.
FIELD-SYMBOLS: <FS>, <FS1>.
DO 3 TIMES.
V_INT = SY-INDEX + 4.
ITAB-KEY1 = 'A'.
ITAB-KEY2 = 'B'.
ITAB-KEY3 = 'C'.
ITAB-KEY4 = 'D'.
ASSIGN COMPONENT V_INT OF STRUCTURE S_STRUC TO <FS>.
ASSIGN COMPONENT V_INT OF STRUCTURE ITAB TO <FS1>.
<FS1> = <FS>.
APPEND ITAB.
ENDDO.
LOOP AT ITAB.
WRITE: / ITAB.
ENDLOOP.
Thanks,
Naren
Message was edited by: Narendran Muthukumaran
‎2006 Oct 17 7:01 PM
Naren,
Thanks makes sense , i am awarding full points as it will take me sometime to work on this code and if i future doubts i will get back to this thread.
thanks
amit