Internal table declaration -OO ABAP
Hi,
I am looking to declare an internal table using OO objects. My declaration are as follows..
TYPES : Begin of itab,
f1 type c,
f2 type c,
End of itab.
DATA : itab1 type standard table of itab.
DATA: wa_tab type itab.
I have an internal table to say itab_pa2001 which i am reading all the records of pernr into ITAB_PA2001.To get the text i want to select * from t5*** into ..... Finally wht am looking is to move some of the fields into the final table ITAB. Could you please let me know how to set this up as i am getting wrong values when i am looping as below.
how to declare a structure in ITAB using ABAP OO....??
LOOP at ITAB_PA2001 into wa_itab.
ENDLOOP.
Thanks,
Vind
Hi,
Please refer to following links :
[How to declare an internal table in OO-ABAP programming? |Re: How to declare an internal table in OO-ABAP programming?;
[sample object oriented ABAP program |http://wiki.sdn.sap.com/wiki/display/Snippets/sampleobjectorientedABAPprogram]
Hope this helps.
Regards,
Chandravadan
Similar Messages
-
DIFF: Field string ,Structure and Internal table declaration
Hai,
what is the diference between Field string ,Structure in ABAP program and Internal table declaration and how it will work ?
Thank you
ASHOK KUMAR.hi,
Look this u will get a good idea.
*& Report ZTYPES *
REPORT ZTYPES .
* Table declaration (old method)
DATA: BEGIN OF tab_ekpo OCCURS 0, "itab with header line
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
END OF tab_ekpo.
*Table declaration (new method) "USE THIS WAY!!!
TYPES: BEGIN OF t_ekpo,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
END OF t_ekpo.
DATA: it_ekpo TYPE STANDARD TABLE OF t_ekpo INITIAL SIZE 0, "itab
wa_ekpo TYPE t_ekpo. "work area (header line)
* Build internal table and work area from existing internal table
DATA: it_datatab LIKE tab_ekpo OCCURS 0, "old method
wa_datatab LIKE LINE OF tab_ekpo.
* Build internal table and work area from existing internal table,
* adding additional fields
TYPES: BEGIN OF t_repdata.
INCLUDE STRUCTURE tab_ekpo. "could include EKKO table itself!!
TYPES: bukrs TYPE ekpo-werks,
bstyp TYPE ekpo-bukrs.
TYPES: END OF t_repdata.
DATA: it_repdata TYPE STANDARD TABLE OF t_repdata INITIAL SIZE 0, "itab
wa_repdata TYPE t_repdata. "work area (header line)
Regards
Reshma -
Internal table declaration - work area and body
Hi all
I have declared my internal table in my program as
data : itab_wa type ZRESULT_LINE,
itab type ZRESULT_ROW.
Where ZRESULT_LINE and ZRESULT_ROW are the structure and table types.
Now I want to add
data: TCOLOR TYPE SLIS_T_SPECIALCOL_ALV.
in my internal table declaration. How can I do this. Please remember I need to have work area and body in my internal table as I have used work area and body in my code.
Waiting..............
Message was edited by: Raju BodaHI,
See the Declarion types of workarea and Internal tables
* Table declaration (old method)
DATA: BEGIN OF tab_ekpo OCCURS 0, "itab with header line
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
END OF tab_ekpo.
*Table declaration (new method) "USE THIS WAY!!!
TYPES: BEGIN OF t_ekpo,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
END OF t_ekpo.
DATA: it_ekpo TYPE STANDARD TABLE OF t_ekpo INITIAL SIZE 0, "itab
wa_ekpo TYPE t_ekpo. "work area (header line)
* Build internal table and work area from existing internal table
DATA: it_datatab LIKE tab_ekpo OCCURS 0, "old method
wa_datatab LIKE LINE OF tab_ekpo.
* Build internal table and work area from existing internal table,
* adding additional fields
TYPES: BEGIN OF t_repdata.
INCLUDE STRUCTURE tab_ekpo. "could include EKKO table itself!!
TYPES: bukrs TYPE ekpo-werks,
bstyp TYPE ekpo-bukrs.
TYPES: END OF t_repdata.
DATA: it_repdata TYPE STANDARD TABLE OF t_repdata INITIAL SIZE 0, "itab
wa_repdata TYPE t_repdata. "work area (header line
you need to maintain same structure for both workarea as well Internal table
Regards
Sudheer -
Use Internal table in WebDynpro ABAP.
Hi,
I am using a internal table, for calling a FM, which require Internal table as its parameter. Since Internal table with header line is not supported in ABAP OO. How to attain this.
Thanq For Ur time.
Cheers,
SamHi Sam,
If we want to use an internal table for the FM as input then we can declare a table and use it.
But when we want use it as a workarea we need to define a work area (another attribute) of a internal table saparatly and use it.
Best regards,
Suresh -
What is the difference between 'OCCURS 0' addition and 'INITIAL SIZE' .
CASE I :(Declaration With 'OCCURS 0' addition)
DATA:BEGIN OF I_TAB OCCURS 0,
NAME(5) TYPE C,
AGE(2) TYPE C,
END OF I_TAB.
CASE II :(Declartion with inital size)
TYPES:BEGIN OF T_TAB,
NAME(5) TYPE C,
AGE(2) TYPE C,
END OF T_TAB.
DATA:I_TAB TYPE STANDARD TABLE OF T_TAB INITIAL SIZE 0.
In the above cases which case is efficient for declaring internal table ?
Moderator message: please read ABAP documentation before posting.
Edited by: Thomas Zloch on Jun 27, 2011 4:23 PMWhat is the difference between 'OCCURS 0' addition and 'INITIAL SIZE' .
CASE I :(Declaration With 'OCCURS 0' addition)
DATA:BEGIN OF I_TAB OCCURS 0,
NAME(5) TYPE C,
AGE(2) TYPE C,
END OF I_TAB.
CASE II :(Declartion with inital size)
TYPES:BEGIN OF T_TAB,
NAME(5) TYPE C,
AGE(2) TYPE C,
END OF T_TAB.
DATA:I_TAB TYPE STANDARD TABLE OF T_TAB INITIAL SIZE 0.
In the above cases which case is efficient for declaring internal table ?
Moderator message: please read ABAP documentation before posting.
Edited by: Thomas Zloch on Jun 27, 2011 4:23 PM -
How to upload XML file into the internal table in Webdynpro ABAP ?
Hi Friends,
I am not able to upload the XML file into ABAP,can you please help me in solving this issue with the help of source code.
Regards
DineshHi Dinesh,
Try go through this program which I had developed earlier. It takes as input an XML file and then breaks it down into name-value pairs of an intrnal table. You need to pass an XML file as input to this program. (I had hard coded the path for my XML file in it. You need to replace it with 1 of your own or you can just delete it and use the browse button to selet the file on your PC)
Regards,
Uday
REPORT ZUDAY_XML no standard page heading.
" Internal table to store the XML file in binary mode
data: begin of it_xml occurs 1,
c(255) type x,
end of it_xml,
" Name-value pairs table rturned by FM SMUM_XML_PARSE
it_SMUM_XMLTB type SMUM_XMLTB occurs 0 with header line,
" Table returned by FM SMUM_XML_PARSE for error handling
it_bapiret2 type bapiret2 occurs 0 with header line.
" XSTRING variable to be used by FM SCMS_BINARY_TO_XSTRING to hold the XML file in XSTRING format
data: I_xstring type xstring,
" String variable to hold XML file path to pass to GUI_UPLOAD
I_file_path type string,
" Variable to store the size of the uploaded binary XML file
I_LENGTH TYPE I VALUE 0.
parameters: P_path type IBIPPARMS-PATH default 'C:\Documents and Settings\c5104398\Desktop\flights.xml'.
" Get the XML file path from the user
at selection-screen on value-request for P_path.
CALL FUNCTION 'F4_FILENAME'
IMPORTING
FILE_NAME = P_PATH. -
XML to internal table conversion within ABAP mapping class
I am doing a ABAP mapping for file to Idoc. My requirement is to convert XML file into ABAP internal table (within ABAP mapping class). Is there any standard FM, method, transformation etc, which can be used here.
Thanks, DehraDehra,
Have you seen this weblogs which talks about this:
/people/r.eijpe/blog/2005/11/10/xml-dom-processing-in-abap-part-i--convert-an-abap-table-into-xml-file-using-sap-dom-approach
/people/r.eijpe/blog/2005/11/21/xml-dom-processing-in-abap-part-ii--convert-an-xml-file-into-an-abap-table-using-sap-dom-approach
/people/r.eijpe/blog/2006/02/19/xml-dom-processing-in-abap-part-iiia150-xml-dom-within-sap-xi-abap-mapping
/people/r.eijpe/blog/2006/02/20/xml-dom-processing-in-abap-part-iiib150-xml-dom-within-sap-xi-abap-mapping
Hope this helps you....
---Satish -
TSV_TNEW_PAGE_ALLOC_FAILED with internal table declared with occurs 0
HI guys,
when the internal table is declared as occurs 0, the dump TSV_TNEW_PAGE_ALLOC_FAILED is encountered, when changing the declaration into standard table, th dump disappears. Why is this so?
Thanks!There are three type of tables: Standard, sorted and hashed tables (see [here|http://help.sap.com/abapdocu_70/en/ABAPDATA_ITAB.htm]). When you define a table using the keyword OCCURS you're still defining a standard table.
Your exception indicates that you're running out of memory. The difference in the declarations that you mention shouldn't cause that. Main difference between the two declaration versions is probably that your table defined via OCCURS has a header line, whereas your other table doesn't (unless you declared it explicitly as WITH HEADER LINE).
I don't think though that with that little information anybody could explain the short dump. Actually it sounds rather odd that the change you mention should cause the dump (or make it go away). So I suspect you probably have to post further details. You might want to check the shortdump yourself and place a breakpoint at this place and run it for each version. Maybe you can see some difference... -
Accessing internal table declared outside of BAdI implementation
I am working on a BAdI implementation and within the BAdI, I need to manipulate the data of an internal table that is declared in the calling routine. This internal table is not a parameter to the BAdI call. I am wondering is there a way to access the internal table that is not recognized by the BAdI implementation? If so, what's the syntax to do this?
I know in debug mode, I am able to access the content of the internal table by using (Program)Itab. But I get a syntax error when accessing the internal table using (Program)Itab syntax.
Any help is appreciated!Thanks, Max.
I tried your method, but I am getting a short dump due to type conflict. I think it's because the internal table I'd like to access is declared using the following syntax:
data: begin of itab occurs 0,
end of itab.
Therefore, when processing the assign statement, the field-symbol is being treated as a structure...
I tried to change the field-symbol type to any, but after that, I can't modify the table content using loop at type of syntax..
Do you have any other suggestions?
Thanks very much! -
Problem with internal table declaration in function gui_upload
hi friends,
can u tell me how should i define internal table when i use this function?
i get error that in oo my declaration not good.
thanks,
dana.see this example:-
DATA: BEGIN OF itab OCCURS 0,
tdname TYPE mara-matnr,
tdline1 TYPE tline-tdline,
tdline2 TYPE tline-tdline,
tdline3 TYPE tline-tdline,
tdline4 TYPE tline-tdline,
tdline5 TYPE tline-tdline,
END OF itab.
DATA: BEGIN OF itab_error OCCURS 0,
tdname TYPE mara-matnr,
error TYPE string,
END OF itab_error.
DATA: lines TYPE STANDARD TABLE OF tline WITH HEADER LINE.
DATA: temp TYPE string.
DATA: tdspras TYPE thead-tdspras.
DATA: tdname TYPE thead-tdname.
DATA: tdobject TYPE thead-tdobject.
DATA: tdid TYPE thead-tdid.
DATA :flag TYPE c.
At Selection Screen Event
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p1.
CALL FUNCTION 'F4_FILENAME'
IMPORTING
file_name = p1.
At Start of Selection Event
START-OF-SELECTION.
PERFORM upload_data.
PERFORM upload_text.
*& Form upload_data
text
--> p1 text
<-- p2 text
FORM upload_data .
temp = p1.
**& Upload Data from Excel
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = temp
filetype = 'ASC'
has_field_separator = 'X'
TABLES
data_tab = itab.
ENDFORM. " upload_data
*& Form upload_text
text
--> p1 text
<-- p2 text
FORM upload_text .
tdspras = 'EN'.
tdid = 'BEST'.
tdobject = 'MATERIAL'.
LOOP AT itab.
REFRESH lines.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = itab-tdname
IMPORTING
output = itab-tdname.
TRANSLATE itab-tdname TO UPPER CASE.
tdname = itab-tdname.
PERFORM check_material.
lines-tdline = itab-tdline1.
APPEND lines.
CLEAR lines.
lines-tdline = itab-tdline2.
APPEND lines.
CLEAR lines.
lines-tdline = itab-tdline3.
APPEND lines.
CLEAR lines.
lines-tdline = itab-tdline4.
APPEND lines.
CLEAR lines.
lines-tdline = itab-tdline5.
APPEND lines.
CLEAR lines.
CALL FUNCTION 'CREATE_TEXT'
EXPORTING
fid = tdid
flanguage = tdspras
fname = tdname
fobject = tdobject
TABLES
flines = lines.
ENDLOOP.
IF itab_error[] IS NOT INITIAL.
WRITE : / 'PO Text For Following Material is not Uploaded'.
WRITE : / .
WRITE : / 'Material', ' Error'.
LOOP AT itab_error.
WRITE : / itab_error-tdname, ' ', itab_error-error.
ENDLOOP.
ELSE.
MESSAGE s001(38) WITH 'Data Uploaded Succcesfully'.
ENDIF.
ENDFORM. " upload_text
*& Form check_material
text
--> p1 text
<-- p2 text
FORM check_material .
DATA : w_matnr TYPE mara-matnr.
SELECT SINGLE matnr
INTO w_matnr
FROM mara
WHERE matnr = itab-tdname.
IF sy-subrc = 0.
flag = 'X'.
ELSE.
MOVE-CORRESPONDING itab TO itab_error.
itab_error-error = 'Material does not exist'.
APPEND itab_error.
ENDIF.
ENDFORM. " check_material -
How to avaoid tables declaration in abap object 's
Hi Folks,
I realised that in abap objects we should not declare tables statement, instead we have to declare wa type dbtable. But my qsn is i am using select single * from dbtable in at selection-screen for validation, in that situation in that situation how to avoid table declaration, i tried with select single * dbtable into wa , but still its asking table declaration.
Pls help me out, thanks.
Regards
Vishal<b>method GET_VENDOR_4_USER .
Get the Vendor for the User
data: x_lfa1 type lfa1.
clear vendor.
select
lifnr
into VENDOR
from zsiacvendor
up to 1 rows
where bname = sy-uname.
endselect.
get the name of the vendor
select single *
into x_lfa1
from lfa1
where lifnr = vendor.
endmethod.</b>
The above code works fine for me. -
Passing a program defined internal table to an abap object
Hi. I have an internal table that was previously defined and created by SAP that I need to process in a user exit. The table is defined exactly as shown below.
Is it possible to pass a table that was defined in this manner (not in the ABAP dictionary) as an argument to a method of an ABAP object?
If so, what would the data type of the itab parameter have to be when defining the object's method parameter list? Is it necessary to somehow "cast it" to the KNA1 table type once I receive the table into the method? If so, what is the data type of the object's receiving variable/attribute?
data: begin of lkna1 occurs 0001.
include structure kna1 .
data:
end of lkna1 .
Just as one additional piece of information, I am using version 4.5B and I am trying to do this through se24.
Thanks so much!Hi again,
<b>This kind of simple approach,
we can pass ANY KIND OF TABLE
WITHOUT HAVING TO DEFINE
LINE TYPE IN SE11.</b>
1. doing this simply u will achieve what u want.
( i just tried the same)
2. in se24,
give like this
ITAB Importing Type <b>STANDARD TABLE</b>
3. in the calling program,
call like this,
report abc.
data: begin of lkna1 occurs 0001.
include structure kna1.
data: end of lkna1.
data: testobj type ref to zsdtest.
select * from kna1
into table lkna1.
lkna1-kunnr = '000234'.
create object testobj.
<b>call method testobj->testreceive
exporting itab = lkna1[].</b>
4.
then in the class, source code,
just use like this
(so that u can accesss the fields of the itab,
using myitab)
<b>method TESTRECEIVE .
data : myitab type table of kna1.
myitab[] = itab[].
break-point.
endmethod.</b>
5. thats all !
regards,
amit m. -
Include a type in a internal table declaration.
Hi.
How can I do this?:
TYPES: BEGIN OF ty_simples,
agr_name LIKE agr_define-agr_name,
text LIKE agr_texts-text.
TYPES: END OF ty_simples.
Transacciones de GS.
TYPES: BEGIN OF ty_transacciones_gs,
tcode LIKE agr_tcodes-tcode,
text LIKE bmeniface-text.
TYPES: END OF ty_transacciones_gs.
And after:
DATA: begin of t_simples occurs 0.
include structure ty_simples.
include structure ty_transacciones_gs.
data: end of t_simples.
I have got a verification error.
Thanks!Hi,
Use as follow,
TYPES: BEGIN OF ty_simples,
agr_name LIKE agr_define-agr_name,
text1 LIKE agr_texts-text.
TYPES: END OF ty_simples.
TYPES: BEGIN OF ty_transacciones_gs,
tcode LIKE agr_tcodes-tcode,
text2 LIKE bmeniface-text.
TYPES: END OF ty_transacciones_gs.
* INTERNAL TABLES
data: BEGIN OF t_simples occurs 0.
INCLUDE TYPE ty_simples.
INCLUDE TYPE type ty_transacciones_gs.
data: END OF t_simples.
Regards.
Marcelo Ramos -
Internal table modification in ABAP object event
Hi Gurus
I have an internal table displayed using ALV - OOPS concept. THe internal table has 15 rows in my test program but it can go up depending on user inpout.
I am able to display it . on the screen . One of the fields is editable . It is required that it take input from user and on pressing enter , the value entered in that cell should be subtracted from a total amout displayed in the cell next to it.
I have used the following code . There are no errors , but nothing happens when I edit it. The screen remains as it is.
Any help will be very useful
DATA : ITAB type ITABT occurs 0.
DATA : itab_w like line of itab.
CLASS LCL_EVENTS_D0100 IMPLEMENTATION.
METHOD handle_data_changed.
DATA: ls_good TYPE lvc_s_modi.
DATA : L_PLANETYPE TYPE ITABT-SEL_QUANT.
LOOP AT er_data_changed->mt_good_cells INTO ls_good.
CASE ls_good-fieldname.
check if column PLANETYPE of this row was changed
WHEN 'SEL_QUANT'.
CALL METHOD pr_data_changed->get_cell_value
EXPORTING
i_row_id = ls_good-row_id
i_fieldname = ls_good-fieldname
IMPORTING
e_value = l_planetype.
ENDCASE.
LOOP AT ITAB INTO ITAB_W .
read table itab into itab_w WITH KEY FINDEX = LS_GOOD-ROW_ID .
itab_w-f_balquant = itab_w-f_balquant - l_planetype.
modify itab FROM itab_w .
endloop.
ENDLOOP.
ENDMETHOD.
ENDCLASS.Hi,
Hi,
AND also use
* Module Pai INPUT *
* PAI module *
module pai input.
save_ok = ok_code.
clear ok_code.
call method grid1->check_changed_data
importing
e_valid = v_valid.
" After this system will automatically update your changed data into
" internal table t_zthlog
case save_ok.
when 'EXIT'.
perform f_exit_program.
when 'CANC'.
perform f_exit_program.
when 'BACK'.
perform f_exit_program.
when 'SAVE'.
perform f_save_data.
endcase.
endmodule. " Pai INPUT
aRs -
How to populate internal table( varaible of ABAP table type) in Excel VBA?
Hi,
I am trying to update a database table from excel using a VBA Macro.
I am able to connect to SAP and able to read data from SAP using a RFC. Similarly after updating certain values, i want to update a table in SAP.
Below are the steps I am doing apart from basic settings.
Getting the reference of the SAP TABLE type from RFC fucntion module
' Call RFC
Set MyFunc = R3.Add("UPDATE_TVARVC_VIA_RFC")
' Get reference and Values TVARVC
Set oParam4 = MyFunc.Tables("TVARVC")
2. Loop over the active cells and populate oParam4
" add values as below
oParam4.Rows.Add
oParam4.Value(1, "NAME") = ..................
oParam4.Value(1, "TYPE") = ..................
oParam4.Value(1, "NUMB") = ..................
Do it for all columns in the table line.
My query is how to identify active cells and make the above code dynamic in step 2.
Thanks in Advance,
Best,
AneelHi Aneel,
You can try the following:
e.g.
for j = 1 to ActiveCell.SpecialCells(11).Column
oParam4.Rows.Add
if j=1 then oParam4.Value(j, "NAME") = ActiveSheet.Cells(1,j).Value
if j=2 then oParam4.Value(j, "TYPE") = ActiveSheet.Cells(1,j).Value
if j=3 then oParam4.Value(j, "NUMB") = ActiveSheet.Cells(1,j).Value
next j
Regards,
ScriptMan
Maybe you are looking for
-
Intermittently iphone 6 and 6 plus is wifi connected but internet does not work.
Hi, I have an issue where intermittently iphone 6 and 6 plus is wifi connected but internet does not work. iMessage works though. Toggling the wifi setting clears the issue temporarily but it occurs again. Running iOS 8.3 now. This was the case on
-
Problem with VideoDisplay orizzontal reflection
Hello everyone, I write because I have a problem with the item VideoDisplay in Flex. A hypothetical <mx:VideoDisplay id="videoDisplay" width="400" height="300" /> how do I reflect it horizontally? So basically the right side should become the left an
-
ITunes will quit working mid-song and will skip around entire library.
In the most recent iTunes version running on windows 7, iTunes will not play through an entire song and skips around the entire library of music. Sometimes only the first few seconds of a song will play, and sometimes a little over a minute will play
-
Capture output myPage.jsp and send by email
Hi all, I'm trying to capture HTML output produced by myFirstPage.jsp and then send it by java mail. The first problem is : How can I capture the output? Is right to call myFirstPage.jsp from another jsp page (by use HttpURLConnection) and then write
-
I am enrolled in an online university program that uses Sakai. Fire Fox updated something that attaches computer script to my Word documents when I upload them. I use a PC and Word 2010