Accessing a field in nested internal table
Hi,
Could you please help me how to get value in nested structure 'COMT_PRODUCT_IL_API'.
We need to access field 'DESTINGUID' in that nested structure.
Thanks,
Santosh
Helo,
I figured the previous reply would have solved ur issue,
but doesnt look like as you ve still kept the issue open.
So il again as well follow d same lines n leave a snippet fr yu to refer:-
DATA : LT_COMT_PRODUCT_IL_API TYPE TABLE OF COMT_PRODUCT_IL_API,
LW_COMT_PRODUCT_IL_API TYPE COMT_PRODUCT_IL_API,
** i AM NOT SURE WHCIH DEEP STRUCT it is, Im just picking one of the deep strucs in this struc**
LW_COMM_IL_ACCESS TYPE COMT_IL_ACCESS_MAINTAIN.
LOOP AT LT_COMT_PRODUCT_IL_API INTO LW_COMT_PRODUCT_IL_API.
READ TABLE LW_COMT_PRODUCT_IL_API-COMM_IL_ACCESS INTO LW_COMM_IL_ACCESS INDEX 1.
IF SY-SUBRC = 0.
+<UR CODE HERE>+
ENDIF.
ENDLOOP.
Shoudl work.
Please close the thread if ur issue lays resolved
Regards
Dedeepya C
Edited by: dedeepya reddy on Mar 23, 2010 1:21 PM
Similar Messages
-
Dynamic access to the fields of an internal table
Hi,
Currently i'm having 10 fields in 1 internal table, and i need to validate this 10 fields but i dont like have too many "if and endif" statement. Is there any option to write an dynamic code.
Example
Data: begin of table,
field1 type c,
field2 type c,
field3 type c,
field4 type c,
field10 type c,
end of table.
Let say i want to fill field1 with 1, field2 with 2,........................... field10 with 10.
So instead of using this code
table-field1 = '1'.
table-field2 = '2'.
table-field3 = '3'.
table-field10 = '10'.
Can i do something dynamic like this
DO 10 times.
Dynamic coding, any idea ?
ENDDO.
<Modified the subject line>
Edited by: Suhas Saha on Jul 12, 2011 4:27 PMHi,
Sorry may my question is not detail enough. I would like to read the field from the internal table dynamically.
Data: begin of table,
field1 type c,
field2 type c,
field3 type c,
field4 type c,
field10 type c,
end of table.
Let say i want to fill field1 with 1, field2 with 2,........................... field10 with 10.
So instead of using this code
table-field1 = '1'.
table-field2 = '2'.
table-field3 = '3'.
table-field10 = '10'.
IF table-field1 < 0,
endif.
IF table-field2 < 0,
endif.
IF table-field3 < 0,
endif.
|
IF table-field10 < 0,
endif.
Can i do something dynamic like this
DO 10 times.
Dynamic coding, any idea ?
ENDDO. -
Nested Internal Table Tables and REUSE_ALV_GRID_DISPLAY
Can you display entries from a nested internal table in the using the call function 'REUSE_ALV_GRID_DISPLAY'?
Types and internal tables are below. I have skimmed the code for the function module below, assume field category built, etc.. The table is in the tables portion of the function module, the nested internal table is inside of int_output defined as data: int_tlines type t_tline occurs 0.
TYPES:
BEGIN OF t_tline,
tdformat type tline-tdformat,
tdline type tline-tdline,
END OF t_tline.
DATA:
BEGIN OF int_output occurs 0,
qmnum TYPE qmnum,
sys_stat TYPE j_stext,
kunum TYPE qkunum,
sting TYPE string,
numr TYPE vbeln,
bstnk TYPE bstkd,
vbeln TYPE kdauf,
erdat(10) TYPE c,
aufnr TYPE aufnr,
werks TYPE werks_d,
idat2(10) TYPE c,
otgrp TYPE otgrp,
oteil TYPE oteil,
fd_text TYPE qtxt_code,
fegrp TYPE fegrp,
fecod TYPE fecod,
pb_text TYPE qtxt_code,
fetxt TYPE fetxt.
data: int_tlines type t_tline occurs 0.
data: QMTXT TYPE QMEL-QMTXT,
NOTIF_TXT TYPE STRING,
bautl TYPE bautl,
bautx TYPE bautx,
END OF int_output.
DATA: i_output LIKE STANDARD TABLE OF int_output,
w_output LIKE LINE OF int_output.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
TABLES
t_outtab = int_output
EXCEPTIONS
program_error = 1
OTHERS = 2.Hi
I dont think this requirement is possible. Even if we pass the data through the nested internal table the FM may not give a dump. The main problem will be with field catalog. How can we build field catalog for the fields inside the nested internal table.
Field catalog for this FM REUSE_ALV_GRID_DISPLAY should be of type SLIS_FIELDCAT_ALV and this is a standard one. -
Problem reading data from nested internal table.
Hi,
Below is my code;
*********SAP Code********
TYPES: BEGIN OF v54a0_scdd,
fknum LIKE vfkk-fknum,
change LIKE vfkkd-updkz,
x TYPE v54a0_scd,
y TYPE v54a0_scd,
tvtf LIKE tvtf,
END OF v54a0_scdd.
SCD table for dialog
TYPES: v54a0_scdd_tab TYPE v54a0_scdd OCCURS 1.
*********SAP Code********
*Custom declaration*****
data: wa_freight_costs type v54a0_scdd_tab.
data: it_freight_costs type v54a0_scdd_tab occurs 0.
*****Here data is getting appended to it_freight_costs. P_frieght_costs is coming from standard program.
move p_freight_costs TO wa_FREIGHT_COSTS.
append wa_freight_costs to it_freight_costs.
clear wa_freight_costs.
***Now the problem is here. I am not able to read the data from the nested internal table x-item.
if i use <fs_f_costs> to move data from it_freight_costs in the outer loop, i get a syntax error; <i> "the line type of the table it_freight_costs is not compatible with field symbol type <fs_f_costs>" </i>
FIELD-SYMBOLS: <fs_f_costs> type line of v54a0_scdd_tab.
LOOP AT it_freight_costs assigning <fs_f_costs>.
LOOP AT <fs_f_costs>-x-item ASSIGNING <fs_freight_item>.
<b> I want to read <fs_freight_item>-vfkp-netwr.</b>
ENDLOOP.
Can anyone guide me?A quick look at how I would do this. Note I haven't checked if this compiles just done a quick brain-dump.
DATA: lr_f_costs TYPE REF TO v54a0_scdd_tab,
lr_f_cost TYPE REF TO v54a0_scdd.
LOOP AT it_freight_costs REFERENCE INTO lr_f_costs.
LOOP AT lr_f_costs->* REFERENCE INTO lr_f_cost.
ENDLOOP.
ENDLOOP.
As you can see I personally prefer pointers to field symbols - I don't believe there is any performance differences and because of my background in other languages pointers make more sense to me.
Cheers
Graham Robbo -
What are nested Internal tables
Hi Guru's,
I am new to ABAP ...just trying to learn things.Can you please explain me what are nested internal tables and what is the purpose of nested internal table?where can it be used and why a header line is not written in a Nested Internal table...
Kindly explain it (scenario where nested internal tables are used) with an example it will be helpful.
Cheers,
PriyankaHi,
When storing data in internal tables, you often use one internal table for each database you read.
Each one contains some or all columns of the relevant database table. It is up to you whether
you create an internal table with a flat structure for each database table or if you create, for
example, internal tables with nested structures. If you have several tables, each one with a flat
structure, you have to work with redundant key fields to link the tables. If, on the other hand, you
use nested internal tables, you can store the data from the database tables hierarchically.
Saving and processing very large amounts of data in internal tables has disadvantages. If you
divide up the data into different internal tables, processing it can be very runtime-intensive, since
the tables have to be processed individually. Furthermore, it requires a lot of storage space,
since internal tables are not stored in compressed form. The system may even need to store the
dataset outside of its working memory. This means that processing it takes even longer.
An example of nested internal table:
Assume the following program is linked to the logical database [Page 1163] F1S.
REPORT DEMO.
DATA: SUM TYPE I, CNT TYPE I.
NODES: SPFLI, SFLIGHT, SBOOK.
DATA: BEGIN OF WA_SBOOK,
BOOKID TYPE SBOOK-BOOKID,
SMOKER TYPE SBOOK-SMOKER,
CLASS TYPE SBOOK-CLASS,
LUGGWEIGHT TYPE SBOOK-LUGGWEIGHT,
WUNIT TYPE SBOOK-WUNIT,
END OF WA_SBOOK.
DATA: BEGIN OF WA_SFLIGHT,
FLDATE TYPE SFLIGHT-FLDATE,
SBOOK LIKE TABLE OF WA_SBOOK,
END OF WA_SFLIGHT.
DATA: BEGIN OF WA_SPFLI,
CARRID TYPE SPFLI-CARRID,
CONNID TYPE SPFLI-CONNID,
CITYFROM TYPE SPFLI-CITYFROM,
CITYTO TYPE SPFLI-CITYTO,
SFLIGHT LIKE TABLE OF WA_SFLIGHT,
END OF WA_SPFLI.
DATA TAB_SPFLI LIKE TABLE OF WA_SPFLI.
START-OF-SELECTION.
GET SPFLI.
REFRESH WA_SPFLI-SFLIGHT.
GET SFLIGHT.
REFRESH WA_SFLIGHT-SBOOK.
GET SBOOK.
MOVE-CORRESPONDING SBOOK TO WA_SBOOK.
APPEND WA_SBOOK TO WA_SFLIGHT-SBOOK.
GET SFLIGHT LATE.
MOVE-CORRESPONDING SFLIGHT TO WA_SFLIGHT.
APPEND WA_SFLIGHT TO WA_SPFLI-SFLIGHT.
GET SPFLI LATE.
MOVE-CORRESPONDING SPFLI TO WA_SPFLI.
APPEND WA_SPFLI TO TAB_SPFLI.
END-OF-SELECTION.
SORT TAB_SPFLI BY CITYFROM CITYTO CONNID.
LOOP AT TAB_SPFLI INTO WA_SPFLI.
SKIP.
WRITE: / WA_SPFLI-CARRID,
WA_SPFLI-CONNID,
'from', (15) WA_SPFLI-CITYFROM,
'to', (15) WA_SPFLI-CITYTO.
ULINE.
SORT WA_SPFLI-SFLIGHT BY FLDATE.
LOOP AT WA_SPFLI-SFLIGHT INTO WA_SFLIGHT.
SKIP.
WRITE: / 'Date:', WA_SFLIGHT-FLDATE.
WRITE: 20 'Book-ID', 40 'Smoker', 50 'Class'.
ULINE.
SORT WA_SFLIGHT-SBOOK BY CLASS SMOKER BOOKID.
SUM = 0.
CNT = 0.
LOOP AT WA_SFLIGHT-SBOOK INTO WA_SBOOK.
WRITE: / WA_SBOOK-BOOKID UNDER 'Book-ID',
WA_SBOOK-SMOKER UNDER 'Smoker',
WA_SBOOK-CLASS UNDER 'Class'.
SUM = SUM + WA_SBOOK-LUGGWEIGHT.
CNT = CNT + 1.
ENDLOOP.
ULINE.
WRITE: 'Number of bookings: ', (3) CNT,
/ 'Total luggage weight:',
(3) SUM, WA_SBOOK-WUNIT.
ENDLOOP.
ENDLOOP.
Thanks. -
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. -
How to create dynamic nested internal table
Hi Experts,
Pleae tell me or give sample code, how to create dynamic nested internal table ?
I have seen threads saying creation of dynamic internal tables using some table structure only. But now the requirement is to create dynamic nested internal table.
For example the internal table contains two fields viz., one is field1 of dynamic internal table and other is normal field2 and values as shown below:
Nested internal table:
field1 | field2 ...
<table content1> | value2..
<table content1> | value2..
Here the [table content] should also a dynamic internal table.
Let me know if you need any other info.
regards
Saravanan Rsee the complete code..i am currently working in ECC6.0 EHP4. just check which version you are using..
REPORT yst_test_000.
DATA:
lt_comptab TYPE cl_abap_structdescr=>component_table,
ls_comp LIKE LINE OF lt_comptab,
lref_newstr TYPE REF TO cl_abap_structdescr,
lref_tab_type TYPE REF TO cl_abap_tabledescr,
lt_fcat TYPE lvc_t_fcat,
ls_fcat TYPE lvc_s_fcat,
ls_dd03p TYPE dd03p,
lt_data type ref to data.
field-symbols: <fs_table> type standard table.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'SCARR'
CHANGING
ct_fieldcat = lt_fcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
LOOP AT lt_fcat INTO ls_fcat.
IF ls_fcat-ref_table IS NOT INITIAL.
CLEAR ls_dd03p.
CALL FUNCTION 'BUS_DDFIELD_GET'
EXPORTING
i_tabnm = ls_fcat-ref_table
i_fldnm = ls_fcat-fieldname
IMPORTING
e_dd03p = ls_dd03p
EXCEPTIONS
field_not_found = 1
OTHERS = 2.
IF sy-subrc EQ 0.
ls_comp-name = ls_fcat-fieldname.
ls_comp-type ?= cl_abap_datadescr=>describe_by_name( ls_dd03p-rollname ).
APPEND ls_comp TO lt_comptab.
CLEAR ls_comp.
ENDIF.
ELSE.
ls_comp-name = ls_fcat-fieldname.
ls_comp-type ?= cl_abap_datadescr=>describe_by_name( ls_fcat-rollname ).
APPEND ls_comp TO lt_comptab.
CLEAR ls_comp.
ENDIF.
ENDLOOP.
*Now for the Field which you want deep table then you can do like this
ls_fcat-fieldname = 'NESTED_TABLE'.
ls_fcat-inttype = 'C'.
ls_fcat-intlen = '000006'.
ls_fcat-rollname = 'SFLIGHT_TAB1'. "For SFLIGHT
APPEND ls_fcat TO lt_fcat.
ls_comp-name = ls_fcat-fieldname.
ls_comp-type ?= cl_abap_datadescr=>describe_by_name( ls_fcat-rollname ).
APPEND ls_comp TO lt_comptab.
CLEAR ls_comp.
lref_newstr = cl_abap_structdescr=>create( lt_comptab ).
lref_tab_type = cl_abap_tabledescr=>create( lref_newstr ).
create data lt_data type handle lref_tab_type.
assign lt_data->* to <fs_table>.
break-point.
Edited by: Vijay Babu Dudla on Apr 28, 2009 8:05 AM -
Extract a value of a fields from an internal table
hello everyone,
i need to extract a value of a fields from an internal table, the fields is in a postion "sy-tabix" that i know, so i need to pick this value without using a loop
thank you.Like this?
DATA: FIELD1 TYPE C,
FIELD2 TYPE C.
READ TABLE T_TAB INDEX 3.
FIELD1 = T_TAB-FIELD1.
FIELD2 = T_TAB-FIELD2.
Greetings,
Blag. -
Field catalog for internal table in ALV
In my program the internal table consists many fields from various tables and structure doesn't belong to a single data table.
In order to get output in ALV grid following FM has been used
REUSE_ALV_GRID_DISPLAY
for field catalog the fields are defined specifically.
l_fieldcat-fieldname = 'VBELN'.
l_fieldcat-outputlen = 10.
l_fieldcat-seltext_l = 'Billing doc'.
l_fieldcat-no_zero = 'X'.
l_fieldcat-hotspot = 'X'.
append l_fieldcat to p_fieldtab.
..............and so on for all the fields.
Just wanted to know is there any other method to display all the fields of this internal table automatically so each field is not specified specifically.
anyaHi
Try this instead:
*& Form create_fieldcatalog
* Create a field catalogue from any internal table
* -->PT_TABLE Internal table
* -->PT_FIELDCAT Field Catalogue
FORM create_fieldcatalog
USING pt_table TYPE ANY TABLE
CHANGING pt_fieldcat TYPE lvc_t_fcat.
DATA:
lr_tabdescr TYPE REF TO cl_abap_structdescr
, lr_data TYPE REF TO data
, lt_dfies TYPE ddfields
, ls_dfies TYPE dfies
, ls_fieldcat TYPE lvc_s_fcat
CLEAR pt_fieldcat.
CREATE DATA lr_data LIKE LINE OF pt_table.
lr_tabdescr ?= cl_abap_structdescr=>describe_by_data_ref( lr_data ).
lt_dfies = cl_salv_data_descr=>read_structdescr( lr_tabdescr ).
LOOP AT lt_dfies
INTO ls_dfies.
CLEAR ls_fieldcat.
MOVE-CORRESPONDING ls_dfies TO ls_fieldcat.
APPEND ls_fieldcat TO pt_fieldcat.
ENDLOOP.
ENDFORM. "create_fieldcatalog -
How to find number of fields in an internal table ?
my requirement is i have 20 internal tables and the data is being uploaded into an application server. so how to find no of fields in a particular internal tableconcatenate all the fields and move them to final internal table , call the function module "GET_COMPONENT_LIST" and pass the work area of the final internal table in the parameter fieldname
***For getting no of FIELDS in an internal table ********
CALL FUNCTION 'GET_COMPONENT_LIST'
EXPORTING
PROGRAM = syrepid
FIELDNAME = 't_payr'
TABLES
COMPONENTS = fieldlist.
describe table fieldlist lines pyr_no_fields.
********end of getting no of fields**********
TRANSFER wa_mat_out_head TO P_FNAME.
LOOP AT GT_PAYR.
MOVE: GT_payr-LIFNR TO T_payr-lifnr,
GT_payr-ZBUKR TO T_payr-zbukr,
GT_payr-LAUFD TO T_payr-LAUFD,
GT_payr-CHECT TO T_payr-CHECT,
GT_payr-RWBTR TO T_payr-RWBTR.
Concatenate T_payr-lifnr t_payr-zbukr T_payr-laufd T_payr-chect
T_payr-rwbtr into wa_mat_out-rec SEPARATED by ',' . -
Changing the order of fields in an internal table
Hi all,
I'm using field symbol as internal table. this table has got a standard database structure.
I want to make the 3rd column of this internal table as 1st colums keeping rest of the columns as it is.
Is there any way to do this?
Thanks,
Anil.Hi
Instead of directly taking the type as a standard structure , declare the FS internal table as type of types structure.
Data: fs_scarr like type_s_scarr.
FIELD-SYMBOLS <scarr2> TYPE fs_scarr
In the types put the third column as first one and use into corresponding in select query
or else
while displaying the internal table change the order of the columns
Loop at itab into fs_itab.
write : col3
col2
col4
endloop.
Thanks,
Viquar Iqbal -
Aggregate a numeric field in an internal table
Hi All,
I have a small requirement in ABAP it goes in this fashion
I need to aggregate a numeric field in an internal table, the table is as follows
FLD1 FLD2 NUM1 FLD3
123A B1 10 C1
123A B1 25 C1
123B B1 20 C2
123C B2 10 C3
Note: FLD1, FLD2, FLD3 are of type numeric characters and NUM1 is of type number or integer
I want the result to be as follows
FLD1 FLD2 NUM1 FLD3
123A B1 35 C1
123B B1 20 C2
123C B2 10 C3
i.e. values in field NUM1 should get add up when the values in all other fields are same
I am not able to use _collect_ for this as the fields contain numeric characters.
Regards and Thanks,
AntonyHi Antony
collect here works like this:-
use at new field
sum
end at.
Pls reward points if it wil be helpful.
Regards
Depanker -
I need to add check whether 21 fields of a internal table are empty or not.
Hello,
I need to add check whether 21 fields of a internal table are empty or not.How can we write a code for the same wand what would be the correct syntax for it.
I tried entering all the fields in the IF loop with AND condition but its giving syntax error.Perhaps this is because the lenght of the IF condition would be more than the allowed one.Hi,
After the select quiery.
If not itab is initial.
Message 'Table is not empty' type 'I'.
Endif.
Regards,
Jagadish. -
Passing Nested internal table to GUI_DOWNLOAD
Hi All
I have got a nested internal table, I want this whole report in excel format, I tried using GUI_DOWNLOAD , it gives error. Does any body have any idea how can I solve this.
regards
AJHi,
I think nested and deep structure internal tables will not work with gui_download.
you need to convert before giving it to gui_download
aRs -
First occurence of a value from a field in the internal table.
How to select the first occurence of a value from a field in an internal table ?
I don think , we can use select query .
Any suggestions?
provide syntaxs also .Hi...
You have to use this code.
DATA : Begin of IT_MARA occurs 0,
mtart type mara-mtart,
matnr type mara-matnr,
meins type mara-meins,
END OF IT_MARA.
START-of-SELECTION.
SELECT MTART MATNR MEINS FROM MARA INTO TABLE IT_MARA.
END-OF-SELECTION.
LOOP AT IT_MARA.
<b> AT NEW MTART. "This will trigger for every first/new value of the field
<<<<WRITE YOUR CODE here>>
ENDAT.</b>
ENDLOOP.
You can also use.
LOOP AT IT_MARA.
<b> <b> ON CHANGE OF IT_MARA-TART.
<<<<WRITE YOUR CODE here>>
ENDON.</b></b>
ENDLOOP.
<b>Reward if Helpful.</b>
Maybe you are looking for
-
How do I add another subscription to my account?
I have taken out a subscription to Creative Cloud but I want to add another subscription to my account. How do I do this?
-
MODIFY SCREEN inactive WITH LDB OF PNP
hi i want to set a screen field no input. and this report use PNP of LDB. AT SELECTION-SCREEN OUTPUT. LOOP AT SCREEN. IF SCREEN-NAME = 'PNPMASSN'. SCREEN-INPUT = 0. MODIFY SCREEN. ENDIF. ENDLOOP. but this can't active. how Mod
-
Amount formatting based on Currency Key
Hi, I want to format the amount field on the basis of the currency key. for eg. Chile has the no of decimal places set as 0 so for Chile, the amount 800.00 should display as 800 Similarly for Mexico, the no of decimal places is set as 2. so for Mexic
-
JES 2005Q4 installation problems
When I start the installation it is not copying any files to any folder. On the screen only this message showing: OrionUninstallersun-ps7_0-entsys %1 OrionUninstallersun-ps7_0-entsys %41 OrionUninstallersun-ps7_0-entsys %71 and after the installation
-
A preoccupying disease occurred 2 times last month and a couple before, one to my Quad and one to my friend's PMG5 2x2.0: both machines have multiple accounts, one for administrative purposes and one for work (each account is able to Administrate, bt