*********************************************************************** *EXAMPLE LOAD PROGRAM FOR TABLE T5J65 USING US DEPT EDUCATION DATA *NCES - IPEDS - IC (Institutional Characteristics) *********************************************************************** REPORT zhr_load_schools . *********************************************************************** *IMPORTANT NOTES: *********************************************************************** *This program assumes that the SLART field values used have already been *configured in table T517T and T517X. *---------------------------------------------------------------------* *This program assumes that the CSV file being uploaded has been *reduced down to the fields named in SCHOOL_TYPE created in the TYPES *section of this program. *-N.B.----------------------------------------------------------------* *The original IPEDS IC CSV file should be edited with Excel to *eliminate any columns that will not be actively used to determine *the institution type(s) for each record *---------------------------------------------------------------------* *IMPORTANT!!! *The edited version should be saved in the same format as origial file *i.e. CSV *********************************************************************** TABLES: t5j65. TYPES: *Layout of our working storage structure BEGIN OF school_type, unitid TYPE p22j_schcd, "REQUIRED instnm TYPE insti, "REQUIRED sector(2) TYPE c, "REQUIRED IF SETTING T5J65-INSTP iclevel(2) TYPE c, "OPTIONAL BUT VERY USEFUL medical(2) TYPE c, "OPTIONAL END OF school_type, *Generic line for upload of edited IPEDS-IC data from workstation BEGIN OF itype, line(8000), END OF itype. DATA: *Upload table and line itab TYPE STANDARD TABLE OF itype, ilin TYPE itype, *Delimiter used in SPLIT command (CSV comma delimited) delimiter TYPE c VALUE ',', *Working storage table and line school_tab TYPE STANDARD TABLE OF school_type, school_lin TYPE school_type, *Table and line used to insert data into T5J65 i5j65 TYPE STANDARD TABLE OF t5j65, l5j65 TYPE t5j65, *Counters w_total TYPE i, w_t5j65 TYPE i. START-OF-SELECTION. PERFORM read_file. PERFORM load_dept_education. END-OF-SELECTION. WRITE: / 'Total', w_total, 'Records read in.'. WRITE: / 'Total', w_t5j65, 'Records loaded to T5J65'. *---------------------------------------------------------------------* * FORM READ_FILE * *---------------------------------------------------------------------* * ........ * *---------------------------------------------------------------------* FORM read_file. *Will automatically prompt for filename and path CALL FUNCTION 'UPLOAD' EXPORTING filename = 'C:\' filetype = 'ASC' TABLES data_tab = itab EXCEPTIONS conversion_error = 1 invalid_table_width = 2 invalid_type = 3 no_batch = 4 unknown_error = 5 OTHERS = 6. IF sy-subrc NE 0. EXIT. ENDIF. LOOP AT itab INTO ilin. SPLIT ilin-line AT delimiter INTO school_lin-unitid school_lin-instnm school_lin-sector school_lin-iclevel school_lin-medical. *Skip column headings if present IF school_lin-unitid CN '0123456789 '. CONTINUE. ENDIF. APPEND school_lin TO school_tab. ENDLOOP. ENDFORM. " READ_FILE *---------------------------------------------------------------------* * FORM LOAD_DEPT_EDUCATION * *---------------------------------------------------------------------* * ........ * *---------------------------------------------------------------------* FORM load_dept_education. *CLEAR PREVIOUS ENTRIES FOR OUR SLART CODES *************************** DELETE FROM t5j65 *SUGGESTED CUSTOM CONFIGE SLART CODES T517T & T517Z * WHERE slart = 'UN' * OR slart = 'CC' * OR slart = 'TR' * OR slart = 'MD' *Existing SLART codes where slart = '50' or slart = '51' or slart = '52'. *LOOP****************************************************************** LOOP AT school_tab INTO school_lin. ADD 1 TO w_total. CLEAR l5j65. *IMPORTANT! - USE UNPACK TO GET LEADING ZEROS!!!! ********************* UNPACK school_lin-unitid TO l5j65-schcd. *********************************************************************** l5j65-insti = school_lin-instnm. l5j65-instk = space. *********************************************************************** *SET T5J65-INSTP - Type of institution/school *********************************************************************** * Control table = T5J66 *Options are: * 1 national * 2 public * 3 private CASE school_lin-sector. WHEN '0'. "Administrative Unit Only *May wish to skip if this institution record is Admin only!!!! * CONTINUE l5j65-instp = space. WHEN '1'. "Public, 4 year or above l5j65-instp = '2'. WHEN '2'. "Private not-for-profit, 4-year or above l5j65-instp = '3'. WHEN '3'. "Private for-profit, 4-year or above l5j65-instp = '3'. WHEN '4'. "Public, 2-year l5j65-instp = '2'. WHEN '5'. "Private not-for-profit, 2-year l5j65-instp = '3'. WHEN '6'. "Private for-profit, 2-year l5j65-instp = '3'. WHEN '7'. "Public, less than 2-year l5j65-instp = '2'. WHEN '8'. "Private not-for-profit, less than 2-year l5j65-instp = '3'. WHEN '9'. "Private for-profit, less than 2-year l5j65-instp = '3'. WHEN '99'. "Sector unknown (not active) l5j65-instp = space. ENDCASE. *********************************************************************** *********************************************************************** *Degree granting type classification - ICLEVEL *********************************************************************** IF school_lin-iclevel = '1'. "Full 4yr+ degree(s) University *SUGGESTED CUSTOM SLART * l5j65-slart = 'UN'. *Existing SLART l5j65-slart = '50'. APPEND l5j65 TO i5j65. ADD 1 TO w_t5j65. ENDIF. IF school_lin-iclevel = '2'. "Community college 2yr degree *SUGGESTED CUSTOM SLART * l5j65-slart = 'CC'. *Existing SLART l5j65-slart = '51'. APPEND l5j65 TO i5j65. ADD 1 TO w_t5j65. ENDIF. IF school_lin-iclevel = '3'. "Trade school less than 2yr degree *SUGGESTED CUSTOM SLART * l5j65-slart = 'TR'. *Existing SLART l5j65-slart = '52'. APPEND l5j65 TO i5j65. ADD 1 TO w_t5j65. ENDIF. *********************************************************************** ************************************************************************ **If has Medical school add to list of Medical schools ************************************************************************ * IF school_lin-medical = '1'. "Medical school * l5j65-slart = 'MD'. * APPEND l5j65 TO i5j65. * ADD 1 TO w_t5j65. * ENDIF. ************************************************************************ ENDLOOP. *LOAD TABLE T5J65 ***************************************************** INSERT t5j65 FROM TABLE i5j65. *********************************************************************** ENDFORM. " LOAD_DEPT_EDUCATION_FILE