Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

insert into this datastructure

0 Likes
822

If you look on the structure below i would like to select and insert data from another table into the id field in the type t_scenario4.

if i do insert it into the number field in t_scenario3 it looks like this:

LOOP AT lt_response ASSIGNING FIELD-SYMBOL(<lfs_rsp>). 
SELECT phone_no AS number FROM zxx_exampletable WHERE example = @<lfs_rsp>-example 
INTO CORRESPONDING FIELDS OF TABLE @<lfs_rsp>-cl_data.

but i cant figure out the syntax to do the insert into sc-data.

TYPES: BEGIN OF t_scenario4, 
id TYPE string, 
END OF t_scenario4. 
TYPES: tt_scenario4 TYPE STANDARD TABLE OF t_scenario4 WITH DEFAULT KEY. 

TYPES: BEGIN OF t_scenario3,
number TYPE string, sc_data 
TYPE tt_clearing_scenarios4, 
END OF t_scenario3. 
TYPES: tt_scenario3 TYPE STANDARD TABLE OF t_scenario3 WITH DEFAULT KEY. 

TYPES: BEGIN OF t_json2, 
email TYPE string, 
cl_data TYPE tt_scenario3, 
END OF t_json2. 
TYPES: tt_json2 TYPE STANDARD TABLE OF t_json2 WITH DEFAULT KEY.
2 REPLIES 2
Read only

Sandra_Rossi
Active Contributor
0 Likes
727

Be very very careful if you use SELECT inside a loop. The rule-of-thumb is to never nest a SELECT in a loop.

I guess SELECT cannot store data into a Deep internal table, so you should temporarily define a Flat internal table to store the SELECT results, and after that use ABAP to distribute the lines to the Deep internal table.

Read only

VXLozano
Active Contributor
0 Likes
727

OMG, please try to edit your CODE to (at least) add the proper line feeds... It took me hours to figure what sc_data meant.
So, your data structure looks like

email1   number1  id1
                  id2
                  id3
         number2  id4
                  id5
email2   number3  id6
         number4  id7
                  id8
         number5  id9

now, try to explain how are you trying to put data into your table, please... it comes from a single table with those three fields and you want to group them? it comes from more than a table? from calculations?