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.
thanks
Hi 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,
Similar Messages
-
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 -
Need to Process Large Internal Tables Efficiently
I have two internal tables, T_EKKO(for PO Header data) and T_EKPO(for PO Item data). These tables carry data for 10 PO's with at least 1 line item in each one.
The requirement is to write the following fields on the result screen:
Line 1: PO Number.-
Line 2:PO Item, Article Number.
What is the most efficient way to do this?Hi,
You can use parallel processing techinque..
Ex.
SORT T_EKPO BY EBELN.
DATA: V_TABIX TYPE SYTABIX.
LOOP AT T_EKKO.
WRITE: / 'PO Number - ', T_EKKO-EBELN.
READ TABLE T_EKPO TRANSPORTING NO FIELDS
WITH KEY EBELN = T_EKKO-EBELN
BINARY SEARCH.
IF SY-SUBRC = 0.
Store the row number.
V_TABIX = SY-TABIX.
LOOP AT T_EKPO FROM V_TABIX.
Exit condition.
IF T_EKPO-EBELN <> T_EKKO-EBELN.
EXIT.
ENDIF.
WRITE: / 'PO item', T_EKPO-EBELP.
ENDLOOP.
ENDIF.
ENDLOOP.
Thanks,
Naren -
WD abap Error - Two internal tables are neither compatible nor convertible
Hi,
I am trying to use a standard Function Module - HR_FBN_GENERATE_SEND_EMAIL in a Webdynpro ABAP Application to send email to a standard mailbox. I am getting this error. Did anyone come across this error?
The following error text was processed in the development system: Two internal tables are neither compatible nor convertible.
The error occurred on the application server Development and in the work process 2.
The termination type was: RABAX_STATE
The ABAP call stack was:
Function: HR_FBN_GENERATE_SEND_EMAIL of program SAPLHRFBN00GENERAL
Method: EXECUTE_HR_FBN_GENERATE_SEND_E of program /1BCWDY/42NDMCF1FS45LZXWDXDY==CP
Method: IF_COMPONENTCONTROLLER~EXECUTE_HR_FBN_GENERATE_SEND_E of program /1BCWDY/42NDMCF1FS45LZXWDXDY==CP
Method: ONACTIONLOADEMAILFORM of program /1BCWDY/42NDMCF1FS45LZXWDXDY==CP
Method: IF_WDR_VIEW~WD_INVOKE_EVENT_HANDLER of program /1BCWDY/42NDMCF1FS45LZXWDXDY==CP
Method: INVOKE_EVENTHANDLER of program CL_WDR_VIEW========CP
Method: IF_WDR_ACTION~FIRE of program CL_WDR_ACTION=================CP
Method: DO_HANDLE_ACTION_EVENT of program CL_WDR_WINDOW_PHASE_MODEL=====CP
Method: PROCESS_REQUEST of program CL_WDR_WINDOW_PHASE_MODEL=====CP
Method: PROCESS_REQUEST of program CL_WDR_WINDOW=================CP
Any help will be appreciated.
Thanks
RM
Edited by: R M on Sep 14, 2008 2:54 PMOpen an OSS ticket, this is probably a programming error which requires a note to fix it.
CHeers,
RIch Heilman -
How to get records into two internal tables from 1 internal table?
VERME LGPLA
252.000 EA 300 0149A 410 0149
276.000 EA 300 0149A 410 0107
516.000 EA 300 0149A 400 3013
528.000 EA 300 0149A 400 3013
528.000 EA 300 0149A 400 3013
528.000 EA 300 0149A 400 3013
528.000 EA 300 0149A 400 3013
528.000 EA 300 0149A 400 3013
528.000 EA 300 0149A 400 3013
I have above records in my one internal table ITAB.
I want to divide these records in to two internal tables ITAB1 and ITAB2. and this is based on LGPLA and VERME.
If there is same LGPLA (last column) and different VERME (1st column) available, then it should append ITAB1
Otherwise it should append ITAB2.
ITAB1 should contain ,
516.000 EA 300 0149A 400 3013
ITAB2 should contain ,
252.000 EA 300 0149A 410 0149
276.000 EA 300 0149A 410 0107
528.000 EA 300 0149A 400 3013
528.000 EA 300 0149A 400 3013
528.000 EA 300 0149A 400 3013
528.000 EA 300 0149A 400 3013
528.000 EA 300 0149A 400 3013
528.000 EA 300 0149A 400 3013
I have tried with this code
Loop at itab .
IF lv_prev_lgpla = wa-lgpla and lv_prev_verme <> wa-verme.
APPEND wa TO itab1.
else.
APPEND wa TO itab2.
endif.
lv_prev_lgpla = wa-vlpla.
lv_prev_verme = wa-anfme.
Endloop.
But it contains,
516.000 EA 300 0149A 400 3013
in table ITAB2 which I dont want.
Points rewarded soon.
Regards,
RonnDear Ronny,
i am gining the solution below.But would request you to change your ITAB STRUCTURE LIKE THIS BEFORE USING THE CODE
VERME LGPLA
252.000 EA 300 0149A 0149 410
276.000 EA 300 0149A 0107 410
516.000 EA 300 0149A 3013 400
528.000 EA 300 0149A 3013 400
528.000 EA 300 0149A 3013 400
528.000 EA 300 0149A 3013 400
528.000 EA 300 0149A 3013 400
528.000 EA 300 0149A 3013 400
528.000 EA 300 0149A 3013 400
then do as follows.
SORT ITAB BY LGPLA VERME.
LOOP AT ITAB INTO WITAB.
W_INDEX = SY-TABIX.
here take all the abOve fields in temp fieds.
LW_VERME = WITAB-VERME..AND SO ON.
AT END OF LGPLA.
MOVE: all LW fields to work area of ITAB1
APPEND work area of ITAB1 TO ITAB1.
DELETE ITAB INDEX W_INDEX
ENDAT.
ENDLOOP.
Basically what u r doing here is thet u r using processing event.
So whenerv VERME changes this event will be triggered.
Just try this out...something like this only will be he logic.
Please let me know further -
Error "Error in ABAP statement when processing an internal table. table."
Hello,
I am facing the error when tried for GR from SRM portal for my shopping cart and for others created shopping cart. The error is
"Error in ABAP statement when processing an internal table. table."
I have the central receipient role. Couold any body assist me?
Thanks,
PijushHi Harish,
Execute the query in RSRT and check whether you have any short dump is in ST22. This would give a clear idea at what might have gone wrong.
Another thing is to check whether the code for the variable is fine in the user exit.
Hope this helps.
Bye
Dinesh -
Using for all entries of two internal tables in where clause of the select
Hi experts,
My requirement is, need to select Marc-minbe and wrpl-sobst, for all the entries of the two internal tables it_mara , and it_t001w.
here is the select queries i have used,
select matnr normt from mara into it_mara for all entries in it_data where normt = it_data-normt.
select konnr werks from t001w into it_t001w for all entries in it_data where konnr = it_data-konnr.
now i need to select minbe of marc table and sobse of wrpl table for all the entries of above internal tables, it_mara and it_t001w, using both matnr of it_mara and werks of it_t001w in where condition.
Pls advise how i can do it.
Thanks.
Moderator message: very basic, please work on this yourself first, these forums are not a substitute for ABAP training.
Edited by: Thomas Zloch on Dec 6, 2010 9:38 AMHi
call SE16 with table TFTIT in order to get a full list (it will be long...)
A list of FMs with parameters can be found in table FUNCT.
Finally go to sm37rsdf4
that will give you all the function modules with description
Here is the list:
http://www.erpgenie.com/abap/functions.htm
hope this helps...
Regards
CSM Reddy -
Comparing each value of two internal tables
HI everybody,
i have two internal tables itab1 and itab2 same structure
both r having four fields each and field with values
now i need to compare the two internal tables
and if every value of itab1 matches itab2
then i have to write one select quirie for the following given description
compare past and current shipping point
compare internal_table2 and internal_table3
if entry in internal_table2 and internal table3 match
variable_tknum = internal_table2-tknum
endif.
for each entry that matches:
select vlabdata into zi_vlabdata from vlbl where vbeln = variable_tknum and vlbl-vlabtyp = 'ZIBOOKNO'.
plz give me solution for this
thanks
hridhayanjili.sort : ITAB1 by f1,f2,f3,f4,
ITAB2 by f1,f2,f3,f4.
LOOP AT ITAB1.
READ TABLE ITAB2 WITH KEY F1 = ITAB1-F1
F2 = ITAB1-F2
F3 = ITAB1-F3
F4 = ITAB1-F4 BINARY SEARCH.
IF SY-SUBRC = 0.
*--all the fields of ITAB1 and ITAB2 are matching .
*--write your logic here
ELSE.
*--ITAB1 and ITAB2 records are not matching.
ENDIF.
ENDLOOP.
Regards
Srikanth
Message was edited by: Srikanth Kidambi -
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. -
Two internal tables in to one internal table
Hi ,
I have two internal tables ITAB1 and ITAB2, i would like to put fields from two internal tables in to one internal table(ITAB3) with out using inner joint. any one of you can give the sample code for this
Thanks
Raja.Hi,
Kamesh wrote :
Read itab2 into wa_itab2 with key f2 = itab1-f1 <USe your where conditions here>.
Read statement does not have WHERE conditions.
Please be careful while posting. Your thread will be reffered by many people. Please dont mislead.
Regards,
Swapna. -
Function module for comparing contents of two internal tables
Hi All,
Is there any function module to compare contents of two internal tables of same structure?
If yes please let me know.
Thanks in advance.
AmolHi
call SE16 with table TFTIT in order to get a full list (it will be long...)
A list of FMs with parameters can be found in table FUNCT.
Finally go to sm37rsdf4
that will give you all the function modules with description
Here is the list:
http://www.erpgenie.com/abap/functions.htm
hope this helps...
Regards
CSM Reddy -
Get the Common from Two Internal Tables with same structure
Hi ,
I need to get the Common data from Two Internal Tables with same structure with using the looping method.
For e.g.
I have two internal table say ITAB1 and ITAB2.
ITAB1 has values A,B,C,D,E,F
ITAB2 has values A,H,B,Y,O
Output at runtime should be : A,BHi mohit,
1. If u want to compare all fields,
for matching purpose,
then we can do like this.
2.
report abc.
data : a like t001 occurs 0 with header line.
data : b like t001 occurs 0 with header line.
loop at a.
LOOP AT B.
IF A = B.
WRITE :/ 'SAME'.
ENDIF.
endloop.
ENDLOOP.
regards,
amit m. -
How to check two internal table fields
Hi all,
I need to check two internal table fields are equal or not means which statement i can use.
Not internal table ,table contents i need to check i.e
it1-pernr = it2-pernr.
like this
if i put loop it'll check one table field for one loop.
if i put two loop means some fields reflecting 2 in it1 then it'll pring 4 times like that.i want to print whatever in internal table only .
pernr(0001) two times there in it1 means
it1-pernr = it2-pernr then
it's printing
0001
0001
0001
0001
like this but actually in it1 only two records.
Anybody know solution.tell me.
Thanks
Regards,
NandhaHi,
code for your view
data : begin of it1 occurs 0,
z_pernr like pa9012-pernr,
z_fac_c like pa9012-zz_fac_c,
end of it1.
data : it2 like Zsc1 occurs 0 with header line,
It1 data
pernr FAC C
0001 5555
0001 5555
0002 4444
0003 3333
0006 8888
It2 data
pernr FAC C
0001 5555
0001 5555
0005 6666
0003 3333
output(My code)
loop at it2 .
loop at it1 where pernr = it2-pernr.
write:/01 it1-1pernr,
10 it1-z_fac_c.
endloop.
endloop.
out put i need.
0001 5555
0001 5555
0002 4444
0003 3333
Thanks,
Nandha -
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 -
Can we get the data from two internal tables in ALV.
hi friends i would like to display the data using two internal tables using alv grid.please guide me.
Hi,
ALV would be having a specific layout say :
MATNR
MAKTX
QTY
Now, if you have two internal tables, then do they have a different structure. If they have different structures, then what kind of ALV layout you expect. The ALV output should be as per the structure of 1st or 2nd internal table.
If both internal table have same layout, then populate the data from 2nd internal table into 1st internal table and pass the 1st internal table ( it will have data of both internal tables) to ALV.
Best regards,
Prashant
Maybe you are looking for
-
I would like to see the stock level of the material through T code
hi I would like to see the material stock by plant storage location the required details are Unrestricted avilable stock , Order stock , delivery stock , blocked stock , quality stock what is the T code to view all those things Dinesh
-
Clicking noise from a laptop HDD
I'll give you a link for a dead topic in which a user explaines a problem similar to mine: https://bbs.archlinux.org/viewtopic.php?id=39450 I'll also write some similar stuff here. It's been almost two years or so since I get these now-and-then click
-
I have just Rented a movie from iTunes in HD to my iPad, its has downloaded almost completely but says 'processing' under the load bar for the past 6 hours, is there anything I can do to refresh it? ....I have lots of available space on my iPad, I am
-
Adobe products (Dreamweaver CS 3 and CS4) and FTP failures in Snow Leopard
Hi all, this is a bit of a cross post, sorry, but I wanted to be a bit more precise about the nature of a problem many folks are voicing. That is, Dreamweaver and Adobe products are trouble it seems, particularly around the FTP function (there are ot
-
CS6 Feature: Media Browser and Preview in Files Panel
Another two-fer feature overview for Audition CS6. When we started the re-write for Auditino CS5.5, it quickly became clear that the hack Audition 3 used to enable preview within the Open File dialog was no longer going to fly. With Windows 7 and O