I created a table "users" with user properties...
however, I wanted to have a complex/nested field called "address", but it seems tables can only be flat in abap dict tables... I can only use ".INCLUDE" to put the address fields flat into the table is that right?
I am just wondering, how I can then parse my complex json users object in an ABAP REPORT program and insert them into my ddict table...
REPORT zzzfz_ins_users.
*TYPES: ty_coord TYPE TABLE OF dec015 WITH NON-UNIQUE DEFAULT KEY.
TYPES: BEGIN OF address,
country TYPE char30,
county TYPE char30,
city TYPE char50,
streetAddress TYPE string,
latitude TYPE dec015,
longitude TYPE dec015,
zipcode TYPE int4,
END OF address.
TYPES: BEGIN OF ls_user,
mandt TYPE mandt,
id TYPE num05_kk2,
uuid TYPE sysuuid_c36,
firstName TYPE char30,
lastName TYPE char30,
fullName TYPE char50,
gender TYPE char10,
username TYPE char30,
email TYPE ad_smtpadr,
avatar TYPE string,
password TYPE char50,
birthdate TYPE char10,
registeredAt TYPE char30,
phone TYPE char30,
jobTitle TYPE char50,
jobType TYPE char30,
profileInfo TYPE string,
address TYPE address,
* country TYPE address-city,
* county TYPE address-county,
* city TYPE address-city,
* streetAddress TYPE address-streetaddress,
* latitude TYPE address-latitude,
* longitude TYPE address-longitude,
* zipcode TYPE address-zipcode,
* maybe TYPE char30,
END OF ls_user.
DATA lt_user TYPE STANDARD TABLE OF ls_user WITH NON-UNIQUE DEFAULT KEY.
DATA lv_dauer TYPE i.
*TYPES user_table TYPE STANDARD TABLE OF ls_user WITH NON-UNIQUE DEFAULT KEY.
DATA wa_user TYPE ls_user.
DATA(lv_json) =
`[{"id":1,"uuid":"3423e00f-b5c2-4f2c-bf88-baceca11c5f4","firstName":"Isabel",...}]
* JSON -> ABAP (iTab)
/ui2/cl_json=>deserialize(
EXPORTING
json = lv_json
* jsonx =
pretty_name = /ui2/cl_json=>pretty_mode-camel_case
* assoc_arrays =
* assoc_arrays_opt =
* name_mappings =
* conversion_exits =
* hex_as_base64 =
CHANGING
data = lt_user
).
*cl_demo_output=>write_data( lv_json ).
cl_demo_output=>write_data( lt_user[ 4 ] ).
*
cl_demo_output=>write_data( lt_user[ 5 ]-jobtitle ).
cl_demo_output=>display( lt_user[ 6 ]-profileinfo ).
*
DELETE FROM zalm_fs_users.
*
GET RUN TIME FIELD lv_dauer.
*
*
*INSERT zalm_fs_users FROM TABLE lt_user. "ACCEPTING DUPLICATE KEYS.
*
DATA: zalm_local_user TYPE zalm_fs_users.
*LOOP AT lt_user into DATA(lv_user).
* zalm_local_user-avatar = lv_user-avatar.
** INSERT zalm_fs_todos from lv_user. "Loop in Workarea
*ENDLOOP.
**
** loop at lt_todo assigning <fs_todo>. "Loop mit Field-Symbol
** INSERT zalm_fs_todos from <fs_todo>.
**endloop.
*
*
GET RUN TIME FIELD lv_dauer.
WRITE lv_dauer.
In debug it shows me address field as nested object:
And the output shows "kind of" nested internal table type address when printing it out:
and in the SEGW as well, there seems to exist the type "complex type", which is an object/structure without a primary key that you can insert into another structure (or table?, not sure about that)... How can I now insert my nested typeds into my users table? or is it not possible, so I would have to flatte my structures again?
And btw, are the "entity types" that I create in SEGW different from the ddict table types? Because I assume the entity types (or instances of entities) are store in entity tables in some way.. are they a different concept than ddict tables? I usually also create my entity types by importing them from ddict tables... so I am just wondering.
I found out the answer to my problem.. (already some time ago, forgot about this thread ;)).
So to address the named "address" structure type included in your working area internal table on the DDIC physical table.. there is a column "GROUP" in the DDIC table, where you can give your includes a "group name". So in this case, it can be recognised as the named structure "address" type when you insert the data into the ddic table.