Appending two internal tables
hello friends,
I have two internal tables of different structure.
i have filled those two internal tables using join statements.
But one field is common in both the tables, when i try to append both tables into another new internal table.
i cant get the value for the 2nd tables field.
EX.
vbeln is common in vbuk, vbup, vbap, vbak, likp, lips.
but its sale order number in vbak, vbap.
delivery document in likp,lips.
vbup has both sales order and delivery in the vbeln field.
so, i made a join to between vbak, vbup and lips to see the goods movement status in vbup.
for that the vbeln should be delievery number.
and in other table, i have added vbup and vbak and vbep to get the delievery status.
for that the vbeln should be sale order no.
when i append both the tables into the third internal table that has the structure of both internal tables.
i could not get the vbeln of the second table(sale order no) in the third table.
help me guys.
rewards for helpful solutions.
hello,
types:
begin of str,
vbeln like vbak-vbeln,
vkorg like vbak-vkorg,
vtweg like vbak-vtweg,
end of str.
types:
begin of st1,
lfstk like vbuk-vbeln,
end of st1.
types:
begin of st2,
vbeln like vbak-vbeln,
vkorg like vbak-vkorg,
vtweg like vbak-vtweg,
lfstk like vbuk-lfstk,
end of st2.
selection-screen: s_order for vbak-vbeln,
s_div for vbak-vtweg.
data: it type table of st with header line,
it1 type table of st1 with header line,
it2 type table of st2 with header line.
select vbeln vkorg vtweg from vbak into table it
where vbeln in s_order and
vkorg in s_div.
select lfstk from vbuk into table it1 for all entries in it
where vbeln = it-vbeln.
it2[] = it[].
append it1-lfstk into it2[].
or
move-corresponding it1 to it2.
" when i execute this code with a grid or list display, i m not able to get the values or entries for the 2nd table it1.
the it2 has the lfstk cloumn blank in the final display.
help me for a remedy.
rewards for useful suggestion.
Similar Messages
-
Reg comparison of two internal tables
hi friends,
please help me solving this.
there are two internal tables t_zvs38 and t_value
1.t_value like seahlpres
2.t_zvs38 like zvs38.
values in t_value will be like this.
first line wil contain zmdtype(mandatory document) and second line will contain
zmdtypet (the description for zmdtype).
eg.
D001 -
-zmdtype
internal----
zmdtypet
D002
external
D003
renewal
values in t_zvs38.
for a particular sales.org the zmdtype is filled.
select vkorg zmdtype into corrsponding fields of table t_zvs38
where vkorg = p_vkorg.
Now i want to compare t_value and t_zvs38 with field zmdtype
and delete the contents of t_value which are not in t_zvs38.
i have written like this.
loop at t_value.
read table t_zvs38 with key zmdtype = t_value-string.
if sy-subrc ne 0.
delete t_value. "to delete zmdtype
sy-tabix = sy-tabix + 1.
delete t_value. " to delete zmdtypet
else.
sy-tabix = sy-tabix +2. "to go to next zmdtype.
endif.
endloop.
but it is deleting all the contents of t_value.
points are assured.CLEAR zvs32t.
SELECT zvs32tzmdtype zvs32tzmdtypet
INTO (zvs32t-zmdtype, zvs32t-zmdtypet)
FROM zvs32t
JOIN zvs32
ON zvs32tzmdtype = zvs32zmdtype
WHERE zvs32t~spras = sy-langu
AND zvs32~zfrenewal = space.
WRITE zvs32t-zmdtype TO t_value.
APPEND t_value.
WRITE zvs32t-zmdtypet TO t_value.
APPEND t_value.
ENDSELECT.
SELECT vkorg vkbur zmdtype FROM zvs38 INTO CORRESPONDING FIELDS OF TABLE t_zvs38
WHERE vkorg = p_vkorg
AND vkbur = p_vkbur.
LOOP AT t_value INTO wa_area1.
v_index = sy-tabix.
READ TABLE t_zvs38 INTO wa_area2 WITH KEY zmdtype = wa_area1-string
BINARY SEARCH.
IF sy-subrc NE 0.
IF l_flag IS INITIAL.
DELETE t_value INDEX v_index.
ELSE.
CLEAR l_flag.
ENDIF.
ELSE.
l_flag = 'X'.
ENDIF.
ENDLOOP.
Using this code ,i am unable to ge the correct output.Thank u all for ur help. -
Downloading two internal tables in same text file
I have one internal table as like below.
Data:begin of itab1 occurs 0,
rec(5),
end of itab1.
Itab1 is getting updated from input text file(Continuous text).
Here Itab1 contains one record with Indicator '01 and n number of records with indicator '02'.
This needs to be seperated in to two internal tables.
data:Begin of Itab_Head occurs 0,
Rec_ind(2) type C,
Name(3) type C,
end of itab_Head.
data:Begin of Itab_Item occurs 0,
Rec_ind(2) type C,
Id(3) type C,
Status(10,
end of itab_Item.
loop at itab1.
If itab1-Rec+0(2) = '01'.
Itab_Head-Rec_Ind = itab1-rec+0(2).
Itab_Head-Name = itab1-rec+2(3).
Append Itab_Head.
elseif itab1-rec+0(2) = '02'.
Itab_Item-Rec_Ind = itab1-rec+0(2).
Itab_Item-Id = itab1-rec+2(3).
Append Itab_Item.
endif.
endloop.
After moving to the internal tables I am doing some processing and updating the status of Itab_item.
After all these again I have to download the internal table as a text file.Now my question is.
I have values in 2 diff internal tables.How to download the two in same file.See this sample code.
data: itab1 type string occurs 0 with header line,
itab2 type string occurs 0 with header line.
itab1 = 'itab1_text'.
append itab1.
itab2 = 'itab2_text'.
append itab2.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD
exporting
FILENAME = 'C:\ftext.txt'
APPEND = 'X'
changing
DATA_TAB = itab1[].
CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD
exporting
FILENAME = 'C:\ftext.txt'
APPEND = 'X'
changing
DATA_TAB = itab2[].
Svetlin -
I have two separate internal tables. However , they have a common field matnr. In the report output, the two internal tables should be joined by this common field. Can this be done with an ALV . The common field Matnr should appear to the extreme left. Followed by itab1 and then itab2 . Its in a sense Matnr is the header , but it shows as rows. Each matnr has several item in both itab1 and itab2 , it is not necessary that total number of item data in itab1 and itab2 will be same .
You can see example program :
TYPE-POOLS: slis.
DATA: BEGIN OF itab OCCURS 0,
vbeln TYPE vbeln,
expand,
END OF itab.
DATA: BEGIN OF itab1 OCCURS 0,
vbeln TYPE vbeln,
posnr TYPE posnr,
matnr TYPE matnr,
netpr TYPE netpr,
END OF itab1.
DATA: t_fieldcatalog TYPE slis_t_fieldcat_alv.
DATA: s_fieldcatalog TYPE slis_fieldcat_alv.
s_fieldcatalog-col_pos = '1'.
s_fieldcatalog-fieldname = 'VBELN'.
s_fieldcatalog-tabname = 'ITAB'.
s_fieldcatalog-rollname = 'VBELN'.
s_fieldcatalog-outputlen = '12'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '1'.
s_fieldcatalog-fieldname = 'VBELN'.
s_fieldcatalog-tabname = 'ITAB1'.
s_fieldcatalog-rollname = 'VBELN'.
s_fieldcatalog-outputlen = '12'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '2'.
s_fieldcatalog-fieldname = 'POSNR'.
s_fieldcatalog-tabname = 'ITAB1'.
s_fieldcatalog-rollname = 'POSNR'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '3'.
s_fieldcatalog-fieldname = 'MATNR'.
s_fieldcatalog-tabname = 'ITAB1'.
s_fieldcatalog-rollname = 'MATNR'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '4'.
s_fieldcatalog-fieldname = 'NETPR'.
s_fieldcatalog-tabname = 'ITAB1'.
s_fieldcatalog-rollname = 'NETPR'.
s_fieldcatalog-do_sum = 'X'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
DATA: s_layout TYPE slis_layout_alv.
s_layout-subtotals_text = 'SUBTOTAL TEXT'.
s_layout-key_hotspot = 'X'.
s_layout-expand_fieldname = 'EXPAND'.
SELECT vbeln UP TO 100 ROWS
FROM
vbak
INTO TABLE itab.
IF NOT itab[] IS INITIAL.
SELECT vbeln posnr matnr netpr
FROM vbap
INTO TABLE itab1
FOR ALL ENTRIES IN itab
WHERE vbeln = itab-vbeln.
ENDIF.
DATA: v_repid TYPE syrepid.
v_repid = sy-repid.
DATA: s_keyinfo TYPE slis_keyinfo_alv.
s_keyinfo-header01 = 'VBELN'.
s_keyinfo-item01 = 'VBELN'.
CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
EXPORTING
i_callback_program = v_repid
is_layout = s_layout
it_fieldcat = t_fieldcatalog
i_tabname_header = 'ITAB'
i_tabname_item = 'ITAB1'
is_keyinfo = s_keyinfo
TABLES
t_outtab_header = itab
t_outtab_item = itab1
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Thanks
Seshu -
How to join two internal table rows in alternative manner into one internal table?
How to join two internal table rows in alternative manner into one internal table?
two internal tables are suppose itab1 & itab2 & its data
Header 1
Header 2
Header 3
a
b
c
d
e
f
g
h
i
Header 1
Header 2
Header 3
1
2
3
4
5
6
7
8
9
INTO itab3 data
Header 1
Header 2
Header 3
a
b
c
1
2
3
d
e
f
4
5
6
g
h
i
7
8
9Hi Soubhik,
I have added two additional columns for each internal table.
Table_Count - It represents the Internal Table Number(ITAB1 -> 1, ITAB2 -> 2)
Row_Count - It represents the Row Count Number, increase the row count value 1 by one..
ITAB1:
Header 1
Header 2
Header 3
Table_Count
Row_Count
a
b
c
1
1
d
e
f
1
2
g
h
i
1
3
ITAB2:
Header 1
Header 2
Header 3
Table_Count
Row_Count
1
2
3
2
1
4
5
6
2
2
7
8
9
2
3
Create the Final Internal table as same as the ITAB1/ITAB2 structure.
"Data Declarations
DATA: IT_FINAL LIKE TABLE OF ITAB1. "Final Internal Table
FIELD-SYMBOLS: <FS_TAB1> TYPE TY_TAB1, "TAB1
<FS_TAB2> TYPE TY_TAB2. "TAB2
"Assign the values for the additional two column for ITAB1
LOOP AT ITAB1 ASSIGNING <FS_TAB1>.
<FS_TAB1>-TABLE_COUNT = 1. "Table value same for all row
<FS_TAB1>-ROW_COUNT = SY-TABIX. "Index value
ENDLOOP.
"Assign the values for the additional two column for ITAB2
LOOP AT ITAB2 ASSIGNING <FS_TAB2>.
<FS_TAB2>-TABLE_COUNT = 2. "Table value same for all row
<FS_TAB2>-ROW_COUNT = SY-TABIX. "Index value
ENDLOOP.
"Copy the First Internal Table 'ITAB1' to Final Table
IT_FINAL[] = ITAB1[].
"Copy the Second Internal Table 'ITAB2' to Final Table
APPEND IT
LOOP AT ITAB2 INTO WA_TAB2.
APPEND WA_TAB2 TO IT_FINAL.
ENDLOOP.
"Sort the Internal Table based on TABLE_COUNT & ROW_COUNT
SORT IT_FINAL BY ROW_COUNT TABLE_COUNT.
After sorting, check the output for IT_FINAL Table, you can find the required output as shown above.
Regards
Rajkumar Narasimman -
Processing two internal tables
hi
i have two internal tables
itab1 with feilds partner, vbeln. cmgst ( SO status)
itab2 - vbeln, posnr(item no ), kwmeng(qunatity) , cmpre ( credit price )
now i need to get the sum of (cmpre * kwmeng) for each partner and SO status combination into another internal table itab3.
so itab3 will have partner, cmgst (so status ) , total amount
is it possible to achieve this with out using loop inside a loop.
thanksHi Sudhakar,
Check below code sample. Change it according to ur need.
DATA: BEGIN OF itab1 OCCURS 0,
partner TYPE string,
vbeln TYPE vbeln,
cmgst TYPE cmgst,
END OF itab1,
wa1 LIKE itab1.
DATA: BEGIN OF itab2 OCCURS 0,
vbeln TYPE vbeln,
posnr TYPE posnr,
kwmeng TYPE kwmeng,
cmpre TYPE cmpre,
END OF itab2,
wa2 LIKE itab2.
DATA: BEGIN OF itab3 OCCURS 0,
partner TYPE string,
cmgst TYPE cmgst,
amt TYPE p DECIMALS 2,
END OF itab3,
wa3 LIKE itab3.
wa1-partner = 'Test1'. wa1-vbeln = '0000000001'. wa1-cmgst = 'X'.
APPEND wa1 TO itab1. CLEAR wa1.
wa1-partner = 'Test2'. wa1-vbeln = '0000000002'. wa1-cmgst = 'X'.
APPEND wa1 TO itab1. CLEAR wa1.
wa2-vbeln = '0000000001'. wa2-posnr = '000001'. wa2-kwmeng = 10. wa2-cmpre = 100.
APPEND wa2 TO itab2. CLEAR wa2.
wa2-vbeln = '0000000002'. wa2-posnr = '000002'. wa2-kwmeng = 20. wa2-cmpre = 200.
APPEND wa2 TO itab2. CLEAR wa2.
LOOP AT itab1 INTO wa1.
READ TABLE itab2 INTO wa2 WITH KEY vbeln = wa1-vbeln.
IF sy-subrc = 0.
wa3-partner = wa1-partner.
wa3-cmgst = wa1-cmgst.
wa3-amt = wa2-kwmeng * wa2-cmpre.
APPEND wa3 TO itab3.
CLEAR wa3.
ENDIF.
ENDLOOP.
Thanks, -
Hi,
I have two internal tables it_tab1 and it_tab2. The fields are,
it_tab1 it_tab2
F1 F1
F2 F2
F3 F4
F6 F5
I want to <b>merge</b>(coloumn wise) these two internal tables into a new internal table it_tab3 where it_tab3 has fields,
F1, F2, F3, F4, F5, F6.(All the fields)
Here, in it_tab1 and in it_tab2 the fields <b>F1 and F2 are the key fields</b>.The number of records in the two internal tables are different.
Can anybody help me. thanx for spending ur time.hi,
try this
hi,
itab1 - first
itab2 - second
itab3 - both
data l_count type i.
l_count = 1.
loop at itab1.
read table itab2 with key f1 = itab1-f1 f2 = itab1-f2.
itab3 = itab1
if sy-subrc is initial
itab3-field6 = itab2-field3.
itab3-field7 = itab2-field4.
append itab3.
endif.
endloop.
loop at itab2.
itab3 = itab2
read table itab1 with key f1 = itab2-f1 f2 = itab2-f2.
if sy-subrc is initial
itab3-field6 = itab1-field3.
itab3-field7 = itab1-field4.
append itab3.
endif.
endloop.
sort itab3 by f1 f2.
delete adjacent duplicates by comparing f1 f2.
hope this will solve your problem
cheers,
sasi
Cheers,
Sasi -
Two internal tables are neither compatible nor convertible.
Hi,
I am having an internal table which is of type table of my own structure.I need to copy the table(containing my structure) to a table of ABAP TYPE TABLE.It is
showing the dump "Two internal tables are neither compatible nor convertible. "
I have triede with MOVE statement,APPEND stmt and even using "=".Can anyone help me on this?
Regards,
Rohini.MHi,
I have given my code below.
DATA: ls_header TYPE bbp_pds_header,
lt_faud TYPE TABLE OF /sappssrm/faud,
ls_syn_swt TYPE /sappssrm/s_synops_audit_data,
lt_syn_audit TYPE STANDARD TABLE OF /sappssrm/s_synops_audit_data,
ls_faud TYPE /sappssrm/faud.
IF iv_flt_bus_obj_type = 'BUS2200'
AND iv_flt_table_type = 'THGPF'.
CALL FUNCTION 'BBP_PROCDOC_GETDETAIL'
EXPORTING
i_guid = iv_parent
IMPORTING
e_header = ls_header.
SELECT * FROM /sappssrm/faud INTO TABLE lt_faud WHERE businessobject = 'BUS2200' AND sapdocnum = ls_header-object_id.
LOOP AT lt_faud INTO ls_faud.
MOVE-CORRESPONDING ls_faud TO ls_syn_swt.
APPEND ls_syn_swt TO lt_syn_audit.
ENDLOOP.
****Here I need to assign my lt_syn_audit table to my changing parameter ct_extension_table which is of generic type TABLE"***************************
endif.
I am using a BAdI "/SAPSRM/BDI_PDO_TE_OUTBOUND"
Thanks and Regards,
Rohini.M -
Two internal tables data into one
Hello Gurus,
I have data in two internal tables. One table IT_A contains the fields -
MATNR - SALES ORG - DCHANNEL - STATUS - DESCRIPTION
The other table IT_B contains the fields -
CUSTOMER - SALES ORG.
I need to display the result of all the fields when the sales org of both the tables are equal. i.e IT_A-VKORG = IT_B-VTORG.
MATNR - SALES ORG - DCHANNEL - STATUS - DESCRIPTION.
Please help me out with the code to be written.
Regards,
BaluTABLES : MVKE, CAUFVD, TVMST.
TYPES : BEGIN OF T_MVKE,
MATNR TYPE MVKE-MATNR,
VKORG TYPE MVKE-VKORG,
VTWEG TYPE MVKE-VTWEG,
VMSTA TYPE MVKE-VMSTA,
VMSTB TYPE TVMST-VMSTB,
END OF T_MVKE.
DATA : LT_MVKE TYPE STANDARD TABLE OF T_MVKE WITH HEADER LINE,
LS_MVKE TYPE T_MVKE.
DATA : LT1_MVKE TYPE STANDARD TABLE OF T_MVKE WITH HEADER LINE,
LS1_MVKE TYPE T_MVKE.
DATA : LT2_MVKE TYPE STANDARD TABLE OF T_MVKE WITH HEADER LINE,
LS2_MVKE TYPE T_MVKE.
TYPES : BEGIN OF T_KNVP,
KUNNR TYPE KNVP-KUNNR,
VKORG TYPE KNVP-VKORG,
END OF T_KNVP.
DATA : LT_KNVP TYPE STANDARD TABLE OF T_KNVP WITH HEADER LINE,
LS_KNVP TYPE T_KNVP.
SELECT-OPTIONS S_MATNR FOR MVKE-MATNR.
PARAMETER : P_KUNNR TYPE KNVP-KUNNR .
START-OF-SELECTION.
SELECT MATNR VKORG VTWEG VMSTA FROM MVKE INTO TABLE LT_MVKE WHERE MATNR IN S_MATNR .
IF SY-SUBRC = 0.
APPEND LT_MVKE.
ELSE.
EXIT.
ENDIF.
SELECT DISTINCT KUNNR VKORG FROM KNVP INTO TABLE LT_KNVP WHERE KUNNR = P_KUNNR.
IF SY-SUBRC = 0.
APPEND LT_KNVP.
ELSE.
EXIT.
ENDIF.
LOOP AT LT_MVKE.
LT1_MVKE-MATNR = LT_MVKE-MATNR.
LT1_MVKE-VKORG = LT_MVKE-VKORG.
LT1_MVKE-VTWEG = LT_MVKE-VTWEG.
LT1_MVKE-VMSTA = LT_MVKE-VMSTA.
SELECT SINGLE VMSTB FROM TVMST INTO LT1_MVKE-VMSTB WHERE VMSTA = LT_MVKE-VMSTA AND SPRAS = SYST-LANGU.
APPEND LT1_MVKE.
CLEAR LT1_MVKE.
ENDLOOP.
LOOP AT LT1_MVKE.
IF NOT LT_KNVP[] is INITIAL.
READ TABLE LT_KNVP WITH KEY VKORG = LT1_MVKE-VKORG BINARY SEARCH TRANSPORTING NO FIELDS.
IF SY-SUBRC = 0.
APPEND LT1_MVKE TO LT2_MVKE.
ELSE.
APPEND LT1_MVKE TO LT2_MVKE.
MESSAGE S003.
ENDIF.
CLEAR LT1_MVKE.
ELSE. "IF LT_KNVP[] IS INITIAL.
APPEND LT1_MVKE TO LT2_MVKE.
ENDIF.
ENDLOOP.
WRITE: /1 'MATERIAL NUMBER', 20 'SALES ORG', 35 'DISTRIBUTION CHANNEL', 65 'MATERIAL STATUS', 85 'STATUS DESCRIPTION'.
LOOP AT LT2_MVKE.
FORMAT HOTSPOT ON.
WRITE: /1 LT2_MVKE-MATNR, 20 LT2_MVKE-VKORG, 35 LT2_MVKE-VTWEG, 65 LT2_MVKE-VMSTA, 85 LT2_MVKE-VMSTB.
HIDE: LT2_MVKE-MATNR, LT2_MVKE-VKORG, LT2_MVKE-VTWEG, LT2_MVKE-VMSTA, LT2_MVKE-VMSTB.
CLEAR LT2_MVKE.
FORMAT HOTSPOT OFF.
ENDLOOP.
AT LINE-SELECTION.
IF LT2_MVKE-VMSTA = ' '.
MESSAGE E002.
ELSE.
SET PARAMETER ID 'MAT' FIELD LT2_MVKE-MATNR.
CALL TRANSACTION 'CO09'.
DATA WERKS(4) TYPE C VALUE '1200'.
SET PARAMETER ID 'WRK' FIELD WERKS.
DATA RULE(2) TYPE C VALUE 'ZB'.
SET PARAMETER ID 'PRR' FIELD RULE.
SET PARAMETER ID 'X' FIELD CAUFVD-PRMBD.
ENDIF.
Hello gurus,
The above code is working fine when I give both Material and customer in the select options. But it is not doing anything when I enter only the material.
Please help.
Regards,
Balu -
Two internal tables with different structures
Hi Experts,
I Have two internal tables.
Table 1 structure:
Name
Age
Table 2 structure :
Name
age
branch
Now the table 1 has some 5 data's and table 2 is empty.
First i want to move that 5 data's from table 1 to table 2.
Then the branch field is same for all records. its stored in a separate field called 'Branch'.
finallay i need to move that branch to internal table 2 for all records.
So the Table 2 should has five records and each record should have the branch.Its like,
Name Age Branch
name1 10 ECE
name2 10 ECE
I didnt use with header line for both tables. In function module i declared as table parameter.
Please give me a logic.
Helps will be appreciated.Since the structure of yur both internal table is different so you can't use ITAB1[] = ITAB2[] statements.
In this case you have to loop on first table then move data into second table and appned data into second table.
Declare work area for both table with like line of statement as follows
data: wa_itab1 like line of itab1,
wa_itab2 like line of itab2.
Loop at ita1 into wa_itab1.
wa_itab2-name = wa_itab1-name.
wa_itab2-age = wa_itab1-age.
wa_itab2-branch = 'ECE'.
append wa_itab to itab2.
clear wa_itab1, wa_itab2.
endloop.
Hope this will solve your problem. -
Two internal tables - calculation
Hi all,
i have two internal tables:
1. structure:
line: workarea e.g. 1 2 3
2 3 6
2. structure:
3000
6000
2000
Now should be build a sum.
Look at structure 1. For the first sum we need entry 1, 2 and 3 from structure 2. (3000 + 6000 + 2000 = 11000)
The next sum is calculated by the entry 2, 3 and 6 .......
Any ideas how to do this?
regardsHi,
Check the below code.
data: begin of itab occurs 0,
num1 type i,
num2 type i,
num3 type i,
end of itab.
data: begin of itab1 occurs 0,
num1 type i,
num2 type i,
num3 type i,
end of itab1.
data: v_tabix type i,
v_first_sum type i,
v_second_sum type i.
itab-num1 = 1.
itab-num2 = 2.
itab-num3 = 3.
append itab.
itab-num1 = 2.
itab-num2 = 3.
itab-num3 = 6.
append itab.
itab1-num1 = 3000.
itab1-num2 = 6000.
itab1-num3 = 2000.
append itab1.
itab1-num1 = 5000.
itab1-num2 = 4000.
itab1-num3 = 1000.
append itab1.
loop at itab.
clear: v_first_sum, v_second_sum.
v_tabix = sy-tabix.
v_first_sum = itab-num1 + itab-num2 + itab-num3.
write:/ 'Sum of record ', v_tabix, '= ', v_first_sum.
read table itab1 index v_tabix.
if sy-subrc = 0.
v_second_sum = itab1-num1 + itab1-num2 + itab1-num3.
write:/ 'Sum of record ', v_tabix, '= ', v_second_sum.
endif.
endloop.
Edited by: Velangini Showry Maria Kumar Bandanadham on Apr 30, 2008 8:56 AM -
Joining of two internal tables...... urgent.
Dear all experts,
I am going to join two internal tables, one table contains some fields from mara
and another table contains some fields from makt.
i have to join these tables without using for all entries.
below is program mentioned... I am not getting exactly how to put the logic, to get fields into table itab_3.
<b>*------- defining internal tables.</b>
DATA: BEGIN OF <b>itab_1</b> OCCURS 0,
matnr TYPE mara-matnr,
END OF itab_1.
DATA: BEGIN OF <b>itab_2</b> OCCURS 0,
matnr TYPE makt-matnr,
maktx TYPE makt-maktx,
spras TYPE makt-spras,
END OF itab_2.
DATA: BEGIN OF <b>itab_3</b> OCCURS 0,
matnr TYPE mara-matnr,
spras TYPE makt-spras,
END OF itab_3.
<b>*---taking data to first internal table.-</b>
SELECT matnr
FROM mara
INTO TABLE itab_1
WHERE ernam = 'RUDISILL'.
<b>*--taking data to second internal table.--</b>
SELECT matnr maktx spras
FROM makt
INTO TABLE itab_2.
sort itab_1 by matnr.
sort itab_2 by matnr.
can anybody please tell, how to take fields of itab_2 to itab_3, where all matnr in itab_2 should be equal to all matnr in itab_1.
points will be surely assigned to your help.
waiting
Warm regards
Vinay.hi,
kindly chk this sample.
check this.
data : begin of itab1 occurs 0. "itab with work area.
key_field1 like ztable1-key_field1,
field1 like ztable1-field1,
field2 like ztable1-field2,
endof itab1.
data : begin of itab2 occurs 0. "itab with work area.
key_field2 like ztable2-key_field2,
field3 like ztable2-field3,
field4 like ztable2-field4,
endof itab2.
data : begin of itab_final occurs 0.
key_field1 like ztable1-key_field1,
field1 like ztable1-field1,
field2 like ztable1-field2,
field3 like ztable2-field3,
field4 like ztable2-field4,
endof itab_final.
put the date final(merged) internal table
1. loop at itab1.
read table itab2 with key keyfield2 = itab1-keyfield1.
if sy-surc = 0.
itab_final-key_field1 = itab1-keyfield1
itab_final-field1 = itab1-field1.
itab_final-field2 = itab1-keyfield2.
itab_final-field3 = itab2-field2.
itab_final-field4 = itab2-keyfield2.
append itab_final.
clear itab_final.
endif.
endloop.
or
LOOP AT ITAB1.
MOVE-CORRESPONDING TO ITAB1 to ITAB_FINAL.
READ TABLE ITAB2 WITH KEY FILED1 = ITAB1-FIELD1.
if sy-subrc = 0.
MOVE-CORRESPONDING TO ITAB2 to ITAB_FINAL.
endif,
READ TABLE ITAB3 WITH KEY FILED1 = ITAB1-FIELD1.
if sy-subrc = 0.
MOVE-CORRESPONDING TO ITAB2 to ITAB_FINAL.
endif,
append itab_final.
clear itab_final.
endloop
Regards,
Anversha -
Joining Two Internal Tables - ( Urgent )
Could anybody please give me the whole code for joining two internal tables
and putting the data in a third internal table. Please, very urgent.
Regards,
SAURAVHi,
Refer this code
*& Form SUB_READ_VBRK
text
FORM sub_read_vbrk.
SELECT vbeln
rplnr
bukrs
FROM vbrk
INTO TABLE it_vbrk
WHERE vbeln IN s_vbeln
AND rplnr NE ' '.
IF sy-subrc EQ 0.
SORT it_vbrk BY rplnr.
ENDIF.
ENDFORM. " SUB_READ_VBRK
*& Form SUB_READ_FPLTC
text
FORM sub_read_fpltc.
IF NOT it_vbrk[] IS INITIAL.
SELECT fplnr
fpltr
ccnum
FROM fpltc
INTO TABLE it_fpltc
FOR ALL ENTRIES IN it_vbrk
WHERE fplnr EQ it_vbrk-rplnr
AND ccins EQ 'GIFC'.
IF sy-subrc EQ 0.
SORT it_fpltc BY fplnr.
ENDIF.
ENDIF.
ENDFORM. " SUB_READ_FPLTC
*& Form SUB_COLLECT_DATA
text
FORM sub_collect_data.
*--Local variables
DATA : lv_count(3) TYPE c.
IF NOT it_fpltc[] IS INITIAL.
LOOP AT it_fpltc INTO wa_fpltc.
lv_count = wa_fpltc-fpltr+3(3).
wa_final-ccnum = wa_fpltc-ccnum.
wa_final-rfzei = lv_count.
CLEAR : wa_vbrk.
READ TABLE it_vbrk INTO wa_vbrk WITH KEY rplnr = wa_fpltc-fplnr
BINARY SEARCH.
IF sy-subrc EQ 0.
wa_final-vbeln = wa_vbrk-vbeln.
wa_final-bukrs = wa_vbrk-bukrs.
ENDIF.
APPEND wa_final TO it_final.
CLEAR : wa_vbrk,
wa_fpltc,
lv_count.
ENDLOOP.
ENDIF.
ENDFORM. " SUB_COLLECT_DATA
Regards,
prashant -
Combining Two Internal Tables??
How do you combine two internal tables(not by append statement)...if any one knws please let me know..thanks in advance..
Sort itab_vbap by vbeln posnr.
sort itab_vbkd by vbeln posnr.
Loop at itab_vbap into wa_vbap.
read table itab_vbkd into wa_vbkd with key vbeln = wa_vbap-vbeln posnr = wa_vbap-posnr binary search.
if sy-subrc = 0.
move corresponding wa_vbap to wa_final.
move corresponding wa_vbkd to wa_final.
append wa_final to itab_final.
endif.
endloop.
For move corresponding statement the name of the fields should match in both the work areas.
I hope it helps. -
Data Transfer between two internal tables
Hi SDN,
If I have two internal tables itab_a and Itab_b and I want to copy a subset of itab_a to itab_b using a conditional statement, is it possible and how?
Second, what if I want to append the smaller internal table itab_b to itab_a, how would you do that.
My task is to take some of the rows from a into b, change one field and append back to a. So if a had 100 rows, now it would have 110.
Please help.
Thanks.
Saf.If I have two internal tables itab_a and Itab_b and I want to copy a subset of itab_a to itab_b using a conditional statement, is it possible and how?
LOOP AT ITAB_A.
IF ITAB_A-SOME_FIELD = SOME_VALUE.
MOVE-CORRESPONDING ITAB_A TO ITAB_B.
APPEND ITAB_B.
ENDIF.
ENDLOOP.
Maybe you are looking for
-
Adobe cs5 production premium student and teacher edition, installation without cd
Hi, i bought adobe cs5 production premium student and teacher edition like a year ago. Or maybe more. anyways, im doing an erasmus semester so i bought myself a Netbook. I want to install Adobe photoshop in it,. but the problem is, it has no CD drive
-
Invalid Export Options RAS SDKs
Hi All, As given in post Re: XML Export - Cannot select format CR2008 SP2 We are using RAS sdks and given sample code but still we are gettting same error i.e. Invalid Export Options. Is this also scheduled to be fixed in SP3. Thanks, Stanly
-
I'm running Lion 10.7.4 on my MacBook. Can I upload Mountain Lion? Thanks.
-
Hi! I am looking into developing an app for the App Store and my question is regarding Apple's 30% in app purchase fee. If my application is free to download, but requires my user to purchase a monthly subscription, will Apple collect a 30% fee ever
-
Error During text determination
Dear Experts I am facing one problem in Text determination.Error is "The SD_WORD_PROCESSING function module is for creating the "Maintain Text" dialog box. You have called up the function module with the wrong values so it is not possible to edit tex