Moving the record to another internal table.
dear all,
i am having two internal tables . itab & itab1.
itab contains matnr plant quantity date
100 500 1000 yyyy/mm/10
100 500 2000 yyyy/mm/20.
i have to move the records to itab1 if dd less than 15 quantity should be moved to q1 if gt 15 then the quantity should be moved to same q2 in a same line.
i want itab1 to be
matnr plant q1 q2
100 500 1000 2000.
regards ,
balaji
hi Balaji,
Please use the following logic:
data:
v_dd(2).
loop at itab.
itab1-matnr = itab-matnr.
itab1-plant = itab-plant.
v_dd = itab-date+8(2).
read table itab1 with key matnr = itab1-matnr
plant = itab1-plant.
if v_dd < 15.
itab1-q1 = itab1-q1 + itab-quantity.
else.
itab1-q2 = itab1-q2 + itab-quantity.
endif.
if sy-subrc = 0.
modify itab1 index sy-tabix.
else.
append itab1.
endif.
clear itab1.
endloop.
Hope this helps,
Sajan Joseph.
Similar Messages
-
Create an internal table with the rows of another internal table.
Hi I want to know if posible to create an internal table structure with the rows of another internal table?
ex.
If in i_tab column A has this values: row 1 = first, row 2 = second, row 3 = third.
Now I want that the structure of my internal table be: first, second, thirdHi,
If you do this way then what will be the difference between the two table anyway?? First internal table has the same structure irrespective of which row you select. and you are going to store the data from each row to the rows of the second internal table. In that case, the structure of the internal table is the same as first table. and it would have same rows.
Am I missing something here? or you want to declare the internal table with each field being the structure of the first table? In this case you'd have to do a dynamic declaration of data as the first table can have any no of rows then the second table would have any no of fields in the structure.
Now if you know that your first internal table is going to have a fixed no of rows eg 3 rows then it becomes simple. Do the following then
Data: begin of second_table occurs 0,
first type <first_table type>,
second type <first_table type>,
third type <first_table type>,
end of second_table.
Regards
Prasenjit -
Problem in moving the data into final internal table
Hello all,
I am stuck in apeculair situation.
I have a internal table having header record and a internal table having its line items.
Header record :: 90006103 A 20080110 ALBERTA 3456
Detail record :: 90006103 D2 2219CR1710441
90006103 D2 2219M11710443
90006103 D2 2219M21710442
90006103 A 20080115 ALBERTA 3456
90006103 D2 2219CR1710441
90006103 D2 2219M11710443
90006103 D2 2219M21710442
I collected the header record in one internal table and another internal table having all the line items.But the problem is when i am moving the values to the final inernal table i am getting the same payment date
20080110 (Date field in first record of header internal table) for all the line items .
But my requirement is that date should be 20080110 for the first 3 line items of first header record and similarly date should be 20080115 for all the line items of the next header record.
Kindly suggest.
Regards,
Arunassumption: some mistake in ur posting that, How belnr and date r same for both header records, so i guess, either one is different.
try with AT NEW - ENDAT.
AT NEW belnr.
here use looping, READing of ur itabs.---> so, u need to build couple of itabs to move forth and back.
ENDAT.
pls. note that, when u use this AT NEW all the CHAR fileds of itab wuld show as STARS **.....so, this is the necessity behind building new itabs.
thanq
Edited by: SAP ABAPer on Dec 30, 2008 6:24 PM -
Moving the data of five internal tables to one internal tables.
iam having the five internal table. like below
g_t_vbfa
g_t_vbrk
g_t_vbpa
g_t_kna1
g_t_vbak
this are the five internal tables. each tables having the datas . but each table having the number of records is different. one table having 100 records means another table having 50 records.
previously i used index sys-tabix concept it was not working properly...
my output table is g_t_output_header_data ..
i want to move that output table....
please coding wise give some solution...
thanks
santhoshhi,
chk a sample.
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
rgds
Anver -
Count the Records in an internal table without a loop.
How do i count the number of records in an internal table without using the loop statement.
The Describe statement give the total no. of records in the internal table.But i want the count of the key fields in the internal table
For eg
Row Field
1 A
2 A
3 A
4 B
5 B
6 C
Count of A = 3
Count of B = 2
Count of C = 1Dilip,
I think isn't posible. Only 3 ideas:
1ª, make other table "table2", similar to your actual table.
table2[] = yourtable[].
delete table2 where key <> 'A'.
describe table table2 lines contA.
But depending the amount of data, you may have problems in performance or memory consumption...
2ª, make other table, only with the keys fields and a count field,
data begin table2
key_field1,
cont type i.
end data.
when you append lines to yourdata, make a collect to this table:
table2-keys = yourtable-keys.
table2-cont = 1.
collect table2.
But only works if you can modify the program where data is appended, and you may be carefull when data is deleted :-(...
3ª if your data if filled in a select, you may fill the table2 of point 2ª, making a similar select but:
select keyfields count( * ) into table table2
from ...
where (the same you have to fill your original table...)
group by keys.
But you have the same problem is data is deleted later...
I hope that any of the three is useful for you...
Edited by: Diego Alvarez on Jan 5, 2010 5:09 PM -
Moving the data from multiple internal tables into a single one
Hello everyone,
I am creating a classical report which uses the following tables.
tables : ekko, ekpo, mara, makt,lfa1.
my input parameter is
Select-options Purchase Order number
Following fields are getting used.
Doc no EKKO-EBELN
Material EKPO-MATNR
Item number EKPO-EBELP
Quantity EKPO-MENGE
Material Group MARA-MATKL
Vendor EKKO-LIFNR
Old Material code MARA-BISMT
Material Desc. MAKT-MAKTX
Vendor name LFA1-NAME1
Now i need to do the following task.
1 Select record from EKKO Using document number.
2 Select record from EKPO using EKKO record using Document no as key.
3 Find out Old Material code of each and every material from Material master.
4 Find out Material description for each and every material from MAKT.
5 Sort record on Vendor, Purchase Order number and Material.
I have defined seperate internal tables for these operation.
Once i have fetched records into these individual internal tables from the corresponding DB tables i need to move these values into a new internal tables which has all the above fields mentioned
I need to move these values into a new internal table because to display the values on the report.
Any idea for the above ? Plz help with a sample example or some relevant.
Regards,
Ranjith NambiarHi
1 Select record from EKKO Using document number.
2 Select record from EKPO using EKKO record using Document no as key.
Use inner join and retrive data into one internal table.for Ex ITAB1
3 Find out Old Material code of each and every material from Material master.
Use ITAB1 with for allentries in MARA table to get the onl materil number populate in to one table.
4 Find out Material description for each and every material from MAKT.
Get the Material desc with the same manner as above,
5 Sort record on Vendor, Purchase Order number and Material.
now sort the ITAB1 as you req.
now Loop on the ITAB1.
and read above 2 tables for old matnr and matner deac and append into another table as you want.
Hope this will help.
Regards,
Hiren Patel -
How to add the records of 2 internal table records into one file
hello experts,
My scenario is...
I am retrieving the data for the for the credit, debit and trailer records of the customer into 3 different internal tables and finally i have to append all those records into one file first debit records then credit records finally the trailer record.... how to do that can anyone give some idea plzzzzzzzzz..
Plz its bit urgent..
Thanks a lot for your anticipation
SRIHello,
Do like this.
" Assume u have three itab.
"Itab1 - debit
"Itab2 - credit
"Itab3 - Credit.
REPORT ZV_TEST_SERVER .
*PARAMETERS: P_FILE TYPE STRING."RLGRAP-FILENAME.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
* BIN_FILESIZE =
FILENAME = P_FILE
* FILETYPE = 'ASC'
APPEND = 'X' " Check here
* WRITE_FIELD_SEPARATOR = ' '
* HEADER = '00'
* TRUNC_TRAILING_BLANKS = ' '
* WRITE_LF = 'X'
* COL_SELECT = ' '
* COL_SELECT_MASK = ' '
* DAT_MODE = ' '
* IMPORTING
* FILELENGTH =
TABLES
DATA_TAB = ITAB1
* EXCEPTIONS
* FILE_WRITE_ERROR = 1
* NO_BATCH = 2
* GUI_REFUSE_FILETRANSFER = 3
* INVALID_TYPE = 4
* NO_AUTHORITY = 5
* UNKNOWN_ERROR = 6
* HEADER_NOT_ALLOWED = 7
* SEPARATOR_NOT_ALLOWED = 8
* FILESIZE_NOT_ALLOWED = 9
* HEADER_TOO_LONG = 10
* DP_ERROR_CREATE = 11
* DP_ERROR_SEND = 12
* DP_ERROR_WRITE = 13
* UNKNOWN_DP_ERROR = 14
* ACCESS_DENIED = 15
* DP_OUT_OF_MEMORY = 16
* DISK_FULL = 17
* DP_TIMEOUT = 18
* FILE_NOT_FOUND = 19
* DATAPROVIDER_EXCEPTION = 20
* CONTROL_FLUSH_ERROR = 21
* OTHERS = 22
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
* BIN_FILESIZE =
FILENAME = P_FILE
* FILETYPE = 'ASC'
APPEND = 'X' " Check here
* WRITE_FIELD_SEPARATOR = ' '
* HEADER = '00'
* TRUNC_TRAILING_BLANKS = ' '
* WRITE_LF = 'X'
* COL_SELECT = ' '
* COL_SELECT_MASK = ' '
* DAT_MODE = ' '
* IMPORTING
* FILELENGTH =
TABLES
DATA_TAB = ITAB2 " Check here
* EXCEPTIONS
* FILE_WRITE_ERROR = 1
* NO_BATCH = 2
* GUI_REFUSE_FILETRANSFER = 3
* INVALID_TYPE = 4
* NO_AUTHORITY = 5
* UNKNOWN_ERROR = 6
* HEADER_NOT_ALLOWED = 7
* SEPARATOR_NOT_ALLOWED = 8
* FILESIZE_NOT_ALLOWED = 9
* HEADER_TOO_LONG = 10
* DP_ERROR_CREATE = 11
* DP_ERROR_SEND = 12
* DP_ERROR_WRITE = 13
* UNKNOWN_DP_ERROR = 14
* ACCESS_DENIED = 15
* DP_OUT_OF_MEMORY = 16
* DISK_FULL = 17
* DP_TIMEOUT = 18
* FILE_NOT_FOUND = 19
* DATAPROVIDER_EXCEPTION = 20
* CONTROL_FLUSH_ERROR = 21
* OTHERS = 22
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
* BIN_FILESIZE =
FILENAME = P_FILE
* FILETYPE = 'ASC'
APPEND = 'X' " Check here
* WRITE_FIELD_SEPARATOR = ' '
* HEADER = '00'
* TRUNC_TRAILING_BLANKS = ' '
* WRITE_LF = 'X'
* COL_SELECT = ' '
* COL_SELECT_MASK = ' '
* DAT_MODE = ' '
* IMPORTING
* FILELENGTH =
TABLES
DATA_TAB = ITAB3 " Check here
* EXCEPTIONS
* FILE_WRITE_ERROR = 1
* NO_BATCH = 2
* GUI_REFUSE_FILETRANSFER = 3
* INVALID_TYPE = 4
* NO_AUTHORITY = 5
* UNKNOWN_ERROR = 6
* HEADER_NOT_ALLOWED = 7
* SEPARATOR_NOT_ALLOWED = 8
* FILESIZE_NOT_ALLOWED = 9
* HEADER_TOO_LONG = 10
* DP_ERROR_CREATE = 11
* DP_ERROR_SEND = 12
* DP_ERROR_WRITE = 13
* UNKNOWN_DP_ERROR = 14
* ACCESS_DENIED = 15
* DP_OUT_OF_MEMORY = 16
* DISK_FULL = 17
* DP_TIMEOUT = 18
* FILE_NOT_FOUND = 19
* DATAPROVIDER_EXCEPTION = 20
* CONTROL_FLUSH_ERROR = 21
* OTHERS = 22
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
If useful reward.
Vasanth -
Get the records number from internal table with conditon.
Internal table itab got more than 1000 records,now i need to get the number of records with condition that itab-field1 = 'XXXX'.
actully, i got an inefficient logic to count the number in a loop statement. is there better way to implement it?Hi,
One alternative solution, which may be useful for other parts of your program, is to have an aditional itab1 with a single column/field (field1), which acts like a index or shadow table, and which is filled simultaneously with itab. Then you can use DESCRIBE TABLE itab1 LINES lv_lines.
Atb -
Moving the fields to final internal table
hi experts,
i have a single field in an internal table and i want to move it to final internal table.
i tried this code but its not working.
IF NOT it_ymmessr IS INITIAL.
LOOP AT it_ymmessr into it_final..
move it_ymmessr-srvpos to it_final-srvpos.
ENDLOOP.
ENDIF.
there is dat in the it_ymmessr.
i have five to six similar internal tables with 1 to 3 records and i have to move them to final internal table.
regards,
vinayHi,
IF NOT it_ymmessr IS INITIAL.
LOOP AT it_ymmessr into it_final..
<b>Have one more firld which is the common field for both the tables into it_ymmessr so that u can fill the record correctly.</b>
READ TABLE it_ymmessr WITH key XXXX = it_final-XXXX.
IF sy-subrc = 0.
it_final-srvpos = it_ymmessr-srvpos.
<b>MODIFY it_final.</b>
ENDIF.
CLAER it_final.
ENDLOOP.
ENDIF. -
Record count in internal table
i want to know record count for the records stored in
internal table.
do we have any system field to display record count?Hi,
Try this:
Data: count_lines type i.
describe table my_table lines count_lines.
Regards,
Arjan -
Hi,
How to check if all the records in an internal table are identical.
could you help soonHi,
use the code,
data : begin of itab occurs 0,
matnr like mara-matnr,
maktx like makt-maktx.
end of itab.
parameters : p_matnr like mara-matnr.
start-of-selection.
select * from makt into corresponding fields of table itab
where matnr = p_matnr.
delete adjacent duplicates from itab comparing matnr.
if sy-subrc eq 0.
write : /1 'Entries are identical.' .
endif.
Regards,
Sankar. -
Moving few contents of one internal table to another internal table
Hi
I want to move some contents of one internal table to another internal table, which records match our condition
(without loop)
Example:
1 aa
2 aa
3 aa
4 bb
5 cc
6 aa
7 cc
8 dd
now i want to move records which contain aa to one internal table without using loop.
is there any statemnt to achieve this
Reagrds
SrinivasuHi Srinivasu,
Just create an another internal table say itab2 having the same structure.
Then use the following code:
itab2[] = itab1[]
delete itab2 where field2 <> 'aa'.
Hope this will help.
Regards,
Nitin.
Edited by: Nitin Karamchandani on Nov 21, 2008 8:51 AM -
Spilt the number of records in a internal table
Hi all,
I have a requirement where i must spilt the number of records in my internal table itab .Say if i have 2000 records , i must spilt it taking the first 990 records and doing some posting using Bapi and again take the next 990 records and do the posting .Can some one help me out.
Good answers will be rewarded with points.Hi,
You can use these instructions using two internal tables, but please be aware to not forget any line.
REFRESH my_table2.
APPEND LINES OF my_table FROM 1 TO 990 TO my_table2.
CALL FUNCTION 'BAPI'....
(with my_table2)
REFRESH my_table2.
APPEND LINES OF my_table FROM 991 TO my_table2.
CALL FUNCTION 'BAPI'....
(with my_table2)
Regards,
Mathieu -
Store the vital info from the absence quota record in an internal table
Hi experts,
I want to detrmine if the Absence records (PA2001 rec) deduction from date (PA2001-BEGDA) and absence to date (PA2001-ENDDA) are permissible for the validity period of the Absence Quota record (the PA2006 rec). If the quotas deduction from date, PA2006-DESTA, is greater than the PA2001-BEGDA, we then need to identify this absence quota record for change and change the deduction from date, PA2006-DESTA, to be the same as PA2001-BEGDA. Store the vital info from the absence quota record in an internal table and record the new date that the deduction from date that needs to be changed to. The changes will be made via a BDC session.
Please help me out...
Thanks,
VickyThis looks possible if we code it in 'dynamic action' table, but the BDC may not read it during run time.
Do you still have this issue?
Thanks
Narasimha -
Filtering records from one internal table based on ranges in another itab
Hi guys,
I have 1 internal table with set of GL accounts. I have 2nd internal table where lower interval and upper interval of GL accounts
How to filter out records from 1 internal table by comparing with the GL account ranges present in 2nd internal table.
Please reply.Hi
Create a RANGE for GL Accounts.
LOOP the second Internal Table.
And assign HIGH & LOW to ranges from second ITAB.
And Delete the accounts which are not there in the range.
Use the below code as reference.
DATA: itab TYPE TABLE OF mara WITH HEADER LINE.
DATA: r_matnr TYPE RANGE OF matnr WITH HEADER LINE.
SELECT * FROM mara INTO TABLE itab UP TO 10 ROWS.
r_matnr-sign = 'I'.
r_matnr-option = 'BT'.
r_matnr-low = '000000000016900036'.
r_matnr-high = '000000000016900040'.
APPEND r_matnr.
DELETE itab WHERE matnr NOT IN r_matnr.
Maybe you are looking for
-
Information in the case folder is not getting updated in Oracle Credit Mgt
Hi, I have created an SO and an Invoice for this SO for a particular customer. Now, when I create a credit application and a case folder in OCM for this customer, Fields like Receivables Balance, Credit Exposure, Days Sales Outstanding etc. in the ca
-
Get resolution out of PDF page?
I have a PDF document that is created by creating NSImages with size in 72dpi pts, each has a single representation which is measured in pixels. I then put these images into PDFPages with initWithImage, and then save the document. When I open the doc
-
Create an ABAP program (e.g. an executable program). Define a (local) class CL_FLIGHT_DATA that cannot be instantiated outside the class and contains a private internal table attribute of line type SPFLI, which is filled during instance c
-
Can anyone tell me if the (?) is standard wildcard search functionality in ISU. The glossary gives the following description, however this does not seem to be funtionong in our system. Maybe it's something we can flip a swith on. SAP's Definition of
-
Just installed FCP 6 and now can't open FCP 5 projects! HELP
Yesterday I was trying to get some help with an FCP project that would no longer open. After a number of (very good) ideas from this and other forums did not help, I gave up and purchased the newest version of FCP Studio 2, figured I would soon anywa