2008 Mar 18 6:24 PM
Hi,
i have 2 tables the first with pernr and comments and seconed
just with pernr (1 row for every pernr)and i wont to move the comments to lines in second table what is the best way to do it?
table 1
pernr comments
11 eeeee
22 jjjjj
22 ccccc
33 aaaaa
33 bbbbb
33 tttttttt
i wont
i have in this table just pernr and i wont to add the data
like that to line 1,2,3
table 2
pernr line 1 line 2 line3
11 eeeee
22 jjjjj ccccc
33 aaaaa bbbbb tttttttthow i can do that?
Regards
2008 Mar 18 6:29 PM
LOOP AT ITAB2.
READ TABLE ITAB1 WITH KEY ITAB1-PERNR = ITAB2-PERNR.
MOVE ITAB1-FIELD5 TO ITAB2-FIELD5.
ENDLOOPJust loop at one table. check for the record with the key and move the rest of the contents.
I hope it helps.
thanks
Hi,
i have 2 tables the first with pernr and comments and seconed
just with pernr (1 row for every pernr)and i wont to move the comments to lines in second table what is the best way to do it?
table 1
pernr comments
11 eeeee
22 jjjjj
22 ccccc
33 aaaaa
33 bbbbb
33 tttttttt
i wont
i have in this table just pernr and i wont to add the data
like that to line 1,2,3
table 2
pernr line 1 line 2 line3
11 eeeee
22 jjjjj ccccc
33 aaaaa bbbbb tttttttthow i can do that?
Regards
2008 Mar 18 6:29 PM
LOOP AT ITAB2.
READ TABLE ITAB1 WITH KEY ITAB1-PERNR = ITAB2-PERNR.
MOVE ITAB1-FIELD5 TO ITAB2-FIELD5.
ENDLOOPJust loop at one table. check for the record with the key and move the rest of the contents.
I hope it helps.
thanks
2008 Mar 18 6:40 PM
hi Alchemi
i thanks but its that simple because when u do read the table
its always read the first line and i need to read (if have) the second line for same employee and so on?
Regards
2008 Mar 18 6:56 PM
Try this way
field-symbols : <fs> type any.
refresh : itab2.
loop at itab1.
at new pernr.
move 1 to v_flg.
endat.
move itab1-pernr to itab2-pernr.
concatenate 'ITAB2-LINE' v_flg to v_field.
condense v_field no-gaps.
assign ( v_field ) to <fs>.
write itab1-comments to <fs>.
v_flg = v_flg + 1.
at end of pernr,
clear v_flg.
append itab2.
endat.
endloop.
, a®
2008 Mar 18 6:30 PM
hi check this ...
REPORT ZZ__GRAPH.
data: begin of itab occurs 0,
matnr like mara-matnr,
meins like mara-meins,
mtart like mara-mtart,
end of itab.
select matnr
meins
mtart
from mara
into table itab
up to 5 rows.
loop at itab.
write: itab-matnr.
endloop.
write:/ .
loop at itab.
write at (18) itab-meins.
endloop.
write:/ .
loop at itab.
write at (18) itab-mtart.
endloop.
<REMOVED BY MODERATOR>
regards,
venkat.
Edited by: Alvaro Tejada Galindo on Mar 18, 2008 3:10 PM
2008 Mar 18 6:50 PM
Crude, but it works.
DATA:
BEGIN OF rec1,
pernr(05),
cmt(10),
END OF rec1,
it_tab1 LIKE STANDARD TABLE OF rec1.
DATA:
BEGIN OF rec2,
pernr(05),
cmt1(10),
cmt2(10),
cmt3(10),
END OF rec2,
it_tab2 LIKE STANDARD TABLE OF rec2.
DATA:
cnt TYPE i.
START-OF-SELECTION.
CLEAR rec1.
rec1-pernr = '11'.
rec1-cmt = 'eeeee'.
APPEND rec1 TO it_tab1.
rec1-pernr = '22'.
rec1-cmt = 'jjjjj'.
APPEND rec1 TO it_tab1.
rec1-cmt = 'ccccc'.
APPEND rec1 TO it_tab1.
rec1-pernr = '33'.
rec1-cmt = 'aaaaa'.
APPEND rec1 TO it_tab1.
rec1-cmt = 'bbbbb'.
APPEND rec1 TO it_tab1.
rec1-cmt = 'tttttttt'.
APPEND rec1 TO it_tab1.
CLEAR rec2.
rec2-pernr = '11'.
APPEND rec2 TO it_tab2.
rec2-pernr = '22'.
APPEND rec2 TO it_tab2.
rec2-pernr = '33'.
APPEND rec2 TO it_tab2.
LOOP AT it_tab2 INTO rec2.
CLEAR cnt.
LOOP AT it_tab1 INTO rec1
WHERE pernr = rec2-pernr.
cnt = cnt + 1.
CASE cnt.
WHEN 1.
rec2-cmt1 = rec1-cmt.
WHEN 2.
rec2-cmt2 = rec1-cmt.
WHEN 3.
rec2-cmt3 = rec1-cmt.
ENDCASE.
ENDLOOP.
MODIFY it_tab2 FROM rec2.
ENDLOOP.
LOOP AT it_tab2 INTO rec2.
WRITE:/ rec2-pernr,
rec2-cmt1,
rec2-cmt2,
rec2-cmt3.
ENDLOOP.
2008 Mar 18 6:51 PM
Hi,
Please try this.
ITAB2[] = ITAB1[].
LOOP AT ITAB1.
LOOP AT ITAB2 WHERE PERNR = ITAB1-PERNR.
MOVE ITAB2-FIELD1 TO ITAB3-FIELD1.
MOVE ITAB2-FIELD2 TO ITAB3-FIELD2.
MOVE ITAB2-FIELD3 TO ITAB3-FIELD3.
APPEND ITAB3.
ENDLOOP.
ENDLOOP
Regards,
Ferry Lianto
2008 Mar 18 7:17 PM
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |