‎2006 Nov 13 10:25 AM
Hellow I have a table person_tab and I declare my table with the same values . in person tab I have names of employee and number of employye and I wont to bring it into my table itab how can I do that
This is my table
TYPES: BEGIN OF 1_itab,
objid TYPE hrobjid,
begda TYPE begdatum,
endda TYPE enddatum,
sobid TYPE sobid,
lastname TYPE pad_nachn,
firstname TYPE pad_vorna,
priox TYPE priox,
END OF 1_itab.
DATA: itab TYPE TABLE OF 1_itab,
wa_itab LIKE LINE OF itab.
DATA: person_tab TYPE RHLDAPP OCCURS 0 WITH HEADER LINE.
DATA: wa_person_tab LIKE LINE OF person_tab .
And person tab is a STRUCTURE type RHLDAPP with values that I bring in in the function CALL FUNCTION 'RH_DIR_ORG_STRUC_GET'
EXPORTING
act_orgunit = obj_tab-objid
act_plvar = '01'
act_date = sy-datum
sort_flag = 'X'
add_flag_pdata = 'X'
TABLES
person_tab = person_tab
EXCEPTIONS
no_active_plvar = 1
OTHERS = 2.
IF sy-subrc <> 0.
<b>And I try like this but it didnt work I get the names in date very confused
LOOP AT person_tab INTO wa_itab.
MOVE-CORRESPONDING person_tab TO wa_itab.
APPEND wa_itab TO itab.
CLEAR wa_itab.
ENDLOOP.</b>
the problem is that i dont get the field in their place
Thankes for your suggstion
‎2006 Nov 13 10:29 AM
HI ,
You have to use wa_person_tab while moving data of person_tab.
LOOP AT person_tab INTO wa_person_tab.
MOVE-CORRESPONDING wa_person_tab TO wa_itab.
APPEND wa_itab TO itab.
CLEAR wa_itab.
ENDLOOP.
Regards,
Raghav
‎2006 Nov 13 10:29 AM
HI ,
You have to use wa_person_tab while moving data of person_tab.
LOOP AT person_tab INTO wa_person_tab.
MOVE-CORRESPONDING wa_person_tab TO wa_itab.
APPEND wa_itab TO itab.
CLEAR wa_itab.
ENDLOOP.
Regards,
Raghav
‎2006 Nov 13 10:32 AM
‎2006 Nov 13 10:32 AM
hi,
chnage ur code like this.
LOOP AT person_tab INTO <b>wa_person_tab</b>.
MOVE-CORRESPONDING <b>wa_person_tab</b> TO wa_itab.
APPEND wa_itab TO itab.
CLEAR wa_itab.
ENDLOOP.
rgds
Anver
‎2006 Nov 13 10:33 AM
Hi,
the problem is the field structure for person_tab & wa_tab or itab are of not same type abd order.
To per form move corresponding , first you have to make the certain fields as required same in both structures.
Try this,
LOOP AT person_tab INTO wa_person_tab.
MOVE-CORRESPONDING wa_person_tab TO wa_itab.
APPEND wa_itab TO itab.
CLEAR wa_itab.
ENDLOOP.
regards,
Amit
‎2006 Nov 13 10:37 AM
Hello Sh,
When you say move-corresponding fields from person_tab into wa_itab. The field names should be the same then it will work else you have to code in this way.
loop at person_tab.
wa_itab-lastname = person_tab-lastname.
wa_itab-firstname = person_tab-firstname.
...........
.........
..........
append wa_itab.
endloop.
‎2006 Nov 13 10:49 AM
Hi,
You can move all necessary fields from itab1 to itab2 in the following way :
DATA: lw_itab1 LIKE LINE OF itab1.
Loop at itab1 into lw_itab1.
move lw_itab1-field1 to itab2-field1.
move lw_itab1-field3 to itab2-field3.
move lw_itab1-field4 to itab2-field4.
....................
.....................
append itab2.
endloop.
Cheers.
‎2006 Nov 13 10:54 AM
Hi,
Declare the fields in itab in the same order as the table person_tab.
loop at person_tab into wa_person_tab.
wa_itab-objid = wa_person_itab-objid .
wa_itab-firstname = wa_person_firstname.
append itab from wa_itab.
endloop.
hope this helps u.
regards,
keerthi.