Internal table with out header line
Hi friends,
Can u send me code for internal table with out header line : how to declare ,how to populate data and how to access the data
Regards,
vijay
Hi Vijay
There are several ways to declare an internal table without header line:
A) You can define a type table
TYPES: BEGIN OF TY_ITAB OCCURS 0,
INCLUDE STRUCTURE ZTABLE.
TYPES: END OF TY_ITAB.
and then your intrnal table:
DATA: ITAB TYPE TY_ITAB.
B) DATA: ITAB TYPE/LIKE STANDARD TABLE OF ZTABLE.
C) DATA: ITAB TYPE/LIKE ZTABLE OCCURS 0.
All these ways create a STANDARD TABLE
You can create other types of internal table, for example SORTED TABLE or HASHED TABLE.
These kinds of table can allow to improve the performance because they use different rules to read the data.
When it wants to manage a table without header line, it need a work area, it has to have the same structure of table.
DATA: WA LIKE ZTABLE.
DATA: T_ZTABLE LIKE STANDARD TABLE OF ZTABLE.
A) To insert the record:
If you use INTO TABLE option you don't need workarea
SELECT * FROM ZTABLE INTO TABLE T_ZTABLE
WHERE FIELD1 = 'Z001'
AND FIELD2 = '2006'.
but if you want to append a single record:
SELECT * FROM ZTABLE INTO wa WHERE FIELD1 = 'Z001'
AND FIELD2 = '2006'.
APPEND WA TO T_ZTABLE.
ENDSELECT.
Now you need workarea.
B) To read data: you need always a workarea:
LOOP AT T_ZTABLE INTO WA WHERE ....
WRITE: / WA-FIELD1, WA-FIELD2, WA-FIELD3.
ENDLOOP.
or
READ T_ZTABLE INTO WA WITH KEY FIELD3 = '0000000001'.
IF SY-SUBRC = 0.
WRITE: / WA-FIELD1, WA-FIELD2, WA-FIELD3.
ENDIF.
Anyway if you want to know only if a record exists, you can use the TRANSPORTING NO FIELDS option, in this case it doesn't need a workarea.
READ T_ZTABLE WITH KEY FIELD3 = '0000000001'
TRANSPORTING NO FIELDS.
IF SY-SUBRC = 0.
WRITE 'OK'.
ENDIF.
C) To update the data: it always needs a workarea
LOOP AT T_ZTABLE INTO WA WHERE FIELD3 = '0000000001'.
WA-FIELD3 = '0000000002'.
MODIF T_ZTABLE FROM WA.
ENDLOOP.
or
READ T_ZTABLE INTO WA WITH KEY FIELD3 = '0000000001'.
IF SY-SUBRC = 0.
WA-FIELD3 = '0000000002'.
MODIF T_ZTABLE FROM WA INDEX SY-TABIX
ENDIF.
AT the end you can use the internal table to update database:
MODIFY/UPDATE/INSERT ZTABLE FROM T_ZTABLE.
See Help online for key words DATA, you can find out more details.
Max
Message was edited by: max bianchi
Similar Messages
-
How to sort an internal table with a header line?
hi all,
i have declared table i_bseg type standard table of bseg with header line.
now i have populated data in i_bseg.
now i am sorting it by bukrs
ie i am writing sort i_bseg by bukrs.
before sorting all i_bseg-belnrs were populated...
but after sorting the contents of the i_bseg is changing.
some of the belnrs are getting deleted..
is there any special way to sort an internal table with header line...?hi,
<b>SORT <itab> [ASCENDING|DESCENDING] [AS TEXT] [STABLE].</b>
The statement sorts the internal table <itab> in ascending order by its key.<b> The statement always applies to the table itself, not to the header line</b>.
If you have an internal table with a structured line type that you want sort by a different key, you can specify the key in the SORT statement:
SORT <itab> [ASCENDING|DESCENDING] [AS TEXT] [STABLE]
BY <f1> [ASCENDING|DESCENDING] [AS TEXT]
<fn> [ASCENDING|DESCENDING] [AS TEXT].
<b>this is your sort statement: sort i_bseg by bukrs.
you try with this statement: sort i_bseg by bukrs STABLE.</b>
regards,
Ashokreddy -
Lt_item_type is a table with out header line and therefore has no component
Dear frnds,
I am new to webdynpro i got this error while creating a tree .can any body tell me what is the mistake i have done.
Regards.
sivaHi,
As you are new to the tree concepts.Try to do this tutorial.It will give a idea.
[Tree|http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/d075dbc5-3b33-2c10-5f9f-99bf2738fe6a?QuickLink=index&overridelayout=true]
Regards,
Karthik.R -
With header line & with out header line ?
what is difference between with header line & without header line ?
When you create an internal table object you can also declare a header line with the same name. You can use the header line as a work area when you process the internal table. The ABAP statements that you use with internal tables have short forms that you can use if your internal table has a header line. These statements automatically assume the header line as an implicit work area. The following table shows the statements that you must use for internal tables without a header line, and the equivalent statements that you can use for internal tables with a header line:
Operations without header line
Operations with header line
Operations for all Table Types
INSERT <wa> INTO TABLE <itab>.
INSERT TABLE ITAB.
COLLECT <wa> INTO <itab>.
COLLECT <itab>.
READ TABLE <itab> ... INTO <wa>.
READ TABLE <itab> ...
MODIFY TABLE <itab> FROM <wa> ...
MODIFY TABLE <itab> ...
MODIFY <itab> FROM <wa> ...WHERE ...
MODIFY <itab> ... WHERE ...
DELETE TABLE <itab> FROM <wa>.
DELETE TABLE <itab>.
LOOP AT ITAB INTO <wa> ...
LOOP AT ITAB ...
Operations for Index Tables
APPEND <wa> TO <itab>.
APPEND <itab>.
INSERT <wa> INTO <itab> ...
INSERT <itab> ...
MODIFY <itab> FROM <wa> ...
MODIFY <itab> ...
Using the header line as a work area means that you can use shorter statements; however, they are not necessarily easier to understand, since you cannot immediately recognize the origin and target of the assignment. Furthermore, the fact that the table and its header line have the same name can cause confusion in operations with entire internal tables. To avoid confusion, you should use internal tables with differently-named work areas.
The following example shows two programs with the same function. One uses a header line, the other does not.
With header line:
TYPES: BEGIN OF LINE,
COL1 TYPE I,
COL2 TYPE I,
END OF LINE.
DATA ITAB TYPE HASHED TABLE OF LINE WITH UNIQUE KEY COL1
WITH HEADER LINE.
DO 4 TIMES.
ITAB-COL1 = SY-INDEX.
ITAB-COL2 = SY-INDEX ** 2.
INSERT TABLE ITAB.
ENDDO.
ITAB-COL1 = 2.
READ TABLE ITAB FROM ITAB.
ITAB-COL2 = 100.
MODIFY TABLE ITAB.
ITAB-COL1 = 4.
DELETE TABLE ITAB.
LOOP AT ITAB.
WRITE: / ITAB-COL1, ITAB-COL2.
ENDLOOP.
Without header line:
TYPES: BEGIN OF LINE,
COL1 TYPE I,
COL2 TYPE I,
END OF LINE.
DATA: ITAB TYPE HASHED TABLE OF LINE WITH UNIQUE KEY COL1,
WA LIKE LINE OF ITAB.
DO 4 TIMES.
WA-COL1 = SY-INDEX.
WA-COL2 = SY-INDEX ** 2.
INSERT WA INTO TABLE ITAB.
ENDDO.
WA-COL1 = 2.
READ TABLE ITAB FROM WA INTO WA.
WA-COL2 = 100.
MODIFY TABLE ITAB FROM WA.
WA-COL1 = 4.
DELETE TABLE ITAB FROM WA.
LOOP AT ITAB INTO WA.
WRITE: / WA-COL1, WA-COL2.
ENDLOOP.
The list, in both cases, appears as follows:
1 1
2 100
3 9
The statements in the program that does not use a header line are easier to understand. As a further measure, you could have a further work area just to specify the key of the internal table, but to which no other values from the table are assigned.
Internal table with header line
you can use anywhere except obkect oriented concept.
Internal table without header line :
You should use in Object oriented concept..
Always try to use without header line,performance point of view it is best..
Example :
Without header line.
Structure
types : begin of ty_itab ,
matnr type mara-matnr,
end of ty_itab.
Internal table
data i_itab type standard table of ty_itab .
Work area
data wa_itab like line of i_itab
With header line
data : begin of i_itab occurs 0,
matnr like mara-matnr,
end of i_itab
itab with header lines are obsolete, anyway it will work but not recommended. instead use work area or more effiecient is field symbols. so donot use itab with header line.
i will explain use of itab w/o header line.
Data: itab1 type standard table of mara with header line occurs 0,
itab2 type standard table of mara,
wa_itab2 type mara.
loop at itab1.
"This will work fine.
endloop.
loop at itab2.
"This will give erro that itabd does not hav workarea
endloop.
"so write
loop at itab2 into wa_itab2.
"This will work
endloop.
<b>The difference between
whih header line and with out heater line of internal table.
ex:-
a) Data : itab like mara occurs 0 with header line.
b) Data: itab like mara occurs 0.
-While adding or retrieving records to / from internal table we have to keep the record temporarily.
-The area where this record is kept is called as work area for the internal table.
-The area must have the same structure as that of internal table. An internal table consists of a body and an optional header line.
-Header line is a implicit work area for the internal table. It depends on how the internal table is declared that the itab will have the header line or not.
a) Data : itab like mara occurs 0 with header line.
table is with header line
b) Data: itab like mara occurs 0.
table is without header line</b>
regards,
srinivas
<b>*reward for useful answers*</b> -
Download alv report output to excel format with out header line
Hi experts,
i want to download a alv report output into excel formatt with out the header line but it has to download including field description. as this output will fed into another transaction, the downloaded excel file should be with out header line.
fro eg:
Report : Zabc ABAP Development Page : 1
Run Date : 12/14/06 System: UD400
Run Time : 08:45:37
this header details should not be downloaded into the excel file.
could somebody help me please.
thanks
deepuhi jayanti,
thanks for your response.
i have delclared all the field types as character but still it is not downloading and it 's sy-subrc is 4... the code is as below.
*field names
lt_fieldnames-value = 'Material Number'.
APPEND lt_fieldnames.
lt_fieldnames-value = 'Plant'.
APPEND lt_fieldnames.
lt_fieldnames-value = 'Material Group'.
APPEND lt_fieldnames.
lt_fieldnames-value = 'Material Description'.
APPEND lt_fieldnames.
lt_fieldnames-value = 'UOM'.
APPEND lt_fieldnames.
lt_fieldnames-value = 'Price Unit'.
APPEND lt_fieldnames.
lt_fieldnames-value = 'Material Type'.
APPEND lt_fieldnames.
lt_fieldnames-value = 'X-Plant Status'.
APPEND lt_fieldnames.
lt_fieldnames-value = 'Valuation Class'.
APPEND lt_fieldnames.
lt_fieldnames-value = lw_avmng.
APPEND lt_fieldnames.
lt_fieldnames-value = lw_avntp.
APPEND lt_fieldnames.
lt_fieldnames-value = 'Latest PO Qty'.
APPEND lt_fieldnames.
lt_fieldnames-value = 'Latest PO Cost'.
APPEND lt_fieldnames.
lt_fieldnames-value = 'PO Creation Date'.
APPEND lt_fieldnames.
lt_fieldnames-value = lw_fcaqt.
APPEND lt_fieldnames.
lt_fieldnames-value = 'Prev. Yr. Std. Cost'.
APPEND lt_fieldnames.
lt_fieldnames-value = lw_stcst.
APPEND lt_fieldnames.
CALL FUNCTION 'MS_EXCEL_OLE_STANDARD_DAT'
EXPORTING
file_name = 'XLSHEET'
CREATE_PIVOT = 0
DATA_SHEET_NAME = ' '
PIVOT_SHEET_NAME = ' '
PASSWORD = ' '
PASSWORD_OPTION = 0
TABLES
PIVOT_FIELD_TAB =
data_tab = t_output1
fieldnames = lt_fieldnames
EXCEPTIONS
file_not_exist = 1
filename_expected = 2
communication_error = 3
ole_object_method_error = 4
ole_object_property_error = 5
invalid_pivot_fields = 6
download_problem = 7
OTHERS = 8
IF sy-subrc <> 0.
MESSAGE e001 WITH 'Data could not be downloaded'.
ENDIF.
ENDFORM. " z_dwn_xl
thanks
deepu -
I want to create an internal table without using header line and occurs 0?
hi experts,
Can anybody help me to declare an internal table without using headerline and occurs 0 options but still i have to use the functionalities that occurs 0 and header line options provide.Hi Saisri,
You can use the internal table without headerline and create a header for then internal table with the same structure. We need to use the header while manipulating with the data of the internal table.
example:
types: begin of ty_afpo,
kdauf type kdauf,
kdpos type kdpos,
ltrmp type ltrmp,
end of ty_afpo.
data : t_afpo type standard table of ty_afpo, " internal table declaration
wa_afpo type ty_afpo. " work area declaration
<after populating the data into the internal table>
loop at t_afpo into wa_afpo.
write:/ wa_afpo-kdauf, wa_afpo-kdpos, wa_afpo-ltrmp.
endloop.
This I think shall give you a basic understanding of how things work.
<b>Reward points if this helps,</b>
Kiran -
Accessing a field from a structure with out header line
Hi Guys,
I am trying to assign a field from a structure type line of data to another field.
This structure type line don't have a header line.
here is the example.
IT_EKKNU TYPE MMPUR_EKKNU.
when I use following statement..
move IT_EKKNU-kostl to e_cekko-kostl.
Iam getting error "IT_ENKKNU is not a structure or Internal table with header line.
How to access the fields in structure IT_EKKNU.
Thank U for ur time.
Cheers
S KumarHere IT_EKKNU is an internal table without Header line.
You can use a structure for assignment.
DATA: IT_EKKNU TYPE MMPUR_EKKNU,
wa_ekknu type ekknu.
read table it_ekknu into wa_ekknu........
move wa_EKKNU-kostl to e_cekko-kostl.
*modify the code for your conditions*. -
Dynamic internal table with dynamic header
Hi Members,
I have created a dynamic report ie In the selection screen i will give set of GL accounts.
Based on the GL it will separate a col like Sales GL, PF GL , Discount Gl etc. In the header portion first 3 col is constant ie it will show the vendor name and material and text remaining col is based on the GL entered in the screen it will cumulate the Total Amount and display accordingly.
This is working fine in ALV grid display, but i required to download the data to excel , while downloading to excel i am getting only the values without header,
ie title of the each col not getting . kindly guide me to solve this issue.
If i entered only sales GLs (100,101,102 ) then my output should be
vendor material mateial text 100 101 102
ddddd 11100 Raw salt 2000 1000 2500
Regards,
Mee.SHi Meenakshi,
As per my knowledge two ways of doing it...
1. when u get the final internal table..check for the fields with not initial...again update the header internal table dynamically..
2. if you get GL or PF or any such thing you can hardcode the header and display it on to excel..
Regards,
Vamshi -
How to fetch the data to the internal table with out using mandt
Hi all,
Iam giving my code please observer... and give me the reasonable solution.
t_mar LIKE STANDARD TABLE OF z_mar.
SELECT mandt
werks " Plant
lifnr " Vendor
FROM z_mar
INTO TABLE t_mar
where sal = 2000.
By removing MANDT from select query, it is going to dump.
ex:
SELECT
werks " Plant
lifnr " Vendor
FROM z_mar
INTO TABLE t_mar
where sal = 2000.
> Now it is going to dump ( here i removed the mandt field ).
Please give me a solution to fetch the data by removing mandt in select statement, with out chaning the internal table structure.
Thanks,
Ravihi Ravi,
i also had to avoid move-corresponding and the following is what i did...its extra work and goes around but it will
do the needed work..............
t_mar LIKE STANDARD TABLE OF z_mar.
SELECT *
FROM z_mar
INTO TABLE t_mar
where sal = 2000.
the above gets you all the fields ...but if you still want to narrow it down to just two fields
*****Declaring structure with 2 fields
data:begin of fs_data.
data:werks type z_mar-werks,
lifnr type z_mar-lifnr ,
data:end of fs_data.
*******internal table of above
data:int_data like fs_data occurs 0 with headerline.
*****moving the only 2 required fields
loop at t_mar.
t_mar-werks = int_data-werks.
t_mar-lifnr = int_data-lifnr.
append int_data.
endloop.
Hope you found it useful...
Regards
Bx -
Intenal table with out headerline
hi,
i have a doubt,please clarify.
data:itab like <databse table> occurs 0 with header line.
or
data:itab like <databse table>occurs 0,
wa like line type of itab.
in above two cases , in my view no difference.
in first case there will be one workarea will be created with same name itab,
in second case we are explicitly creating work area.
ok.
here my doubt is in what cases it is madatory to create internal table with explicitly work area?
thanks in advance.
venuhi,
abap object oriented programming in higher versions doesn't allow internal table with header line, so we can create internal table with out header line.
for that one we follow two approches...
1)
TYPES: BEGIN OF LINE,
COL1 TYPE I,
COL2 TYPE I,
END OF LINE.
DATA : ITAB TYPE STANDARD TABLE OF LINE,
WA TYPE LINE.
2) In second case create line type(structure) and row type by using SE11.
SE11->select DATA ELEMENT object> here select STRUCTURE object and provide required fields>now select ROW TYPE object here provide LINE TYPE( STRCTURE which is created in previous)-> SAVE and activate.
IN the above case STRCTURE acts as WORK-AREA AND ROW TYPE acts as body.
object oriented programming doesn't support to using LIKE key word.
regards,
Ashok -
How to move field symbol internal table to internal table with header line?
Dear all,
hi...hereby i would like to ask how i can move field symbol internal table to a internal table?
as i know field symbol internal table is without header line..
so, may i know how to do this....to move field symbol internal table to internal table which consist of header line and field and record will same as field symbol internal table...in additional, my field symbol internal table is dynamic table mean everytime will have flexible columns..?
Please advise...
Thanks
Regard,
ToToRo.
Edited by: @ToToRo@ on Aug 20, 2009 6:16 AMHello,
Try this way:
If both the type of internal tables are same then you can directly assign dynamic internal table to static internal table.
itab = <itab>.
Suppose you have field symbol internal table <itab> which is different in structure from ITAB.
Now, you can create <wa> as follow:
FIELD-SYMBOLS <wa>.
DATA wa TYPE REF TO DATA.
CREATE DATA wa TYPE LINE OF <itab>.
ASSIGN wa->* to <wa>.
This way your work area is read.
Using [ASSIGN COMPONENT|http://help.sap.com/saphelp_nw04/helpdata/EN/fc/eb3923358411d1829f0000e829fbfe/content.htm] syntax you can read required component of <wa>.
Finally you can use that value to load static internal table.
You can also refer to my thread on [Dynamic table|Re: Creating Dynamic table].
Hope this helps!
Thanks,
Augustin.
Edited by: Augustarian on Aug 20, 2009 10:06 AM -
Downloading the internal table with header to FTP folder
Hi All,
I have one requirement in downloading the internal table details with the fixed header line to FTP folder. The header line having the fixed text of 425 characters length.
Note: We are not suppose to use WS_DOWNLOAD and GUI_DOWNLOAD function modules.
Thanks in advance for your reply.
Regards
Kamini.Hi,
I can download the internal table details successfully to FTP folder using the FTP function modules like(FTP_CONNECT, FTP_COMMAND , FTP_R/3_TO_SERVER and FTP_DISCONNECT). Here my problem is I am unable to download the internation table with some header text.
You can see the format (example) of file to be download.
Here I can successfully download the below details without the header. But I am unable to download with header line. Could you please suggest me.
seq_no|record_action|trans_date|sku|description|
1|N|2008-01-03 07:52:31|TTASA5025CBO
2|N|2008-01-03 10:28:33|411014
3|N|2008-01-03 10:01:03|TTASA6030CBO
4|N|2008-01-03 10:01:15|TTASA6630CBO
5|N|2008-01-03 10:01:25|TTASA7035CBO
6|N|2008-01-08 16:57:39|TT6G
Regards
Kamini. -
Internal table with header line
Hi All,
I want to declare a internal table with headerline as page attribute.
i am having to fields in the internal table ( firstname and lastname ). how to do that?
helpful answers will be rewarded.
Regards,
Azaz Ali.Azaz,
Why do you need a header line?
Header lines are a no-no in an object context and if you need to loop at the table you can always declare a line type or an field symbol to process the table.
If you need an table as a page parameter the best way to do it is to create a table type. This is based of a line type (another name for structure ) and this may well be based off a database (transparent) table.
If you need to do special things to the table I would look at tableview iterators.
Let me dig out a blog reference for that...
... ahh here it is
<a href="/people/thomas.jung3/blog/2004/06/17/bsp-150-a-developer146s-journal-part-i-introduction View Iterator blog</a>
HTH,
N -
WHEN DO U NEED CREATE AN INTERNAL TABLE WITH HEADERLINE AND WITH OUT HEADER
HI
EXPERTS CAN U HELP ME FOR THISHi,
PLEASE CHECK OUT THE LINK BELOW FOR INTERNAL TABLE WITH HEADER LINE IT MIGHT HELP YOU
http://sap.mis.cmich.edu/sap-abap/abap04/sld012.htm
PLEASE CHECK OUT THE LINK BELOW FOR INTERNAL TABLE WITHOUT HEADER LINE IT MIGHT HELP YOU
http://sap.mis.cmich.edu/sap-abap/abap04/sld013.htm
DIFFERENCES BEWTEEN WORK AREA AND HEADER LINE PLEASE CHECK OUT THE LINK BELOW IT MIGHT HELP YOU
http://www.sap-img.com/abap/difference-between-work-area-and-header-line.htm
*************please reward points if the information is helpful to you*********** -
Getting error of Defining an internal table with header line, SELECT-OPTIO
Hi all,
i have a coding for my smart form,In this coding i have define an structure which being used,but when i execute it it give me
error of Defining an internal table with header line, SELECT-OPTIONS, and RANGES is not allowed within a structure.Even tough you can see that in my coding im not using SELECT-OPTION or RANGES,but can't understand why it gives me this error.
Following are the code:
DATA: BEGIN OF traptab OCCURS 50.
INCLUDE STRUCTURE mseg.
DATA: vgart LIKE mkpf-vgart,
blart LIKE mkpf-blart,
blaum LIKE mkpf-blaum,
bldat LIKE mkpf-bldat,
budat LIKE mkpf-budat,
cpudt LIKE mkpf-cpudt,
cputm LIKE mkpf-cputm,
aedat LIKE mkpf-aedat,
usnam LIKE mkpf-usnam,
tcode LIKE mkpf-tcode,
xblnr LIKE mkpf-xblnr,
bktxt LIKE mkpf-bktxt,
frath LIKE mkpf-frath,
frbnr LIKE mkpf-frbnr,
wever LIKE mkpf-wever,
END OF traptab.
Thanks & Regards,
sappk25thanks
Maybe you are looking for
-
Hi all Thank you to every one for giving support who are really needs..... Here i have a small query that goes like this Iam converting a web page from english version to chinees version This is a struts application In one jsp page i have 2 text file
-
Screen capture of the front panel automatically
I've got a VI that analyzes a data file and outputs a graph, some numbers/notes, and a pass/fail message to the front panel each time we run it. I want to be able to automatically save all that data into one easy-to-access file (no html) after runnin
-
Hello All, Please let me know the transaction change history table in CRM. Kindly help. Regards DJ
-
Oracle Internal Error????
Hi, I am getting the following error in PL/SQL procedure in which i have used XMLDB. ERROR: ORA-21500: internal error code, arguments: [%s], [%s], [%s], [%s], [%s], [%s], [%s], [%s] What does that mean? more importantly how do resolve this error?
-
Hey guys, first...Happy thanksgiving :) Ok, so I'm on my last assignment for my amazingly taught Data Structures class. I battled my way successfully through recursion, binary trees, redblack trees, 234 trees, B Trees, and heaps!...no issues at all!.