100 likes | 191 Views
ERP I1, Session 6. Working with Data. A data model. A table. Types and tables. show_wa TYPE yshows , show_tab TYPE HASHED TABLE OF yshows WITH UNIQUE KEY id , room_wa TYPE yroom ,. Inserting into tables. show_wa -id = 1. show_wa -title = 'Shrek 1'.
E N D
ERP I1, Session 6 Working with Data
Types and tables show_wa TYPE yshows, show_tab TYPE HASHED TABLE OF yshows WITH UNIQUE KEY id, room_wa TYPE yroom,
Inserting into tables show_wa-id = 1. show_wa-title = 'Shrek 1'. show_wa-author = 'William Sheik'. INSERTshow_wa INTO TABLE show_tab. TRY.DELETE FROM yshows.INSERTyshows FROM TABLE show_tab CATCH cx_sy_open_sql_db. MESSAGE 'Database error.' TYPE 'E'. ENDTRY.
Reading from tables TYPES: BEGIN OF program, title TYPE c LENGTH 50,playing_date TYPE d,playing_time TYPE t, room TYPE c LENGTH 50,END OF program. DATA: program_wa TYPE program.
Reading from tables (cont.) SELECTs~title sch~playing_date sch~playing_time r~name AS room r~seats FROMyshows AS s INNER JOIN yschedule AS sch ONsch~show_id = s~idINNER JOIN yroom AS r ONsch~room_id = r~idINTO CORRESPONDING FIELDS OF program_wa.WRITE: / program_wa-title, program_wa-playing_date, program_wa-playing_time, program_wa-room. ENDSELECT.
Creating objects DATA: room TYPE REF TO ycl_room, room = yca_room=>agent->create_persistent(i_id = 1i_name = 'Theatre 1'i_seats = 500 ). COMMIT WORK.
Reading objects DATA: query_manager TYPE REF TO if_os_query_manager,query TYPE REF TO if_os_query,agent TYPE REF TO if_os_ca_persistency,result TYPE osreftab, query_manager = cl_os_system=>get_query_manager( ). query = query_manager->create_query( i_filter = 'SEATS >= PAR1' ). agent = yca_room=>agent. result = agent->get_persistent_by_query( i_query = query i_par1 = 500 ).
Looping through the result DATA:obj TYPE REF TO object, room TYPE REF TO ycl_room, LOOP AT result INTO obj. room ?= obj.name = room->get_name( ).seats = room->get_seats( ).WRITE: / name, seats. ENDLOOP.