Select statement not populating the internal table
Hi,
I have a requirement where I have to upload a file from C drive, the fields in this file are VBELN, description & date of creation.
I am able to get this file into the internal table. After this i need to cross check the VBELN against VBRK-VBELN, if present then update a Z-table.... How do I do the cross check part ?...
if not tw_zvatcn[] is initial,
select * from vbrk
into table tw_vbrk
for all entries in tw_zvatcn
where vbeln = tw_zvztcn-vbeln
and vkorg = p_vkorg.
if sy-subrc = 0.
modify ztzb from lw_zvatcn.
endif.
endif.
Internal table tw_vbrk is coming blank, which is not correct because I see the data in db tbl VBRK
Is p_vkorg a parameter or select option.
If it is parameter and is blank you will not get data in the table.
In that case make a condition for that field also.
if not tw_zvatcn[] is initial.
if p_vkorg is not initial.
select * from vbrk
into table tw_vbrk
for all entries in tw_zvatcn
where vbeln = tw_zvztcn-vbeln
and vkorg = p_vkorg.
if sy-subrc = 0.
modify ztzb from lw_zvatcn.
endif.
else.
select * from vbrk
into table tw_vbrk
for all entries in tw_zvatcn
where vbeln = tw_zvztcn-vbeln.
if sy-subrc = 0.
modify ztzb from lw_zvatcn.
endif.
endif.
endif.
Similar Messages
-
Reading from select-options field into the internal table
Hi,
I have to read the low and high ranges from the select-options fields into a field in the internal table in order to update the same field in line item table. since the user may change the screen fields, i need to pass the values directly from the screen and store it in a variable in the internal table. Is there a way to pass both ranges, low and high to one variable which holds the entire range?
Thanks,
SruthyHi,
In the Selection screen you can directly read the field(Select-option)value using read statement as follows:
READ TABLE <SELECT-OPTIONS field name> [using index] INTO <work area>.
After reading you can directly access all the values as follows and can store them in the variables:
var1 = <work area>-LOW
var2 = <work area>-HIGH
var3 = <work area>-SIGN
var4 = <work area>-OPTION
as per your requirement.
I think this will help you.
<b>Kindly reward if helpful.</b>
Regards,
Shakuntala. -
Problem in the internal table of open dataset statement
Hi abapers,
I am using the open dataset command to download my file at application server into an internal table.
But some colums of the internal table are string since i do not want to truncate any of the long text present in the file.
The open dataset command does not allow the internal table to have string components.
Is there any workaround by which i can download all the text components of the file without truncating them .
Regards,
Adityatry to use field symbols:-
FORM download_file .
DATA: l_file TYPE rlgrap-filename,
l_line TYPE string.
DATA: v_excel_string(1000) TYPE c,
v_len TYPE i,
v_zover TYPE i .
FIELD-SYMBOLS: <f> TYPE ANY .
CLEAR wa_fin.
*--- Seting File path
CONCATENATE p_cfile v_file sy-datum INTO l_file.
*--- Open data set
OPEN DATASET l_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc = 0.
LOOP AT it_down INTO wa_down.
CLEAR : v_excel_string, v_zover, v_len.
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE wa_down TO <f>.
IF sy-subrc <> 0.
EXIT. "exits do loop and process next record in itab
ENDIF.
DESCRIBE FIELD <f> LENGTH v_len IN CHARACTER MODE.
v_excel_string+v_zover(v_len) = <f> .
v_zover = v_zover + v_len .
ENDDO.
TRANSFER v_excel_string TO l_file.
CLEAR : v_excel_string,
wa_down ,
v_zover .
ENDLOOP.
*--- Close data set
CLOSE DATASET l_file.
IF sy-subrc = 0.
*--- Success Message
MESSAGE s000(000) WITH text-018.
ENDIF.
ELSE.
*--- Error unable to open file.
MESSAGE e000(000) WITH text-017.
ENDIF.
ENDFORM. " DOWNLOAD_FILE
Thanks ,
Ruchi Tiwari -
Value not moved to work are of the internal table
HI
I have one internal table declared with occurs 2500.
i am selecting the values from a z table into this internal table.
now i want to move the values in the table to another internal table for download.here except one field all the other fields are moving to the new internal table.When i debugged i could see the value in the internal table but its not getting moved to work area of that internal table (or the header line).
I could not see the value when i use itab[]-field in debugger mode instead when i use itab[1]-field i could see that field value.
please do suggest.There is no need to move your data from one internal table to another with fixed structure. All you need to do is take each row's components skipping the column you don't want to download and concatenate this to some string. Then append to string table and download it. Sample:
"let's say your column is on 3rd place in the table
data l_row_string type string.
data lt_string_tab type table of string.
Loop at itab assigning <wa>.
do.
check sy-index ne 3. "skip this column
assign component sy-index of structure <wa> to <comp>.
if sy-subrc = 0.
CONCATENATE l_row_string <comp> INTO l_row_string SEPARATED BY cl_abap_char_utilities=>horizontal_tab.
else.
"no more component in row
append l_row_string to lt_string_tab.
clear l_row_string.
exit.
endif.
enddo.
endloop.
Now all you need is to downlaod your lt_string_tab as your text file (extension TXT).
Regards
Marcin -
Web ADI-Custom Integrator- LOV value selected is not populating in the cell
Hi,
I have a custom integrator, created a layout and mapping
and I have update the BNE_INTERFACE_COLS_B table for the column that I want as an LOV.
LOV_TYPE = STANDARD
val_obj_name = 'FA_BOOK_CONTROLS_SEC'
val_addl_w_c= 'NVL(DATE_INEFFECTIVE,SYSDATE) >= SYSDATE AND BOOK_CLASS IN (''CORPORATE'',''TAX'')',field_size = 15
val_component_code = 'FA_BOOK_TYPE_CODE'
val_component_app_id = 140
val_type = TABLE
val_id_cil= BOOK_TYPE_CODE
val_mean_col=BOOK_TYPE_CODE
val_desc_col=BOOK_TYPE_CODE
The LOV is showing up fine, but when I select the value the , selected value is not getting populated in the excel cell.
Can you please help me resolve this? This is urgent.
Thanks,
AJHi Ashish,
Can you please give more details?
On my end I have the same issue but one of my LOVs is not populating the cell while the other does. But I never performed any of the action you mentionned.
So I would like to try your solution for the remaining LOV that does not populate my Excel cell. What is the purpose of "Then create a web adi function and attach to web adi menu.Call form function association integrator and attach the form function to your integrator.( Interface_cols)"? and what kind of "function" should we create?
Thanks and regards,
Gaël
Edited by: Gaël on 21 sept. 2012 08:16 -
Validate the data in the internal table with the date in selection screen
Hi all,
I want to validate the data in the internal table and get only the records with the input date in the selection screen.
The date is in the select options and please let me know how to get the records only if it satisfies the input date in the selection screen.
Regards,
ShalemFor Ex.
SELECT-OPTIONS: S_DATE FOR VBAK-VDATU
If you want to read one INTERNAL TABLE record
READ TABLE it_tab(internal table name) WHERE vdatu(date field name in the internal table) = s_date
If you want to move more then one
LOOP AT it_tab WHERE vdatu = s_date.
Take the field values in another table and append it. then end loop.
you will get the records which only have the date in select option..
If you want detail code give me internal table name and select option name i will write you the code.
regards
Yuvaram -
Limit on the memory/size of the internal table
Hi,
Is there any limit on the size of internal table....?
we are having some select statements that are fetching huge no. of records into the internal tables...
can some of the records be missed or is there any limit on the no. of records or size of the internal table...
The code that we are using is logically correct and it is working fine for small inputs but for the large selections, some of the records are getting missed as we are displaying the data from these internal tables only...
We can not debug the code coz for the large inputs, code is taking around 2 to 3 hours of processing
We are using this code in BI in the end routines
We are doing the operation like
itab1 = itab2
where itab2 contains around 25000 records and itab1 is initial(no entries)
If there is a limit , then how can we increase the size
Please suggest..
Thanks
Tarun Brijwani
Edited by: Tarun Brijwani on Apr 23, 2009 6:06 PM
Edited by: Tarun Brijwani on Apr 23, 2009 6:06 PMHello Tarun
You can limit the number of records selected by your SELECT statement by adding the addition "UP TO n ROWS" to your SELECT statement.
Example:
SELECT * FROM TABLEXYZ UP TO 5000 ROWS WHERE .........
Hope this helps you.
Thanks and best regards
Anand. -
Runtime error:ABAP program lines are longer than the internal table
Hi all,
Below is the code I have written,when Iam running it Iam getting
'ABAP program lines are longer than the internal table' runtime error.How can I resolve it.
REPORT ZTEST1 NO STANDARD PAGE HEADING LINE-SIZE 255.
TABLES:MARC,CDHDR,CDPOS.
TYPE-POOLS:SLIS.
DATA:HEADER TYPE SLIS_T_FIELDCAT_ALV,
WA TYPE SLIS_FIELDCAT_ALV,
LAYOUT TYPE SLIS_LAYOUT_ALV.
TYPES:BEGIN OF MARC_TY,
MATNR LIKE MARC-MATNR,
WERKS LIKE MARC-WERKS,
EKGRP LIKE MARC-EKGRP,
MINBE LIKE MARC-MINBE,
EISBE LIKE MARC-EISBE,
MABST LIKE MARC-MABST,
END OF MARC_TY.
TYPES:BEGIN OF MATNR1_TY,
MATNR1 LIKE CDHDR-OBJECTID,
END OF MATNR1_TY.
TYPES:BEGIN OF CDHDR_TY,
OBJECTCLAS LIKE CDHDR-OBJECTCLAS,
OBJECTID LIKE CDHDR-OBJECTID,
CHANGENR LIKE CDHDR-CHANGENR,
USERNAME LIKE CDHDR-USERNAME,
UDATE LIKE CDHDR-UDATE,
END OF CDHDR_TY.
TYPES:BEGIN OF CDPOS_TY,
OBJECTCLAS LIKE CDPOS-OBJECTCLAS,
OBJECTID LIKE CDPOS-OBJECTID,
CHANGENR LIKE CDPOS-CHANGENR,
TABNAME LIKE CDPOS-TABNAME,
FNAME LIKE CDPOS-FNAME,
CHNGIND LIKE CDPOS-CHNGIND,
VALUE_NEW LIKE CDPOS-VALUE_NEW,
VALUE_OLD LIKE CDPOS-VALUE_OLD,
END OF CDPOS_TY.
**************TABLE TYPES********************************************
TYPES: MARC_TAB TYPE TABLE OF MARC_TY,
MATNR1_TAB TYPE TABLE OF MATNR1_TY,
CDHDR_TAB TYPE TABLE OF CDHDR_TY,
CDPOS_TAB TYPE TABLE OF CDPOS_TY.
*******************INTERNAL TABLES************************************
DATA:MARC_ITAB TYPE MARC_TAB,
MATNR1_ITAB TYPE MATNR1_TAB,
CDHDR_ITAB TYPE CDHDR_TAB,
CDPOS_ITAB TYPE CDPOS_TAB.
****************WORK AREAS********************************************
DATA:MARC_WA TYPE MARC_TY,
MATNR1_WA TYPE MATNR1_TY,
CDHDR_WA TYPE CDHDR_TY,
CDPOS_WA TYPE CDPOS_TY.
*******************SELECTION-SCREEN***********************************
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-000.
PARAMETERS:PLANT LIKE MARC-WERKS.
SELECT-OPTIONS:MATERIAL FOR MARC-MATNR.
SELECT-OPTIONS:DATE FOR CDHDR-UDATE.
SELECTION-SCREEN END OF BLOCK B1.
START-OF-SELECTION.
SELECT MATNR
WERKS
EKGRP
MINBE
EISBE
MABST
FROM MARC INTO TABLE MARC_ITAB
WHERE MATNR IN MATERIAL
AND WERKS = PLANT.
CHECK MARC_ITAB[] IS NOT INITIAL.
LOOP AT MARC_ITAB INTO MARC_WA.
MATNR1_WA-MATNR1 = MARC_WA-MATNR.
APPEND MATNR1_WA TO MATNR1_ITAB.
CLEAR MATNR1_WA.
ENDLOOP.
CHECK MATNR1_ITAB[] IS NOT INITIAL.
SELECT OBJECTCLAS
OBJECTID
CHANGENR
USERNAME
UDATE
FROM CDHDR INTO TABLE CDHDR_ITAB
FOR ALL ENTRIES IN MATNR1_ITAB
WHERE OBJECTCLAS = 'MATERIAL'
AND OBJECTID = MATNR1_ITAB-MATNR1
AND UDATE IN DATE.
CHECK CDHDR_ITAB[] IS NOT INITIAL.
SORT CDHDR_ITAB[] DESCENDING BY OBJECTID CHANGENR.
DELETE ADJACENT DUPLICATES FROM CDHDR_ITAB[] COMPARING OBJECTID.
SELECT OBJECTCLAS
OBJECTID
CHANGENR
TABNAME
FNAME
CHNGIND
VALUE_NEW
VALUE_OLD
FROM CDPOS INTO CORRESPONDING FIELDS OF TABLE CDPOS_ITAB
FOR ALL ENTRIES IN CDHDR_ITAB
WHERE OBJECTCLAS = CDHDR_ITAB-OBJECTCLAS
AND OBJECTID = CDHDR_ITAB-OBJECTID
AND CHANGENR = CDHDR_ITAB-CHANGENR
AND TABNAME = 'MARC'
AND FNAME IN ('MINBE','EISBE','MABST','LVORM')
AND CHNGIND = 'U'.
CHECK CDPOS_ITAB[] IS NOT INITIAL.
*LOOP AT CDPOS_ITAB INTO CDPOS_WA.
WRITE: / CDPOS_WA-OBJECTCLAS,
CDPOS_WA-OBJECTID,
CDPOS_WA-CHANGENR,
CDPOS_WA-TABNAME,
CDPOS_WA-FNAME,
CDPOS_WA-CHNGIND,
CDPOS_WA-VALUE_NEW,
CDPOS_WA-VALUE_OLD.
*ENDLOOP.
WA-SELTEXT_L = 'OBJECTCLAS'.
WA-COL_POS = '1'.
WA-FIELDNAME = 'OBJECTCLAS'.
WA-TABNAME = 'CDPOS_ITAB'.
WA-OUTPUTLEN = '15'.
APPEND WA TO HEADER.
CLEAR WA.
WA-SELTEXT_L = 'OBJECTID'.
WA-COL_POS = '2'.
WA-FIELDNAME = 'OBJECTID'.
WA-TABNAME = 'CDPOS_ITAB'.
WA-OUTPUTLEN = '20'.
APPEND WA TO HEADER.
CLEAR WA.
WA-SELTEXT_L = 'CHANGENR'.
WA-COL_POS = '3'.
WA-FIELDNAME = 'CHANGENR'.
WA-TABNAME = 'CDPOS_ITAB'.
WA-OUTPUTLEN = '8'.
APPEND WA TO HEADER.
CLEAR WA.
WA-SELTEXT_L = 'TABNAME'.
WA-COL_POS = '4'.
WA-FIELDNAME = 'TABNAME'.
WA-TABNAME = 'CDPOS_ITAB'.
WA-OUTPUTLEN = '5'.
APPEND WA TO HEADER.
CLEAR WA.
WA-SELTEXT_L = 'FNAME'.
WA-COL_POS = '5'.
WA-FIELDNAME = 'FNAME'.
WA-TABNAME = 'CDPOS_ITAB'.
WA-OUTPUTLEN = '7'.
APPEND WA TO HEADER.
CLEAR WA.
WA-SELTEXT_L = 'CHANGING'.
WA-COL_POS = '6'.
WA-FIELDNAME = 'CHANGING'.
WA-TABNAME = 'CDPOS_ITAB'.
WA-OUTPUTLEN = '1'.
APPEND WA TO HEADER.
CLEAR WA.
WA-SELTEXT_L = 'VALUE_NEW'.
WA-COL_POS = '7'.
WA-FIELDNAME = 'VALUE_NEW'.
WA-TABNAME = 'CDPOS_ITAB'.
WA-OUTPUTLEN = '5'.
APPEND WA TO HEADER.
CLEAR WA.
WA-SELTEXT_L = 'VALUE_OLD'.
WA-COL_POS = '8'.
WA-FIELDNAME = 'VALUE_OLD'.
WA-TABNAME = 'CDPOS_ITAB'.
WA-OUTPUTLEN = '5'.
APPEND WA TO HEADER.
CLEAR WA.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = SY-REPID
I_INTERNAL_TABNAME = 'CDPOS_ITAB'
I_CLIENT_NEVER_DISPLAY = 'X'
I_INCLNAME = SY-REPID
CHANGING
CT_FIELDCAT = HEADER[]
EXCEPTIONS
IF SY-SUBRC <> 0.
ENDIF.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IT_FIELDCAT = HEADER[]
TABLES
T_OUTTAB = CDPOS_ITAB[]
IF SY-SUBRC <> 0.
ENDIF.Your select querry on MARC is not matching with MARC_TY.
The field in the MARC table and MARC_TY should be same.
and also, when you are making select querry on CDPOS table
with all entries.
When ever you are using all entries select statement, you should check whether the internal table is having value.
you should check
if CDPOS_IT[] is not initial.
SELECT OBJECTCLAS
OBJECTID
CHANGENR
TABNAME
FNAME
CHNGIND
VALUE_NEW
VALUE_OLD
FROM CDPOS INTO CORRESPONDING FIELDS OF TABLE CDPOS_ITAB
FOR ALL ENTRIES IN CDHDR_ITAB
WHERE OBJECTCLAS = CDHDR_ITAB-OBJECTCLAS
AND OBJECTID = CDHDR_ITAB-OBJECTID
AND CHANGENR = CDHDR_ITAB-CHANGENR
AND TABNAME = 'MARC'
AND FNAME IN ('MINBE','EISBE','MABST','LVORM')
AND CHNGIND = 'U'.
endif.
Regards
Madhan D -
Moving data in all the internal tables to the final table t_data
hi all,
how to data in all the internal tables to the final table t_data
*selecting fields from bkpf table
SELECT bukrs
belnr
gjahr
bldat
xblnr
usnam
FROM bkpf
INTO TABLE t_bkpf
WHERE bukrs EQ po_bukrs AND
belnr IN so_belnr AND
budat IN so_budat AND
blart IN so_blart.
IF t_bkpf[] IS INITIAL.
MESSAGE a999(zfi_ap_gl) WITH text-011.
STOP.
ELSE.
*selecting fields from bseg table.
SELECT bukrs
belnr
gjahr
koart
shkzg
dmbtr
zuonr
sgtxt
kostl
hkont
lifnr
prctr
FROM bseg
INTO TABLE t_bseg
FOR ALL ENTRIES IN t_bkpf
WHERE bukrs EQ t_bkpf-bukrs AND
belnr EQ t_bkpf-belnr AND
gjahr EQ t_bkpf-gjahr AND
lifnr IN so_lifnr.
ENDIF.
IF t_bseg[] IS INITIAL.
MESSAGE a999(zfi_ap_gl) WITH text-011.
STOP.
ELSE.
*selecting the companies address from adrc table
SELECT SINGLE addrnumber street str_suppl2 city1
region post_code1
FROM adrc
INTO wa_adrc
WHERE addrnumber EQ w_adrnr.
*selecting adrnr from the lfa1 table
SELECT lifnr adrnr name1 ort01 regio pstlz
FROM lfa1
INTO TABLE t_adrnr
FOR ALL ENTRIES IN t_bseg
WHERE lifnr EQ t_bseg-lifnr.
IF NOT t_adrnr[] IS INITIAL.
*populating the t_vaddress table.
SELECT addrnumber
street
str_suppl2
FROM adrc
INTO TABLE t_vaddress
FOR ALL ENTRIES IN t_adrnr
WHERE addrnumber EQ t_adrnr-adrnr.
*populating the t_vendor table with the vendor address
SELECT lifnr
adrnp_2
namev
name1
INTO TABLE t_vendor
FROM knvk
FOR ALL ENTRIES IN t_adrnr
WHERE lifnr EQ t_adrnr-lifnr AND
adrnp_2 EQ t_adrnr-adrnr.
ENDIF.
ENDIF.Loop the internal table which is having the maximum number of records,then use read table....for other internal tables....in that loop and then append them into final internal table.
Ex-LOOP AT IT_VBRP INTO WA_VBRP.
WA_FINAL-WERKS = WA_VBRP-WERKS_I.
WA_FINAL-KUNAG = WA_VBRP-KUNAG.
WA_FINAL-AEDAT = WA_VBRP-AEDAT.
READ TABLE IT_KONV INTO WA_KONV WITH KEY KNUMV = WA_VBRP-KNUMV
KPOSN = WA_VBRP-POSNR_I.
IF SY-SUBRC EQ 0.
WA_FINAL-KSCHL = WA_KONV-KSCHL.
CLEAR WA_KONV.
ENDIF.
READ TABLE IT_KNA1 INTO WA_KNA1 WITH KEY KUNNR = WA_VBRP-KUNAG.
IF SY-SUBRC EQ 0.
WA_FINAL-NAME1 = WA_KNA1-NAME1.
CLEAR WA_KNA1.
ENDIF.
ENDIF.
APPEND WA_FINAL TO IT_FINAL.
CLEAR: WA_FINAL,WA_KONV,wa_kna1.
ENDLOOP. -
Difference betwen the internal tables
Hai friends,
Pls give me the types of internal tables and their differences .and its usage by example.
regrds,
Prashanth.Internal tables
Definition
Data structure that exists only at program runtime.
An internal table is one of two structured data types in ABAP. It can contain any number of identically structured rows, with or without a header line.
The header line is similar to a structure and serves as the work area of the internal table. The data type of individual rows can be either elementary or structured.
Internal tables provide a means of taking data from a fixed structure and storing it in working memory in ABAP. The data is stored line by line in memory, and each line has the same structure. In ABAP, internal tables fulfill the function of arrays. Since they are dynamic data objects, they save the programmer the task of dynamic memory management in his or her programs. You should use internal tables whenever you want to process a dataset with a fixed structure within a program. A particularly important use for internal tables is for storing and formatting data from a database table within a program. They are also a good way of including very complicated data structures in an ABAP program.
Like all elements in the ABAP type concept, internal tables can exist both as data types and as data objects . A data type is the abstract description of an internal table, either in a program or centrally in the ABAP Dictionary, that you use to create a concrete data object. The data type is also an attribute of an existing data object.
Internal Tables as Data Types
Internal tables and structures are the two structured data types in ABAP. The data type of an internal table is fully specified by its line type, key, and table type.
Line type
The line type of an internal table can be any data type. The data type of an internal table is normally a structure. Each component of the structure is a column in the internal table. However, the line type may also be elementary or another internal table.
Key
The key identifies table rows. There are two kinds of key for internal tables - the standard key and a user-defined key. You can specify whether the key should be UNIQUE or NON-UNIQUE. Internal tables with a unique key cannot contain duplicate entries. The uniqueness depends on the table access method.
If a table has a structured line type, its default key consists of all of its non-numerical columns that are not references or themselves internal tables. If a table has an elementary line type, the default key is the entire line . The default key of an internal table whose line type is an internal table, the default key is empty.
The user-defined key can contain any columns of the internal table that are not references or themselves internal tables. Internal tables with a user-defined key are called key tables. When you define the key, the sequence of the key fields is significant. You should remember this, for example, if you intend to sort the table according to the key.
Table type
The table type determines how ABAP will access individual table entries. Internal tables can be divided into three types:
Standard tables have an internal linear index. From a particular size upwards, the indexes of internal tables are administered as trees. In this case, the index administration overhead increases in logarithmic and not linear relation to the number of lines. The system can access records either by using the table index or the key. The response time for key access is proportional to the number of entries in the table. The key of a standard table is always non-unique. You cannot specify a unique key. This means that standard tables can always be filled very quickly, since the system does not have to check whether there are already existing entries.
Sorted tables are always saved sorted by the key. They also have an internal index. The system can access records either by using the table index or the key. The response time for key access is logarithmically proportional to the number of table entries, since the system uses a binary search. The key of a sorted table can be either unique or non-unique. When you define the table, you must specify whether the key is to be unique or not. Standard tables and sorted tables are known generically as index tables.
Hashed tables have no linear index. You can only access a hashed table using its key. The response time is independent of the number of table entries, and is constant, since the system access the table entries using a hash algorithm. The key of a hashed table must be unique. When you define the table, you must specify the key as UNIQUE.
Generic Internal Tables
Unlike other local data types in programs, you do not have to specify the data type of an internal table fully. Instead, you can specify a generic construction, that is, the key or key and line type of an internal table data type may remain unspecified. You can use generic internal tables to specify the types of field symbols and the interface parameters of procedures. You cannot use them to declare data objects.
Internal Tables as Dynamic Data Objects
Data objects that are defined either with the data type of an internal table, or directly as an internal table, are always fully defined in respect of their line type, key and access method. However, the number of lines is not fixed. Thus internal tables are dynamic data objects, since they can contain any number of lines of a particular type. The only restriction on the number of lines an internal table may contain are the limits of your system installation. The maximum memory that can be occupied by an internal table (including its internal administration) is 2 gigabytes. A more realistic figure is up to 500 megabytes. An additional restriction for hashed tables is that they may not contain more than 2 million entries. The line types of internal tables can be any ABAP data types - elementary, structured, or internal tables. The individual lines of an internal table are called table lines or table entries. Each component of a structured line is called a column in the internal table.
Choosing a Table Type
The table type (and particularly the access method) that you will use depends on how the typical internal table operations will be most frequently executed.
Standard tables
This is the most appropriate type if you are going to address the individual table entries using the index. Index access is the quickest possible access. You should fill a standard table by appending lines (ABAP APPEND statement), and read, modify and delete entries by specifying the index (INDEX option with the relevant ABAP command). The access time for a standard table increases in a linear relationship with the number of table entries. If you need key access, standard tables are particularly useful if you can fill and process the table in separate steps. For example, you could fill the table by appending entries, and then sort it. If you use the binary search option with key access, the response time is logarithmically proportional to the number of table entries.
Sorted tables
This is the most appropriate type if you need a table which is sorted as you fill it. You fill sorted tables using the INSERT statement. Entries are inserted according to the sort sequence defined through the table key. Any illegal entries are recognized as soon as you try to add them to the table. The response time for key access is logarithmically proportional to the number of table entries, since the system always uses a binary search. Sorted tables are particularly useful for partially sequential processing in a LOOP if you specify the beginning of the table key in the WHERE condition.
Hashed tables
This is the most appropriate type for any table where the main operation is key access. You cannot access a hashed table using its index. The response time for key access remains constant, regardless of the number of table entries. Like database tables, hashed tables always have a unique key. Hashed tables are useful if you want to construct and use an internal table which resembles a database table or for processing large amounts of data.
Special Features of Standard Tables
Unlike sorted tables, hashed tables, and key access to internal tables, which were only introduced in Release 4.0, standard tables already existed several releases previously. Defining a line type, table type, and tables without a header line have only been possible since Release 3.0. For this reason, there are certain features of standard tables that still exist for compatibility reasons.
Standard Tables Before Release 3.0
Before Release 3.0, internal tables all had header lines and a flat-structured line type. There were no independent table types. You could only create a table object using the OCCURS addition in the DATA statement, followed by a declaration of a flat structure:
DATA: BEGIN OF .
The effect of the OCCURS addition is to construct a standard table with the data type
They can also be replaced by the following statements:
Standard Tables From Release 4.0
When you create a standard table, you can use the following forms of the TYPES and DATA statements. The addition INITIAL SIZE is also possible in all of the statements. The addition WITH HEADER LINE is possible in the DATA statement.
Standard Table Types
Generic Standard Table Type:
TYPES TYPE|LIKE TABLE OF TYPE|LIKE TABLE OF
WITH TYPE|LIKE TABLE OF TYPE|LIKE TABLE OF TYPE|LIKE TABLE OF
WITH .
Here, the LIKE addition refers to an existing table object in the same program. The TYPE addition can refer to an internal type in the program declared using the TYPES statement, or a table type in the ABAP Dictionary.
You must ensure that you only refer to tables that are fully typed. Referring to generic table types (ANY TABLE, INDEX TABLE) or not specifying the key fully is not allowed (for exceptions, refer to Special Features of Standard Tables).
The optional addition WITH HEADER line declares an extra data object with the same name and line type as the internal table. This data object is known as the header line of the internal table. You use it as a work area when working with the internal table (see Using the Header Line as a Work Area). When you use internal tables with header lines, you must remember that the header line and the body of the table have the same name. If you have an internal table with header line and you want to address the body of the table, you must indicate this by placing brackets after the table name ([]). Otherwise, ABAP interprets the name as the name of the header line and not of the body of the table. You can avoid this potential confusion by using internal tables without header lines. In particular, internal tables nested in structures or other internal tables must not have a header line, since this can lead to ambiguous expressions.
TYPES VECTOR TYPE SORTED TABLE OF I WITH UNIQUE KEY TABLE LINE.
DATA: ITAB TYPE VECTOR,
JTAB LIKE ITAB WITH HEADER LINE.
MOVE ITAB TO JTAB. <- Syntax error!
MOVE ITAB TO JTAB[].
The table object ITAB is created with reference to the table type VECTOR. The table object JTAB has the same data type as ITAB. JTAB also has a header line. In the first MOVE statement, JTAB addresses the header line. Since this has the data type I, and the table type of ITAB cannot be converted into an elementary type, the MOVE statement causes a syntax error. The second MOVE statement is correct, since both operands are table objects.
Declaring New Internal Tables
You can use the DATA statement to construct new internal tables as well as using the LIKE or TYPE addition to refer to existing types or objects. The table type that you construct does not exist in its own right; instead, it is only an attribute of the table object. You can refer to it using the LIKE addition, but not using TYPE. The syntax for constructing a table object in the DATA statement is similar to that for defining a table type in the TYPES statement.
DATA ]
As when you define a table type, the type constructor
of an internal table as follows:
UNIQUE KEY belong to the key as long as they are not internal tables or references, and do not contain internal tables or references. Key fields can be nested structures. The substructures are expanded component by component when you access the table using the key. The system follows the sequence of the key fields.
UNIQUE KEY TABLE LINE
If a table has an elementary line type (C, D, F, I, N, P, T, X), you can define the entire line as the key. If you try this for a table whose line type is itself a table, a syntax error occurs. If a table has a structured line type, it is possible to specify the entire line as the key. However, you should remember that this is often not suitable.
UNIQUE DEFAULT KEY
This declares the fields of the default key as the key fields. If the table has a structured line type, the default key contains all non-numeric columns of the internal table that are not and do not contain references or internal tables. If the table has an elementary line type, the default key is the entire line. The default key of an internal table whose line type is an internal table, the default key is empty.
Specifying a key is optional. If you do not specify a key, the system defines a table type with an arbitrary key. You can only use this to define the types of field symbols and the interface parameters of procedures. For exceptions, refer to Special Features of Standard Tables.
The optional additions UNIQUE or NON-UNIQUE determine whether the key is to be unique or non-unique, that is, whether the table can accept duplicate entries. If you do not specify UNIQUE or NON-UNIQUE for the key, the table type is generic in this respect. As such, it can only be used for specifying types. When you specify the table type simultaneously, you must note the following restrictions:
· You cannot use the UNIQUE addition for standard tables. The system always generates the NON-UNIQUE addition automatically.
· You must always specify the UNIQUE option when you create a hashed table.
Initial Memory Requirement
You can specify the initial amount of main memory assigned to an internal table object when you define the data type using the following addition:
INITIAL SIZE , the system calculates a new value so that n times the line width is around 12KB.
Examples
TYPES: BEGIN OF LINE,
COLUMN1 TYPE I,
COLUMN2 TYPE I,
COLUMN3 TYPE I,
END OF LINE.
1. TYPES ITAB TYPE SORTED TABLE OF LINE WITH UNIQUE KEY COLUMN1.
The program defines a table type ITAB. It is a sorted table, with line type of the structure LINE and a unique key of the component COLUMN1.
2. TYPES VECTOR TYPE HASHED TABLE OF I WITH UNIQUE KEY TABLE LINE.
TYPES: BEGIN OF LINE,
COLUMN1 TYPE I,
COLUMN2 TYPE I,
COLUMN3 TYPE I,
END OF LINE.
TYPES ITAB TYPE SORTED TABLE OF LINE WITH UNIQUE KEY COLUMN1.
TYPES: BEGIN OF DEEPLINE,
FIELD TYPE C,
TABLE1 TYPE VECTOR,
TABLE2 TYPE ITAB,
END OF DEEPLINE.
TYPES DEEPTABLE TYPE STANDARD TABLE OF DEEPLINE
WITH DEFAULT KEY.
The program defines a table type VECTOR with type hashed table, the elementary line type I and a unique key of the entire table line. The second table type is the same as in the previous example. The structure DEEPLINE contains the internal table as a component. The table type DEEPTABLE has the line type DEEPLINE. Therefore, the elements of this internal table are themselves internal tables. The key is the default key - in this case the column FIELD. The key is non-unique, since the table is a standard table.
Specifying the Type of Formal Parameters
Formal parameters can have any valid ABAP data type. You can specify the type of a formal parameter, either generically or fully, using the TYPE or LIKE addition. If you specify a generic type, the type of the formal parameter is either partially specified or not specified at all. Any attributes that are not specified are inherited from the corresponding actual parameter when the subroutine is called. If you specify the type fully, all of the technical attributes of the formal parameter are defined with the subroutine definition.
The following remarks about specifying the types of parameters also apply to the parameters of other procedures (function modules and methods).
If you have specified the type of the formal parameters, the system checks that the corresponding actual parameters are compatible when the subroutine is called. For internal subroutines, the system checks this in the syntax check. For external subroutines, the check cannot occur until runtime.
By specifying the type, you ensure that a subroutine always works with the correct data type. Generic formal parameters allow a large degree of freedom when you call subroutines, since you can pass data of any type. This restricts accordingly the options for processing data in the subroutine, since the operations must be valid for all data types. For example, assigning one data object to another may not even be possible for all data types. If you specify the types of subroutine parameters, you can perform a much wider range of operations, since only the data appropriate to those operations can be passed in the call. If you want to process structured data objects component by component in a subroutine, you must specify the type of the parameter.
Specifying Generic Types
The following types allow you more freedom when using actual parameters. The actual parameter need only have the selection of attributes possessed by the formal parameter. The formal parameter adopts its remaining unnamed attributes from the actual parameter.
Check for actual parameters
No type specificationTYPE ANY The subroutine accepts actual parameters of any type. The formal parameter inherits all of the technical attributes of the actual parameter.
TYPE C, N, P, or X The subroutine only accepts actual parameters with the type C, N, P, or X. The formal parameter inherits the field length and DECIMALS specification (for type P) from the actual parameter.
TYPE TABLE The system checks whether the actual parameter is a standard internal table. This is a shortened form of TYPE STANDARD TABLE (see below).
TYPE ANY TABLE The system checks whether the actual parameter is an internal table. The formal parameter inherits all of the attributes (line type, table type, key) from the actual parameter.
TYPE INDEX TABLE The system checks whether the actual parameter is an index table (standard or sorted table). The formal parameter inherits all of the attributes (line type, table type, key) from the actual parameter.
TYPE STANDARD TABLE The system checks whether the actual parameter is a standard internal table. The formal parameter inherits all of the attributes (line type, key) from the actual parameter.
TYPE SORTED TABLE The system checks whether the actual parameter is a sorted table. The formal parameter inherits all of the attributes (line type, key) from the actual parameter.
TYPE HASHED TABLE The system checks whether the actual parameter is a hashed table. The formal parameter inherits all of the attributes (line type, key) from the actual parameter.
Note that formal parameters inherit the attributes of their corresponding actual parameters dynamically at runtime, and so they cannot be identified in the program code. For example, you cannot address an inherited table key statically in a subroutine, but you probably can dynamically.
TYPES: BEGIN OF LINE,
COL1,
COL2,
END OF LINE.
DATA: WA TYPE LINE,
ITAB TYPE HASHED TABLE OF LINE WITH UNIQUE KEY COL1,
KEY(4) VALUE 'COL1'.
WA-COL1 = 'X'. INSERT WA INTO TABLE ITAB.
WA-COL1 = 'Y'. INSERT WA INTO TABLE ITAB.
PERFORM DEMO USING ITAB.
FORM DEMO USING P TYPE ANY TABLE.
READ TABLE P WITH TABLE KEY (KEY) = 'X' INTO WA.
ENDFORM.
The table key is addressed dynamically in the subroutine. However, the static address
READ TABLE P WITH TABLE KEY COL1 = 'X' INTO WA.
is syntactically incorrect, since the formal parameter P does not adopt the key of table ITAB until runtime.
Assigning Internal Tables :
Like other data objects, you can use internal tables as operands in a MOVE statement
MOVE , including the data in any nested internal tables. The original contents of the target table are overwritten.
If you are using internal tables with header lines, remember that the header line and the body of the table have the same name. If you want to address the body of the table in an assignment, you must place two brackets () after the table name.
DATA: BEGIN OF line,
col1(1) TYPE c,
col2(1) TYPE c,
END OF line.
DATA: etab LIKE TABLE OF line WITH HEADER LINE,
ftab LIKE TABLE OF line.
line-col1 = 'A'. line-col2 = 'B'.
APPEND line TO etab.
MOVE etab[] TO ftab.
LOOP AT ftab INTO line.
WRITE: / line-col1, line-col2.
ENDLOOP.
The output is:
A B
The example creates two standard tables ETAB and FTAB with the line type of the structure LINE. ETAB has a header line. After filling ETAB line by line using the APPEND statement, its entire contents are assigned to FTAB. Note the brackets in the statement.
DATA: ftab TYPE SORTED TABLE OF f
WITH NON-UNIQUE KEY table_line,
itab TYPE HASHED TABLE OF i
WITH UNIQUE KEY table_line,
fl TYPE f.
DO 3 TIMES.
INSERT sy-index INTO TABLE itab.
ENDDO.
ftab = itab.
LOOP AT ftab INTO fl.
WRITE: / fl.
ENDLOOP.
The output is:
1.000000000000000E+00
2.000000000000000E+00
3.000000000000000E+00
FTAB is a sorted table with line type F and a non-unique key. ITAB is a hashed table with line type I and a unique key. The line types, and therefore the entire tables, are convertible. It is therefore possible to assign the contents of ITAB to FTAB. When you assign the unsorted table ITAB to the sorted table FTAB, the contents are automatically sorted by the key of FTAB.
In Unicode systems, the following conversion is not allowed:
DATA: BEGIN OF iline,
num TYPE i,
END OF iline,
BEGIN OF fline,
num TYPE f,
END OF fline,
itab LIKE TABLE OF iline,
ftab LIKE TABLE OF fline.
DO 3 TIMES.
iline-num = sy-index.
APPEND iline-num TO itab.
ENDDO.
ftab = itab.
loop AT ftab INTO fline.
WRITE: / fline-num.
ENDLOOP.
In a non-Unicode system, the output may look something like this:
6.03823403895813E-154
6.03969074613219E-154
6.04114745330626E-154
Here, the line types of the internal tables ITAB and FTAB are structures each with one component of type I or F. The line types are convertible, but not compatible. Therefore, when assigning ITAB to FTAB, the contents of Table ITAB are converted to type C fields and then written to FTAB. The system interprets the transferred data as type F fields, so that the results are meaningless. In Unicode systems, you are not allowed to convert numeric fields to fields of type C.
Initializing Internal Tables
Like all data objects, you can initialize internal tables with the
CLEAR .
statement. This statement restores an internal table to the state it was in immediately after you declared it. This means that the table contains no lines. However, the memory already occupied by the memory up until you cleared it remains allocated to the table.
If you are using internal tables with header lines, remember that the header line and the body of the table have the same name. If you want to address the body of the table in a comparison, you must place two brackets () after the table name.
CLEAR , LT, <).
If you are using internal tables with header lines, remember that the header line and the body of the table have the same name. If you want to address the body of the table in a comparison, you must place two brackets () after the table name.
The first criterion for comparing internal tables is the number of lines they contain. The more lines an internal table contains, the larger it is. If two internal tables contain the same number of lines, they are compared line by line, component by component. If components of the table lines are themselves internal tables, they are compared recursively. If you are testing internal tables for anything other than equality, the comparison stops when it reaches the first pair of components that are unequal, and returns the corresponding result.
DATA: BEGIN OF LINE,
COL1 TYPE I,
COL2 TYPE I,
END OF LINE.
DATA: ITAB LIKE TABLE OF LINE,
JTAB LIKE TABLE OF LINE.
DO 3 TIMES.
LINE-COL1 = SY-INDEX.
LINE-COL2 = SY-INDEX ** 2.
APPEND LINE TO ITAB.
ENDDO.
MOVE ITAB TO JTAB.
LINE-COL1 = 10. LINE-COL2 = 20.
APPEND LINE TO ITAB.
IF ITAB GT JTAB.
WRITE / 'ITAB GT JTAB'.
ENDIF.
APPEND LINE TO JTAB.
IF ITAB EQ JTAB.
WRITE / 'ITAB EQ JTAB'.
ENDIF.
LINE-COL1 = 30. LINE-COL2 = 80.
APPEND LINE TO ITAB.
IF JTAB LE ITAB.
WRITE / 'JTAB LE ITAB'.
ENDIF.
LINE-COL1 = 50. LINE-COL2 = 60.
APPEND LINE TO JTAB.
IF ITAB NE JTAB.
WRITE / 'ITAB NE JTAB'.
ENDIF.
IF ITAB LT JTAB.
WRITE / 'ITAB LT JTAB'.
ENDIF.
The output is:
ITAB GT JTAB
ITAB EQ JTAB
JTAB LE ITAB
ITAB NE JTAB
ITAB LT JTAB
This example creates two standard tables, ITAB and JTAB. ITAB is filled with 3 lines and copied to JTAB. Then, another line is appended to ITAB and the first logical expression tests whether ITAB is greater than JTAB. After appending the same line to JTAB, the second logical expression tests whether both tables are equal. Then, another line is appended to ITAB and the third logical expressions tests whether JTAB is less than or equal to ITAB. Next, another line is appended to JTAB. Its contents are unequal to the contents of the last line of ITAB. The next logical expressions test whether ITAB is not equal to JTAB. The first table field whose contents are different in ITAB and JTAB is COL1 in the last line of the table: 30 in ITAB and 50 in JTAB. Therefore, in the last logical expression, ITAB is less than JTAB.
Sorting Internal Tables
You can sort a standard or hashed table in a program. To sort a table by its key, use the statement
SORT ASCENDING .
The statement sorts the internal table ASCENDING
BY ASCENDING
ASCENDING .
The table is now sorted by the specified components : T for standard table, S for sorted table, and H for hashed table.
DATA: BEGIN OF LINE,
COL1 TYPE I,
COL2 TYPE I,
END OF LINE.
DATA ITAB LIKE HASHED TABLE OF LINE WITH UNIQUE KEY COL1
INITIAL SIZE 10.
DATA: LIN TYPE I,
INI TYPE I,
KND TYPE C.
DESCRIBE TABLE ITAB LINES LIN OCCURS INI KIND KND.
WRITE: / LIN, INI, KND.
DO 1000 TIMES.
LINE-COL1 = SY-INDEX.
LINE-COL2 = SY-INDEX ** 2.
INSERT LINE INTO TABLE ITAB.
ENDDO.
DESCRIBE TABLE ITAB LINES LIN OCCURS INI KIND KND.
WRITE: / LIN, INI, KND.
The output is:
0 10 H
1,000 10 H
Here, a hashed table ITAB is created and filled. The DESCRIBE TABLE statement is processed before and after the table is filled. The current number of lines changes, but the number of initial lines cannot change.
INSERT LINE INTO TABLE ITAB.
LINE-TEXT = 'Moller'.
CONVERT TEXT LINE-TEXT INTO SORTABLE CODE LINE-XTEXT.
INSERT LINE INTO TABLE ITAB.
LINE-TEXT = 'Miller'.
CONVERT TEXT LINE-TEXT INTO SORTABLE CODE LINE-XTEXT.
INSERT LINE INTO TABLE ITAB.
SORT ITAB.
PERFORM LOOP_AT_ITAB.
SORT ITAB BY XTEXT.
PERFORM LOOP_AT_ITAB.
SORT ITAB AS TEXT.
PERFORM LOOP_AT_ITAB.
FORM LOOP_AT_ITAB.
LOOP AT ITAB INTO LINE.
WRITE / LINE-TEXT.
ENDLOOP.
SKIP.
ENDFORM.
This example demonstrates alphabetical sorting of character fields. The internal table ITAB contains a column with character fields and a column with corresponding binary codes that are alphabetically sortable. The binary codes are created with the CONVERT statement (see Converting to a Sortable Format). The table is sorted three times. First, it is sorted binarily by the TEXT field. Second, it is sorted binarily by the XTEXT field. Third, it is sorted alphabetically by the TEXT field. Since there is no directly corresponding case in English, we have taken the results from a German text environment:
Miller
Moller
Muller
Möller
Miller
Moller
Möller
Muller
Miller
Moller
Möller
Muller
After the first sorting, 'Möller' follows behind 'Muller' since the internal code for the letter 'ö' comes after the code for 'u'. The other two sorts are alphabetical
The binary sort by XTEXT has the same result as the alphabetical sorting by the field TEXT.
Regards,
Amit
Reward all helpful replies. -
Values r not fetch in internal table
Hi Frds
In my report the values are not fetching in the internal table ICOSP
This is my program ,kindly correct my mistake.
DATA : WBS LIKE VBAK-PS_PSP_PNR.
SELECTION-SCREEN: BEGIN OF BLOCK 01.
SELECTION-SCREEN: BEGIN OF BLOCK 02 WITH FRAME .
SELECT-OPTIONS PROJECT FOR WBS.
SELECTION-SCREEN: END OF BLOCK 02.
SELECTION-SCREEN: END OF BLOCK 01.
DATA: BEGIN OF IVBAK OCCURS 0,
VBTYP LIKE VBAK-VBTYP, "SD document category
AUART LIKE VBAK-AUART, "Sales Document Type
NETWR LIKE VBAP-NETWR, "NET VALUE OF THE ORDER ITEM
WAERK LIKE VBAK-WAERK, "SD document currency
PS_PSP_PNR LIKE VBAP-PS_PSP_PNR, "WBS Element
END OF IVBAK.
DATA: BEGIN OF IPRPS OCCURS 0,
PSPNR LIKE PRPS-PSPNR, "WBS Element
POSID LIKE PRPS-POSID, "WBS Element
OBJNR LIKE PRPS-OBJNR, "Object number
PSPHI LIKE PRPS-PSPHI, "Current project number
END OF IPRPS.
DATA: BEGIN OF ICOSP OCCURS 0,
OBJNR LIKE COSP-OBJNR,
GJAHR LIKE COSP-GJAHR,
WRTTP LIKE COSP-WRTTP,
BEKNZ LIKE COSP-BEKNZ,
WTG001 LIKE COSP-WTG001,
WTG002 LIKE COSP-WTG002,
WTG003 LIKE COSP-WTG003,
WTG004 LIKE COSP-WTG004,
WTG005 LIKE COSP-WTG005,
WTG006 LIKE COSP-WTG006,
WTG007 LIKE COSP-WTG007,
WTG008 LIKE COSP-WTG008,
WTG009 LIKE COSP-WTG009,
WTG010 LIKE COSP-WTG010,
WTG011 LIKE COSP-WTG011,
WTG012 LIKE COSP-WTG012,
WTG013 LIKE COSP-WTG013,
WTG014 LIKE COSP-WTG014,
WTG015 LIKE COSP-WTG015,
WTG016 LIKE COSP-WTG016,
SUM TYPE CURRENCY ,
END OF ICOSP.
*DATA: ICOSP LIKE COSP OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF ITAB OCCURS 0,
PSPNR LIKE VBAK-PS_PSP_PNR,
NETWR LIKE VBAP-NETWR,
END OF ITAB.
PERFORM IVBAK.
PERFORM IPRPS.
PERFORM ICOSP.
PERFORM MOVE_COSP.
PERFORM MOVE.
PERFORM FIELDCATALOG.
PERFORM BUILD_LAYOUT.
PERFORM ALVDISPLAY.
FORM IVBAK.
SELECT VBTYP AUART NETWR WAERK PS_PSP_PNR FROM VBAK INTO TABLE IVBAK
WHERE PS_PSP_PNR IN PROJECT AND
VBTYP = 'G' AND AUART = 'ZPCQ'.
CLEAR: IVBAK.
ENDFORM. "IVBAK
FORM IPRPS.
SELECT PSPNR POSID OBJNR PSPHI FROM PRPS INTO TABLE
IPRPS WHERE PRPS~PSPHI IN PROJECT.
CLEAR : IPRPS.
ENDFORM. "IVBAP
FORM ICOSP.
LOOP AT IPRPS.
SELECT OBJNR GJAHR WRTTP BEKNZ WTG001 WTG002 WTG003 WTG004 WTG005
WTG006 WTG007 WTG008 WTG009 WTG010 WTG011
WTG012 WTG013 WTG014 WTG015 WTG016
FROM COSP INTO CORRESPONDING FIELDS OF TABLE ICOSP
WHERE OBJNR = IPRPS-OBJNR AND WRTTP = '4'.
ENDLOOP.
CLEAR:ICOSP.
ENDFORM.
Thanks
Parihi,
try this Code
DATA : wbs LIKE vbak-ps_psp_pnr.
SELECTION-SCREEN: BEGIN OF BLOCK 01.
SELECTION-SCREEN: BEGIN OF BLOCK 02 WITH FRAME .
SELECT-OPTIONS project FOR wbs.
SELECTION-SCREEN: END OF BLOCK 02.
SELECTION-SCREEN: END OF BLOCK 01.
TYPES: BEGIN OF ivbak,
vbtyp LIKE vbak-vbtyp, "SD document category
auart LIKE vbak-auart, "Sales Document Type
netwr LIKE vbap-netwr, "NET VALUE OF THE ORDER ITEM
waerk LIKE vbak-waerk, "SD document currency
ps_psp_pnr LIKE vbap-ps_psp_pnr, "WBS Element
END OF ivbak.
TYPES: BEGIN OF iprps,
pspnr LIKE prps-pspnr, "WBS Element
posid LIKE prps-posid, "WBS Element
objnr LIKE prps-objnr, "Object number
psphi LIKE prps-psphi, "Current project number
END OF iprps.
TYPES: BEGIN OF icosp,
objnr LIKE cosp-objnr,
gjahr LIKE cosp-gjahr,
wrttp LIKE cosp-wrttp,
beknz LIKE cosp-beknz,
wtg001 LIKE cosp-wtg001,
wtg002 LIKE cosp-wtg002,
wtg003 LIKE cosp-wtg003,
wtg004 LIKE cosp-wtg004,
wtg005 LIKE cosp-wtg005,
wtg006 LIKE cosp-wtg006,
wtg007 LIKE cosp-wtg007,
wtg008 LIKE cosp-wtg008,
wtg009 LIKE cosp-wtg009,
wtg010 LIKE cosp-wtg010,
wtg011 LIKE cosp-wtg011,
wtg012 LIKE cosp-wtg012,
wtg013 LIKE cosp-wtg013,
wtg014 LIKE cosp-wtg014,
wtg015 LIKE cosp-wtg015,
wtg016 LIKE cosp-wtg016,
sum TYPE currency ,
END OF icosp.
*DATA: ICOSP LIKE COSP OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF itab,
pspnr LIKE vbak-ps_psp_pnr,
netwr LIKE vbap-netwr,
END OF itab.
DATA : i_ivbak TYPE STANDARD TABLE OF ivbak,
i_prps TYPE STANDARD TABLE OF iprps,
i_icosp TYPE STANDARD TABLE OF icosp,
wa_ivbak TYPE ivbak,
wa_prps TYPE prps,
wa_icosp TYPE icosp.
PERFORM ivbak.
PERFORM iprps.
PERFORM icosp.
*PERFORM MOVE_COSP.
*PERFORM MOVE.
*PERFORM FIELDCATALOG.
*PERFORM BUILD_LAYOUT.
*PERFORM ALVDISPLAY.
FORM ivbak.
SELECT vbtyp auart netwr waerk ps_psp_pnr FROM vbak
INTO TABLE i_ivbak
WHERE ps_psp_pnr IN project AND
vbtyp = 'G' AND auart = 'ZPCQ'.
ENDFORM. "IVBAK
*& Form IPRPS
* text
FORM iprps.
SELECT pspnr posid objnr psphi
FROM prps INTO TABLE
i_prps WHERE prps~psphi IN project.
ENDFORM. "IVBAP
*& Form ICOSP
* text
FORM icosp.
IF i_prps[] IS NOT INITIAL.
SELECT objnr gjahr wrttp beknz wtg001 wtg002 wtg003 wtg004 wtg005
wtg006 wtg007 wtg008 wtg009 wtg010 wtg011
wtg012 wtg013 wtg014 wtg015 wtg016
FROM cosp INTO CORRESPONDING FIELDS OF TABLE i_icosp
FOR ALL ENTRIES IN i_prps
WHERE objnr = i_prps-objnr AND wrttp = '4'.
ENDIF.
ENDFORM. "ICOSP
Regards
Sandipan -
Bind Variable in SELECT statement and get the value in PL/SQL block
Hi All,
I would like pass bind variable in SELECT statement and get the value of the column in Dynamic SQL
Please seee below
I want to get the below value
Expected result:
select distinct empno ,pr.dept from emp pr, dept ps where ps.dept like '%IT' and pr.empno =100
100, HR
select distinct ename ,pr.dept from emp pr, dept ps where ps.dept like '%IT' and pr.empno =100
TEST, HR
select distinct loc ,pr.dept from emp pr, dept ps where ps.dept like '%IT' and pr.empno =100
NYC, HR
Using the below block I am getting column names only not the value of the column. I need to pass that value(TEST,NYC..) into l_col_val variable
Please suggest
----- TABLE LIST
CREATE TABLE EMP(
EMPNO NUMBER,
ENAME VARCHAR2(255),
DEPT VARCHAR2(255),
LOC VARCHAR2(255)
INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (100,'TEST','HR','NYC');
INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (200,'TEST1','IT','NYC');
INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (300,'TEST2','MR','NYC');
INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (400,'TEST3','HR','DTR');
INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (500,'TEST4','HR','DAL');
INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (600,'TEST5','IT','ATL');
INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (700,'TEST6','IT','BOS');
INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (800,'TEST7','HR','NYC');
COMMIT;
CREATE TABLE COLUMNAMES(
COLUMNAME VARCHAR2(255)
INSERT INTO COLUMNAMES(COLUMNAME) VALUES ('EMPNO');
INSERT INTO COLUMNAMES(COLUMNAME) VALUES ('ENAME');
INSERT INTO COLUMNAMES(COLUMNAME) VALUES ('DEPT');
INSERT INTO COLUMNAMES(COLUMNAME) VALUES ('LOC');
COMMIT;
CREATE TABLE DEPT(
DEPT VARCHAR2(255),
DNAME VARCHAR2(255)
INSERT INTO DEPT(DEPT,DNAME) VALUES ('IT','INFORMATION TECH');
INSERT INTO DEPT(DEPT,DNAME) VALUES ('HR','HUMAN RESOURCE');
INSERT INTO DEPT(DEPT,DNAME) VALUES ('MR','MARKETING');
INSERT INTO DEPT(DEPT,DNAME) VALUES ('IT','INFORMATION TECH');
COMMIT;
PL/SQL BLOCK
DECLARE
TYPE EMPCurTyp IS REF CURSOR;
v_EMP_cursor EMPCurTyp;
l_col_val EMP.ENAME%type;
l_ENAME_val EMP.ENAME%type;
l_col_ddl varchar2(4000);
l_col_name varchar2(60);
l_tab_name varchar2(60);
l_empno number ;
b_l_col_name VARCHAR2(255);
b_l_empno NUMBER;
begin
for rec00 in (
select EMPNO aa from EMP
loop
l_empno := rec00.aa;
for rec in (select COLUMNAME as column_name from columnames
loop
l_col_name := rec.column_name;
begin
l_col_val :=null;
l_col_ddl := 'select distinct :b_l_col_name ,pr.dept ' ||' from emp pr, dept ps where ps.dept like ''%IT'' '||' and pr.empno =:b_l_empno';
dbms_output.put_line('DDL ...'||l_col_ddl);
OPEN v_EMP_cursor FOR l_col_ddl USING l_col_name, l_empno;
LOOP
l_col_val :=null;
FETCH v_EMP_cursor INTO l_col_val,l_ename_val;
EXIT WHEN v_EMP_cursor%NOTFOUND;
dbms_output.put_line('l_col_name='||l_col_name ||' empno ='||l_empno);
END LOOP;
CLOSE v_EMP_cursor;
END;
END LOOP;
END LOOP;
END;user1758353 wrote:
Thanks Billy, Would you be able to suggest any other faster method to load the data into table. Thanks,
As Mark responded - it all depends on the actual data to load, structure and source/origin. On my busiest database, I am loading on average 30,000 rows every second from data in external files.
However, the data structures are just that - structured. Logical.
Having a data structure with 100's of fields (columns in a SQL table), raise all kinds of questions about how sane that structure is, and what impact it will have on a physical data model implementation.
There is a gross misunderstanding by many when it comes to performance and scalability. The prime factor that determines performance is not how well you code, what tools/language you use, the h/w your c ode runs on, or anything like that. The prime factor that determines perform is the design of the data model - as it determines the complexity/ease to use the data model, and the amount of I/O (the slowest of all db operations) needed to effectively use the data model. -
Data overflow in the internal table
Hi Friends,
I am hitting table CDHDR and getting a huge data based on date range and the problem is the internal table is not able to hold the entire data selected and hence it is going for run time error. Could you please suggest an idea to overcome this?
Thanks in advance,
RamHi,
here is the code i have written...
Get all changes to materials in the given date range
SELECT objectclas " Object Class
objectid " Object Value
changenr " Change Document Number
udate " Changed Date
utime " Changed Time
FROM cdhdr
INTO TABLE gt_cdhdr
WHERE objectclas EQ c_clas_material
AND udate IN s_date.
Regards,
Ram -
How to Pass the Internal table of a report to Smart Form
Hi Experts,
I have one report in which from selection screen i am getting the values from the users, and upon that values i am filling data in to the internal table.
Now i want to pass that internal table data to the smart form
and print that data in the smart form.
So could you pls give me some pseudo code or any steps to achieve it.
Thanks & Regards,
DSHi DS,
First of all you need to create a SF and then need to call the FM generated by the FM in your report.
In the SF in the form interface>tables tab>mention the name of the table and its type structure.
Pls note that a new structure has to be created as the same type of your internal table which holds the data.
And the import and export parameters as just the same as in a FM.
Now after you create and activate your SF a FM will be generated (wen u execute your SF you will be taken to this SE37 screen with the name of FM so no probs..)
You can call this FM in your report. Hope this helps.
Ex:
say itab has your final data, and you also want to export a variable var1 to the SF.
after your normal report operations end, call the FM and pass on these data.
say your FM name is FM1.
call function FM1
exporting
var1 = var1
tables
itab1 = itab1.
pls note that in the SF also i gave the same names, it is not mandatory to give the same names.
and as you want to print a table in the smartforms, you need to create a table in the smart forms and then display the data which is quite simple.
Hope this helps...
if you need any further explanations, pls revert...
Regards,
Narendra.
Reward points if helpful!!! -
How to export internal table and pass the internal table to another screen?
Hi,
I have a sql SELECT statement that select data from table into internal table. I would like to export out the internal table and pass to another screen and display the data in ALV list. How to export it out? I try but the error given was " The type of "OUT_SELECT_ITAB" cannot be converted to the type of "itab_result".
Another question is, how to pass the internal table that i export out from the function module to another screen?
Here is the code
==============================================================
FUNCTION ZNEW_SELECT_ZSTUD00.
""Local Interface:
*" IMPORTING
*" REFERENCE(IN_SELECT_YEAR) TYPE ZSTUD00-EYEAR
*" EXPORTING
*" REFERENCE(OUT_RESULT) TYPE CHAR9
*" REFERENCE(OUT_SELECT_ITAB) TYPE ZSTUD00
*& Global Declarations
DATA: itab TYPE ZSTUD00,
itab_result TYPE TABLE OF ZSTUD00.
*& Processing Blocks called by the Runtime Environment
itab-eyear = IN_SELECT_YEAR.
SELECT *
FROM ZSTUD00
INTO TABLE itab_result
WHERE eyear = IN_SELECT_YEAR.
IF sy-subrc = 0.
out_result = 'Success'.
OUT_SELECT_ITAB = itab_result.
ELSE.
out_result = 'Fail'.
ENDIF.
ENDFUNCTION.
===============================================================
Please advise. Thanks
Regards,
RaydenHi Nagaraj,
I try to change it in Tables tab page but it state that TABLES parameters are obsolete. when i "Enter". I try to "Enter" again. it seem to be ok but it stil give me the same error.
================================================================
FUNCTION ZNEW_SELECT_ZSTUD00.
""Local Interface:
*" IMPORTING
*" REFERENCE(IN_SELECT_YEAR) TYPE ZSTUD00-EYEAR
*" EXPORTING
*" REFERENCE(OUT_RESULT) TYPE CHAR9
*" TABLES
*" OUT_SELECT_ITAB STRUCTURE ZSTUD00
*& Global Declarations
DATA: itab TYPE ZSTUD00,
itab_result TYPE TABLE OF ZSTUD00.
*& Processing Blocks called by the Runtime Environment
itab-eyear = IN_SELECT_YEAR.
SELECT *
FROM ZSTUD00
INTO TABLE itab_result
WHERE eyear = IN_SELECT_YEAR.
IF sy-subrc = 0.
out_result = 'Success'.
OUT_SELECT_ITAB = itab_result.
ELSE.
out_result = 'Fail'.
ENDIF.
ENDFUNCTION.
===============================================================
regards,
Rayden
Maybe you are looking for
-
Hello, I've been reading some threads on the "Other" storage problem that people are having with their iOS devices. I have an iPhone 5 with 16Gb of space and I could get the "Other" storage down from 2.67Gb to 2.22Gb by backing up the phone to the co
-
CSA_ORDER_4000* - Queue generation
Dear Friends, I would like to know about the queue generation happening from CRM to R/3 Say if i create a order in CRM enterprise automatically system finds the Bdoc type BUS_TRANS_MSG based on the adapter maintaiend in R3ac1 and generates the
-
How to install Flex plugin for Eclipse?
Hello All, I am a new user of Flex. I would like to install Flex Framework as part of Eclipse, but I have installation problems with it I have downloaded and installed the plugin from here: http://www.adobe.com/cfusion/search/index.cfm?term=Eclipse+p
-
Hi, I am new to oracle , i have a doubt : I have written a query using analytical functions to get the desired , but i wanted the same in a normal query . INPUT TABLE : NAME AMOUNT A 100 A 200 A 300 B 200 B 300 C 300 Query : SELECT name,AMOUNT,ROW_NU
-
Why I press button only once, but it executes 2-4 times??
Dear Sir: I used following code in a project, when I press buttonTest only once, looks like it execues 2 or three times. and it outputs: I am testing I am Calling a new testing I am testing I am Calling a new testing Class myButtonTest(){ publi