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!
Similar Messages
-
Accessing internal tables at runtime.
Hi all,
I am writing a code where in i have to transfer data from excel to database table.
Iam getting the excel data in an itab. Can anybody help me with how to access internal tables at runtime ?
i am using the following code with sy-tabix. here, when the sy-tabix is odd it picks up the value,
but i want that within the same loop when i increment sy-tabix by 1, then it should fetch the second column of same row. But its not working as it shows an error that it does not permit subfield access.
the code is as follows:
LOOP AT t_tab[] into wa_tab .
data: l_tabix type sy-tabix,
name_index type sy-tabix.
data: c type i.
l_tabix = sy-tabix.
name_index = l_tabix+1.
c = ( l_tabix mod 2 ).
******to check if sy-tabix is odd**********
if c ne 0.
READ TABLE t_tab into wa_tab index l_tabix.
wa_product1-product = wa_tab-VALUE.
************incrementing sy-tabix*************
READ TABLE t_tab into wa_tab index name_index. (here it shows error)
wa_product1-product_name = wa_tab-value.
endif.
endloop.
Thanks in advance.Hi Omer,
Copy and paste this code.
=====================================
REPORT ztest_create_data_dynamic .
TYPE-POOLS: slis.
DATA: it_fcat TYPE slis_t_fieldcat_alv,
is_fcat LIKE LINE OF it_fcat.
DATA: it_fieldcat TYPE lvc_t_fcat,
is_fieldcat LIKE LINE OF it_fieldcat.
DATA: new_table TYPE REF TO data.
DATA: new_line TYPE REF TO data.
FIELD-SYMBOLS: <l_table> TYPE ANY TABLE,
<l_line> TYPE ANY,
<l_field> TYPE ANY.
Build fieldcat
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'SYST'
CHANGING
ct_fieldcat = it_fcat[].
LOOP AT it_fcat INTO is_fcat WHERE NOT reptext_ddic IS initial.
MOVE-CORRESPONDING is_fcat TO is_fieldcat.
is_fieldcat-fieldname = is_fcat-fieldname.
is_fieldcat-ref_field = is_fcat-fieldname.
is_fieldcat-ref_table = is_fcat-ref_tabname.
APPEND is_fieldcat TO it_fieldcat.
ENDLOOP.
Create a new Table
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fieldcat
IMPORTING
ep_table = new_table.
Create a new Line with the same structure of the table.
ASSIGN new_table->* TO <l_table>.
CREATE DATA new_line LIKE LINE OF <l_table>.
ASSIGN new_line->* TO <l_line>.
Test it...
DO 30 TIMES.
ASSIGN COMPONENT 'SUBRC' OF STRUCTURE <l_line> TO <l_field>.
<l_field> = sy-index.
INSERT <l_line> INTO TABLE <l_table>.
ENDDO.
LOOP AT <l_table> ASSIGNING <l_line>.
ASSIGN COMPONENT 'SUBRC' OF STRUCTURE <l_line> TO <l_field>.
WRITE <l_field>.
ENDLOOP. -
How to access internal table data from webdynpro to Flex application.
Hi Connoisseur
The data transfer from Abap WebDeypro to flex island works well. I followed , there is an example from Thomas Jung (by the way as always Great Work) and Karthikeyan Venkatesan (Infosys) but this example covers simple type only.
There is no example with complex types like arrayCollection which handle the transfer of data from flex to WebDynpro.
i tried to do pass internal table value to flex-datagrid.but its not work.
i would like to know
1.how to access internal table data from webdynpro to Flex application.
2.how to pass the internal table to flex-datagrid.
2.how to pass dynamically in ADOBE flex.
3. how to do Flex is receiving the wd context data?
4. how can we update WD context with FLEX data.
Ple give me sample example and step by step procedure.
Regards
laxmikanthHi Laxmikanth,
Please refer this...
Flash island: update complex type from flex
Cheers..
kris. -
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 -
Hi Experts,
I have moved values from node with attributes in context to an internal table using
node_output_4->GET_STATIC_ATTRIBUTES_TABLE(
importing
table = itab
Now the neccessary values are in itab (internal table).I want to check the itab-id with item_code(user input).
I want to access the itab.Plz guide me.Hi Ramanan,
With header line statement is not avilable in OO concepts.
So you can use the Node of the context.
If you are read your node means it will automatically generate the code.
In the code it will automatically declares the wa for your context.
generally it looks like,
DATA:
node_znode2 TYPE REF TO if_wd_context_node,
elem_znode2 TYPE REF TO if_wd_context_element,
stru_znode2 TYPE if_view1=>element_znode2 .
From the above code stru_znode2 is the WA.
Then you can define your own Itab based on this structure.
DATA : itab like table of stru_znode2.
Thanks. -
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 of main program inside function module...
I have function module say ZFUNC and main program say ZMAIN and internal table defined as IT_TAB inside ZMAIN but not passed as parameter to Function module ZFUNC.
If I want to access the field value of IT_TAB of main program ZMAIN inside ZFUNC during debugging then, I simply put <b>(ZMAIN)IT_TAB-amount</b> in ABAP debugger and then change it when the debugger is inside ZFUNC.
How can I write code to change the value of internal table of main program in function module ZFUNC instead of doing in debugger ? I guess I have to use some field symbols, but not sure. Please suggest.
Regards,
Rajesh.Yes, you do need to use a field symbol. Say for example, you had a internal table called IMARC in your program and you want to access it later in a funciton module, you would do something like this.
data: xmarc type marc.
field-symbols: <imarc> type marc_upl_tt.
* Assign an internal table
field = '(ZPROGRAM_NAME)IMARC[]'.
assign (field) to <imarc>.
loop at <imarc> into xmarc.
write: / xmarc-matnr, xmarc-werks.
endloop.
Regards,
Rich Heilman -
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 -
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,
VindHi,
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 -
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 -
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 -
Accessing internal table ACCIT
Hi Experts,
I am currently working on a substitution exit to substitute cost center in FI line item.
The problem is that the data will only be available when the document is completed, so I put the substitution in complete document level.
Does anyone know whether it is still possible to perform substitution at this level? Since it is necessary for us to perform this substitution.
Many thanks for your kind reply,
Fandi.A few added information,
My colleague told me that it is possible to do this, but the substitution must be performed to internal table ACCIT which is the accounting posting interface internal table.
How can this be done? As the structure is not recognized in the substitution.
Thanks,
Fandi. -
Problem in declaring internal table
hai experts ,
i am new to web dynpro abap .. my problem is i want to declare a internal table for a table using the web dynpro code wizard .. i found many threads regarding that .. but for mee its not working .. many of them posted that get_static_attributes_table method will solve the problem .. but i used the method in the wizard but it saying that method does not exist ..pls solve the problem ..
say where to enter the method in the wizard ..
thanks & kind regards
chinnaiyaHi Chinnaiya,
Your post isnt that clear as to what you intend to do. Do you intend to just create an internal table declaration which would be able to hold your context nodes data or do you wish to use the get_static_attributes method to fetch all your tables data into this internal table?
If you want to just declare an internal table which can hold the data then you would have to do it manually. You can't generate your internal table declaration using the code wizard. Suppose your context nodes name is SFLIGHT then you can use the below syntax to declare a table & work area respectively.
DATA: lt_sflight TYPE wd_this->elements_sflight, " Internal table
wa_sflight TYPE wd_this->element_sflight. " Work area
For each node <node> of a controller context, a structure type element_<node> is implicitly generated in the interface IF_<ctrl>. The structure fields correspond to the attributes a node element consists of. Similarly for each node <node> of a controller context, a standard table type elements_<node> is implicitly generated in the interface IF_<ctrl>. The line type of this table is element_<node>. This constant can be used to
type an internal table that can hold the attributes of multiple node elements. So as how said here you can even declare the work area and internal table like shown below in your MAIN view:
DATA: lt_sflight TYPE if_main=>elements_sflight, " internal table
wa_sflight TYPE if_main=>element_sflight. " work area
But the disadvantage of this approach as how pointed out by Thomas in 1 of this earlier threads is that this coding works fine only for this particular view. If you copy the same code and try to use it in another view say VIEW1 then it wouldn't work as the interface name would have changed from if_main to if_view1. So its suggested to use the earlier approach.
Regards,
Uday -
Hi,
I am using user exit "MV45AFZZ" - Sales order, I have declaired one internal table in userexit_save_document_prepare and storing some data in it.
FORM userexit_save_document_prepare.
ENDFORM.
I wish to use the data from internal table declared in userexit_save_document_prepare in
FORM userexit_save_document.
ENDFORM.
Should i declare the internal table at some other place so that it can be accessed from other user exits.Hi Ganesh,
You are asking if your internal table can be declared globally. I don't believe there is an area (an include program for example) in SAPMV45A that allows customers to declare their own global data. This would of course be the most straight-forward solution, but if we don't have this option, you can always do something like this:
FORM userexit_save_document_prepare.
EXPORT my_itab TO MEMORY ID 'CUST_MEMORY'.
ENDFORM.
And then this:
FORM userexit_save_document.
IMPORT my_itab FORM MEMORY ID 'CUST_MEMORY'.
ENDFORM.
Regards,
Jamie
Maybe you are looking for
-
Problem after installing OBIEE 11.1.1.5
Hi, I installed obiee 11g on a windows server. But i dint use a service account,but installed it with another user account which had all admin privileages. Now, i logged into the server and All programs-->Oracle Business Intelligence --->start BI ser
-
Vendor Blocked for Local Purchase Organization
Hi, I have checked the vendor details in SRM and ECC. The vendor is not locked in SRM & ECC, still the User is getting the Error message that Vendor Blocked for Local Purchase Organization. Please suggest. Regards, Lovkesh
-
PDF Docs in browser cannot be found (15;524)
Have received this following The Adobe/Reader selected for viewing PDF docs in browsers cannot be found at its installed location; it may have been moved or deleted. Please reinstall or repair the application (15;524) Also on games on facebook some h
-
CONTROLLING PERIOD END CLOSING
Hello I was trying to execute "Actual Price Calculation" (trx KSII) and I have the following messagge: All activity prices are set politically Message no. KP211
-
#REF! appearing in the workbook cells
Hi gurus, When there are values for the query selection, the workbook will present the values properly but when there are no values for a perticular selection criteria of the query- #REF! appeares in the workbook cells. I think there are cell referen